Przeglądaj źródła

poly2tri: more useful handling of CW/CCW error on triangles

bcorbet 5 lat temu
rodzic
commit
bf21f6af55
1 zmienionych plików z 11 dodań i 1 usunięć
  1. 11 1
      hxd/poly2tri/Sweep.hx

+ 11 - 1
hxd/poly2tri/Sweep.hx

@@ -52,7 +52,17 @@ class Sweep
 	{
 		// trace(point);
 		var node = this.context.locateNode(point);
-		var new_node = newFrontTriangle(point, node);
+		var new_node = null;
+		try	new_node = newFrontTriangle(point, node)
+		catch(e: Dynamic) { }
+		
+		if(new_node == null) {
+			#if release
+			new_node = node;
+			#else
+			throw 'Failed to add point (${point.x}, ${point.y})';
+			#end
+		}
 
 		// Only need to check +epsilon since point never have smaller
 		// x value than node due to how we fetch nodes from the front