public void RemoveBlockFromOctree(Vector3 localPosition, Octant octant) { if (!octant.IsLeaf()) { this.RemoveBlockFromOctree(localPosition, octant.Octants [this.GetIndexOfPosition(localPosition, octant.Position)]); } else { } octant.objectCount--; }
void DrawNode(Octant node, int nodeDepth = 0) { if (!node.IsLeaf()) { for (int i = 0; i < 8; i++) { DrawNode(node.Octants [i], nodeDepth + 1); } } //if (!node.IsEmpty ()) { Gizmos.color = Color.Lerp(minColor, maxColor, nodeDepth / (float)4); Gizmos.DrawWireCube(node.Position, Vector3.one * node.OctantSize); //} }
public void AddBlockToOctree(Vector3 localPosition, Octant octant) { if (!octant.IsLeaf()) { this.AddBlockToOctree(localPosition, octant.Octants [this.GetIndexOfPosition(localPosition, octant.Position)]); } else { if (octant.objectCount == 0) { octant.data = localPosition; } else if (octant.Subdivide()) { this.AddBlockToOctree(localPosition, octant.Octants [this.GetIndexOfPosition(localPosition, octant.Position)]); this.AddBlockToOctree(octant.data, octant.Octants [this.GetIndexOfPosition(octant.data, octant.Position)]); } } octant.objectCount++; }