Skip to content

Commit

Permalink
[haxe][flixel] Fix rotation for clipped attachments.
Browse files Browse the repository at this point in the history
  • Loading branch information
davidetan committed Jul 21, 2024
1 parent a2f82a2 commit b68d59e
Showing 1 changed file with 30 additions and 7 deletions.
37 changes: 30 additions & 7 deletions spine-haxe/spine-haxe/spine/flixel/SkeletonSprite.hx
Original file line number Diff line number Diff line change
Expand Up @@ -225,36 +225,59 @@ class SkeletonSprite extends FlxObject

if (clipper.isClipping()) {
clipper.clipTriangles(worldVertices, triangles, triangles.length, uvs);
mesh.vertices = Vector.ofArray(clipper.clippedVertices);

mesh.indices = Vector.ofArray(clipper.clippedTriangles);
mesh.uvtData = Vector.ofArray(clipper.clippedUvs);

if (angle == 0) {
mesh.vertices = Vector.ofArray(clipper.clippedVertices);
mesh.x = x + offsetX;
mesh.y = y + offsetY;
} else {
var i = 0;
mesh.vertices.length = clipper.clippedVertices.length;
while (i < mesh.vertices.length) {
_tempPoint.setTo(clipper.clippedVertices[i], clipper.clippedVertices[i + 1]);
_tempPoint = _tempMatrix.transformPoint(_tempPoint);
mesh.vertices[i] = _tempPoint.x;
mesh.vertices[i + 1] = _tempPoint.y;
i+=2;
}
}
} else {
var v = 0;
var n = numFloats;
var i = 0;
mesh.vertices.length = numVertices;
while (v < n) {
// if (angle != 0) {
if (angle == 0) {
mesh.vertices[i] = worldVertices[v];
mesh.vertices[i + 1] = worldVertices[v + 1];
} else {
_tempPoint.setTo(worldVertices[v], worldVertices[v + 1]);
_tempPoint = _tempMatrix.transformPoint(_tempPoint);
mesh.vertices[i] = _tempPoint.x;
mesh.vertices[i + 1] = _tempPoint.y;
// } else {
// mesh.vertices[i] = worldVertices[v];
// mesh.vertices[i + 1] = worldVertices[v + 1];
// }
}
v += 8;
i += 2;
}
if (angle == 0) {
mesh.x = x + offsetX;
mesh.y = y + offsetY;
}
mesh.indices = Vector.ofArray(triangles);
mesh.uvtData = Vector.ofArray(uvs);
}

mesh.antialiasing = antialiasing;
mesh.blend = SpineTexture.toFlixelBlending(slot.data.blendMode);
// x/y position works for mesh, but angle does not work.
// if the transformation matrix is moved into the FlxStrip draw and used there
// we can just put vertices without doing any transformation
// mesh.x = x + offsetX;
// mesh.y = y + offsetY;
mesh.angle = angle;
// mesh.angle = angle;
mesh.draw();
}

Expand Down

0 comments on commit b68d59e

Please sign in to comment.