public Voxel(Vector3Int index, Grid3d grid) { _grid = grid; Index = index; Center = grid.Corner + new Vector3(index.x + 0.5f, index.y + 0.5f, index.z + 0.5f) * grid.VoxelSize; IsActive = true; }
public Voxel(Voxel voxel) { _grid = voxel._grid; Index = voxel.Index; Center = voxel.Center; IsActive = voxel.IsActive; _grid.Voxels[Index.x, Index.y, Index.z] = this; }
public Edge(int x, int y, int z, Axis direction, Grid3d grid) { _grid = grid; Index = new Vector3Int(x, y, z); Direction = direction; Center = GetCenter(); Voxels = GetVoxels(); Faces = GetFaces(); }
public Face(int x, int y, int z, Axis direction, Grid3d grid) { _grid = grid; Index = new Vector3Int(x, y, z); Direction = direction; Voxels = GetVoxels(); foreach (var v in Voxels.Where(v => v != null)) { v.Faces.Add(this); } Center = GetCenter(); }
// public Mesh[] Mesh; public static Grid3d MakeGridWithVoids(IEnumerable <MeshCollider> voids, float voxelSize, bool invert = false) { var bbox = new Bounds(); foreach (var v in voids.Select(v => v.bounds)) { bbox.Encapsulate(v); } var grid = new Grid3d(bbox, voxelSize); grid.AddVoids(voids, invert); return(grid); }
public void PutObject(Grid3d item) { _objects.Add(item); }
public Grid3dPool(Grid3d grid) { _objects = new ConcurrentBag <Grid3d>(); _grid = grid; }
public Corner(Vector3Int index, Grid3d grid) { _grid = grid; Index = index; Position = grid.Corner + new Vector3(index.x, index.y, index.z) * grid.VoxelSize; }