MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/PhysX / insert

Method insert

physx/source/scenequery/src/SqIncrementalAABBTree.cpp:540–669  ·  view source on GitHub ↗

insert new bounds into tree

Source from the content-addressed store, hash-verified

538
539// insert new bounds into tree
540IncrementalAABBTreeNode* IncrementalAABBTree::insert(const PoolIndex index, const PxBounds3* bounds, NodeList& changedLeaf)
541{
542 PX_SIMD_GUARD;
543
544 // get the bounds, reset the W value
545 const Vec4V minV = V4ClearW(V4LoadU(&bounds[index].minimum.x));
546 const Vec4V maxV = V4ClearW(V4LoadU(&bounds[index].maximum.x));
547
548 // check if tree is empty
549 if(!mRoot)
550 {
551 // make it a leaf
552 AABBTreeIndices* indices = mIndicesPool.construct(index);
553 mRoot = reinterpret_cast<IncrementalAABBTreeNode*> (mNodesPool.allocate());
554 mRoot->mBVMin = minV;
555 mRoot->mBVMax = maxV;
556 mRoot->mIndices = indices;
557 mRoot->mChilds[1] = NULL;
558 mRoot->mParent = NULL;
559
560 return mRoot;
561 }
562 else
563 {
564 // check if root is a leaf
565 if(mRoot->isLeaf())
566 {
567 // if we still can insert the primitive into the leaf, or we need to split
568 if(mRoot->getNbPrimitives() < NB_OBJECTS_PER_NODE)
569 {
570 // simply add the primitive into the current leaf
571 addPrimitiveIntoNode(mRoot, index, minV, maxV);
572 return mRoot;
573 }
574 else
575 {
576 // need to split the node
577 // check if the leaf is not marked as changed, we need to remove it
578 if(!changedLeaf.empty())
579 {
580 PX_ASSERT(changedLeaf.size() == 1);
581 if(changedLeaf[0] == mRoot)
582 changedLeaf.popBack();
583 }
584 IncrementalAABBTreeNode* retNode = splitLeafNode(mRoot, index, minV, maxV, bounds);
585 mRoot = retNode->mParent;
586 IncrementalAABBTreeNode* sibling = (mRoot->mChilds[0] == retNode) ? mRoot->mChilds[1] : mRoot->mChilds[0];
587 if(sibling->isLeaf())
588 changedLeaf.pushBack(sibling);
589 changedLeaf.pushBack(retNode);
590 return retNode;
591 }
592 }
593 else
594 {
595 const Vec4V testCenterV = V4Add(maxV, minV);
596 IncrementalAABBTreeNode* returnNode = NULL;
597 IncrementalAABBTreeNode* rotationNode = NULL; // store a node that seems not balanced

Callers 15

addBodyMethod · 0.45
addConstraintMethod · 0.45
addArticulationMethod · 0.45
ScScene.cppFile · 0.45
onBodySleepMethod · 0.45
onBodyWakeUpMethod · 0.45
registerInteractionMethod · 0.45
addToPosePreviewListFunction · 0.45

Calls 14

addPrimitiveIntoNodeFunction · 0.85
traversalDirectionFunction · 0.85
V4ClearWFunction · 0.50
V4LoadUFunction · 0.50
V4AddFunction · 0.50
prefetchLineFunction · 0.50
constructMethod · 0.45
allocateMethod · 0.45
isLeafMethod · 0.45
getNbPrimitivesMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected