mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-06 15:24:55 +08:00
[libgdx] Removed VertexAttachment#applyDeform and replaced it with VertexAttachment#deformAttachment. The attachment set on this field is used to decide if a DeformTimeline should be applied to the attachment active on the slot to which a deform timeline is applied. Also removed inheritDeform field and getters/setters from MeshAttachment.
This commit is contained in:
parent
eae88a058c
commit
b87ff7337b
@ -29,14 +29,16 @@
|
||||
|
||||
package com.esotericsoftware.spine;
|
||||
|
||||
import static com.esotericsoftware.spine.Animation.MixBlend.*;
|
||||
import static com.esotericsoftware.spine.Animation.MixDirection.*;
|
||||
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 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;
|
||||
|
||||
@ -1006,7 +1008,8 @@ public class Animation {
|
||||
Slot slot = skeleton.slots.get(slotIndex);
|
||||
if (!slot.bone.active) return;
|
||||
Attachment slotAttachment = slot.attachment;
|
||||
if (!(slotAttachment instanceof VertexAttachment) || !((VertexAttachment)slotAttachment).applyDeform(attachment)) return;
|
||||
if (!(slotAttachment instanceof VertexAttachment)
|
||||
|| ((VertexAttachment)slotAttachment).getDeformAttachment() != attachment) return;
|
||||
|
||||
FloatArray deformArray = slot.getDeform();
|
||||
if (deformArray.size == 0) blend = setup;
|
||||
|
||||
@ -40,7 +40,6 @@ import com.badlogic.gdx.utils.DataInput;
|
||||
import com.badlogic.gdx.utils.FloatArray;
|
||||
import com.badlogic.gdx.utils.IntArray;
|
||||
import com.badlogic.gdx.utils.SerializationException;
|
||||
|
||||
import com.esotericsoftware.spine.Animation.AttachmentTimeline;
|
||||
import com.esotericsoftware.spine.Animation.ColorTimeline;
|
||||
import com.esotericsoftware.spine.Animation.CurveTimeline;
|
||||
@ -304,6 +303,7 @@ public class SkeletonBinary {
|
||||
if (skin == null) throw new SerializationException("Skin not found: " + linkedMesh.skin);
|
||||
Attachment parent = skin.getAttachment(linkedMesh.slotIndex, linkedMesh.parent);
|
||||
if (parent == null) throw new SerializationException("Parent mesh not found: " + linkedMesh.parent);
|
||||
linkedMesh.mesh.setDeformAttachment(linkedMesh.inheritDeform ? (VertexAttachment)parent : linkedMesh.mesh);
|
||||
linkedMesh.mesh.setParentMesh((MeshAttachment)parent);
|
||||
linkedMesh.mesh.updateUVs();
|
||||
}
|
||||
@ -469,12 +469,11 @@ public class SkeletonBinary {
|
||||
if (mesh == null) return null;
|
||||
mesh.setPath(path);
|
||||
Color.rgba8888ToColor(mesh.getColor(), color);
|
||||
mesh.setInheritDeform(inheritDeform);
|
||||
if (nonessential) {
|
||||
mesh.setWidth(width * scale);
|
||||
mesh.setHeight(height * scale);
|
||||
}
|
||||
linkedMeshes.add(new LinkedMesh(mesh, skinName, slotIndex, parent));
|
||||
linkedMeshes.add(new LinkedMesh(mesh, skinName, slotIndex, parent, inheritDeform));
|
||||
return mesh;
|
||||
}
|
||||
case path: {
|
||||
|
||||
@ -38,7 +38,6 @@ import com.badlogic.gdx.utils.IntArray;
|
||||
import com.badlogic.gdx.utils.JsonReader;
|
||||
import com.badlogic.gdx.utils.JsonValue;
|
||||
import com.badlogic.gdx.utils.SerializationException;
|
||||
|
||||
import com.esotericsoftware.spine.Animation.AttachmentTimeline;
|
||||
import com.esotericsoftware.spine.Animation.ColorTimeline;
|
||||
import com.esotericsoftware.spine.Animation.CurveTimeline;
|
||||
@ -311,6 +310,7 @@ public class SkeletonJson {
|
||||
if (skin == null) throw new SerializationException("Skin not found: " + linkedMesh.skin);
|
||||
Attachment parent = skin.getAttachment(linkedMesh.slotIndex, linkedMesh.parent);
|
||||
if (parent == null) throw new SerializationException("Parent mesh not found: " + linkedMesh.parent);
|
||||
linkedMesh.mesh.setDeformAttachment(linkedMesh.inheritDeform ? (VertexAttachment)parent : linkedMesh.mesh);
|
||||
linkedMesh.mesh.setParentMesh((MeshAttachment)parent);
|
||||
linkedMesh.mesh.updateUVs();
|
||||
}
|
||||
@ -398,8 +398,8 @@ public class SkeletonJson {
|
||||
|
||||
String parent = map.getString("parent", null);
|
||||
if (parent != null) {
|
||||
mesh.setInheritDeform(map.getBoolean("deform", true));
|
||||
linkedMeshes.add(new LinkedMesh(mesh, map.getString("skin", null), slotIndex, parent));
|
||||
linkedMeshes
|
||||
.add(new LinkedMesh(mesh, map.getString("skin", null), slotIndex, parent, map.getBoolean("deform", true)));
|
||||
return mesh;
|
||||
}
|
||||
|
||||
@ -798,12 +798,14 @@ public class SkeletonJson {
|
||||
String parent, skin;
|
||||
int slotIndex;
|
||||
MeshAttachment mesh;
|
||||
boolean inheritDeform;
|
||||
|
||||
public LinkedMesh (MeshAttachment mesh, String skin, int slotIndex, String parent) {
|
||||
public LinkedMesh (MeshAttachment mesh, String skin, int slotIndex, String parent, boolean inheritDeform) {
|
||||
this.mesh = mesh;
|
||||
this.skin = skin;
|
||||
this.slotIndex = slotIndex;
|
||||
this.parent = parent;
|
||||
this.inheritDeform = inheritDeform;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -32,7 +32,6 @@ package com.esotericsoftware.spine.attachments;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion;
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||
import com.esotericsoftware.spine.Animation.DeformTimeline;
|
||||
|
||||
/** An attachment that displays a textured mesh. A mesh has hull vertices and internal vertices within the hull. Holes are not
|
||||
* supported. Each vertex has UVs (texture coordinates) and triangles are used to map an image on to the mesh.
|
||||
@ -46,7 +45,6 @@ public class MeshAttachment extends VertexAttachment {
|
||||
private final Color color = new Color(1, 1, 1, 1);
|
||||
private int hullLength;
|
||||
private MeshAttachment parentMesh;
|
||||
private boolean inheritDeform;
|
||||
|
||||
// Nonessential.
|
||||
private short[] edges;
|
||||
@ -130,12 +128,6 @@ public class MeshAttachment extends VertexAttachment {
|
||||
}
|
||||
}
|
||||
|
||||
/** Returns true if the <code>sourceAttachment</code> is this mesh, else returns true if {@link #inheritDeform} is true and the
|
||||
* the <code>sourceAttachment</code> is the {@link #parentMesh}. */
|
||||
public boolean applyDeform (VertexAttachment sourceAttachment) {
|
||||
return this == sourceAttachment || (inheritDeform && parentMesh == sourceAttachment);
|
||||
}
|
||||
|
||||
/** Triplets of vertex indices which describe the mesh's triangulation. */
|
||||
public short[] getTriangles () {
|
||||
return triangles;
|
||||
@ -240,24 +232,12 @@ public class MeshAttachment extends VertexAttachment {
|
||||
}
|
||||
}
|
||||
|
||||
/** When this is a linked mesh (see {@link #parentMesh}), if true, any {@link DeformTimeline} for the {@link #parentMesh} is
|
||||
* also applied to this mesh. If false, this linked mesh may have its own deform timelines.
|
||||
* <p>
|
||||
* See {@link #applyDeform(VertexAttachment)}. */
|
||||
public boolean getInheritDeform () {
|
||||
return inheritDeform;
|
||||
}
|
||||
|
||||
public void setInheritDeform (boolean inheritDeform) {
|
||||
this.inheritDeform = inheritDeform;
|
||||
}
|
||||
|
||||
public Attachment copy () {
|
||||
MeshAttachment copy = new MeshAttachment(name);
|
||||
copy.region = region;
|
||||
copy.path = path;
|
||||
copy.color.set(color);
|
||||
copy.inheritDeform = inheritDeform;
|
||||
copy.deformAttachment = deformAttachment;
|
||||
|
||||
if (parentMesh == null) {
|
||||
copyTo(copy);
|
||||
@ -290,7 +270,7 @@ public class MeshAttachment extends VertexAttachment {
|
||||
linkedMesh.region = region;
|
||||
linkedMesh.path = path;
|
||||
linkedMesh.color.set(color);
|
||||
linkedMesh.inheritDeform = inheritDeform;
|
||||
linkedMesh.deformAttachment = deformAttachment;
|
||||
linkedMesh.setParentMesh(parentMesh != null ? parentMesh : this);
|
||||
linkedMesh.updateUVs();
|
||||
return linkedMesh;
|
||||
|
||||
@ -43,9 +43,11 @@ abstract public class VertexAttachment extends Attachment {
|
||||
int[] bones;
|
||||
float[] vertices;
|
||||
int worldVerticesLength;
|
||||
VertexAttachment deformAttachment;
|
||||
|
||||
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
|
||||
@ -116,10 +118,12 @@ abstract public class VertexAttachment extends Attachment {
|
||||
}
|
||||
}
|
||||
|
||||
/** Returns true if a deform originally applied to the specified attachment should be applied to this attachment. The default
|
||||
* implementation returns true only when <code>sourceAttachment</code> is this attachment. */
|
||||
public boolean applyDeform (VertexAttachment sourceAttachment) {
|
||||
return this == sourceAttachment;
|
||||
public VertexAttachment getDeformAttachment () {
|
||||
return deformAttachment;
|
||||
}
|
||||
|
||||
public void setDeformAttachment (VertexAttachment deformAttachment) {
|
||||
this.deformAttachment = deformAttachment;
|
||||
}
|
||||
|
||||
/** The bones which affect the {@link #getVertices()}. The array entries are, for each vertex, the number of bones affecting
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user