public static void Destroy(UnsafeNodesList *listData) { var allocator = listData->allocator; listData->Dispose(); AllocatorManager.Free(allocator, listData); }
public void Dispose() { UnsafeNodesList.Destroy(nodesList); nodesList = null; insertionHeap.Dispose(); rootIndex.Dispose(); }
public NativeBVHTree(int initialCapacity = 64, Allocator allocator = Allocator.Temp, Configuration config = default) : this() { nodesList = UnsafeNodesList.Create(initialCapacity, allocator, NativeArrayOptions.ClearMemory); rootIndex = new NativeArray <int>(1, allocator); // Create invalid node (at index 0) AllocInternalNode(); this.config = config; }
public static UnsafeNodesList *Create(int length, Allocator allocator, NativeArrayOptions options = NativeArrayOptions.UninitializedMemory) { var handle = new AllocatorManager.AllocatorHandle { Value = (int)allocator }; UnsafeNodesList *listData = AllocatorManager.Allocate <UnsafeNodesList>(handle); UnsafeUtility.MemClear(listData, UnsafeUtility.SizeOf <UnsafeNodesList>()); listData->allocator = allocator; listData->emptyIndices = UnsafeList.Create(UnsafeUtility.SizeOf <int>(), UnsafeUtility.AlignOf <int>(), length, allocator); if (length != 0) { listData->Resize(length); } if (options == NativeArrayOptions.ClearMemory && listData->ptr != null) { UnsafeUtility.MemClear(listData->ptr, listData->length * UnsafeUtility.SizeOf <int>()); } return(listData); }