X-Git-Url: http://git.megacz.com/?p=org.ibex.core.git;a=blobdiff_plain;f=src%2Forg%2Fibex%2Fgraphics%2FMesh.java;fp=src%2Forg%2Fibex%2Fgraphics%2FMesh.java;h=f9bd44a1d568aed8c0dde9f61bce8ac51240423e;hp=6fc234999fcdb7b23f085cbd602d4489df46b5c1;hb=c350e11257bfcf51b330d4d438ddd206ea75e593;hpb=a523360b6bafb7ce98d0913259a46441ad8cd129 diff --git a/src/org/ibex/graphics/Mesh.java b/src/org/ibex/graphics/Mesh.java index 6fc2349..f9bd44a 100644 --- a/src/org/ibex/graphics/Mesh.java +++ b/src/org/ibex/graphics/Mesh.java @@ -229,6 +229,7 @@ public final class Mesh { } private Point point(float x, float y) { return new Point(x,y); } + private Point point(Point a, Point b) { return new Point((a.x+b.x)/2,(a.y+b.y)/2); } private Point point(Point p, Affine a) { return point(p.x(a), p.y(a)); } private class Point { public float x; @@ -271,11 +272,24 @@ public final class Mesh { //if (ret != null) throw new Error("tried to get an edge that already exists!"); if (ret == null) ret = new Edge(v1,v2); return ret; + */ } public Edge getEdge(Vertex v1, Vertex v2) { if (v1==v2) throw new Error(); - Edge ret = (Edge)edges.get(v1,v2); + //Edge ret = (Edge)edges.get(v1,v2); + Edge ret = null; + Triangle t = null; + if (triangle0 != null) { + t = triangle0.seek(point(v1,v2)); + if (t != null) + for(int i=1; i<=3; i++) + if (t.e(i).hasVertex(v1) && t.e(i).hasVertex(v2)) ret = t.e(i); + } + if (ret == null) { + ret = (Edge)edges.get(v1,v2); + if (ret != null && (ret.t1 != null || ret.t2 != null)) throw new Error("bah! " + ret); + } if (ret == null) ret = new Edge(v1,v2); return ret; }