diff --git a/spine-as3/spine-as3-example/lib/spine-as3.swc b/spine-as3/spine-as3-example/lib/spine-as3.swc index b239cee65..b9f5a7485 100644 Binary files a/spine-as3/spine-as3-example/lib/spine-as3.swc and b/spine-as3/spine-as3-example/lib/spine-as3.swc differ diff --git a/spine-as3/spine-as3/src/spine/SkeletonJson.as b/spine-as3/spine-as3/src/spine/SkeletonJson.as index 108df5a94..cdc49079f 100644 --- a/spine-as3/spine-as3/src/spine/SkeletonJson.as +++ b/spine-as3/spine-as3/src/spine/SkeletonJson.as @@ -253,6 +253,7 @@ package spine { if (!parentSkin) throw new Error("Skin not found: " + linkedMesh.skin); var parentMesh : Attachment = parentSkin.getAttachment(linkedMesh.slotIndex, linkedMesh.parent); if (!parentMesh) throw new Error("Parent mesh not found: " + linkedMesh.parent); + linkedMesh.mesh.deformAttachment = linkedMesh.inheritDeform ? VertexAttachment(parentMesh) : linkedMesh.mesh; linkedMesh.mesh.parentMesh = MeshAttachment(parentMesh); linkedMesh.mesh.updateUVs(); } @@ -322,8 +323,8 @@ package spine { mesh.width = Number(map["width"] || 0) * scale; mesh.height = Number(map["height"] || 0) * scale; if (map["parent"]) { - mesh.inheritDeform = map.hasOwnProperty("deform") ? Boolean(map["deform"]) : true; - linkedMeshes.push(new LinkedMesh(mesh, map["skin"], slotIndex, map["parent"])); + var inheritDeform : Boolean = map.hasOwnProperty("deform") ? Boolean(map["deform"]) : true; + linkedMeshes.push(new LinkedMesh(mesh, map["skin"], slotIndex, map["parent"], inheritDeform)); return mesh; } var uvs : Vector. = getFloatArray(map, "uvs", 1); @@ -786,11 +787,13 @@ class LinkedMesh { internal var parent : String, skin : String; internal var slotIndex : int; internal var mesh : MeshAttachment; + internal var inheritDeform : Boolean; - public function LinkedMesh(mesh : MeshAttachment, skin : String, slotIndex : int, parent : String) { + public function LinkedMesh(mesh : MeshAttachment, skin : String, slotIndex : int, parent : String, inheritDeform : Boolean) { this.mesh = mesh; this.skin = skin; this.slotIndex = slotIndex; this.parent = parent; + this.inheritDeform = inheritDeform; } } diff --git a/spine-as3/spine-as3/src/spine/Skin.as b/spine-as3/spine-as3/src/spine/Skin.as index ac6db68ec..0a7f937ec 100644 --- a/spine-as3/spine-as3/src/spine/Skin.as +++ b/spine-as3/spine-as3/src/spine/Skin.as @@ -119,19 +119,13 @@ package spine { var attachments : Vector. = skin.getAttachments(); for (i = 0; i < attachments.length; i++) { attachment = attachments[i]; - attachment.attachment = attachment.attachment.copy(); - setAttachment(attachment.slotIndex, attachment.name, attachment.attachment); - } - - attachments = this.getAttachments(); - for (i = 0; i < attachments.length; i++) { - attachment = attachments[i]; - if (attachment.attachment instanceof MeshAttachment) { - var mesh : MeshAttachment = attachment.attachment as MeshAttachment; - if (mesh.parentMesh) { - mesh.parentMesh = this.getAttachment(attachment.slotIndex, mesh.parentMesh.name) as MeshAttachment; - mesh.updateUVs(); - } + if (attachment.attachment == null) continue; + if (attachment.attachment is MeshAttachment) { + attachment.attachment = MeshAttachment(attachment.attachment).newLinkedMesh(); + setAttachment(attachment.slotIndex, attachment.name, attachment.attachment); + } else { + attachment.attachment = attachment.attachment.copy(); + setAttachment(attachment.slotIndex, attachment.name, attachment.attachment); } } } diff --git a/spine-as3/spine-as3/src/spine/animation/DeformTimeline.as b/spine-as3/spine-as3/src/spine/animation/DeformTimeline.as index 2fd25fd6b..a1c0f4346 100644 --- a/spine-as3/spine-as3/src/spine/animation/DeformTimeline.as +++ b/spine-as3/spine-as3/src/spine/animation/DeformTimeline.as @@ -61,7 +61,7 @@ package spine.animation { var setupVertices : Vector.; var slot : Slot = skeleton.slots[slotIndex]; var slotAttachment : Attachment = slot.attachment; - if (!(slotAttachment is VertexAttachment) || !(VertexAttachment(slotAttachment)).applyDeform(attachment)) return; + if (!(slotAttachment is VertexAttachment) || !(VertexAttachment(slotAttachment).deformAttachment == attachment)) return; var deformArray : Vector. = slot.deform; if (deformArray.length == 0) blend = MixBlend.setup; diff --git a/spine-as3/spine-as3/src/spine/attachments/MeshAttachment.as b/spine-as3/spine-as3/src/spine/attachments/MeshAttachment.as index 1f06411d8..b2d09a08e 100644 --- a/spine-as3/spine-as3/src/spine/attachments/MeshAttachment.as +++ b/spine-as3/spine-as3/src/spine/attachments/MeshAttachment.as @@ -36,8 +36,7 @@ package spine.attachments { public var triangles : Vector.; public var color : Color = new Color(1, 1, 1, 1); public var hullLength : int; - private var _parentMesh : MeshAttachment; - public var inheritDeform : Boolean; + private var _parentMesh : MeshAttachment; public var path : String; public var rendererObject : Object; public var regionU : Number; @@ -123,10 +122,6 @@ package spine.attachments { } } - override public function applyDeform(sourceAttachment : VertexAttachment) : Boolean { - return this == sourceAttachment || (inheritDeform && _parentMesh == sourceAttachment); - } - public function get parentMesh() : MeshAttachment { return _parentMesh; } @@ -161,17 +156,15 @@ package spine.attachments { copy.regionHeight = regionHeight; copy.regionOriginalWidth = regionOriginalWidth; copy.regionOriginalHeight = regionOriginalHeight; - copy.path = path; + copy.path = path; + copy.color.setFromColor(color); if (parentMesh == null) { this.copyTo(copy); copy.regionUVs = regionUVs.concat(); copy.uvs = uvs.concat(); - copy.triangles = triangles.concat(); - copy.color.setFromColor(color); - copy.hullLength = hullLength; - - copy.inheritDeform = inheritDeform; + copy.triangles = triangles.concat(); + copy.hullLength = hullLength; // Nonessential. if (edges != null) @@ -185,5 +178,28 @@ package spine.attachments { return copy; } + + public function newLinkedMesh (): MeshAttachment { + var copy : MeshAttachment = new MeshAttachment(name); + copy.rendererObject = rendererObject; + copy.regionU = regionU; + copy.regionV = regionV; + copy.regionU2 = regionU2; + copy.regionV2 = regionV2; + copy.regionRotate = regionRotate; + copy.regionDegrees = regionDegrees; + copy.regionOffsetX = regionOffsetX; + copy.regionOffsetY = regionOffsetY; + copy.regionWidth = regionWidth; + copy.regionHeight = regionHeight; + copy.regionOriginalWidth = regionOriginalWidth; + copy.regionOriginalHeight = regionOriginalHeight; + copy.path = path; + copy.color.setFromColor(color); + copy.deformAttachment = deformAttachment; + copy.parentMesh = parentMesh != null ? parentMesh : this; + copy.updateUVs(); + return copy; + } } } diff --git a/spine-as3/spine-as3/src/spine/attachments/VertexAttachment.as b/spine-as3/spine-as3/src/spine/attachments/VertexAttachment.as index cfd24be8a..91b00c3aa 100644 --- a/spine-as3/spine-as3/src/spine/attachments/VertexAttachment.as +++ b/spine-as3/spine-as3/src/spine/attachments/VertexAttachment.as @@ -39,6 +39,7 @@ package spine.attachments { public var vertices : Vector.; public var worldVerticesLength : int; public var id : int = (nextID++ & 65535) << 11; + public var deformAttachment : VertexAttachment = this; public function VertexAttachment(name : String) { super(name); @@ -124,11 +125,6 @@ package spine.attachments { } } } - - /** Returns true if a deform originally applied to the specified attachment should be applied to this attachment. */ - public function applyDeform(sourceAttachment : VertexAttachment) : Boolean { - return this == sourceAttachment; - } public function copyTo(attachment : VertexAttachment) : void { if (bones != null) { @@ -142,6 +138,7 @@ package spine.attachments { attachment.vertices = null; attachment.worldVerticesLength = worldVerticesLength; + attachment.deformAttachment = deformAttachment; } } } diff --git a/spine-starling/spine-starling-example/lib/spine-as3.swc b/spine-starling/spine-starling-example/lib/spine-as3.swc index b239cee65..b9f5a7485 100644 Binary files a/spine-starling/spine-starling-example/lib/spine-as3.swc and b/spine-starling/spine-starling-example/lib/spine-as3.swc differ diff --git a/spine-starling/spine-starling-example/src/spine/examples/GoblinsExample.as b/spine-starling/spine-starling-example/src/spine/examples/GoblinsExample.as index a58c11972..147d3b669 100644 --- a/spine-starling/spine-starling-example/src/spine/examples/GoblinsExample.as +++ b/spine-starling/spine-starling-example/src/spine/examples/GoblinsExample.as @@ -87,6 +87,11 @@ package spine.examples { skeleton.skeleton.skinName = "goblin"; skeleton.skeleton.setSlotsToSetupPose(); skeleton.state.setAnimationByName(0, "walk", true); + + var skin : Skin = new Skin("test"); + skin.copySkin(skeletonData.findSkin("goblingirl")); + skeleton.skeleton.skin = skin; + skeleton.skeleton.setToSetupPose(); addChild(skeleton); Starling.juggler.add(skeleton); diff --git a/spine-starling/spine-starling-example/src/spine/examples/Main.as b/spine-starling/spine-starling-example/src/spine/examples/Main.as index 549a36f18..ac7a3a5d0 100644 --- a/spine-starling/spine-starling-example/src/spine/examples/Main.as +++ b/spine-starling/spine-starling-example/src/spine/examples/Main.as @@ -37,7 +37,7 @@ package spine.examples { private var _starling : Starling; public function Main() { - _starling = new Starling(OwlExample, stage); + _starling = new Starling(GoblinsExample, stage); _starling.enableErrorChecking = true; _starling.showStats = true; _starling.skipUnchangedFrames = false; diff --git a/spine-starling/spine-starling-example/src/spine/examples/OwlExample.as b/spine-starling/spine-starling-example/src/spine/examples/OwlExample.as index a4baa3f9c..848d0a273 100644 --- a/spine-starling/spine-starling-example/src/spine/examples/OwlExample.as +++ b/spine-starling/spine-starling-example/src/spine/examples/OwlExample.as @@ -89,11 +89,6 @@ package spine.examples { skeleton.state.update(0.25); skeleton.state.apply(skeleton.skeleton); skeleton.skeleton.updateWorldTransform(); - - var skin : Skin = new Skin("test"); - skin.addSkin(skeletonData.findSkin("default")); - skeleton.skeleton.skin = skin; - skeleton.skeleton.setToSetupPose(); addChild(skeleton); Starling.juggler.add(skeleton); diff --git a/spine-starling/spine-starling/lib/spine-as3.swc b/spine-starling/spine-starling/lib/spine-as3.swc index b239cee65..b9f5a7485 100644 Binary files a/spine-starling/spine-starling/lib/spine-as3.swc and b/spine-starling/spine-starling/lib/spine-as3.swc differ