From 7780a5439a0ec529dc5fd85b42448da493dff6cd Mon Sep 17 00:00:00 2001 From: andywiecko Date: Mon, 16 Oct 2023 17:03:19 +0200 Subject: [PATCH] refactor: remove edges to triangles mapping --- Runtime/Triangulator.cs | 35 +---------------------------------- 1 file changed, 1 insertion(+), 34 deletions(-) diff --git a/Runtime/Triangulator.cs b/Runtime/Triangulator.cs index a57de58..6fe0dda 100644 --- a/Runtime/Triangulator.cs +++ b/Runtime/Triangulator.cs @@ -193,7 +193,6 @@ public class OutputData private NativeList triangles; private NativeList halfedges; private NativeList circles; - private NativeHashMap> edgesToTriangles; private NativeList constraintEdges; private NativeReference status; @@ -217,7 +216,6 @@ public Triangulator(int capacity, Allocator allocator) triangles = new(capacity, allocator); halfedges = new(6 * capacity, allocator); circles = new(capacity, allocator); - edgesToTriangles = new(capacity, allocator); constraintEdges = new(capacity, allocator); status = new(Status.OK, allocator); @@ -242,7 +240,6 @@ public void Dispose() triangles.Dispose(); halfedges.Dispose(); circles.Dispose(); - edgesToTriangles.Dispose(); constraintEdges.Dispose(); status.Dispose(); @@ -717,7 +714,6 @@ private struct ClearDataJob : IJob private NativeList triangles; private NativeList halfedges; private NativeList circles; - private NativeHashMap> edgesToTriangles; private NativeList constraintEdges; private NativeList pointsToRemove; private NativeList pointsOffset; @@ -730,7 +726,6 @@ public ClearDataJob(Triangulator triangulator) triangles = triangulator.triangles; halfedges = triangulator.halfedges; circles = triangulator.circles; - edgesToTriangles = triangulator.edgesToTriangles; constraintEdges = triangulator.constraintEdges; pointsToRemove = triangulator.pointsToRemove; pointsOffset = triangulator.pointsOffset; @@ -748,7 +743,6 @@ public void Execute() triangles.Clear(); halfedges.Clear(); circles.Clear(); - edgesToTriangles.Clear(); constraintEdges.Clear(); pointsToRemove.Clear(); @@ -1160,14 +1154,12 @@ private struct RecalculateTriangleMappingsJob : IJob { [ReadOnly] private NativeArray triangles; - private NativeHashMap> edgesToTriangles; private NativeList circles; private NativeList positions; public RecalculateTriangleMappingsJob(Triangulator triangulator) { triangles = triangulator.triangles.AsDeferredJobArray(); - edgesToTriangles = triangulator.edgesToTriangles; circles = triangulator.circles; positions = triangulator.outputPositions; } @@ -1175,34 +1167,9 @@ public RecalculateTriangleMappingsJob(Triangulator triangulator) public void Execute() { circles.Length = triangles.Length; - edgesToTriangles.Clear(); for (int i = 0; i < triangles.Length; i++) { - Execute(i); - } - } - - private void Execute(int t) - { - var (i, j, k) = triangles[t]; - - circles[t] = CalculateCircumCircle((i, j, k), positions.AsArray()); - - RegisterEdgeData((i, j), t); - RegisterEdgeData((j, k), t); - RegisterEdgeData((k, i), t); - } - - private void RegisterEdgeData(Edge edge, int triangleId) - { - if (edgesToTriangles.TryGetValue(edge, out var tris)) - { - tris.Add(triangleId); - edgesToTriangles[edge] = tris; - } - else - { - edgesToTriangles.Add(edge, new() { triangleId }); + circles[i] = CalculateCircumCircle(triangles[i], positions.AsArray()); } } }