internal 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); mergedSubnode.left = left; mergedSubnode.right = right; mergedSubnode.parent = curNode; mergedSubnode.gobjects = null; // we need to be an interior node... so null out our object list.. left.parent = mergedSubnode; right.parent = mergedSubnode; mergedSubnode.childRefit(nAda, propagate: false); // make new subnode for obj var newSubnode = new ssBVHNode <GO>(nAda.BVH); newSubnode.parent = curNode; newSubnode.gobjects = 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(int newdepth) { this.depth = newdepth; if (gobjects == null) { left.setDepth(newdepth + 1); right.setDepth(newdepth + 1); } }
void setDepth(SSBVHNodeAdaptor <GO> nAda, int newdepth) { this.depth = newdepth; if (newdepth > nAda.BVH.maxDepth) { nAda.BVH.maxDepth = newdepth; } if (gobjects == null) { left.setDepth(nAda, newdepth + 1); right.setDepth(nAda, newdepth + 1); } }