Skip to content

Commit 8004d18

Browse files
committed
Spine Runtime update to latest version.
1 parent b9c47d8 commit 8004d18

17 files changed

+1004
-370
lines changed

blade-engine-spine-plugin/src/main/java/com/esotericsoftware/spine/Animation.java

Lines changed: 191 additions & 91 deletions
Large diffs are not rendered by default.

blade-engine-spine-plugin/src/main/java/com/esotericsoftware/spine/Bone.java

Lines changed: 93 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,17 @@
3131

3232
package com.esotericsoftware.spine;
3333

34+
import static com.badlogic.gdx.math.MathUtils.*;
3435
import static com.badlogic.gdx.math.Matrix3.*;
3536

36-
import com.badlogic.gdx.math.MathUtils;
3737
import com.badlogic.gdx.math.Matrix3;
3838
import com.badlogic.gdx.math.Vector2;
3939

4040
public class Bone implements Updatable {
4141
final BoneData data;
4242
final Skeleton skeleton;
4343
final Bone parent;
44-
float x, y, rotation, scaleX, scaleY;
44+
float x, y, rotation, scaleX, scaleY, shearX, shearY;
4545
float appliedRotation, appliedScaleX, appliedScaleY;
4646

4747
float a, b, worldX;
@@ -76,26 +76,30 @@ public Bone (Bone bone, Skeleton skeleton, Bone parent) {
7676
rotation = bone.rotation;
7777
scaleX = bone.scaleX;
7878
scaleY = bone.scaleY;
79+
shearX = bone.shearX;
80+
shearY = bone.shearY;
7981
}
8082

8183
/** Same as {@link #updateWorldTransform()}. This method exists for Bone to implement {@link Updatable}. */
8284
public void update () {
83-
updateWorldTransform(x, y, rotation, scaleX, scaleY);
85+
updateWorldTransform(x, y, rotation, scaleX, scaleY, shearX, shearY);
8486
}
8587

8688
/** Computes the world SRT using the parent bone and this bone's local SRT. */
8789
public void updateWorldTransform () {
88-
updateWorldTransform(x, y, rotation, scaleX, scaleY);
90+
updateWorldTransform(x, y, rotation, scaleX, scaleY, shearX, shearY);
8991
}
9092

9193
/** Computes the world SRT using the parent bone and the specified local SRT. */
92-
public void updateWorldTransform (float x, float y, float rotation, float scaleX, float scaleY) {
94+
public void updateWorldTransform (float x, float y, float rotation, float scaleX, float scaleY, float shearX, float shearY) {
9395
appliedRotation = rotation;
9496
appliedScaleX = scaleX;
9597
appliedScaleY = scaleY;
9698

97-
float cos = MathUtils.cosDeg(rotation), sin = MathUtils.sinDeg(rotation);
98-
float la = cos * scaleX, lb = -sin * scaleY, lc = sin * scaleX, ld = cos * scaleY;
99+
float rotationY = rotation + 90 + shearY;
100+
float la = cosDeg(rotation + shearX) * scaleX, lb = cosDeg(rotationY) * scaleY;
101+
float lc = sinDeg(rotation + shearX) * scaleX, ld = sinDeg(rotationY) * scaleY;
102+
99103
Bone parent = this.parent;
100104
if (parent == null) { // Root bone.
101105
Skeleton skeleton = this.skeleton;
@@ -131,68 +135,67 @@ public void updateWorldTransform (float x, float y, float rotation, float scaleX
131135
b = pa * lb + pb * ld;
132136
c = pc * la + pd * lc;
133137
d = pc * lb + pd * ld;
134-
} else if (data.inheritRotation) { // No scale inheritance.
135-
pa = 1;
136-
pb = 0;
137-
pc = 0;
138-
pd = 1;
139-
do {
140-
cos = MathUtils.cosDeg(parent.appliedRotation);
141-
sin = MathUtils.sinDeg(parent.appliedRotation);
142-
float temp = pa * cos + pb * sin;
143-
pb = pa * -sin + pb * cos;
144-
pa = temp;
145-
temp = pc * cos + pd * sin;
146-
pd = pc * -sin + pd * cos;
147-
pc = temp;
148-
parent = parent.parent;
149-
} while (parent != null);
150-
a = pa * la + pb * lc;
151-
b = pa * lb + pb * ld;
152-
c = pc * la + pd * lc;
153-
d = pc * lb + pd * ld;
154-
if (skeleton.flipX) {
155-
a = -a;
156-
b = -b;
157-
}
158-
if (skeleton.flipY) {
159-
c = -c;
160-
d = -d;
138+
} else {
139+
if (data.inheritRotation) { // No scale inheritance.
140+
pa = 1;
141+
pb = 0;
142+
pc = 0;
143+
pd = 1;
144+
do {
145+
float cos = cosDeg(parent.appliedRotation), sin = sinDeg(parent.appliedRotation);
146+
float temp = pa * cos + pb * sin;
147+
pb = pa * -sin + pb * cos;
148+
pa = temp;
149+
temp = pc * cos + pd * sin;
150+
pd = pc * -sin + pd * cos;
151+
pc = temp;
152+
153+
if (!parent.data.inheritRotation) break;
154+
parent = parent.parent;
155+
} while (parent != null);
156+
a = pa * la + pb * lc;
157+
b = pa * lb + pb * ld;
158+
c = pc * la + pd * lc;
159+
d = pc * lb + pd * ld;
160+
} else if (data.inheritScale) { // No rotation inheritance.
161+
pa = 1;
162+
pb = 0;
163+
pc = 0;
164+
pd = 1;
165+
do {
166+
float r = parent.appliedRotation, cos = cosDeg(r), sin = sinDeg(r);
167+
float psx = parent.appliedScaleX, psy = parent.appliedScaleY;
168+
float za = cos * psx, zb = -sin * psy, zc = sin * psx, zd = cos * psy;
169+
float temp = pa * za + pb * zc;
170+
pb = pa * zb + pb * zd;
171+
pa = temp;
172+
temp = pc * za + pd * zc;
173+
pd = pc * zb + pd * zd;
174+
pc = temp;
175+
176+
if (psx < 0) r = -r;
177+
cos = cosDeg(-r);
178+
sin = sinDeg(-r);
179+
temp = pa * cos + pb * sin;
180+
pb = pa * -sin + pb * cos;
181+
pa = temp;
182+
temp = pc * cos + pd * sin;
183+
pd = pc * -sin + pd * cos;
184+
pc = temp;
185+
186+
if (!parent.data.inheritScale) break;
187+
parent = parent.parent;
188+
} while (parent != null);
189+
a = pa * la + pb * lc;
190+
b = pa * lb + pb * ld;
191+
c = pc * la + pd * lc;
192+
d = pc * lb + pd * ld;
193+
} else {
194+
a = la;
195+
b = lb;
196+
c = lc;
197+
d = ld;
161198
}
162-
} else if (data.inheritScale) { // No rotation inheritance.
163-
pa = 1;
164-
pb = 0;
165-
pc = 0;
166-
pd = 1;
167-
do {
168-
float r = parent.rotation;
169-
cos = MathUtils.cosDeg(r);
170-
sin = MathUtils.sinDeg(r);
171-
float psx = parent.appliedScaleX, psy = parent.appliedScaleY;
172-
float za = cos * psx, zb = -sin * psy, zc = sin * psx, zd = cos * psy;
173-
float temp = pa * za + pb * zc;
174-
pb = pa * zb + pb * zd;
175-
pa = temp;
176-
temp = pc * za + pd * zc;
177-
pd = pc * zb + pd * zd;
178-
pc = temp;
179-
180-
if (psx < 0) r = -r;
181-
cos = MathUtils.cosDeg(-r);
182-
sin = MathUtils.sinDeg(-r);
183-
temp = pa * cos + pb * sin;
184-
pb = pa * -sin + pb * cos;
185-
pa = temp;
186-
temp = pc * cos + pd * sin;
187-
pd = pc * -sin + pd * cos;
188-
pc = temp;
189-
190-
parent = parent.parent;
191-
} while (parent != null);
192-
a = pa * la + pb * lc;
193-
b = pa * lb + pb * ld;
194-
c = pc * la + pd * lc;
195-
d = pc * lb + pd * ld;
196199
if (skeleton.flipX) {
197200
a = -a;
198201
b = -b;
@@ -201,11 +204,6 @@ public void updateWorldTransform (float x, float y, float rotation, float scaleX
201204
c = -c;
202205
d = -d;
203206
}
204-
} else {
205-
a = la;
206-
b = lb;
207-
c = lc;
208-
d = ld;
209207
}
210208
}
211209

@@ -216,6 +214,8 @@ public void setToSetupPose () {
216214
rotation = data.rotation;
217215
scaleX = data.scaleX;
218216
scaleY = data.scaleY;
217+
shearX = data.shearX;
218+
shearY = data.shearY;
219219
}
220220

221221
public BoneData getData () {
@@ -251,7 +251,6 @@ public void setPosition (float x, float y) {
251251
this.y = y;
252252
}
253253

254-
/** Returns the forward kinetics rotation. */
255254
public float getRotation () {
256255
return rotation;
257256
}
@@ -286,6 +285,22 @@ public void setScale (float scale) {
286285
scaleY = scale;
287286
}
288287

288+
public float getShearX () {
289+
return shearX;
290+
}
291+
292+
public void setShearX (float shearX) {
293+
this.shearX = shearX;
294+
}
295+
296+
public float getShearY () {
297+
return shearY;
298+
}
299+
300+
public void setShearY (float shearY) {
301+
this.shearY = shearY;
302+
}
303+
289304
public float getA () {
290305
return a;
291306
}
@@ -319,11 +334,11 @@ public float getWorldSignY () {
319334
}
320335

321336
public float getWorldRotationX () {
322-
return MathUtils.atan2(c, a) * MathUtils.radDeg;
337+
return atan2(c, a) * radDeg;
323338
}
324339

325340
public float getWorldRotationY () {
326-
return MathUtils.atan2(d, b) * MathUtils.radDeg;
341+
return atan2(d, b) * radDeg;
327342
}
328343

329344
public float getWorldScaleX () {
@@ -353,8 +368,8 @@ public Vector2 worldToLocal (Vector2 world) {
353368
float x = world.x - worldX, y = world.y - worldY;
354369
float a = this.a, b = this.b, c = this.c, d = this.d;
355370
float invDet = 1 / (a * d - b * c);
356-
world.x = (x * a * invDet - y * b * invDet);
357-
world.y = (y * d * invDet - x * c * invDet);
371+
world.x = (x * d * invDet - y * b * invDet);
372+
world.y = (y * a * invDet - x * c * invDet);
358373
return world;
359374
}
360375

blade-engine-spine-plugin/src/main/java/com/esotericsoftware/spine/BoneData.java

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ public class BoneData {
3737
final BoneData parent;
3838
final String name;
3939
float length;
40-
float x, y;
41-
float rotation;
42-
float scaleX = 1, scaleY = 1;
40+
float x, y, rotation, scaleX = 1, scaleY = 1, shearX, shearY;
4341
boolean inheritScale = true, inheritRotation = true;
4442

4543
// Nonessential.
@@ -64,6 +62,8 @@ public BoneData (BoneData bone, BoneData parent) {
6462
rotation = bone.rotation;
6563
scaleX = bone.scaleX;
6664
scaleY = bone.scaleY;
65+
shearX = bone.shearX;
66+
shearY = bone.shearY;
6767
}
6868

6969
/** @return May be null. */
@@ -133,6 +133,22 @@ public void setScale (float scaleX, float scaleY) {
133133
this.scaleY = scaleY;
134134
}
135135

136+
public float getShearX () {
137+
return shearX;
138+
}
139+
140+
public void setShearX (float shearX) {
141+
this.shearX = shearX;
142+
}
143+
144+
public float getShearY () {
145+
return shearY;
146+
}
147+
148+
public void setShearY (float shearY) {
149+
this.shearY = shearY;
150+
}
151+
136152
public boolean getInheritScale () {
137153
return inheritScale;
138154
}

0 commit comments

Comments
 (0)