mirror of
https://github.com/jhasse/poly2tri.git
synced 2024-11-19 12:06:09 +01:00
updated earClip init
This commit is contained in:
parent
e6d11f8c81
commit
bd128eb4e3
@ -396,11 +396,6 @@ class Poly2TriDemo extends BasicGame("Poly2Tri") {
|
|||||||
var xVerts = polyX.toArray
|
var xVerts = polyX.toArray
|
||||||
var yVerts = polyY.toArray
|
var yVerts = polyY.toArray
|
||||||
|
|
||||||
if(currentModel != strange) {
|
|
||||||
xVerts = xVerts.reverse
|
|
||||||
yVerts = yVerts.reverse
|
|
||||||
}
|
|
||||||
|
|
||||||
val t1 = System.nanoTime
|
val t1 = System.nanoTime
|
||||||
earClip.triangulatePolygon(xVerts, yVerts, xVerts.size, earClipResults)
|
earClip.triangulatePolygon(xVerts, yVerts, xVerts.size, earClipResults)
|
||||||
val runTime = System.nanoTime - t1
|
val runTime = System.nanoTime - t1
|
||||||
|
@ -117,9 +117,6 @@ class AFront(iTriangle: Triangle) {
|
|||||||
|
|
||||||
node = node.next
|
node = node.next
|
||||||
}
|
}
|
||||||
|
|
||||||
T1.last.markNeighbor(T2.last)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def -=(tuple: Tuple3[Node, Node, Triangle]) {
|
def -=(tuple: Tuple3[Node, Node, Triangle]) {
|
||||||
|
@ -229,6 +229,7 @@ class CDT(val points: List[Point], val segments: List[Segment], iTriangle: Trian
|
|||||||
// Update neighbors
|
// Update neighbors
|
||||||
edgeNeighbors(nTriangles, T1)
|
edgeNeighbors(nTriangles, T1)
|
||||||
edgeNeighbors(nTriangles, T2)
|
edgeNeighbors(nTriangles, T2)
|
||||||
|
T1.last.markNeighbor(T2.last)
|
||||||
|
|
||||||
// Update advancing front
|
// Update advancing front
|
||||||
|
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
package org.poly2tri.earClip
|
package org.poly2tri.earClip
|
||||||
|
|
||||||
import shapes.Point
|
import shapes.Point
|
||||||
|
import utils.Util
|
||||||
|
|
||||||
class EarClip {
|
class EarClip {
|
||||||
|
|
||||||
@ -37,10 +38,20 @@ class EarClip {
|
|||||||
|
|
||||||
var numTriangles = 0
|
var numTriangles = 0
|
||||||
|
|
||||||
def triangulatePolygon(xv: Array[Float], yv: Array[Float], vn: Int, results: Array[Triangle]): Int = {
|
def triangulatePolygon(x: Array[Float], y: Array[Float], vn: Int, results: Array[Triangle]): Int = {
|
||||||
|
|
||||||
|
val p1 = Point(x(0), y(0))
|
||||||
|
val p2 = Point(x(1), y(1))
|
||||||
|
val p3 = Point(x(2), y(2))
|
||||||
|
|
||||||
|
val ccw = Util.orient2d(p1, p2, p3) > 0
|
||||||
|
|
||||||
|
val xv = if(ccw) x else x.reverse.toArray
|
||||||
|
val yv = if(ccw) y else y.reverse.toArray
|
||||||
|
|
||||||
if (vn < 3) return 0
|
if (vn < 3) return 0
|
||||||
var vNum = vn
|
var vNum = vn
|
||||||
|
|
||||||
//Recurse and split on pinch points
|
//Recurse and split on pinch points
|
||||||
val pA = new Poly
|
val pA = new Poly
|
||||||
val pB = new Poly
|
val pB = new Poly
|
||||||
|
Loading…
Reference in New Issue
Block a user