aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes
diff options
context:
space:
mode:
Diffstat (limited to 'src/jogl/classes')
-rw-r--r--src/jogl/classes/com/jogamp/graph/curve/tess/CDTriangulator2D.java2
-rwxr-xr-xsrc/jogl/classes/com/jogamp/graph/math/VectorUtil.java22
-rw-r--r--src/jogl/classes/jogamp/graph/curve/tess/Loop.java46
-rw-r--r--src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java5
4 files changed, 49 insertions, 26 deletions
diff --git a/src/jogl/classes/com/jogamp/graph/curve/tess/CDTriangulator2D.java b/src/jogl/classes/com/jogamp/graph/curve/tess/CDTriangulator2D.java
index 6130410d7..55bdbcd33 100644
--- a/src/jogl/classes/com/jogamp/graph/curve/tess/CDTriangulator2D.java
+++ b/src/jogl/classes/com/jogamp/graph/curve/tess/CDTriangulator2D.java
@@ -88,7 +88,7 @@ public class CDTriangulator2D {
GraphOutline outline = new GraphOutline(polyline);
GraphOutline innerPoly = extractBoundaryTriangles(outline, false);
vertices.addAll(polyline.getVertices());
- loop = new Loop(innerPoly, VectorUtil.CCW);
+ loop = new Loop(innerPoly, VectorUtil.Winding.CCW);
loops.add(loop);
}
else {
diff --git a/src/jogl/classes/com/jogamp/graph/math/VectorUtil.java b/src/jogl/classes/com/jogamp/graph/math/VectorUtil.java
index afab69f79..aae7a8c5c 100755
--- a/src/jogl/classes/com/jogamp/graph/math/VectorUtil.java
+++ b/src/jogl/classes/com/jogamp/graph/math/VectorUtil.java
@@ -35,8 +35,16 @@ import com.jogamp.graph.geom.Vertex;
public class VectorUtil {
- public static final int CW = -1;
- public static final int CCW = 1;
+ public enum Winding {
+ CW(-1), CCW(1);
+
+ public final int dir;
+
+ Winding(int dir) {
+ this.dir = dir;
+ }
+ }
+
public static final int COLLINEAR = 0;
/** compute the dot product of two points
@@ -290,6 +298,16 @@ public class VectorUtil {
return triArea(a,b,c) > 0;
}
+ /** Compute the winding of given points
+ * @param a first vertex
+ * @param b second vertex
+ * @param c third vertex
+ * @return Winding
+ */
+ public static Winding getWinding(Vertex a, Vertex b, Vertex c) {
+ return triArea(a,b,c) > 0 ? Winding.CCW : Winding.CW ;
+ }
+
/** Computes the area of a list of vertices to check if ccw
* @param vertices
* @return positve area if ccw else negative area value
diff --git a/src/jogl/classes/jogamp/graph/curve/tess/Loop.java b/src/jogl/classes/jogamp/graph/curve/tess/Loop.java
index 956fd56f2..230bdad0e 100644
--- a/src/jogl/classes/jogamp/graph/curve/tess/Loop.java
+++ b/src/jogl/classes/jogamp/graph/curve/tess/Loop.java
@@ -40,9 +40,9 @@ public class Loop {
private AABBox box = new AABBox();
private GraphOutline initialOutline = null;
- public Loop(GraphOutline polyline, int direction){
+ public Loop(GraphOutline polyline, VectorUtil.Winding winding){
initialOutline = polyline;
- this.root = initFromPolyline(initialOutline, direction);
+ this.root = initFromPolyline(initialOutline, winding);
}
public HEdge getHEdge(){
@@ -94,34 +94,37 @@ public class Loop {
/**Create a connected list of half edges (loop)
* from the boundary profile
- * @param direction requested winding of edges (CCW or CW)
+ * @param reqWinding requested winding of edges (CCW or CW)
*/
- private HEdge initFromPolyline(GraphOutline outline, int direction){
+ private HEdge initFromPolyline(GraphOutline outline, VectorUtil.Winding reqWinding){
ArrayList<GraphVertex> vertices = outline.getGraphPoint();
if(vertices.size()<3) {
throw new IllegalArgumentException("outline's vertices < 3: " + vertices.size());
}
- boolean isCCW = VectorUtil.ccw(vertices.get(0).getPoint(), vertices.get(1).getPoint(),
- vertices.get(2).getPoint());
- boolean invert = isCCW && (direction == VectorUtil.CW);
-
- final int dir;
+ final VectorUtil.Winding hasWinding = VectorUtil.getWinding(
+ vertices.get(0).getPoint(),
+ vertices.get(1).getPoint(),
+ vertices.get(2).getPoint());
+ // isCCW && (reqWinding == VectorUtil.CW);
+ // skips inversion CW -> CCW ?
+ final boolean invert = hasWinding != reqWinding &&
+ reqWinding == VectorUtil.Winding.CW;
+ /*if( hasWinding != reqWinding ) {
+ System.err.println("Winding: i "+invert+" "+hasWinding+" -> "+reqWinding);
+ }*/
+
final int max;
- final int edgeType;
+ final int edgeType = reqWinding == VectorUtil.Winding.CCW ? HEdge.BOUNDARY : HEdge.HOLE ;
int index;
HEdge firstEdge = null;
HEdge lastEdge = null;
if(!invert) {
- dir = 1;
max = vertices.size();
- edgeType = HEdge.BOUNDARY;
index = 0;
} else {
- dir = -1;
max = -1;
- edgeType = HEdge.HOLE;
index = vertices.size() -1;
}
@@ -144,14 +147,15 @@ public class Loop {
edge.setNext(firstEdge);
firstEdge.setPrev(edge);
}
- } else if (index == 0) {
- edge.setNext(firstEdge);
- firstEdge.setPrev(edge);
+ index++;
+ } else {
+ if (index == 0) {
+ edge.setNext(firstEdge);
+ firstEdge.setPrev(edge);
+ }
+ index--;
}
-
lastEdge = edge;
-
- index += dir;
}
return firstEdge;
}
@@ -159,7 +163,7 @@ public class Loop {
public void addConstraintCurve(GraphOutline polyline) {
// GraphOutline outline = new GraphOutline(polyline);
/**needed to generate vertex references.*/
- initFromPolyline(polyline, VectorUtil.CW);
+ initFromPolyline(polyline, VectorUtil.Winding.CW);
GraphVertex v3 = locateClosestVertex(polyline);
HEdge v3Edge = v3.findBoundEdge();
diff --git a/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java b/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java
index b5ec011c9..2e692e5ce 100644
--- a/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java
+++ b/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java
@@ -124,6 +124,7 @@ class TypecastFont implements FontInt {
cmapentries += range.getEndCode() - range.getStartCode() + 1; // end included
}
if(DEBUG) {
+ System.err.println("font direction hint: "+font.getHeadTable().getFontDirectionHint());
System.err.println("num glyphs: "+font.getNumGlyphs());
System.err.println("num cmap entries: "+cmapentries);
System.err.println("num cmap ranges: "+cmapFormat.getRangeCount());
@@ -198,9 +199,9 @@ class TypecastFont implements FontInt {
{
final HdmxTable.DeviceRecord dr = hdmx.getRecord(i);
result.addAdvance(dr.getWidth(code), dr.getPixelSize());
- if(DEBUG) {
+ /* if(DEBUG) {
System.err.println("hdmx advance : pixelsize = "+dr.getWidth(code)+" : "+ dr.getPixelSize());
- }
+ } */
}
}
char2Glyph.put(symbol, result);