aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2014-03-05 03:23:44 +0100
committerSven Gothel <[email protected]>2014-03-05 03:23:44 +0100
commit79156e080ef919857f1624543e37b62794fb5a64 (patch)
tree8c7b3eeea7bb85b5af05356c7adce1f69606be3a /src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java
parentfe3daea00da48c90a4e0c90cf37514a3ab7093d6 (diff)
Bug 801: VectorUtil: Pass result vector, allowing caller to manage memory (performance, reduce temp objects)
Diffstat (limited to 'src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java')
-rw-r--r--src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java27
1 files changed, 13 insertions, 14 deletions
diff --git a/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java b/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java
index 44a8e7384..cb99fbfa4 100644
--- a/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java
+++ b/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java
@@ -135,6 +135,10 @@ public class OutlineShape implements Comparable<OutlineShape> {
private float sharpness;
+ private final float[] tmpV1 = new float[3];
+ private final float[] tmpV2 = new float[3];
+ private final float[] tmpV3 = new float[3];
+
/** Create a new Outline based Shape
*/
public OutlineShape(Vertex.Factory<? extends Vertex> factory) {
@@ -428,16 +432,16 @@ public class OutlineShape implements Comparable<OutlineShape> {
}
private void subdivideTriangle(final Outline outline, Vertex a, Vertex b, Vertex c, int index){
- float[] v1 = VectorUtil.mid(a.getCoord(), b.getCoord());
- float[] v3 = VectorUtil.mid(b.getCoord(), c.getCoord());
- float[] v2 = VectorUtil.mid(v1, v3);
+ VectorUtil.mid(tmpV1, a.getCoord(), b.getCoord());
+ VectorUtil.mid(tmpV3, b.getCoord(), c.getCoord());
+ VectorUtil.mid(tmpV2, tmpV1, tmpV3);
//drop off-curve vertex to image on the curve
- b.setCoord(v2, 0, 3);
+ b.setCoord(tmpV2, 0, 3);
b.setOnCurve(true);
- outline.addVertex(index, vertexFactory.create(v1, 0, 3, false));
- outline.addVertex(index+2, vertexFactory.create(v3, 0, 3, false));
+ outline.addVertex(index, vertexFactory.create(tmpV1, 0, 3, false));
+ outline.addVertex(index+2, vertexFactory.create(tmpV3, 0, 3, false));
}
/**
@@ -491,10 +495,6 @@ 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++) {
@@ -515,7 +515,7 @@ public class OutlineShape implements Comparable<OutlineShape> {
if( VectorUtil.vertexInTriangle3(a.getCoord(), b.getCoord(), c.getCoord(),
current.getCoord(), nextV.getCoord(), prevV.getCoord(),
- tempVecAC, tempVecAB, tempVecAP) ) {
+ tmpV1, tmpV2, tmpV3) ) {
return current;
}
if(VectorUtil.testTri2SegIntersection(a, b, c, prevV, current) ||
@@ -538,9 +538,8 @@ public class OutlineShape implements Comparable<OutlineShape> {
final Vertex currentVertex = outline.getVertex(i);
final Vertex nextVertex = outline.getVertex((i+1)%vertexCount);
if ( !currentVertex.isOnCurve() && !nextVertex.isOnCurve() ) {
- final float[] newCoords = VectorUtil.mid(currentVertex.getCoord(),
- nextVertex.getCoord());
- final Vertex v = vertexFactory.create(newCoords, 0, 3, true);
+ VectorUtil.mid(tmpV1, currentVertex.getCoord(), nextVertex.getCoord());
+ final Vertex v = vertexFactory.create(tmpV1, 0, 3, true);
i++;
vertexCount++;
outline.addVertex(i, v);