Voxel QueryCreateVoxel(int x, int y, int z) { int hashKey = GetHashKey(x, y, z); Voxel v = voxelStorage.Query(hashKey); if (v == null) { v = InitializeVoxel(x, y, z, cellSize, initialVoxelValue, 0); voxelStorage.Insert(v, hashKey); } return(v); }
public void Insert(Voxel voxel, int hashkey) { if (key == -1) { key = hashkey; this.voxel = voxel; return; } if (hashkey == key) { this.voxel = voxel; return; } if (hashkey < key) { if (leftTree == null) { leftTree = new VoxelTree(); leftTree.key = hashkey; leftTree.voxel = voxel; leftTree.parent = this; } else { leftTree.Insert(voxel, hashkey); } } else { if (rightTree == null) { rightTree = new VoxelTree(); rightTree.key = hashkey; rightTree.voxel = voxel; rightTree.parent = this; } else { rightTree.Insert(voxel, hashkey); } } }