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

Method prepareBuild

physx/source/scenequery/src/SqAABBPruner.cpp:677–726  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

675}
676
677bool AABBPruner::prepareBuild()
678{
679 PX_PROFILE_ZONE("SceneQuery.prepareBuild", mContextID);
680
681 PX_ASSERT(mIncrementalRebuild);
682 if(mNeedsNewTree)
683 {
684 if(mProgress==BUILD_NOT_STARTED)
685 {
686 const PxU32 nbObjects = mPool.getNbActiveObjects();
687 if(!nbObjects)
688 return false;
689
690 PX_DELETE(mNewTree);
691 mNewTree = PX_NEW(AABBTree);
692
693 mNbCachedBoxes = nbObjects;
694 // PT: we always allocate one extra box, to make sure we can safely use V4 loads on the array
695 mCachedBoxes = reinterpret_cast<PxBounds3*>(PX_ALLOC(sizeof(PxBounds3)*(nbObjects+1), "PxBound3"));
696
697 PxMemCopy(mCachedBoxes, mPool.getCurrentWorldBoxes(), nbObjects*sizeof(PxBounds3));
698
699 // PT: objects currently in the bucket pruner will be in the new tree. They are marked with the
700 // current timestamp (mTimeStamp). However more objects can get added while we compute the new tree,
701 // and those ones will not be part of it. These new objects will be marked with the new timestamp
702 // value (mTimeStamp+1), and we can use these different values to remove the proper objects from
703 // the bucket pruner (when switching to the new tree).
704 mTimeStamp++;
705#if USE_INCREMENTAL_PRUNER
706 // notify the incremental pruner to swap trees
707 mBucketPruner.timeStampChange();
708#endif
709 mBuilder.reset();
710 mBuilder.mNbPrimitives = mNbCachedBoxes;
711 mBuilder.mAABBArray = mCachedBoxes;
712 mBuilder.mLimit = NB_OBJECTS_PER_NODE;
713
714 mBuildStats.reset();
715
716 // start recording modifications to the tree made during rebuild to reapply (fix the new tree) eventually
717 PX_ASSERT(mNewTreeFixups.size()==0);
718
719 mProgress = BUILD_INIT;
720 }
721 }
722 else
723 return false;
724
725 return true;
726}
727
728
729///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Callers 1

Calls 6

PxMemCopyFunction · 0.85
getNbActiveObjectsMethod · 0.80
getCurrentWorldBoxesMethod · 0.80
timeStampChangeMethod · 0.45
resetMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected