private static void addObject_Pushdown(SSBVHNodeAdaptor <GO> nAda, ssBVHNode <GO> curNode, GO newOb) { var left = curNode.Left; var right = curNode.Right; // merge and pushdown left and right as a new node.. var mergedSubnode = new ssBVHNode <GO>(nAda.BVH) { Left = left, Right = right, Parent = curNode, ContainedObjects = null }; // we need to be an interior node... so null out our object list.. left.Parent = mergedSubnode; right.Parent = mergedSubnode; mergedSubnode.ChildRefit(nAda, false); // make new subnode for obj var newSubnode = new ssBVHNode <GO>(nAda.BVH); newSubnode.Parent = curNode; newSubnode.ContainedObjects = new List <GO> { newOb }; nAda.MapObjectToBvhLeaf(newOb, newSubnode); newSubnode.ComputeVolume(nAda); // make assignments.. curNode.Left = mergedSubnode; curNode.Right = newSubnode; curNode.SetDepth(nAda, curNode.Depth); // propagate new depths to our children. curNode.ChildRefit(nAda); }
void SetDepth(SSBVHNodeAdaptor <GO> nAda, int newdepth) { Depth = newdepth; if (newdepth > nAda.BVH.MaxDepth) { nAda.BVH.MaxDepth = newdepth; } if (ContainedObjects == null) { Left.SetDepth(nAda, newdepth + 1); Right.SetDepth(nAda, newdepth + 1); } }