37
37
import com .badlogic .gdx .utils .Array ;
38
38
import com .badlogic .gdx .utils .Null ;
39
39
40
- import com .esotericsoftware .spine .BoneData .TransformMode ;
40
+ import com .esotericsoftware .spine .BoneData .Inherit ;
41
41
import com .esotericsoftware .spine .Skeleton .Physics ;
42
42
43
43
/** Stores a bone's current pose.
@@ -54,6 +54,7 @@ public class Bone implements Updatable {
54
54
float ax , ay , arotation , ascaleX , ascaleY , ashearX , ashearY ;
55
55
float a , b , worldX ;
56
56
float c , d , worldY ;
57
+ Inherit inherit ;
57
58
58
59
boolean sorted , active ;
59
60
@@ -80,6 +81,7 @@ public Bone (Bone bone, Skeleton skeleton, @Null Bone parent) {
80
81
scaleY = bone .scaleY ;
81
82
shearX = bone .shearX ;
82
83
shearY = bone .shearY ;
84
+ inherit = bone .inherit ;
83
85
}
84
86
85
87
/** Computes the world transform using the parent bone and this bone's local applied transform. */
@@ -127,7 +129,7 @@ public void updateWorldTransform (float x, float y, float rotation, float scaleX
127
129
worldX = pa * x + pb * y + parent .worldX ;
128
130
worldY = pc * x + pd * y + parent .worldY ;
129
131
130
- switch (data . transformMode ) {
132
+ switch (inherit ) {
131
133
case normal : {
132
134
float rx = (rotation + shearX ) * degRad ;
133
135
float ry = (rotation + 90 + shearY ) * degRad ;
@@ -187,8 +189,7 @@ public void updateWorldTransform (float x, float y, float rotation, float scaleX
187
189
za *= s ;
188
190
zc *= s ;
189
191
s = (float )Math .sqrt (za * za + zc * zc );
190
- if (data .transformMode == TransformMode .noScale
191
- && (pa * pd - pb * pc < 0 ) != (skeleton .scaleX < 0 != skeleton .scaleY < 0 )) s = -s ;
192
+ if (inherit == Inherit .noScale && (pa * pd - pb * pc < 0 ) != (skeleton .scaleX < 0 != skeleton .scaleY < 0 )) s = -s ;
192
193
rotation = PI / 2 + atan2 (zc , za );
193
194
float zb = cos (rotation ) * s ;
194
195
float zd = sin (rotation ) * s ;
@@ -219,6 +220,7 @@ public void setToSetupPose () {
219
220
scaleY = data .scaleY ;
220
221
shearX = data .shearX ;
221
222
shearY = data .shearY ;
223
+ inherit = data .inherit ;
222
224
}
223
225
224
226
/** The bone's setup pose data. */
@@ -325,6 +327,16 @@ public void setShearY (float shearY) {
325
327
this .shearY = shearY ;
326
328
}
327
329
330
+ /** Controls how parent world transforms affect this bone. */
331
+ public Inherit getInherit () {
332
+ return inherit ;
333
+ }
334
+
335
+ public void setInherit (Inherit inherit ) {
336
+ if (inherit == null ) throw new IllegalArgumentException ("inherit cannot be null." );
337
+ this .inherit = inherit ;
338
+ }
339
+
328
340
// -- Applied transform
329
341
330
342
/** The applied local x translation. */
@@ -420,13 +432,13 @@ public void updateAppliedTransform () {
420
432
ay = (dy * id - dx * ic );
421
433
422
434
float ra , rb , rc , rd ;
423
- if (data . transformMode == TransformMode .onlyTranslation ) {
435
+ if (inherit == Inherit .onlyTranslation ) {
424
436
ra = a ;
425
437
rb = b ;
426
438
rc = c ;
427
439
rd = d ;
428
440
} else {
429
- switch (data . transformMode ) {
441
+ switch (inherit ) {
430
442
case noRotationOrReflection : {
431
443
float s = Math .abs (pa * pd - pb * pc ) / (pa * pa + pc * pc );
432
444
float sa = pa / skeleton .scaleX ;
@@ -448,7 +460,7 @@ public void updateAppliedTransform () {
448
460
pa *= s ;
449
461
pc *= s ;
450
462
s = (float )Math .sqrt (pa * pa + pc * pc );
451
- if (data . transformMode == TransformMode .noScale && pid < 0 != (skeleton .scaleX < 0 != skeleton .scaleY < 0 )) s = -s ;
463
+ if (inherit == Inherit .noScale && pid < 0 != (skeleton .scaleX < 0 != skeleton .scaleY < 0 )) s = -s ;
452
464
r = PI / 2 + atan2 (pc , pa );
453
465
pb = cos (r ) * s ;
454
466
pd = sin (r ) * s ;
0 commit comments