mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-06 07:14:55 +08:00
[libgdx] Early out if all edges of a triangle are outside the clip region
This commit is contained in:
parent
242eaf2bcc
commit
7245115a63
@ -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]);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user