Skip to content

Commit 7241450

Browse files
committed
Fix armature buffer data synchronization issue
1 parent f4a927c commit 7241450

File tree

2 files changed

+38
-10
lines changed

2 files changed

+38
-10
lines changed

extensions/cocostudio/armature/CCArmatureWebGLRenderCmd.js

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,37 @@
163163
currentStack.top = this._stackMatrix;
164164

165165
node.sortAllChildren();
166-
cc.renderer.pushRenderCommand(this);
166+
167+
var renderer = cc.renderer,
168+
children = node._children, child,
169+
i, len = children.length;
170+
171+
for (i = 0; i < len; i++) {
172+
child = children[i];
173+
if (child._localZOrder < 0) {
174+
if (isNaN(child._customZ)) {
175+
child._vertexZ = renderer.assignedZ;
176+
renderer.assignedZ += renderer.assignedZStep;
177+
}
178+
}
179+
else {
180+
break;
181+
}
182+
}
183+
184+
if (isNaN(node._customZ)) {
185+
node._vertexZ = renderer.assignedZ;
186+
renderer.assignedZ += renderer.assignedZStep;
187+
}
188+
renderer.pushRenderCommand(this);
189+
190+
for (; i < len; i++) {
191+
child = children[i];
192+
if (isNaN(child._customZ)) {
193+
child._vertexZ = renderer.assignedZ;
194+
renderer.assignedZ += renderer.assignedZStep;
195+
}
196+
}
167197

168198
this._dirtyFlag = 0;
169199
currentStack.top = currentStack.stack.pop();

extensions/cocostudio/armature/display/CCSkinWebGLRenderCmd.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,8 @@
4545
var node = this._node;
4646
var locQuad = this._quad;
4747
var vertices = this._vertices;
48-
// If it is not visible, or one of its ancestors is not visible, then do nothing:
49-
if (!node._visible)
50-
locQuad.br.vertices = locQuad.tl.vertices = locQuad.tr.vertices = locQuad.bl.vertices = {x: 0, y: 0, z: 0};
51-
else if (this._buffer) {
48+
49+
if (this._buffer) {
5250
//
5351
// calculate the Quad based on the Affine Matrix
5452
//
@@ -86,11 +84,11 @@
8684
if (node.textureAtlas) {
8785
node.textureAtlas.updateQuad(locQuad, node.textureAtlas.getTotalQuads());
8886
}
89-
90-
this._quadDirty = true;
91-
this._savedDirtyFlag = true;
92-
this._bufferDirty = true;
93-
this._buffer.setDirty();
87+
88+
// Need manually buffer data because it's invoked during rendering
89+
cc._renderContext.bindBuffer(gl.ARRAY_BUFFER, this._buffer.vertexBuffer);
90+
cc._renderContext.bufferSubData(gl.ARRAY_BUFFER, this._bufferOffset, this._float32View);
91+
cc._renderContext.bindBuffer(gl.ARRAY_BUFFER, null);
9492
}
9593
};
9694
})();

0 commit comments

Comments
 (0)