summaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/com/jogamp/graph/curve
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2012-05-16 15:30:27 +0200
committerSven Gothel <[email protected]>2012-05-16 15:30:27 +0200
commite1d954439572d7e6776c0d928d1882e1cf200675 (patch)
tree01f8d2edf7a1b23da3014bd7b348cd61144e0790 /src/jogl/classes/com/jogamp/graph/curve
parentcf51a97f04011ce643c42d6872f37cc69f4342aa (diff)
Graph minor linear optimization: Passing array storage (reduce temp array) and use array ref access.
Diffstat (limited to 'src/jogl/classes/com/jogamp/graph/curve')
-rwxr-xr-xsrc/jogl/classes/com/jogamp/graph/curve/OutlineShape.java24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java b/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java
index e60fba02b..f79dd6644 100755
--- a/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java
+++ b/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java
@@ -427,6 +427,10 @@ public class OutlineShape implements Comparable<OutlineShape> {
}while(!overlaps.isEmpty());
}
+ private final float[] tempVecAC = new float[3];
+ private final float[] tempVecAB = new float[3];
+ private final float[] tempVecAP = new float[3];
+
private Vertex checkTriOverlaps(Vertex a, Vertex b, Vertex c) {
int count = getOutlineNumber();
for (int cc = 0; cc < count; cc++) {
@@ -445,15 +449,19 @@ public class OutlineShape implements Comparable<OutlineShape> {
continue;
}
- if(VectorUtil.vertexInTriangle(a.getCoord(), b.getCoord(), c.getCoord(), current.getCoord())
- || VectorUtil.vertexInTriangle(a.getCoord(), b.getCoord(), c.getCoord(), nextV.getCoord())
- || VectorUtil.vertexInTriangle(a.getCoord(), b.getCoord(), c.getCoord(), prevV.getCoord())) {
-
- return current;
+ {
+ final float[] coordA = a.getCoord();
+ final float[] coordB = b.getCoord();
+ final float[] coordC = c.getCoord();
+ if(VectorUtil.vertexInTriangle(coordA, coordB, coordC, current.getCoord(), tempVecAC, tempVecAB, tempVecAP) ||
+ VectorUtil.vertexInTriangle(coordA, coordB, coordC, nextV.getCoord(), tempVecAC, tempVecAB, tempVecAP) ||
+ VectorUtil.vertexInTriangle(coordA, coordB, coordC, prevV.getCoord(), tempVecAC, tempVecAB, tempVecAP) ) {
+ return current;
+ }
}
- if(VectorUtil.tri2SegIntersection(a, b, c, prevV, current)
- || VectorUtil.tri2SegIntersection(a, b, c, current, nextV)
- || VectorUtil.tri2SegIntersection(a, b, c, prevV, nextV)) {
+ if(VectorUtil.testTri2SegIntersection(a, b, c, prevV, current) ||
+ VectorUtil.testTri2SegIntersection(a, b, c, current, nextV) ||
+ VectorUtil.testTri2SegIntersection(a, b, c, prevV, nextV)) {
return current;
}
}