Эх сурвалжийг харах

[libgdx] Minor clipping improvements.

* Don't return clipping polygon count (editor no longer needs it).
* Avoid returning to the pool, then immediately getting it out again.
Nathan Sweet 4 жил өмнө
parent
commit
9795ef1a1d

+ 3 - 4
spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/utils/SkeletonClipping.java

@@ -47,10 +47,10 @@ public class SkeletonClipping {
 	private ClippingAttachment clipAttachment;
 	private Array<FloatArray> clippingPolygons;
 
-	public int clipStart (Slot slot, ClippingAttachment clip) {
-		if (clipAttachment != null) return 0;
+	public void clipStart (Slot slot, ClippingAttachment clip) {
+		if (clipAttachment != null) return;
 		int n = clip.getWorldVerticesLength();
-		if (n < 6) return 0;
+		if (n < 6) return;
 		clipAttachment = clip;
 
 		float[] vertices = clippingPolygon.setSize(n);
@@ -63,7 +63,6 @@ public class SkeletonClipping {
 			polygon.add(polygon.items[0]);
 			polygon.add(polygon.items[1]);
 		}
-		return clippingPolygons.size;
 	}
 
 	public void clipEnd (Slot slot) {

+ 2 - 5
spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/utils/Triangulator.java

@@ -179,11 +179,9 @@ class Triangulator {
 				if (polygon.size > 0) {
 					convexPolygons.add(polygon);
 					convexPolygonsIndices.add(polygonIndices);
-				} else {
-					polygonPool.free(polygon);
-					polygonIndicesPool.free(polygonIndices);
+					polygon = polygonPool.obtain();
+					polygonIndices = polygonIndicesPool.obtain();
 				}
-				polygon = polygonPool.obtain();
 				polygon.clear();
 				polygon.add(x1);
 				polygon.add(y1);
@@ -191,7 +189,6 @@ class Triangulator {
 				polygon.add(y2);
 				polygon.add(x3);
 				polygon.add(y3);
-				polygonIndices = polygonIndicesPool.obtain();
 				polygonIndices.clear();
 				polygonIndices.add(t1);
 				polygonIndices.add(t2);