Exemplo n.º 1
0
        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));
                    }
                }
            }
        }
Exemplo n.º 2
0
 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();
 }