public SpatialHash(Bounds worldBounds, float3 cellSize, int startSize, Allocator label) { #if ENABLE_UNITY_COLLECTIONS_CHECKS DisposeSentinel.Create(out _safety, out _disposeSentinel, 0, label); #endif _allocatorLabel = label; _data = (SpatialHashData *)UnsafeUtility.Malloc(sizeof(SpatialHashData), UnsafeUtility.AlignOf <SpatialHashData>(), label); _data->WorldBounds = worldBounds; _data->WorldBoundsMin = worldBounds.Min; _data->CellSize = cellSize; _data->CellCount = worldBounds.GetCellCount(cellSize); _data->RayCastBound = new Bounds(); _data->HasHit = false; _data->Counter = 0; _data->RayOrigin = float3.zero; _data->RayDirection = float3.zero; _buckets = new NativeMultiHashMap <uint, int>(startSize, label); _itemIDToBounds = new NativeHashMap <int, Bounds>(startSize >> 1, label); _itemIDToItem = new NativeHashMap <int, T>(startSize >> 1, label); _helpMoveHashMapOld = new NativeHashMap <int3, byte>(128, _allocatorLabel); _helpMoveHashMapNew = new NativeHashMap <int3, byte>(128, _allocatorLabel); _voxelRay = new VoxelRay <SpatialHash <T> >(); _rayHitValue = 0; }
public SpatialHash(Bounds worldBounds, float3 cellSize, Allocator label) : this(worldBounds, cellSize, worldBounds.GetCellCount(cellSize).Mul() * 3, label) { }