private static void SetVoxelIndexForBounds <TY>(SpatialHashData *data, Bounds bounds, NativeHashMap <int3, TY> collection) where TY : struct { CalculStartEndIterationInternal(data, bounds, out var start, out var end); var position = new int3(0F); for (int x = start.x; x < end.x; ++x) { position.x = x; for (int y = start.y; y < end.y; ++y) { position.y = y; for (int z = start.z; z < end.z; ++z) { position.z = z; collection.TryAdd(position, default(TY)); } } } }
private static void CalculStartEndIterationInternal(SpatialHashData *data, Bounds bounds, out int3 start, out int3 end) { start = ((bounds.Min - data->WorldBoundsMin) / data->CellSize).FloorToInt(); end = ((bounds.Max - data->WorldBoundsMin) / data->CellSize).CeilToInt(); }