mirror of
https://github.com/jhasse/poly2tri.git
synced 2024-12-27 21:23:30 +01:00
fixed advancing front bug
This commit is contained in:
parent
8f8e8144bf
commit
8e788b2e15
@ -439,7 +439,7 @@ class Poly2TriDemo extends BasicGame("Poly2Tri") {
|
||||
if(slCDT.cList.size > 1) {
|
||||
//slCDT.addPoint(slCDT.cList(0))
|
||||
//slCDT.addPoint(slCDT.cList(1))
|
||||
for(i <- 0 until 9 /*slCDT.cList.size*/)
|
||||
for(i <- 0 until slCDT.cList.size)
|
||||
slCDT.addPoint(slCDT.cList(i))
|
||||
slCDT.triangulate
|
||||
}
|
||||
|
@ -155,7 +155,7 @@ class CDT(polyLine: Array[Point], clearPoint: Point) {
|
||||
// 49 69
|
||||
val size = if(refine) 50 else points.size
|
||||
|
||||
for(i <- 1 until size) {
|
||||
for(i <- 1 until points.size) {
|
||||
|
||||
val point = points(i)
|
||||
// Process Point event
|
||||
@ -331,7 +331,7 @@ class CDT(polyLine: Array[Point], clearPoint: Point) {
|
||||
}
|
||||
nTriangles += pNode.triangle
|
||||
}
|
||||
|
||||
|
||||
val point2 = if(aboveEdge) {
|
||||
val p1 = pNode.point
|
||||
val p2 = if(ahead) pNode.prev.point else pNode.next.point
|
||||
@ -364,15 +364,13 @@ class CDT(polyLine: Array[Point], clearPoint: Point) {
|
||||
pNode.prev = n
|
||||
n
|
||||
} else {
|
||||
val n = new Node(point2, pNode.next.triangle)
|
||||
val n = new Node(point2, T.last)
|
||||
aFront link (n, first, T.last)
|
||||
pNode.next = n
|
||||
n.prev = pNode
|
||||
n
|
||||
}
|
||||
val above = point2.y > edge.p.y
|
||||
val e = if(above) new Segment(edge.p, point2) else { println("wtf"); new Segment(point2, edge.p)}
|
||||
edgeEvent(e, iNode)
|
||||
pNode
|
||||
}
|
||||
edgeEvent(new Segment(edge.p, point2), iNode)
|
||||
}
|
||||
|
||||
} else if(firstTriangle.contains(edge.q, edge.p)) {
|
||||
|
@ -157,15 +157,15 @@ class Triangle(val points: Array[Point]) {
|
||||
}
|
||||
|
||||
// Locate next triangle crossed by edge
|
||||
def findNeighbor(e: Point): Triangle = {
|
||||
def findNeighbor(p: Point): Triangle = {
|
||||
|
||||
if(contains(e)) return this
|
||||
if(contains(p)) return this
|
||||
|
||||
if(Util.orient2d(points(1), points(0), e) > 0)
|
||||
if(Util.orient2d(points(1), points(0), p) > 0)
|
||||
return neighbors(2)
|
||||
else if(Util.orient2d(points(2), points(1), e) > 0)
|
||||
else if(Util.orient2d(points(2), points(1), p) > 0)
|
||||
return neighbors(0)
|
||||
else if(Util.orient2d(points(0), points(2), e) > 0)
|
||||
else if(Util.orient2d(points(0), points(2), p) > 0)
|
||||
return neighbors(1)
|
||||
else
|
||||
throw new Exception("Point not found")
|
||||
|
Loading…
Reference in New Issue
Block a user