aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes
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
parent4ccf5ed0cc14743a3a97d7b0dcc61e839d263a1a (diff)
Loop: Fix invert; GlyphString/createRegion: Remove unnecessary on-the-fly object creation
Diffstat (limited to 'src/jogl/classes')
-rw-r--r--src/jogl/classes/com/jogamp/graph/curve/Region.java25
-rw-r--r--src/jogl/classes/jogamp/graph/curve/tess/Loop.java40
-rw-r--r--src/jogl/classes/jogamp/graph/curve/text/GlyphString.java11
3 files changed, 50 insertions, 26 deletions
diff --git a/src/jogl/classes/com/jogamp/graph/curve/Region.java b/src/jogl/classes/com/jogamp/graph/curve/Region.java
index 320483d8d..46bdedee4 100644
--- a/src/jogl/classes/com/jogamp/graph/curve/Region.java
+++ b/src/jogl/classes/com/jogamp/graph/curve/Region.java
@@ -83,6 +83,18 @@ public abstract class Region {
return numVertices;
}
+ /** Adds a {@link Triangle} object to the Region
+ * This triangle will be bound to OGL objects
+ * on the next call to {@code update}
+ * @param tri a triangle object
+ *
+ * @see update(GL2ES2)
+ */
+ public void addTriangle(Triangle tri) {
+ triangles.add(tri);
+ setDirty(true);
+ }
+
/** Adds a list of {@link Triangle} objects to the Region
* These triangles are to be binded to OGL objects
* on the next call to {@code update}
@@ -95,6 +107,19 @@ public abstract class Region {
setDirty(true);
}
+ /** Adds a {@link Vertex} object to the Region
+ * This vertex will be bound to OGL objects
+ * on the next call to {@code update}
+ * @param vert a vertex objects
+ *
+ * @see update(GL2ES2)
+ */
+ public void addVertex(Vertex vert) {
+ vertices.add(vert);
+ numVertices++;
+ setDirty(true);
+ }
+
/** Adds a list of {@link Vertex} objects to the Region
* These vertices are to be binded to OGL objects
* on the next call to {@code update}
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;
}