From 7245115a631887aa8ff9c579e0ff5da19c2ed2d6 Mon Sep 17 00:00:00 2001 From: badlogic Date: Tue, 28 Mar 2017 18:16:45 +0200 Subject: [PATCH] [libgdx] Early out if all edges of a triangle are outside the clip region --- .../spine/utils/SutherlandHodgmanClipper.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/utils/SutherlandHodgmanClipper.java b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/utils/SutherlandHodgmanClipper.java index 4c2177ef4..a4192aa98 100644 --- a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/utils/SutherlandHodgmanClipper.java +++ b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/utils/SutherlandHodgmanClipper.java @@ -45,6 +45,8 @@ public class SutherlandHodgmanClipper { final float[] inputVertices = input.items; final int inputVerticesLength = input.size - 2; + + int numOutside = 0; for (int j = 0; j < inputVerticesLength; j += 2) { final float inputX = inputVertices[j]; @@ -71,6 +73,7 @@ public class SutherlandHodgmanClipper { if (side2 < 0) { // no output clipped = true; + numOutside += 2; } // v1 outside, v2 inside else { @@ -81,6 +84,12 @@ public class SutherlandHodgmanClipper { } } } + + // early out if all edges were outside + if (numOutside == inputVerticesLength) { + originalOutput.clear(); + return true; + } output.add(output.items[0]); output.add(output.items[1]);