aboutsummaryrefslogtreecommitdiff
path: root/PhysX_3.4/Source/LowLevelAABB
diff options
context:
space:
mode:
authorSheikh Dawood Abdul Ajees <[email protected]>2018-09-25 11:33:48 -0500
committerSheikh Dawood Abdul Ajees <[email protected]>2018-09-25 11:33:48 -0500
commitad993f2926db6fe4ba2c75e17c4f099d9d853038 (patch)
tree426f831e7aa870a4704b8dd082538ff292e751f9 /PhysX_3.4/Source/LowLevelAABB
parentPhysX 3.4, APEX 1.4 patch release @24698370 (diff)
downloadphysx-3.4-ad993f2926db6fe4ba2c75e17c4f099d9d853038.tar.xz
physx-3.4-ad993f2926db6fe4ba2c75e17c4f099d9d853038.zip
PhysX 3.4, APEX 1.4 patch release @24990349
Diffstat (limited to 'PhysX_3.4/Source/LowLevelAABB')
-rw-r--r--PhysX_3.4/Source/LowLevelAABB/include/BpBroadPhase.h8
-rw-r--r--PhysX_3.4/Source/LowLevelAABB/src/BpBroadPhase.cpp155
-rw-r--r--PhysX_3.4/Source/LowLevelAABB/src/BpBroadPhaseMBP.cpp31
-rw-r--r--PhysX_3.4/Source/LowLevelAABB/src/BpBroadPhaseMBP.h8
-rw-r--r--PhysX_3.4/Source/LowLevelAABB/src/BpBroadPhaseSap.cpp19
-rw-r--r--PhysX_3.4/Source/LowLevelAABB/src/BpBroadPhaseSap.h15
-rw-r--r--PhysX_3.4/Source/LowLevelAABB/src/BpSimpleAABBManager.cpp10
7 files changed, 125 insertions, 121 deletions
diff --git a/PhysX_3.4/Source/LowLevelAABB/include/BpBroadPhase.h b/PhysX_3.4/Source/LowLevelAABB/include/BpBroadPhase.h
index b69825dd..a2603361 100644
--- a/PhysX_3.4/Source/LowLevelAABB/include/BpBroadPhase.h
+++ b/PhysX_3.4/Source/LowLevelAABB/include/BpBroadPhase.h
@@ -225,7 +225,7 @@ public:
/**
\brief Shutdown of the broadphase.
*/
- virtual void destroy() = 0;
+ virtual void destroy() = 0;
/**
\brief Update the broadphase and compute the lists of created/deleted pairs.
@@ -311,10 +311,12 @@ public:
virtual bool isValid(const BroadPhaseUpdateData& updateData) const = 0;
#endif
- virtual BroadPhasePair* getBroadPhasePairs() const = 0;
+ virtual BroadPhasePair* getBroadPhasePairs() const = 0;
- virtual void deletePairs() = 0;
+ virtual void deletePairs() = 0;
+ // PT: for unit-testing the non-GPU versions
+ virtual void singleThreadedUpdate(PxcScratchAllocator* /*scratchAllocator*/, const BroadPhaseUpdateData& /*updateData*/){}
};
} //namespace Bp
diff --git a/PhysX_3.4/Source/LowLevelAABB/src/BpBroadPhase.cpp b/PhysX_3.4/Source/LowLevelAABB/src/BpBroadPhase.cpp
index 5ced7e0e..ed11420b 100644
--- a/PhysX_3.4/Source/LowLevelAABB/src/BpBroadPhase.cpp
+++ b/PhysX_3.4/Source/LowLevelAABB/src/BpBroadPhase.cpp
@@ -32,9 +32,11 @@
#include "BpBroadPhaseMBP.h"
#include "PxSceneDesc.h"
#include "BpSimpleAABBManager.h"
+#include "CmBitMap.h"
using namespace physx;
using namespace Bp;
+using namespace Cm;
BroadPhase* BroadPhase::create(
const PxBroadPhaseType::Enum bpType,
@@ -58,119 +60,100 @@ bool BroadPhaseUpdateData::isValid(const BroadPhaseUpdateData& updateData, const
return (updateData.isValid() && bp.isValid(updateData));
}
-bool BroadPhaseUpdateData::isValid() const
+static bool testHandles(PxU32 size, const BpHandle* handles, const PxU32 capacity, const Bp::FilterGroup::Enum* groups, const PxBounds3* bounds, BitMap& bitmap)
{
- const BpHandle* created=getCreatedHandles();
- const BpHandle* updated=getUpdatedHandles();
- const BpHandle* removed=getRemovedHandles();
- const PxU32 createdSize=getNumCreatedHandles();
- const PxU32 updatedSize=getNumUpdatedHandles();
- const PxU32 removedSize=getNumRemovedHandles();
- const PxBounds3* bounds=getAABBs();
- const PxU32 boxesCapacity=getCapacity();
-
- if(NULL==created && createdSize>0)
- {
- return false;
- }
- if(NULL==updated && updatedSize>0)
- {
+ if(!handles && size)
return false;
- }
- if(NULL==removed && removedSize>0)
- {
- return false;
- }
- ValType minVal=0;
- ValType maxVal=0xffffffff;
- PX_UNUSED(minVal);
- PX_UNUSED(maxVal);
+/* ValType minVal=0;
+ ValType maxVal=0xffffffff;*/
- for(PxU32 i=0;i<createdSize;i++)
+ for(PxU32 i=0;i<size;i++)
{
- if(created[i]>=boxesCapacity)
+ const BpHandle h = handles[i];
+
+ if(h>=capacity)
return false;
- //Created array in ascending order of id.
- if(i>0 && (created[i] < created[i-1]))
- {
+ // Array in ascending order of id.
+ if(i>0 && (h < handles[i-1]))
return false;
- }
- for(PxU32 j=0;j<3;j++)
- {
- //Max must be greater than min.
- if(bounds[created[i]].minimum[j]>bounds[created[i]].maximum[j])
- return false;
+ if(groups && groups[h]==FilterGroup::eINVALID)
+ return false;
+
+ bitmap.set(h);
+
+ if(bounds)
+ {
+ for(PxU32 j=0;j<3;j++)
+ {
+ //Max must be greater than min.
+ if(bounds[h].minimum[j]>bounds[h].maximum[j])
+ return false;
#if 0
- //Bounds have an upper limit.
- if(bounds[created[i]].getMax(j)>=maxVal)
- return false;
+ //Bounds have an upper limit.
+ if(bounds[created[i]].getMax(j)>=maxVal)
+ return false;
- //Bounds have a lower limit.
- if(bounds[created[i]].getMin(j)<=minVal)
- return false;
+ //Bounds have a lower limit.
+ if(bounds[created[i]].getMin(j)<=minVal)
+ return false;
- //Max must be odd.
- if(4 != (bounds[created[i]].getMax(j) & 4))
- return false;
+ //Max must be odd.
+ if(4 != (bounds[created[i]].getMax(j) & 4))
+ return false;
- //Min must be even.
- if(0 != (bounds[created[i]].getMin(j) & 4))
- return false;
+ //Min must be even.
+ if(0 != (bounds[created[i]].getMin(j) & 4))
+ return false;
#endif
+ }
}
}
+ return true;
+}
- for(PxU32 i=0;i<updatedSize;i++)
+static bool testBitmap(const BitMap& bitmap, PxU32 size, const BpHandle* handles)
+{
+ while(size--)
{
- if(updated[i]>=boxesCapacity)
+ const BpHandle h = *handles++;
+ if(bitmap.test(h))
return false;
+ }
+ return true;
+}
- //Updated array in ascending order of id
- if(i>0 && (updated[i] < updated[i-1]))
- {
- return false;
- }
-
- for(PxU32 j=0;j<3;j++)
- {
- //Max must be greater than min.
- if(bounds[updated[i]].minimum[j]>bounds[updated[i]].maximum[j])
- return false;
-#if 0
- //Bounds have an upper limit.
- if(bounds[updated[i]].getMax(j)>=maxVal)
- return false;
-
- //Bounds have a lower limit.
- if(bounds[updated[i]].getMin(j)<=minVal)
- return false;
+bool BroadPhaseUpdateData::isValid() const
+{
+ const PxBounds3* bounds = getAABBs();
+ const PxU32 boxesCapacity = getCapacity();
+ const Bp::FilterGroup::Enum* groups = getGroups();
- //Max must be odd.
- if(4 != (bounds[updated[i]].getMax(j) & 4))
- return false;
+ BitMap createdBitmap; createdBitmap.resizeAndClear(boxesCapacity);
+ BitMap updatedBitmap; updatedBitmap.resizeAndClear(boxesCapacity);
+ BitMap removedBitmap; removedBitmap.resizeAndClear(boxesCapacity);
- //Min must be even.
- if(0 != (bounds[updated[i]].getMin(j) & 4))
- return false;
-#endif
- }
- }
+ if(!testHandles(getNumCreatedHandles(), getCreatedHandles(), boxesCapacity, groups, bounds, createdBitmap))
+ return false;
+ if(!testHandles(getNumUpdatedHandles(), getUpdatedHandles(), boxesCapacity, groups, bounds, updatedBitmap))
+ return false;
+ if(!testHandles(getNumRemovedHandles(), getRemovedHandles(), boxesCapacity, NULL, NULL, removedBitmap))
+ return false;
- for(PxU32 i=0;i<removedSize;i++)
+ if(1)
{
- if(removed[i]>=boxesCapacity)
+ // Created/updated
+ if(!testBitmap(createdBitmap, getNumUpdatedHandles(), getUpdatedHandles()))
return false;
-
- //Removed array in ascending order of id
- if(i>0 && (removed[i] < removed[i-1]))
- {
+ // Created/removed
+ if(!testBitmap(createdBitmap, getNumRemovedHandles(), getRemovedHandles()))
+ return false;
+ // Updated/removed
+ if(!testBitmap(updatedBitmap, getNumRemovedHandles(), getRemovedHandles()))
return false;
- }
}
-
return true;
}
#endif
diff --git a/PhysX_3.4/Source/LowLevelAABB/src/BpBroadPhaseMBP.cpp b/PhysX_3.4/Source/LowLevelAABB/src/BpBroadPhaseMBP.cpp
index 313e27f3..cdaa2145 100644
--- a/PhysX_3.4/Source/LowLevelAABB/src/BpBroadPhaseMBP.cpp
+++ b/PhysX_3.4/Source/LowLevelAABB/src/BpBroadPhaseMBP.cpp
@@ -3354,6 +3354,14 @@ void BroadPhaseMBP::update(const PxU32 numCpuTasks, PxcScratchAllocator* scratch
}
}
+void BroadPhaseMBP::singleThreadedUpdate(PxcScratchAllocator* /*scratchAllocator*/, const BroadPhaseUpdateData& updateData)
+{
+ // PT: TODO: the scratchAllocator isn't actually needed, is it?
+ setUpdateData(updateData);
+ update();
+ postUpdate();
+}
+
static PX_FORCE_INLINE void computeMBPBounds(MBP_AABB& aabb, const PxBounds3* PX_RESTRICT boundsXYZ, const PxReal* PX_RESTRICT contactDistances, const BpHandle index)
{
const PxBounds3& b = boundsXYZ[index];
@@ -3614,23 +3622,24 @@ bool BroadPhaseMBP::isValid(const BroadPhaseUpdateData& updateData) const
const BpHandle* created = updateData.getCreatedHandles();
if(created)
{
+ Ps::HashSet<BpHandle> set;
+ PxU32 nbObjects = mMBP->mMBP_Objects.size();
+ const MBP_Object* PX_RESTRICT objects = mMBP->mMBP_Objects.begin();
+ while(nbObjects--)
+ {
+ if(!(objects->mFlags & MBP_REMOVED))
+ set.insert(objects->mUserID);
+ objects++;
+ }
+
PxU32 nbToGo = updateData.getNumCreatedHandles();
while(nbToGo--)
{
const BpHandle index = *created++;
PX_ASSERT(index<mCapacity);
- PxU32 nbObjects = mMBP->mMBP_Objects.size();
- const MBP_Object* PX_RESTRICT objects = mMBP->mMBP_Objects.begin();
- while(nbObjects--)
- {
- if(!(objects->mFlags & MBP_REMOVED))
- {
- if(objects->mUserID==index)
- return false; // This object has been added already
- }
- objects++;
- }
+ if(set.contains(index))
+ return false; // This object has been added already
}
}
diff --git a/PhysX_3.4/Source/LowLevelAABB/src/BpBroadPhaseMBP.h b/PhysX_3.4/Source/LowLevelAABB/src/BpBroadPhaseMBP.h
index 08f6e771..cfda1d38 100644
--- a/PhysX_3.4/Source/LowLevelAABB/src/BpBroadPhaseMBP.h
+++ b/PhysX_3.4/Source/LowLevelAABB/src/BpBroadPhaseMBP.h
@@ -65,27 +65,21 @@ namespace Bp
// BroadPhase
virtual PxBroadPhaseType::Enum getType() const { return PxBroadPhaseType::eMBP; }
-
virtual void destroy() { delete this; }
-
virtual void update(const PxU32 numCpuTasks, PxcScratchAllocator* scratchAllocator, const BroadPhaseUpdateData& updateData, physx::PxBaseTask* continuation, physx::PxBaseTask* narrowPhaseUnblockTask);
virtual void fetchBroadPhaseResults(physx::PxBaseTask*) {}
-
virtual PxU32 getNbCreatedPairs() const;
virtual BroadPhasePair* getCreatedPairs();
virtual PxU32 getNbDeletedPairs() const;
virtual BroadPhasePair* getDeletedPairs();
-
virtual void freeBuffers();
-
virtual void shiftOrigin(const PxVec3& shift);
-
#if PX_CHECKED
virtual bool isValid(const BroadPhaseUpdateData& updateData) const;
#endif
-
virtual BroadPhasePair* getBroadPhasePairs() const {return NULL;} //KS - TODO - implement this!!!
virtual void deletePairs(){} //KS - TODO - implement this!!!
+ virtual void singleThreadedUpdate(PxcScratchAllocator* scratchAllocator, const BroadPhaseUpdateData& updateData);
//~BroadPhase
MBPUpdateWorkTask mMBPUpdateWorkTask;
diff --git a/PhysX_3.4/Source/LowLevelAABB/src/BpBroadPhaseSap.cpp b/PhysX_3.4/Source/LowLevelAABB/src/BpBroadPhaseSap.cpp
index e295ca78..53c3dcfe 100644
--- a/PhysX_3.4/Source/LowLevelAABB/src/BpBroadPhaseSap.cpp
+++ b/PhysX_3.4/Source/LowLevelAABB/src/BpBroadPhaseSap.cpp
@@ -461,9 +461,7 @@ void BroadPhaseSap::update(const PxU32 numCpuTasks, PxcScratchAllocator* scratch
if(narrowPhaseUnblockTask)
narrowPhaseUnblockTask->removeReference();
- const bool success = setUpdateData(updateData);
-
- if(success)
+ if(setUpdateData(updateData))
{
mScratchAllocator = scratchAllocator;
@@ -483,6 +481,21 @@ void BroadPhaseSap::update(const PxU32 numCpuTasks, PxcScratchAllocator* scratch
}
}
+void BroadPhaseSap::singleThreadedUpdate(PxcScratchAllocator* scratchAllocator, const BroadPhaseUpdateData& updateData)
+{
+#if PX_CHECKED
+ PX_CHECK_AND_RETURN(scratchAllocator, "BroadPhaseSap::singleThreadedUpdate - scratchAllocator must be non-NULL \n");
+#endif
+
+ if(setUpdateData(updateData))
+ {
+ mScratchAllocator = scratchAllocator;
+ resizeBuffers();
+ update();
+ postUpdate();
+ }
+}
+
bool BroadPhaseSap::setUpdateData(const BroadPhaseUpdateData& updateData)
{
PX_ASSERT(0==mCreatedPairsSize);
diff --git a/PhysX_3.4/Source/LowLevelAABB/src/BpBroadPhaseSap.h b/PhysX_3.4/Source/LowLevelAABB/src/BpBroadPhaseSap.h
index 4ec745db..44f17893 100644
--- a/PhysX_3.4/Source/LowLevelAABB/src/BpBroadPhaseSap.h
+++ b/PhysX_3.4/Source/LowLevelAABB/src/BpBroadPhaseSap.h
@@ -113,33 +113,28 @@ public:
BroadPhaseSap(const PxU32 maxNbBroadPhaseOverlaps, const PxU32 maxNbStaticShapes, const PxU32 maxNbDynamicShapes, PxU64 contextID);
virtual ~BroadPhaseSap();
- virtual void destroy();
+ // BroadPhase
virtual PxBroadPhaseType::Enum getType() const { return PxBroadPhaseType::eSAP; }
-
+ virtual void destroy();
virtual void update(const PxU32 numCpuTasks, PxcScratchAllocator* scratchAllocator, const BroadPhaseUpdateData& updateData, physx::PxBaseTask* continuation, physx::PxBaseTask* narrowPhaseUnblockTask);
virtual void fetchBroadPhaseResults(physx::PxBaseTask*) {}
-
virtual PxU32 getNbCreatedPairs() const { return mCreatedPairsSize; }
virtual BroadPhasePair* getCreatedPairs() { return mCreatedPairsArray; }
virtual PxU32 getNbDeletedPairs() const { return mDeletedPairsSize; }
virtual BroadPhasePair* getDeletedPairs() { return mDeletedPairsArray; }
-
- virtual void resizeBuffers();
virtual void freeBuffers();
-
virtual void shiftOrigin(const PxVec3& shift);
- //~BroadPhase
-
#if PX_CHECKED
virtual bool isValid(const BroadPhaseUpdateData& updateData) const;
#endif
-
virtual BroadPhasePair* getBroadPhasePairs() const {return mPairs.mActivePairs;}
-
virtual void deletePairs();
+ virtual void singleThreadedUpdate(PxcScratchAllocator* scratchAllocator, const BroadPhaseUpdateData& updateData);
+ //~BroadPhase
private:
+ void resizeBuffers();
PxcScratchAllocator* mScratchAllocator;
diff --git a/PhysX_3.4/Source/LowLevelAABB/src/BpSimpleAABBManager.cpp b/PhysX_3.4/Source/LowLevelAABB/src/BpSimpleAABBManager.cpp
index 2e0bc7e0..298f3f00 100644
--- a/PhysX_3.4/Source/LowLevelAABB/src/BpSimpleAABBManager.cpp
+++ b/PhysX_3.4/Source/LowLevelAABB/src/BpSimpleAABBManager.cpp
@@ -2767,6 +2767,9 @@ static void processAggregatePairsParallel(AggPairMap& map, SimpleAABBManager& ma
ProcessAggPairsParallelTask* task = PX_PLACEMENT_NEW(flushPool.allocate(sizeof(ProcessAggPairsParallelTask)), ProcessAggPairsParallelTask)(0, &manager.mMapLock, &manager, &map, taskName);
+
+ PxU32 startIdx = pairTasks.size();
+
for (AggPairMap::Iterator iter = map.getIterator(); !iter.done(); ++iter)
{
task->mAggPairs[task->mNbPairs] = iter->first;
@@ -2775,7 +2778,6 @@ static void processAggregatePairsParallel(AggPairMap& map, SimpleAABBManager& ma
{
pairTasks.pushBack(task);
task->setContinuation(continuation);
- task->removeReference();
//task->runInternal();
task = PX_PLACEMENT_NEW(flushPool.allocate(sizeof(ProcessAggPairsParallelTask)), ProcessAggPairsParallelTask)(0, &manager.mMapLock, &manager, &map, taskName);
}
@@ -2783,6 +2785,12 @@ static void processAggregatePairsParallel(AggPairMap& map, SimpleAABBManager& ma
manager.mMapLock.unlock();
+ for (PxU32 i = startIdx; i < pairTasks.size(); ++i)
+ {
+ pairTasks[i]->removeReference();
+ }
+
+
if (task->mNbPairs)
{
pairTasks.pushBack(task);