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 9f90884bd..ef50d9546 100644 --- a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/Animation.java +++ b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/Animation.java @@ -29,16 +29,14 @@ package com.esotericsoftware.spine; -import static com.esotericsoftware.spine.Animation.MixBlend.add; -import static com.esotericsoftware.spine.Animation.MixBlend.first; -import static com.esotericsoftware.spine.Animation.MixBlend.setup; -import static com.esotericsoftware.spine.Animation.MixDirection.in; -import static com.esotericsoftware.spine.Animation.MixDirection.out; +import static com.esotericsoftware.spine.Animation.MixBlend.*; +import static com.esotericsoftware.spine.Animation.MixDirection.*; import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.math.MathUtils; import com.badlogic.gdx.utils.Array; import com.badlogic.gdx.utils.FloatArray; + import com.esotericsoftware.spine.attachments.Attachment; import com.esotericsoftware.spine.attachments.VertexAttachment; diff --git a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/Skeleton.java b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/Skeleton.java index 3ab8b8fe3..04bdfca6d 100644 --- a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/Skeleton.java +++ b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/Skeleton.java @@ -587,7 +587,7 @@ public class Skeleton { /** A convenience method to set an attachment by finding the slot with {@link #findSlot(String)}, finding the attachment with * {@link #getAttachment(int, String)}, then setting the slot's {@link Slot#attachment}. - * @param attachmentName May be null to clear the slot. */ + * @param attachmentName May be null to clear the slot's attachment. */ public void setAttachment (String slotName, String attachmentName) { if (slotName == null) throw new IllegalArgumentException("slotName cannot be null."); Slot slot = findSlot(slotName); diff --git a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/attachments/MeshAttachment.java b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/attachments/MeshAttachment.java index 240388e77..d37170efa 100644 --- a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/attachments/MeshAttachment.java +++ b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/attachments/MeshAttachment.java @@ -233,46 +233,42 @@ public class MeshAttachment extends VertexAttachment { } public Attachment copy () { + if (parentMesh != null) return newLinkedMesh(); + MeshAttachment copy = new MeshAttachment(name); copy.region = region; copy.path = path; copy.color.set(color); copy.deformAttachment = deformAttachment; - if (parentMesh == null) { - copyTo(copy); - copy.regionUVs = new float[regionUVs.length]; - System.arraycopy(regionUVs, 0, copy.regionUVs, 0, regionUVs.length); - copy.uvs = new float[uvs.length]; - System.arraycopy(uvs, 0, copy.uvs, 0, uvs.length); - copy.triangles = new short[triangles.length]; - System.arraycopy(triangles, 0, copy.triangles, 0, triangles.length); - copy.hullLength = hullLength; + copyTo(copy); + copy.regionUVs = new float[regionUVs.length]; + System.arraycopy(regionUVs, 0, copy.regionUVs, 0, regionUVs.length); + copy.uvs = new float[uvs.length]; + System.arraycopy(uvs, 0, copy.uvs, 0, uvs.length); + copy.triangles = new short[triangles.length]; + System.arraycopy(triangles, 0, copy.triangles, 0, triangles.length); + copy.hullLength = hullLength; - // Nonessential. - if (edges != null) { - copy.edges = new short[edges.length]; - System.arraycopy(edges, 0, copy.edges, 0, edges.length); - } - copy.width = width; - copy.height = height; - } else { - copy.setParentMesh(parentMesh); - copy.updateUVs(); + // Nonessential. + if (edges != null) { + copy.edges = new short[edges.length]; + System.arraycopy(edges, 0, copy.edges, 0, edges.length); } - + copy.width = width; + copy.height = height; return copy; } - /** returns a mesh linking to this mesh. **/ + /** Returns a new mesh with this mesh set as the {@link #parentMesh}. **/ public MeshAttachment newLinkedMesh () { - MeshAttachment linkedMesh = new MeshAttachment(name); - linkedMesh.region = region; - linkedMesh.path = path; - linkedMesh.color.set(color); - linkedMesh.deformAttachment = deformAttachment; - linkedMesh.setParentMesh(parentMesh != null ? parentMesh : this); - linkedMesh.updateUVs(); - return linkedMesh; + MeshAttachment mesh = new MeshAttachment(name); + mesh.region = region; + mesh.path = path; + mesh.color.set(color); + mesh.deformAttachment = deformAttachment; + mesh.setParentMesh(parentMesh != null ? parentMesh : this); + mesh.updateUVs(); + return mesh; } } 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 2f41eef85..3df2beb3a 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 @@ -30,6 +30,7 @@ package com.esotericsoftware.spine.attachments; import com.badlogic.gdx.utils.FloatArray; + import com.esotericsoftware.spine.Bone; import com.esotericsoftware.spine.Skeleton; import com.esotericsoftware.spine.Slot; @@ -43,11 +44,10 @@ abstract public class VertexAttachment extends Attachment { int[] bones; float[] vertices; int worldVerticesLength; - VertexAttachment deformAttachment; + VertexAttachment deformAttachment = this; public VertexAttachment (String name) { super(name); - deformAttachment = this; } /** Transforms the attachment's local {@link #getVertices()} to world coordinates. If the slot's {@link Slot#getDeform()} is @@ -118,10 +118,13 @@ abstract public class VertexAttachment extends Attachment { } } + /** Deform keys for the deform attachment are also applied to this attachment. + * @return May be null if no deform keys should be applied. */ public VertexAttachment getDeformAttachment () { return deformAttachment; } + /** @param deformAttachment May be null if no deform keys should be applied. */ public void setDeformAttachment (VertexAttachment deformAttachment) { this.deformAttachment = deformAttachment; }