|
@@ -52,6 +52,7 @@ namespace Spine {
|
|
|
|
|
|
internal float a, b, worldX;
|
|
internal float a, b, worldX;
|
|
internal float c, d, worldY;
|
|
internal float c, d, worldY;
|
|
|
|
+ internal Inherit inherit;
|
|
|
|
|
|
internal bool sorted, active;
|
|
internal bool sorted, active;
|
|
|
|
|
|
@@ -79,6 +80,9 @@ namespace Spine {
|
|
/// <summary>The local shearY.</summary>
|
|
/// <summary>The local shearY.</summary>
|
|
public float ShearY { get { return shearY; } set { shearY = value; } }
|
|
public float ShearY { get { return shearY; } set { shearY = value; } }
|
|
|
|
|
|
|
|
+ /// <summary>Controls how parent world transforms affect this bone.</summary>
|
|
|
|
+ public Inherit Inherit { get { return inherit; } set { inherit = value; } }
|
|
|
|
+
|
|
/// <summary>The rotation, as calculated by any constraints.</summary>
|
|
/// <summary>The rotation, as calculated by any constraints.</summary>
|
|
public float AppliedRotation { get { return arotation; } set { arotation = value; } }
|
|
public float AppliedRotation { get { return arotation; } set { arotation = value; } }
|
|
|
|
|
|
@@ -147,6 +151,7 @@ namespace Spine {
|
|
scaleY = bone.scaleY;
|
|
scaleY = bone.scaleY;
|
|
shearX = bone.shearX;
|
|
shearX = bone.shearX;
|
|
shearY = bone.shearY;
|
|
shearY = bone.shearY;
|
|
|
|
+ inherit = bone.inherit;
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>Computes the world transform using the parent bone and this bone's local applied transform.</summary>
|
|
/// <summary>Computes the world transform using the parent bone and this bone's local applied transform.</summary>
|
|
@@ -192,8 +197,8 @@ namespace Spine {
|
|
worldX = pa * x + pb * y + parent.worldX;
|
|
worldX = pa * x + pb * y + parent.worldX;
|
|
worldY = pc * x + pd * y + parent.worldY;
|
|
worldY = pc * x + pd * y + parent.worldY;
|
|
|
|
|
|
- switch (data.transformMode) {
|
|
|
|
- case TransformMode.Normal: {
|
|
|
|
|
|
+ switch (inherit) {
|
|
|
|
+ case Inherit.Normal: {
|
|
float rx = (rotation + shearX) * MathUtils.DegRad;
|
|
float rx = (rotation + shearX) * MathUtils.DegRad;
|
|
float ry = (rotation + 90 + shearY) * MathUtils.DegRad;
|
|
float ry = (rotation + 90 + shearY) * MathUtils.DegRad;
|
|
float la = (float)Math.Cos(rx) * scaleX;
|
|
float la = (float)Math.Cos(rx) * scaleX;
|
|
@@ -206,7 +211,7 @@ namespace Spine {
|
|
d = pc * lb + pd * ld;
|
|
d = pc * lb + pd * ld;
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- case TransformMode.OnlyTranslation: {
|
|
|
|
|
|
+ case Inherit.OnlyTranslation: {
|
|
float rx = (rotation + shearX) * MathUtils.DegRad;
|
|
float rx = (rotation + shearX) * MathUtils.DegRad;
|
|
float ry = (rotation + 90 + shearY) * MathUtils.DegRad;
|
|
float ry = (rotation + 90 + shearY) * MathUtils.DegRad;
|
|
a = (float)Math.Cos(rx) * scaleX;
|
|
a = (float)Math.Cos(rx) * scaleX;
|
|
@@ -215,7 +220,7 @@ namespace Spine {
|
|
d = (float)Math.Sin(ry) * scaleY;
|
|
d = (float)Math.Sin(ry) * scaleY;
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
- case TransformMode.NoRotationOrReflection: {
|
|
|
|
|
|
+ case Inherit.NoRotationOrReflection: {
|
|
float s = pa * pa + pc * pc, prx;
|
|
float s = pa * pa + pc * pc, prx;
|
|
if (s > 0.0001f) {
|
|
if (s > 0.0001f) {
|
|
s = Math.Abs(pa * pd - pb * pc) / s;
|
|
s = Math.Abs(pa * pd - pb * pc) / s;
|
|
@@ -241,8 +246,8 @@ namespace Spine {
|
|
d = pc * lb + pd * ld;
|
|
d = pc * lb + pd * ld;
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
- case TransformMode.NoScale:
|
|
|
|
- case TransformMode.NoScaleOrReflection: {
|
|
|
|
|
|
+ case Inherit.NoScale:
|
|
|
|
+ case Inherit.NoScaleOrReflection: {
|
|
rotation *= MathUtils.DegRad;
|
|
rotation *= MathUtils.DegRad;
|
|
float cos = (float)Math.Cos(rotation), sin = (float)Math.Sin(rotation);
|
|
float cos = (float)Math.Cos(rotation), sin = (float)Math.Sin(rotation);
|
|
float za = (pa * cos + pb * sin) / skeleton.scaleX;
|
|
float za = (pa * cos + pb * sin) / skeleton.scaleX;
|
|
@@ -252,8 +257,7 @@ namespace Spine {
|
|
za *= s;
|
|
za *= s;
|
|
zc *= s;
|
|
zc *= s;
|
|
s = (float)Math.Sqrt(za * za + zc * zc);
|
|
s = (float)Math.Sqrt(za * za + zc * zc);
|
|
- if (data.transformMode == TransformMode.NoScale
|
|
|
|
- && (pa * pd - pb * pc < 0) != (skeleton.scaleX < 0 != skeleton.scaleY < 0)) s = -s;
|
|
|
|
|
|
+ if (inherit == Inherit.NoScale && (pa * pd - pb * pc < 0) != (skeleton.scaleX < 0 != skeleton.scaleY < 0)) s = -s;
|
|
rotation = MathUtils.PI / 2 + MathUtils.Atan2(zc, za);
|
|
rotation = MathUtils.PI / 2 + MathUtils.Atan2(zc, za);
|
|
float zb = (float)Math.Cos(rotation) * s;
|
|
float zb = (float)Math.Cos(rotation) * s;
|
|
float zd = (float)Math.Sin(rotation) * s;
|
|
float zd = (float)Math.Sin(rotation) * s;
|
|
@@ -286,6 +290,7 @@ namespace Spine {
|
|
scaleY = data.scaleY;
|
|
scaleY = data.scaleY;
|
|
shearX = data.shearX;
|
|
shearX = data.shearX;
|
|
shearY = data.shearY;
|
|
shearY = data.shearY;
|
|
|
|
+ inherit = data.inherit;
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
@@ -320,14 +325,14 @@ namespace Spine {
|
|
ay = (dy * id - dx * ic);
|
|
ay = (dy * id - dx * ic);
|
|
|
|
|
|
float ra, rb, rc, rd;
|
|
float ra, rb, rc, rd;
|
|
- if (data.transformMode == TransformMode.OnlyTranslation) {
|
|
|
|
|
|
+ if (inherit == Inherit.OnlyTranslation) {
|
|
ra = a;
|
|
ra = a;
|
|
rb = b;
|
|
rb = b;
|
|
rc = c;
|
|
rc = c;
|
|
rd = d;
|
|
rd = d;
|
|
} else {
|
|
} else {
|
|
- switch (data.transformMode) {
|
|
|
|
- case TransformMode.NoRotationOrReflection: {
|
|
|
|
|
|
+ switch (inherit) {
|
|
|
|
+ case Inherit.NoRotationOrReflection: {
|
|
float s = Math.Abs(pa * pd - pb * pc) / (pa * pa + pc * pc);
|
|
float s = Math.Abs(pa * pd - pb * pc) / (pa * pa + pc * pc);
|
|
float sa = pa / skeleton.scaleX;
|
|
float sa = pa / skeleton.scaleX;
|
|
float sc = pc / skeleton.scaleY;
|
|
float sc = pc / skeleton.scaleY;
|
|
@@ -338,8 +343,8 @@ namespace Spine {
|
|
ib = pb * pid;
|
|
ib = pb * pid;
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
- case TransformMode.NoScale:
|
|
|
|
- case TransformMode.NoScaleOrReflection: {
|
|
|
|
|
|
+ case Inherit.NoScale:
|
|
|
|
+ case Inherit.NoScaleOrReflection: {
|
|
float r = rotation * MathUtils.DegRad, cos = (float)Math.Cos(r), sin = (float)Math.Sin(r);
|
|
float r = rotation * MathUtils.DegRad, cos = (float)Math.Cos(r), sin = (float)Math.Sin(r);
|
|
pa = (pa * cos + pb * sin) / skeleton.scaleX;
|
|
pa = (pa * cos + pb * sin) / skeleton.scaleX;
|
|
pc = (pc * cos + pd * sin) / skeleton.scaleY;
|
|
pc = (pc * cos + pd * sin) / skeleton.scaleY;
|
|
@@ -348,7 +353,7 @@ namespace Spine {
|
|
pa *= s;
|
|
pa *= s;
|
|
pc *= s;
|
|
pc *= s;
|
|
s = (float)Math.Sqrt(pa * pa + pc * pc);
|
|
s = (float)Math.Sqrt(pa * pa + pc * pc);
|
|
- if (data.transformMode == TransformMode.NoScale && pid < 0 != (skeleton.scaleX < 0 != skeleton.scaleY < 0)) s = -s;
|
|
|
|
|
|
+ if (inherit == Inherit.NoScale && pid < 0 != (skeleton.scaleX < 0 != skeleton.scaleY < 0)) s = -s;
|
|
r = MathUtils.PI / 2 + MathUtils.Atan2(pc, pa);
|
|
r = MathUtils.PI / 2 + MathUtils.Atan2(pc, pa);
|
|
pb = (float)Math.Cos(r) * s;
|
|
pb = (float)Math.Cos(r) * s;
|
|
pd = (float)Math.Sin(r) * s;
|
|
pd = (float)Math.Sin(r) * s;
|