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 | |
| 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')
| -rw-r--r-- | PhysX_3.4/Source/SceneQuery/src/SqAABBPruner.cpp | 34 | ||||
| -rw-r--r-- | PhysX_3.4/Source/SceneQuery/src/SqAABBPruner.h | 8 | ||||
| -rw-r--r-- | PhysX_3.4/Source/SceneQuery/src/SqBounds.h | 5 | ||||
| -rw-r--r-- | PhysX_3.4/Source/SceneQuery/src/SqBucketPruner.cpp | 16 | ||||
| -rw-r--r-- | PhysX_3.4/Source/SceneQuery/src/SqBucketPruner.h | 10 | ||||
| -rw-r--r-- | PhysX_3.4/Source/SceneQuery/src/SqPruningPool.h | 14 | ||||
| -rw-r--r-- | PhysX_3.4/Source/SceneQuery/src/SqSceneQueryManager.cpp | 14 |
7 files changed, 53 insertions, 48 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; diff --git a/PhysX_3.4/Source/SceneQuery/src/SqAABBPruner.h b/PhysX_3.4/Source/SceneQuery/src/SqAABBPruner.h index c5e96aa6..84c7e5af 100644 --- a/PhysX_3.4/Source/SceneQuery/src/SqAABBPruner.h +++ b/PhysX_3.4/Source/SceneQuery/src/SqAABBPruner.h @@ -128,10 +128,10 @@ namespace Sq virtual ~AABBPruner(); // Pruner - virtual bool addObjects(PrunerHandle* results, const PxBounds3* bounds, const PrunerPayload* userData, PxU32 count = 1, bool hasPruningStructure = false); - virtual void removeObjects(const PrunerHandle* handles, PxU32 count = 1); - virtual void updateObjects(const PrunerHandle* handles, const PxBounds3* newBounds, PxU32 count = 1); - virtual void updateObjects(const PrunerHandle* handles, const PxU32* indices, const PxBounds3* newBounds, PxU32 count = 1); + virtual bool addObjects(PrunerHandle* results, const PxBounds3* bounds, const PrunerPayload* userData, PxU32 count, bool hasPruningStructure); + virtual void removeObjects(const PrunerHandle* handles, PxU32 count); + virtual void updateObjectsAfterManualBoundsUpdates(const PrunerHandle* handles, PxU32 count); + virtual void updateObjectsAndInflateBounds(const PrunerHandle* handles, const PxU32* indices, const PxBounds3* newBounds, PxU32 count); virtual void commit(); virtual PxAgain raycast(const PxVec3& origin, const PxVec3& unitDir, PxReal& inOutDistance, PrunerCallback&) const; virtual PxAgain overlap(const Gu::ShapeData& queryVolume, PrunerCallback&) const; diff --git a/PhysX_3.4/Source/SceneQuery/src/SqBounds.h b/PhysX_3.4/Source/SceneQuery/src/SqBounds.h index 60c6ad6f..cd40ece6 100644 --- a/PhysX_3.4/Source/SceneQuery/src/SqBounds.h +++ b/PhysX_3.4/Source/SceneQuery/src/SqBounds.h @@ -51,13 +51,16 @@ namespace Sq extern const ComputeBoundsFunc gComputeBoundsTable[2]; + // PT: TODO: - check that this is compatible with Gu::computeBounds(..., SQ_PRUNER_INFLATION, ...) + // PT: TODO: - refactor with "inflateBounds" in GuBounds.cpp if possible + // PT: TODO: - use SQ_PRUNER_INFLATION instead of hardcoding "0.01f" PX_FORCE_INLINE void inflateBounds(PxBounds3& dst, const PxBounds3& src) { using namespace physx::shdfnd::aos; const Vec4V minV = V4LoadU(&src.minimum.x); const Vec4V maxV = V4LoadU(&src.maximum.x); - const Vec4V eV = V4Scale(V4Sub(maxV, minV), FLoad(0.5f* 0.01f)); + const Vec4V eV = V4Scale(V4Sub(maxV, minV), FLoad(0.5f * 0.01f)); V4StoreU(V4Sub(minV, eV), &dst.minimum.x); PX_ALIGN(16, PxVec4) max4; diff --git a/PhysX_3.4/Source/SceneQuery/src/SqBucketPruner.cpp b/PhysX_3.4/Source/SceneQuery/src/SqBucketPruner.cpp index 35a5ca13..ba0934b0 100644 --- a/PhysX_3.4/Source/SceneQuery/src/SqBucketPruner.cpp +++ b/PhysX_3.4/Source/SceneQuery/src/SqBucketPruner.cpp @@ -2219,24 +2219,24 @@ void BucketPruner::removeObjects(const PrunerHandle* handles, PxU32 count) mCore.mDirty = true; } -void BucketPruner::updateObjects(const PrunerHandle* handles, const PxBounds3* newBounds, PxU32 count) +void BucketPruner::updateObjectsAfterManualBoundsUpdates(const PrunerHandle* handles, PxU32 count) { if(!count) return; - if(newBounds) - { - for(PxU32 i=0;i<count;i++) - mPool.setWorldAABB(handles[i], newBounds[i]); - } + PX_UNUSED(handles); mCore.setExternalMemory(mPool.getNbActiveObjects(), mPool.getCurrentWorldBoxes(), mPool.getObjects()); mCore.mDirty = true; } -void BucketPruner::updateObjects(const PrunerHandle* handles, const PxU32* indices, const PxBounds3* newBounds, PxU32 count) +void BucketPruner::updateObjectsAndInflateBounds(const PrunerHandle* handles, const PxU32* indices, const PxBounds3* newBounds, PxU32 count) { - mPool.updateObjects(handles, indices, newBounds, count); + if(!count) + return; + + mPool.updateObjectsAndInflateBounds(handles, indices, newBounds, count); + mCore.setExternalMemory(mPool.getNbActiveObjects(), mPool.getCurrentWorldBoxes(), mPool.getObjects()); mCore.mDirty = true; } diff --git a/PhysX_3.4/Source/SceneQuery/src/SqBucketPruner.h b/PhysX_3.4/Source/SceneQuery/src/SqBucketPruner.h index dec62ccd..85646cba 100644 --- a/PhysX_3.4/Source/SceneQuery/src/SqBucketPruner.h +++ b/PhysX_3.4/Source/SceneQuery/src/SqBucketPruner.h @@ -252,15 +252,15 @@ namespace Sq // Pruner virtual bool addObjects(PrunerHandle* results, const PxBounds3* bounds, const PrunerPayload* payload, PxU32 count, bool); virtual void removeObjects(const PrunerHandle* handles, PxU32 count); - virtual void updateObjects(const PrunerHandle* handles, const PxBounds3* newBounds, PxU32 count); - virtual void updateObjects(const PrunerHandle* handles, const PxU32* indices, const PxBounds3* newBounds, PxU32 count = 1); + virtual void updateObjectsAfterManualBoundsUpdates(const PrunerHandle* handles, PxU32 count); + virtual void updateObjectsAndInflateBounds(const PrunerHandle* handles, const PxU32* indices, const PxBounds3* newBounds, PxU32 count); virtual void commit(); virtual PxAgain raycast(const PxVec3& origin, const PxVec3& unitDir, PxReal& inOutDistance, PrunerCallback&) const; virtual PxAgain overlap(const Gu::ShapeData& queryVolume, PrunerCallback&) const; virtual PxAgain sweep(const Gu::ShapeData& queryVolume, const PxVec3& unitDir, PxReal& inOutDistance, PrunerCallback&) const; - virtual const PrunerPayload& getPayload(PrunerHandle handle) const { return mPool.getPayload(handle); } - virtual const PrunerPayload& getPayload(PrunerHandle handle, PxBounds3*& bounds) const { return mPool.getPayload(handle, bounds); } - virtual void preallocate(PxU32 entries) { mPool.preallocate(entries); } + virtual const PrunerPayload& getPayload(PrunerHandle handle) const { return mPool.getPayload(handle); } + virtual const PrunerPayload& getPayload(PrunerHandle handle, PxBounds3*& bounds) const { return mPool.getPayload(handle, bounds); } + virtual void preallocate(PxU32 entries) { mPool.preallocate(entries); } virtual void shiftOrigin(const PxVec3& shift); virtual void visualize(Cm::RenderOutput& out, PxU32 color) const; // merge not implemented for bucket pruner diff --git a/PhysX_3.4/Source/SceneQuery/src/SqPruningPool.h b/PhysX_3.4/Source/SceneQuery/src/SqPruningPool.h index 229ea340..0bf5e655 100644 --- a/PhysX_3.4/Source/SceneQuery/src/SqPruningPool.h +++ b/PhysX_3.4/Source/SceneQuery/src/SqPruningPool.h @@ -76,20 +76,20 @@ namespace Sq PX_FORCE_INLINE const PxBounds3* getCurrentWorldBoxes() const { return mWorldBoxes; } PX_FORCE_INLINE PxBounds3* getCurrentWorldBoxes() { return mWorldBoxes; } - PX_FORCE_INLINE void setWorldAABB(PrunerHandle h, const PxBounds3& worldAABB) - { - mWorldBoxes[getIndex(h)] = worldAABB; - } - PX_FORCE_INLINE const PxBounds3& getWorldAABB(PrunerHandle h) const { return mWorldBoxes[getIndex(h)]; } - PX_FORCE_INLINE void updateObjects(const PrunerHandle* handles, const PxU32* indices, const PxBounds3* newBounds, PxU32 count) + PX_FORCE_INLINE void updateObjectsAndInflateBounds(const PrunerHandle* handles, const PxU32* indices, const PxBounds3* newBounds, PxU32 count) { for(PxU32 i=0; i<count; i++) - Sq::inflateBounds(mWorldBoxes[getIndex(handles[i])], newBounds[indices[i]]); + { + const PoolIndex poolIndex = getIndex(handles[i]); + PX_ASSERT(poolIndex!=INVALID_PRUNERHANDLE); +// if(poolIndex!=INVALID_PRUNERHANDLE) + Sq::inflateBounds(mWorldBoxes[poolIndex], newBounds[indices[i]]); + } } void preallocate(PxU32 entries); diff --git a/PhysX_3.4/Source/SceneQuery/src/SqSceneQueryManager.cpp b/PhysX_3.4/Source/SceneQuery/src/SqSceneQueryManager.cpp index cd3e25eb..1498c745 100644 --- a/PhysX_3.4/Source/SceneQuery/src/SqSceneQueryManager.cpp +++ b/PhysX_3.4/Source/SceneQuery/src/SqSceneQueryManager.cpp @@ -124,7 +124,7 @@ void PrunerExt::flushShapes(PxU32 index) (func)(*bounds, *(reinterpret_cast<Scb::Shape*>(pp.data[0])), *(reinterpret_cast<Scb::Actor*>(pp.data[1]))); } // PT: batch update happens after the loop instead of once per loop iteration - mPruner->updateObjects(prunerHandles, NULL, numDirtyList); + mPruner->updateObjectsAfterManualBoundsUpdates(prunerHandles, numDirtyList); mTimestamp += numDirtyList; mDirtyList.clear(); } @@ -257,7 +257,7 @@ void SceneQueryManager::removePrunerShape(PrunerData data) mPrunerExt[index].removeFromDirtyList(handle); mPrunerExt[index].invalidateTimestamp(); - mPrunerExt[index].pruner()->removeObjects(&handle); + mPrunerExt[index].pruner()->removeObjects(&handle, 1); } void SceneQueryManager::setDynamicTreeRebuildRateHint(PxU32 rebuildRateHint) @@ -397,7 +397,7 @@ void SceneQueryManager::processSimUpdates() if(nbBatchedObjects==NB_BATCHED_OBJECTS) { mPrunerExt[PruningIndex::eDYNAMIC].invalidateTimestamp(); - pruner->updateObjects(batchedHandles, NULL, nbBatchedObjects); + pruner->updateObjectsAfterManualBoundsUpdates(batchedHandles, nbBatchedObjects); nbBatchedObjects = 0; } } @@ -407,7 +407,7 @@ void SceneQueryManager::processSimUpdates() if(nbBatchedObjects) { mPrunerExt[PruningIndex::eDYNAMIC].invalidateTimestamp(); - pruner->updateObjects(batchedHandles, NULL, nbBatchedObjects); + pruner->updateObjectsAfterManualBoundsUpdates(batchedHandles, nbBatchedObjects); } } @@ -490,11 +490,11 @@ void SceneQueryManager::shiftOrigin(const PxVec3& shift) mPrunerExt[i].pruner()->shiftOrigin(shift); } -void DynamicBoundsSync::sync(const PxU32* sqRefs, const PxU32* indices, const PxBounds3* bounds, PxU32 count) +void DynamicBoundsSync::sync(const PrunerHandle* handles, const PxU32* indices, const PxBounds3* bounds, PxU32 count) { - mPruner->updateObjects(sqRefs, indices, bounds, count); + mPruner->updateObjectsAndInflateBounds(handles, indices, bounds, count); - if (count) + if(count) (*mTimestamp)++; } |