internal void Allocate(NavmeshComponent component) { Assert.IsTrue(math.all(component.Size > 0)); Assert.IsTrue(component.ExpectedVerts > 0); Max = component.Size / 2; _e = component.MergePointsDistance; _collinearMargin = component.CollinearMargin; _vertices = new PersistentStore <Vertex>(component.ExpectedVerts, Allocator.Persistent); _verticesSeq = new UnsafeList <IntPtr>(component.ExpectedVerts, Allocator.Persistent); _quadEdges = new PersistentStore <QuadEdge>(3 * component.ExpectedVerts, Allocator.Persistent); _constraints = new UnsafeHashMap <Entity, IntPtr>(component.ExpectedVerts, Allocator.Persistent); V = new HashSet <IntPtr>(16, Allocator.Persistent); C = new HashSet <IntPtr>(16, Allocator.Persistent); _edgeSearch = new EdgeSearch(100, 100, Allocator.Persistent); _qt = new QuadTree(math.max(component.Size.x, component.Size.y), 100, 10, Allocator.Persistent); _flipStack = new PtrStack <Edge>(32, Allocator.Persistent); _insertedPoints = new UnsafeList <Point>(64, Allocator.Persistent); _open = new PtrStack <Vertex>(64, Allocator.Persistent); _vlist = new UnsafeList <IntPtr>(64, Allocator.Persistent); _elist = new UnsafeList <IntPtr>(64, Allocator.Persistent); _creps = new Stack <UnsafeList>(2 * component.ExpectedVerts, Allocator.Persistent); for (int i = 0; i < 2 * component.ExpectedVerts; i++) { _creps.Push(new UnsafeList(UnsafeUtility.SizeOf <int>(), UnsafeUtility.AlignOf <int>(), CrepMinCapacity, Allocator.Persistent)); } DestroyedTriangles = new HashSet <int>(64, Allocator.Persistent); _refinementQueue = new Deque <IntPtr>(24, Allocator.Persistent); BuildBoundingBoxes(); }
internal Navmesh(NavmeshComponent component) { Assert.IsTrue(math.all(component.Size > 0)); Assert.IsTrue(component.ExpectedVerts > 0); Extent = component.Size / 2; _e = component.MergePointsDistance; _collinearMargin = component.CollinearMargin; const int blockSize = 128; var initialBlocks = (int)math.ceil((float)component.ExpectedVerts / blockSize); _vertices = new BlockPool <Vertex>(blockSize, initialBlocks, Allocator.Persistent); _verticesSeq = new UnsafeList <IntPtr>(component.ExpectedVerts, Allocator.Persistent); _quadEdges = new BlockPool <QuadEdge>(3 * blockSize, initialBlocks, Allocator.Persistent); _constraints = new UnsafeHashMap <Entity, IntPtr>(component.ExpectedVerts, Allocator.Persistent); V = new HashSet <IntPtr>(16, Allocator.Persistent); C = new HashSet <IntPtr>(16, Allocator.Persistent); _edgeSearch = new EdgeSearch(100, 100, Allocator.Persistent); _qt = new QuadTree(math.max(component.Size.x, component.Size.y), 100, 10, Allocator.Persistent); _flipStack = new PtrStack <Edge>(32, Allocator.Persistent); _insertedPoints = new UnsafeList <Point>(64, Allocator.Persistent); _open = new PtrStack <Vertex>(64, Allocator.Persistent); _vlist = new UnsafeList <IntPtr>(64, Allocator.Persistent); _elist = new UnsafeList <IntPtr>(64, Allocator.Persistent); _creps = new Stack <UnsafeList <Entity> >(2 * component.ExpectedVerts, Allocator.Persistent); for (int i = 0; i < 2 * component.ExpectedVerts; i++) { _creps.Push(new UnsafeList <Entity>(CrepMinCapacity, Allocator.Persistent)); } DestroyedTriangles = new HashSet <int>(64, Allocator.Persistent); _refinementQueue = new Deque <IntPtr>(24, Allocator.Persistent); _mark = default; _edgeId = default; _triangleId = default; BuildBoundingBoxes(); }