public List <PolygroupModifier> AdvancedSubtractPolygroup(PolygroupModifier subjectPolygroup, List <Vector2> clippingPolygon) { // The polygons to keep from the subject polygroup, by index List <int> keptIndices = new List <int>(); // The new triangles added from the triangulated clipped polygons List <List <Vector2> > newTriangles = new List <List <Vector2> >(); foreach (int i in subjectPolygroup.keptIndices) { List <Vector2> originalPolygon = subjectPolygroup.originalPolygroup[i]; if (SubtractInternal(originalPolygon, clippingPolygon, out List <DTPolygon> subOutput)) { DTProfilerMarkers.Triangulation.Begin(); List <List <Vector2> > triangles = DTUtility.TriangulateAll(subOutput, TriangleNetTriangulator.Instance); DTProfilerMarkers.Triangulation.End(); newTriangles.AddRange(triangles); } else { keptIndices.Add(i); } } return(Polygrouper.AdvancedCreatePolygroups(subjectPolygroup.originalPolygroup, keptIndices, newTriangles)); }
public override void ApplyPolygonList(List <DTPolygon> clippedPolygonList) { // The clipped polygons could potentially be concave or have holes, so we will triangulate each one before applying DTProfilerMarkers.Triangulation.Begin(); dtPolygroup = DTUtility.TriangulateAll(clippedPolygonList, GetTriangulator()); DTProfilerMarkers.Triangulation.End(); // Collider from polygon DTProfilerMarkers.ApplyCollider.Begin(); ApplyCollider(dtPolygroup); DTProfilerMarkers.ApplyCollider.End(); // Create mesh from triangulated polygon ApplyRenderMesh(dtPolygroup.ToMesh()); }
public override void ApplyPolygonList(List <DTPolygon> clippedPolygonList) { // The clipped polygons could potentially be concave or have holes, so we will triangulate each one before applying DTProfilerMarkers.Triangulation.Begin(); DTConvexPolygroup triangulatedPolygroup = DTUtility.TriangulateAll(clippedPolygonList, GetTriangulator()); DTProfilerMarkers.Triangulation.End(); // Collider from polygon DTProfilerMarkers.HertelMehlhorn.Begin(); hmPolygroup = HertelMehlhorn.PolyPartitionHM.Instance.ExecuteToPolygroup(triangulatedPolygroup); DTProfilerMarkers.HertelMehlhorn.End(); // Collider from polygon DTProfilerMarkers.ApplyCollider.Begin(); ApplyCollider(hmPolygroup); DTProfilerMarkers.ApplyCollider.End(); // Create mesh from triangulated polygon ApplyRenderMesh(triangulatedPolygroup.ToMesh()); }
public override void ApplyPolygonList(List <DTPolygon> clippedPolygonList) { // The clipped polygons could potentially be concave or have holes, so we will triangulate each one before applying DTProfilerMarkers.Triangulation.Begin(); DTConvexPolygroup triangleList = DTUtility.TriangulateAll(clippedPolygonList, GetTriangulator()); DTProfilerMarkers.Triangulation.End(); // Our Hertel-Mehlhorn implementation takes a DTMesh, so convert before instead of after DTMesh triangulatedMesh = triangleList.ToMesh(); // Collider from polygon DTProfilerMarkers.HertelMehlhorn.Begin(); hmMesh = HertelMehlhorn.CustomHM.Instance.ExecuteToMesh(triangulatedMesh); DTProfilerMarkers.HertelMehlhorn.End(); // Collider from polygon DTProfilerMarkers.ApplyCollider.Begin(); ApplyCollider(hmMesh); DTProfilerMarkers.ApplyCollider.End(); // Create mesh from triangulated polygon ApplyRenderMesh(triangulatedMesh); }
public override void ApplyPolygonList(List <DTPolygon> clippedPolygonList) { DTConvexPolygroup triangles = DTUtility.TriangulateAll(clippedPolygonList, GetTriangulator()); ApplyPolygroupModifier(new PolygroupModifier(null, null, triangles)); }