NathanSweet 11 роки тому
батько
коміт
1671d6bd9f

+ 1 - 1
spine-libgdx/src/com/esotericsoftware/spine/SkeletonBinary.java

@@ -258,7 +258,7 @@ public class SkeletonBinary {
 					weights.add(input.readFloat());
 					weights.add(input.readFloat());
 				}
 				}
 			}
 			}
-			mesh.setMesh(bones.toArray(), weights.toArray(), uvs, triangles);
+			mesh.setMesh(bones.toArray(), weights.toArray(), triangles, uvs);
 
 
 			Color.rgba8888ToColor(mesh.getColor(), input.readInt());
 			Color.rgba8888ToColor(mesh.getColor(), input.readInt());
 			if (nonessential) {
 			if (nonessential) {

+ 1 - 1
spine-libgdx/src/com/esotericsoftware/spine/SkeletonJson.java

@@ -239,7 +239,7 @@ public class SkeletonJson {
 					i += 4;
 					i += 4;
 				}
 				}
 			}
 			}
-			mesh.setMesh(bones.toArray(), weights.toArray(), uvs, triangles);
+			mesh.setMesh(bones.toArray(), weights.toArray(), triangles, uvs);
 
 
 			if (map.has("hull")) mesh.setHullLength(map.require("hull").asInt() * 2);
 			if (map.has("hull")) mesh.setHullLength(map.require("hull").asInt() * 2);
 			if (map.has("edges")) mesh.setEdges(map.require("edges").asIntArray());
 			if (map.has("edges")) mesh.setEdges(map.require("edges").asIntArray());

+ 2 - 2
spine-libgdx/src/com/esotericsoftware/spine/SkeletonRenderer.java

@@ -43,7 +43,7 @@ import com.badlogic.gdx.graphics.g2d.PolygonSpriteBatch;
 import com.badlogic.gdx.utils.Array;
 import com.badlogic.gdx.utils.Array;
 
 
 public class SkeletonRenderer {
 public class SkeletonRenderer {
-	static private final short[] quadTriangle = {0, 1, 2, 2, 3, 0};
+	static private final short[] quadTriangles = {0, 1, 2, 2, 3, 0};
 
 
 	private boolean premultipliedAlpha;
 	private boolean premultipliedAlpha;
 
 
@@ -65,7 +65,7 @@ public class SkeletonRenderer {
 				RegionAttachment region = (RegionAttachment)attachment;
 				RegionAttachment region = (RegionAttachment)attachment;
 				region.updateWorldVertices(slot, premultipliedAlpha);
 				region.updateWorldVertices(slot, premultipliedAlpha);
 				vertices = region.getWorldVertices();
 				vertices = region.getWorldVertices();
-				triangles = quadTriangle;
+				triangles = quadTriangles;
 				texture = region.getRegion().getTexture();
 				texture = region.getRegion().getTexture();
 
 
 				if (slot.data.getAdditiveBlending() != additive) {
 				if (slot.data.getAdditiveBlending() != additive) {

+ 31 - 31
spine-libgdx/src/com/esotericsoftware/spine/attachments/MeshAttachment.java

@@ -50,9 +50,9 @@ public class MeshAttachment extends Attachment {
 	private final Color color = new Color(1, 1, 1, 1);
 	private final Color color = new Color(1, 1, 1, 1);
 
 
 	// Nonessential.
 	// Nonessential.
+	private int hullLength;
 	private int[] edges;
 	private int[] edges;
 	private float width, height;
 	private float width, height;
-	private int hullLength;
 
 
 	public MeshAttachment (String name) {
 	public MeshAttachment (String name) {
 		super(name);
 		super(name);
@@ -68,6 +68,36 @@ public class MeshAttachment extends Attachment {
 		return region;
 		return region;
 	}
 	}
 
 
+	public void setMesh (float[] vertices, short[] triangles, float[] uvs) {
+		this.vertices = vertices;
+		this.triangles = triangles;
+
+		int worldVerticesLength = vertices.length / 2 * 5;
+		if (worldVertices == null || worldVertices.length != worldVerticesLength) worldVertices = new float[worldVerticesLength];
+
+		float u, v, width, height;
+		if (region == null) {
+			u = v = 0;
+			width = height = 1;
+		} else {
+			u = region.getU();
+			v = region.getV();
+			width = region.getU2() - u;
+			height = region.getV2() - v;
+		}
+		if (region instanceof AtlasRegion && ((AtlasRegion)region).rotate) {
+			for (int i = 0, w = 3, n = vertices.length; i < n; i += 2, w += 5) {
+				worldVertices[w] = u + uvs[i + 1] * width;
+				worldVertices[w + 1] = v + height - uvs[i] * height;
+			}
+		} else {
+			for (int i = 0, w = 3, n = vertices.length; i < n; i += 2, w += 5) {
+				worldVertices[w] = u + uvs[i] * width;
+				worldVertices[w + 1] = v + uvs[i + 1] * height;
+			}
+		}
+	}
+
 	public void updateWorldVertices (Slot slot, boolean premultipliedAlpha) {
 	public void updateWorldVertices (Slot slot, boolean premultipliedAlpha) {
 		Skeleton skeleton = slot.getSkeleton();
 		Skeleton skeleton = slot.getSkeleton();
 		Color skeletonColor = skeleton.getColor();
 		Color skeletonColor = skeleton.getColor();
@@ -152,34 +182,4 @@ public class MeshAttachment extends Attachment {
 	public void setHeight (float height) {
 	public void setHeight (float height) {
 		this.height = height;
 		this.height = height;
 	}
 	}
-
-	public void setMesh (float[] vertices, short[] triangles, float[] uvs) {
-		this.vertices = vertices;
-		this.triangles = triangles;
-
-		int worldVerticesLength = vertices.length / 2 * 5;
-		if (worldVertices == null || worldVertices.length != worldVerticesLength) worldVertices = new float[worldVerticesLength];
-
-		float u, v, w, h;
-		if (region == null) {
-			u = v = 0;
-			w = h = 1;
-		} else {
-			u = region.getU();
-			v = region.getV();
-			w = region.getU2() - u;
-			h = region.getV2() - v;
-		}
-		if (region instanceof AtlasRegion && ((AtlasRegion)region).rotate) {
-			for (int i = 0, ii = 3, n = vertices.length; i < n; i += 2, ii += 5) {
-				worldVertices[ii] = u + uvs[i + 1] * w;
-				worldVertices[ii + 1] = v + h - uvs[i] * h;
-			}
-		} else {
-			for (int i = 0, ii = 3, n = vertices.length; i < n; i += 2, ii += 5) {
-				worldVertices[ii] = u + uvs[i] * w;
-				worldVertices[ii + 1] = v + uvs[i + 1] * h;
-			}
-		}
-	}
 }
 }

+ 38 - 38
spine-libgdx/src/com/esotericsoftware/spine/attachments/SkinnedMeshAttachment.java

@@ -69,6 +69,44 @@ public class SkinnedMeshAttachment extends Attachment {
 		return region;
 		return region;
 	}
 	}
 
 
+	/** @param bones For each vertex, the number of bones affecting the vertex followed by that many bone indices. Ie: count,
+	 *           boneIndex, ...
+	 * @param weights For each bone affecting the vertex, the vertex position in the bone's coordinate system and the weight for
+	 *           the bone's influence. Ie: x, y, weight, ...
+	 * @param uvs For each vertex, a texure coordinate pair. Ie: u, v, ...
+	 * @param triangles Vertex number triplets which describe the mesh's triangulation. */
+	public void setMesh (int[] bones, float[] weights, short[] triangles, float[] uvs) {
+		this.bones = bones;
+		this.weights = weights;
+		this.triangles = triangles;
+
+		int uvsLength = uvs.length;
+		int worldVerticesLength = uvsLength / 2 * 5;
+		if (worldVertices == null || worldVertices.length != worldVerticesLength) worldVertices = new float[worldVerticesLength];
+
+		float u, v, w, h;
+		if (region == null) {
+			u = v = 0;
+			w = h = 1;
+		} else {
+			u = region.getU();
+			v = region.getV();
+			w = region.getU2() - u;
+			h = region.getV2() - v;
+		}
+		if (region instanceof AtlasRegion && ((AtlasRegion)region).rotate) {
+			for (int i = 0, ii = 3; i < uvsLength; i += 2, ii += 5) {
+				worldVertices[ii] = u + uvs[i + 1] * w;
+				worldVertices[ii + 1] = v + h - uvs[i] * h;
+			}
+		} else {
+			for (int i = 0, ii = 3; i < uvsLength; i += 2, ii += 5) {
+				worldVertices[ii] = u + uvs[i] * w;
+				worldVertices[ii + 1] = v + uvs[i + 1] * h;
+			}
+		}
+	}
+
 	public void updateWorldVertices (Slot slot, boolean premultipliedAlpha) {
 	public void updateWorldVertices (Slot slot, boolean premultipliedAlpha) {
 		Skeleton skeleton = slot.getSkeleton();
 		Skeleton skeleton = slot.getSkeleton();
 		Color skeletonColor = skeleton.getColor();
 		Color skeletonColor = skeleton.getColor();
@@ -180,42 +218,4 @@ public class SkinnedMeshAttachment extends Attachment {
 	public void setHeight (float height) {
 	public void setHeight (float height) {
 		this.height = height;
 		this.height = height;
 	}
 	}
-
-	/** @param bones For each vertex, the number of bones affecting the vertex followed by that many bone indices. Ie: count,
-	 *           boneIndex, ...
-	 * @param weights For each bone affecting the vertex, the vertex position in the bone's coordinate system and the weight for
-	 *           the bone's influence. Ie: x, y, weight, ...
-	 * @param uvs For each vertex, a texure coordinate pair. Ie: u, v, ...
-	 * @param triangles Vertex number triplets which describe the mesh's triangulation. */
-	public void setMesh (int[] bones, float[] weights, float[] uvs, short[] triangles) {
-		this.bones = bones;
-		this.weights = weights;
-		this.triangles = triangles;
-
-		int uvsLength = uvs.length;
-		int worldVerticesLength = uvsLength / 2 * 5;
-		if (worldVertices == null || worldVertices.length != worldVerticesLength) worldVertices = new float[worldVerticesLength];
-
-		float u, v, w, h;
-		if (region == null) {
-			u = v = 0;
-			w = h = 1;
-		} else {
-			u = region.getU();
-			v = region.getV();
-			w = region.getU2() - u;
-			h = region.getV2() - v;
-		}
-		if (region instanceof AtlasRegion && ((AtlasRegion)region).rotate) {
-			for (int i = 0, ii = 3; i < uvsLength; i += 2, ii += 5) {
-				worldVertices[ii] = u + uvs[i + 1] * w;
-				worldVertices[ii + 1] = v + h - uvs[i] * h;
-			}
-		} else {
-			for (int i = 0, ii = 3; i < uvsLength; i += 2, ii += 5) {
-				worldVertices[ii] = u + uvs[i] * w;
-				worldVertices[ii + 1] = v + uvs[i + 1] * h;
-			}
-		}
-	}
 }
 }