Skip to content

Commit 72e75f3

Browse files
committed
adapts uvs
1 parent bf393b9 commit 72e75f3

File tree

3 files changed

+27
-21
lines changed

3 files changed

+27
-21
lines changed

Diff for: extensions/spine/CCSkeleton.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,10 @@ sp.ATTACHMENT_TYPE = {
5656
REGION: 0,
5757
BOUNDING_BOX: 1,
5858
MESH: 2,
59-
SKINNED_MESH:3
59+
SKINNED_MESH:3,
60+
PATH:4,
61+
POINT:5,
62+
CLIPPING:6
6063
};
6164

6265
var spine = sp.spine;

Diff for: extensions/spine/CCSkeletonCanvasRenderCmd.js

+5-6
Original file line numberDiff line numberDiff line change
@@ -115,15 +115,14 @@ proto._updateRegionAttachmentSlot = function (attachment, slot, points) {
115115
if (!points)
116116
return;
117117

118-
// 3.5 var vertices = attachment.updateWorldVertices(slot, false);
119118
var vertices = spine.Utils.setArraySize(new Array(), 8, 0);
120-
attachment.computeWorldVertices(slot.bone, vertices, 0, 8);
119+
attachment.computeWorldVertices(slot.bone, vertices, 0, 2);
121120
var VERTEX = spine.RegionAttachment;
122121
points.length = 0;
123-
points.push(cc.p(vertices[VERTEX.X1], vertices[VERTEX.Y1]));
124-
points.push(cc.p(vertices[VERTEX.X4], vertices[VERTEX.Y4]));
125-
points.push(cc.p(vertices[VERTEX.X3], vertices[VERTEX.Y3]));
126-
points.push(cc.p(vertices[VERTEX.X2], vertices[VERTEX.Y2]));
122+
points.push(cc.p(vertices[VERTEX.OX1], vertices[VERTEX.OY1]));
123+
points.push(cc.p(vertices[VERTEX.OX4], vertices[VERTEX.OY4]));
124+
points.push(cc.p(vertices[VERTEX.OX3], vertices[VERTEX.OY3]));
125+
points.push(cc.p(vertices[VERTEX.OX2], vertices[VERTEX.OY2]));
127126
};
128127

129128
proto._createChildFormSkeletonData = function () {

Diff for: extensions/spine/CCSkeletonWebGLRenderCmd.js

+18-14
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,12 @@ proto._uploadRegionAttachmentData = function(attachment, slot, premultipliedAlph
234234
nodeB = nodeColor.b,
235235
nodeA = this._displayedOpacity;
236236
// 3.5 var vertices = attachment.updateWorldVertices(slot, premultipliedAlpha);
237-
// FIXME: lose premultipliedAlpha?
237+
// FIXME: lose premultipliedAlpha? alpha impl innner, "vertices, 0, 8);" -> "vertices, 0, 2);"
238238
var vertices = spine.Utils.setArraySize(new Array(), 8, 0);
239-
attachment.computeWorldVertices(slot.bone, vertices, 0, 8);
239+
attachment.computeWorldVertices(slot.bone, vertices, 0, 2);
240+
241+
var uvs = attachment.uvs;
242+
var color = attachment.color;
240243

241244
var wt = this._worldTransform,
242245
wa = wt.a, wb = wt.b, wc = wt.c, wd = wt.d,
@@ -248,32 +251,32 @@ proto._uploadRegionAttachmentData = function(attachment, slot, premultipliedAlph
248251
// using two angles : (0, 1, 2) & (0, 2, 3)
249252
for (var i = 0; i < 6; i++) {
250253
var srcIdx = i < 4 ? i % 3 : i - 2;
251-
var vx = vertices[srcIdx * 8],
252-
vy = vertices[srcIdx * 8 + 1];
254+
var vx = vertices[srcIdx * 2],
255+
vy = vertices[srcIdx * 2 + 1];
253256
var x = vx * wa + vy * wc + wx,
254257
y = vx * wb + vy * wd + wy;
255-
var r = vertices[srcIdx * 8 + 2] * nodeR,
256-
g = vertices[srcIdx * 8 + 3] * nodeG,
257-
b = vertices[srcIdx * 8 + 4] * nodeB,
258-
a = vertices[srcIdx * 8 + 5] * nodeA;
258+
var r = color.r * nodeR,
259+
g = color.g * nodeG,
260+
b = color.b * nodeB,
261+
a = color.a * nodeA;
259262
var color = ((a<<24) | (b<<16) | (g<<8) | r);
260263
f32buffer[offset] = x;
261264
f32buffer[offset + 1] = y;
262265
f32buffer[offset + 2] = z;
263266
ui32buffer[offset + 3] = color;
264-
f32buffer[offset + 4] = vertices[srcIdx * 8 + 6];
265-
f32buffer[offset + 5] = vertices[srcIdx * 8 + 7];
267+
f32buffer[offset + 4] = uvs[srcIdx * 2];
268+
f32buffer[offset + 5] = uvs[srcIdx * 2 + 1];
266269
offset += 6;
267270
}
268271

269272
if (this._node._debugSlots) {
270273
// return the quad points info if debug slot enabled
271274
var VERTEX = spine.RegionAttachment;
272275
return [
273-
cc.p(vertices[VERTEX.X1], vertices[VERTEX.Y1]),
274-
cc.p(vertices[VERTEX.X2], vertices[VERTEX.Y2]),
275-
cc.p(vertices[VERTEX.X3], vertices[VERTEX.Y3]),
276-
cc.p(vertices[VERTEX.X4], vertices[VERTEX.Y4])
276+
cc.p(vertices[VERTEX.OX1], vertices[VERTEX.OY1]),
277+
cc.p(vertices[VERTEX.OX2], vertices[VERTEX.OY2]),
278+
cc.p(vertices[VERTEX.OX3], vertices[VERTEX.OY3]),
279+
cc.p(vertices[VERTEX.OX4], vertices[VERTEX.OY4])
277280
];
278281
}
279282
};
@@ -285,6 +288,7 @@ proto._uploadMeshAttachmentData = function(attachment, slot, premultipliedAlpha,
285288
z = this._node.vertexZ;
286289
// get the vertex data
287290
// 3.5 var vertices = attachment.updateWorldVertices(slot, premultipliedAlpha);
291+
// FIXME, NOT USED THIS FUNCTION?
288292
var verticesLength = attachment.worldVerticesLength;
289293
var vertices = spine.Utils.setArraySize(new Array(), verticesLength, 0);
290294
attachment.computeWorldVertices(slot, 0, verticesLength, vertices, 0, 2);

0 commit comments

Comments
 (0)