public OctTreeNode findLeaf(OctTreeNode children, Vector3 pos) { foreach(OctTreeNode child in children.childNode) { if (child.Contains(pos.X, pos.Y, pos.Z)) { if (child.AllItems.Count != 0) { possibleLeaf = child; findLeaf(child, pos); } } } return possibleLeaf; }
public List<IOctTreeElement> getObjectsToCompareWith(Vector3 pos) { List<IOctTreeElement> ret = new List<IOctTreeElement>(); List<OctTreeNode> children = root.childNode; possibleLeaf = null; foreach(OctTreeNode child in children) { if (child.Contains(pos.X, pos.Y, pos.Z)) { if (child.AllItems.Count != 0) { findLeaf(child, pos); } } } if (possibleLeaf == null) { return ret; } else { return possibleLeaf.AllItems; } }
public OctTree(float xMin, float yMin, float zMin, float xMax, float yMax, float zMax) { root = new OctTreeNode(xMin, yMin,zMin, xMax, yMax, zMax); }