From ef6937e69e8ee3f409cf9d460d5ad300a65d5924 Mon Sep 17 00:00:00 2001 From: sschirm Date: Fri, 23 Dec 2016 14:20:36 +0100 Subject: PhysX 3.4 / APEX 1.4 release candidate @21506124 --- PhysX_3.4/Source/SceneQuery/src/SqAABBPruner.cpp | 34 ++++++++++++---------- PhysX_3.4/Source/SceneQuery/src/SqAABBPruner.h | 8 ++--- PhysX_3.4/Source/SceneQuery/src/SqBounds.h | 5 +++- PhysX_3.4/Source/SceneQuery/src/SqBucketPruner.cpp | 16 +++++----- PhysX_3.4/Source/SceneQuery/src/SqBucketPruner.h | 10 +++---- PhysX_3.4/Source/SceneQuery/src/SqPruningPool.h | 14 ++++----- .../Source/SceneQuery/src/SqSceneQueryManager.cpp | 14 ++++----- 7 files changed, 53 insertions(+), 48 deletions(-) (limited to 'PhysX_3.4/Source/SceneQuery/src') 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; imarkNodeForRefit(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(pp.data[0])), *(reinterpret_cast(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)++; } -- cgit v1.2.3