diff --git a/src/org/poly2tri/Poly2Tri.scala b/src/org/poly2tri/Poly2Tri.scala index 5ccdc54..c4179d0 100644 --- a/src/org/poly2tri/Poly2Tri.scala +++ b/src/org/poly2tri/Poly2Tri.scala @@ -84,7 +84,7 @@ class Poly2TriDemo extends BasicGame("Poly2Tri") { val strange = "data/strange.dat" val i18 = "data/i.18" - var currentModel = nazcaMonkey + var currentModel = star var mouseButton = 0 var mousePressed = false diff --git a/src/org/poly2tri/cdt/CDT.scala b/src/org/poly2tri/cdt/CDT.scala index a673ac7..080e819 100644 --- a/src/org/poly2tri/cdt/CDT.scala +++ b/src/org/poly2tri/cdt/CDT.scala @@ -108,6 +108,7 @@ class CDT(val points: List[Point], val segments: List[Segment], iTriangle: Trian // Triangle list def triangles = mesh.map + def triangleMesh = mesh.map def debugTriangles = mesh.debug // The triangle mesh @@ -139,7 +140,7 @@ class CDT(val points: List[Point], val segments: List[Segment], iTriangle: Trian } // Process edge events point.edges.foreach(e => edgeEvent(e, triangle)) - //if(i == 10) {cTri = triangle; mesh.debug += cTri} + //if(i == 5) {cTri = triangle; mesh.debug += cTri} } //mesh clean cTri } @@ -424,7 +425,7 @@ class CDT(val points: List[Point], val segments: List[Segment], iTriangle: Trian val c2 = Util.collinear(t2.points(0), t2.points(1), oPoint) val c3 = Util.collinear(t2.points(1), t2.points(2), oPoint) val c4 = Util.collinear(t2.points(0), t2.points(2), oPoint) - val collinear = !(c1 && c2 && c3 && c4) + val collinear = (c1 || c2 || c3 || c4) if(illegal(t1.points(1), oPoint, t1.points(2), t1.points(0)) && !collinear) { @@ -433,8 +434,8 @@ class CDT(val points: List[Point], val segments: List[Segment], iTriangle: Trian val ccwNeighbor = t2.neighborCCW(oPoint) if(ccwNeighbor != null) { - //val point = if(t1.points(0).x > oPoint.x) t1.points(1) else t1.points(2) - ccwNeighbor.updateNeighbors(oPoint, t1.points(2), t1, mesh.debug) + val point = if(t1.points(0).x > oPoint.x) t1.points(1) else t1.points(2) + ccwNeighbor.updateNeighbors(oPoint, point, t1, mesh.debug) t1.neighbors(1) = ccwNeighbor } diff --git a/src/org/poly2tri/cdt/Mesh.scala b/src/org/poly2tri/cdt/Mesh.scala index b6333cc..25d52c0 100644 --- a/src/org/poly2tri/cdt/Mesh.scala +++ b/src/org/poly2tri/cdt/Mesh.scala @@ -46,13 +46,13 @@ class Mesh(initialTriangle: Triangle) { def clean(triangle: Triangle) { if(triangle != null && triangle.clean == false) { triangle.clean = true + triangles += triangle if(triangle.edges(0) == false) clean(triangle.neighbors(0)) if(triangle.edges(1) == false) clean(triangle.neighbors(1)) if(triangle.edges(2) == false) clean(triangle.neighbors(2)) - triangles += triangle } } diff --git a/src/org/poly2tri/shapes/Triangle.scala b/src/org/poly2tri/shapes/Triangle.scala index 88c09fb..d0b405f 100644 --- a/src/org/poly2tri/shapes/Triangle.scala +++ b/src/org/poly2tri/shapes/Triangle.scala @@ -54,6 +54,7 @@ class Triangle(val points: Array[Point], val neighbors: Array[Triangle]) { neighbors(2) = triangle else { debug += triangle + debug += this throw new Exception("Neighbor pointer error, please report!") } } diff --git a/src/org/poly2tri/utils/Util.scala b/src/org/poly2tri/utils/Util.scala index d9bc795..2565730 100644 --- a/src/org/poly2tri/utils/Util.scala +++ b/src/org/poly2tri/utils/Util.scala @@ -51,11 +51,10 @@ object Util { // Determinant val d = a11*(a22-a32) - a12*(a21-a31) + (a21*a32-a31*a22) - if(Math.abs(d) <= COLLINEAR_SLOP) { + if(Math.abs(d) <= COLLINEAR_SLOP) true - } else { + else false - } }