[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.
This commit is contained in:
Nathan Sweet 2021-04-08 15:40:28 +02:00
parent 02f87a0f9f
commit 9795ef1a1d
2 changed files with 5 additions and 9 deletions

View File

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

View File

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