Added player character and step in/out of dialogue in scene 101

This commit is contained in:
2026-08-15 15:22:47 +02:00
parent a42f25d5fa
commit 38ba2b0eff
2019 changed files with 181227 additions and 265 deletions
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: d880a3d3b580e384db43a01ff5d06326
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,215 @@
/* Poly2Tri
* Copyright (c) 2009-2010, Poly2Tri Contributors
* http://code.google.com/p/poly2tri/
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* * Neither the name of Poly2Tri nor the names of its contributors may be
* used to endorse or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/// Changes from the Java version
/// attributification
/// Future possibilities
/// Flattening out the number of indirections
/// Replacing arrays of 3 with fixed-length arrays?
/// Replacing bool[3] with a bit array of some sort?
/// Bundling everything into an AoS mess?
/// Hardcode them all as ABC ?
using System;
using System.Diagnostics;
using System.Collections.Generic;
namespace UnityEngine.ProBuilder.Poly2Tri {
class DelaunayTriangle {
public FixedArray3<TriangulationPoint> Points;
public FixedArray3<DelaunayTriangle > Neighbors;
public FixedBitArray3 EdgeIsConstrained, EdgeIsDelaunay;
public bool IsInterior { get; set; }
public DelaunayTriangle(TriangulationPoint p1, TriangulationPoint p2, TriangulationPoint p3) {
Points[0] = p1;
Points[1] = p2;
Points[2] = p3;
}
public int IndexOf(TriangulationPoint p) {
int i = Points.IndexOf(p);
if (i==-1) throw new Exception("Calling index with a point that doesn't exist in triangle");
return i;
}
public int IndexCWFrom (TriangulationPoint p) { return (IndexOf(p)+2)%3; }
public int IndexCCWFrom(TriangulationPoint p) { return (IndexOf(p)+1)%3; }
public bool Contains(TriangulationPoint p) { return Points.Contains(p); }
/// <summary>
/// Update neighbor pointers
/// </summary>
/// <param name="p1">Point 1 of the shared edge</param>
/// <param name="p2">Point 2 of the shared edge</param>
/// <param name="t">This triangle's new neighbor</param>
private void MarkNeighbor( TriangulationPoint p1, TriangulationPoint p2, DelaunayTriangle t ) {
int i = EdgeIndex(p1,p2);
if ( i==-1 ) throw new Exception( "Error marking neighbors -- t doesn't contain edge p1-p2!" );
Neighbors[i] = t;
}
/// <summary>
/// Exhaustive search to update neighbor pointers
/// </summary>
public void MarkNeighbor( DelaunayTriangle t ) {
// Points of this triangle also belonging to t
bool a = t.Contains(Points[0]);
bool b = t.Contains(Points[1]);
bool c = t.Contains(Points[2]);
if (b&&c) { Neighbors[0]=t; t.MarkNeighbor(Points[1],Points[2],this); }
else if (a&&c) { Neighbors[1]=t; t.MarkNeighbor(Points[0],Points[2],this); }
else if (a&&b) { Neighbors[2]=t; t.MarkNeighbor(Points[0],Points[1],this); }
else throw new Exception( "Failed to mark neighbor, doesn't share an edge!");
}
/// <param name="t">Opposite triangle</param>
/// <param name="p">The point in t that isn't shared between the triangles</param>
public TriangulationPoint OppositePoint(DelaunayTriangle t, TriangulationPoint p) {
System.Diagnostics.Debug.Assert(t != this, "self-pointer error");
return PointCWFrom(t.PointCWFrom(p));
}
public DelaunayTriangle NeighborCWFrom (TriangulationPoint point) { return Neighbors[(Points.IndexOf(point)+1)%3]; }
public DelaunayTriangle NeighborCCWFrom (TriangulationPoint point) { return Neighbors[(Points.IndexOf(point)+2)%3]; }
public DelaunayTriangle NeighborAcrossFrom(TriangulationPoint point) { return Neighbors[ Points.IndexOf(point) ]; }
public TriangulationPoint PointCCWFrom(TriangulationPoint point) { return Points[(IndexOf(point)+1)%3]; }
public TriangulationPoint PointCWFrom (TriangulationPoint point) { return Points[(IndexOf(point)+2)%3]; }
private void RotateCW() {
var t = Points[2];
Points[2] = Points[1];
Points[1] = Points[0];
Points[0] = t;
}
/// <summary>
/// Legalize triangle by rotating clockwise around oPoint
/// </summary>
/// <param name="oPoint">The origin point to rotate around</param>
/// <param name="nPoint">???</param>
public void Legalize(TriangulationPoint oPoint, TriangulationPoint nPoint) {
RotateCW();
Points[IndexCCWFrom(oPoint)] = nPoint;
}
public override string ToString() { return Points[0] + "," + Points[1] + "," + Points[2]; }
/// <summary>
/// Finalize edge marking
/// </summary>
public void MarkNeighborEdges() {
for (int i = 0; i < 3; i++) if ( EdgeIsConstrained[i] && Neighbors[i] != null ) {
Neighbors[i].MarkConstrainedEdge(Points[(i+1)%3], Points[(i+2)%3]);
}
}
public void MarkEdge(DelaunayTriangle triangle) {
for (int i = 0; i < 3; i++) if ( EdgeIsConstrained[i] ) {
triangle.MarkConstrainedEdge(Points[(i+1)%3], Points[(i+2)%3]);
}
}
public void MarkEdge(List<DelaunayTriangle> tList) {
foreach ( DelaunayTriangle t in tList )
for ( int i = 0; i < 3; i++ )
if ( t.EdgeIsConstrained[i] )
{
MarkConstrainedEdge( t.Points[(i+1)%3], t.Points[(i+2)%3] );
}
}
public void MarkConstrainedEdge(int index) {
EdgeIsConstrained[index] = true;
}
public void MarkConstrainedEdge(DTSweepConstraint edge) {
MarkConstrainedEdge(edge.P, edge.Q);
}
/// <summary>
/// Mark edge as constrained
/// </summary>
public void MarkConstrainedEdge(TriangulationPoint p, TriangulationPoint q) {
int i = EdgeIndex(p,q);
if ( i != -1 ) EdgeIsConstrained[i] = true;
}
public double Area() {
double b = Points[0].X - Points[1].X;
double h = Points[2].Y - Points[1].Y;
return Math.Abs((b * h * 0.5f));
}
public TriangulationPoint Centroid() {
double cx = (Points[0].X + Points[1].X + Points[2].X) / 3f;
double cy = (Points[0].Y + Points[1].Y + Points[2].Y) / 3f;
return new TriangulationPoint(cx, cy);
}
/// <summary>
/// Get the index of the neighbor that shares this edge (or -1 if it isn't shared)
/// </summary>
/// <returns>index of the shared edge or -1 if edge isn't shared</returns>
public int EdgeIndex(TriangulationPoint p1, TriangulationPoint p2) {
int i1 = Points.IndexOf(p1);
int i2 = Points.IndexOf(p2);
// Points of this triangle in the edge p1-p2
bool a = (i1==0 || i2==0);
bool b = (i1==1 || i2==1);
bool c = (i1==2 || i2==2);
if (b&&c) return 0;
if (a&&c) return 1;
if (a&&b) return 2;
return -1;
}
public bool GetConstrainedEdgeCCW ( TriangulationPoint p ) { return EdgeIsConstrained[(IndexOf(p)+2)%3]; }
public bool GetConstrainedEdgeCW ( TriangulationPoint p ) { return EdgeIsConstrained[(IndexOf(p)+1)%3]; }
public bool GetConstrainedEdgeAcross( TriangulationPoint p ) { return EdgeIsConstrained[ IndexOf(p) ]; }
public void SetConstrainedEdgeCCW ( TriangulationPoint p, bool ce ) { EdgeIsConstrained[(IndexOf(p)+2)%3] = ce; }
public void SetConstrainedEdgeCW ( TriangulationPoint p, bool ce ) { EdgeIsConstrained[(IndexOf(p)+1)%3] = ce; }
public void SetConstrainedEdgeAcross( TriangulationPoint p, bool ce ) { EdgeIsConstrained[ IndexOf(p) ] = ce; }
public bool GetDelaunayEdgeCCW ( TriangulationPoint p ) { return EdgeIsDelaunay[(IndexOf(p)+2)%3]; }
public bool GetDelaunayEdgeCW ( TriangulationPoint p ) { return EdgeIsDelaunay[(IndexOf(p)+1)%3]; }
public bool GetDelaunayEdgeAcross( TriangulationPoint p ) { return EdgeIsDelaunay[ IndexOf(p) ]; }
public void SetDelaunayEdgeCCW ( TriangulationPoint p, bool ce ) { EdgeIsDelaunay[(IndexOf(p)+2)%3] = ce; }
public void SetDelaunayEdgeCW ( TriangulationPoint p, bool ce ) { EdgeIsDelaunay[(IndexOf(p)+1)%3] = ce; }
public void SetDelaunayEdgeAcross( TriangulationPoint p, bool ce ) { EdgeIsDelaunay[ IndexOf(p) ] = ce; }
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ec676d2a8ccecde4f8eb0d32aeaafb98
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 9db8260d0bbb07e4bb0356d0b21fbc20
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,133 @@
/* Poly2Tri
* Copyright (c) 2009-2010, Poly2Tri Contributors
* http://code.google.com/p/poly2tri/
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* * Neither the name of Poly2Tri nor the names of its contributors may be
* used to endorse or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/// Changes from the Java version
/// Removed BST code, but not all artifacts of it
/// Future possibilities
/// Eliminate Add/RemoveNode ?
/// Comments comments and more comments!
using System.Text;
using System;
namespace UnityEngine.ProBuilder.Poly2Tri {
/**
* @author Thomas Åhlen ([email protected])
*/
class AdvancingFront {
public AdvancingFrontNode Head;
public AdvancingFrontNode Tail;
protected AdvancingFrontNode Search;
public AdvancingFront( AdvancingFrontNode head, AdvancingFrontNode tail ) {
this.Head = head;
this.Tail = tail;
this.Search = head;
AddNode(head);
AddNode(tail);
}
public void AddNode( AdvancingFrontNode node ) { }
public void RemoveNode( AdvancingFrontNode node ) { }
public override string ToString() {
StringBuilder sb = new StringBuilder();
AdvancingFrontNode node = Head;
while (node != Tail) {
sb.Append(node.Point.X).Append("->");
node = node.Next;
}
sb.Append(Tail.Point.X);
return sb.ToString();
}
/// <summary>
/// MM: This seems to be used by LocateNode to guess a position in the implicit linked list of AdvancingFrontNodes near x
/// Removed an overload that depended on this being exact
/// </summary>
private AdvancingFrontNode FindSearchNode( double x ) {
return Search;
}
/// <summary>
/// We use a balancing tree to locate a node smaller or equal to given key value (in theory)
/// </summary>
public AdvancingFrontNode LocateNode( TriangulationPoint point ) {
return LocateNode(point.X);
}
private AdvancingFrontNode LocateNode( double x ) {
AdvancingFrontNode node = FindSearchNode(x);
if (x < node.Value) {
while ((node = node.Prev) != null)
if (x >= node.Value) {
Search = node;
return node;
}
} else {
while ((node = node.Next) != null)
if (x < node.Value) {
Search = node.Prev;
return node.Prev;
}
}
return null;
}
/// <summary>
/// This implementation will use simple node traversal algorithm to find a point on the front
/// </summary>
public AdvancingFrontNode LocatePoint( TriangulationPoint point ) {
double px = point.X;
AdvancingFrontNode node = FindSearchNode(px);
double nx = node.Point.X;
if (px == nx) {
if (point != node.Point) {
// We might have two nodes with same x value for a short time
if (point == node.Prev.Point) {
node = node.Prev;
} else if (point == node.Next.Point) {
node = node.Next;
} else {
throw new Exception("Failed to find Node for given afront point");
}
}
} else if (px < nx) {
while ((node = node.Prev) != null) if (point == node.Point) break;
} else {
while ((node = node.Next) != null) if (point == node.Point) break;
}
Search = node;
return node;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 53aa5497892312842a4c059529cd2397
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,54 @@
/* Poly2Tri
* Copyright (c) 2009-2010, Poly2Tri Contributors
* http://code.google.com/p/poly2tri/
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* * Neither the name of Poly2Tri nor the names of its contributors may be
* used to endorse or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/// Changes from the Java version
/// Removed getters
/// Has* turned into attributes
/// Future possibilities
/// Comments!
namespace UnityEngine.ProBuilder.Poly2Tri {
class AdvancingFrontNode {
public AdvancingFrontNode Next;
public AdvancingFrontNode Prev;
public double Value;
public TriangulationPoint Point;
public DelaunayTriangle Triangle;
public AdvancingFrontNode(TriangulationPoint point) {
this.Point = point;
Value = point.X;
}
public bool HasNext { get { return Next != null; } }
public bool HasPrev { get { return Prev != null; } }
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9d6fbeb339bff0f4cb3744bd60aec40f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,908 @@
/* Poly2Tri
* Copyright (c) 2009-2010, Poly2Tri Contributors
* http://code.google.com/p/poly2tri/
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* * Neither the name of Poly2Tri nor the names of its contributors may be
* used to endorse or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* Sweep-line, Constrained Delauney Triangulation (CDT) See: Domiter, V. and
* Zalik, B.(2008)'Sweep-line algorithm for constrained Delaunay triangulation',
* International Journal of Geographical Information Science
*
* "FlipScan" Constrained Edge Algorithm invented by author of this code.
*
* Author: Thomas Åhlén, [email protected]
*/
/// Changes from the Java version
/// Turned DTSweep into a static class
/// Lots of deindentation via early bailout
/// Future possibilities
/// Comments!
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
namespace UnityEngine.ProBuilder.Poly2Tri {
static class DTSweep {
private const double PI_div2 = Math.PI / 2;
private const double PI_3div4 = 3 * Math.PI / 4;
/// <summary>
/// Triangulate simple polygon with holes
/// </summary>
public static void Triangulate( DTSweepContext tcx ) {
tcx.CreateAdvancingFront();
Sweep(tcx);
// TODO: remove temporary
// Check if the sweep algorithm is legalize robust
// By doing a legalize on all triangles and see if anything happens
// we know if the sweep algorithm missed some legalizations
// Console.WriteLine("============================");
// foreach ( DelaunayTriangle t in tcx.Triangles )
// {
// if( Legalize( tcx, t ) )
// {
// tcx.getDebugContext().setPrimaryTriangle( t );
// Console.WriteLine("[FIX] Triangle needed legalization after sweep");
// }
// }
// Finalize triangulation
if (tcx.TriangulationMode == TriangulationMode.Polygon) {
FinalizationPolygon(tcx);
} else {
FinalizationConvexHull(tcx);
}
tcx.Done();
}
/// <summary>
/// Start sweeping the Y-sorted point set from bottom to top
/// </summary>
private static void Sweep( DTSweepContext tcx ) {
var points = tcx.Points;
TriangulationPoint point;
AdvancingFrontNode node;
for (int i = 1; i < points.Count; i++) {
point = points[i];
node = PointEvent(tcx, point);
if (point.HasEdges) foreach (DTSweepConstraint e in point.Edges) {
if (tcx.IsDebugEnabled) tcx.DTDebugContext.ActiveConstraint = e;
EdgeEvent(tcx, e, node);
}
tcx.Update(null);
}
}
/// <summary>
/// If this is a Delaunay Triangulation of a pointset we need to fill so the triangle mesh gets a ConvexHull
/// </summary>
private static void FinalizationConvexHull( DTSweepContext tcx ) {
AdvancingFrontNode n1, n2;
DelaunayTriangle t1;
TriangulationPoint first, p1;
n1 = tcx.Front.Head.Next;
n2 = n1.Next;
first = n1.Point;
TurnAdvancingFrontConvex(tcx, n1, n2);
n1 = tcx.Front.Tail.Prev;
if (n1.Triangle.Contains(n1.Next.Point) && n1.Triangle.Contains(n1.Prev.Point)) {
t1 = n1.Triangle.NeighborAcrossFrom(n1.Point);
RotateTrianglePair(n1.Triangle, n1.Point, t1, t1.OppositePoint(n1.Triangle, n1.Point));
tcx.MapTriangleToNodes(n1.Triangle);
tcx.MapTriangleToNodes(t1);
}
n1 = tcx.Front.Head.Next;
if (n1.Triangle.Contains(n1.Prev.Point) && n1.Triangle.Contains(n1.Next.Point)) {
t1 = n1.Triangle.NeighborAcrossFrom(n1.Point);
RotateTrianglePair(n1.Triangle, n1.Point, t1, t1.OppositePoint(n1.Triangle, n1.Point));
tcx.MapTriangleToNodes(n1.Triangle);
tcx.MapTriangleToNodes(t1);
}
// TODO: implement ConvexHull for lower right and left boundary
// Lower right boundary
first = tcx.Front.Head.Point;
n2 = tcx.Front.Tail.Prev;
t1 = n2.Triangle;
p1 = n2.Point;
do {
tcx.RemoveFromList(t1);
p1 = t1.PointCCWFrom(p1);
if (p1 == first) break;
t1 = t1.NeighborCCWFrom(p1);
} while (true);
// Lower left boundary
first = tcx.Front.Head.Next.Point;
p1 = t1.PointCWFrom(tcx.Front.Head.Point);
t1 = t1.NeighborCWFrom(tcx.Front.Head.Point);
do {
tcx.RemoveFromList(t1);
p1 = t1.PointCCWFrom(p1);
t1 = t1.NeighborCCWFrom(p1);
} while (p1 != first);
tcx.FinalizeTriangulation();
}
/// <summary>
/// We will traverse the entire advancing front and fill it to form a convex hull.
/// </summary>
private static void TurnAdvancingFrontConvex( DTSweepContext tcx, AdvancingFrontNode b, AdvancingFrontNode c ) {
AdvancingFrontNode first = b;
while (c != tcx.Front.Tail) {
if (tcx.IsDebugEnabled) tcx.DTDebugContext.ActiveNode = c;
if (TriangulationUtil.Orient2d(b.Point, c.Point, c.Next.Point) == Orientation.CCW) {
// [b,c,d] Concave - fill around c
Fill(tcx, c);
c = c.Next;
} else {
// [b,c,d] Convex
if (b != first && TriangulationUtil.Orient2d(b.Prev.Point, b.Point, c.Point) == Orientation.CCW) {
// [a,b,c] Concave - fill around b
Fill(tcx, b);
b = b.Prev;
} else {
// [a,b,c] Convex - nothing to fill
b = c;
c = c.Next;
}
}
}
}
private static void FinalizationPolygon( DTSweepContext tcx ) {
// Get an Internal triangle to start with
DelaunayTriangle t = tcx.Front.Head.Next.Triangle;
TriangulationPoint p = tcx.Front.Head.Next.Point;
while (!t.GetConstrainedEdgeCW(p)) t = t.NeighborCCWFrom(p);
// Collect interior triangles constrained by edges
tcx.MeshClean(t);
}
/// <summary>
/// Find closes node to the left of the new point and
/// create a new triangle. If needed new holes and basins
/// will be filled to.
/// </summary>
private static AdvancingFrontNode PointEvent( DTSweepContext tcx, TriangulationPoint point ) {
AdvancingFrontNode node, newNode;
node = tcx.LocateNode(point);
if (tcx.IsDebugEnabled) tcx.DTDebugContext.ActiveNode = node;
newNode = NewFrontTriangle(tcx, point, node);
// Only need to check +epsilon since point never have smaller
// x value than node due to how we fetch nodes from the front
if (point.X <= node.Point.X + TriangulationUtil.EPSILON) Fill(tcx, node);
tcx.AddNode(newNode);
FillAdvancingFront(tcx, newNode);
return newNode;
}
/// <summary>
/// Creates a new front triangle and legalize it
/// </summary>
private static AdvancingFrontNode NewFrontTriangle( DTSweepContext tcx, TriangulationPoint point, AdvancingFrontNode node ) {
AdvancingFrontNode newNode;
DelaunayTriangle triangle;
triangle = new DelaunayTriangle(point, node.Point, node.Next.Point);
triangle.MarkNeighbor(node.Triangle);
tcx.Triangles.Add(triangle);
newNode = new AdvancingFrontNode(point);
newNode.Next = node.Next;
newNode.Prev = node;
node.Next.Prev = newNode;
node.Next = newNode;
tcx.AddNode(newNode); // XXX: BST
if (tcx.IsDebugEnabled) tcx.DTDebugContext.ActiveNode = newNode;
if (!Legalize(tcx, triangle)) tcx.MapTriangleToNodes(triangle);
return newNode;
}
private static void EdgeEvent( DTSweepContext tcx, DTSweepConstraint edge, AdvancingFrontNode node ) {
try
{
tcx.EdgeEvent.ConstrainedEdge = edge;
tcx.EdgeEvent.Right = edge.P.X > edge.Q.X;
if (tcx.IsDebugEnabled) { tcx.DTDebugContext.PrimaryTriangle = node.Triangle; }
if (IsEdgeSideOfTriangle(node.Triangle, edge.P, edge.Q))
return;
// For now we will do all needed filling
// TODO: integrate with flip process might give some better performance
// but for now this avoid the issue with cases that needs both flips and fills
FillEdgeEvent(tcx, edge, node);
EdgeEvent(tcx, edge.P, edge.Q, node.Triangle, edge.Q);
}
catch { }
// catch (PointOnEdgeException e)
// {
// //Debug.WriteLine( String.Format( "Warning: Skipping Edge: {0}", e.Message ) );
// throw;
// }
}
private static void FillEdgeEvent( DTSweepContext tcx, DTSweepConstraint edge, AdvancingFrontNode node ) {
if (tcx.EdgeEvent.Right) {
FillRightAboveEdgeEvent(tcx, edge, node);
} else {
FillLeftAboveEdgeEvent(tcx, edge, node);
}
}
private static void FillRightConcaveEdgeEvent( DTSweepContext tcx, DTSweepConstraint edge, AdvancingFrontNode node ) {
Fill(tcx, node.Next);
if (node.Next.Point != edge.P) {
// Next above or below edge?
if (TriangulationUtil.Orient2d(edge.Q, node.Next.Point, edge.P) == Orientation.CCW) {
// Below
if (TriangulationUtil.Orient2d(node.Point, node.Next.Point, node.Next.Next.Point) == Orientation.CCW) {
// Next is concave
FillRightConcaveEdgeEvent(tcx, edge, node);
} else {
// Next is convex
}
}
}
}
private static void FillRightConvexEdgeEvent( DTSweepContext tcx, DTSweepConstraint edge, AdvancingFrontNode node ) {
// Next concave or convex?
if (TriangulationUtil.Orient2d(node.Next.Point, node.Next.Next.Point, node.Next.Next.Next.Point) == Orientation.CCW) {
// Concave
FillRightConcaveEdgeEvent(tcx, edge, node.Next);
} else {
// Convex
// Next above or below edge?
if (TriangulationUtil.Orient2d(edge.Q, node.Next.Next.Point, edge.P) == Orientation.CCW) {
// Below
FillRightConvexEdgeEvent(tcx, edge, node.Next);
} else {
// Above
}
}
}
private static void FillRightBelowEdgeEvent( DTSweepContext tcx, DTSweepConstraint edge, AdvancingFrontNode node ) {
if (tcx.IsDebugEnabled) tcx.DTDebugContext.ActiveNode = node;
if (node.Point.X < edge.P.X) { // needed?
if (TriangulationUtil.Orient2d(node.Point, node.Next.Point, node.Next.Next.Point) == Orientation.CCW) {
// Concave
FillRightConcaveEdgeEvent(tcx, edge, node);
} else {
// Convex
FillRightConvexEdgeEvent(tcx, edge, node);
// Retry this one
FillRightBelowEdgeEvent(tcx, edge, node);
}
}
}
private static void FillRightAboveEdgeEvent( DTSweepContext tcx, DTSweepConstraint edge, AdvancingFrontNode node ) {
while (node.Next.Point.X < edge.P.X) {
if (tcx.IsDebugEnabled) { tcx.DTDebugContext.ActiveNode = node; }
// Check if next node is below the edge
Orientation o1 = TriangulationUtil.Orient2d(edge.Q, node.Next.Point, edge.P);
if (o1 == Orientation.CCW) {
FillRightBelowEdgeEvent(tcx, edge, node);
} else {
node = node.Next;
}
}
}
private static void FillLeftConvexEdgeEvent( DTSweepContext tcx, DTSweepConstraint edge, AdvancingFrontNode node ) {
// Next concave or convex?
if (TriangulationUtil.Orient2d(node.Prev.Point, node.Prev.Prev.Point, node.Prev.Prev.Prev.Point) == Orientation.CW) {
// Concave
FillLeftConcaveEdgeEvent(tcx, edge, node.Prev);
} else {
// Convex
// Next above or below edge?
if (TriangulationUtil.Orient2d(edge.Q, node.Prev.Prev.Point, edge.P) == Orientation.CW) {
// Below
FillLeftConvexEdgeEvent(tcx, edge, node.Prev);
} else {
// Above
}
}
}
private static void FillLeftConcaveEdgeEvent( DTSweepContext tcx, DTSweepConstraint edge, AdvancingFrontNode node ) {
Fill(tcx, node.Prev);
if (node.Prev.Point != edge.P) {
// Next above or below edge?
if (TriangulationUtil.Orient2d(edge.Q, node.Prev.Point, edge.P) == Orientation.CW) {
// Below
if (TriangulationUtil.Orient2d(node.Point, node.Prev.Point, node.Prev.Prev.Point) == Orientation.CW) {
// Next is concave
FillLeftConcaveEdgeEvent(tcx, edge, node);
} else {
// Next is convex
}
}
}
}
private static void FillLeftBelowEdgeEvent( DTSweepContext tcx, DTSweepConstraint edge, AdvancingFrontNode node ) {
if (tcx.IsDebugEnabled) tcx.DTDebugContext.ActiveNode = node;
if (node.Point.X > edge.P.X) {
if (TriangulationUtil.Orient2d(node.Point, node.Prev.Point, node.Prev.Prev.Point) == Orientation.CW) {
// Concave
FillLeftConcaveEdgeEvent(tcx, edge, node);
} else {
// Convex
FillLeftConvexEdgeEvent(tcx, edge, node);
// Retry this one
FillLeftBelowEdgeEvent(tcx, edge, node);
}
}
}
private static void FillLeftAboveEdgeEvent( DTSweepContext tcx, DTSweepConstraint edge, AdvancingFrontNode node ) {
while (node.Prev.Point.X > edge.P.X) {
if (tcx.IsDebugEnabled) tcx.DTDebugContext.ActiveNode = node;
// Check if next node is below the edge
Orientation o1 = TriangulationUtil.Orient2d(edge.Q, node.Prev.Point, edge.P);
if (o1 == Orientation.CW) {
FillLeftBelowEdgeEvent(tcx, edge, node);
} else {
node = node.Prev;
}
}
}
private static bool IsEdgeSideOfTriangle( DelaunayTriangle triangle, TriangulationPoint ep, TriangulationPoint eq ) {
int index = triangle.EdgeIndex(ep, eq);
if ( index == -1 ) return false;
triangle.MarkConstrainedEdge(index);
triangle = triangle.Neighbors[index];
if (triangle != null) triangle.MarkConstrainedEdge(ep, eq);
return true;
}
private static void EdgeEvent( DTSweepContext tcx, TriangulationPoint ep, TriangulationPoint eq, DelaunayTriangle triangle, TriangulationPoint point ) {
TriangulationPoint p1, p2;
if (tcx.IsDebugEnabled) tcx.DTDebugContext.PrimaryTriangle=triangle;
if (IsEdgeSideOfTriangle(triangle, ep, eq)) return;
p1 = triangle.PointCCWFrom(point);
Orientation o1 = TriangulationUtil.Orient2d(eq, p1, ep);
if (o1 == Orientation.Collinear) {
// TODO: Split edge in two
//// splitEdge( ep, eq, p1 );
// edgeEvent( tcx, p1, eq, triangle, point );
// edgeEvent( tcx, ep, p1, triangle, p1 );
// return;
throw new PointOnEdgeException("EdgeEvent - Point on constrained edge not supported yet",eq,p1,ep);
}
p2 = triangle.PointCWFrom(point);
Orientation o2 = TriangulationUtil.Orient2d(eq, p2, ep);
if (o2 == Orientation.Collinear) {
// TODO: Split edge in two
// edgeEvent( tcx, p2, eq, triangle, point );
// edgeEvent( tcx, ep, p2, triangle, p2 );
// return;
throw new PointOnEdgeException("EdgeEvent - Point on constrained edge not supported yet",eq,p2,ep);
}
if (o1 == o2) {
// Need to decide if we are rotating CW or CCW to get to a triangle
// that will cross edge
if (o1 == Orientation.CW) {
triangle = triangle.NeighborCCWFrom(point);
} else {
triangle = triangle.NeighborCWFrom(point);
}
EdgeEvent(tcx, ep, eq, triangle, point);
} else {
// This triangle crosses constraint so lets flippin start!
FlipEdgeEvent(tcx, ep, eq, triangle, point);
}
}
/// <summary>
/// In the case of a pointset with some constraint edges. If a triangle side is collinear
/// with a part of the constraint we split the constraint into two constraints. This could
/// happen when the given constraint migth intersect a point in the set.<br>
/// This can never happen in the case when we are working with a polygon.
///
/// Think of two triangles that have non shared sides that are collinear and the constraint
/// is set from a point in triangle A to a point in triangle B so that the constraint is
/// the union of both those sides. We then have to split the constraint into two so we get
/// one constraint for each triangle.
/// </summary>
/// <param name="ep"></param>
/// <param name="eq"></param>
/// <param name="p">point on the edge between ep->eq</param>
private static void SplitEdge( TriangulationPoint ep, TriangulationPoint eq, TriangulationPoint p ) {
DTSweepConstraint edge = eq.Edges.First( e => e.Q==ep || e.P==ep );
edge.P = p;
new DTSweepConstraint(ep, p); // Et tu, Brute? --MM
// // Redo this edge now that we have split the constraint
// newEdgeEvent( tcx, edge, triangle, point );
// // Continue with new edge
// newEdgeEvent( tcx, edge, triangle, p2 );
}
private static void FlipEdgeEvent( DTSweepContext tcx, TriangulationPoint ep, TriangulationPoint eq, DelaunayTriangle t, TriangulationPoint p ) {
DelaunayTriangle ot = t.NeighborAcrossFrom(p);
TriangulationPoint op = ot.OppositePoint(t, p);
if (ot == null) {
// If we want to integrate the fillEdgeEvent do it here
// With current implementation we should never get here
throw new InvalidOperationException("[BUG:FIXME] FLIP failed due to missing triangle");
}
if (tcx.IsDebugEnabled) {
tcx.DTDebugContext.PrimaryTriangle = t;
tcx.DTDebugContext.SecondaryTriangle = ot;
} // TODO: remove
bool inScanArea = TriangulationUtil.InScanArea(p, t.PointCCWFrom(p), t.PointCWFrom(p), op);
if (inScanArea) {
// Lets rotate shared edge one vertex CW
RotateTrianglePair(t, p, ot, op);
tcx.MapTriangleToNodes(t);
tcx.MapTriangleToNodes(ot);
if (p == eq && op == ep) {
if (eq == tcx.EdgeEvent.ConstrainedEdge.Q
&& ep == tcx.EdgeEvent.ConstrainedEdge.P) {
if (tcx.IsDebugEnabled) Console.WriteLine("[FLIP] - constrained edge done"); // TODO: remove
t.MarkConstrainedEdge(ep, eq);
ot.MarkConstrainedEdge(ep, eq);
Legalize(tcx, t);
Legalize(tcx, ot);
} else {
if (tcx.IsDebugEnabled) Console.WriteLine("[FLIP] - subedge done"); // TODO: remove
// XXX: I think one of the triangles should be legalized here?
}
} else {
if (tcx.IsDebugEnabled) Console.WriteLine("[FLIP] - flipping and continuing with triangle still crossing edge"); // TODO: remove
Orientation o = TriangulationUtil.Orient2d(eq, op, ep);
t = NextFlipTriangle(tcx, o, t, ot, p, op);
FlipEdgeEvent(tcx, ep, eq, t, p);
}
} else {
TriangulationPoint newP = NextFlipPoint(ep, eq, ot, op);
FlipScanEdgeEvent(tcx, ep, eq, t, ot, newP);
EdgeEvent(tcx, ep, eq, t, p);
}
}
/// <summary>
/// When we need to traverse from one triangle to the next we need
/// the point in current triangle that is the opposite point to the next
/// triangle.
/// </summary>
private static TriangulationPoint NextFlipPoint( TriangulationPoint ep, TriangulationPoint eq, DelaunayTriangle ot, TriangulationPoint op ) {
Orientation o2d = TriangulationUtil.Orient2d(eq, op, ep);
switch ( o2d ) {
case Orientation.CW: return ot.PointCCWFrom(op);
case Orientation.CCW: return ot.PointCWFrom(op);
case Orientation.Collinear:
// TODO: implement support for point on constraint edge
throw new PointOnEdgeException("Point on constrained edge not supported yet",eq,op,ep);
default:
throw new NotImplementedException("Orientation not handled");
}
}
/// <summary>
/// After a flip we have two triangles and know that only one will still be
/// intersecting the edge. So decide which to contiune with and legalize the other
/// </summary>
/// <param name="tcx"></param>
/// <param name="o">should be the result of an TriangulationUtil.orient2d( eq, op, ep )</param>
/// <param name="t">triangle 1</param>
/// <param name="ot">triangle 2</param>
/// <param name="p">a point shared by both triangles</param>
/// <param name="op">another point shared by both triangles</param>
/// <returns>returns the triangle still intersecting the edge</returns>
private static DelaunayTriangle NextFlipTriangle( DTSweepContext tcx, Orientation o, DelaunayTriangle t, DelaunayTriangle ot, TriangulationPoint p, TriangulationPoint op ) {
int edgeIndex;
if (o == Orientation.CCW) {
// ot is not crossing edge after flip
edgeIndex = ot.EdgeIndex(p, op);
ot.EdgeIsDelaunay[edgeIndex] = true;
Legalize(tcx, ot);
ot.EdgeIsDelaunay.Clear();
return t;
}
// t is not crossing edge after flip
edgeIndex = t.EdgeIndex(p, op);
t.EdgeIsDelaunay[edgeIndex] = true;
Legalize(tcx, t);
t.EdgeIsDelaunay.Clear();
return ot;
}
/// <summary>
/// Scan part of the FlipScan algorithm<br>
/// When a triangle pair isn't flippable we will scan for the next
/// point that is inside the flip triangle scan area. When found
/// we generate a new flipEdgeEvent
/// </summary>
/// <param name="tcx"></param>
/// <param name="ep">last point on the edge we are traversing</param>
/// <param name="eq">first point on the edge we are traversing</param>
/// <param name="flipTriangle">the current triangle sharing the point eq with edge</param>
/// <param name="t"></param>
/// <param name="p"></param>
private static void FlipScanEdgeEvent( DTSweepContext tcx, TriangulationPoint ep, TriangulationPoint eq, DelaunayTriangle flipTriangle, DelaunayTriangle t, TriangulationPoint p ) {
DelaunayTriangle ot;
TriangulationPoint op, newP;
bool inScanArea;
ot = t.NeighborAcrossFrom(p);
op = ot.OppositePoint(t, p);
if (ot == null) {
// If we want to integrate the fillEdgeEvent do it here
// With current implementation we should never get here
throw new Exception("[BUG:FIXME] FLIP failed due to missing triangle");
}
if (tcx.IsDebugEnabled) {
Console.WriteLine("[FLIP:SCAN] - scan next point"); // TODO: remove
tcx.DTDebugContext.PrimaryTriangle = t;
tcx.DTDebugContext.SecondaryTriangle = ot;
}
inScanArea = TriangulationUtil.InScanArea(eq, flipTriangle.PointCCWFrom(eq), flipTriangle.PointCWFrom(eq), op);
if (inScanArea) {
// flip with new edge op->eq
FlipEdgeEvent(tcx, eq, op, ot, op);
// TODO: Actually I just figured out that it should be possible to
// improve this by getting the next ot and op before the the above
// flip and continue the flipScanEdgeEvent here
// set new ot and op here and loop back to inScanArea test
// also need to set a new flipTriangle first
// Turns out at first glance that this is somewhat complicated
// so it will have to wait.
} else {
newP = NextFlipPoint(ep, eq, ot, op);
FlipScanEdgeEvent(tcx, ep, eq, flipTriangle, ot, newP);
}
}
/// <summary>
/// Fills holes in the Advancing Front
/// </summary>
private static void FillAdvancingFront( DTSweepContext tcx, AdvancingFrontNode n ) {
AdvancingFrontNode node;
double angle;
// Fill right holes
node = n.Next;
while (node.HasNext) {
angle = HoleAngle(node);
if (angle > PI_div2 || angle < -PI_div2) break;
Fill(tcx, node);
node = node.Next;
}
// Fill left holes
node = n.Prev;
while (node.HasPrev) {
angle = HoleAngle(node);
if (angle > PI_div2 || angle < -PI_div2) break;
Fill(tcx, node);
node = node.Prev;
}
// Fill right basins
if (n.HasNext && n.Next.HasNext) {
angle = BasinAngle(n);
if (angle < PI_3div4) FillBasin(tcx, n);
}
}
/// <summary>
/// Fills a basin that has formed on the Advancing Front to the right
/// of given node.<br>
/// First we decide a left,bottom and right node that forms the
/// boundaries of the basin. Then we do a reqursive fill.
/// </summary>
/// <param name="tcx"></param>
/// <param name="node">starting node, this or next node will be left node</param>
private static void FillBasin( DTSweepContext tcx, AdvancingFrontNode node ) {
if (TriangulationUtil.Orient2d(node.Point, node.Next.Point, node.Next.Next.Point) == Orientation.CCW) {
// tcx.basin.leftNode = node.next.next;
tcx.Basin.leftNode = node;
} else {
tcx.Basin.leftNode = node.Next;
}
// Find the bottom and right node
tcx.Basin.bottomNode = tcx.Basin.leftNode;
while (tcx.Basin.bottomNode.HasNext && tcx.Basin.bottomNode.Point.Y >= tcx.Basin.bottomNode.Next.Point.Y) tcx.Basin.bottomNode = tcx.Basin.bottomNode.Next;
if (tcx.Basin.bottomNode == tcx.Basin.leftNode) return; // No valid basin
tcx.Basin.rightNode = tcx.Basin.bottomNode;
while (tcx.Basin.rightNode.HasNext && tcx.Basin.rightNode.Point.Y < tcx.Basin.rightNode.Next.Point.Y) tcx.Basin.rightNode = tcx.Basin.rightNode.Next;
if (tcx.Basin.rightNode == tcx.Basin.bottomNode) return; // No valid basins
tcx.Basin.width = tcx.Basin.rightNode.Point.X - tcx.Basin.leftNode.Point.X;
tcx.Basin.leftHighest = tcx.Basin.leftNode.Point.Y > tcx.Basin.rightNode.Point.Y;
FillBasinReq(tcx, tcx.Basin.bottomNode);
}
/// <summary>
/// Recursive algorithm to fill a Basin with triangles
/// </summary>
private static void FillBasinReq( DTSweepContext tcx, AdvancingFrontNode node ) {
if (IsShallow(tcx, node)) return; // if shallow stop filling
Fill(tcx, node);
if (node.Prev == tcx.Basin.leftNode && node.Next == tcx.Basin.rightNode) {
return;
} else if (node.Prev == tcx.Basin.leftNode) {
Orientation o = TriangulationUtil.Orient2d(node.Point, node.Next.Point, node.Next.Next.Point);
if (o == Orientation.CW) return;
node = node.Next;
} else if (node.Next == tcx.Basin.rightNode) {
Orientation o = TriangulationUtil.Orient2d(node.Point, node.Prev.Point, node.Prev.Prev.Point);
if (o == Orientation.CCW) return;
node = node.Prev;
} else {
// Continue with the neighbor node with lowest Y value
if (node.Prev.Point.Y < node.Next.Point.Y) {
node = node.Prev;
} else {
node = node.Next;
}
}
FillBasinReq(tcx, node);
}
private static bool IsShallow( DTSweepContext tcx, AdvancingFrontNode node ) {
double height;
if (tcx.Basin.leftHighest) {
height = tcx.Basin.leftNode.Point.Y - node.Point.Y;
} else {
height = tcx.Basin.rightNode.Point.Y - node.Point.Y;
}
if (tcx.Basin.width > height) {
return true;
}
return false;
}
/// <summary>
/// ???
/// </summary>
/// <param name="node">middle node</param>
/// <returns>the angle between 3 front nodes</returns>
private static double HoleAngle( AdvancingFrontNode node ) {
// XXX: do we really need a signed angle for holeAngle?
// could possible save some cycles here
/* Complex plane
* ab = cosA +i*sinA
* ab = (ax + ay*i)(bx + by*i) = (ax*bx + ay*by) + i(ax*by-ay*bx)
* atan2(y,x) computes the principal value of the argument function
* applied to the complex number x+iy
* Where x = ax*bx + ay*by
* y = ax*by - ay*bx
*/
double px = node.Point.X;
double py = node.Point.Y;
double ax = node.Next.Point.X - px;
double ay = node.Next.Point.Y - py;
double bx = node.Prev.Point.X - px;
double by = node.Prev.Point.Y - py;
return Math.Atan2(ax * by - ay * bx, ax * bx + ay * by);
}
/// <summary>
/// The basin angle is decided against the horizontal line [1,0]
/// </summary>
private static double BasinAngle( AdvancingFrontNode node ) {
double ax = node.Point.X - node.Next.Next.Point.X;
double ay = node.Point.Y - node.Next.Next.Point.Y;
return Math.Atan2(ay, ax);
}
/// <summary>
/// Adds a triangle to the advancing front to fill a hole.
/// </summary>
/// <param name="tcx"></param>
/// <param name="node">middle node, that is the bottom of the hole</param>
private static void Fill( DTSweepContext tcx, AdvancingFrontNode node ) {
DelaunayTriangle triangle = new DelaunayTriangle(node.Prev.Point, node.Point, node.Next.Point);
// TODO: should copy the cEdge value from neighbor triangles
// for now cEdge values are copied during the legalize
triangle.MarkNeighbor(node.Prev.Triangle);
triangle.MarkNeighbor(node.Triangle);
tcx.Triangles.Add(triangle);
// Update the advancing front
node.Prev.Next = node.Next;
node.Next.Prev = node.Prev;
tcx.RemoveNode(node);
// If it was legalized the triangle has already been mapped
if (!Legalize(tcx, triangle)) tcx.MapTriangleToNodes(triangle);
}
/// <summary>
/// Returns true if triangle was legalized
/// </summary>
private static bool Legalize( DTSweepContext tcx, DelaunayTriangle t ) {
// To legalize a triangle we start by finding if any of the three edges
// violate the Delaunay condition
for (int i = 0; i < 3; i++) {
// TODO: fix so that cEdge is always valid when creating new triangles then we can check it here
// instead of below with ot
if (t.EdgeIsDelaunay[i]) continue;
DelaunayTriangle ot = t.Neighbors[i];
if (ot == null) continue;
TriangulationPoint p = t.Points[i];
TriangulationPoint op = ot.OppositePoint(t, p);
int oi = ot.IndexOf(op);
// If this is a Constrained Edge or a Delaunay Edge(only during recursive legalization)
// then we should not try to legalize
if (ot.EdgeIsConstrained[oi] || ot.EdgeIsDelaunay[oi]) {
t.EdgeIsConstrained[i] = ot.EdgeIsConstrained[oi]; // XXX: have no good way of setting this property when creating new triangles so lets set it here
continue;
}
if (!TriangulationUtil.SmartIncircle(p,t.PointCCWFrom(p),t.PointCWFrom(p),op)) continue;
// Lets mark this shared edge as Delaunay
t.EdgeIsDelaunay[i] = true;
ot.EdgeIsDelaunay[oi] = true;
// Lets rotate shared edge one vertex CW to legalize it
RotateTrianglePair(t, p, ot, op);
// We now got one valid Delaunay Edge shared by two triangles
// This gives us 4 new edges to check for Delaunay
// Make sure that triangle to node mapping is done only one time for a specific triangle
if (!Legalize(tcx, t)) tcx.MapTriangleToNodes(t);
if (!Legalize(tcx, ot)) tcx.MapTriangleToNodes(ot);
// Reset the Delaunay edges, since they only are valid Delaunay edges
// until we add a new triangle or point.
// XXX: need to think about this. Can these edges be tried after we
// return to previous recursive level?
t.EdgeIsDelaunay[i] = false;
ot.EdgeIsDelaunay[oi] = false;
// If triangle have been legalized no need to check the other edges since
// the recursive legalization will handles those so we can end here.
return true;
}
return false;
}
/// <summary>
/// Rotates a triangle pair one vertex CW
/// n2 n2
/// P +-----+ P +-----+
/// | t /| |\ t |
/// | / | | \ |
/// n1| / |n3 n1| \ |n3
/// | / | after CW | \ |
/// |/ oT | | oT \|
/// +-----+ oP +-----+
/// n4 n4
/// </summary>
private static void RotateTrianglePair( DelaunayTriangle t, TriangulationPoint p, DelaunayTriangle ot, TriangulationPoint op ) {
DelaunayTriangle n1, n2, n3, n4;
n1 = t.NeighborCCWFrom(p);
n2 = t.NeighborCWFrom(p);
n3 = ot.NeighborCCWFrom(op);
n4 = ot.NeighborCWFrom(op);
bool ce1, ce2, ce3, ce4;
ce1 = t.GetConstrainedEdgeCCW(p);
ce2 = t.GetConstrainedEdgeCW(p);
ce3 = ot.GetConstrainedEdgeCCW(op);
ce4 = ot.GetConstrainedEdgeCW(op);
bool de1, de2, de3, de4;
de1 = t.GetDelaunayEdgeCCW(p);
de2 = t.GetDelaunayEdgeCW(p);
de3 = ot.GetDelaunayEdgeCCW(op);
de4 = ot.GetDelaunayEdgeCW(op);
t.Legalize(p, op);
ot.Legalize(op, p);
// Remap dEdge
ot.SetDelaunayEdgeCCW(p, de1);
t.SetDelaunayEdgeCW(p, de2);
t.SetDelaunayEdgeCCW(op, de3);
ot.SetDelaunayEdgeCW(op, de4);
// Remap cEdge
ot.SetConstrainedEdgeCCW(p, ce1);
t.SetConstrainedEdgeCW(p, ce2);
t.SetConstrainedEdgeCCW(op, ce3);
ot.SetConstrainedEdgeCW(op, ce4);
// Remap neighbors
// XXX: might optimize the markNeighbor by keeping track of
// what side should be assigned to what neighbor after the
// rotation. Now mark neighbor does lots of testing to find
// the right side.
t.Neighbors.Clear();
ot.Neighbors.Clear();
if (n1 != null) ot.MarkNeighbor(n1);
if (n2 != null) t.MarkNeighbor(n2);
if (n3 != null) t.MarkNeighbor(n3);
if (n4 != null) ot.MarkNeighbor(n4);
t.MarkNeighbor(ot);
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2b3f77c5dfa698a478ad5d291674b8a5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,40 @@
/* Poly2Tri
* Copyright (c) 2009-2010, Poly2Tri Contributors
* http://code.google.com/p/poly2tri/
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* * Neither the name of Poly2Tri nor the names of its contributors may be
* used to endorse or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
namespace UnityEngine.ProBuilder.Poly2Tri {
class DTSweepBasin {
public AdvancingFrontNode leftNode;
public AdvancingFrontNode bottomNode;
public AdvancingFrontNode rightNode;
public double width;
public bool leftHighest;
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d6658a80b0b3b964281a5312b39c9203
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,57 @@
/* Poly2Tri
* Copyright (c) 2009-2010, Poly2Tri Contributors
* http://code.google.com/p/poly2tri/
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* * Neither the name of Poly2Tri nor the names of its contributors may be
* used to endorse or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
namespace UnityEngine.ProBuilder.Poly2Tri {
class DTSweepConstraint : TriangulationConstraint {
/// <summary>
/// Give two points in any order. Will always be ordered so
/// that q.y > p.y and q.x > p.x if same y value
/// </summary>
public DTSweepConstraint( TriangulationPoint p1, TriangulationPoint p2 ) {
P = p1;
Q = p2;
if (p1.Y > p2.Y) {
Q = p1;
P = p2;
} else if (p1.Y == p2.Y) {
if (p1.X > p2.X) {
Q = p1;
P = p2;
} else if (p1.X == p2.X) {
// logger.info( "Failed to create constraint {}={}", p1, p2 );
// throw new DuplicatePointException( p1 + "=" + p2 );
// return;
}
}
Q.AddEdge(this);
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2efa3d03c26294747aaa61c2a09ac41f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,197 @@
/* Poly2Tri
* Copyright (c) 2009-2010, Poly2Tri Contributors
* http://code.google.com/p/poly2tri/
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* * Neither the name of Poly2Tri nor the names of its contributors may be
* used to endorse or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
namespace UnityEngine.ProBuilder.Poly2Tri {
/**
*
* @author Thomas Åhlén, [email protected]
*
*/
class DTSweepContext : TriangulationContext {
// Inital triangle factor, seed triangle will extend 30% of
// PointSet width to both left and right.
private readonly float ALPHA = 0.3f;
public AdvancingFront Front;
public TriangulationPoint Head { get; set; }
public TriangulationPoint Tail { get; set; }
public DTSweepBasin Basin = new DTSweepBasin();
public DTSweepEdgeEvent EdgeEvent = new DTSweepEdgeEvent();
private DTSweepPointComparator _comparator = new DTSweepPointComparator();
public DTSweepContext() {
Clear();
}
public override bool IsDebugEnabled { get {
return base.IsDebugEnabled;
} protected set {
if (value && DebugContext == null) DebugContext = new DTSweepDebugContext(this);
base.IsDebugEnabled = value;
}}
public void RemoveFromList( DelaunayTriangle triangle ) {
Triangles.Remove(triangle);
// TODO: remove all neighbor pointers to this triangle
// for( int i=0; i<3; i++ )
// {
// if( triangle.neighbors[i] != null )
// {
// triangle.neighbors[i].clearNeighbor( triangle );
// }
// }
// triangle.clearNeighbors();
}
public void MeshClean( DelaunayTriangle triangle ) {
MeshCleanReq(triangle);
}
private void MeshCleanReq( DelaunayTriangle triangle ) {
if (triangle != null && !triangle.IsInterior) {
triangle.IsInterior = true;
Triangulatable.AddTriangle(triangle);
for (int i = 0; i < 3; i++)
if (!triangle.EdgeIsConstrained[i])
{
MeshCleanReq(triangle.Neighbors[i]);
}
}
}
public override void Clear() {
base.Clear();
Triangles.Clear();
}
public void AddNode( AdvancingFrontNode node ) {
// Console.WriteLine( "add:" + node.key + ":" + System.identityHashCode(node.key));
// m_nodeTree.put( node.getKey(), node );
Front.AddNode(node);
}
public void RemoveNode( AdvancingFrontNode node ) {
// Console.WriteLine( "remove:" + node.key + ":" + System.identityHashCode(node.key));
// m_nodeTree.delete( node.getKey() );
Front.RemoveNode(node);
}
public AdvancingFrontNode LocateNode( TriangulationPoint point ) {
return Front.LocateNode(point);
}
public void CreateAdvancingFront() {
AdvancingFrontNode head, tail, middle;
// Initial triangle
DelaunayTriangle iTriangle = new DelaunayTriangle(Points[0], Tail, Head);
Triangles.Add(iTriangle);
head = new AdvancingFrontNode(iTriangle.Points[1]);
head.Triangle = iTriangle;
middle = new AdvancingFrontNode(iTriangle.Points[0]);
middle.Triangle = iTriangle;
tail = new AdvancingFrontNode(iTriangle.Points[2]);
Front = new AdvancingFront(head, tail);
Front.AddNode(middle);
// TODO: I think it would be more intuitive if head is middles next and not previous
// so swap head and tail
Front.Head.Next = middle;
middle.Next = Front.Tail;
middle.Prev = Front.Head;
Front.Tail.Prev = middle;
}
/// <summary>
/// Try to map a node to all sides of this triangle that don't have
/// a neighbor.
/// </summary>
public void MapTriangleToNodes( DelaunayTriangle t ) {
for (int i = 0; i < 3; i++)
if (t.Neighbors[i] == null)
{
AdvancingFrontNode n = Front.LocatePoint(t.PointCWFrom(t.Points[i]));
if (n != null) n.Triangle = t;
}
}
public override void PrepareTriangulation( Triangulatable t ) {
base.PrepareTriangulation(t);
double xmax, xmin;
double ymax, ymin;
xmax = xmin = Points[0].X;
ymax = ymin = Points[0].Y;
// Calculate bounds. Should be combined with the sorting
foreach (TriangulationPoint p in Points) {
if (p.X > xmax) xmax = p.X;
if (p.X < xmin) xmin = p.X;
if (p.Y > ymax) ymax = p.Y;
if (p.Y < ymin) ymin = p.Y;
}
double deltaX = ALPHA * (xmax - xmin);
double deltaY = ALPHA * (ymax - ymin);
TriangulationPoint p1 = new TriangulationPoint(xmax + deltaX, ymin - deltaY, -1);
TriangulationPoint p2 = new TriangulationPoint(xmin - deltaX, ymin - deltaY, -1);
Head = p1;
Tail = p2;
// long time = System.nanoTime();
// Sort the points along y-axis
Points.Sort(_comparator);
// logger.info( "Triangulation setup [{}ms]", ( System.nanoTime() - time ) / 1e6 );
}
public void FinalizeTriangulation() {
Triangulatable.AddTriangles(Triangles);
Triangles.Clear();
}
public override TriangulationConstraint NewConstraint( TriangulationPoint a, TriangulationPoint b ) {
return new DTSweepConstraint(a, b);
}
public override TriangulationAlgorithm Algorithm { get { return TriangulationAlgorithm.DTSweep; }}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a943be722733e6741978a775d47f8e2c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,62 @@
/* Poly2Tri
* Copyright (c) 2009-2010, Poly2Tri Contributors
* http://code.google.com/p/poly2tri/
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* * Neither the name of Poly2Tri nor the names of its contributors may be
* used to endorse or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
namespace UnityEngine.ProBuilder.Poly2Tri {
class DTSweepDebugContext : TriangulationDebugContext {
/*
* Fields used for visual representation of current triangulation
*/
public DelaunayTriangle PrimaryTriangle { get { return _primaryTriangle ; } set { _primaryTriangle = value; _tcx.Update("set PrimaryTriangle"); } }
public DelaunayTriangle SecondaryTriangle { get { return _secondaryTriangle; } set { _secondaryTriangle = value; _tcx.Update("set SecondaryTriangle"); } }
public TriangulationPoint ActivePoint { get { return _activePoint ; } set { _activePoint = value; _tcx.Update("set ActivePoint"); } }
public AdvancingFrontNode ActiveNode { get { return _activeNode ; } set { _activeNode = value; _tcx.Update("set ActiveNode"); } }
public DTSweepConstraint ActiveConstraint { get { return _activeConstraint ; } set { _activeConstraint = value; _tcx.Update("set ActiveConstraint"); } }
public DTSweepDebugContext( DTSweepContext tcx ) : base(tcx) { }
public bool IsDebugContext { get { return true; } }
public override void Clear() {
PrimaryTriangle = null;
SecondaryTriangle = null;
ActivePoint = null;
ActiveNode = null;
ActiveConstraint = null;
}
private DelaunayTriangle _primaryTriangle;
private DelaunayTriangle _secondaryTriangle;
private TriangulationPoint _activePoint;
private AdvancingFrontNode _activeNode;
private DTSweepConstraint _activeConstraint;
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: fe5e031b8d5fd9d43b054ae08c843652
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,40 @@
/* Poly2Tri
* Copyright (c) 2009-2010, Poly2Tri Contributors
* http://code.google.com/p/poly2tri/
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* * Neither the name of Poly2Tri nor the names of its contributors may be
* used to endorse or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/// Changes from the Java version
/// Turned DTSweepEdgeEvent into a value type
namespace UnityEngine.ProBuilder.Poly2Tri {
class DTSweepEdgeEvent {
public DTSweepConstraint ConstrainedEdge;
public bool Right;
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9c90a3667d9b2154bb538feb303989f8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,52 @@
/* Poly2Tri
* Copyright (c) 2009-2010, Poly2Tri Contributors
* http://code.google.com/p/poly2tri/
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* * Neither the name of Poly2Tri nor the names of its contributors may be
* used to endorse or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System.Collections.Generic;
namespace UnityEngine.ProBuilder.Poly2Tri {
class DTSweepPointComparator : IComparer<TriangulationPoint> {
public int Compare(TriangulationPoint p1, TriangulationPoint p2) {
if (p1.Y < p2.Y) {
return -1;
} else if (p1.Y > p2.Y) {
return 1;
} else {
if (p1.X < p2.X) {
return -1;
} else if (p1.X > p2.X) {
return 1;
} else {
return 0;
}
}
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 881b617b0cb15574f93592b7b6a3e373
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,46 @@
/* Poly2Tri
* Copyright (c) 2009-2010, Poly2Tri Contributors
* http://code.google.com/p/poly2tri/
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* * Neither the name of Poly2Tri nor the names of its contributors may be
* used to endorse or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
namespace UnityEngine.ProBuilder.Poly2Tri {
class PointOnEdgeException : NotImplementedException {
public readonly TriangulationPoint A,B,C;
public PointOnEdgeException( string message, TriangulationPoint a, TriangulationPoint b, TriangulationPoint c )
: base(message)
{
A=a;
B=b;
C=c;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 659601bba69c8e747bcc79ca9e877a2f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,47 @@
/* Poly2Tri
* Copyright (c) 2009-2010, Poly2Tri Contributors
* http://code.google.com/p/poly2tri/
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* * Neither the name of Poly2Tri nor the names of its contributors may be
* used to endorse or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System.Collections.Generic;
namespace UnityEngine.ProBuilder.Poly2Tri {
interface Triangulatable {
void Prepare(TriangulationContext tcx);
IList<TriangulationPoint> Points { get; } // MM: Neither of these are used via interface (yet?)
IList<DelaunayTriangle> Triangles { get; }
void AddTriangle(DelaunayTriangle t);
void AddTriangles(IEnumerable<DelaunayTriangle> list);
void ClearTriangles();
TriangulationMode TriangulationMode { get; }
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3d263593a085cdf469778e9ea07ba483
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,36 @@
/* Poly2Tri
* Copyright (c) 2009-2010, Poly2Tri Contributors
* http://code.google.com/p/poly2tri/
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* * Neither the name of Poly2Tri nor the names of its contributors may be
* used to endorse or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
namespace UnityEngine.ProBuilder.Poly2Tri {
enum Orientation {
CW, CCW, Collinear
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6e4871d32a3aac4448c0c3f9e182f972
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 9f85da24fbeceaa4e96e6881fe6fac37
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,61 @@
/* Poly2Tri
* Copyright (c) 2009-2010, Poly2Tri Contributors
* http://code.google.com/p/poly2tri/
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* * Neither the name of Poly2Tri nor the names of its contributors may be
* used to endorse or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System.Collections.Generic;
namespace UnityEngine.ProBuilder.Poly2Tri {
/*
* Extends the PointSet by adding some Constraints on how it will be triangulated<br>
* A constraint defines an edge between two points in the set, these edges can not
* be crossed. They will be enforced triangle edges after a triangulation.
* <p>
*
*
* @author Thomas Åhlén, [email protected]
*/
class ConstrainedPointSet : PointSet {
public int[] EdgeIndex { get; private set; }
public ConstrainedPointSet(List<TriangulationPoint> points, int[] index)
: base(points) {
EdgeIndex = index;
}
public override TriangulationMode TriangulationMode { get { return TriangulationMode.Constrained; } }
public override void Prepare(TriangulationContext tcx) {
base.Prepare(tcx);
for (int i = 0; i < EdgeIndex.Length; i += 2) {
// XXX: must change!!
tcx.NewConstraint(Points[EdgeIndex[i]], Points[EdgeIndex[i + 1]]);
}
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 92edb19c798910a47b4dec2660fcd96d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,66 @@
/* Poly2Tri
* Copyright (c) 2009-2010, Poly2Tri Contributors
* http://code.google.com/p/poly2tri/
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* * Neither the name of Poly2Tri nor the names of its contributors may be
* used to endorse or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System.Collections.Generic;
namespace UnityEngine.ProBuilder.Poly2Tri {
class PointSet : Triangulatable {
public IList<TriangulationPoint> Points { get; private set; }
public IList<DelaunayTriangle> Triangles { get; private set; }
public PointSet(List<TriangulationPoint> points) {
Points = new List<TriangulationPoint>(points);
}
public virtual TriangulationMode TriangulationMode { get { return TriangulationMode.Unconstrained; }}
public void AddTriangle(DelaunayTriangle t) {
Triangles.Add(t);
}
public void AddTriangles(IEnumerable<DelaunayTriangle> list) {
foreach ( var tri in list ) Triangles.Add(tri);
}
public void ClearTriangles() {
Triangles.Clear();
}
public virtual void Prepare(TriangulationContext tcx) {
if (Triangles == null) {
Triangles = new List<DelaunayTriangle>(Points.Count);
} else {
Triangles.Clear();
}
tcx.Points.AddRange(Points);
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 906ae4b0ce907194cb4d1d255e03675b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,36 @@
/* Poly2Tri
* Copyright (c) 2009-2010, Poly2Tri Contributors
* http://code.google.com/p/poly2tri/
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* * Neither the name of Poly2Tri nor the names of its contributors may be
* used to endorse or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
namespace UnityEngine.ProBuilder.Poly2Tri {
enum TriangulationAlgorithm {
DTSweep
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c5b66ff70e896a64ebe5aa9cb28dd535
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,44 @@
/* Poly2Tri
* Copyright (c) 2009-2010, Poly2Tri Contributors
* http://code.google.com/p/poly2tri/
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* * Neither the name of Poly2Tri nor the names of its contributors may be
* used to endorse or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* Forces a triangle edge between two points p and q
* when triangulating. For example used to enforce
* Polygon Edges during a polygon triangulation.
*
* @author Thomas Åhlén, [email protected]
*/
namespace UnityEngine.ProBuilder.Poly2Tri {
class TriangulationConstraint {
public TriangulationPoint P;
public TriangulationPoint Q;
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d42d456e720b1c5438d87059c69284bd
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,71 @@
/* Poly2Tri
* Copyright (c) 2009-2010, Poly2Tri Contributors
* http://code.google.com/p/poly2tri/
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* * Neither the name of Poly2Tri nor the names of its contributors may be
* used to endorse or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System.Collections.Generic;
namespace UnityEngine.ProBuilder.Poly2Tri {
abstract class TriangulationContext {
public TriangulationDebugContext DebugContext { get; protected set; }
public readonly List<DelaunayTriangle> Triangles = new List<DelaunayTriangle>();
public readonly List<TriangulationPoint> Points = new List<TriangulationPoint>();
public TriangulationMode TriangulationMode { get; protected set; }
public Triangulatable Triangulatable { get; private set; }
public int StepCount { get; private set; }
public void Done() {
StepCount++;
}
public abstract TriangulationAlgorithm Algorithm { get; }
public virtual void PrepareTriangulation(Triangulatable t) {
Triangulatable = t;
TriangulationMode = t.TriangulationMode;
t.Prepare(this);
}
public abstract TriangulationConstraint NewConstraint(TriangulationPoint a, TriangulationPoint b);
public void Update(string message) {}
public virtual void Clear() {
Points.Clear();
if (DebugContext != null) DebugContext.Clear();
StepCount = 0;
}
public virtual bool IsDebugEnabled { get; protected set; }
public DTSweepDebugContext DTDebugContext { get { return DebugContext as DTSweepDebugContext; } }
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 848eabc153ab891409f3d562463a0efe
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,42 @@
/* Poly2Tri
* Copyright (c) 2009-2010, Poly2Tri Contributors
* http://code.google.com/p/poly2tri/
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* * Neither the name of Poly2Tri nor the names of its contributors may be
* used to endorse or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
namespace UnityEngine.ProBuilder.Poly2Tri {
abstract class TriangulationDebugContext {
protected TriangulationContext _tcx;
public TriangulationDebugContext(TriangulationContext tcx) {
_tcx = tcx;
}
public abstract void Clear();
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6ccb8b5f00388f545b4b986d5149d926
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,36 @@
/* Poly2Tri
* Copyright (c) 2009-2010, Poly2Tri Contributors
* http://code.google.com/p/poly2tri/
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* * Neither the name of Poly2Tri nor the names of its contributors may be
* used to endorse or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
namespace UnityEngine.ProBuilder.Poly2Tri {
enum TriangulationMode {
Unconstrained,Constrained,Polygon
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 319d9808ed35cae4ca212b4b97a9ee0b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,65 @@
/* Poly2Tri
* Copyright (c) 2009-2010, Poly2Tri Contributors
* http://code.google.com/p/poly2tri/
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* * Neither the name of Poly2Tri nor the names of its contributors may be
* used to endorse or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System.Collections.Generic;
namespace UnityEngine.ProBuilder.Poly2Tri {
class TriangulationPoint {
// This point was an inserted index.
public const int INSERTED_INDEX = -1;
// This point is not a valid index.
public const int INVALID_INDEX = -2;
// List of edges this point constitutes an upper ending point (CDT)
public List<DTSweepConstraint> Edges { get; private set; }
public TriangulationPoint( double x, double y, int index = INSERTED_INDEX) { X=x; Y=y; Index = index; }
public override string ToString() {
return "[" + X + "," + Y + "]";
}
public double X,Y;
public int Index;
public float Xf { get { return (float)X; } set { X=value; } }
public float Yf { get { return (float)Y; } set { Y=value; } }
public void AddEdge(DTSweepConstraint e) {
if (Edges == null) Edges = new List<DTSweepConstraint>();
Edges.Add(e);
}
public bool HasEdges { get { return Edges != null; } }
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 267c7f09b45427d4596b29d4c39055fa
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,154 @@
/* Poly2Tri
* Copyright (c) 2009-2010, Poly2Tri Contributors
* http://code.google.com/p/poly2tri/
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* * Neither the name of Poly2Tri nor the names of its contributors may be
* used to endorse or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
namespace UnityEngine.ProBuilder.Poly2Tri {
/**
* @author Thomas Åhlén, [email protected]
*/
class TriangulationUtil {
public static double EPSILON = 1e-12;
#if UNITY_EDITOR
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
static void ResetStaticsOnLoad()
{
EPSILON = 1e-12;
}
#endif
/// <summary>
/// Requirements:
/// 1. a,b and c form a triangle.
/// 2. a and d is know to be on opposite side of bc
/// <code>
/// a
/// +
/// / \
/// / \
/// b/ \c
/// +-------+
/// / B \
/// / \
/// </code>
/// Facts:
/// d has to be in area B to have a chance to be inside the circle formed by a,b and c
/// d is outside B if orient2d(a,b,d) or orient2d(c,a,d) is CW
/// This preknowledge gives us a way to optimize the incircle test
/// </summary>
/// <param name="pa">triangle point, opposite d</param>
/// <param name="pb">triangle point</param>
/// <param name="pc">triangle point</param>
/// <param name="pd">point opposite a</param>
/// <returns>true if d is inside circle, false if on circle edge</returns>
public static bool SmartIncircle(TriangulationPoint pa, TriangulationPoint pb, TriangulationPoint pc, TriangulationPoint pd)
{
double pdx = pd.X;
double pdy = pd.Y;
double adx = pa.X - pdx;
double ady = pa.Y - pdy;
double bdx = pb.X - pdx;
double bdy = pb.Y - pdy;
double adxbdy = adx * bdy;
double bdxady = bdx * ady;
double oabd = adxbdy - bdxady;
// oabd = orient2d(pa,pb,pd);
if (oabd <= 0) return false;
double cdx = pc.X - pdx;
double cdy = pc.Y - pdy;
double cdxady = cdx * ady;
double adxcdy = adx * cdy;
double ocad = cdxady - adxcdy;
// ocad = orient2d(pc,pa,pd);
if (ocad <= 0) return false;
double bdxcdy = bdx * cdy;
double cdxbdy = cdx * bdy;
double alift = adx * adx + ady * ady;
double blift = bdx * bdx + bdy * bdy;
double clift = cdx * cdx + cdy * cdy;
double det = alift * (bdxcdy - cdxbdy) + blift * ocad + clift * oabd;
return det > 0;
}
public static bool InScanArea( TriangulationPoint pa, TriangulationPoint pb, TriangulationPoint pc, TriangulationPoint pd ) {
double pdx = pd.X;
double pdy = pd.Y;
double adx = pa.X - pdx;
double ady = pa.Y - pdy;
double bdx = pb.X - pdx;
double bdy = pb.Y - pdy;
double adxbdy = adx * bdy;
double bdxady = bdx * ady;
double oabd = adxbdy - bdxady;
// oabd = orient2d(pa,pb,pd);
if (oabd <= 0) {
return false;
}
double cdx = pc.X - pdx;
double cdy = pc.Y - pdy;
double cdxady = cdx * ady;
double adxcdy = adx * cdy;
double ocad = cdxady - adxcdy;
// ocad = orient2d(pc,pa,pd);
if (ocad <= 0) {
return false;
}
return true;
}
/// Forumla to calculate signed area
/// Positive if CCW
/// Negative if CW
/// 0 if collinear
/// A[P1,P2,P3] = (x1*y2 - y1*x2) + (x2*y3 - y2*x3) + (x3*y1 - y3*x1)
/// = (x1-x3)*(y2-y3) - (y1-y3)*(x2-x3)
public static Orientation Orient2d( TriangulationPoint pa, TriangulationPoint pb, TriangulationPoint pc ) {
double detleft = (pa.X - pc.X) * (pb.Y - pc.Y);
double detright = (pa.Y - pc.Y) * (pb.X - pc.X);
double val = detleft - detright;
if (val > -EPSILON && val < EPSILON) {
return Orientation.Collinear;
} else if (val > 0) {
return Orientation.CCW;
}
return Orientation.CW;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: bedfc9d5ebff70f4896001f60a9b2790
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: b46e64067adbbe341bf0afb1ee309299
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,58 @@
/* Poly2Tri
* Copyright (c) 2009-2010, Poly2Tri Contributors
* http://code.google.com/p/poly2tri/
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* * Neither the name of Poly2Tri nor the names of its contributors may be
* used to endorse or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections.Generic;
namespace UnityEngine.ProBuilder.Poly2Tri {
class PointGenerator {
static readonly System.Random RNG = new System.Random();
public static List<TriangulationPoint> UniformDistribution(int n, double scale) {
List<TriangulationPoint> points = new List<TriangulationPoint>();
for (int i = 0; i < n; i++) points.Add(new TriangulationPoint(scale * (0.5 - RNG.NextDouble()), scale * (0.5 - RNG.NextDouble()), i));
return points;
}
public static List<TriangulationPoint> UniformGrid(int n, double scale) {
double x = 0;
double size = scale / n;
double halfScale = 0.5 * scale;
List<TriangulationPoint> points = new List<TriangulationPoint>();
for (int i = 0; i < n + 1; i++) {
x = halfScale - i * size;
for (int j = 0; j < n + 1; j++) points.Add(new TriangulationPoint(x, halfScale - j * size, i));
}
return points;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5e41f6d30b7fa6543a40193098cf4eae
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,99 @@
/* Poly2Tri
* Copyright (c) 2009-2010, Poly2Tri Contributors
* http://code.google.com/p/poly2tri/
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* * Neither the name of Poly2Tri nor the names of its contributors may be
* used to endorse or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
namespace UnityEngine.ProBuilder.Poly2Tri {
class PolygonGenerator {
static readonly System.Random RNG = new System.Random();
private static double PI_2 = 2.0 * Math.PI;
#if UNITY_EDITOR
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
static void ResetStaticsOnLoad()
{
PI_2 = 2.0 * Math.PI;
}
#endif
public static Polygon RandomCircleSweep(double scale, int vertexCount)
{
PolygonPoint point;
PolygonPoint[] points;
double radius = scale / 4;
points = new PolygonPoint[vertexCount];
for (int i = 0; i < vertexCount; i++)
{
do
{
if (i % 250 == 0)
{
radius += scale / 2 * (0.5 - RNG.NextDouble());
}
else if (i % 50 == 0)
{
radius += scale / 5 * (0.5 - RNG.NextDouble());
}
else
{
radius += 25 * scale / vertexCount * (0.5 - RNG.NextDouble());
}
radius = radius > scale / 2 ? scale / 2 : radius;
radius = radius < scale / 10 ? scale / 10 : radius;
} while (radius < scale / 10 || radius > scale / 2);
point = new PolygonPoint(radius * Math.Cos((PI_2 * i) / vertexCount),
radius * Math.Sin((PI_2 * i) / vertexCount), i);
points[i] = point;
}
return new Polygon(points);
}
public static Polygon RandomCircleSweep2(double scale, int vertexCount) {
PolygonPoint point;
PolygonPoint[] points;
double radius = scale / 4;
points = new PolygonPoint[vertexCount];
for (int i = 0; i < vertexCount; i++) {
do {
radius += scale / 5 * (0.5 - RNG.NextDouble());
radius = radius > scale / 2 ? scale / 2 : radius;
radius = radius < scale / 10 ? scale / 10 : radius;
} while (radius < scale / 10 || radius > scale / 2);
point = new PolygonPoint(radius * Math.Cos((PI_2 * i) / vertexCount),
radius * Math.Sin((PI_2 * i) / vertexCount), i);
points[i] = point;
}
return new Polygon(points);
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9652f5ea32e3966499300efa0597ba92
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: