Skip to content

Commit

Permalink
1.41.2 Fix PMA palette bug and more.
Browse files Browse the repository at this point in the history
1.41.2 Fix PMA palette bug, update palette _after_ use, less dependent. Add EntryPalette string expression.
  • Loading branch information
MikalDev committed Mar 23, 2021
1 parent d8d0f1e commit d77a55e
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 3 deletions.
Binary file added dist/Spine-v1.41.2.c3addon
Binary file not shown.
13 changes: 13 additions & 0 deletions src/aces.json
Original file line number Diff line number Diff line change
Expand Up @@ -1062,6 +1062,19 @@
"returnType": "string",
"params": [
]
},
{
"id": "entry-palette-color-string",
"expressionName": "EntryPaletteColorString",
"scriptName": "EntryPaletteColorString",
"highlight": false,
"returnType": "string",
"params": [
{
"id": "palette-number",
"type": "number"
}
]
}
]
}
Expand Down
2 changes: 1 addition & 1 deletion src/addon.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"type": "plugin",
"name": "Spine",
"id": "Gritsenko_Spine",
"version": "1.41.1",
"version": "1.41.2",
"author": "Mikal and Igor Gritsenko",
"website": "https://gritsenko.github.io/c3_spine_plugin",
"documentation": "https://gritsenko.github.io/c3_spine_plugin",
Expand Down
11 changes: 11 additions & 0 deletions src/c3runtime/expressions.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,17 @@
}
return hexString;
},
EntryPaletteColorString(paletteNumber){
if (!this.palette) return "";
let hexString = ""
let paletteEntryOffset = this.palette.indexSize*paletteNumber*4;
for(let i=0;i<this.palette.paletteNumber;i++)
{
const hexValueString = this.palette.palette[paletteEntryOffset+i].toString(16).padStart(2, '0');
hexString = hexString + hexValueString;
}
return hexString;
},
GetValue(pathString){
if(pathString === '') return '';
let path = pathString.split('.');
Expand Down
11 changes: 10 additions & 1 deletion src/c3runtime/spine-draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,13 @@ class SpineBatch {
const skeletonInstance = skeletonInstances[uid];
const palette = skeletonInstance.palette;

/*
if (skeletonInstance.initialized && palette.uploadNeeded)
{
palette.uploadNeeded = false;
palette.upload(gl.TEXTURE1, gl);
}
*/

if (skeletonInstance.initialized
&& (tickCount%this._renderRate == index%this._renderRate)
Expand Down Expand Up @@ -256,6 +258,13 @@ class SpineBatch {
this.batcher.end();
this.shader.unbind();
}

if (skeletonInstance.initialized && palette.uploadNeeded)
{
palette.uploadNeeded = false;
palette.upload(gl.TEXTURE1, gl);
}

index++;
}

Expand Down Expand Up @@ -334,6 +343,6 @@ class SpineBatch {

if (!globalThis.spineBatcher)
{
console.log('[Spine] SpineBatcher init, 1.41.1');
console.log('[Spine] SpineBatcher init, 1.41.2');
globalThis.spineBatcher = new SpineBatch();
}
1 change: 1 addition & 0 deletions src/c3runtime/spine-palette.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ class SpinePalette {
let oldActive = gl.getParameter(gl.ACTIVE_TEXTURE);
let oldTex = gl.getParameter(gl.TEXTURE_BINDING_2D);
gl.activeTexture(textureUnit);
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false);
gl.bindTexture(gl.TEXTURE_2D, this._paletteTexture);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, this.indexSize, this.paletteNumber, 0, gl.RGBA, gl.UNSIGNED_BYTE, this._palette);
gl.activeTexture(oldActive);
Expand Down
10 changes: 10 additions & 0 deletions src/lang/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -994,6 +994,16 @@
"params": {
}
},
"entry-palette-color-string": {
"description": "Entry palette color string",
"translated-name": "EntryPaletteColorString",
"params": {
"palette-number": {
"name": "Palette number",
"desc": "Palette number"
}
}
},
"get-value": {
"description": "Get value at path",
"translated-name": "GetValue",
Expand Down
2 changes: 1 addition & 1 deletion src/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const C3 = self.C3;

const PLUGIN_ID = "Gritsenko_Spine";
const PLUGIN_VERSION = "1.41.1";
const PLUGIN_VERSION = "1.41.2";
const PLUGIN_CATEGORY = "general";

const PLUGIN_CLASS = SDK.Plugins.Gritsenko_Spine = class SpinePlugin extends SDK.IPluginBase {
Expand Down

0 comments on commit d77a55e

Please sign in to comment.