aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp/graph
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-05-09 14:25:59 +0200
committerSven Gothel <[email protected]>2011-05-09 14:25:59 +0200
commit1303328b476570d94e56c9d2fc061e3b09cf538a (patch)
tree4781aab739a4c321fefc92e872d3817b44b787b9 /src/jogl/classes/jogamp/graph
parent4ccf5ed0cc14743a3a97d7b0dcc61e839d263a1a (diff)
Loop: Fix invert; GlyphString/createRegion: Remove unnecessary on-the-fly object creation
Diffstat (limited to 'src/jogl/classes/jogamp/graph')
-rw-r--r--src/jogl/classes/jogamp/graph/curve/tess/Loop.java40
-rw-r--r--src/jogl/classes/jogamp/graph/curve/text/GlyphString.java11
2 files changed, 25 insertions, 26 deletions
diff --git a/src/jogl/classes/jogamp/graph/curve/tess/Loop.java b/src/jogl/classes/jogamp/graph/curve/tess/Loop.java
index 9e29d3973..038d41b84 100644
--- a/src/jogl/classes/jogamp/graph/curve/tess/Loop.java
+++ b/src/jogl/classes/jogamp/graph/curve/tess/Loop.java
@@ -104,18 +104,25 @@ public class Loop {
}
boolean isCCW = VectorUtil.ccw(vertices.get(0).getPoint(), vertices.get(1).getPoint(),
vertices.get(2).getPoint());
- boolean invert = isCCW && (direction == VectorUtil.CW);
+ boolean invert = isCCW != (direction == VectorUtil.CCW);
+ final int dir;
+ final int max;
+ final int edgeType;
+ int index;
HEdge firstEdge = null;
HEdge lastEdge = null;
- int index =0;
- int max = vertices.size();
-
- int edgeType = HEdge.BOUNDARY;
- if(invert){
- index = vertices.size() -1;
+
+ if(!invert) {
+ dir = 1;
+ max = vertices.size();
+ edgeType = HEdge.BOUNDARY;
+ index = 0;
+ } else {
+ dir = -1;
max = -1;
edgeType = HEdge.HOLE;
+ index = vertices.size() -1;
}
while(index != max){
@@ -125,33 +132,26 @@ public class Loop {
HEdge edge = new HEdge(v1, edgeType);
v1.addEdge(edge);
- if(lastEdge != null){
+ if(lastEdge != null) {
lastEdge.setNext(edge);
edge.setPrev(lastEdge);
- }
- else{
+ } else {
firstEdge = edge;
}
- if(!invert){
- if(index == vertices.size()-1){
+ if(!invert) {
+ if(index == vertices.size()-1) {
edge.setNext(firstEdge);
firstEdge.setPrev(edge);
}
- }
- else if (index == 0){
+ } else if (index == 0) {
edge.setNext(firstEdge);
firstEdge.setPrev(edge);
}
lastEdge = edge;
- if(!invert){
- index++;
- }
- else{
- index--;
- }
+ index += dir;
}
return firstEdge;
}
diff --git a/src/jogl/classes/jogamp/graph/curve/text/GlyphString.java b/src/jogl/classes/jogamp/graph/curve/text/GlyphString.java
index 53a3ec5e0..cd6cd56aa 100644
--- a/src/jogl/classes/jogamp/graph/curve/text/GlyphString.java
+++ b/src/jogl/classes/jogamp/graph/curve/text/GlyphString.java
@@ -152,20 +152,19 @@ public class GlyphString {
// region.setFlipped(true);
int numVertices = region.getNumVertices();
- ArrayList<Triangle> tris = new ArrayList<Triangle>();
for(int i=0; i< glyphs.size(); i++) {
final GlyphShape glyph = glyphs.get(i);
ArrayList<Triangle> gtris = glyph.triangulate();
- tris.addAll(gtris);
+ region.addTriangles(gtris);
- ArrayList<Vertex> gVertices = glyph.getVertices();
+ final ArrayList<Vertex> gVertices = glyph.getVertices();
for(int j=0; j<gVertices.size(); j++) {
- gVertices.get(j).setId(numVertices++);
+ final Vertex gVert = gVertices.get(j);
+ gVert.setId(numVertices++);
+ region.addVertex(gVert);
}
- region.addVertices(gVertices);
}
- region.addTriangles(tris);
return region;
}