mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-10 04:36:57 +08:00
Don't need local to track if all edges were outside.
This commit is contained in:
parent
3adaf1b9ac
commit
e334d7a27a
@ -69,8 +69,7 @@ public class Clipper {
|
|||||||
float deltaX = edgeX - edgeX2, deltaY = edgeY - edgeY2;
|
float deltaX = edgeX - edgeX2, deltaY = edgeY - edgeY2;
|
||||||
|
|
||||||
float[] inputVertices = input.items;
|
float[] inputVertices = input.items;
|
||||||
int inputVerticesLength = input.size - 2;
|
int inputVerticesLength = input.size - 2, outputStart = output.size;
|
||||||
int numOutside = 0;
|
|
||||||
for (int ii = 0; ii < inputVerticesLength; ii += 2) {
|
for (int ii = 0; ii < inputVerticesLength; ii += 2) {
|
||||||
float inputX = inputVertices[ii], inputY = inputVertices[ii + 1];
|
float inputX = inputVertices[ii], inputY = inputVertices[ii + 1];
|
||||||
float inputX2 = inputVertices[ii + 2], inputY2 = inputVertices[ii + 3];
|
float inputX2 = inputVertices[ii + 2], inputY2 = inputVertices[ii + 3];
|
||||||
@ -90,9 +89,7 @@ public class Clipper {
|
|||||||
clipped = true;
|
clipped = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (side2 < 0) // v1 outside, v2 outside: no output
|
if (side2 >= 0) { // v1 outside, v2 inside
|
||||||
numOutside += 2;
|
|
||||||
else { // v1 outside, v2 inside
|
|
||||||
float c0 = inputY2 - inputY, c2 = inputX2 - inputX;
|
float c0 = inputY2 - inputY, c2 = inputX2 - inputX;
|
||||||
float d = c0 * (edgeX2 - edgeX) - c2 * (edgeY2 - edgeY);
|
float d = c0 * (edgeX2 - edgeX) - c2 * (edgeY2 - edgeY);
|
||||||
float ua = (c2 * (edgeY - inputY) - c0 * (edgeX - inputX)) / d;
|
float ua = (c2 * (edgeY - inputY) - c0 * (edgeX - inputX)) / d;
|
||||||
@ -105,8 +102,7 @@ public class Clipper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Early out if all edges were outside.
|
if (outputStart == output.size) { // All edges were outside.
|
||||||
if (numOutside == inputVerticesLength) {
|
|
||||||
originalOutput.clear();
|
originalOutput.clear();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user