/// <summary> /// ID's which child to make component to grow Octree towards point. /// NOTE: returns -1 if component contains point. /// If confused, probably easiest to chart input-outputs. /// <summary> private int optimalChildNum(OctreeComponent <T> component, Vector3 point) { if (component.contains(point)) { return(-1); } if (point.x <= component.min.x) { if (point.y <= component.min.y) { if (point.z <= component.min.z) { return(1); /// (<,<,<) } else { return(5); /// (<,<,>) } } else { if (point.z <= component.min.z) { return(3); /// (<,>,<) } else { return(7); /// (<,>,>) } } } else { if (point.y <= component.min.y) { if (point.z <= component.min.z) { return(0); /// (>,<,<) } else { return(4); /// (>,<,>) } } else { if (point.z <= component.min.z) { return(2); /// (>,>,<) } else { return(6); /// (>,>,>) } } } }
/// <summary> /// Mutator for a child. /// Used by Octree in grow, Voxel in split. /// NOTE: Private variable/public mutator is more safe than pure public variable. /// Really wish C# allowed friend classes. /// <summary> public void setChild(int childNum, OctreeComponent <T> newChild) { children[childNum] = newChild; }