private static Branch CreateBranch(Octree <T> tree, Branch parent, Bounds bounds) { // ____________ // / / / // / 6 / 7 / | // /_____/_____/ | // / / / | // / 4 / 5 / | // /_____/_____/ | // | ____________| // | / / / // | / 2 / 3 / // | /_____/_____/ // | / / / // | / 0 / 1 / // /_____/_____/ var branch = new Branch(bounds); branch.Tree = tree; branch.Parent = parent; branch.Split = false; double midX = bounds.MinX + (bounds.MaxX - bounds.MinX) / 2; double midY = bounds.MinY + (bounds.MaxY - bounds.MinY) / 2; double midZ = bounds.MinZ + (bounds.MaxZ - bounds.MinZ) / 2; double[] xPos = new double[] { bounds.MinX, midX, midX, bounds.MaxX }; double[] yPos = new double[] { bounds.MinY, midY, midY, bounds.MaxY }; double[] zPos = new double[] { bounds.MinZ, midZ, midZ, bounds.MaxZ }; branch.ChildBounds[0].Set(xPos[0], yPos[0], zPos[0], xPos[1], yPos[1], zPos[1]); branch.ChildBounds[1].Set(xPos[2], yPos[0], zPos[0], xPos[3], yPos[1], zPos[1]); branch.ChildBounds[2].Set(xPos[0], yPos[2], zPos[0], xPos[1], yPos[3], zPos[1]); branch.ChildBounds[3].Set(xPos[2], yPos[2], zPos[0], xPos[3], yPos[3], zPos[1]); branch.ChildBounds[4].Set(xPos[0], yPos[0], zPos[2], xPos[1], yPos[1], zPos[3]); branch.ChildBounds[5].Set(xPos[2], yPos[0], zPos[2], xPos[3], yPos[1], zPos[3]); branch.ChildBounds[6].Set(xPos[0], yPos[2], zPos[2], xPos[1], yPos[3], zPos[3]); branch.ChildBounds[7].Set(xPos[2], yPos[2], zPos[2], xPos[3], yPos[3], zPos[3]); return(branch); }
private static Branch CreateBranch(Octree <T> tree, Branch parent, AxisAlignedBoundingBox bounds) { // ____________ // / / / // / 6 / 7 / | // /_____/_____/ | // / / / | // / 4 / 5 / | // /_____/_____/ | // | ____________| // | / / / // | / 2 / 3 / // | /_____/_____/ // | / / / // | / 0 / 1 / // /_____/_____/ var branch = new Branch(bounds); branch.Tree = tree; branch.Parent = parent; branch.Split = false; double midX = bounds.MinXYZ.X + (bounds.MaxXYZ.X - bounds.MinXYZ.X) / 2; double midY = bounds.MinXYZ.Y + (bounds.MaxXYZ.Y - bounds.MinXYZ.Y) / 2; double midZ = bounds.MinXYZ.Z + (bounds.MaxXYZ.Z - bounds.MinXYZ.Z) / 2; double[] xPos = new double[] { bounds.MinXYZ.X, midX, midX, bounds.MaxXYZ.X }; double[] yPos = new double[] { bounds.MinXYZ.Y, midY, midY, bounds.MaxXYZ.Y }; double[] zPos = new double[] { bounds.MinXYZ.Z, midZ, midZ, bounds.MaxXYZ.Z }; branch.ChildBounds[0] = new AxisAlignedBoundingBox(xPos[0], yPos[0], zPos[0], xPos[1], yPos[1], zPos[1]); branch.ChildBounds[1] = new AxisAlignedBoundingBox(xPos[2], yPos[0], zPos[0], xPos[3], yPos[1], zPos[1]); branch.ChildBounds[2] = new AxisAlignedBoundingBox(xPos[0], yPos[2], zPos[0], xPos[1], yPos[3], zPos[1]); branch.ChildBounds[3] = new AxisAlignedBoundingBox(xPos[2], yPos[2], zPos[0], xPos[3], yPos[3], zPos[1]); branch.ChildBounds[4] = new AxisAlignedBoundingBox(xPos[0], yPos[0], zPos[2], xPos[1], yPos[1], zPos[3]); branch.ChildBounds[5] = new AxisAlignedBoundingBox(xPos[2], yPos[0], zPos[2], xPos[3], yPos[1], zPos[3]); branch.ChildBounds[6] = new AxisAlignedBoundingBox(xPos[0], yPos[2], zPos[2], xPos[1], yPos[3], zPos[3]); branch.ChildBounds[7] = new AxisAlignedBoundingBox(xPos[2], yPos[2], zPos[2], xPos[3], yPos[3], zPos[3]); return(branch); }