Javadoc, clean up.

This commit is contained in:
NathanSweet 2019-05-31 18:13:02 +02:00
parent b87ff7337b
commit 47c3704acd
4 changed files with 34 additions and 37 deletions

View File

@ -29,16 +29,14 @@
package com.esotericsoftware.spine; package com.esotericsoftware.spine;
import static com.esotericsoftware.spine.Animation.MixBlend.add; import static com.esotericsoftware.spine.Animation.MixBlend.*;
import static com.esotericsoftware.spine.Animation.MixBlend.first; import static com.esotericsoftware.spine.Animation.MixDirection.*;
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 com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.math.MathUtils; import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.utils.Array; import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.FloatArray; import com.badlogic.gdx.utils.FloatArray;
import com.esotericsoftware.spine.attachments.Attachment; import com.esotericsoftware.spine.attachments.Attachment;
import com.esotericsoftware.spine.attachments.VertexAttachment; import com.esotericsoftware.spine.attachments.VertexAttachment;

View File

@ -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 /** 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}. * {@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) { public void setAttachment (String slotName, String attachmentName) {
if (slotName == null) throw new IllegalArgumentException("slotName cannot be null."); if (slotName == null) throw new IllegalArgumentException("slotName cannot be null.");
Slot slot = findSlot(slotName); Slot slot = findSlot(slotName);

View File

@ -233,46 +233,42 @@ public class MeshAttachment extends VertexAttachment {
} }
public Attachment copy () { public Attachment copy () {
if (parentMesh != null) return newLinkedMesh();
MeshAttachment copy = new MeshAttachment(name); MeshAttachment copy = new MeshAttachment(name);
copy.region = region; copy.region = region;
copy.path = path; copy.path = path;
copy.color.set(color); copy.color.set(color);
copy.deformAttachment = deformAttachment; copy.deformAttachment = deformAttachment;
if (parentMesh == null) { copyTo(copy);
copyTo(copy); copy.regionUVs = new float[regionUVs.length];
copy.regionUVs = new float[regionUVs.length]; System.arraycopy(regionUVs, 0, copy.regionUVs, 0, regionUVs.length);
System.arraycopy(regionUVs, 0, copy.regionUVs, 0, regionUVs.length); copy.uvs = new float[uvs.length];
copy.uvs = new float[uvs.length]; System.arraycopy(uvs, 0, copy.uvs, 0, uvs.length);
System.arraycopy(uvs, 0, copy.uvs, 0, uvs.length); copy.triangles = new short[triangles.length];
copy.triangles = new short[triangles.length]; System.arraycopy(triangles, 0, copy.triangles, 0, triangles.length);
System.arraycopy(triangles, 0, copy.triangles, 0, triangles.length); copy.hullLength = hullLength;
copy.hullLength = hullLength;
// Nonessential. // Nonessential.
if (edges != null) { if (edges != null) {
copy.edges = new short[edges.length]; copy.edges = new short[edges.length];
System.arraycopy(edges, 0, copy.edges, 0, edges.length); System.arraycopy(edges, 0, copy.edges, 0, edges.length);
}
copy.width = width;
copy.height = height;
} else {
copy.setParentMesh(parentMesh);
copy.updateUVs();
} }
copy.width = width;
copy.height = height;
return copy; return copy;
} }
/** returns a mesh linking to this mesh. **/ /** Returns a new mesh with this mesh set as the {@link #parentMesh}. **/
public MeshAttachment newLinkedMesh () { public MeshAttachment newLinkedMesh () {
MeshAttachment linkedMesh = new MeshAttachment(name); MeshAttachment mesh = new MeshAttachment(name);
linkedMesh.region = region; mesh.region = region;
linkedMesh.path = path; mesh.path = path;
linkedMesh.color.set(color); mesh.color.set(color);
linkedMesh.deformAttachment = deformAttachment; mesh.deformAttachment = deformAttachment;
linkedMesh.setParentMesh(parentMesh != null ? parentMesh : this); mesh.setParentMesh(parentMesh != null ? parentMesh : this);
linkedMesh.updateUVs(); mesh.updateUVs();
return linkedMesh; return mesh;
} }
} }

View File

@ -30,6 +30,7 @@
package com.esotericsoftware.spine.attachments; package com.esotericsoftware.spine.attachments;
import com.badlogic.gdx.utils.FloatArray; import com.badlogic.gdx.utils.FloatArray;
import com.esotericsoftware.spine.Bone; import com.esotericsoftware.spine.Bone;
import com.esotericsoftware.spine.Skeleton; import com.esotericsoftware.spine.Skeleton;
import com.esotericsoftware.spine.Slot; import com.esotericsoftware.spine.Slot;
@ -43,11 +44,10 @@ abstract public class VertexAttachment extends Attachment {
int[] bones; int[] bones;
float[] vertices; float[] vertices;
int worldVerticesLength; int worldVerticesLength;
VertexAttachment deformAttachment; VertexAttachment deformAttachment = this;
public VertexAttachment (String name) { public VertexAttachment (String name) {
super(name); super(name);
deformAttachment = this;
} }
/** Transforms the attachment's local {@link #getVertices()} to world coordinates. If the slot's {@link Slot#getDeform()} is /** 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 () { public VertexAttachment getDeformAttachment () {
return deformAttachment; return deformAttachment;
} }
/** @param deformAttachment May be null if no deform keys should be applied. */
public void setDeformAttachment (VertexAttachment deformAttachment) { public void setDeformAttachment (VertexAttachment deformAttachment) {
this.deformAttachment = deformAttachment; this.deformAttachment = deformAttachment;
} }