123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- using UnityEngine;
- using System.Collections.Generic;
- namespace Pathfinding.Voxels {
- using Pathfinding.Util;
-
- public class Utility {
- public static float Min (float a, float b, float c) {
- a = a < b ? a : b;
- return a < c ? a : c;
- }
- public static float Max (float a, float b, float c) {
- a = a > b ? a : b;
- return a > c ? a : c;
- }
-
-
-
-
- public static Int3[] RemoveDuplicateVertices (Int3[] vertices, int[] triangles) {
-
- var firstVerts = ObjectPoolSimple<Dictionary<Int3, int> >.Claim();
- firstVerts.Clear();
-
- var compressedPointers = new int[vertices.Length];
- int count = 0;
- for (int i = 0; i < vertices.Length; i++) {
- if (!firstVerts.ContainsKey(vertices[i])) {
- firstVerts.Add(vertices[i], count);
- compressedPointers[i] = count;
- vertices[count] = vertices[i];
- count++;
- } else {
-
- compressedPointers[i] = firstVerts[vertices[i]];
- }
- }
- firstVerts.Clear();
- ObjectPoolSimple<Dictionary<Int3, int> >.Release(ref firstVerts);
- for (int i = 0; i < triangles.Length; i++) {
- triangles[i] = compressedPointers[triangles[i]];
- }
- var compressed = new Int3[count];
- for (int i = 0; i < count; i++) compressed[i] = vertices[i];
- return compressed;
- }
- }
- }
|