diff --git a/spine-csharp/src/Animation.cs b/spine-csharp/src/Animation.cs index 6cc1a025a..2a6e5fb91 100644 --- a/spine-csharp/src/Animation.cs +++ b/spine-csharp/src/Animation.cs @@ -452,7 +452,7 @@ namespace Spine { String attachmentName = attachmentNames[frameIndex]; skeleton.slots.Items[slotIndex].Attachment = - attachmentName == null ? null : skeleton.GetAttachment(slotIndex, attachmentName); + attachmentName == null ? null : skeleton.GetAttachment(slotIndex, attachmentName); } } diff --git a/spine-csharp/src/Attachments/WeightedMeshAttachment.cs b/spine-csharp/src/Attachments/WeightedMeshAttachment.cs index 61a039362..2b4b56524 100644 --- a/spine-csharp/src/Attachments/WeightedMeshAttachment.cs +++ b/spine-csharp/src/Attachments/WeightedMeshAttachment.cs @@ -33,7 +33,7 @@ using System; using System.Collections.Generic; namespace Spine { - /// Attachment that displays a texture region using a mesh which can be deformed by bones. + /// Attachment that displays a texture region using a mesh which can be deformed by bones. public class WeightedMeshAttachment : Attachment { internal int[] bones; internal float[] weights, uvs, regionUVs; diff --git a/spine-csharp/src/Bone.cs b/spine-csharp/src/Bone.cs index de7b19639..c453b1384 100644 --- a/spine-csharp/src/Bone.cs +++ b/spine-csharp/src/Bone.cs @@ -33,7 +33,7 @@ using System; using System.Collections.Generic; namespace Spine { - public class Bone : IUpdatable { + public class Bone : IUpdatable { static public bool yDown; internal BoneData data; @@ -123,44 +123,44 @@ namespace Spine { return; } - float pa = parent.a, pb = parent.b, pc = parent.c, pd = parent.d; - worldX = pa * x + pb * y + parent.worldX; - worldY = pc * x + pd * y + parent.worldY; - worldSignX = parent.worldSignX * Math.Sign(scaleX); - worldSignY = parent.worldSignY * Math.Sign(scaleY); + float pa = parent.a, pb = parent.b, pc = parent.c, pd = parent.d; + worldX = pa * x + pb * y + parent.worldX; + worldY = pc * x + pd * y + parent.worldY; + worldSignX = parent.worldSignX * Math.Sign(scaleX); + worldSignY = parent.worldSignY * Math.Sign(scaleY); - if (data.inheritRotation && data.inheritScale) { - a = pa * la + pb * lc; - b = pa * lb + pb * ld; - c = pc * la + pd * lc; - d = pc * lb + pd * ld; - } else if (data.inheritRotation) { // No scale inheritance. - Bone p = parent; - pa = 1; - pb = 0; - pc = 0; - pd = 1; - while (p != null) { - cos = MathUtils.CosDeg(p.appliedRotation); - sin = MathUtils.SinDeg(p.appliedRotation); - float ta = pa * cos + pb * sin; - float tb = pa * -sin + pb * cos; - float tc = pc * cos + pd * sin; - float td = pc * -sin + pd * cos; - pa = ta; - pb = tb; - pc = tc; - pd = td; - p = p.parent; - } + if (data.inheritRotation && data.inheritScale) { + a = pa * la + pb * lc; + b = pa * lb + pb * ld; + c = pc * la + pd * lc; + d = pc * lb + pd * ld; + } else if (data.inheritRotation) { // No scale inheritance. + Bone p = parent; + pa = 1; + pb = 0; + pc = 0; + pd = 1; + while (p != null) { + cos = MathUtils.CosDeg(p.appliedRotation); + sin = MathUtils.SinDeg(p.appliedRotation); + float ta = pa * cos + pb * sin; + float tb = pa * -sin + pb * cos; + float tc = pc * cos + pd * sin; + float td = pc * -sin + pd * cos; + pa = ta; + pb = tb; + pc = tc; + pd = td; + p = p.parent; + } if (yDown) { pb = -pb; pd = -pd; } - a = pa * la + pb * lc; - b = pa * lb + pb * ld; - c = pc * la + pd * lc; - d = pc * lb + pd * ld; + a = pa * la + pb * lc; + b = pa * lb + pb * ld; + c = pc * la + pd * lc; + d = pc * lb + pd * ld; if (skeleton.flipX) { a = -a; b = -b; @@ -169,45 +169,45 @@ namespace Spine { c = -c; d = -d; } - } else if (data.inheritScale) { // No rotation inheritance. - Bone p = parent; - pa = 1; - pb = 0; - pc = 0; - pd = 1; - while (p != null) { - float r = p.rotation; - cos = MathUtils.CosDeg(r); - sin = MathUtils.SinDeg(r); - float psx = p.appliedScaleX, psy = p.appliedScaleY; - float za = cos * psx, zb = -sin * psy, zc = sin * psx, zd = cos * psy; - float temp = pa * za + pb * zc; - pb = pa * zb + pb * zd; - pa = temp; - temp = pc * za + pd * zc; - pd = pc * zb + pd * zd; - pc = temp; + } else if (data.inheritScale) { // No rotation inheritance. + Bone p = parent; + pa = 1; + pb = 0; + pc = 0; + pd = 1; + while (p != null) { + float r = p.rotation; + cos = MathUtils.CosDeg(r); + sin = MathUtils.SinDeg(r); + float psx = p.appliedScaleX, psy = p.appliedScaleY; + float za = cos * psx, zb = -sin * psy, zc = sin * psx, zd = cos * psy; + float temp = pa * za + pb * zc; + pb = pa * zb + pb * zd; + pa = temp; + temp = pc * za + pd * zc; + pd = pc * zb + pd * zd; + pc = temp; - if (psx < 0) r = -r; - cos = MathUtils.CosDeg(-r); - sin = MathUtils.SinDeg(-r); - temp = pa * cos + pb * sin; - pb = pa * -sin + pb * cos; - pa = temp; - temp = pc * cos + pd * sin; - pd = pc * -sin + pd * cos; - pc = temp; + if (psx < 0) r = -r; + cos = MathUtils.CosDeg(-r); + sin = MathUtils.SinDeg(-r); + temp = pa * cos + pb * sin; + pb = pa * -sin + pb * cos; + pa = temp; + temp = pc * cos + pd * sin; + pd = pc * -sin + pd * cos; + pc = temp; - p = p.parent; - } + p = p.parent; + } if (yDown) { pb = -pb; pd = -pd; } - a = pa * la + pb * lc; - b = pa * lb + pb * ld; - c = pc * la + pd * lc; - d = pc * lb + pd * ld; + a = pa * la + pb * lc; + b = pa * lb + pb * ld; + c = pc * la + pd * lc; + d = pc * lb + pd * ld; if (skeleton.flipX) { a = -a; b = -b; @@ -216,39 +216,39 @@ namespace Spine { c = -c; d = -d; } - } else { - a = la; - b = lb; - c = lc; - d = ld; - } - } + } else { + a = la; + b = lb; + c = lc; + d = ld; + } + } - public void Update () { - UpdateWorldTransform(x, y, rotation, scaleX, scaleY); - } + public void Update () { + UpdateWorldTransform(x, y, rotation, scaleX, scaleY); + } public void SetToSetupPose () { - BoneData data = this.data; - x = data.x; - y = data.y; - rotation = data.rotation; - scaleX = data.scaleX; - scaleY = data.scaleY; + BoneData data = this.data; + x = data.x; + y = data.y; + rotation = data.rotation; + scaleX = data.scaleX; + scaleY = data.scaleY; } public void WorldToLocal (float worldX, float worldY, out float localX, out float localY) { - float x = worldX - this.worldX, y = worldY - this.worldY; - float a = this.a, b = this.b, c = this.c, d = this.d; - float invDet = 1 / (a * d - b * c); - localX = (x * a * invDet - y * b * invDet); - localY = (y * d * invDet - x * c * invDet); + float x = worldX - this.worldX, y = worldY - this.worldY; + float a = this.a, b = this.b, c = this.c, d = this.d; + float invDet = 1 / (a * d - b * c); + localX = (x * a * invDet - y * b * invDet); + localY = (y * d * invDet - x * c * invDet); } public void LocalToWorld (float localX, float localY, out float worldX, out float worldY) { - float x = localX, y = localY; - worldX = x * a + y * b + this.worldX; - worldY = x * c + y * d + this.worldY; + float x = localX, y = localY; + worldX = x * a + y * b + this.worldX; + worldY = x * c + y * d + this.worldY; } override public String ToString () { diff --git a/spine-csharp/src/MathUtils.cs b/spine-csharp/src/MathUtils.cs index 2ed1ba539..225b20f6c 100644 --- a/spine-csharp/src/MathUtils.cs +++ b/spine-csharp/src/MathUtils.cs @@ -37,41 +37,41 @@ namespace Spine { public const float radDeg = 180f / PI; public const float degRad = PI / 180; - const int SIN_BITS = 14; // 16KB. Adjust for accuracy. + const int SIN_BITS = 14; // 16KB. Adjust for accuracy. const int SIN_MASK = ~(-1 << SIN_BITS); const int SIN_COUNT = SIN_MASK + 1; const float radFull = PI * 2; const float degFull = 360; const float radToIndex = SIN_COUNT / radFull; const float degToIndex = SIN_COUNT / degFull; - static float[] sin = new float[SIN_COUNT]; + static float[] sin = new float[SIN_COUNT]; - static MathUtils () { + static MathUtils () { for (int i = 0; i < SIN_COUNT; i++) - sin[i] = (float)Math.Sin((i + 0.5f) / SIN_COUNT * radFull); + sin[i] = (float)Math.Sin((i + 0.5f) / SIN_COUNT * radFull); for (int i = 0; i < 360; i += 90) - sin[(int)(i * degToIndex) & SIN_MASK] = (float)Math.Sin(i * degRad); - } + sin[(int)(i * degToIndex) & SIN_MASK] = (float)Math.Sin(i * degRad); + } - /** Returns the sine in radians from a lookup table. */ - static public float Sin (float radians) { - return sin[(int)(radians * radToIndex) & SIN_MASK]; - } + /** Returns the sine in radians from a lookup table. */ + static public float Sin (float radians) { + return sin[(int)(radians * radToIndex) & SIN_MASK]; + } - /** Returns the cosine in radians from a lookup table. */ - static public float Cos (float radians) { - return sin[(int)((radians + PI / 2) * radToIndex) & SIN_MASK]; - } + /** Returns the cosine in radians from a lookup table. */ + static public float Cos (float radians) { + return sin[(int)((radians + PI / 2) * radToIndex) & SIN_MASK]; + } - /** Returns the sine in radians from a lookup table. */ - static public float SinDeg (float degrees) { - return sin[(int)(degrees * degToIndex) & SIN_MASK]; - } + /** Returns the sine in radians from a lookup table. */ + static public float SinDeg (float degrees) { + return sin[(int)(degrees * degToIndex) & SIN_MASK]; + } - /** Returns the cosine in radians from a lookup table. */ - static public float CosDeg (float degrees) { - return sin[(int)((degrees + 90) * degToIndex) & SIN_MASK]; - } + /** Returns the cosine in radians from a lookup table. */ + static public float CosDeg (float degrees) { + return sin[(int)((degrees + 90) * degToIndex) & SIN_MASK]; + } /// Returns atan2 in radians, faster but less accurate than Math.Atan2. Average error of 0.00231 radians (0.1323 /// degrees), largest error of 0.00488 radians (0.2796 degrees). diff --git a/spine-csharp/src/Skeleton.cs b/spine-csharp/src/Skeleton.cs index 308d5606c..6617f21ca 100644 --- a/spine-csharp/src/Skeleton.cs +++ b/spine-csharp/src/Skeleton.cs @@ -39,8 +39,8 @@ namespace Spine { internal ExposedList slots; internal ExposedList drawOrder; internal ExposedList ikConstraints; - internal ExposedList transformConstraints; - private ExposedList updateCache = new ExposedList(); + internal ExposedList transformConstraints; + private ExposedList updateCache = new ExposedList(); internal Skin skin; internal float r = 1, g = 1, b = 1, a = 1; internal float time; @@ -90,13 +90,13 @@ namespace Spine { drawOrder.Add(slot); } - ikConstraints = new ExposedList(data.ikConstraints.Count); - foreach (IkConstraintData ikConstraintData in data.ikConstraints) - ikConstraints.Add(new IkConstraint(ikConstraintData, this)); + ikConstraints = new ExposedList(data.ikConstraints.Count); + foreach (IkConstraintData ikConstraintData in data.ikConstraints) + ikConstraints.Add(new IkConstraint(ikConstraintData, this)); - transformConstraints = new ExposedList(data.transformConstraints.Count); - foreach (TransformConstraintData transformConstraintData in data.transformConstraints) - transformConstraints.Add(new TransformConstraint(transformConstraintData, this)); + transformConstraints = new ExposedList(data.transformConstraints.Count); + foreach (TransformConstraintData transformConstraintData in data.transformConstraints) + transformConstraints.Add(new TransformConstraint(transformConstraintData, this)); UpdateCache(); UpdateWorldTransform(); diff --git a/spine-csharp/src/SkeletonData.cs b/spine-csharp/src/SkeletonData.cs index 92f149640..b6ff7edb5 100644 --- a/spine-csharp/src/SkeletonData.cs +++ b/spine-csharp/src/SkeletonData.cs @@ -42,7 +42,7 @@ namespace Spine { internal ExposedList events = new ExposedList(); internal ExposedList animations = new ExposedList(); internal ExposedList ikConstraints = new ExposedList(); - internal ExposedList transformConstraints = new ExposedList(); + internal ExposedList transformConstraints = new ExposedList(); internal float width, height; internal String version, hash, imagesPath;