From 963da7561e41a9eb3d70d6534a53f16c0d20552d Mon Sep 17 00:00:00 2001 From: Nathan Sweet Date: Mon, 31 May 2021 01:21:03 -0400 Subject: [PATCH] [csharp] Code style update. * `else` on same line as `if` brace. * `var` only when the type is shown. * Removed unnecessarily locals, eg `var events = this.events; var eventsItems = events.Items;`. * Don't indent `case`. * ExposedList for EventQueue just so iteration can use array indexing. * EventQueue, inner members (struct/enum) after methods. * No braces for single line `if/else/for`. * Removed comments noting ref impl code, eg `// abc.setSize(xyz);`. * Removed comments that didn't add to what the code shows, eg `// Pooling`. * Removed comments not in ref impl about implementation details, eg `// nextTrackLast == -1 ...`. * Removed commented code we are not using. * Use local with list.Items when iterating. --- .gitignore | 1 + spine-csharp/src/Animation.cs | 1002 ++++++++--------- spine-csharp/src/AnimationState.cs | 206 ++-- .../src/Attachments/VertexAttachment.cs | 11 +- spine-csharp/src/Bone.cs | 130 +-- spine-csharp/src/ExposedList.cs | 7 +- spine-csharp/src/IkConstraint.cs | 3 +- spine-csharp/src/PathConstraint.cs | 142 ++- spine-csharp/src/Skeleton.cs | 98 +- spine-csharp/src/SkeletonBinary.cs | 371 +++--- spine-csharp/src/SkeletonBounds.cs | 24 +- spine-csharp/src/SkeletonClipping.cs | 12 +- spine-csharp/src/SkeletonData.cs | 12 +- spine-csharp/src/SkeletonJson.cs | 27 +- spine-csharp/src/Skin.cs | 3 +- spine-csharp/src/Triangulator.cs | 6 +- .../com/esotericsoftware/spine/Animation.java | 9 +- .../spine/attachments/VertexAttachment.java | 3 +- 18 files changed, 1001 insertions(+), 1066 deletions(-) diff --git a/.gitignore b/.gitignore index 46df4e679..1a9a3859f 100644 --- a/.gitignore +++ b/.gitignore @@ -48,6 +48,7 @@ xcshareddata/ spine-cocos2d-objc/cocos2d/* spine-cocos2d-objc/spine-cocos2d-iphone-objc.xcodeproj/project.xcworkspace/xcshareddata/ +spine-csharp/.vs/ spine-csharp/bin spine-csharp/obj spine-csharp/src/*.meta diff --git a/spine-csharp/src/Animation.cs b/spine-csharp/src/Animation.cs index 9b93acbe3..1636a47a0 100644 --- a/spine-csharp/src/Animation.cs +++ b/spine-csharp/src/Animation.cs @@ -60,17 +60,15 @@ namespace Spine { // once (EnsureCapacity() is only available in newer .Net versions). int idCount = 0; int timelinesCount = timelines.Count; - var timelinesItems = timelines.Items; - for (int t = 0; t < timelinesCount; ++t) { + Timeline[] timelinesItems = timelines.Items; + for (int t = 0; t < timelinesCount; ++t) idCount += timelinesItems[t].PropertyIds.Length; - } string[] propertyIds = new string[idCount]; int currentId = 0; for (int t = 0; t < timelinesCount; ++t) { var ids = timelinesItems[t].PropertyIds; - for (int i = 0, idsLength = ids.Length; i < idsLength; ++i) { + for (int i = 0, idsLength = ids.Length; i < idsLength; ++i) propertyIds[currentId++] = ids[i]; - } } this.timelineIds = new HashSet(propertyIds); } @@ -125,26 +123,6 @@ namespace Spine { override public string ToString () { return name; } - - /// Search using a stride of 1. - /// Must be >= the first value in frames. - /// The index of the first value <= time. - internal static int Search (float[] frames, float time) { - int n = frames.Length; - for (int i = 1; i < n; i++) - if (frames[i] > time) return i - 1; - return n - 1; - } - - /// Search using the specified stride. - /// Must be >= the first value in frames. - /// The index of the first value <= time. - internal static int Search (float[] frames, float time, int step) { - int n = frames.Length; - for (int i = step; i < n; i += step) - if (frames[i] > time) return i - step; - return n - step; - } } /// @@ -152,7 +130,6 @@ namespace Spine { /// alpha < 1. /// public enum MixBlend { - /// Transitions from the setup value to the timeline value (the current value is not used). Before the first frame, the /// setup value is set. Setup, @@ -199,7 +176,7 @@ namespace Spine { } internal enum Property { - Rotate=0, X, Y, ScaleX, ScaleY, ShearX, ShearY, // + Rotate = 0, X, Y, ScaleX, ScaleY, ShearX, ShearY, // RGB, Alpha, RGB2, // Attachment, Deform, // Event, DrawOrder, // @@ -267,6 +244,26 @@ namespace Spine { /// such as or , and other such as . public abstract void Apply (Skeleton skeleton, float lastTime, float time, ExposedList events, float alpha, MixBlend blend, MixDirection direction); + + /// Search using a stride of 1. + /// Must be >= the first value in frames. + /// The index of the first value <= time. + internal static int Search (float[] frames, float time) { + int n = frames.Length; + for (int i = 1; i < n; i++) + if (frames[i] > time) return i - 1; + return n - 1; + } + + /// Search using the specified stride. + /// Must be >= the first value in frames. + /// The index of the first value <= time. + internal static int Search (float[] frames, float time, int step) { + int n = frames.Length; + for (int i = step; i < n; i += step) + if (frames[i] > time) return i - step; + return n - step; + } } /// An interface for timelines which change the property of a bone. @@ -498,16 +495,16 @@ namespace Spine { float r = GetCurveValue(time); switch (blend) { - case MixBlend.Setup: - bone.rotation = bone.data.rotation + r * alpha; - break; - case MixBlend.First: - case MixBlend.Replace: - r += bone.data.rotation - bone.rotation; - goto case MixBlend.Add; // Fall through. - case MixBlend.Add: - bone.rotation += r * alpha; - break; + case MixBlend.Setup: + bone.rotation = bone.data.rotation + r * alpha; + break; + case MixBlend.First: + case MixBlend.Replace: + r += bone.data.rotation - bone.rotation; + goto case MixBlend.Add; // Fall through. + case MixBlend.Add: + bone.rotation += r * alpha; + break; } } } @@ -550,40 +547,40 @@ namespace Spine { } float x, y; - int i = Animation.Search(frames, time, ENTRIES), curveType = (int)curves[i / ENTRIES]; + int i = Search(frames, time, ENTRIES), curveType = (int)curves[i / ENTRIES]; switch (curveType) { - case LINEAR: - float before = frames[i]; - x = frames[i + VALUE1]; - y = frames[i + VALUE2]; - float t = (time - before) / (frames[i + ENTRIES] - before); - x += (frames[i + ENTRIES + VALUE1] - x) * t; - y += (frames[i + ENTRIES + VALUE2] - y) * t; - break; - case STEPPED: - x = frames[i + VALUE1]; - y = frames[i + VALUE2]; - break; - default: - x = GetBezierValue(time, i, VALUE1, curveType - BEZIER); - y = GetBezierValue(time, i, VALUE2, curveType + BEZIER_SIZE - BEZIER); - break; + case LINEAR: + float before = frames[i]; + x = frames[i + VALUE1]; + y = frames[i + VALUE2]; + float t = (time - before) / (frames[i + ENTRIES] - before); + x += (frames[i + ENTRIES + VALUE1] - x) * t; + y += (frames[i + ENTRIES + VALUE2] - y) * t; + break; + case STEPPED: + x = frames[i + VALUE1]; + y = frames[i + VALUE2]; + break; + default: + x = GetBezierValue(time, i, VALUE1, curveType - BEZIER); + y = GetBezierValue(time, i, VALUE2, curveType + BEZIER_SIZE - BEZIER); + break; } switch (blend) { - case MixBlend.Setup: - bone.x = bone.data.x + x * alpha; - bone.y = bone.data.y + y * alpha; - break; - case MixBlend.First: - case MixBlend.Replace: - bone.x += (bone.data.x + x - bone.x) * alpha; - bone.y += (bone.data.y + y - bone.y) * alpha; - break; - case MixBlend.Add: - bone.x += x * alpha; - bone.y += y * alpha; - break; + case MixBlend.Setup: + bone.x = bone.data.x + x * alpha; + bone.y = bone.data.y + y * alpha; + break; + case MixBlend.First: + case MixBlend.Replace: + bone.x += (bone.data.x + x - bone.x) * alpha; + bone.y += (bone.data.y + y - bone.y) * alpha; + break; + case MixBlend.Add: + bone.x += x * alpha; + bone.y += y * alpha; + break; } } } @@ -611,28 +608,28 @@ namespace Spine { float[] frames = this.frames; if (time < frames[0]) { // Time is before first frame. switch (blend) { - case MixBlend.Setup: - bone.x = bone.data.x; - return; - case MixBlend.First: - bone.x += (bone.data.x - bone.x) * alpha; - break; + case MixBlend.Setup: + bone.x = bone.data.x; + return; + case MixBlend.First: + bone.x += (bone.data.x - bone.x) * alpha; + return; } return; } float x = GetCurveValue(time); switch (blend) { - case MixBlend.Setup: - bone.x = bone.data.x + x * alpha; - break; - case MixBlend.First: - case MixBlend.Replace: - bone.x += (bone.data.x + x - bone.x) * alpha; - break; - case MixBlend.Add: - bone.x += x * alpha; - break; + case MixBlend.Setup: + bone.x = bone.data.x + x * alpha; + break; + case MixBlend.First: + case MixBlend.Replace: + bone.x += (bone.data.x + x - bone.x) * alpha; + break; + case MixBlend.Add: + bone.x += x * alpha; + break; } } } @@ -665,7 +662,7 @@ namespace Spine { return; case MixBlend.First: bone.y += (bone.data.y - bone.y) * alpha; - break; + return; } return; } @@ -724,24 +721,24 @@ namespace Spine { } float x, y; - int i = Animation.Search(frames, time, ENTRIES), curveType = (int)curves[i / ENTRIES]; + int i = Search(frames, time, ENTRIES), curveType = (int)curves[i / ENTRIES]; switch (curveType) { - case LINEAR: - float before = frames[i]; - x = frames[i + VALUE1]; - y = frames[i + VALUE2]; - float t = (time - before) / (frames[i + ENTRIES] - before); - x += (frames[i + ENTRIES + VALUE1] - x) * t; - y += (frames[i + ENTRIES + VALUE2] - y) * t; - break; - case STEPPED: - x = frames[i + VALUE1]; - y = frames[i + VALUE2]; - break; - default: - x = GetBezierValue(time, i, VALUE1, curveType - BEZIER); - y = GetBezierValue(time, i, VALUE2, curveType + BEZIER_SIZE - BEZIER); - break; + case LINEAR: + float before = frames[i]; + x = frames[i + VALUE1]; + y = frames[i + VALUE2]; + float t = (time - before) / (frames[i + ENTRIES] - before); + x += (frames[i + ENTRIES + VALUE1] - x) * t; + y += (frames[i + ENTRIES + VALUE2] - y) * t; + break; + case STEPPED: + x = frames[i + VALUE1]; + y = frames[i + VALUE2]; + break; + default: + x = GetBezierValue(time, i, VALUE1, curveType - BEZIER); + y = GetBezierValue(time, i, VALUE2, curveType + BEZIER_SIZE - BEZIER); + break; } x *= bone.data.scaleX; y *= bone.data.scaleY; @@ -759,47 +756,47 @@ namespace Spine { float bx, by; if (direction == MixDirection.Out) { switch (blend) { - case MixBlend.Setup: - bx = bone.data.scaleX; - by = bone.data.scaleY; - bone.scaleX = bx + (Math.Abs(x) * Math.Sign(bx) - bx) * alpha; - bone.scaleY = by + (Math.Abs(y) * Math.Sign(by) - by) * alpha; - break; - case MixBlend.First: - case MixBlend.Replace: - bx = bone.scaleX; - by = bone.scaleY; - bone.scaleX = bx + (Math.Abs(x) * Math.Sign(bx) - bx) * alpha; - bone.scaleY = by + (Math.Abs(y) * Math.Sign(by) - by) * alpha; - break; - case MixBlend.Add: - bx = bone.scaleX; - by = bone.scaleY; - bone.scaleX = bx + (Math.Abs(x) * Math.Sign(bx) - bone.data.scaleX) * alpha; - bone.scaleY = by + (Math.Abs(y) * Math.Sign(by) - bone.data.scaleY) * alpha; - break; + case MixBlend.Setup: + bx = bone.data.scaleX; + by = bone.data.scaleY; + bone.scaleX = bx + (Math.Abs(x) * Math.Sign(bx) - bx) * alpha; + bone.scaleY = by + (Math.Abs(y) * Math.Sign(by) - by) * alpha; + break; + case MixBlend.First: + case MixBlend.Replace: + bx = bone.scaleX; + by = bone.scaleY; + bone.scaleX = bx + (Math.Abs(x) * Math.Sign(bx) - bx) * alpha; + bone.scaleY = by + (Math.Abs(y) * Math.Sign(by) - by) * alpha; + break; + case MixBlend.Add: + bx = bone.scaleX; + by = bone.scaleY; + bone.scaleX = bx + (Math.Abs(x) * Math.Sign(bx) - bone.data.scaleX) * alpha; + bone.scaleY = by + (Math.Abs(y) * Math.Sign(by) - bone.data.scaleY) * alpha; + break; } } else { switch (blend) { - case MixBlend.Setup: - bx = Math.Abs(bone.data.scaleX) * Math.Sign(x); - by = Math.Abs(bone.data.scaleY) * Math.Sign(y); - bone.scaleX = bx + (x - bx) * alpha; - bone.scaleY = by + (y - by) * alpha; - break; - case MixBlend.First: - case MixBlend.Replace: - bx = Math.Abs(bone.scaleX) * Math.Sign(x); - by = Math.Abs(bone.scaleY) * Math.Sign(y); - bone.scaleX = bx + (x - bx) * alpha; - bone.scaleY = by + (y - by) * alpha; - break; - case MixBlend.Add: - bx = Math.Sign(x); - by = Math.Sign(y); - bone.scaleX = Math.Abs(bone.scaleX) * bx + (x - Math.Abs(bone.data.scaleX) * bx) * alpha; - bone.scaleY = Math.Abs(bone.scaleY) * by + (y - Math.Abs(bone.data.scaleY) * by) * alpha; - break; + case MixBlend.Setup: + bx = Math.Abs(bone.data.scaleX) * Math.Sign(x); + by = Math.Abs(bone.data.scaleY) * Math.Sign(y); + bone.scaleX = bx + (x - bx) * alpha; + bone.scaleY = by + (y - by) * alpha; + break; + case MixBlend.First: + case MixBlend.Replace: + bx = Math.Abs(bone.scaleX) * Math.Sign(x); + by = Math.Abs(bone.scaleY) * Math.Sign(y); + bone.scaleX = bx + (x - bx) * alpha; + bone.scaleY = by + (y - by) * alpha; + break; + case MixBlend.Add: + bx = Math.Sign(x); + by = Math.Sign(y); + bone.scaleX = Math.Abs(bone.scaleX) * bx + (x - Math.Abs(bone.data.scaleX) * bx) * alpha; + bone.scaleY = Math.Abs(bone.scaleY) * by + (y - Math.Abs(bone.data.scaleY) * by) * alpha; + break; } } } @@ -834,7 +831,7 @@ namespace Spine { return; case MixBlend.First: bone.scaleX += (bone.data.scaleX - bone.scaleX) * alpha; - break; + return; } return; } @@ -913,7 +910,7 @@ namespace Spine { return; case MixBlend.First: bone.scaleY += (bone.data.scaleY - bone.scaleY) * alpha; - break; + return; } return; } @@ -1002,41 +999,40 @@ namespace Spine { } float x, y; - int i = Animation.Search(frames, time, ENTRIES), curveType = (int)curves[i / ENTRIES]; + int i = Search(frames, time, ENTRIES), curveType = (int)curves[i / ENTRIES]; switch (curveType) { - case LINEAR: - float before = frames[i]; - x = frames[i + VALUE1]; - y = frames[i + VALUE2]; - float t = (time - before) / (frames[i + ENTRIES] - before); - x += (frames[i + ENTRIES + VALUE1] - x) * t; - y += (frames[i + ENTRIES + VALUE2] - y) * t; - break; - case STEPPED: - x = frames[i + VALUE1]; - y = frames[i + VALUE2]; - break; - default: - x = GetBezierValue(time, i, VALUE1, curveType - BEZIER); - y = GetBezierValue(time, i, VALUE2, curveType + BEZIER_SIZE - BEZIER); - break; + case LINEAR: + float before = frames[i]; + x = frames[i + VALUE1]; + y = frames[i + VALUE2]; + float t = (time - before) / (frames[i + ENTRIES] - before); + x += (frames[i + ENTRIES + VALUE1] - x) * t; + y += (frames[i + ENTRIES + VALUE2] - y) * t; + break; + case STEPPED: + x = frames[i + VALUE1]; + y = frames[i + VALUE2]; + break; + default: + x = GetBezierValue(time, i, VALUE1, curveType - BEZIER); + y = GetBezierValue(time, i, VALUE2, curveType + BEZIER_SIZE - BEZIER); + break; } - switch (blend) { - case MixBlend.Setup: - bone.shearX = bone.data.shearX + x * alpha; - bone.shearY = bone.data.shearY + y * alpha; - break; - case MixBlend.First: - case MixBlend.Replace: - bone.shearX += (bone.data.shearX + x - bone.shearX) * alpha; - bone.shearY += (bone.data.shearY + y - bone.shearY) * alpha; - break; - case MixBlend.Add: - bone.shearX += x * alpha; - bone.shearY += y * alpha; - break; + case MixBlend.Setup: + bone.shearX = bone.data.shearX + x * alpha; + bone.shearY = bone.data.shearY + y * alpha; + break; + case MixBlend.First: + case MixBlend.Replace: + bone.shearX += (bone.data.shearX + x - bone.shearX) * alpha; + bone.shearY += (bone.data.shearY + y - bone.shearY) * alpha; + break; + case MixBlend.Add: + bone.shearX += x * alpha; + bone.shearY += y * alpha; + break; } } } @@ -1069,7 +1065,7 @@ namespace Spine { return; case MixBlend.First: bone.shearX += (bone.data.shearX - bone.shearX) * alpha; - break; + return; } return; } @@ -1118,7 +1114,7 @@ namespace Spine { return; case MixBlend.First: bone.shearY += (bone.data.shearY - bone.shearY) * alpha; - break; + return; } return; } @@ -1201,32 +1197,32 @@ namespace Spine { } float r, g, b, a; - int i = Animation.Search(frames, time, ENTRIES), curveType = (int)curves[i / ENTRIES]; + int i = Search(frames, time, ENTRIES), curveType = (int)curves[i / ENTRIES]; switch (curveType) { - case LINEAR: - float before = frames[i]; - r = frames[i + R]; - g = frames[i + G]; - b = frames[i + B]; - a = frames[i + A]; - float t = (time - before) / (frames[i + ENTRIES] - before); - r += (frames[i + ENTRIES + R] - r) * t; - g += (frames[i + ENTRIES + G] - g) * t; - b += (frames[i + ENTRIES + B] - b) * t; - a += (frames[i + ENTRIES + A] - a) * t; - break; - case STEPPED: - r = frames[i + R]; - g = frames[i + G]; - b = frames[i + B]; - a = frames[i + A]; - break; - default: - r = GetBezierValue(time, i, R, curveType - BEZIER); - g = GetBezierValue(time, i, G, curveType + BEZIER_SIZE - BEZIER); - b = GetBezierValue(time, i, B, curveType + BEZIER_SIZE * 2 - BEZIER); - a = GetBezierValue(time, i, A, curveType + BEZIER_SIZE * 3 - BEZIER); - break; + case LINEAR: + float before = frames[i]; + r = frames[i + R]; + g = frames[i + G]; + b = frames[i + B]; + a = frames[i + A]; + float t = (time - before) / (frames[i + ENTRIES] - before); + r += (frames[i + ENTRIES + R] - r) * t; + g += (frames[i + ENTRIES + G] - g) * t; + b += (frames[i + ENTRIES + B] - b) * t; + a += (frames[i + ENTRIES + A] - a) * t; + break; + case STEPPED: + r = frames[i + R]; + g = frames[i + G]; + b = frames[i + B]; + a = frames[i + A]; + break; + default: + r = GetBezierValue(time, i, R, curveType - BEZIER); + g = GetBezierValue(time, i, G, curveType + BEZIER_SIZE - BEZIER); + b = GetBezierValue(time, i, B, curveType + BEZIER_SIZE * 2 - BEZIER); + a = GetBezierValue(time, i, A, curveType + BEZIER_SIZE * 3 - BEZIER); + break; } if (alpha == 1) { @@ -1269,6 +1265,7 @@ namespace Spine { (int)Property.RGB + "|" + slotIndex) { this.slotIndex = slotIndex; } + public override int FrameEntries { get { return ENTRIES; } } @@ -1299,44 +1296,44 @@ namespace Spine { if (time < frames[0]) { // Time is before first frame. var setup = slot.data; switch (blend) { - case MixBlend.Setup: - slot.r = setup.r; - slot.g = setup.g; - slot.b = setup.b; - return; - case MixBlend.First: - slot.r += (setup.r - slot.r) * alpha; - slot.g += (setup.g - slot.g) * alpha; - slot.b += (setup.b - slot.b) * alpha; - slot.ClampColor(); - return; + case MixBlend.Setup: + slot.r = setup.r; + slot.g = setup.g; + slot.b = setup.b; + return; + case MixBlend.First: + slot.r += (setup.r - slot.r) * alpha; + slot.g += (setup.g - slot.g) * alpha; + slot.b += (setup.b - slot.b) * alpha; + slot.ClampColor(); + return; } return; } float r, g, b; - int i = Animation.Search(frames, time, ENTRIES), curveType = (int)curves[i >> 2]; + int i = Search(frames, time, ENTRIES), curveType = (int)curves[i >> 2]; switch (curveType) { - case LINEAR: - float before = frames[i]; - r = frames[i + R]; - g = frames[i + G]; - b = frames[i + B]; - float t = (time - before) / (frames[i + ENTRIES] - before); - r += (frames[i + ENTRIES + R] - r) * t; - g += (frames[i + ENTRIES + G] - g) * t; - b += (frames[i + ENTRIES + B] - b) * t; - break; - case STEPPED: - r = frames[i + R]; - g = frames[i + G]; - b = frames[i + B]; - break; - default: - r = GetBezierValue(time, i, R, curveType - BEZIER); - g = GetBezierValue(time, i, G, curveType + BEZIER_SIZE - BEZIER); - b = GetBezierValue(time, i, B, curveType + BEZIER_SIZE * 2 - BEZIER); - break; + case LINEAR: + float before = frames[i]; + r = frames[i + R]; + g = frames[i + G]; + b = frames[i + B]; + float t = (time - before) / (frames[i + ENTRIES] - before); + r += (frames[i + ENTRIES + R] - r) * t; + g += (frames[i + ENTRIES + G] - g) * t; + b += (frames[i + ENTRIES + B] - b) * t; + break; + case STEPPED: + r = frames[i + R]; + g = frames[i + G]; + b = frames[i + B]; + break; + default: + r = GetBezierValue(time, i, R, curveType - BEZIER); + g = GetBezierValue(time, i, G, curveType + BEZIER_SIZE - BEZIER); + b = GetBezierValue(time, i, B, curveType + BEZIER_SIZE * 2 - BEZIER); + break; } if (alpha == 1) { @@ -1344,16 +1341,14 @@ namespace Spine { slot.g = g; slot.b = b; slot.ClampColor(); - } - else { + } else { float br, bg, bb; if (blend == MixBlend.Setup) { var setup = slot.data; br = setup.r; bg = setup.g; bb = setup.b; - } - else { + } else { br = slot.r; bg = slot.g; bb = slot.b; @@ -1390,27 +1385,25 @@ namespace Spine { if (time < frames[0]) { // Time is before first frame. var setup = slot.data; switch (blend) { - case MixBlend.Setup: - slot.a = setup.a; - return; - case MixBlend.First: - slot.a += (setup.a - slot.a) * alpha; - slot.ClampColor(); - return; + case MixBlend.Setup: + slot.a = setup.a; + return; + case MixBlend.First: + slot.a += (setup.a - slot.a) * alpha; + slot.ClampColor(); + return; } return; } float a = GetCurveValue(time); - if (alpha == 1) { + if (alpha == 1) slot.a = a; - slot.ClampColor(); - } else { if (blend == MixBlend.Setup) slot.a = slot.data.a; slot.a += (a - slot.a) * alpha; - slot.ClampColor(); } + slot.ClampColor(); } } @@ -1469,8 +1462,6 @@ namespace Spine { var slotData = slot.data; switch (blend) { case MixBlend.Setup: - // slot.color.set(slot.data.color); - // slot.darkColor.set(slot.data.darkColor); slot.r = slotData.r; slot.g = slotData.g; slot.b = slotData.b; @@ -1497,44 +1488,44 @@ namespace Spine { } float r, g, b, a, r2, g2, b2; - int i = Animation.Search(frames, time, ENTRIES), curveType = (int)curves[i >> 3]; + int i = Search(frames, time, ENTRIES), curveType = (int)curves[i >> 3]; switch (curveType) { - case LINEAR: - float before = frames[i]; - r = frames[i + R]; - g = frames[i + G]; - b = frames[i + B]; - a = frames[i + A]; - r2 = frames[i + R2]; - g2 = frames[i + G2]; - b2 = frames[i + B2]; - float t = (time - before) / (frames[i + ENTRIES] - before); - r += (frames[i + ENTRIES + R] - r) * t; - g += (frames[i + ENTRIES + G] - g) * t; - b += (frames[i + ENTRIES + B] - b) * t; - a += (frames[i + ENTRIES + A] - a) * t; - r2 += (frames[i + ENTRIES + R2] - r2) * t; - g2 += (frames[i + ENTRIES + G2] - g2) * t; - b2 += (frames[i + ENTRIES + B2] - b2) * t; - break; - case STEPPED: - r = frames[i + R]; - g = frames[i + G]; - b = frames[i + B]; - a = frames[i + A]; - r2 = frames[i + R2]; - g2 = frames[i + G2]; - b2 = frames[i + B2]; - break; - default: - r = GetBezierValue(time, i, R, curveType - BEZIER); - g = GetBezierValue(time, i, G, curveType + BEZIER_SIZE - BEZIER); - b = GetBezierValue(time, i, B, curveType + BEZIER_SIZE * 2 - BEZIER); - a = GetBezierValue(time, i, A, curveType + BEZIER_SIZE * 3 - BEZIER); - r2 = GetBezierValue(time, i, R2, curveType + BEZIER_SIZE * 4 - BEZIER); - g2 = GetBezierValue(time, i, G2, curveType + BEZIER_SIZE * 5 - BEZIER); - b2 = GetBezierValue(time, i, B2, curveType + BEZIER_SIZE * 6 - BEZIER); - break; + case LINEAR: + float before = frames[i]; + r = frames[i + R]; + g = frames[i + G]; + b = frames[i + B]; + a = frames[i + A]; + r2 = frames[i + R2]; + g2 = frames[i + G2]; + b2 = frames[i + B2]; + float t = (time - before) / (frames[i + ENTRIES] - before); + r += (frames[i + ENTRIES + R] - r) * t; + g += (frames[i + ENTRIES + G] - g) * t; + b += (frames[i + ENTRIES + B] - b) * t; + a += (frames[i + ENTRIES + A] - a) * t; + r2 += (frames[i + ENTRIES + R2] - r2) * t; + g2 += (frames[i + ENTRIES + G2] - g2) * t; + b2 += (frames[i + ENTRIES + B2] - b2) * t; + break; + case STEPPED: + r = frames[i + R]; + g = frames[i + G]; + b = frames[i + B]; + a = frames[i + A]; + r2 = frames[i + R2]; + g2 = frames[i + G2]; + b2 = frames[i + B2]; + break; + default: + r = GetBezierValue(time, i, R, curveType - BEZIER); + g = GetBezierValue(time, i, G, curveType + BEZIER_SIZE - BEZIER); + b = GetBezierValue(time, i, B, curveType + BEZIER_SIZE * 2 - BEZIER); + a = GetBezierValue(time, i, A, curveType + BEZIER_SIZE * 3 - BEZIER); + r2 = GetBezierValue(time, i, R2, curveType + BEZIER_SIZE * 4 - BEZIER); + g2 = GetBezierValue(time, i, G2, curveType + BEZIER_SIZE * 5 - BEZIER); + b2 = GetBezierValue(time, i, B2, curveType + BEZIER_SIZE * 6 - BEZIER); + break; } if (alpha == 1) { @@ -1631,67 +1622,67 @@ namespace Spine { if (time < frames[0]) { // Time is before first frame. var slotData = slot.data; switch (blend) { - case MixBlend.Setup: - // slot.color.set(slot.data.color); - // slot.darkColor.set(slot.data.darkColor); - slot.r = slotData.r; - slot.g = slotData.g; - slot.b = slotData.b; - slot.ClampColor(); - slot.r2 = slotData.r2; - slot.g2 = slotData.g2; - slot.b2 = slotData.b2; - slot.ClampSecondColor(); - return; - case MixBlend.First: - slot.r += (slot.r - slotData.r) * alpha; - slot.g += (slot.g - slotData.g) * alpha; - slot.b += (slot.b - slotData.b) * alpha; - slot.ClampColor(); - slot.r2 += (slot.r2 - slotData.r2) * alpha; - slot.g2 += (slot.g2 - slotData.g2) * alpha; - slot.b2 += (slot.b2 - slotData.b2) * alpha; - slot.ClampSecondColor(); - return; + case MixBlend.Setup: + // slot.color.set(slot.data.color); + // slot.darkColor.set(slot.data.darkColor); + slot.r = slotData.r; + slot.g = slotData.g; + slot.b = slotData.b; + slot.ClampColor(); + slot.r2 = slotData.r2; + slot.g2 = slotData.g2; + slot.b2 = slotData.b2; + slot.ClampSecondColor(); + return; + case MixBlend.First: + slot.r += (slot.r - slotData.r) * alpha; + slot.g += (slot.g - slotData.g) * alpha; + slot.b += (slot.b - slotData.b) * alpha; + slot.ClampColor(); + slot.r2 += (slot.r2 - slotData.r2) * alpha; + slot.g2 += (slot.g2 - slotData.g2) * alpha; + slot.b2 += (slot.b2 - slotData.b2) * alpha; + slot.ClampSecondColor(); + return; } return; } float r, g, b, r2, g2, b2; - int i = Animation.Search(frames, time, ENTRIES), curveType = (int)curves[i / ENTRIES]; + int i = Search(frames, time, ENTRIES), curveType = (int)curves[i / ENTRIES]; switch (curveType) { - case LINEAR: - float before = frames[i]; - r = frames[i + R]; - g = frames[i + G]; - b = frames[i + B]; - r2 = frames[i + R2]; - g2 = frames[i + G2]; - b2 = frames[i + B2]; - float t = (time - before) / (frames[i + ENTRIES] - before); - r += (frames[i + ENTRIES + R] - r) * t; - g += (frames[i + ENTRIES + G] - g) * t; - b += (frames[i + ENTRIES + B] - b) * t; - r2 += (frames[i + ENTRIES + R2] - r2) * t; - g2 += (frames[i + ENTRIES + G2] - g2) * t; - b2 += (frames[i + ENTRIES + B2] - b2) * t; - break; - case STEPPED: - r = frames[i + R]; - g = frames[i + G]; - b = frames[i + B]; - r2 = frames[i + R2]; - g2 = frames[i + G2]; - b2 = frames[i + B2]; - break; - default: - r = GetBezierValue(time, i, R, curveType - BEZIER); - g = GetBezierValue(time, i, G, curveType + BEZIER_SIZE - BEZIER); - b = GetBezierValue(time, i, B, curveType + BEZIER_SIZE * 2 - BEZIER); - r2 = GetBezierValue(time, i, R2, curveType + BEZIER_SIZE * 3 - BEZIER); - g2 = GetBezierValue(time, i, G2, curveType + BEZIER_SIZE * 4 - BEZIER); - b2 = GetBezierValue(time, i, B2, curveType + BEZIER_SIZE * 5 - BEZIER); - break; + case LINEAR: + float before = frames[i]; + r = frames[i + R]; + g = frames[i + G]; + b = frames[i + B]; + r2 = frames[i + R2]; + g2 = frames[i + G2]; + b2 = frames[i + B2]; + float t = (time - before) / (frames[i + ENTRIES] - before); + r += (frames[i + ENTRIES + R] - r) * t; + g += (frames[i + ENTRIES + G] - g) * t; + b += (frames[i + ENTRIES + B] - b) * t; + r2 += (frames[i + ENTRIES + R2] - r2) * t; + g2 += (frames[i + ENTRIES + G2] - g2) * t; + b2 += (frames[i + ENTRIES + B2] - b2) * t; + break; + case STEPPED: + r = frames[i + R]; + g = frames[i + G]; + b = frames[i + B]; + r2 = frames[i + R2]; + g2 = frames[i + G2]; + b2 = frames[i + B2]; + break; + default: + r = GetBezierValue(time, i, R, curveType - BEZIER); + g = GetBezierValue(time, i, G, curveType + BEZIER_SIZE - BEZIER); + b = GetBezierValue(time, i, B, curveType + BEZIER_SIZE * 2 - BEZIER); + r2 = GetBezierValue(time, i, R2, curveType + BEZIER_SIZE * 3 - BEZIER); + g2 = GetBezierValue(time, i, G2, curveType + BEZIER_SIZE * 4 - BEZIER); + b2 = GetBezierValue(time, i, B2, curveType + BEZIER_SIZE * 5 - BEZIER); + break; } if (alpha == 1) { @@ -1703,8 +1694,7 @@ namespace Spine { slot.g2 = g2; slot.b2 = b2; slot.ClampSecondColor(); - } - else { + } else { float br, bg, bb, br2, bg2, bb2; if (blend == MixBlend.Setup) { br = slot.data.r; @@ -1713,8 +1703,7 @@ namespace Spine { br2 = slot.data.r2; bg2 = slot.data.g2; bb2 = slot.data.b2; - } - else { + } else { br = slot.r; bg = slot.g; bb = slot.b; @@ -1782,7 +1771,7 @@ namespace Spine { return; } - SetAttachment(skeleton, slot, attachmentNames[Animation.Search(frames, time)]); + SetAttachment(skeleton, slot, attachmentNames[Search(frames, time)]); } private void SetAttachment (Skeleton skeleton, Slot slot, string attachmentName) { @@ -1862,11 +1851,11 @@ namespace Spine { float[] curves = this.curves; int i = (int)curves[frame]; switch (i) { - case LINEAR: - float x = frames[frame]; - return (time - x) / (frames[frame + FrameEntries] - x); - case STEPPED: - return 0; + case LINEAR: + float x = frames[frame]; + return (time - x) / (frames[frame + FrameEntries] - x); + case STEPPED: + return 0; } i -= BEZIER; if (curves[i] > time) { @@ -1888,9 +1877,10 @@ namespace Spine { override public void Apply (Skeleton skeleton, float lastTime, float time, ExposedList firedEvents, float alpha, MixBlend blend, MixDirection direction) { + Slot slot = skeleton.slots.Items[slotIndex]; if (!slot.bone.active) return; - VertexAttachment vertexAttachment = slot.attachment as VertexAttachment; + var vertexAttachment = slot.attachment as VertexAttachment; if (vertexAttachment == null || vertexAttachment.DeformAttachment != attachment) return; var deformArray = slot.Deform; @@ -1898,11 +1888,11 @@ namespace Spine { float[][] vertices = this.vertices; int vertexCount = vertices[0].Length; - float[] frames = this.frames; + float[] deform; + float[] frames = this.frames; if (time < frames[0]) { // Time is before first frame. - switch (blend) { case MixBlend.Setup: deformArray.Clear(); @@ -1913,7 +1903,7 @@ namespace Spine { return; } - // deformArray.SetSize(vertexCount) // Ensure size and preemptively set count. + // Ensure size and preemptively set count. if (deformArray.Capacity < vertexCount) deformArray.Capacity = vertexCount; deformArray.Count = vertexCount; deform = deformArray.Items; @@ -1930,19 +1920,16 @@ namespace Spine { deform[i] *= alpha; } return; - default: - return; } - + return; } - // deformArray.SetSize(vertexCount) // Ensure size and preemptively set count. + // Ensure size and preemptively set count. if (deformArray.Capacity < vertexCount) deformArray.Capacity = vertexCount; deformArray.Count = vertexCount; deform = deformArray.Items; if (time >= frames[frames.Length - 1]) { // Time is after last frame. - float[] lastVertices = vertices[frames.Length - 1]; if (alpha == 1) { if (blend == MixBlend.Add) { @@ -1962,45 +1949,45 @@ namespace Spine { } } else { switch (blend) { - case MixBlend.Setup: { - if (vertexAttachment.bones == null) { - // Unweighted vertex positions, with alpha. - float[] setupVertices = vertexAttachment.vertices; - for (int i = 0; i < vertexCount; i++) { - float setup = setupVertices[i]; - deform[i] = setup + (lastVertices[i] - setup) * alpha; - } - } else { - // Weighted deform offsets, with alpha. - for (int i = 0; i < vertexCount; i++) - deform[i] = lastVertices[i] * alpha; + case MixBlend.Setup: { + if (vertexAttachment.bones == null) { + // Unweighted vertex positions, with alpha. + float[] setupVertices = vertexAttachment.vertices; + for (int i = 0; i < vertexCount; i++) { + float setup = setupVertices[i]; + deform[i] = setup + (lastVertices[i] - setup) * alpha; } - break; - } - case MixBlend.First: - case MixBlend.Replace: - // Vertex positions or deform offsets, with alpha. + } else { + // Weighted deform offsets, with alpha. for (int i = 0; i < vertexCount; i++) - deform[i] += (lastVertices[i] - deform[i]) * alpha; - break; - case MixBlend.Add: - if (vertexAttachment.bones == null) { - // Unweighted vertex positions, no alpha. - float[] setupVertices = vertexAttachment.vertices; - for (int i = 0; i < vertexCount; i++) - deform[i] += (lastVertices[i] - setupVertices[i]) * alpha; - } else { - // Weighted deform offsets, alpha. - for (int i = 0; i < vertexCount; i++) - deform[i] += lastVertices[i] * alpha; - } - break; + deform[i] = lastVertices[i] * alpha; + } + break; + } + case MixBlend.First: + case MixBlend.Replace: + // Vertex positions or deform offsets, with alpha. + for (int i = 0; i < vertexCount; i++) + deform[i] += (lastVertices[i] - deform[i]) * alpha; + break; + case MixBlend.Add: + if (vertexAttachment.bones == null) { + // Unweighted vertex positions, no alpha. + float[] setupVertices = vertexAttachment.vertices; + for (int i = 0; i < vertexCount; i++) + deform[i] += (lastVertices[i] - setupVertices[i]) * alpha; + } else { + // Weighted deform offsets, alpha. + for (int i = 0; i < vertexCount; i++) + deform[i] += lastVertices[i] * alpha; + } + break; } } return; } - int frame = Animation.Search(frames, time); + int frame = Search(frames, time); float percent = GetCurvePercent(time, frame); float[] prevVertices = vertices[frame]; float[] nextVertices = vertices[frame + 1]; @@ -2030,49 +2017,48 @@ namespace Spine { } } else { switch (blend) { - case MixBlend.Setup: { - if (vertexAttachment.bones == null) { - // Unweighted vertex positions, with alpha. - float[] setupVertices = vertexAttachment.vertices; - for (int i = 0; i < vertexCount; i++) { - float prev = prevVertices[i], setup = setupVertices[i]; - deform[i] = setup + (prev + (nextVertices[i] - prev) * percent - setup) * alpha; - } - } else { - // Weighted deform offsets, with alpha. - for (int i = 0; i < vertexCount; i++) { - float prev = prevVertices[i]; - deform[i] = (prev + (nextVertices[i] - prev) * percent) * alpha; - } + case MixBlend.Setup: { + if (vertexAttachment.bones == null) { + // Unweighted vertex positions, with alpha. + float[] setupVertices = vertexAttachment.vertices; + for (int i = 0; i < vertexCount; i++) { + float prev = prevVertices[i], setup = setupVertices[i]; + deform[i] = setup + (prev + (nextVertices[i] - prev) * percent - setup) * alpha; } - break; - } - case MixBlend.First: - case MixBlend.Replace: { - // Vertex positions or deform offsets, with alpha. + } else { + // Weighted deform offsets, with alpha. for (int i = 0; i < vertexCount; i++) { float prev = prevVertices[i]; - deform[i] += (prev + (nextVertices[i] - prev) * percent - deform[i]) * alpha; + deform[i] = (prev + (nextVertices[i] - prev) * percent) * alpha; } - break; } - case MixBlend.Add: { - if (vertexAttachment.bones == null) { - // Unweighted vertex positions, with alpha. - float[] setupVertices = vertexAttachment.vertices; - for (int i = 0; i < vertexCount; i++) { - float prev = prevVertices[i]; - deform[i] += (prev + (nextVertices[i] - prev) * percent - setupVertices[i]) * alpha; - } - } else { - // Weighted deform offsets, with alpha. - for (int i = 0; i < vertexCount; i++) { - float prev = prevVertices[i]; - deform[i] += (prev + (nextVertices[i] - prev) * percent) * alpha; - } + break; + } + case MixBlend.First: + case MixBlend.Replace: { + // Vertex positions or deform offsets, with alpha. + for (int i = 0; i < vertexCount; i++) { + float prev = prevVertices[i]; + deform[i] += (prev + (nextVertices[i] - prev) * percent - deform[i]) * alpha; + } + break; + } + case MixBlend.Add: + if (vertexAttachment.bones == null) { + // Unweighted vertex positions, with alpha. + float[] setupVertices = vertexAttachment.vertices; + for (int i = 0; i < vertexCount; i++) { + float prev = prevVertices[i]; + deform[i] += (prev + (nextVertices[i] - prev) * percent - setupVertices[i]) * alpha; + } + } else { + // Weighted deform offsets, with alpha. + for (int i = 0; i < vertexCount; i++) { + float prev = prevVertices[i]; + deform[i] += (prev + (nextVertices[i] - prev) * percent) * alpha; } - break; } + break; } } } @@ -2122,7 +2108,7 @@ namespace Spine { if (lastTime < frames[0]) i = 0; else { - i = Animation.Search(frames, lastTime) + 1; + i = Search(frames, lastTime) + 1; float frameTime = frames[i]; while (i > 0) { // Fire multiple events with the same frame. if (frames[i - 1] != frameTime) break; @@ -2166,23 +2152,23 @@ namespace Spine { public override void Apply (Skeleton skeleton, float lastTime, float time, ExposedList firedEvents, float alpha, MixBlend blend, MixDirection direction) { - var drawOrder = skeleton.drawOrder.Items; if (direction == MixDirection.Out) { - if (blend == MixBlend.Setup) Array.Copy(skeleton.slots.Items, 0, drawOrder, 0, skeleton.slots.Count); + if (blend == MixBlend.Setup) Array.Copy(skeleton.slots.Items, 0, skeleton.drawOrder.Items, 0, skeleton.slots.Count); return; } float[] frames = this.frames; if (time < frames[0]) { // Time is before first frame. - if (blend == MixBlend.Setup || blend == MixBlend.First) Array.Copy(skeleton.slots.Items, 0, drawOrder, 0, skeleton.slots.Count); + if (blend == MixBlend.Setup || blend == MixBlend.First) Array.Copy(skeleton.slots.Items, 0, skeleton.drawOrder.Items, 0, skeleton.slots.Count); return; } - int[] drawOrderToSetupIndex = drawOrders[Animation.Search(frames, time)]; + int[] drawOrderToSetupIndex = drawOrders[Search(frames, time)]; if (drawOrderToSetupIndex == null) - Array.Copy(skeleton.slots.Items, 0, drawOrder, 0, skeleton.slots.Count); + Array.Copy(skeleton.slots.Items, 0, skeleton.drawOrder.Items, 0, skeleton.slots.Count); else { - var slots = skeleton.slots.Items; + Slot[] slots = skeleton.slots.Items; + Slot[] drawOrder = skeleton.drawOrder.Items; for (int i = 0, n = drawOrderToSetupIndex.Length; i < n; i++) drawOrder[i] = slots[drawOrderToSetupIndex[i]]; } @@ -2258,24 +2244,24 @@ namespace Spine { } float mix, softness; - int i = Animation.Search(frames, time, ENTRIES), curveType = (int)curves[i / ENTRIES]; + int i = Search(frames, time, ENTRIES), curveType = (int)curves[i / ENTRIES]; switch (curveType) { - case LINEAR: - float before = frames[i]; - mix = frames[i + MIX]; - softness = frames[i + SOFTNESS]; - float t = (time - before) / (frames[i + ENTRIES] - before); - mix += (frames[i + ENTRIES + MIX] - mix) * t; - softness += (frames[i + ENTRIES + SOFTNESS] - softness) * t; - break; - case STEPPED: - mix = frames[i + MIX]; - softness = frames[i + SOFTNESS]; - break; - default: - mix = GetBezierValue(time, i, MIX, curveType - BEZIER); - softness = GetBezierValue(time, i, SOFTNESS, curveType + BEZIER_SIZE - BEZIER); - break; + case LINEAR: + float before = frames[i]; + mix = frames[i + MIX]; + softness = frames[i + SOFTNESS]; + float t = (time - before) / (frames[i + ENTRIES] - before); + mix += (frames[i + ENTRIES + MIX] - mix) * t; + softness += (frames[i + ENTRIES + SOFTNESS] - softness) * t; + break; + case STEPPED: + mix = frames[i + MIX]; + softness = frames[i + SOFTNESS]; + break; + default: + mix = GetBezierValue(time, i, MIX, curveType - BEZIER); + softness = GetBezierValue(time, i, SOFTNESS, curveType + BEZIER_SIZE - BEZIER); + break; } if (blend == MixBlend.Setup) { @@ -2285,14 +2271,12 @@ namespace Spine { constraint.bendDirection = constraint.data.bendDirection; constraint.compress = constraint.data.compress; constraint.stretch = constraint.data.stretch; - } - else { + } else { constraint.bendDirection = (int)frames[i + BEND_DIRECTION]; constraint.compress = frames[i + COMPRESS] != 0; constraint.stretch = frames[i + STRETCH] != 0; } - } - else { + } else { constraint.mix += (mix - constraint.mix) * alpha; constraint.softness += (softness - constraint.softness) * alpha; if (direction == MixDirection.In) { @@ -2375,40 +2359,40 @@ namespace Spine { } float rotate, x, y, scaleX, scaleY, shearY; - int i = Animation.Search(frames, time, ENTRIES), curveType = (int)curves[i / ENTRIES]; + int i = Search(frames, time, ENTRIES), curveType = (int)curves[i / ENTRIES]; switch (curveType) { - case LINEAR: - float before = frames[i]; - rotate = frames[i + ROTATE]; - x = frames[i + X]; - y = frames[i + Y]; - scaleX = frames[i + SCALEX]; - scaleY = frames[i + SCALEY]; - shearY = frames[i + SHEARY]; - float t = (time - before) / (frames[i + ENTRIES] - before); - rotate += (frames[i + ENTRIES + ROTATE] - rotate) * t; - x += (frames[i + ENTRIES + X] - x) * t; - y += (frames[i + ENTRIES + Y] - y) * t; - scaleX += (frames[i + ENTRIES + SCALEX] - scaleX) * t; - scaleY += (frames[i + ENTRIES + SCALEY] - scaleY) * t; - shearY += (frames[i + ENTRIES + SHEARY] - shearY) * t; - break; - case STEPPED: - rotate = frames[i + ROTATE]; - x = frames[i + X]; - y = frames[i + Y]; - scaleX = frames[i + SCALEX]; - scaleY = frames[i + SCALEY]; - shearY = frames[i + SHEARY]; - break; - default: - rotate = GetBezierValue(time, i, ROTATE, curveType - BEZIER); - x = GetBezierValue(time, i, X, curveType + BEZIER_SIZE - BEZIER); - y = GetBezierValue(time, i, Y, curveType + BEZIER_SIZE * 2 - BEZIER); - scaleX = GetBezierValue(time, i, SCALEX, curveType + BEZIER_SIZE * 3 - BEZIER); - scaleY = GetBezierValue(time, i, SCALEY, curveType + BEZIER_SIZE * 4 - BEZIER); - shearY = GetBezierValue(time, i, SHEARY, curveType + BEZIER_SIZE * 5 - BEZIER); - break; + case LINEAR: + float before = frames[i]; + rotate = frames[i + ROTATE]; + x = frames[i + X]; + y = frames[i + Y]; + scaleX = frames[i + SCALEX]; + scaleY = frames[i + SCALEY]; + shearY = frames[i + SHEARY]; + float t = (time - before) / (frames[i + ENTRIES] - before); + rotate += (frames[i + ENTRIES + ROTATE] - rotate) * t; + x += (frames[i + ENTRIES + X] - x) * t; + y += (frames[i + ENTRIES + Y] - y) * t; + scaleX += (frames[i + ENTRIES + SCALEX] - scaleX) * t; + scaleY += (frames[i + ENTRIES + SCALEY] - scaleY) * t; + shearY += (frames[i + ENTRIES + SHEARY] - shearY) * t; + break; + case STEPPED: + rotate = frames[i + ROTATE]; + x = frames[i + X]; + y = frames[i + Y]; + scaleX = frames[i + SCALEX]; + scaleY = frames[i + SCALEY]; + shearY = frames[i + SHEARY]; + break; + default: + rotate = GetBezierValue(time, i, ROTATE, curveType - BEZIER); + x = GetBezierValue(time, i, X, curveType + BEZIER_SIZE - BEZIER); + y = GetBezierValue(time, i, Y, curveType + BEZIER_SIZE * 2 - BEZIER); + scaleX = GetBezierValue(time, i, SCALEX, curveType + BEZIER_SIZE * 3 - BEZIER); + scaleY = GetBezierValue(time, i, SCALEY, curveType + BEZIER_SIZE * 4 - BEZIER); + shearY = GetBezierValue(time, i, SHEARY, curveType + BEZIER_SIZE * 5 - BEZIER); + break; } if (blend == MixBlend.Setup) { @@ -2575,28 +2559,28 @@ namespace Spine { } float rotate, x, y; - int i = Animation.Search(frames, time, ENTRIES), curveType = (int)curves[i >> 2]; + int i = Search(frames, time, ENTRIES), curveType = (int)curves[i >> 2]; switch (curveType) { - case LINEAR: - float before = frames[i]; - rotate = frames[i + ROTATE]; - x = frames[i + X]; - y = frames[i + Y]; - float t = (time - before) / (frames[i + ENTRIES] - before); - rotate += (frames[i + ENTRIES + ROTATE] - rotate) * t; - x += (frames[i + ENTRIES + X] - x) * t; - y += (frames[i + ENTRIES + Y] - y) * t; - break; - case STEPPED: - rotate = frames[i + ROTATE]; - x = frames[i + X]; - y = frames[i + Y]; - break; - default: - rotate = GetBezierValue(time, i, ROTATE, curveType - BEZIER); - x = GetBezierValue(time, i, X, curveType + BEZIER_SIZE - BEZIER); - y = GetBezierValue(time, i, Y, curveType + BEZIER_SIZE * 2 - BEZIER); - break; + case LINEAR: + float before = frames[i]; + rotate = frames[i + ROTATE]; + x = frames[i + X]; + y = frames[i + Y]; + float t = (time - before) / (frames[i + ENTRIES] - before); + rotate += (frames[i + ENTRIES + ROTATE] - rotate) * t; + x += (frames[i + ENTRIES + X] - x) * t; + y += (frames[i + ENTRIES + Y] - y) * t; + break; + case STEPPED: + rotate = frames[i + ROTATE]; + x = frames[i + X]; + y = frames[i + Y]; + break; + default: + rotate = GetBezierValue(time, i, ROTATE, curveType - BEZIER); + x = GetBezierValue(time, i, X, curveType + BEZIER_SIZE - BEZIER); + y = GetBezierValue(time, i, Y, curveType + BEZIER_SIZE * 2 - BEZIER); + break; } if (blend == MixBlend.Setup) { diff --git a/spine-csharp/src/AnimationState.cs b/spine-csharp/src/AnimationState.cs index 370cf9621..809fc6c22 100644 --- a/spine-csharp/src/AnimationState.cs +++ b/spine-csharp/src/AnimationState.cs @@ -134,7 +134,7 @@ namespace Spine { /// delta time public void Update (float delta) { delta *= timeScale; - var tracksItems = tracks.Items; + TrackEntry[] tracksItems = tracks.Items; for (int i = 0, n = tracks.Count; i < n; i++) { TrackEntry current = tracksItems[i]; if (current == null) continue; @@ -225,9 +225,9 @@ namespace Spine { if (skeleton == null) throw new ArgumentNullException("skeleton", "skeleton cannot be null."); if (animationsChanged) AnimationsChanged(); - var events = this.events; + ExposedList events = this.events; bool applied = false; - var tracksItems = tracks.Items; + TrackEntry[] tracksItems = tracks.Items; for (int i = 0, n = tracks.Count; i < n; i++) { TrackEntry current = tracksItems[i]; if (current == null || current.delay > 0) continue; @@ -252,25 +252,24 @@ namespace Spine { } int timelineCount = current.animation.timelines.Count; - var timelines = current.animation.timelines; - var timelinesItems = timelines.Items; + Timeline[] timelines = current.animation.timelines.Items; if ((i == 0 && mix == 1) || blend == MixBlend.Add) { for (int ii = 0; ii < timelineCount; ii++) { - var timeline = timelinesItems[ii]; + Timeline timeline = timelines[ii]; if (timeline is AttachmentTimeline) ApplyAttachmentTimeline((AttachmentTimeline)timeline, skeleton, applyTime, blend, true); else timeline.Apply(skeleton, animationLast, applyTime, applyEvents, mix, blend, MixDirection.In); } } else { - var timelineMode = current.timelineMode.Items; + int[] timelineMode = current.timelineMode.Items; bool firstFrame = current.timelinesRotation.Count != timelineCount << 1; - if (firstFrame) current.timelinesRotation.Resize(timelines.Count << 1); - var timelinesRotation = current.timelinesRotation.Items; + if (firstFrame) current.timelinesRotation.Resize(timelineCount << 1); + float[] timelinesRotation = current.timelinesRotation.Items; for (int ii = 0; ii < timelineCount; ii++) { - Timeline timeline = timelinesItems[ii]; + Timeline timeline = timelines[ii]; MixBlend timelineBlend = timelineMode[ii] == AnimationState.Subsequent ? blend : MixBlend.Setup; var rotateTimeline = timeline as RotateTimeline; if (rotateTimeline != null) @@ -292,9 +291,9 @@ namespace Spine { // subsequent timelines see any deform, but the subsequent timelines don't set an attachment (eg they are also mixing out or // the time is before the first key). int setupState = unkeyedState + Setup; - var slots = skeleton.slots.Items; + Slot[] slots = skeleton.slots.Items; for (int i = 0, n = skeleton.slots.Count; i < n; i++) { - Slot slot = (Slot)slots[i]; + Slot slot = slots[i]; if (slot.attachmentState == setupState) { string attachmentName = slot.data.attachmentName; slot.Attachment = (attachmentName == null ? null : skeleton.GetAttachment(slot.data.index, attachmentName)); @@ -311,25 +310,23 @@ namespace Spine { public bool ApplyEventTimelinesOnly (Skeleton skeleton) { if (skeleton == null) throw new ArgumentNullException("skeleton", "skeleton cannot be null."); - var events = this.events; + ExposedList events = this.events; bool applied = false; - var tracksItems = tracks.Items; + TrackEntry[] tracksItems = tracks.Items; for (int i = 0, n = tracks.Count; i < n; i++) { TrackEntry current = tracksItems[i]; if (current == null || current.delay > 0) continue; applied = true; // Apply mixing from entries first. - if (current.mixingFrom != null) - ApplyMixingFromEventTimelinesOnly(current, skeleton); + if (current.mixingFrom != null) ApplyMixingFromEventTimelinesOnly(current, skeleton); // Apply current entry. float animationLast = current.animationLast, animationTime = current.AnimationTime; int timelineCount = current.animation.timelines.Count; - var timelines = current.animation.timelines; - var timelinesItems = timelines.Items; + Timeline[] timelines = current.animation.timelines.Items; for (int ii = 0; ii < timelineCount; ii++) { - Timeline timeline = timelinesItems[ii]; + Timeline timeline = timelines[ii]; if (timeline is EventTimeline) timeline.Apply(skeleton, animationLast, animationTime, events, 1.0f, MixBlend.Setup, MixDirection.In); } @@ -358,9 +355,8 @@ namespace Spine { } bool attachments = mix < from.attachmentThreshold, drawOrder = mix < from.drawOrderThreshold; - var timelines = from.animation.timelines; - int timelineCount = timelines.Count; - var timelinesItems = timelines.Items; + int timelineCount = from.animation.timelines.Count; + Timeline[] timelines = from.animation.timelines.Items; float alphaHold = from.alpha * to.interruptAlpha, alphaMix = alphaHold * (1 - mix); float animationLast = from.animationLast, animationTime = from.AnimationTime, applyTime = animationTime; ExposedList events = null; @@ -373,44 +369,44 @@ namespace Spine { if (blend == MixBlend.Add) { for (int i = 0; i < timelineCount; i++) - timelinesItems[i].Apply(skeleton, animationLast, applyTime, events, alphaMix, blend, MixDirection.Out); + timelines[i].Apply(skeleton, animationLast, applyTime, events, alphaMix, blend, MixDirection.Out); } else { - var timelineMode = from.timelineMode.Items; - var timelineHoldMix = from.timelineHoldMix.Items; + int[] timelineMode = from.timelineMode.Items; + TrackEntry[] timelineHoldMix = from.timelineHoldMix.Items; bool firstFrame = from.timelinesRotation.Count != timelineCount << 1; - if (firstFrame) from.timelinesRotation.Resize(timelines.Count << 1); // from.timelinesRotation.setSize - var timelinesRotation = from.timelinesRotation.Items; + if (firstFrame) from.timelinesRotation.Resize(timelineCount << 1); + float[] timelinesRotation = from.timelinesRotation.Items; from.totalAlpha = 0; for (int i = 0; i < timelineCount; i++) { - Timeline timeline = timelinesItems[i]; + Timeline timeline = timelines[i]; MixDirection direction = MixDirection.Out; MixBlend timelineBlend; float alpha; switch (timelineMode[i]) { - case AnimationState.Subsequent: - if (!drawOrder && timeline is DrawOrderTimeline) continue; - timelineBlend = blend; - alpha = alphaMix; - break; - case AnimationState.First: - timelineBlend = MixBlend.Setup; - alpha = alphaMix; - break; - case AnimationState.HoldSubsequent: - timelineBlend = blend; - alpha = alphaHold; - break; - case AnimationState.HoldFirst: - timelineBlend = MixBlend.Setup; - alpha = alphaHold; - break; - default: // HoldMix - timelineBlend = MixBlend.Setup; - TrackEntry holdMix = timelineHoldMix[i]; - alpha = alphaHold * Math.Max(0, 1 - holdMix.mixTime / holdMix.mixDuration); - break; + case AnimationState.Subsequent: + if (!drawOrder && timeline is DrawOrderTimeline) continue; + timelineBlend = blend; + alpha = alphaMix; + break; + case AnimationState.First: + timelineBlend = MixBlend.Setup; + alpha = alphaMix; + break; + case AnimationState.HoldSubsequent: + timelineBlend = blend; + alpha = alphaHold; + break; + case AnimationState.HoldFirst: + timelineBlend = MixBlend.Setup; + alpha = alphaHold; + break; + default: // HoldMix + timelineBlend = MixBlend.Setup; + TrackEntry holdMix = timelineHoldMix[i]; + alpha = alphaHold * Math.Max(0, 1 - holdMix.mixTime / holdMix.mixDuration); + break; } from.totalAlpha += alpha; var rotateTimeline = timeline as RotateTimeline; @@ -444,22 +440,19 @@ namespace Spine { float mix; if (to.mixDuration == 0) { // Single frame mix to undo mixingFrom changes. mix = 1; - } - else { + } else { mix = to.mixTime / to.mixDuration; if (mix > 1) mix = 1; } - var eventBuffer = mix < from.eventThreshold ? this.events : null; - if (eventBuffer == null) - return mix; + ExposedList eventBuffer = mix < from.eventThreshold ? this.events : null; + if (eventBuffer == null) return mix; float animationLast = from.animationLast, animationTime = from.AnimationTime; - var timelines = from.animation.timelines; - int timelineCount = timelines.Count; - var timelinesItems = timelines.Items; + int timelineCount = from.animation.timelines.Count; + Timeline[] timelines = from.animation.timelines.Items; for (int i = 0; i < timelineCount; i++) { - var timeline = timelinesItems[i]; + Timeline timeline = timelines[i]; if (timeline is EventTimeline) timeline.Apply(skeleton, animationLast, animationTime, eventBuffer, 0, MixBlend.Setup, MixDirection.Out); } @@ -486,10 +479,8 @@ namespace Spine { if (time < frames[0]) { // Time is before first frame. if (blend == MixBlend.Setup || blend == MixBlend.First) SetAttachment(skeleton, slot, slot.data.attachmentName, attachments); - } - else { - SetAttachment(skeleton, slot, timeline.AttachmentNames[Animation.Search(frames, time)], attachments); - } + } else + SetAttachment(skeleton, slot, timeline.AttachmentNames[Timeline.Search(frames, time)], attachments); // If an attachment wasn't set (ie before the first frame or attachments is false), set the setup attachment later. if (slot.attachmentState <= unkeyedState) slot.attachmentState = unkeyedState + Setup; @@ -570,8 +561,7 @@ namespace Spine { float trackLastWrapped = entry.trackLast % duration; // Queue events before complete. - var events = this.events; - var eventsItems = events.Items; + Event[] eventsItems = this.events.Items; int i = 0, n = events.Count; for (; i < n; i++) { Event e = eventsItems[i]; @@ -698,9 +688,8 @@ namespace Spine { DisposeNext(current); current = current.mixingFrom; interrupt = false; // mixingFrom is current again, but don't interrupt it twice. - } else { + } else DisposeNext(current); - } } TrackEntry entry = NewTrackEntry(trackIndex, animation, loop, current); SetCurrent(trackIndex, entry, interrupt); @@ -801,7 +790,7 @@ namespace Spine { public void SetEmptyAnimations (float mixDuration) { bool oldDrainDisabled = queue.drainDisabled; queue.drainDisabled = true; - var tracksItems = tracks.Items; + TrackEntry[] tracksItems = tracks.Items; for (int i = 0, n = tracks.Count; i < n; i++) { TrackEntry current = tracksItems[i]; if (current != null) SetEmptyAnimation(current.trackIndex, mixDuration); @@ -819,7 +808,7 @@ namespace Spine { /// Object-pooling version of new TrackEntry. Obtain an unused TrackEntry from the pool and clear/initialize its values. /// May be null. private TrackEntry NewTrackEntry (int trackIndex, Animation animation, bool loop, TrackEntry last) { - TrackEntry entry = trackEntryPool.Obtain(); // Pooling + TrackEntry entry = trackEntryPool.Obtain(); entry.trackIndex = trackIndex; entry.animation = animation; entry.loop = loop; @@ -837,14 +826,14 @@ namespace Spine { entry.delay = 0; entry.trackTime = 0; entry.trackLast = -1; - entry.nextTrackLast = -1; // nextTrackLast == -1 signifies a TrackEntry that wasn't applied yet. - entry.trackEnd = float.MaxValue; // loop ? float.MaxValue : animation.Duration; + entry.nextTrackLast = -1; + entry.trackEnd = float.MaxValue; entry.timeScale = 1; entry.alpha = 1; entry.interruptAlpha = 1; entry.mixTime = 0; - entry.mixDuration = (last == null) ? 0 : data.GetMix(last.animation, animation); + entry.mixDuration = last == null ? 0 : data.GetMix(last.animation, animation); return entry; } @@ -864,7 +853,7 @@ namespace Spine { // Process in the order that animations are applied. propertyIds.Clear(); int n = tracks.Count; - var tracksItems = tracks.Items; + TrackEntry[] tracksItems = tracks.Items; for (int i = 0; i < n; i++) { TrackEntry entry = tracksItems[i]; if (entry == null) continue; @@ -882,12 +871,12 @@ namespace Spine { private void ComputeHold (TrackEntry entry) { TrackEntry to = entry.mixingTo; - var timelines = entry.animation.timelines.Items; + Timeline[] timelines = entry.animation.timelines.Items; int timelinesCount = entry.animation.timelines.Count; - var timelineMode = entry.timelineMode.Resize(timelinesCount).Items; //timelineMode.setSize(timelinesCount); + int[] timelineMode = entry.timelineMode.Resize(timelinesCount).Items; entry.timelineHoldMix.Clear(); - var timelineHoldMix = entry.timelineHoldMix.Resize(timelinesCount).Items; //timelineHoldMix.setSize(timelinesCount); - var propertyIds = this.propertyIds; + TrackEntry[] timelineHoldMix = entry.timelineHoldMix.Resize(timelinesCount).Items; + HashSet propertyIds = this.propertyIds; if (to != null && to.holdPrevious) { for (int i = 0; i < timelinesCount; i++) @@ -958,7 +947,7 @@ namespace Spine { override public string ToString () { var buffer = new System.Text.StringBuilder(); - var tracksItems = tracks.Items; + TrackEntry[] tracksItems = tracks.Items; for (int i = 0, n = tracks.Count; i < n; i++) { TrackEntry entry = tracksItems[i]; if (entry == null) continue; @@ -1273,7 +1262,7 @@ namespace Spine { } class EventQueue { - private readonly List eventQueueEntries = new List(); + private readonly ExposedList eventQueueEntries = new ExposedList(); internal bool drainDisabled; private readonly AnimationState state; @@ -1286,22 +1275,6 @@ namespace Spine { this.trackEntryPool = trackEntryPool; } - struct EventQueueEntry { - public EventType type; - public TrackEntry entry; - public Event e; - - public EventQueueEntry (EventType eventType, TrackEntry trackEntry, Event e = null) { - this.type = eventType; - this.entry = trackEntry; - this.e = e; - } - } - - enum EventType { - Start, Interrupt, End, Dispose, Complete, Event - } - internal void Start (TrackEntry entry) { eventQueueEntries.Add(new EventQueueEntry(EventType.Start, entry)); if (AnimationsChanged != null) AnimationsChanged(); @@ -1333,12 +1306,12 @@ namespace Spine { if (drainDisabled) return; drainDisabled = true; - var entries = this.eventQueueEntries; + EventQueueEntry[] entries = eventQueueEntries.Items; AnimationState state = this.state; - // Don't cache entries.Count so callbacks can queue their own events (eg, call SetAnimation in AnimationState_Complete). - for (int i = 0; i < entries.Count; i++) { - var queueEntry = entries[i]; + // Don't cache eventQueueEntries.Count so callbacks can queue their own events (eg, call SetAnimation in AnimationState_Complete). + for (int i = 0; i < eventQueueEntries.Count; i++) { + EventQueueEntry queueEntry = entries[i]; TrackEntry trackEntry = queueEntry.entry; switch (queueEntry.type) { @@ -1357,7 +1330,7 @@ namespace Spine { case EventType.Dispose: trackEntry.OnDispose(); state.OnDispose(trackEntry); - trackEntryPool.Free(trackEntry); // Pooling + trackEntryPool.Free(trackEntry); break; case EventType.Complete: trackEntry.OnComplete(); @@ -1377,9 +1350,25 @@ namespace Spine { internal void Clear () { eventQueueEntries.Clear(); } + + struct EventQueueEntry { + public EventType type; + public TrackEntry entry; + public Event e; + + public EventQueueEntry (EventType eventType, TrackEntry trackEntry, Event e = null) { + this.type = eventType; + this.entry = trackEntry; + this.e = e; + } + } + + enum EventType { + Start, Interrupt, End, Dispose, Complete, Event + } } - public class Pool where T : class, new() { + class Pool where T : class, new() { public readonly int max; readonly Stack freeObjects; @@ -1404,19 +1393,6 @@ namespace Spine { Reset(obj); } -// protected void FreeAll (List objects) { -// if (objects == null) throw new ArgumentNullException("objects", "objects cannot be null."); -// var freeObjects = this.freeObjects; -// int max = this.max; -// for (int i = 0; i < objects.Count; i++) { -// T obj = objects[i]; -// if (obj == null) continue; -// if (freeObjects.Count < max) freeObjects.Push(obj); -// Reset(obj); -// } -// Peak = Math.Max(Peak, freeObjects.Count); -// } - public void Clear () { freeObjects.Clear(); } @@ -1435,7 +1411,7 @@ namespace Spine { public static bool AddAll (this HashSet set, T[] addSet) { bool anyItemAdded = false; for (int i = 0, n = addSet.Length; i < n; ++i) { - var item = addSet[i]; + T item = addSet[i]; anyItemAdded |= set.Add(item); } return anyItemAdded; diff --git a/spine-csharp/src/Attachments/VertexAttachment.cs b/spine-csharp/src/Attachments/VertexAttachment.cs index 5466c7514..a60373534 100644 --- a/spine-csharp/src/Attachments/VertexAttachment.cs +++ b/spine-csharp/src/Attachments/VertexAttachment.cs @@ -78,8 +78,7 @@ namespace Spine { /// The number of entries between the value pairs written. public void ComputeWorldVertices (Slot slot, int start, int count, float[] worldVertices, int offset, int stride = 2) { count = offset + (count >> 1) * stride; - Skeleton skeleton = slot.bone.skeleton; - var deformArray = slot.deform; + ExposedList deformArray = slot.deform; float[] vertices = this.vertices; int[] bones = this.bones; if (bones == null) { @@ -100,7 +99,7 @@ namespace Spine { v += n + 1; skip += n; } - var skeletonBones = skeleton.bones.Items; + Bone[] skeletonBones = slot.bone.skeleton.bones.Items; if (deformArray.Count == 0) { for (int w = offset, b = skip * 3; w < count; w += stride) { float wx = 0, wy = 0; @@ -138,15 +137,13 @@ namespace Spine { if (bones != null) { attachment.bones = new int[bones.Length]; Array.Copy(bones, 0, attachment.bones, 0, bones.Length); - } - else + } else attachment.bones = null; if (vertices != null) { attachment.vertices = new float[vertices.Length]; Array.Copy(vertices, 0, attachment.vertices, 0, vertices.Length); - } - else + } else attachment.vertices = null; attachment.worldVerticesLength = worldVerticesLength; diff --git a/spine-csharp/src/Bone.cs b/spine-csharp/src/Bone.cs index 4c4c9bc98..64627eb59 100644 --- a/spine-csharp/src/Bone.cs +++ b/spine-csharp/src/Bone.cs @@ -174,77 +174,77 @@ namespace Spine { switch (data.transformMode) { case TransformMode.Normal: { - float rotationY = rotation + 90 + shearY; - float la = MathUtils.CosDeg(rotation + shearX) * scaleX; - float lb = MathUtils.CosDeg(rotationY) * scaleY; - float lc = MathUtils.SinDeg(rotation + shearX) * scaleX; - float ld = MathUtils.SinDeg(rotationY) * scaleY; - a = pa * la + pb * lc; - b = pa * lb + pb * ld; - c = pc * la + pd * lc; - d = pc * lb + pd * ld; - return; - } + float rotationY = rotation + 90 + shearY; + float la = MathUtils.CosDeg(rotation + shearX) * scaleX; + float lb = MathUtils.CosDeg(rotationY) * scaleY; + float lc = MathUtils.SinDeg(rotation + shearX) * scaleX; + float ld = MathUtils.SinDeg(rotationY) * scaleY; + a = pa * la + pb * lc; + b = pa * lb + pb * ld; + c = pc * la + pd * lc; + d = pc * lb + pd * ld; + return; + } case TransformMode.OnlyTranslation: { - float rotationY = rotation + 90 + shearY; - a = MathUtils.CosDeg(rotation + shearX) * scaleX; - b = MathUtils.CosDeg(rotationY) * scaleY; - c = MathUtils.SinDeg(rotation + shearX) * scaleX; - d = MathUtils.SinDeg(rotationY) * scaleY; - break; - } + float rotationY = rotation + 90 + shearY; + a = MathUtils.CosDeg(rotation + shearX) * scaleX; + b = MathUtils.CosDeg(rotationY) * scaleY; + c = MathUtils.SinDeg(rotation + shearX) * scaleX; + d = MathUtils.SinDeg(rotationY) * scaleY; + break; + } case TransformMode.NoRotationOrReflection: { - float s = pa * pa + pc * pc, prx; - if (s > 0.0001f) { - s = Math.Abs(pa * pd - pb * pc) / s; - pa /= skeleton.ScaleX; - pc /= skeleton.ScaleY; - pb = pc * s; - pd = pa * s; - prx = MathUtils.Atan2(pc, pa) * MathUtils.RadDeg; - } else { - pa = 0; - pc = 0; - prx = 90 - MathUtils.Atan2(pd, pb) * MathUtils.RadDeg; - } - float rx = rotation + shearX - prx; - float ry = rotation + shearY - prx + 90; - float la = MathUtils.CosDeg(rx) * scaleX; - float lb = MathUtils.CosDeg(ry) * scaleY; - float lc = MathUtils.SinDeg(rx) * scaleX; - float ld = MathUtils.SinDeg(ry) * scaleY; - a = pa * la - pb * lc; - b = pa * lb - pb * ld; - c = pc * la + pd * lc; - d = pc * lb + pd * ld; - break; + float s = pa * pa + pc * pc, prx; + if (s > 0.0001f) { + s = Math.Abs(pa * pd - pb * pc) / s; + pa /= skeleton.ScaleX; + pc /= skeleton.ScaleY; + pb = pc * s; + pd = pa * s; + prx = MathUtils.Atan2(pc, pa) * MathUtils.RadDeg; + } else { + pa = 0; + pc = 0; + prx = 90 - MathUtils.Atan2(pd, pb) * MathUtils.RadDeg; } + float rx = rotation + shearX - prx; + float ry = rotation + shearY - prx + 90; + float la = MathUtils.CosDeg(rx) * scaleX; + float lb = MathUtils.CosDeg(ry) * scaleY; + float lc = MathUtils.SinDeg(rx) * scaleX; + float ld = MathUtils.SinDeg(ry) * scaleY; + a = pa * la - pb * lc; + b = pa * lb - pb * ld; + c = pc * la + pd * lc; + d = pc * lb + pd * ld; + break; + } case TransformMode.NoScale: case TransformMode.NoScaleOrReflection: { - float cos = MathUtils.CosDeg(rotation), sin = MathUtils.SinDeg(rotation); - float za = (pa * cos + pb * sin) / skeleton.ScaleX; - float zc = (pc * cos + pd * sin) / skeleton.ScaleY; - float s = (float)Math.Sqrt(za * za + zc * zc); - if (s > 0.00001f) s = 1 / s; - za *= s; - zc *= s; - 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; + float cos = MathUtils.CosDeg(rotation), sin = MathUtils.SinDeg(rotation); + float za = (pa * cos + pb * sin) / skeleton.ScaleX; + float zc = (pc * cos + pd * sin) / skeleton.ScaleY; + float s = (float)Math.Sqrt(za * za + zc * zc); + if (s > 0.00001f) s = 1 / s; + za *= s; + zc *= s; + 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; - float r = MathUtils.PI / 2 + MathUtils.Atan2(zc, za); - float zb = MathUtils.Cos(r) * s; - float zd = MathUtils.Sin(r) * s; - float la = MathUtils.CosDeg(shearX) * scaleX; - float lb = MathUtils.CosDeg(90 + shearY) * scaleY; - float lc = MathUtils.SinDeg(shearX) * scaleX; - float ld = MathUtils.SinDeg(90 + shearY) * scaleY; - a = za * la + zb * lc; - b = za * lb + zb * ld; - c = zc * la + zd * lc; - d = zc * lb + zd * ld; - break; - } + float r = MathUtils.PI / 2 + MathUtils.Atan2(zc, za); + float zb = MathUtils.Cos(r) * s; + float zd = MathUtils.Sin(r) * s; + float la = MathUtils.CosDeg(shearX) * scaleX; + float lb = MathUtils.CosDeg(90 + shearY) * scaleY; + float lc = MathUtils.SinDeg(shearX) * scaleX; + float ld = MathUtils.SinDeg(90 + shearY) * scaleY; + a = za * la + zb * lc; + b = za * lb + zb * ld; + c = zc * la + zd * lc; + d = zc * lb + zd * ld; + break; + } } a *= skeleton.ScaleX; diff --git a/spine-csharp/src/ExposedList.cs b/spine-csharp/src/ExposedList.cs index 7d0b69711..55e00eabd 100644 --- a/spine-csharp/src/ExposedList.cs +++ b/spine-csharp/src/ExposedList.cs @@ -198,10 +198,11 @@ namespace Spine { if (converter == null) throw new ArgumentNullException("converter"); ExposedList u = new ExposedList(Count); - for (int i = 0; i < Count; i++) - u.Items[i] = converter(Items[i]); - u.Count = Count; + T[] items = Items; + TOutput[] uItems = u.Items; + for (int i = 0; i < Count; i++) + uItems[i] = converter(items[i]); return u; } diff --git a/spine-csharp/src/IkConstraint.cs b/spine-csharp/src/IkConstraint.cs index ecc3c796a..4018ee423 100644 --- a/spine-csharp/src/IkConstraint.cs +++ b/spine-csharp/src/IkConstraint.cs @@ -293,8 +293,7 @@ namespace Spine { sx *= a; if (uniform) sy *= a; } - } - else + } else a2 = (float)Math.Acos(cos) * bendDir; a = l1 + l2 * cos; b = l2 * (float)Math.Sin(a2); diff --git a/spine-csharp/src/PathConstraint.cs b/spine-csharp/src/PathConstraint.cs index 275620b8f..b114cca76 100644 --- a/spine-csharp/src/PathConstraint.cs +++ b/spine-csharp/src/PathConstraint.cs @@ -103,63 +103,62 @@ namespace Spine { float[] spaces = this.spaces.Resize(spacesCount).Items, lengths = scale ? this.lengths.Resize(boneCount).Items : null; float spacing = this.spacing; switch (data.spacingMode) { - case SpacingMode.Percent: - if (scale) { - for (int i = 0, n = spacesCount - 1; i < n; i++) { - Bone bone = bonesItems[i]; - float setupLength = bone.data.length; - if (setupLength < PathConstraint.Epsilon) - lengths[i] = 0; - else { - float x = setupLength * bone.a, y = setupLength * bone.c; - lengths[i] = (float)Math.Sqrt(x * x + y * y); - } - } - } - ArraysFill(spaces, 1, spacesCount, spacing); - break; - case SpacingMode.Proportional: { - float sum = 0; - for (int i = 0; i < boneCount;) { + case SpacingMode.Percent: + if (scale) { + for (int i = 0, n = spacesCount - 1; i < n; i++) { Bone bone = bonesItems[i]; float setupLength = bone.data.length; - if (setupLength < PathConstraint.Epsilon) { - if (scale) lengths[i] = 0; - spaces[++i] = spacing; - } else { - float x = setupLength * bone.a, y = setupLength * bone.c; - float length = (float)Math.Sqrt(x * x + y * y); - if (scale) lengths[i] = length; - spaces[++i] = length; - sum += length; - } - } - if (sum > 0) { - sum = spacesCount / sum * spacing; - for (int i = 1; i < spacesCount; i++) - spaces[i] *= sum; - } - break; - } - default: { - bool lengthSpacing = data.spacingMode == SpacingMode.Length; - - for (int i = 0, n = spacesCount - 1; i < n;) { - Bone bone = bonesItems[i]; - float setupLength = bone.data.length; - if (setupLength < PathConstraint.Epsilon) { - if (scale) lengths[i] = 0; - spaces[++i] = spacing; - } + if (setupLength < PathConstraint.Epsilon) + lengths[i] = 0; else { float x = setupLength * bone.a, y = setupLength * bone.c; - float length = (float)Math.Sqrt(x * x + y * y); - if (scale) lengths[i] = length; - spaces[++i] = (lengthSpacing ? setupLength + spacing : spacing) * length / setupLength; + lengths[i] = (float)Math.Sqrt(x * x + y * y); } } - break; } + ArraysFill(spaces, 1, spacesCount, spacing); + break; + case SpacingMode.Proportional: { + float sum = 0; + for (int i = 0; i < boneCount;) { + Bone bone = bonesItems[i]; + float setupLength = bone.data.length; + if (setupLength < PathConstraint.Epsilon) { + if (scale) lengths[i] = 0; + spaces[++i] = spacing; + } else { + float x = setupLength * bone.a, y = setupLength * bone.c; + float length = (float)Math.Sqrt(x * x + y * y); + if (scale) lengths[i] = length; + spaces[++i] = length; + sum += length; + } + } + if (sum > 0) { + sum = spacesCount / sum * spacing; + for (int i = 1; i < spacesCount; i++) + spaces[i] *= sum; + } + break; + } + default: { + bool lengthSpacing = data.spacingMode == SpacingMode.Length; + + for (int i = 0, n = spacesCount - 1; i < n;) { + Bone bone = bonesItems[i]; + float setupLength = bone.data.length; + if (setupLength < PathConstraint.Epsilon) { + if (scale) lengths[i] = 0; + spaces[++i] = spacing; + } else { + float x = setupLength * bone.a, y = setupLength * bone.c; + float length = (float)Math.Sqrt(x * x + y * y); + if (scale) lengths[i] = length; + spaces[++i] = (lengthSpacing ? setupLength + spacing : spacing) * length / setupLength; + } + } + break; + } } float[] positions = ComputeWorldPositions(attachment, spacesCount, tangents); @@ -221,14 +220,13 @@ namespace Spine { } float[] ComputeWorldPositions (PathAttachment path, int spacesCount, bool tangents) { - Slot target = this.target; float position = this.position; float[] spaces = this.spaces.Items, output = this.positions.Resize(spacesCount * 3 + 2).Items, world; bool closed = path.Closed; int verticesLength = path.WorldVerticesLength, curveCount = verticesLength / 6, prevCurve = NONE; - float pathLength; - float multiplier; + + float pathLength, multiplier; if (!path.ConstantSpeed) { float[] lengths = path.Lengths; curveCount -= closed ? 1 : 2; @@ -236,17 +234,16 @@ namespace Spine { if (data.positionMode == PositionMode.Percent) position *= pathLength; - //float multiplier; switch (data.spacingMode) { - case SpacingMode.Percent: - multiplier = pathLength; - break; - case SpacingMode.Proportional: - multiplier = pathLength / spacesCount; - break; - default: - multiplier = 1; - break; + case SpacingMode.Percent: + multiplier = pathLength; + break; + case SpacingMode.Proportional: + multiplier = pathLength / spacesCount; + break; + default: + multiplier = 1; + break; } world = this.world.Resize(8).Items; @@ -355,17 +352,16 @@ namespace Spine { if (data.positionMode == PositionMode.Percent) position *= pathLength; - //float multiplier; switch (data.spacingMode) { - case SpacingMode.Percent: - multiplier = pathLength; - break; - case SpacingMode.Proportional: - multiplier = pathLength / spacesCount; - break; - default: - multiplier = 1; - break; + case SpacingMode.Percent: + multiplier = pathLength; + break; + case SpacingMode.Proportional: + multiplier = pathLength / spacesCount; + break; + default: + multiplier = 1; + break; } float[] segments = this.segments; diff --git a/spine-csharp/src/Skeleton.cs b/spine-csharp/src/Skeleton.cs index a9b482d29..f7af22e88 100644 --- a/spine-csharp/src/Skeleton.cs +++ b/spine-csharp/src/Skeleton.cs @@ -87,7 +87,7 @@ namespace Spine { this.data = data; bones = new ExposedList(data.bones.Count); - var bonesItems = this.bones.Items; + Bone[] bonesItems = this.bones.Items; foreach (BoneData boneData in data.bones) { Bone bone; if (boneData.parent == null) { @@ -131,17 +131,17 @@ namespace Spine { var updateCache = this.updateCache; updateCache.Clear(); - int boneCount = this.bones.Items.Length; - var bones = this.bones; + int boneCount = this.bones.Count; + Bone[] bones = this.bones.Items; for (int i = 0; i < boneCount; i++) { - Bone bone = bones.Items[i]; + Bone bone = bones[i]; bone.sorted = bone.data.skinRequired; bone.active = !bone.sorted; } if (skin != null) { - Object[] skinBones = skin.bones.Items; + BoneData[] skinBones = skin.bones.Items; for (int i = 0, n = skin.bones.Count; i < n; i++) { - Bone bone = (Bone)bones.Items[((BoneData)skinBones[i]).index]; + var bone = bones[skinBones[i].index]; do { bone.sorted = false; bone.active = true; @@ -151,38 +151,37 @@ namespace Spine { } int ikCount = this.ikConstraints.Count, transformCount = this.transformConstraints.Count, pathCount = this.pathConstraints.Count; - var ikConstraints = this.ikConstraints; - var transformConstraints = this.transformConstraints; - var pathConstraints = this.pathConstraints; + IkConstraint[] ikConstraints = this.ikConstraints.Items; + TransformConstraint[] transformConstraints = this.transformConstraints.Items; + PathConstraint[] pathConstraints = this.pathConstraints.Items; int constraintCount = ikCount + transformCount + pathCount; - //outer: for (int i = 0; i < constraintCount; i++) { for (int ii = 0; ii < ikCount; ii++) { - IkConstraint constraint = ikConstraints.Items[ii]; + IkConstraint constraint = ikConstraints[ii]; if (constraint.data.order == i) { SortIkConstraint(constraint); - goto continue_outer; //continue outer; + goto continue_outer; } } for (int ii = 0; ii < transformCount; ii++) { - TransformConstraint constraint = transformConstraints.Items[ii]; + TransformConstraint constraint = transformConstraints[ii]; if (constraint.data.order == i) { SortTransformConstraint(constraint); - goto continue_outer; //continue outer; + goto continue_outer; } } for (int ii = 0; ii < pathCount; ii++) { - PathConstraint constraint = pathConstraints.Items[ii]; + PathConstraint constraint = pathConstraints[ii]; if (constraint.data.order == i) { SortPathConstraint(constraint); - goto continue_outer; //continue outer; + goto continue_outer; } } continue_outer: {} } for (int i = 0; i < boneCount; i++) - SortBone(bones.Items[i]); + SortBone(bones[i]); } private void SortIkConstraint (IkConstraint constraint) { @@ -200,8 +199,7 @@ namespace Spine { if (constrained.Count == 1) { updateCache.Add(constraint); SortReset(parent.children); - } - else { + } else { Bone child = constrained.Items[constrained.Count - 1]; SortBone(child); @@ -269,9 +267,8 @@ namespace Spine { } private void SortPathConstraintAttachment (Skin skin, int slotIndex, Bone slotBone) { - foreach (var entry in skin.Attachments) { + foreach (var entry in skin.Attachments) if (entry.SlotIndex == slotIndex) SortPathConstraintAttachment(entry.Attachment, slotBone); - } } private void SortPathConstraintAttachment (Attachment attachment, Bone slotBone) { @@ -299,7 +296,7 @@ namespace Spine { } private static void SortReset (ExposedList bones) { - var bonesItems = bones.Items; + Bone[] bonesItems = bones.Items; for (int i = 0, n = bones.Count; i < n; i++) { Bone bone = bonesItems[i]; if (!bone.active) continue; @@ -308,7 +305,6 @@ namespace Spine { } } - /// /// Updates the world transform for each bone and applies all constraints. /// @@ -316,9 +312,9 @@ namespace Spine { /// Runtimes Guide. /// public void UpdateWorldTransform () { - Object[] bones = this.bones.Items; + Bone[] bones = this.bones.Items; for (int i = 0, n = this.bones.Count; i < n; i++) { - Bone bone = (Bone)bones[i]; + Bone bone = bones[i]; bone.ax = bone.x; bone.ay = bone.y; bone.arotation = bone.rotation; @@ -360,8 +356,7 @@ namespace Spine { var updateCache = this.updateCache.Items; for (int i = 0, n = this.updateCache.Count; i < n; i++) { var updatable = updateCache[i]; - if (updatable != rootBone) - updatable.Update(); + if (updatable != rootBone) updatable.Update(); } } @@ -380,34 +375,35 @@ namespace Spine { var ikConstraints = this.ikConstraints.Items; for (int i = 0, n = this.ikConstraints.Count; i < n; i++) { IkConstraint constraint = ikConstraints[i]; - constraint.mix = constraint.data.mix; - constraint.softness = constraint.data.softness; - constraint.bendDirection = constraint.data.bendDirection; - constraint.compress = constraint.data.compress; - constraint.stretch = constraint.data.stretch; + IkConstraintData data = constraint.data; + constraint.mix = data.mix; + constraint.softness = data.softness; + constraint.bendDirection = data.bendDirection; + constraint.compress = data.compress; + constraint.stretch = data.stretch; } var transformConstraints = this.transformConstraints.Items; for (int i = 0, n = this.transformConstraints.Count; i < n; i++) { TransformConstraint constraint = transformConstraints[i]; - TransformConstraintData constraintData = constraint.data; - constraint.mixRotate = constraintData.mixRotate; - constraint.mixX = constraintData.mixX; - constraint.mixY = constraintData.mixY; - constraint.mixScaleX = constraintData.mixScaleX; - constraint.mixScaleY = constraintData.mixScaleY; - constraint.mixShearY = constraintData.mixShearY; + TransformConstraintData data = constraint.data; + constraint.mixRotate = data.mixRotate; + constraint.mixX = data.mixX; + constraint.mixY = data.mixY; + constraint.mixScaleX = data.mixScaleX; + constraint.mixScaleY = data.mixScaleY; + constraint.mixShearY = data.mixShearY; } var pathConstraints = this.pathConstraints.Items; for (int i = 0, n = this.pathConstraints.Count; i < n; i++) { PathConstraint constraint = pathConstraints[i]; - PathConstraintData constraintData = constraint.data; - constraint.position = constraintData.position; - constraint.spacing = constraintData.spacing; - constraint.mixRotate = constraintData.mixRotate; - constraint.mixX = constraintData.mixX; - constraint.mixY = constraintData.mixY; + PathConstraintData data = constraint.data; + constraint.position = data.position; + constraint.spacing = data.spacing; + constraint.mixRotate = data.mixRotate; + constraint.mixX = data.mixX; + constraint.mixY = data.mixY; } } @@ -491,9 +487,9 @@ namespace Spine { if (skin != null) newSkin.AttachAll(this, skin); else { - ExposedList slots = this.slots; - for (int i = 0, n = slots.Count; i < n; i++) { - Slot slot = slots.Items[i]; + Slot[] slots = this.slots.Items; + for (int i = 0, n = this.slots.Count; i < n; i++) { + Slot slot = slots[i]; string name = slot.data.attachmentName; if (name != null) { Attachment attachment = newSkin.GetAttachment(i, name); @@ -527,9 +523,9 @@ namespace Spine { /// May be null to clear the slot's attachment. public void SetAttachment (string slotName, string attachmentName) { if (slotName == null) throw new ArgumentNullException("slotName", "slotName cannot be null."); - ExposedList slots = this.slots; - for (int i = 0, n = slots.Count; i < n; i++) { - Slot slot = slots.Items[i]; + Slot[] slots = this.slots.Items; + for (int i = 0, n = this.slots.Count; i < n; i++) { + Slot slot = slots[i]; if (slot.data.name == slotName) { Attachment attachment = null; if (attachmentName != null) { diff --git a/spine-csharp/src/SkeletonBinary.cs b/spine-csharp/src/SkeletonBinary.cs index 1b8702107..68fb34356 100644 --- a/spine-csharp/src/SkeletonBinary.cs +++ b/spine-csharp/src/SkeletonBinary.cs @@ -376,162 +376,162 @@ namespace Spine { switch ((AttachmentType)input.ReadByte()) { case AttachmentType.Region: { - String path = input.ReadStringRef(); - float rotation = input.ReadFloat(); - float x = input.ReadFloat(); - float y = input.ReadFloat(); - float scaleX = input.ReadFloat(); - float scaleY = input.ReadFloat(); - float width = input.ReadFloat(); - float height = input.ReadFloat(); - int color = input.ReadInt(); + String path = input.ReadStringRef(); + float rotation = input.ReadFloat(); + float x = input.ReadFloat(); + float y = input.ReadFloat(); + float scaleX = input.ReadFloat(); + float scaleY = input.ReadFloat(); + float width = input.ReadFloat(); + float height = input.ReadFloat(); + int color = input.ReadInt(); - if (path == null) path = name; - RegionAttachment region = attachmentLoader.NewRegionAttachment(skin, name, path); - if (region == null) return null; - region.Path = path; - region.x = x * scale; - region.y = y * scale; - region.scaleX = scaleX; - region.scaleY = scaleY; - region.rotation = rotation; - region.width = width * scale; - region.height = height * scale; - region.r = ((color & 0xff000000) >> 24) / 255f; - region.g = ((color & 0x00ff0000) >> 16) / 255f; - region.b = ((color & 0x0000ff00) >> 8) / 255f; - region.a = ((color & 0x000000ff)) / 255f; - region.UpdateOffset(); - return region; - } + if (path == null) path = name; + RegionAttachment region = attachmentLoader.NewRegionAttachment(skin, name, path); + if (region == null) return null; + region.Path = path; + region.x = x * scale; + region.y = y * scale; + region.scaleX = scaleX; + region.scaleY = scaleY; + region.rotation = rotation; + region.width = width * scale; + region.height = height * scale; + region.r = ((color & 0xff000000) >> 24) / 255f; + region.g = ((color & 0x00ff0000) >> 16) / 255f; + region.b = ((color & 0x0000ff00) >> 8) / 255f; + region.a = ((color & 0x000000ff)) / 255f; + region.UpdateOffset(); + return region; + } case AttachmentType.Boundingbox: { - int vertexCount = input.ReadInt(true); - Vertices vertices = ReadVertices(input, vertexCount); - if (nonessential) input.ReadInt(); //int color = nonessential ? input.ReadInt() : 0; // Avoid unused local warning. + int vertexCount = input.ReadInt(true); + Vertices vertices = ReadVertices(input, vertexCount); + if (nonessential) input.ReadInt(); //int color = nonessential ? input.ReadInt() : 0; // Avoid unused local warning. - BoundingBoxAttachment box = attachmentLoader.NewBoundingBoxAttachment(skin, name); - if (box == null) return null; - box.worldVerticesLength = vertexCount << 1; - box.vertices = vertices.vertices; - box.bones = vertices.bones; - // skipped porting: if (nonessential) Color.rgba8888ToColor(box.getColor(), color); - return box; - } + BoundingBoxAttachment box = attachmentLoader.NewBoundingBoxAttachment(skin, name); + if (box == null) return null; + box.worldVerticesLength = vertexCount << 1; + box.vertices = vertices.vertices; + box.bones = vertices.bones; + // skipped porting: if (nonessential) Color.rgba8888ToColor(box.getColor(), color); + return box; + } case AttachmentType.Mesh: { - String path = input.ReadStringRef(); - int color = input.ReadInt(); - int vertexCount = input.ReadInt(true); - float[] uvs = ReadFloatArray(input, vertexCount << 1, 1); - int[] triangles = ReadShortArray(input); - Vertices vertices = ReadVertices(input, vertexCount); - int hullLength = input.ReadInt(true); - int[] edges = null; - float width = 0, height = 0; - if (nonessential) { - edges = ReadShortArray(input); - width = input.ReadFloat(); - height = input.ReadFloat(); - } - - if (path == null) path = name; - MeshAttachment mesh = attachmentLoader.NewMeshAttachment(skin, name, path); - if (mesh == null) return null; - mesh.Path = path; - mesh.r = ((color & 0xff000000) >> 24) / 255f; - mesh.g = ((color & 0x00ff0000) >> 16) / 255f; - mesh.b = ((color & 0x0000ff00) >> 8) / 255f; - mesh.a = ((color & 0x000000ff)) / 255f; - mesh.bones = vertices.bones; - mesh.vertices = vertices.vertices; - mesh.WorldVerticesLength = vertexCount << 1; - mesh.triangles = triangles; - mesh.regionUVs = uvs; - mesh.UpdateUVs(); - mesh.HullLength = hullLength << 1; - if (nonessential) { - mesh.Edges = edges; - mesh.Width = width * scale; - mesh.Height = height * scale; - } - return mesh; + String path = input.ReadStringRef(); + int color = input.ReadInt(); + int vertexCount = input.ReadInt(true); + float[] uvs = ReadFloatArray(input, vertexCount << 1, 1); + int[] triangles = ReadShortArray(input); + Vertices vertices = ReadVertices(input, vertexCount); + int hullLength = input.ReadInt(true); + int[] edges = null; + float width = 0, height = 0; + if (nonessential) { + edges = ReadShortArray(input); + width = input.ReadFloat(); + height = input.ReadFloat(); } + + if (path == null) path = name; + MeshAttachment mesh = attachmentLoader.NewMeshAttachment(skin, name, path); + if (mesh == null) return null; + mesh.Path = path; + mesh.r = ((color & 0xff000000) >> 24) / 255f; + mesh.g = ((color & 0x00ff0000) >> 16) / 255f; + mesh.b = ((color & 0x0000ff00) >> 8) / 255f; + mesh.a = ((color & 0x000000ff)) / 255f; + mesh.bones = vertices.bones; + mesh.vertices = vertices.vertices; + mesh.WorldVerticesLength = vertexCount << 1; + mesh.triangles = triangles; + mesh.regionUVs = uvs; + mesh.UpdateUVs(); + mesh.HullLength = hullLength << 1; + if (nonessential) { + mesh.Edges = edges; + mesh.Width = width * scale; + mesh.Height = height * scale; + } + return mesh; + } case AttachmentType.Linkedmesh: { - String path = input.ReadStringRef(); - int color = input.ReadInt(); - String skinName = input.ReadStringRef(); - String parent = input.ReadStringRef(); - bool inheritDeform = input.ReadBoolean(); - float width = 0, height = 0; - if (nonessential) { - width = input.ReadFloat(); - height = input.ReadFloat(); - } - - if (path == null) path = name; - MeshAttachment mesh = attachmentLoader.NewMeshAttachment(skin, name, path); - if (mesh == null) return null; - mesh.Path = path; - mesh.r = ((color & 0xff000000) >> 24) / 255f; - mesh.g = ((color & 0x00ff0000) >> 16) / 255f; - mesh.b = ((color & 0x0000ff00) >> 8) / 255f; - mesh.a = ((color & 0x000000ff)) / 255f; - if (nonessential) { - mesh.Width = width * scale; - mesh.Height = height * scale; - } - linkedMeshes.Add(new SkeletonJson.LinkedMesh(mesh, skinName, slotIndex, parent, inheritDeform)); - return mesh; + String path = input.ReadStringRef(); + int color = input.ReadInt(); + String skinName = input.ReadStringRef(); + String parent = input.ReadStringRef(); + bool inheritDeform = input.ReadBoolean(); + float width = 0, height = 0; + if (nonessential) { + width = input.ReadFloat(); + height = input.ReadFloat(); } + + if (path == null) path = name; + MeshAttachment mesh = attachmentLoader.NewMeshAttachment(skin, name, path); + if (mesh == null) return null; + mesh.Path = path; + mesh.r = ((color & 0xff000000) >> 24) / 255f; + mesh.g = ((color & 0x00ff0000) >> 16) / 255f; + mesh.b = ((color & 0x0000ff00) >> 8) / 255f; + mesh.a = ((color & 0x000000ff)) / 255f; + if (nonessential) { + mesh.Width = width * scale; + mesh.Height = height * scale; + } + linkedMeshes.Add(new SkeletonJson.LinkedMesh(mesh, skinName, slotIndex, parent, inheritDeform)); + return mesh; + } case AttachmentType.Path: { - bool closed = input.ReadBoolean(); - bool constantSpeed = input.ReadBoolean(); - int vertexCount = input.ReadInt(true); - Vertices vertices = ReadVertices(input, vertexCount); - float[] lengths = new float[vertexCount / 3]; - for (int i = 0, n = lengths.Length; i < n; i++) - lengths[i] = input.ReadFloat() * scale; - if (nonessential) input.ReadInt(); //int color = nonessential ? input.ReadInt() : 0; + bool closed = input.ReadBoolean(); + bool constantSpeed = input.ReadBoolean(); + int vertexCount = input.ReadInt(true); + Vertices vertices = ReadVertices(input, vertexCount); + float[] lengths = new float[vertexCount / 3]; + for (int i = 0, n = lengths.Length; i < n; i++) + lengths[i] = input.ReadFloat() * scale; + if (nonessential) input.ReadInt(); //int color = nonessential ? input.ReadInt() : 0; - PathAttachment path = attachmentLoader.NewPathAttachment(skin, name); - if (path == null) return null; - path.closed = closed; - path.constantSpeed = constantSpeed; - path.worldVerticesLength = vertexCount << 1; - path.vertices = vertices.vertices; - path.bones = vertices.bones; - path.lengths = lengths; - // skipped porting: if (nonessential) Color.rgba8888ToColor(path.getColor(), color); - return path; - } + PathAttachment path = attachmentLoader.NewPathAttachment(skin, name); + if (path == null) return null; + path.closed = closed; + path.constantSpeed = constantSpeed; + path.worldVerticesLength = vertexCount << 1; + path.vertices = vertices.vertices; + path.bones = vertices.bones; + path.lengths = lengths; + // skipped porting: if (nonessential) Color.rgba8888ToColor(path.getColor(), color); + return path; + } case AttachmentType.Point: { - float rotation = input.ReadFloat(); - float x = input.ReadFloat(); - float y = input.ReadFloat(); - if (nonessential) input.ReadInt(); //int color = nonessential ? input.ReadInt() : 0; + float rotation = input.ReadFloat(); + float x = input.ReadFloat(); + float y = input.ReadFloat(); + if (nonessential) input.ReadInt(); //int color = nonessential ? input.ReadInt() : 0; - PointAttachment point = attachmentLoader.NewPointAttachment(skin, name); - if (point == null) return null; - point.x = x * scale; - point.y = y * scale; - point.rotation = rotation; - // skipped porting: if (nonessential) point.color = color; - return point; - } + PointAttachment point = attachmentLoader.NewPointAttachment(skin, name); + if (point == null) return null; + point.x = x * scale; + point.y = y * scale; + point.rotation = rotation; + // skipped porting: if (nonessential) point.color = color; + return point; + } case AttachmentType.Clipping: { - int endSlotIndex = input.ReadInt(true); - int vertexCount = input.ReadInt(true); - Vertices vertices = ReadVertices(input, vertexCount); - if (nonessential) input.ReadInt(); + int endSlotIndex = input.ReadInt(true); + int vertexCount = input.ReadInt(true); + Vertices vertices = ReadVertices(input, vertexCount); + if (nonessential) input.ReadInt(); - ClippingAttachment clip = attachmentLoader.NewClippingAttachment(skin, name); - if (clip == null) return null; - clip.EndSlot = skeletonData.slots.Items[endSlotIndex]; - clip.worldVerticesLength = vertexCount << 1; - clip.vertices = vertices.vertices; - clip.bones = vertices.bones; - // skipped porting: if (nonessential) Color.rgba8888ToColor(clip.getColor(), color); - return clip; - } + ClippingAttachment clip = attachmentLoader.NewClippingAttachment(skin, name); + if (clip == null) return null; + clip.EndSlot = skeletonData.slots.Items[endSlotIndex]; + clip.worldVerticesLength = vertexCount << 1; + clip.vertices = vertices.vertices; + clip.bones = vertices.bones; + // skipped porting: if (nonessential) Color.rgba8888ToColor(clip.getColor(), color); + return clip; + } } return null; } @@ -865,42 +865,42 @@ namespace Spine { PathConstraintData data = skeletonData.pathConstraints.Items[index]; for (int ii = 0, nn = input.ReadInt(true); ii < nn; ii++) { switch (input.ReadByte()) { - case PATH_POSITION: - timelines - .Add(ReadTimeline(input, new PathConstraintPositionTimeline(input.ReadInt(true), input.ReadInt(true), index), - data.positionMode == PositionMode.Fixed ? scale : 1)); - break; - case PATH_SPACING: - timelines - .Add(ReadTimeline(input, new PathConstraintSpacingTimeline(input.ReadInt(true), input.ReadInt(true), index), - data.spacingMode == SpacingMode.Length || data.spacingMode == SpacingMode.Fixed ? scale : 1)); - break; - case PATH_MIX: - PathConstraintMixTimeline timeline = new PathConstraintMixTimeline(input.ReadInt(true), input.ReadInt(true), - index); - float time = input.ReadFloat(), mixRotate = input.ReadFloat(), mixX = input.ReadFloat(), mixY = input.ReadFloat(); - for (int frame = 0, bezier = 0, frameLast = timeline.FrameCount - 1; ; frame++) { - timeline.SetFrame(frame, time, mixRotate, mixX, mixY); - if (frame == frameLast) break; - float time2 = input.ReadFloat(), mixRotate2 = input.ReadFloat(), mixX2 = input.ReadFloat(), - mixY2 = input.ReadFloat(); - switch (input.ReadByte()) { - case CURVE_STEPPED: - timeline.SetStepped(frame); - break; - case CURVE_BEZIER: - SetBezier(input, timeline, bezier++, frame, 0, time, time2, mixRotate, mixRotate2, 1); - SetBezier(input, timeline, bezier++, frame, 1, time, time2, mixX, mixX2, 1); - SetBezier(input, timeline, bezier++, frame, 2, time, time2, mixY, mixY2, 1); - break; - } - time = time2; - mixRotate = mixRotate2; - mixX = mixX2; - mixY = mixY2; + case PATH_POSITION: + timelines + .Add(ReadTimeline(input, new PathConstraintPositionTimeline(input.ReadInt(true), input.ReadInt(true), index), + data.positionMode == PositionMode.Fixed ? scale : 1)); + break; + case PATH_SPACING: + timelines + .Add(ReadTimeline(input, new PathConstraintSpacingTimeline(input.ReadInt(true), input.ReadInt(true), index), + data.spacingMode == SpacingMode.Length || data.spacingMode == SpacingMode.Fixed ? scale : 1)); + break; + case PATH_MIX: + PathConstraintMixTimeline timeline = new PathConstraintMixTimeline(input.ReadInt(true), input.ReadInt(true), + index); + float time = input.ReadFloat(), mixRotate = input.ReadFloat(), mixX = input.ReadFloat(), mixY = input.ReadFloat(); + for (int frame = 0, bezier = 0, frameLast = timeline.FrameCount - 1; ; frame++) { + timeline.SetFrame(frame, time, mixRotate, mixX, mixY); + if (frame == frameLast) break; + float time2 = input.ReadFloat(), mixRotate2 = input.ReadFloat(), mixX2 = input.ReadFloat(), + mixY2 = input.ReadFloat(); + switch (input.ReadByte()) { + case CURVE_STEPPED: + timeline.SetStepped(frame); + break; + case CURVE_BEZIER: + SetBezier(input, timeline, bezier++, frame, 0, time, time2, mixRotate, mixRotate2, 1); + SetBezier(input, timeline, bezier++, frame, 1, time, time2, mixX, mixX2, 1); + SetBezier(input, timeline, bezier++, frame, 2, time, time2, mixY, mixY2, 1); + break; } - timelines.Add(timeline); - break; + time = time2; + mixRotate = mixRotate2; + mixX = mixX2; + mixY = mixY2; + } + timelines.Add(timeline); + break; } } } @@ -934,8 +934,7 @@ namespace Spine { if (scale == 1) { for (int v = start; v < end; v++) deform[v] = input.ReadFloat(); - } - else { + } else { for (int v = start; v < end; v++) deform[v] = input.ReadFloat() * scale; } @@ -948,12 +947,12 @@ namespace Spine { if (frame == frameLast) break; float time2 = input.ReadFloat(); switch (input.ReadByte()) { - case CURVE_STEPPED: - timeline.SetStepped(frame); - break; - case CURVE_BEZIER: - SetBezier(input, timeline, bezier++, frame, 0, time, time2, 0, 1, 1); - break; + case CURVE_STEPPED: + timeline.SetStepped(frame); + break; + case CURVE_BEZIER: + SetBezier(input, timeline, bezier++, frame, 0, time, time2, 0, 1, 1); + break; } time = time2; } diff --git a/spine-csharp/src/SkeletonBounds.cs b/spine-csharp/src/SkeletonBounds.cs index 7904dfa51..191548147 100644 --- a/spine-csharp/src/SkeletonBounds.cs +++ b/spine-csharp/src/SkeletonBounds.cs @@ -64,8 +64,8 @@ namespace Spine { public void Update (Skeleton skeleton, bool updateAabb) { ExposedList boundingBoxes = BoundingBoxes; ExposedList polygons = Polygons; - ExposedList slots = skeleton.slots; - int slotCount = slots.Count; + Slot[] slots = skeleton.slots.Items; + int slotCount = skeleton.slots.Count; boundingBoxes.Clear(); for (int i = 0, n = polygons.Count; i < n; i++) @@ -73,7 +73,7 @@ namespace Spine { polygons.Clear(); for (int i = 0; i < slotCount; i++) { - Slot slot = slots.Items[i]; + Slot slot = slots[i]; if (!slot.bone.active) continue; BoundingBoxAttachment boundingBox = slot.attachment as BoundingBoxAttachment; if (boundingBox == null) continue; @@ -106,9 +106,9 @@ namespace Spine { private void AabbCompute () { float minX = int.MaxValue, minY = int.MaxValue, maxX = int.MinValue, maxY = int.MinValue; - ExposedList polygons = Polygons; - for (int i = 0, n = polygons.Count; i < n; i++) { - Polygon polygon = polygons.Items[i]; + Polygon[] polygons = Polygons.Items; + for (int i = 0, n = Polygons.Count; i < n; i++) { + Polygon polygon = polygons[i]; float[] vertices = polygon.Vertices; for (int ii = 0, nn = polygon.Count; ii < nn; ii += 2) { float x = vertices[ii]; @@ -178,18 +178,18 @@ namespace Spine { /// Returns the first bounding box attachment that contains the point, or null. When doing many checks, it is usually more /// efficient to only call this method if returns true. public BoundingBoxAttachment ContainsPoint (float x, float y) { - ExposedList polygons = Polygons; - for (int i = 0, n = polygons.Count; i < n; i++) - if (ContainsPoint(polygons.Items[i], x, y)) return BoundingBoxes.Items[i]; + Polygon[] polygons = Polygons.Items; + for (int i = 0, n = Polygons.Count; i < n; i++) + if (ContainsPoint(polygons[i], x, y)) return BoundingBoxes.Items[i]; return null; } /// Returns the first bounding box attachment that contains the line segment, or null. When doing many checks, it is usually /// more efficient to only call this method if returns true. public BoundingBoxAttachment IntersectsSegment (float x1, float y1, float x2, float y2) { - ExposedList polygons = Polygons; - for (int i = 0, n = polygons.Count; i < n; i++) - if (IntersectsSegment(polygons.Items[i], x1, y1, x2, y2)) return BoundingBoxes.Items[i]; + Polygon[] polygons = Polygons.Items; + for (int i = 0, n = Polygons.Count; i < n; i++) + if (IntersectsSegment(polygons[i], x1, y1, x2, y2)) return BoundingBoxes.Items[i]; return null; } diff --git a/spine-csharp/src/SkeletonClipping.cs b/spine-csharp/src/SkeletonClipping.cs index 40b6036a6..f0d845ebb 100644 --- a/spine-csharp/src/SkeletonClipping.cs +++ b/spine-csharp/src/SkeletonClipping.cs @@ -137,8 +137,7 @@ namespace Spine { s += 3; } index += clipOutputCount + 1; - } - else { + } else { float[] clippedVerticesItems = clippedVertices.Resize(s + 3 * 2).Items; float[] clippedUVsItems = clippedUVs.Resize(s + 3 * 2).Items; clippedVerticesItems[s] = x1; @@ -224,8 +223,7 @@ namespace Spine { output.Add(edgeX); output.Add(edgeY); } - } - else if (side2) { // v1 outside, v2 inside + } else if (side2) { // v1 outside, v2 inside float c0 = inputY2 - inputY, c2 = inputX2 - inputX; float s = c0 * (edgeX2 - edgeX) - c2 * (edgeY2 - edgeY); if (Math.Abs(s) > 0.000001f) { @@ -259,12 +257,10 @@ namespace Spine { if (originalOutput != output) { originalOutput.Clear(); - for (int i = 0, n = output.Count - 2; i < n; i++) { + for (int i = 0, n = output.Count - 2; i < n; i++) originalOutput.Add(output.Items[i]); - } - } else { + } else originalOutput.Resize(originalOutput.Count - 2); - } return clipped; } diff --git a/spine-csharp/src/SkeletonData.cs b/spine-csharp/src/SkeletonData.cs index 5c390f3dc..e6f70750b 100644 --- a/spine-csharp/src/SkeletonData.cs +++ b/spine-csharp/src/SkeletonData.cs @@ -136,9 +136,9 @@ namespace Spine { /// -1 if the slot was not found. public int FindSlotIndex (string slotName) { if (slotName == null) throw new ArgumentNullException("slotName", "slotName cannot be null."); - ExposedList slots = this.slots; - for (int i = 0, n = slots.Count; i < n; i++) - if (slots.Items[i].name == slotName) return i; + SlotData[] slots = this.slots.Items; + for (int i = 0, n = this.slots.Count; i < n; i++) + if (slots[i].name == slotName) return i; return -1; } @@ -217,9 +217,9 @@ namespace Spine { /// -1 if the path constraint was not found. public int FindPathConstraintIndex (string pathConstraintName) { if (pathConstraintName == null) throw new ArgumentNullException("pathConstraintName", "pathConstraintName cannot be null."); - ExposedList pathConstraints = this.pathConstraints; - for (int i = 0, n = pathConstraints.Count; i < n; i++) - if (pathConstraints.Items[i].name.Equals(pathConstraintName)) return i; + PathConstraintData[] pathConstraints = this.pathConstraints.Items; + for (int i = 0, n = this.pathConstraints.Count; i < n; i++) + if (pathConstraints[i].name.Equals(pathConstraintName)) return i; return -1; } diff --git a/spine-csharp/src/SkeletonJson.cs b/spine-csharp/src/SkeletonJson.cs index d64c80b1b..4c1cfb9c9 100644 --- a/spine-csharp/src/SkeletonJson.cs +++ b/spine-csharp/src/SkeletonJson.cs @@ -590,8 +590,7 @@ namespace Spine { } timelines.Add(timeline); - } - else if (timelineName == "rgb") { + } else if (timelineName == "rgb") { var timeline = new RGBTimeline(values.Count, values.Count * 3, slotIndex); var keyMapEnumerator = values.GetEnumerator(); @@ -772,28 +771,23 @@ namespace Spine { else if (timelineName == "translate") { TranslateTimeline timeline = new TranslateTimeline(values.Count, values.Count << 1, boneIndex); timelines.Add(ReadTimeline(ref keyMapEnumerator, timeline, "x", "y", 0, scale)); - } - else if (timelineName == "translatex") { + } else if (timelineName == "translatex") { timelines .Add(ReadTimeline(ref keyMapEnumerator, new TranslateXTimeline(values.Count, values.Count, boneIndex), 0, scale)); - } - else if (timelineName == "translatey") { + } else if (timelineName == "translatey") { timelines .Add(ReadTimeline(ref keyMapEnumerator, new TranslateYTimeline(values.Count, values.Count, boneIndex), 0, scale)); - } - else if (timelineName == "scale") { + } else if (timelineName == "scale") { ScaleTimeline timeline = new ScaleTimeline(values.Count, values.Count << 1, boneIndex); timelines.Add(ReadTimeline(ref keyMapEnumerator, timeline, "x", "y", 1, 1)); - } - else if (timelineName == "scalex") + } else if (timelineName == "scalex") timelines.Add(ReadTimeline(ref keyMapEnumerator, new ScaleXTimeline(values.Count, values.Count, boneIndex), 1, 1)); else if (timelineName == "scaley") timelines.Add(ReadTimeline(ref keyMapEnumerator, new ScaleYTimeline(values.Count, values.Count, boneIndex), 1, 1)); else if (timelineName == "shear") { ShearTimeline timeline = new ShearTimeline(values.Count, values.Count << 1, boneIndex); timelines.Add(ReadTimeline(ref keyMapEnumerator, timeline, "x", "y", 0, 1)); - } - else if (timelineName == "shearx") + } else if (timelineName == "shearx") timelines.Add(ReadTimeline(ref keyMapEnumerator, new ShearXTimeline(values.Count, values.Count, boneIndex), 0, 1)); else if (timelineName == "sheary") timelines.Add(ReadTimeline(ref keyMapEnumerator, new ShearYTimeline(values.Count, values.Count, boneIndex), 0, 1)); @@ -906,13 +900,11 @@ namespace Spine { if (timelineName == "position") { CurveTimeline1 timeline = new PathConstraintPositionTimeline(values.Count, values.Count, index); timelines.Add(ReadTimeline(ref keyMapEnumerator, timeline, 0, data.positionMode == PositionMode.Fixed ? scale : 1)); - } - else if (timelineName == "spacing") { + } else if (timelineName == "spacing") { CurveTimeline1 timeline = new PathConstraintSpacingTimeline(values.Count, values.Count, index); timelines.Add(ReadTimeline(ref keyMapEnumerator, timeline, 0, data.spacingMode == SpacingMode.Length || data.spacingMode == SpacingMode.Fixed ? scale : 1)); - } - else if (timelineName == "mix") { + } else if (timelineName == "mix") { PathConstraintMixTimeline timeline = new PathConstraintMixTimeline(values.Count, values.Count * 3, index); var keyMap = (Dictionary)keyMapEnumerator.Current; float time = GetFloat(keyMap, "time", 0); @@ -1135,8 +1127,7 @@ namespace Spine { if (curve is string) { if (value != 0) timeline.SetStepped(frame); - } - else { + } else { var curveValues = (List)curve; int index = value << 2; float cx1 = (float)curveValues[index]; diff --git a/spine-csharp/src/Skin.cs b/spine-csharp/src/Skin.cs index 6e06b98ec..ec4234930 100644 --- a/spine-csharp/src/Skin.cs +++ b/spine-csharp/src/Skin.cs @@ -132,10 +132,11 @@ namespace Spine { /// Attach all attachments from this skin if the corresponding attachment from the old skin is currently attached. internal void AttachAll (Skeleton skeleton, Skin oldSkin) { + Slot[] slots = skeleton.slots.Items; foreach (var item in oldSkin.attachments) { SkinEntry entry = item.Value; int slotIndex = entry.slotIndex; - Slot slot = skeleton.slots.Items[slotIndex]; + Slot slot = slots[slotIndex]; if (slot.Attachment == entry.attachment) { Attachment attachment = GetAttachment(slotIndex, entry.name); if (attachment != null) slot.Attachment = attachment; diff --git a/spine-csharp/src/Triangulator.cs b/spine-csharp/src/Triangulator.cs index f0cc8dc5b..c76afdb24 100644 --- a/spine-csharp/src/Triangulator.cs +++ b/spine-csharp/src/Triangulator.cs @@ -124,15 +124,13 @@ namespace Spine { public ExposedList> Decompose (ExposedList verticesArray, ExposedList triangles) { var vertices = verticesArray.Items; var convexPolygons = this.convexPolygons; - for (int i = 0, n = convexPolygons.Count; i < n; i++) { + for (int i = 0, n = convexPolygons.Count; i < n; i++) polygonPool.Free(convexPolygons.Items[i]); - } convexPolygons.Clear(); var convexPolygonsIndices = this.convexPolygonsIndices; - for (int i = 0, n = convexPolygonsIndices.Count; i < n; i++) { + for (int i = 0, n = convexPolygonsIndices.Count; i < n; i++) polygonIndicesPool.Free(convexPolygonsIndices.Items[i]); - } convexPolygonsIndices.Clear(); var polygonIndices = polygonIndicesPool.Obtain(); diff --git a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/Animation.java b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/Animation.java index 70ff71172..abeddb68b 100644 --- a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/Animation.java +++ b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/Animation.java @@ -1994,22 +1994,23 @@ public class Animation { public void apply (Skeleton skeleton, float lastTime, float time, @Null Array events, float alpha, MixBlend blend, MixDirection direction) { - Object[] drawOrder = skeleton.drawOrder.items; if (direction == out) { - if (blend == setup) arraycopy(skeleton.slots.items, 0, drawOrder, 0, skeleton.slots.size); + if (blend == setup) arraycopy(skeleton.slots.items, 0, skeleton.drawOrder.items, 0, skeleton.slots.size); return; } if (time < frames[0]) { // Time is before first frame. - if (blend == setup || blend == first) arraycopy(skeleton.slots.items, 0, drawOrder, 0, skeleton.slots.size); + if (blend == setup || blend == first) + arraycopy(skeleton.slots.items, 0, skeleton.drawOrder.items, 0, skeleton.slots.size); return; } int[] drawOrderToSetupIndex = drawOrders[search(frames, time)]; if (drawOrderToSetupIndex == null) - arraycopy(skeleton.slots.items, 0, drawOrder, 0, skeleton.slots.size); + arraycopy(skeleton.slots.items, 0, skeleton.drawOrder.items, 0, skeleton.slots.size); else { Object[] slots = skeleton.slots.items; + Object[] drawOrder = skeleton.drawOrder.items; for (int i = 0, n = drawOrderToSetupIndex.length; i < n; i++) drawOrder[i] = slots[drawOrderToSetupIndex[i]]; } diff --git a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/attachments/VertexAttachment.java b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/attachments/VertexAttachment.java index 5208a071f..2bf633738 100644 --- a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/attachments/VertexAttachment.java +++ b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/attachments/VertexAttachment.java @@ -66,7 +66,6 @@ abstract public class VertexAttachment extends Attachment { * @param stride The number of worldVertices entries between the value pairs written. */ public void computeWorldVertices (Slot slot, int start, int count, float[] worldVertices, int offset, int stride) { count = offset + (count >> 1) * stride; - Skeleton skeleton = slot.getSkeleton(); FloatArray deformArray = slot.getDeform(); float[] vertices = this.vertices; int[] bones = this.bones; @@ -88,7 +87,7 @@ abstract public class VertexAttachment extends Attachment { v += n + 1; skip += n; } - Object[] skeletonBones = skeleton.getBones().items; + Object[] skeletonBones = slot.getSkeleton().getBones().items; if (deformArray.size == 0) { for (int w = offset, b = skip * 3; w < count; w += stride) { float wx = 0, wy = 0;