diff options
| author | sschirm <[email protected]> | 2016-12-23 14:20:36 +0100 |
|---|---|---|
| committer | sschirm <[email protected]> | 2016-12-23 14:56:17 +0100 |
| commit | ef6937e69e8ee3f409cf9d460d5ad300a65d5924 (patch) | |
| tree | 710426e8daa605551ce3f34b581897011101c30f /PhysX_3.4/Source/SceneQuery/src/SqAABBPruner.cpp | |
| parent | Initial commit: (diff) | |
| download | physx-3.4-ef6937e69e8ee3f409cf9d460d5ad300a65d5924.tar.xz physx-3.4-ef6937e69e8ee3f409cf9d460d5ad300a65d5924.zip | |
PhysX 3.4 / APEX 1.4 release candidate @21506124
Diffstat (limited to 'PhysX_3.4/Source/SceneQuery/src/SqAABBPruner.cpp')
| -rw-r--r-- | PhysX_3.4/Source/SceneQuery/src/SqAABBPruner.cpp | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/PhysX_3.4/Source/SceneQuery/src/SqAABBPruner.cpp b/PhysX_3.4/Source/SceneQuery/src/SqAABBPruner.cpp index 895c5776..54edd920 100644 --- a/PhysX_3.4/Source/SceneQuery/src/SqAABBPruner.cpp +++ b/PhysX_3.4/Source/SceneQuery/src/SqAABBPruner.cpp @@ -124,7 +124,7 @@ bool AABBPruner::addObjects(PrunerHandle* results, const PxBounds3* bounds, cons return valid==count; } -void AABBPruner::updateObjects(const PrunerHandle* handles, const PxBounds3* newBounds, PxU32 count) +void AABBPruner::updateObjectsAfterManualBoundsUpdates(const PrunerHandle* handles, PxU32 count) { PX_PROFILE_ZONE("SceneQuery.prunerUpdateObjects", mContextID); @@ -133,16 +133,10 @@ void AABBPruner::updateObjects(const PrunerHandle* handles, const PxBounds3* new mUncommittedChanges = true; - if(newBounds) - { - for(PxU32 i=0; i<count; i++) - mPool.setWorldAABB(handles[i], newBounds[i]); // only updates the bounds - } - if(mIncrementalRebuild && mAABBTree) { mNeedsNewTree = true; // each update forces a tree rebuild - newBounds = mPool.getCurrentWorldBoxes(); + const PxBounds3* newBounds = mPool.getCurrentWorldBoxes(); PrunerPayload* payloads = mPool.getObjects(); for(PxU32 i=0; i<count; i++) { @@ -162,30 +156,38 @@ void AABBPruner::updateObjects(const PrunerHandle* handles, const PxBounds3* new } } -void AABBPruner::updateObjects(const PrunerHandle* handles, const PxU32* indices, const PxBounds3* newBounds, PxU32 count) +void AABBPruner::updateObjectsAndInflateBounds(const PrunerHandle* handles, const PxU32* indices, const PxBounds3* newBounds, PxU32 count) { PX_PROFILE_ZONE("SceneQuery.prunerUpdateObjects", mContextID); + if(!count) + return; + mUncommittedChanges = true; - mPool.updateObjects(handles, indices, newBounds, count); + mPool.updateObjectsAndInflateBounds(handles, indices, newBounds, count); - if (mIncrementalRebuild && mAABBTree) + if(mIncrementalRebuild && mAABBTree) { mNeedsNewTree = true; // each update forces a tree rebuild - for (PxU32 i = 0; i<count; i++) + PrunerPayload* payloads = mPool.getObjects(); + for(PxU32 i=0; i<count; i++) { const PoolIndex poolIndex = mPool.getIndex(handles[i]); const TreeNodeIndex treeNodeIndex = mTreeMap[poolIndex]; - if (treeNodeIndex != INVALID_NODE_ID) // this means it's in the current tree still and hasn't been removed + if(treeNodeIndex != INVALID_NODE_ID) // this means it's in the current tree still and hasn't been removed mAABBTree->markNodeForRefit(treeNodeIndex); else // otherwise it means it should be in the bucket pruner { - bool found = mBucketPruner.updateObject(newBounds[indices[i]], mPool.getPayload(handles[i])); + // PT: TODO: is this line correct? +// bool found = mBucketPruner.updateObject(newBounds[indices[i]], mPool.getPayload(handles[i])); + PX_ASSERT(&payloads[poolIndex]==&mPool.getPayload(handles[i])); + // PT: TODO: don't we need to read the pool's array here, to pass the inflated bounds? + bool found = mBucketPruner.updateObject(newBounds[indices[i]], payloads[poolIndex]); PX_UNUSED(found); PX_ASSERT(found); } - if (mProgress == BUILD_NEW_MAPPING || mProgress == BUILD_FULL_REFIT) + if(mProgress == BUILD_NEW_MAPPING || mProgress == BUILD_FULL_REFIT) mToRefit.pushBack(poolIndex); } } @@ -607,7 +609,7 @@ bool AABBPruner::buildStep() const PxU32 depth = Ps::ilog2(mBuilder.mNbPrimitives); // Note: This is the depth without counting the leaf layer const PxU32 estimatedNbWorkUnits = depth * mBuilder.mNbPrimitives; // Estimated number of work units for new tree - const PxU32 estimatedNbWorkUnitsOld = mAABBTree->getTotalPrims(); + const PxU32 estimatedNbWorkUnitsOld = mAABBTree ? mAABBTree->getTotalPrims() : 0; if ((estimatedNbWorkUnits <= (estimatedNbWorkUnitsOld << 1)) && (estimatedNbWorkUnits >= (estimatedNbWorkUnitsOld >> 1))) // The two estimates do not differ by more than a factor 2 mTotalWorkUnits = estimatedNbWorkUnitsOld; |