aboutsummaryrefslogtreecommitdiff
path: root/PhysX_3.4/Source/LowLevelAABB/src
diff options
context:
space:
mode:
authorSheikh Dawood <[email protected]>2018-05-25 09:54:38 -0500
committerSheikh Dawood <[email protected]>2018-05-25 09:54:38 -0500
commitb99b3783cd7e3fb1bb0a07dc472b2fc000c4cdc1 (patch)
treede67d7adc7cc66d44c3e0a399d94d1db6bcebd0c /PhysX_3.4/Source/LowLevelAABB/src
parentPhysX 3.4, APEX 1.4 patch release @23933511 (diff)
downloadphysx-3.4-b99b3783cd7e3fb1bb0a07dc472b2fc000c4cdc1.tar.xz
physx-3.4-b99b3783cd7e3fb1bb0a07dc472b2fc000c4cdc1.zip
PhysX 3.4, APEX 1.4 patch release @24214033v3.4.2
Diffstat (limited to 'PhysX_3.4/Source/LowLevelAABB/src')
-rw-r--r--PhysX_3.4/Source/LowLevelAABB/src/BpBroadPhase.cpp14
-rw-r--r--PhysX_3.4/Source/LowLevelAABB/src/BpBroadPhaseMBP.cpp198
-rw-r--r--PhysX_3.4/Source/LowLevelAABB/src/BpBroadPhaseMBP.h13
-rw-r--r--PhysX_3.4/Source/LowLevelAABB/src/BpBroadPhaseMBPCommon.h53
-rw-r--r--PhysX_3.4/Source/LowLevelAABB/src/BpBroadPhaseSap.cpp71
-rw-r--r--PhysX_3.4/Source/LowLevelAABB/src/BpBroadPhaseSap.h7
-rw-r--r--PhysX_3.4/Source/LowLevelAABB/src/BpBroadPhaseSapAux.cpp93
-rw-r--r--PhysX_3.4/Source/LowLevelAABB/src/BpBroadPhaseSapAux.h28
-rw-r--r--PhysX_3.4/Source/LowLevelAABB/src/BpMBPTasks.cpp2
-rw-r--r--PhysX_3.4/Source/LowLevelAABB/src/BpMBPTasks.h2
-rw-r--r--PhysX_3.4/Source/LowLevelAABB/src/BpSAPTasks.cpp2
-rw-r--r--PhysX_3.4/Source/LowLevelAABB/src/BpSAPTasks.h2
-rw-r--r--PhysX_3.4/Source/LowLevelAABB/src/BpSimpleAABBManager.cpp217
13 files changed, 431 insertions, 271 deletions
diff --git a/PhysX_3.4/Source/LowLevelAABB/src/BpBroadPhase.cpp b/PhysX_3.4/Source/LowLevelAABB/src/BpBroadPhase.cpp
index a68fe607..5ced7e0e 100644
--- a/PhysX_3.4/Source/LowLevelAABB/src/BpBroadPhase.cpp
+++ b/PhysX_3.4/Source/LowLevelAABB/src/BpBroadPhase.cpp
@@ -23,11 +23,10 @@
// components in life support devices or systems without express written approval of
// NVIDIA Corporation.
//
-// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2008-2018 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
-
#include "BpBroadPhase.h"
#include "BpBroadPhaseSap.h"
#include "BpBroadPhaseMBP.h"
@@ -58,9 +57,7 @@ bool BroadPhaseUpdateData::isValid(const BroadPhaseUpdateData& updateData, const
{
return (updateData.isValid() && bp.isValid(updateData));
}
-#endif
-#if PX_CHECKED
bool BroadPhaseUpdateData::isValid() const
{
const BpHandle* created=getCreatedHandles();
@@ -70,7 +67,6 @@ bool BroadPhaseUpdateData::isValid() const
const PxU32 updatedSize=getNumUpdatedHandles();
const PxU32 removedSize=getNumRemovedHandles();
const PxBounds3* bounds=getAABBs();
- const BpHandle* groups=getGroups();
const PxU32 boxesCapacity=getCapacity();
if(NULL==created && createdSize>0)
@@ -125,10 +121,6 @@ bool BroadPhaseUpdateData::isValid() const
return false;
#endif
}
-
- //Group ids must be less than BP_INVALID_BP_HANDLE.
- if(groups[created[i]]>=BP_INVALID_BP_HANDLE)
- return false;
}
for(PxU32 i=0;i<updatedSize;i++)
@@ -165,10 +157,6 @@ bool BroadPhaseUpdateData::isValid() const
return false;
#endif
}
-
- //Group ids must be less than BP_INVALID_BP_HANDLE.
- if(groups[updated[i]]>=BP_INVALID_BP_HANDLE)
- return false;
}
for(PxU32 i=0;i<removedSize;i++)
diff --git a/PhysX_3.4/Source/LowLevelAABB/src/BpBroadPhaseMBP.cpp b/PhysX_3.4/Source/LowLevelAABB/src/BpBroadPhaseMBP.cpp
index df6ede0c..c43c20cb 100644
--- a/PhysX_3.4/Source/LowLevelAABB/src/BpBroadPhaseMBP.cpp
+++ b/PhysX_3.4/Source/LowLevelAABB/src/BpBroadPhaseMBP.cpp
@@ -23,7 +23,7 @@
// components in life support devices or systems without express written approval of
// NVIDIA Corporation.
//
-// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2008-2018 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
@@ -49,6 +49,25 @@ using namespace physx;
using namespace Bp;
using namespace Cm;
+ static PX_FORCE_INLINE MBP_Handle encodeHandle(MBP_ObjectIndex objectIndex, PxU32 flipFlop, bool isStatic)
+ {
+ /* objectIndex += objectIndex;
+ objectIndex |= flipFlop;
+ return objectIndex;*/
+ return (objectIndex<<2)|(flipFlop<<1)|PxU32(isStatic);
+ }
+
+ static PX_FORCE_INLINE MBP_ObjectIndex decodeHandle_Index(MBP_Handle handle)
+ {
+ // return handle>>1;
+ return handle>>2;
+ }
+
+ static PX_FORCE_INLINE PxU32 decodeHandle_IsStatic(MBP_Handle handle)
+ {
+ return handle&1;
+ }
+
static PX_FORCE_INLINE void storeDwords(PxU32* dest, PxU32 nb, PxU32 value)
{
while(nb--)
@@ -94,7 +113,7 @@ enum MBPFlags
// We have one of those for each of the "200K" objects so we should optimize this size as much as possible
struct MBP_Object : public Ps::UserAllocated
{
- BpHandle mUserID; // ### added for PhysX integration
+ BpHandle mUserID; // Handle sent to us by the AABB manager
PxU16 mNbHandles; // Number of regions the object is part of
PxU16 mFlags; // MBPFlags ### only 1 bit used in the end
@@ -108,12 +127,24 @@ struct MBP_Object : public Ps::UserAllocated
};
// This one is used in each Region
-struct MBPEntry : public MBPEntry_Data, public Ps::UserAllocated
+struct MBPEntry : public Ps::UserAllocated
{
PX_FORCE_INLINE MBPEntry()
{
mMBPHandle = INVALID_ID;
}
+
+ // ### mIndex could be PxU16 but beware, we store mFirstFree there
+ PxU32 mIndex; // Out-to-in, maps user handle to internal array. mIndex indexes either the static or dynamic array.
+ MBP_Handle mMBPHandle; // MBP-level handle (the one returned to users)
+#if PX_DEBUG
+ bool mUpdated;
+#endif
+
+ PX_FORCE_INLINE PxU32 isStatic() const
+ {
+ return decodeHandle_IsStatic(mMBPHandle);
+ }
};
///////////////////////////////////////////////////////////////////////////////
@@ -307,11 +338,11 @@ static PX_FORCE_INLINE void clearBit(BitArray& bitmap, MBP_ObjectIndex objectInd
typedef IAABB MBP_AABB;
#endif
+ // PT: TODO: Consider sharing with AABB Manager dup now
struct MBP_Pair : public Ps::UserAllocated
{
PxU32 id0;
PxU32 id1;
-// void* usrData; // PT: TODO: why is this not used?! Consider sharing with AABB Manager dup now
// TODO: optimize memory here
bool isNew;
bool isUpdated;
@@ -330,11 +361,10 @@ static PX_FORCE_INLINE void clearBit(BitArray& bitmap, MBP_ObjectIndex objectInd
void purge();
void shrinkMemory();
- MBP_Pair* addPair (PxU32 id0, PxU32 id1, const BpHandle* PX_RESTRICT groups = NULL, const MBP_Object* objects = NULL);
- bool removePair (PxU32 id0, PxU32 id1);
-// bool removePairs (const BitArray& array);
- bool removeMarkedPairs (const MBP_Object* objects, BroadPhaseMBP* mbp, const BitArray& updated, const BitArray& removed);
- PX_FORCE_INLINE PxU32 getPairIndex (const MBP_Pair* pair) const
+ MBP_Pair* addPair (PxU32 id0, PxU32 id1);
+ bool removePair (PxU32 id0, PxU32 id1);
+ bool computeCreatedDeletedPairs (const MBP_Object* objects, BroadPhaseMBP* mbp, const BitArray& updated, const BitArray& removed);
+ PX_FORCE_INLINE PxU32 getPairIndex (const MBP_Pair* pair) const
{
return (PxU32((size_t(pair) - size_t(mActivePairs)))/sizeof(MBP_Pair));
}
@@ -347,6 +377,12 @@ static PX_FORCE_INLINE void clearBit(BitArray& bitmap, MBP_ObjectIndex objectInd
MBP_Pair* mActivePairs;
PxU32 mReservedMemory;
+ const Bp::FilterGroup::Enum* mGroups;
+ const MBP_Object* mObjects;
+#ifdef BP_FILTERING_USES_TYPE_IN_GROUP
+ const bool* mLUT;
+#endif
+
PX_FORCE_INLINE MBP_Pair* findPair(PxU32 id0, PxU32 id1, PxU32 hashValue) const;
void removePair(PxU32 id0, PxU32 id1, PxU32 hashValue, PxU32 pairIndex);
void reallocPairs();
@@ -441,7 +477,7 @@ static PX_FORCE_INLINE void clearBit(BitArray& bitmap, MBP_ObjectIndex objectInd
MBP_Handle retrieveBounds(MBP_AABB& bounds, MBP_Index handle) const;
void setBounds(MBP_Index handle, const MBP_AABB& bounds);
void prepareOverlaps();
- void findOverlaps(MBP_PairManager& pairManager, const BpHandle* PX_RESTRICT groups, const MBP_Object* PX_RESTRICT mbpObjects);
+ void findOverlaps(MBP_PairManager& pairManager);
// private:
BoxPruning_Input PX_ALIGN(16, mInput);
@@ -503,19 +539,22 @@ struct RegionData : public Ps::UserAllocated
const Region* getRegion(PxU32 i) const;
PX_FORCE_INLINE PxU32 getNbRegions() const { return mNbRegions; }
- MBP_Handle addObject(const MBP_AABB& box, BpHandle userID, bool isStatic=false);
+ MBP_Handle addObject(const MBP_AABB& box, BpHandle userID, bool isStatic);
bool removeObject(MBP_Handle handle);
bool updateObject(MBP_Handle handle, const MBP_AABB& box);
bool updateObjectAfterRegionRemoval(MBP_Handle handle, Region* removedRegion);
bool updateObjectAfterNewRegionAdded(MBP_Handle handle, const MBP_AABB& box, Region* addedRegion, PxU32 regionIndex);
void prepareOverlaps();
- void findOverlaps(const BpHandle* PX_RESTRICT groups);
+ void findOverlaps(const Bp::FilterGroup::Enum* PX_RESTRICT groups
+#ifdef BP_FILTERING_USES_TYPE_IN_GROUP
+ , const bool* PX_RESTRICT lut
+#endif
+ );
PxU32 finalize(BroadPhaseMBP* mbp);
void shiftOrigin(const PxVec3& shift);
void setTransientBounds(const PxBounds3* bounds, const PxReal* contactDistance);
// private:
- PxU32 mNbPairs;
PxU32 mNbRegions;
MBP_ObjectIndex mFirstFreeIndex; // First free recycled index for mMBP_Objects
PxU32 mFirstFreeIndexBP; // First free recycled index for mRegions
@@ -534,8 +573,8 @@ struct RegionData : public Ps::UserAllocated
Ps::Array<PxU32> mOutOfBoundsObjects; // These are BpHandle but the BP interface expects PxU32s
void addToOutOfBoundsArray(BpHandle id);
- const PxBounds3* mTransientBounds;
- const PxReal* mTransientContactDistance;
+ const PxBounds3* mTransientBounds;
+ const PxReal* mTransientContactDistance;
#ifdef USE_FULLY_INSIDE_FLAG
BitArray mFullyInsideBitmap; // Indexed by MBP_ObjectIndex
@@ -600,7 +639,12 @@ MBP_PairManager::MBP_PairManager() :
mHashTable (NULL),
mNext (NULL),
mActivePairs (NULL),
- mReservedMemory (0)
+ mReservedMemory (0),
+ mGroups (NULL),
+ mObjects (NULL)
+#ifdef BP_FILTERING_USES_TYPE_IN_GROUP
+ ,mLUT (NULL)
+#endif
{
}
@@ -657,20 +701,24 @@ PX_FORCE_INLINE MBP_Pair* MBP_PairManager::findPair(PxU32 id0, PxU32 id1, PxU32
///////////////////////////////////////////////////////////////////////////////
-MBP_Pair* MBP_PairManager::addPair(PxU32 id0, PxU32 id1, const BpHandle* PX_RESTRICT groups, const MBP_Object* objects)
+MBP_Pair* MBP_PairManager::addPair(PxU32 id0, PxU32 id1)
{
PX_ASSERT(id0!=INVALID_ID);
PX_ASSERT(id1!=INVALID_ID);
-
- PX_ASSERT(groups);
+ PX_ASSERT(mGroups);
+ PX_ASSERT(mObjects);
{
const MBP_ObjectIndex index0 = decodeHandle_Index(id0);
const MBP_ObjectIndex index1 = decodeHandle_Index(id1);
- const BpHandle object0 = objects[index0].mUserID;
- const BpHandle object1 = objects[index1].mUserID;
+ const BpHandle object0 = mObjects[index0].mUserID;
+ const BpHandle object1 = mObjects[index1].mUserID;
- if(groups[object0] == groups[object1])
+#ifdef BP_FILTERING_USES_TYPE_IN_GROUP
+ if(!groupFiltering(mGroups[object0], mGroups[object1], mLUT))
+#else
+ if(!groupFiltering(mGroups[object0], mGroups[object1]))
+#endif
return NULL;
}
@@ -908,9 +956,6 @@ void MBP_PairManager::reserveMemory(PxU32 memSize)
#define SIMD_OVERLAP_PRELOAD_BOX0
#endif
-
-
-
#ifdef MBP_USE_NO_CMP_OVERLAP
/*static PX_FORCE_INLINE void initBox(IAABB& box, const PxBounds3& src)
{
@@ -1110,6 +1155,7 @@ void Region::optimizeMemory()
void Region::resizeObjects()
{
const PxU32 newMaxNbOjects = mMaxNbObjects ? mMaxNbObjects + DEFAULT_NB_ENTRIES : DEFAULT_NB_ENTRIES;
+// const PxU32 newMaxNbOjects = mMaxNbObjects ? mMaxNbObjects*2 : DEFAULT_NB_ENTRIES;
MBPEntry* newObjects = PX_NEW(MBPEntry)[newMaxNbOjects];
if(mNbObjects)
PxMemCopy(newObjects, mObjects, mNbObjects*sizeof(MBPEntry));
@@ -1191,6 +1237,7 @@ MBP_Index Region::addObject(const MBP_AABB& bounds, MBP_Handle mbpHandle, bool i
if(mMaxNbStaticBoxes==mNbStaticBoxes)
{
const PxU32 newMaxNbBoxes = mMaxNbStaticBoxes ? mMaxNbStaticBoxes + DEFAULT_NB_ENTRIES : DEFAULT_NB_ENTRIES;
+// const PxU32 newMaxNbBoxes = mMaxNbStaticBoxes ? mMaxNbStaticBoxes*2 : DEFAULT_NB_ENTRIES;
mStaticBoxes = resizeBoxes(mNbStaticBoxes, newMaxNbBoxes, mStaticBoxes);
mInToOut_Static = resizeMapping(mNbStaticBoxes, newMaxNbBoxes, mInToOut_Static);
mMaxNbStaticBoxes = newMaxNbBoxes;
@@ -1207,6 +1254,7 @@ MBP_Index Region::addObject(const MBP_AABB& bounds, MBP_Handle mbpHandle, bool i
if(mMaxNbDynamicBoxes==mNbDynamicBoxes)
{
const PxU32 newMaxNbBoxes = mMaxNbDynamicBoxes ? mMaxNbDynamicBoxes + DEFAULT_NB_ENTRIES : DEFAULT_NB_ENTRIES;
+// const PxU32 newMaxNbBoxes = mMaxNbDynamicBoxes ? mMaxNbDynamicBoxes*2 : DEFAULT_NB_ENTRIES;
mDynamicBoxes = resizeBoxes(mNbDynamicBoxes, newMaxNbBoxes, mDynamicBoxes);
mInToOut_Dynamic = resizeMapping(mNbDynamicBoxes, newMaxNbBoxes, mInToOut_Dynamic);
mMaxNbDynamicBoxes = newMaxNbBoxes;
@@ -1258,7 +1306,6 @@ void Region::removeObject(MBP_Index handle)
MBP_Index* PX_RESTRICT mapping;
MBP_AABB* PX_RESTRICT boxes;
PxU32 lastIndex;
- PxU32 maxNbBoxes;
if(!object.isStatic())
{
mPrevNbUpdatedBoxes = 0;
@@ -1295,7 +1342,6 @@ void Region::removeObject(MBP_Index handle)
mapping = mInToOut_Dynamic;
boxes = mDynamicBoxes;
lastIndex = --mNbDynamicBoxes;
- maxNbBoxes = mMaxNbDynamicBoxes;
// ### adjust size of mPosList ?
}
@@ -1310,16 +1356,9 @@ void Region::removeObject(MBP_Index handle)
mapping = mInToOut_Static;
boxes = mStaticBoxes;
lastIndex = --mNbStaticBoxes;
- maxNbBoxes = mMaxNbStaticBoxes;
}
remove(mObjects, mapping, boxes, removedBoxIndex, lastIndex);
- PX_UNUSED(maxNbBoxes);
-/* if(lastIndex+DEFAULT_NB_ENTRIES<maxNbBoxes/2)
- {
- int stop=1;
- }*/
-
object.mIndex = mFirstFree;
object.mMBPHandle = INVALID_ID;
// printf("Invalid: %d\n", handle);
@@ -1451,8 +1490,7 @@ static PxU32 gNbOverlaps = 0;
static PX_FORCE_INLINE void outputPair( MBP_PairManager& pairManager,
PxU32 index0, PxU32 index1,
const MBP_Index* PX_RESTRICT inToOut0, const MBP_Index* PX_RESTRICT inToOut1,
- const MBPEntry* PX_RESTRICT objects,
- const BpHandle* PX_RESTRICT groups, const MBP_Object* PX_RESTRICT mbpObjects)
+ const MBPEntry* PX_RESTRICT objects)
{
#ifdef CHECK_NB_OVERLAPS
gNbOverlaps++;
@@ -1464,7 +1502,7 @@ static PX_FORCE_INLINE void outputPair( MBP_PairManager& pairManager,
const MBP_Handle id1 = objects[objectIndex1].mMBPHandle;
// printf("2: %d %d\n", index0, index1);
// printf("3: %d %d\n", objectIndex0, objectIndex1);
- pairManager.addPair(id0, id1, groups, mbpObjects);
+ pairManager.addPair(id0, id1);
}
MBPOS_TmpBuffers::MBPOS_TmpBuffers() :
@@ -1483,14 +1521,11 @@ MBPOS_TmpBuffers::~MBPOS_TmpBuffers()
MBP_FREE(mInToOut_Dynamic_Sleeping);
if(mSleepingDynamicBoxes!=mSleepingDynamicBoxes_Stack)
- {
DELETEARRAY(mSleepingDynamicBoxes);
- }
if(mUpdatedDynamicBoxes!=mUpdatedDynamicBoxes_Stack)
- {
DELETEARRAY(mUpdatedDynamicBoxes);
- }
+
mNbSleeping = 0;
mNbUpdated = 0;
}
@@ -1502,9 +1537,7 @@ void MBPOS_TmpBuffers::allocateSleeping(PxU32 nbSleeping, PxU32 nbSentinels)
if(mInToOut_Dynamic_Sleeping!=mInToOut_Dynamic_Sleeping_Stack)
MBP_FREE(mInToOut_Dynamic_Sleeping);
if(mSleepingDynamicBoxes!=mSleepingDynamicBoxes_Stack)
- {
DELETEARRAY(mSleepingDynamicBoxes);
- }
if(nbSleeping+nbSentinels<=STACK_BUFFER_SIZE)
{
@@ -1525,16 +1558,13 @@ void MBPOS_TmpBuffers::allocateUpdated(PxU32 nbUpdated, PxU32 nbSentinels)
if(nbUpdated>mNbUpdated)
{
if(mUpdatedDynamicBoxes!=mUpdatedDynamicBoxes_Stack)
- {
DELETEARRAY(mUpdatedDynamicBoxes);
- }
if(nbUpdated+nbSentinels<=STACK_BUFFER_SIZE)
mUpdatedDynamicBoxes = mUpdatedDynamicBoxes_Stack;
else
- {
mUpdatedDynamicBoxes = PX_NEW_TEMP(MBP_AABB)[nbUpdated+nbSentinels];
- }
+
mNbUpdated = nbUpdated;
}
}
@@ -1714,7 +1744,7 @@ void Region::prepareBIPPruning(const MBPOS_TmpBuffers& buffers)
mInput.mBIPInput.mNeeded = true;
}
-static void doCompleteBoxPruning(MBP_PairManager* PX_RESTRICT pairManager, const BoxPruning_Input& input, const BpHandle* PX_RESTRICT groups, const MBP_Object* PX_RESTRICT mbpObjects)
+static void doCompleteBoxPruning(MBP_PairManager* PX_RESTRICT pairManager, const BoxPruning_Input& input)
{
const MBPEntry* PX_RESTRICT objects = input.mObjects;
const MBP_AABB* PX_RESTRICT updatedDynamicBoxes = input.mUpdatedDynamicBoxes;
@@ -1726,6 +1756,7 @@ static void doCompleteBoxPruning(MBP_PairManager* PX_RESTRICT pairManager, const
//
+ // PT: find sleeping-dynamics-vs-active-dynamics overlaps
if(nbNonUpdated)
{
const PxU32 nb0 = nbUpdated;
@@ -1751,7 +1782,7 @@ static void doCompleteBoxPruning(MBP_PairManager* PX_RESTRICT pairManager, const
{
MBP_OVERLAP_TEST(sleepingDynamicBoxes[index1])
{
- outputPair(*pairManager, index0, index1, inToOut_Dynamic, inToOut_Dynamic_Sleeping, objects, groups, mbpObjects);
+ outputPair(*pairManager, index0, index1, inToOut_Dynamic, inToOut_Dynamic_Sleeping, objects);
}
index1++;
}
@@ -1778,7 +1809,7 @@ static void doCompleteBoxPruning(MBP_PairManager* PX_RESTRICT pairManager, const
{
MBP_OVERLAP_TEST(updatedDynamicBoxes[index1])
{
- outputPair(*pairManager, index1, index0, inToOut_Dynamic, inToOut_Dynamic_Sleeping, objects, groups, mbpObjects);
+ outputPair(*pairManager, index1, index0, inToOut_Dynamic, inToOut_Dynamic_Sleeping, objects);
}
index1++;
}
@@ -1788,7 +1819,8 @@ static void doCompleteBoxPruning(MBP_PairManager* PX_RESTRICT pairManager, const
///////
- // Prune the list
+ // PT: find active-dynamics-vs-active-dynamics overlaps
+
PxU32 index0 = 0;
PxU32 runningIndex = 0;
while(runningIndex<nbUpdated && index0<nbUpdated)
@@ -1808,7 +1840,7 @@ static void doCompleteBoxPruning(MBP_PairManager* PX_RESTRICT pairManager, const
{
MBP_OVERLAP_TEST(updatedDynamicBoxes[index1])
{
- outputPair(*pairManager, index0, index1, inToOut_Dynamic, inToOut_Dynamic, objects, groups, mbpObjects);
+ outputPair(*pairManager, index0, index1, inToOut_Dynamic, inToOut_Dynamic, objects);
}
index1++;
}
@@ -1817,7 +1849,7 @@ static void doCompleteBoxPruning(MBP_PairManager* PX_RESTRICT pairManager, const
}
}
-static void doBipartiteBoxPruning(MBP_PairManager* PX_RESTRICT pairManager, const BIP_Input& input, const BpHandle* PX_RESTRICT groups, const MBP_Object* PX_RESTRICT mbpObjects)
+static void doBipartiteBoxPruning(MBP_PairManager* PX_RESTRICT pairManager, const BIP_Input& input)
{
// ### crashes because the code expects the dynamic array to be sorted, but mDynamicBoxes is not
// ### we should instead modify mNbUpdatedBoxes so that mNbUpdatedBoxes == mNbDynamicBoxes, and
@@ -1859,7 +1891,7 @@ static void doBipartiteBoxPruning(MBP_PairManager* PX_RESTRICT pairManager, cons
{
MBP_OVERLAP_TEST(staticBoxes[index1])
{
- outputPair(*pairManager, index0, index1, inToOut_Dynamic, inToOut_Static, mObjects, groups, mbpObjects);
+ outputPair(*pairManager, index0, index1, inToOut_Dynamic, inToOut_Static, mObjects);
}
index1++;
}
@@ -1886,7 +1918,7 @@ static void doBipartiteBoxPruning(MBP_PairManager* PX_RESTRICT pairManager, cons
{
MBP_OVERLAP_TEST(dynamicBoxes[index1])
{
- outputPair(*pairManager, index1, index0, inToOut_Dynamic, inToOut_Static, mObjects, groups, mbpObjects);
+ outputPair(*pairManager, index1, index0, inToOut_Dynamic, inToOut_Static, mObjects);
}
index1++;
}
@@ -1901,9 +1933,7 @@ static void doBipartiteBoxPruning(MBP_PairManager* PX_RESTRICT pairManager, cons
void Region::prepareOverlaps()
{
- if(!mNbUpdatedBoxes
- && !mNeedsSorting //### bugfix added for PhysX integration
- )
+ if(!mNbUpdatedBoxes && !mNeedsSorting)
return;
if(mNeedsSorting)
@@ -1917,7 +1947,7 @@ void Region::prepareOverlaps()
// a) skip the actual pruning in PreparePruning() (we only need to re-sort)
// b) do BipartiteBoxPruning() with the new/modified boxes, not all of them
// Well, not done yet.
- mNbUpdatedBoxes = mNbDynamicBoxes; // ### PhysX
+ mNbUpdatedBoxes = mNbDynamicBoxes;
mPrevNbUpdatedBoxes = 0;
mNeedsSortingSleeping = true;
#if PX_DEBUG
@@ -1933,17 +1963,17 @@ void Region::prepareOverlaps()
prepareBIPPruning(mTmpBuffers);
}
-void Region::findOverlaps(MBP_PairManager& pairManager, const BpHandle* PX_RESTRICT groups, const MBP_Object* PX_RESTRICT mbpObjects)
+void Region::findOverlaps(MBP_PairManager& pairManager)
{
PX_ASSERT(!mNeedsSorting);
if(!mNbUpdatedBoxes)
return;
if(mInput.mNeeded)
- doCompleteBoxPruning(&pairManager, mInput, groups, mbpObjects);
+ doCompleteBoxPruning(&pairManager, mInput);
if(mInput.mBIPInput.mNeeded)
- doBipartiteBoxPruning(&pairManager, mInput.mBIPInput, groups, mbpObjects);
+ doBipartiteBoxPruning(&pairManager, mInput.mBIPInput);
mNbUpdatedBoxes = 0;
}
@@ -1951,7 +1981,6 @@ void Region::findOverlaps(MBP_PairManager& pairManager, const BpHandle* PX_RESTR
///////////////////////////////////////////////////////////////////////////
MBP::MBP() :
- mNbPairs (0),
mNbRegions (0),
mFirstFreeIndex (INVALID_ID),
mFirstFreeIndexBP (INVALID_ID)
@@ -2958,7 +2987,7 @@ bool MBP::updateObjectAfterNewRegionAdded(MBP_Handle handle, const MBP_AABB& box
return true;
}
-bool MBP_PairManager::removeMarkedPairs(const MBP_Object* objects, BroadPhaseMBP* mbp, const BitArray& updated, const BitArray& removed)
+bool MBP_PairManager::computeCreatedDeletedPairs(const MBP_Object* objects, BroadPhaseMBP* mbp, const BitArray& updated, const BitArray& removed)
{
// PT: parse all currently active pairs. The goal here is to generate the found/lost pairs, compared to previous frame.
PxU32 i=0;
@@ -3055,22 +3084,33 @@ void MBP::prepareOverlaps()
}
}
-void MBP::findOverlaps(const BpHandle* PX_RESTRICT groups)
+void MBP::findOverlaps(const Bp::FilterGroup::Enum* PX_RESTRICT groups
+#ifdef BP_FILTERING_USES_TYPE_IN_GROUP
+ , const bool* PX_RESTRICT lut
+#endif
+ )
{
PxU32 nb = mNbRegions;
const RegionData* PX_RESTRICT regions = mRegions.begin();
const MBP_Object* objects = mMBP_Objects.begin();
+
+ mPairManager.mObjects = objects;
+ mPairManager.mGroups = groups;
+#ifdef BP_FILTERING_USES_TYPE_IN_GROUP
+ mPairManager.mLUT = lut;
+#endif
+
for(PxU32 i=0;i<nb;i++)
{
if(regions[i].mBP)
- regions[i].mBP->findOverlaps(mPairManager, groups, objects);
+ regions[i].mBP->findOverlaps(mPairManager);
}
}
PxU32 MBP::finalize(BroadPhaseMBP* mbp)
{
const MBP_Object* objects = mMBP_Objects.begin();
- mPairManager.removeMarkedPairs(objects, mbp, mUpdatedObjects, mRemoved);
+ mPairManager.computeCreatedDeletedPairs(objects, mbp, mUpdatedObjects, mRemoved);
mUpdatedObjects.clearAll();
@@ -3088,7 +3128,6 @@ void MBP::reset()
regions++;
}
- mNbPairs = 0;
mNbRegions = 0;
mFirstFreeIndex = INVALID_ID;
mFirstFreeIndexBP = INVALID_ID;
@@ -3183,8 +3222,10 @@ BroadPhaseMBP::BroadPhaseMBP( PxU32 maxNbRegions,
mMapping (NULL),
mCapacity (0),
mGroups (NULL)
+#ifdef BP_FILTERING_USES_TYPE_IN_GROUP
+ ,mLUT (NULL)
+#endif
{
-
mMBP = PX_NEW(MBP)();
const PxU32 nbObjects = maxNbStaticShapes + maxNbDynamicShapes;
@@ -3283,11 +3324,6 @@ bool BroadPhaseMBP::removeRegion(PxU32 handle)
return mMBP->removeRegion(handle);
}
-void BroadPhaseMBP::destroy()
-{
- delete this;
-}
-
void BroadPhaseMBP::update(const PxU32 numCpuTasks, PxcScratchAllocator* scratchAllocator, const BroadPhaseUpdateData& updateData, physx::PxBaseTask* continuation, physx::PxBaseTask* narrowPhaseUnblockTask)
{
#if PX_CHECKED
@@ -3425,7 +3461,7 @@ void BroadPhaseMBP::addObjects(const BroadPhaseUpdateData& updateData)
if(created)
{
const PxBounds3* PX_RESTRICT boundsXYZ = updateData.getAABBs();
- const BpHandle* PX_RESTRICT groups = updateData.getGroups();
+ const Bp::FilterGroup::Enum* PX_RESTRICT groups = updateData.getGroups();
PxU32 nbToGo = updateData.getNumCreatedHandles();
while(nbToGo--)
@@ -3453,6 +3489,7 @@ void BroadPhaseMBP::setUpdateData(const BroadPhaseUpdateData& updateData)
allocateMappingArray(newCapacity);
#if PX_CHECKED
+ // PT: WARNING: this must be done after the allocateMappingArray call
if(!BroadPhaseUpdateData::isValid(updateData, *this))
{
PX_CHECK_MSG(false, "Illegal BroadPhaseUpdateData \n");
@@ -3460,7 +3497,10 @@ void BroadPhaseMBP::setUpdateData(const BroadPhaseUpdateData& updateData)
}
#endif
- mGroups = updateData.getGroups(); // ### why are those 'handles'?
+ mGroups = updateData.getGroups();
+#ifdef BP_FILTERING_USES_TYPE_IN_GROUP
+ mLUT = updateData.getLUT();
+#endif
// ### TODO: handle groups inside MBP
// ### TODO: get rid of AABB conversions
@@ -3480,7 +3520,11 @@ void BroadPhaseMBP::update()
#ifdef CHECK_NB_OVERLAPS
gNbOverlaps = 0;
#endif
- mMBP->findOverlaps(mGroups);
+ mMBP->findOverlaps(mGroups
+#ifdef BP_FILTERING_USES_TYPE_IN_GROUP
+ , mLUT
+#endif
+ );
#ifdef CHECK_NB_OVERLAPS
printf("PPU: %d overlaps\n", gNbOverlaps);
#endif
diff --git a/PhysX_3.4/Source/LowLevelAABB/src/BpBroadPhaseMBP.h b/PhysX_3.4/Source/LowLevelAABB/src/BpBroadPhaseMBP.h
index 465599cc..eb302c2e 100644
--- a/PhysX_3.4/Source/LowLevelAABB/src/BpBroadPhaseMBP.h
+++ b/PhysX_3.4/Source/LowLevelAABB/src/BpBroadPhaseMBP.h
@@ -23,7 +23,7 @@
// components in life support devices or systems without express written approval of
// NVIDIA Corporation.
//
-// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2008-2018 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
@@ -33,7 +33,6 @@
#include "CmPhysXCommon.h"
#include "BpBroadPhase.h"
#include "BpBroadPhaseMBPCommon.h"
-#include "PsUserAllocated.h"
#include "BpMBPTasks.h"
class MBP;
@@ -69,7 +68,7 @@ namespace Bp
// BroadPhase
virtual PxBroadPhaseType::Enum getType() const { return PxBroadPhaseType::eMBP; }
- virtual void destroy();
+ 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*) {}
@@ -88,9 +87,7 @@ namespace Bp
#endif
virtual BroadPhasePair* getBroadPhasePairs() const {return NULL;} //KS - TODO - implement this!!!
-
virtual void deletePairs(){} //KS - TODO - implement this!!!
-
//~BroadPhase
MBPUpdateWorkTask mMBPUpdateWorkTask;
@@ -103,8 +100,10 @@ namespace Bp
Ps::Array<BroadPhasePair> mCreated;
Ps::Array<BroadPhasePair> mDeleted;
- const BpHandle* mGroups; // ### why are those 'handles'?
-
+ const Bp::FilterGroup::Enum*mGroups;
+#ifdef BP_FILTERING_USES_TYPE_IN_GROUP
+ const bool* mLUT;
+#endif
void setUpdateData(const BroadPhaseUpdateData& updateData);
void addObjects(const BroadPhaseUpdateData& updateData);
void removeObjects(const BroadPhaseUpdateData& updateData);
diff --git a/PhysX_3.4/Source/LowLevelAABB/src/BpBroadPhaseMBPCommon.h b/PhysX_3.4/Source/LowLevelAABB/src/BpBroadPhaseMBPCommon.h
index 1b9e9239..149ff28e 100644
--- a/PhysX_3.4/Source/LowLevelAABB/src/BpBroadPhaseMBPCommon.h
+++ b/PhysX_3.4/Source/LowLevelAABB/src/BpBroadPhaseMBPCommon.h
@@ -23,7 +23,7 @@
// components in life support devices or systems without express written approval of
// NVIDIA Corporation.
//
-// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2008-2018 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
@@ -53,57 +53,6 @@ namespace Bp
typedef PxU32 MBP_ObjectIndex; // PT: index in mMBP_Objects
typedef PxU32 MBP_Handle; // PT: returned to MBP users, combination of index/flip-flop/static-bit
- PX_FORCE_INLINE MBP_Handle encodeHandle(MBP_ObjectIndex objectIndex, PxU32 flipFlop, bool isStatic)
- {
- /* objectIndex += objectIndex;
- objectIndex |= flipFlop;
- return objectIndex;*/
- return (objectIndex<<2)|(flipFlop<<1)|PxU32(isStatic);
- }
-
- PX_FORCE_INLINE MBP_ObjectIndex decodeHandle_Index(MBP_Handle handle)
- {
- // return handle>>1;
- return handle>>2;
- }
-
- PX_FORCE_INLINE PxU32 decodeHandle_IsStatic(MBP_Handle handle)
- {
- return handle&1;
- }
-
- struct MBPEntry_Data
- {
- #if PX_DEBUG
- bool mUpdated;
- #endif
-
- // ### mIndex could be PxU16 but beware, we store mFirstFree there
- PxU32 mIndex; // Out-to-in, maps user handle to internal array. mIndex indexes either the static or dynamic array.
- MBP_Handle mMBPHandle; // MBP-level handle (the one returned to users)
-
- PX_FORCE_INLINE PxU32 isStatic() const
- {
- return decodeHandle_IsStatic(mMBPHandle);
- }
- };
-
-// #define MBP_MAX_NB_OVERLAPS 4096
- #define MBP_MAX_NB_OVERLAPS 8192
- struct MBP_Overlap
- {
- PxU16 mIndex0;
- PxU16 mIndex1;
- };
-
-// #define MBP_BOX_CACHE_SIZE (16)
-// #define MBP_BOX_CACHE_SIZE (16*2)
-// #define MBP_BOX_CACHE_SIZE (16*4)
-// #define MBP_BOX_CACHE_SIZE (16*8)
-// #define MBP_BOX_CACHE_SIZE (16*16)
- #define MBP_BOX_CACHE_SIZE (16*32)
-// #define MBP_BOX_CACHE_SIZE (16*64)
-
struct IAABB : public Ps::UserAllocated
{
PX_FORCE_INLINE bool isInside(const IAABB& box) const
diff --git a/PhysX_3.4/Source/LowLevelAABB/src/BpBroadPhaseSap.cpp b/PhysX_3.4/Source/LowLevelAABB/src/BpBroadPhaseSap.cpp
index 9a85dbf2..d8aa0b54 100644
--- a/PhysX_3.4/Source/LowLevelAABB/src/BpBroadPhaseSap.cpp
+++ b/PhysX_3.4/Source/LowLevelAABB/src/BpBroadPhaseSap.cpp
@@ -23,7 +23,7 @@
// components in life support devices or systems without express written approval of
// NVIDIA Corporation.
//
-// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2008-2018 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
@@ -135,6 +135,10 @@ BroadPhaseSap::BroadPhaseSap(
mDeletedPairsCapacity = 0;
mDeletedPairsSize = 0;
mActualDeletedPairSize = 0;
+
+#ifdef BP_FILTERING_USES_TYPE_IN_GROUP
+ mLUT = NULL;
+#endif
}
BroadPhaseSap::~BroadPhaseSap()
@@ -350,8 +354,6 @@ void BroadPhaseSap::shiftOrigin(const PxVec3& shift)
#if PX_CHECKED
bool BroadPhaseSap::isValid(const BroadPhaseUpdateData& updateData) const
{
- PX_UNUSED(updateData);
-#if 0
//Test that the created bounds haven't been added already (without first being removed).
const BpHandle* created=updateData.getCreatedHandles();
const PxU32 numCreated=updateData.getNumCreatedHandles();
@@ -446,7 +448,6 @@ bool BroadPhaseSap::isValid(const BroadPhaseUpdateData& updateData) const
}
}
}
-#endif
return true;
}
#endif
@@ -512,6 +513,9 @@ bool BroadPhaseSap::setUpdateData(const BroadPhaseUpdateData& updateData)
mRemovedSize = updateData.getNumRemovedHandles();
mBoxBoundsMinMax = updateData.getAABBs();
mBoxGroups = updateData.getGroups();
+#ifdef BP_FILTERING_USES_TYPE_IN_GROUP
+ mLUT = updateData.getLUT();
+#endif
mContactDistance = updateData.getContactDistance();
//Do we need more memory to store the positions of each box min/max in the arrays of sorted boxes min/max?
@@ -749,7 +753,6 @@ static PX_FORCE_INLINE bool Intersect3D(const ValType bDir1Min, const ValType bD
bDir3Max >= cDir3Min && cDir3Max >= bDir3Min);
}
-PX_COMPILE_TIME_ASSERT(FilterGroup::eSTATICS==0);
void BroadPhaseSap::ComputeSortedLists( BpHandle* PX_RESTRICT newBoxIndicesSorted, PxU32& newBoxIndicesCount, BpHandle* PX_RESTRICT oldBoxIndicesSorted, PxU32& oldBoxIndicesCount,
bool& allNewBoxesStatics, bool& allOldBoxesStatics)
{
@@ -769,7 +772,7 @@ void BroadPhaseSap::ComputeSortedLists( BpHandle* PX_RESTRICT newBoxIndicesSorte
const PxU32 insertAABBEnd = mCreatedSize;
const BpHandle* PX_RESTRICT createdAABBs = mCreated;
SapBox1D** PX_RESTRICT asapBoxes = mBoxEndPts;
- const BpHandle* PX_RESTRICT asapBoxGroupIds = mBoxGroups;
+ const Bp::FilterGroup::Enum* PX_RESTRICT asapBoxGroupIds = mBoxGroups;
BpHandle* PX_RESTRICT asapEndPointDatas = mEndPointDatas[axis0];
const PxU32 numSortedEndPoints = mBoxesSize*2 + NUM_SENTINELS;
@@ -828,15 +831,14 @@ void BroadPhaseSap::ComputeSortedLists( BpHandle* PX_RESTRICT newBoxIndicesSorte
asapBoxes[axis2][boxId].mMinMax[1]))
{
oldBoxIndicesSorted[oldBoxIndicesCount++] = boxId;
- oldStaticCount += asapBoxGroupIds[boxId]; // (*)
+ oldStaticCount += asapBoxGroupIds[boxId]==FilterGroup::eSTATICS ? 0 : 1;
}
}
- else
+ else
{
newBoxIndicesSorted[newBoxIndicesCount++] = boxId;
- newStaticCount += asapBoxGroupIds[boxId]; // (*)
+ newStaticCount += asapBoxGroupIds[boxId]==FilterGroup::eSTATICS ? 0 : 1;
}
- // (*) PT: warning, this will break if we put kinematics in the same group as statics to disable collisions!
}
}
@@ -968,7 +970,11 @@ void BroadPhaseSap::batchCreate()
if(!allNewBoxesStatics)
{
- performBoxPruningNewNew(&data0, mScratchAllocator, mPairs, mData, mDataSize, mDataCapacity);
+ performBoxPruningNewNew(&data0, mScratchAllocator,
+#ifdef BP_FILTERING_USES_TYPE_IN_GROUP
+ mLUT,
+#endif
+ mPairs, mData, mDataSize, mDataCapacity);
}
// the old boxes are not the first ones in the array
@@ -978,7 +984,11 @@ void BroadPhaseSap::batchCreate()
{
const AuxData data1(oldBoxCount, mBoxEndPts, oldBoxesIndicesSorted, mBoxGroups);
- performBoxPruningNewOld(&data0, &data1, mScratchAllocator, mPairs, mData, mDataSize, mDataCapacity);
+ performBoxPruningNewOld(&data0, &data1, mScratchAllocator,
+#ifdef BP_FILTERING_USES_TYPE_IN_GROUP
+ mLUT,
+#endif
+ mPairs, mData, mDataSize, mDataCapacity);
}
}
}
@@ -1023,7 +1033,6 @@ void BroadPhaseSap::batchRemove()
MinMinIndex = MinIndex;
}
-
PxU32 ReadIndex = MinMinIndex;
PxU32 DestIndex = MinMinIndex;
const PxU32 Limit = mBoxesSize*2+NUM_SENTINELS;
@@ -1123,9 +1132,8 @@ void BroadPhaseSap::batchUpdate
const SapBox1D* PX_RESTRICT boxMinMax0=boxMinMax2D[2*Axis+0];
const SapBox1D* PX_RESTRICT boxMinMax1=boxMinMax2D[2*Axis+1];
-
#if BP_SAP_TEST_GROUP_ID_CREATEUPDATE
- const BpHandle* PX_RESTRICT asapBoxGroupIds=mBoxGroups;
+ const Bp::FilterGroup::Enum* PX_RESTRICT asapBoxGroupIds=mBoxGroups;
#endif
SapBox1D* PX_RESTRICT asapBoxes=mBoxEndPts[Axis];
@@ -1169,7 +1177,6 @@ void BroadPhaseSap::batchUpdate
currentPocket->mEndIndex = 0;
currentPocket->mStartIndex = 0;
-
BpHandle ind = 2;
PxU8 wasUpdated = updated[startHandle];
for(; !isSentinel(BaseEPDatas[ind]); ++ind)
@@ -1187,7 +1194,6 @@ void BroadPhaseSap::batchUpdate
const BpHandle startIsMax = isMax(ThisData);
-
//Access and write back the updated values. TODO - can we avoid this when we're walking through inactive nodes?
//BPValType ThisValue = boxMinMax1D[Axis][twoHandle+startIsMax];
//BPValType ThisValue = startIsMax ? boxMinMax3D[handle].getMax(Axis) : boxMinMax3D[handle].getMin(Axis);
@@ -1223,9 +1229,8 @@ void BroadPhaseSap::batchUpdate
PxU32 startIndex = ind;
#if BP_SAP_TEST_GROUP_ID_CREATEUPDATE
- ValType group = asapBoxGroupIds[handle];
+ const Bp::FilterGroup::Enum group = asapBoxGroupIds[handle];
#endif
-
if(!isMax(ThisData))
{
do
@@ -1247,7 +1252,11 @@ void BroadPhaseSap::batchUpdate
boxMinMax0[ownerId].mMinMax[0],boxMinMax0[ownerId].mMinMax[1],boxMinMax1[ownerId].mMinMax[0],boxMinMax1[ownerId].mMinMax[1])
#if BP_SAP_TEST_GROUP_ID_CREATEUPDATE
- && (group!=asapBoxGroupIds[ownerId])
+ #ifdef BP_FILTERING_USES_TYPE_IN_GROUP
+ && groupFiltering(group, asapBoxGroupIds[ownerId], mLUT)
+ #else
+ && groupFiltering(group, asapBoxGroupIds[ownerId])
+ #endif
#else
&& handle!=ownerId
#endif
@@ -1294,7 +1303,11 @@ void BroadPhaseSap::batchUpdate
boxMinMax0[ownerId].mMinMax[0],boxMinMax0[ownerId].mMinMax[1],boxMinMax1[ownerId].mMinMax[0],boxMinMax1[ownerId].mMinMax[1])
#endif
#if BP_SAP_TEST_GROUP_ID_CREATEUPDATE
- && (group!=asapBoxGroupIds[ownerId])
+ #ifdef BP_FILTERING_USES_TYPE_IN_GROUP
+ && groupFiltering(group, asapBoxGroupIds[ownerId], mLUT)
+ #else
+ && groupFiltering(group, asapBoxGroupIds[ownerId])
+ #endif
#else
&& handle!=ownerId
#endif
@@ -1429,7 +1442,7 @@ void BroadPhaseSap::batchUpdateFewUpdates
SapBox1D* boxMinMax2D[6]={mBoxEndPts[1],mBoxEndPts[2],mBoxEndPts[2],mBoxEndPts[0],mBoxEndPts[0],mBoxEndPts[1]};
#if BP_SAP_TEST_GROUP_ID_CREATEUPDATE
- const BpHandle* PX_RESTRICT asapBoxGroupIds=mBoxGroups;
+ const Bp::FilterGroup::Enum* PX_RESTRICT asapBoxGroupIds=mBoxGroups;
#endif
SapBox1D* PX_RESTRICT asapBoxes=mBoxEndPts[Axis];
@@ -1559,7 +1572,7 @@ void BroadPhaseSap::batchUpdateFewUpdates
//const BPValType* PX_RESTRICT box0MinMax0 = &boxMinMax0[twoHandle];
//const BPValType* PX_RESTRICT box0MinMax1 = &boxMinMax1[twoHandle];
#if BP_SAP_TEST_GROUP_ID_CREATEUPDATE
- ValType group = asapBoxGroupIds[handle];
+ const Bp::FilterGroup::Enum group = asapBoxGroupIds[handle];
#endif
if(!isMax(ThisData))
{
@@ -1581,7 +1594,11 @@ void BroadPhaseSap::batchUpdateFewUpdates
Intersect2D_Handle(boxMinMax0[handle].mMinMax[0], boxMinMax0[handle].mMinMax[1], boxMinMax1[handle].mMinMax[0], boxMinMax1[handle].mMinMax[1],
boxMinMax0[ownerId].mMinMax[0],boxMinMax0[ownerId].mMinMax[1],boxMinMax1[ownerId].mMinMax[0],boxMinMax1[ownerId].mMinMax[1])
#if BP_SAP_TEST_GROUP_ID_CREATEUPDATE
- && (group!=asapBoxGroupIds[ownerId])
+ #ifdef BP_FILTERING_USES_TYPE_IN_GROUP
+ && groupFiltering(group, asapBoxGroupIds[ownerId], mLUT)
+ #else
+ && groupFiltering(group, asapBoxGroupIds[ownerId])
+ #endif
#else
&& Object!=id1
#endif
@@ -1628,7 +1645,11 @@ void BroadPhaseSap::batchUpdateFewUpdates
boxMinMax0[ownerId].mMinMax[0],boxMinMax0[ownerId].mMinMax[1],boxMinMax1[ownerId].mMinMax[0],boxMinMax1[ownerId].mMinMax[1])
#endif
#if BP_SAP_TEST_GROUP_ID_CREATEUPDATE
- && (group!=asapBoxGroupIds[ownerId])
+ #ifdef BP_FILTERING_USES_TYPE_IN_GROUP
+ && groupFiltering(group, asapBoxGroupIds[ownerId], mLUT)
+ #else
+ && groupFiltering(group, asapBoxGroupIds[ownerId])
+ #endif
#else
&& Object!=id1
#endif
diff --git a/PhysX_3.4/Source/LowLevelAABB/src/BpBroadPhaseSap.h b/PhysX_3.4/Source/LowLevelAABB/src/BpBroadPhaseSap.h
index 47b41f6e..eeee3651 100644
--- a/PhysX_3.4/Source/LowLevelAABB/src/BpBroadPhaseSap.h
+++ b/PhysX_3.4/Source/LowLevelAABB/src/BpBroadPhaseSap.h
@@ -23,7 +23,7 @@
// components in life support devices or systems without express written approval of
// NVIDIA Corporation.
//
-// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2008-2018 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
@@ -154,7 +154,10 @@ private:
const BpHandle* mUpdated;
PxU32 mUpdatedSize;
const PxBounds3* mBoxBoundsMinMax;
- const BpHandle* mBoxGroups;
+ const Bp::FilterGroup::Enum*mBoxGroups;
+#ifdef BP_FILTERING_USES_TYPE_IN_GROUP
+ const bool* mLUT;
+#endif
const PxReal* mContactDistance;
PxU32 mBoxesCapacity;
diff --git a/PhysX_3.4/Source/LowLevelAABB/src/BpBroadPhaseSapAux.cpp b/PhysX_3.4/Source/LowLevelAABB/src/BpBroadPhaseSapAux.cpp
index 0f6763e4..8d8b8694 100644
--- a/PhysX_3.4/Source/LowLevelAABB/src/BpBroadPhaseSapAux.cpp
+++ b/PhysX_3.4/Source/LowLevelAABB/src/BpBroadPhaseSapAux.cpp
@@ -23,7 +23,7 @@
// components in life support devices or systems without express written approval of
// NVIDIA Corporation.
//
-// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2008-2018 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
@@ -483,7 +483,7 @@ void resizeCreatedDeleted(BroadPhasePair*& pairs, PxU32& maxNumPairs)
}
void ComputeCreatedDeletedPairsLists
-(const BpHandle* PX_RESTRICT boxGroups,
+(const Bp::FilterGroup::Enum* PX_RESTRICT boxGroups,
const BpHandle* PX_RESTRICT dataArray, const PxU32 dataArraySize,
PxcScratchAllocator* scratchAllocator,
BroadPhasePair*& createdPairsList, PxU32& numCreatedPairs, PxU32& maxNumCreatedPairs,
@@ -529,7 +529,7 @@ void ComputeCreatedDeletedPairsLists
if(pairManager.IsNew(UP))
{
#if !BP_SAP_TEST_GROUP_ID_CREATEUPDATE
- if(boxGroups[UP->mVolA]!=boxGroups[UP->mVolB])
+ if(groupFiltering(boxGroups[UP->mVolA], boxGroups[UP->mVolB]))
#endif
{
if(numCreatedPairs==maxNumCreatedPairs)
@@ -594,7 +594,7 @@ void ComputeCreatedDeletedPairsLists
{
const PxU32 id0 = deletedPairsList[i].mVolA;
const PxU32 id1 = deletedPairsList[i].mVolB;
- if(boxGroups[id0]==boxGroups[id1])
+ if(!groupFiltering(boxGroups[id0], boxGroups[id1]))
{
while((numDeletedPairs-1) > i && boxGroups[deletedPairsList[numDeletedPairs-1].mVolA] == boxGroups[deletedPairsList[numDeletedPairs-1].mVolB])
{
@@ -736,13 +736,13 @@ static void addPair(const AddPairParams* PX_RESTRICT params, const BpHandle id0_
// PT: TODO: use SIMD
-AuxData::AuxData(PxU32 nb, const SapBox1D*const* PX_RESTRICT boxes, const BpHandle* PX_RESTRICT indicesSorted, const BpHandle* PX_RESTRICT groupIds)
+AuxData::AuxData(PxU32 nb, const SapBox1D*const* PX_RESTRICT boxes, const BpHandle* PX_RESTRICT indicesSorted, const Bp::FilterGroup::Enum* PX_RESTRICT groupIds)
{
// PT: TODO: use scratch allocator / etc
- BoxX* PX_RESTRICT boxX = reinterpret_cast<BoxX*>(PX_ALLOC(sizeof(BoxX)*(nb+1), PX_DEBUG_EXP("mBoxX")));
- BoxYZ* PX_RESTRICT boxYZ = reinterpret_cast<BoxYZ*>(PX_ALLOC(sizeof(BoxYZ)*nb, PX_DEBUG_EXP("mBoxYZ")));
- BpHandle* PX_RESTRICT groups = reinterpret_cast<BpHandle*>(PX_ALLOC(sizeof(BpHandle)*nb, PX_DEBUG_EXP("mGroups")));
- PxU32* PX_RESTRICT remap = reinterpret_cast<PxU32*>(PX_ALLOC(sizeof(PxU32)*nb, PX_DEBUG_EXP("mRemap")));
+ BoxX* PX_RESTRICT boxX = reinterpret_cast<BoxX*>(PX_ALLOC(sizeof(BoxX)*(nb+1), PX_DEBUG_EXP("mBoxX")));
+ BoxYZ* PX_RESTRICT boxYZ = reinterpret_cast<BoxYZ*>(PX_ALLOC(sizeof(BoxYZ)*nb, PX_DEBUG_EXP("mBoxYZ")));
+ Bp::FilterGroup::Enum* PX_RESTRICT groups = reinterpret_cast<Bp::FilterGroup::Enum*>(PX_ALLOC(sizeof(Bp::FilterGroup::Enum)*nb, PX_DEBUG_EXP("mGroups")));
+ PxU32* PX_RESTRICT remap = reinterpret_cast<PxU32*>(PX_ALLOC(sizeof(PxU32)*nb, PX_DEBUG_EXP("mRemap")));
mBoxX = boxX;
mBoxYZ = boxYZ;
@@ -788,6 +788,9 @@ AuxData::~AuxData()
}
void performBoxPruningNewNew( const AuxData* PX_RESTRICT auxData, PxcScratchAllocator* scratchAllocator,
+#ifdef BP_FILTERING_USES_TYPE_IN_GROUP
+ const bool* lut,
+#endif
SapPairManager& pairManager, BpHandle*& dataArray, PxU32& dataArraySize, PxU32& dataArrayCapacity)
{
const PxU32 nb = auxData->mNb;
@@ -800,7 +803,7 @@ void performBoxPruningNewNew( const AuxData* PX_RESTRICT auxData, PxcScratchAllo
{
BoxX* boxX = auxData->mBoxX;
BoxYZ* boxYZ = auxData->mBoxYZ;
- BpHandle* groups = auxData->mGroups;
+ Bp::FilterGroup::Enum* groups = auxData->mGroups;
PxU32* remap = auxData->mRemap;
AddPairParams params(remap, remap, scratchAllocator, &pairManager, &da);
@@ -811,7 +814,7 @@ void performBoxPruningNewNew( const AuxData* PX_RESTRICT auxData, PxcScratchAllo
while(runningIndex<nb && index0<nb)
{
#if BP_SAP_TEST_GROUP_ID_CREATEUPDATE
- const BpHandle group0 = groups[index0];
+ const Bp::FilterGroup::Enum group0 = groups[index0];
#endif
const BoxX& boxX0 = boxX[index0];
@@ -824,7 +827,11 @@ void performBoxPruningNewNew( const AuxData* PX_RESTRICT auxData, PxcScratchAllo
{
INCREASE_STATS_NB_ITER
#if BP_SAP_TEST_GROUP_ID_CREATEUPDATE
- if(group0!=groups[index1])
+ #ifdef BP_FILTERING_USES_TYPE_IN_GROUP
+ if(groupFiltering(group0, groups[index1], lut))
+ #else
+ if(groupFiltering(group0, groups[index1]))
+ #endif
#endif
{
INCREASE_STATS_NB_TESTS
@@ -852,9 +859,13 @@ void performBoxPruningNewNew( const AuxData* PX_RESTRICT auxData, PxcScratchAllo
dataArrayCapacity = da.mCapacity;
}
+template<int codepath>
static void bipartitePruning(
- const PxU32 nb0, const BoxX* PX_RESTRICT boxX0, const BoxYZ* PX_RESTRICT boxYZ0, const PxU32* PX_RESTRICT remap0, const BpHandle* PX_RESTRICT groups0,
- const PxU32 nb1, const BoxX* PX_RESTRICT boxX1, const BoxYZ* PX_RESTRICT boxYZ1, const PxU32* PX_RESTRICT remap1, const BpHandle* PX_RESTRICT groups1,
+ const PxU32 nb0, const BoxX* PX_RESTRICT boxX0, const BoxYZ* PX_RESTRICT boxYZ0, const PxU32* PX_RESTRICT remap0, const Bp::FilterGroup::Enum* PX_RESTRICT groups0,
+ const PxU32 nb1, const BoxX* PX_RESTRICT boxX1, const BoxYZ* PX_RESTRICT boxYZ1, const PxU32* PX_RESTRICT remap1, const Bp::FilterGroup::Enum* PX_RESTRICT groups1,
+#ifdef BP_FILTERING_USES_TYPE_IN_GROUP
+ const bool* lut,
+#endif
PxcScratchAllocator* scratchAllocator, SapPairManager& pairManager, DataArray& dataArray
)
{
@@ -866,12 +877,20 @@ static void bipartitePruning(
while(runningIndex<nb1 && index0<nb0)
{
#if BP_SAP_TEST_GROUP_ID_CREATEUPDATE
- const BpHandle group0 = groups0[index0];
+ const Bp::FilterGroup::Enum group0 = groups0[index0];
#endif
const BpHandle minLimit = boxX0[index0].mMinX;
- while(boxX1[runningIndex].mMinX<minLimit)
- runningIndex++;
+ if(!codepath)
+ {
+ while(boxX1[runningIndex].mMinX<minLimit)
+ runningIndex++;
+ }
+ else
+ {
+ while(boxX1[runningIndex].mMinX<=minLimit)
+ runningIndex++;
+ }
const BpHandle maxLimit = boxX0[index0].mMaxX;
PxU32 index1 = runningIndex;
@@ -879,7 +898,11 @@ static void bipartitePruning(
{
INCREASE_STATS_NB_ITER
#if BP_SAP_TEST_GROUP_ID_CREATEUPDATE
- if(group0!=groups1[index1])
+ #ifdef BP_FILTERING_USES_TYPE_IN_GROUP
+ if(groupFiltering(group0, groups1[index1], lut))
+ #else
+ if(groupFiltering(group0, groups1[index1]))
+ #endif
#endif
{
INCREASE_STATS_NB_TESTS
@@ -895,7 +918,10 @@ static void bipartitePruning(
}
}
-void performBoxPruningNewOld( const AuxData* PX_RESTRICT auxData0, const AuxData* PX_RESTRICT auxData1, PxcScratchAllocator* scratchAllocator,
+void performBoxPruningNewOld( const AuxData* PX_RESTRICT auxData0, const AuxData* PX_RESTRICT auxData1, PxcScratchAllocator* scratchAllocator,
+#ifdef BP_FILTERING_USES_TYPE_IN_GROUP
+ const bool* lut,
+#endif
SapPairManager& pairManager, BpHandle*& dataArray, PxU32& dataArraySize, PxU32& dataArrayCapacity)
{
const PxU32 nb0 = auxData0->mNb;
@@ -908,18 +934,23 @@ void performBoxPruningNewOld( const AuxData* PX_RESTRICT auxData0, const AuxData
START_STATS
{
- BoxX* boxX0 = auxData0->mBoxX;
- BoxYZ* boxYZ0 = auxData0->mBoxYZ;
- BpHandle* groups0 = auxData0->mGroups;
- PxU32* remap0 = auxData0->mRemap;
-
- BoxX* boxX1 = auxData1->mBoxX;
- BoxYZ* boxYZ1 = auxData1->mBoxYZ;
- BpHandle* groups1 = auxData1->mGroups;
- PxU32* remap1 = auxData1->mRemap;
-
- bipartitePruning(nb0, boxX0, boxYZ0, remap0, groups0, nb1, boxX1, boxYZ1, remap1, groups1, scratchAllocator, pairManager, da);
- bipartitePruning(nb1, boxX1, boxYZ1, remap1, groups1, nb0, boxX0, boxYZ0, remap0, groups0, scratchAllocator, pairManager, da);
+ const BoxX* boxX0 = auxData0->mBoxX;
+ const BoxYZ* boxYZ0 = auxData0->mBoxYZ;
+ const Bp::FilterGroup::Enum* groups0 = auxData0->mGroups;
+ const PxU32* remap0 = auxData0->mRemap;
+
+ const BoxX* boxX1 = auxData1->mBoxX;
+ const BoxYZ* boxYZ1 = auxData1->mBoxYZ;
+ const Bp::FilterGroup::Enum* groups1 = auxData1->mGroups;
+ const PxU32* remap1 = auxData1->mRemap;
+
+#ifdef BP_FILTERING_USES_TYPE_IN_GROUP
+ bipartitePruning<0>(nb0, boxX0, boxYZ0, remap0, groups0, nb1, boxX1, boxYZ1, remap1, groups1, lut, scratchAllocator, pairManager, da);
+ bipartitePruning<1>(nb1, boxX1, boxYZ1, remap1, groups1, nb0, boxX0, boxYZ0, remap0, groups0, lut, scratchAllocator, pairManager, da);
+#else
+ bipartitePruning<0>(nb0, boxX0, boxYZ0, remap0, groups0, nb1, boxX1, boxYZ1, remap1, groups1, scratchAllocator, pairManager, da);
+ bipartitePruning<1>(nb1, boxX1, boxYZ1, remap1, groups1, nb0, boxX0, boxYZ0, remap0, groups0, scratchAllocator, pairManager, da);
+#endif
}
DUMP_STATS
diff --git a/PhysX_3.4/Source/LowLevelAABB/src/BpBroadPhaseSapAux.h b/PhysX_3.4/Source/LowLevelAABB/src/BpBroadPhaseSapAux.h
index 73aa504b..3068ba08 100644
--- a/PhysX_3.4/Source/LowLevelAABB/src/BpBroadPhaseSapAux.h
+++ b/PhysX_3.4/Source/LowLevelAABB/src/BpBroadPhaseSapAux.h
@@ -23,7 +23,7 @@
// components in life support devices or systems without express written approval of
// NVIDIA Corporation.
//
-// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2008-2018 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
@@ -54,15 +54,9 @@ namespace Bp
//Set 0 to neglect group id test in batchCreate/batchUpdate and delay test until ComputeCreatedDeletedPairsLists
#define BP_SAP_TEST_GROUP_ID_CREATEUPDATE 1
-#if PX_USE_16_BIT_HANDLES
-#define MAX_BP_HANDLE 0xffff
-#define PX_REMOVED_BP_HANDLE 0xfffd
-#define MAX_BP_PAIRS_MESSAGE "Only 65536 broadphase pairs are supported. This limit has been exceeded and some pairs will be dropped \n"
-#else
#define MAX_BP_HANDLE 0x3fffffff
#define PX_REMOVED_BP_HANDLE 0x3ffffffd
#define MAX_BP_PAIRS_MESSAGE "Only 4294967296 broadphase pairs are supported. This limit has been exceeded and some pairs will be dropped \n"
-#endif
PX_FORCE_INLINE void setMinSentinel(ValType& v, BpHandle& d)
{
@@ -228,7 +222,7 @@ void addPair(const BpHandle id0, const BpHandle id1, PxcScratchAllocator* scratc
void removePair(BpHandle id0, BpHandle id1, PxcScratchAllocator* scratchAllocator, SapPairManager& pairManager, DataArray& dataArray);
void ComputeCreatedDeletedPairsLists
-(const BpHandle* PX_RESTRICT boxGroups,
+(const Bp::FilterGroup::Enum* PX_RESTRICT boxGroups,
const BpHandle* PX_RESTRICT dataArray, const PxU32 dataArraySize,
PxcScratchAllocator* scratchAllocator,
BroadPhasePair* & createdPairsList, PxU32& numCreatedPairs, PxU32& maxNumCreatdPairs,
@@ -254,20 +248,26 @@ void DeletePairsLists(const PxU32 numActualDeletedPairs, BroadPhasePair* deleted
struct AuxData
{
- AuxData(PxU32 nb, const SapBox1D*const* PX_RESTRICT boxes, const BpHandle* PX_RESTRICT indicesSorted, const BpHandle* PX_RESTRICT groupIds);
+ AuxData(PxU32 nb, const SapBox1D*const* PX_RESTRICT boxes, const BpHandle* PX_RESTRICT indicesSorted, const Bp::FilterGroup::Enum* PX_RESTRICT groupIds);
~AuxData();
- BoxX* mBoxX;
- BoxYZ* mBoxYZ;
- BpHandle* mGroups;
- PxU32* mRemap;
- PxU32 mNb;
+ BoxX* mBoxX;
+ BoxYZ* mBoxYZ;
+ Bp::FilterGroup::Enum* mGroups;
+ PxU32* mRemap;
+ PxU32 mNb;
};
void performBoxPruningNewNew( const AuxData* PX_RESTRICT auxData, PxcScratchAllocator* scratchAllocator,
+#ifdef BP_FILTERING_USES_TYPE_IN_GROUP
+ const bool* lut,
+#endif
SapPairManager& pairManager, BpHandle*& dataArray, PxU32& dataArraySize, PxU32& dataArrayCapacity);
void performBoxPruningNewOld( const AuxData* PX_RESTRICT auxData0, const AuxData* PX_RESTRICT auxData1, PxcScratchAllocator* scratchAllocator,
+#ifdef BP_FILTERING_USES_TYPE_IN_GROUP
+ const bool* lut,
+#endif
SapPairManager& pairManager, BpHandle*& dataArray, PxU32& dataArraySize, PxU32& dataArrayCapacity);
PX_FORCE_INLINE bool Intersect2D_Handle
diff --git a/PhysX_3.4/Source/LowLevelAABB/src/BpMBPTasks.cpp b/PhysX_3.4/Source/LowLevelAABB/src/BpMBPTasks.cpp
index 6a0a3ac7..6781ea48 100644
--- a/PhysX_3.4/Source/LowLevelAABB/src/BpMBPTasks.cpp
+++ b/PhysX_3.4/Source/LowLevelAABB/src/BpMBPTasks.cpp
@@ -23,7 +23,7 @@
// components in life support devices or systems without express written approval of
// NVIDIA Corporation.
//
-// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2008-2018 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
diff --git a/PhysX_3.4/Source/LowLevelAABB/src/BpMBPTasks.h b/PhysX_3.4/Source/LowLevelAABB/src/BpMBPTasks.h
index 9f392235..742e0d29 100644
--- a/PhysX_3.4/Source/LowLevelAABB/src/BpMBPTasks.h
+++ b/PhysX_3.4/Source/LowLevelAABB/src/BpMBPTasks.h
@@ -23,7 +23,7 @@
// components in life support devices or systems without express written approval of
// NVIDIA Corporation.
//
-// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2008-2018 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
diff --git a/PhysX_3.4/Source/LowLevelAABB/src/BpSAPTasks.cpp b/PhysX_3.4/Source/LowLevelAABB/src/BpSAPTasks.cpp
index a7eabb69..ef6dee35 100644
--- a/PhysX_3.4/Source/LowLevelAABB/src/BpSAPTasks.cpp
+++ b/PhysX_3.4/Source/LowLevelAABB/src/BpSAPTasks.cpp
@@ -23,7 +23,7 @@
// components in life support devices or systems without express written approval of
// NVIDIA Corporation.
//
-// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2008-2018 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
diff --git a/PhysX_3.4/Source/LowLevelAABB/src/BpSAPTasks.h b/PhysX_3.4/Source/LowLevelAABB/src/BpSAPTasks.h
index 96442524..47369b43 100644
--- a/PhysX_3.4/Source/LowLevelAABB/src/BpSAPTasks.h
+++ b/PhysX_3.4/Source/LowLevelAABB/src/BpSAPTasks.h
@@ -23,7 +23,7 @@
// components in life support devices or systems without express written approval of
// NVIDIA Corporation.
//
-// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2008-2018 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
diff --git a/PhysX_3.4/Source/LowLevelAABB/src/BpSimpleAABBManager.cpp b/PhysX_3.4/Source/LowLevelAABB/src/BpSimpleAABBManager.cpp
index 5a0bd44f..0dd4cc01 100644
--- a/PhysX_3.4/Source/LowLevelAABB/src/BpSimpleAABBManager.cpp
+++ b/PhysX_3.4/Source/LowLevelAABB/src/BpSimpleAABBManager.cpp
@@ -23,7 +23,7 @@
// components in life support devices or systems without express written approval of
// NVIDIA Corporation.
//
-// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2008-2018 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
@@ -95,11 +95,6 @@ static const bool gUseBruteForce = false;
#define USE_SIMD_BOUNDS
#endif
-static PX_FORCE_INLINE bool groupFiltering(PxU32 group0, PxU32 group1)
-{
- return group0!=group1;
-}
-
namespace physx
{
@@ -115,11 +110,11 @@ static PX_FORCE_INLINE uint32_t hash(const AggPair& p)
return PxU32(Ps::hash( (p.mIndex0&0xffff)|(p.mIndex1<<16)) );
}
-static PX_FORCE_INLINE bool shouldPairBeDeleted(const Ps::Array<PxU32, Ps::VirtualAllocator>& groups, ShapeHandle h0, ShapeHandle h1)
+static PX_FORCE_INLINE bool shouldPairBeDeleted(const Ps::Array<Bp::FilterGroup::Enum, Ps::VirtualAllocator>& groups, ShapeHandle h0, ShapeHandle h1)
{
PX_ASSERT(h0<groups.size());
PX_ASSERT(h1<groups.size());
- return (groups[h0]==PX_INVALID_U32) || (groups[h1]==PX_INVALID_U32);
+ return (groups[h0]==Bp::FilterGroup::eINVALID) || (groups[h1]==Bp::FilterGroup::eINVALID);
}
// PT: TODO: refactor with CCT version
@@ -292,7 +287,6 @@ namespace
PxU32* mNext;
MBP_Pair* mActivePairs;
PxU32 mReservedMemory;
- bool mStuff;
PX_FORCE_INLINE MBP_Pair* findPair(PxU32 id0, PxU32 id1, PxU32 hashValue) const;
void removePair(PxU32 id0, PxU32 id1, PxU32 hashValue, PxU32 pairIndex);
@@ -604,11 +598,18 @@ class PersistentPairs : public Ps::UserAllocated
virtual bool update(SimpleAABBManager& /*manager*/) { return false; }
- PX_FORCE_INLINE void updatePairs(PxU32 timestamp, const PxBounds3* bounds, const float* contactDistances, const PxU32* groups,
+ PX_FORCE_INLINE void updatePairs(PxU32 timestamp, const PxBounds3* bounds, const float* contactDistances, const Bp::FilterGroup::Enum* groups,
+#ifdef BP_FILTERING_USES_TYPE_IN_GROUP
+ const bool* lut,
+#endif
Ps::Array<VolumeData>& volumeData, Ps::Array<AABBOverlap>* createdOverlaps, Ps::Array<AABBOverlap>* destroyedOverlaps);
void outputDeletedOverlaps(Ps::Array<AABBOverlap>* overlaps, const Ps::Array<VolumeData>& volumeData);
private:
- virtual void findOverlaps(PairArray& pairs, const PxBounds3* PX_RESTRICT bounds, const float* PX_RESTRICT contactDistances, const PxU32* PX_RESTRICT groups) = 0;
+ virtual void findOverlaps(PairArray& pairs, const PxBounds3* PX_RESTRICT bounds, const float* PX_RESTRICT contactDistances, const Bp::FilterGroup::Enum* PX_RESTRICT groups
+#ifdef BP_FILTERING_USES_TYPE_IN_GROUP
+ , const bool* PX_RESTRICT lut
+#endif
+ ) = 0;
protected:
PxU32 mTimestamp;
#ifdef USE_MBP_PAIR_MANAGER
@@ -676,16 +677,24 @@ static PX_FORCE_INLINE InflatedType getMaxX(const InflatedAABB& box)
#endif
}
-static PX_FORCE_INLINE void testPair(PairArray& pairs, const InflatedAABB* bounds0, const InflatedAABB* bounds1, const PxU32* PX_RESTRICT groups, const PxU32 aggIndex0, const PxU32 aggIndex1, const PxU32 index0, const PxU32 index1)
+static PX_FORCE_INLINE void testPair(PairArray& pairs, const InflatedAABB* bounds0, const InflatedAABB* bounds1, const Bp::FilterGroup::Enum* PX_RESTRICT groups,
+#ifdef BP_FILTERING_USES_TYPE_IN_GROUP
+ const bool* PX_RESTRICT lut,
+#endif
+ const PxU32 aggIndex0, const PxU32 aggIndex1, const PxU32 index0, const PxU32 index1)
{
+#ifdef BP_FILTERING_USES_TYPE_IN_GROUP
+ if(groupFiltering(groups[aggIndex0], groups[aggIndex1], lut))
+#else
if(groupFiltering(groups[aggIndex0], groups[aggIndex1]))
+#endif
if(intersects2D(bounds0[index0], bounds1[index1]))
outputPair(pairs, aggIndex0, aggIndex1);
}
#ifdef REMOVED_FAILED_EXPERIMENT
static PX_NOINLINE void processCandidates(PxU32 nbCandidates, const Pair* PX_RESTRICT candidates,
- PairArray& pairs, const InflatedAABB* bounds0, const InflatedAABB* bounds1, const PxU32* PX_RESTRICT groups, const PxU32* aggIndices0, const PxU32* aggIndices1)
+ PairArray& pairs, const InflatedAABB* bounds0, const InflatedAABB* bounds1, const Bp::FilterGroup::Enum* PX_RESTRICT groups, const PxU32* aggIndices0, const PxU32* aggIndices1)
{
while(nbCandidates--)
{
@@ -700,7 +709,7 @@ static PX_NOINLINE void processCandidates(PxU32 nbCandidates, const Pair* PX_RES
}
}
-static /*PX_FORCE_INLINE*/ void boxPruning(PairArray& pairs, const InflatedAABB* bounds0, const InflatedAABB* bounds1, const PxU32* PX_RESTRICT groups, PxU32 size0, PxU32 size1, const PxU32* aggIndices0, const PxU32* aggIndices1)
+static /*PX_FORCE_INLINE*/ void boxPruning(PairArray& pairs, const InflatedAABB* bounds0, const InflatedAABB* bounds1, const Bp::FilterGroup::Enum* PX_RESTRICT groups, PxU32 size0, PxU32 size1, const PxU32* aggIndices0, const PxU32* aggIndices1)
{
// PxU32 nbCandidates = 0;
// Pair candidates[16384];
@@ -735,7 +744,7 @@ static /*PX_FORCE_INLINE*/ void boxPruning(PairArray& pairs, const InflatedAABB*
#endif
#ifdef REMOVED
-static /*PX_FORCE_INLINE*/ void boxPruning(PairArray& pairs, const InflatedAABB* bounds0, const InflatedAABB* bounds1, const PxU32* PX_RESTRICT groups, PxU32 size0, PxU32 size1, const PxU32* aggIndices0, const PxU32* aggIndices1)
+static /*PX_FORCE_INLINE*/ void boxPruning(PairArray& pairs, const InflatedAABB* bounds0, const InflatedAABB* bounds1, const Bp::FilterGroup::Enum* PX_RESTRICT groups, PxU32 size0, PxU32 size1, const PxU32* aggIndices0, const PxU32* aggIndices1)
{
PxU32 index0 = 0;
PxU32 runningAddress1 = 0;
@@ -767,7 +776,10 @@ static /*PX_FORCE_INLINE*/ void boxPruning(PairArray& pairs, const InflatedAABB*
#endif
#ifdef STORE_SORTED_BOUNDS
-static void boxPruning( PairArray& pairs, const InflatedAABB* PX_RESTRICT bounds0, const InflatedAABB* PX_RESTRICT bounds1, const PxU32* PX_RESTRICT groups,
+static void boxPruning( PairArray& pairs, const InflatedAABB* PX_RESTRICT bounds0, const InflatedAABB* PX_RESTRICT bounds1, const Bp::FilterGroup::Enum* PX_RESTRICT groups,
+#ifdef BP_FILTERING_USES_TYPE_IN_GROUP
+ const bool* PX_RESTRICT lut,
+#endif
PxU32 size0, PxU32 size1, const BoundsIndex* PX_RESTRICT aggIndices0, const BoundsIndex* PX_RESTRICT aggIndices1)
{
{
@@ -791,7 +803,11 @@ static void boxPruning( PairArray& pairs, const InflatedAABB* PX_RESTRICT bounds
{
const PxU32 aggIndex1 = aggIndices1[index1];
// testPair(pairs, bounds0, bounds1, groups, aggIndex0, aggIndex1, index0, index1);
+#ifdef BP_FILTERING_USES_TYPE_IN_GROUP
+ if(groupFiltering(groups[aggIndex0], groups[aggIndex1], lut))
+#else
if(groupFiltering(groups[aggIndex0], groups[aggIndex1]))
+#endif
{
#ifdef USE_SIMD_BOUNDS
SIMD_OVERLAP_TEST(bounds1[index1])
@@ -830,7 +846,11 @@ static void boxPruning( PairArray& pairs, const InflatedAABB* PX_RESTRICT bounds
{
const PxU32 aggIndex1 = aggIndices0[index1];
// testPair(pairs, bounds0, bounds1, groups, aggIndex0, aggIndex1, index1, index0);
+#ifdef BP_FILTERING_USES_TYPE_IN_GROUP
+ if(groupFiltering(groups[aggIndex0], groups[aggIndex1], lut))
+#else
if(groupFiltering(groups[aggIndex0], groups[aggIndex1]))
+#endif
{
#ifdef USE_SIMD_BOUNDS
SIMD_OVERLAP_TEST(bounds0[index1])
@@ -858,7 +878,11 @@ class PersistentActorAggregatePair : public PersistentPairs
PersistentActorAggregatePair(Aggregate* aggregate, ShapeHandle actorHandle);
virtual ~PersistentActorAggregatePair() {}
- virtual void findOverlaps(PairArray& pairs, const PxBounds3* PX_RESTRICT bounds, const float* PX_RESTRICT contactDistances, const PxU32* PX_RESTRICT groups);
+ virtual void findOverlaps(PairArray& pairs, const PxBounds3* PX_RESTRICT bounds, const float* PX_RESTRICT contactDistances, const Bp::FilterGroup::Enum* PX_RESTRICT groups
+#ifdef BP_FILTERING_USES_TYPE_IN_GROUP
+ , const bool* PX_RESTRICT lut
+#endif
+ );
virtual bool update(SimpleAABBManager& manager);
ShapeHandle mAggregateHandle;
@@ -873,7 +897,11 @@ PersistentActorAggregatePair::PersistentActorAggregatePair(Aggregate* aggregate,
{
}
-void PersistentActorAggregatePair::findOverlaps(PairArray& pairs, const PxBounds3* PX_RESTRICT bounds, const float* PX_RESTRICT contactDistances, const PxU32* PX_RESTRICT groups)
+void PersistentActorAggregatePair::findOverlaps(PairArray& pairs, const PxBounds3* PX_RESTRICT bounds, const float* PX_RESTRICT contactDistances, const Bp::FilterGroup::Enum* PX_RESTRICT groups
+#ifdef BP_FILTERING_USES_TYPE_IN_GROUP
+ , const bool* PX_RESTRICT lut
+#endif
+ )
{
const ShapeHandle actorHandle = mActorHandle;
@@ -893,11 +921,15 @@ void PersistentActorAggregatePair::findOverlaps(PairArray& pairs, const PxBounds
const InflatedAABB* inflatedBounds = mAggregate->mInflatedBounds;
if(gUseBruteForce)
{
- const PxU32 actorGroup = groups[actorHandle];
+ const Bp::FilterGroup::Enum actorGroup = groups[actorHandle];
for(PxU32 i=0;i<size;i++)
{
const BoundsIndex index = mAggregate->getAggregated(i);
+#ifdef BP_FILTERING_USES_TYPE_IN_GROUP
+ if(groupFiltering(actorGroup, groups[index], lut))
+#else
if(groupFiltering(actorGroup, groups[index]))
+#endif
{
if(actorBounds[0].intersects(inflatedBounds[i]))
outputPair(pairs, index, actorHandle);
@@ -916,7 +948,11 @@ void PersistentActorAggregatePair::findOverlaps(PairArray& pairs, const PxBounds
const InflatedAABB* PX_RESTRICT bounds0 = actorBounds;
const InflatedAABB* PX_RESTRICT bounds1 = inflatedBounds;
mAggregate->getSortedMinBounds();
+ #ifdef BP_FILTERING_USES_TYPE_IN_GROUP
+ boxPruning(pairs, bounds0, bounds1, groups, lut, 1, size, &actorHandle, mAggregate->getIndices());
+ #else
boxPruning(pairs, bounds0, bounds1, groups, 1, size, &actorHandle, mAggregate->getIndices());
+ #endif
#else
const InflatedAABB* PX_RESTRICT bounds0 = actorBounds;
const InflatedAABB* PX_RESTRICT bounds1 = inflatedBounds;
@@ -999,7 +1035,11 @@ class PersistentAggregateAggregatePair : public PersistentPairs
PersistentAggregateAggregatePair(Aggregate* aggregate0, Aggregate* aggregate1);
virtual ~PersistentAggregateAggregatePair() {}
- virtual void findOverlaps(PairArray& pairs, const PxBounds3* PX_RESTRICT bounds, const float* PX_RESTRICT contactDistances, const PxU32* PX_RESTRICT groups);
+ virtual void findOverlaps(PairArray& pairs, const PxBounds3* PX_RESTRICT bounds, const float* PX_RESTRICT contactDistances, const Bp::FilterGroup::Enum* PX_RESTRICT groups
+#ifdef BP_FILTERING_USES_TYPE_IN_GROUP
+ , const bool* PX_RESTRICT lut
+#endif
+ );
virtual bool update(SimpleAABBManager& manager);
ShapeHandle mAggregateHandle0;
@@ -1016,7 +1056,11 @@ PersistentAggregateAggregatePair::PersistentAggregateAggregatePair(Aggregate* ag
{
}
-void PersistentAggregateAggregatePair::findOverlaps(PairArray& pairs, const PxBounds3* PX_RESTRICT /*bounds*/, const float* PX_RESTRICT /*contactDistances*/, const PxU32* PX_RESTRICT groups)
+void PersistentAggregateAggregatePair::findOverlaps(PairArray& pairs, const PxBounds3* PX_RESTRICT /*bounds*/, const float* PX_RESTRICT /*contactDistances*/, const Bp::FilterGroup::Enum* PX_RESTRICT groups
+#ifdef BP_FILTERING_USES_TYPE_IN_GROUP
+ , const bool* PX_RESTRICT lut
+#endif
+ )
{
const PxU32 size0 = mAggregate0->getNbAggregated();
const PxU32 size1 = mAggregate1->getNbAggregated();
@@ -1036,7 +1080,11 @@ void PersistentAggregateAggregatePair::findOverlaps(PairArray& pairs, const PxBo
{
const BoundsIndex index1 = mAggregate1->getAggregated(j);
+#ifdef BP_FILTERING_USES_TYPE_IN_GROUP
+ if(groupFiltering(groups[index0], groups[index1], lut))
+#else
if(groupFiltering(groups[index0], groups[index1]))
+#endif
{
if(inflatedBounds0.intersects(inflated1[j]))
outputPair(pairs, index0, index1);
@@ -1051,7 +1099,11 @@ void PersistentAggregateAggregatePair::findOverlaps(PairArray& pairs, const PxBo
mAggregate1->getSortedMinBounds();
const InflatedAABB* PX_RESTRICT bounds0 = mAggregate0->mInflatedBounds;
const InflatedAABB* PX_RESTRICT bounds1 = mAggregate1->mInflatedBounds;
+ #ifdef BP_FILTERING_USES_TYPE_IN_GROUP
+ boxPruning(pairs, bounds0, bounds1, groups, lut, size0, size1, mAggregate0->getIndices(), mAggregate1->getIndices());
+ #else
boxPruning(pairs, bounds0, bounds1, groups, size0, size1, mAggregate0->getIndices(), mAggregate1->getIndices());
+ #endif
#else
const InflatedAABB* PX_RESTRICT bounds0 = mAggregate0->mInflatedBounds;
const InflatedAABB* PX_RESTRICT bounds1 = mAggregate1->mInflatedBounds;
@@ -1153,7 +1205,11 @@ class PersistentSelfCollisionPairs : public PersistentPairs
PersistentSelfCollisionPairs(Aggregate* aggregate);
virtual ~PersistentSelfCollisionPairs() {}
- virtual void findOverlaps(PairArray& pairs, const PxBounds3* PX_RESTRICT bounds, const float* PX_RESTRICT contactDistances, const PxU32* PX_RESTRICT groups);
+ virtual void findOverlaps(PairArray& pairs, const PxBounds3* PX_RESTRICT bounds, const float* PX_RESTRICT contactDistances, const Bp::FilterGroup::Enum* PX_RESTRICT groups
+#ifdef BP_FILTERING_USES_TYPE_IN_GROUP
+ , const bool* PX_RESTRICT lut
+#endif
+ );
Aggregate* mAggregate;
};
@@ -1163,7 +1219,11 @@ PersistentSelfCollisionPairs::PersistentSelfCollisionPairs(Aggregate* aggregate)
{
}
-void PersistentSelfCollisionPairs::findOverlaps(PairArray& pairs, const PxBounds3* PX_RESTRICT/*bounds*/, const float* PX_RESTRICT/*contactDistances*/, const PxU32* PX_RESTRICT groups)
+void PersistentSelfCollisionPairs::findOverlaps(PairArray& pairs, const PxBounds3* PX_RESTRICT/*bounds*/, const float* PX_RESTRICT/*contactDistances*/, const Bp::FilterGroup::Enum* PX_RESTRICT groups
+#ifdef BP_FILTERING_USES_TYPE_IN_GROUP
+ , const bool* PX_RESTRICT lut
+#endif
+ )
{
const PxU32 size0 = mAggregate->getNbAggregated();
@@ -1181,7 +1241,11 @@ void PersistentSelfCollisionPairs::findOverlaps(PairArray& pairs, const PxBounds
for(PxU32 j=i+1;j<size0;j++)
{
const BoundsIndex index1 = mAggregate->getAggregated(j);
+#ifdef BP_FILTERING_USES_TYPE_IN_GROUP
+ if(groupFiltering(groups[index0], groups[index1], lut))
+#else
if(groupFiltering(groups[index0], groups[index1]))
+#endif
{
if(inflatedBounds0.intersects(inflatedBounds[j]))
outputPair(pairs, index0, index1);
@@ -1212,7 +1276,11 @@ void PersistentSelfCollisionPairs::findOverlaps(PairArray& pairs, const PxBounds
// if(index0!=index1)
{
const PxU32 aggIndex1 = mAggregate->getAggregated(index1);
+#ifdef BP_FILTERING_USES_TYPE_IN_GROUP
+ testPair(pairs, bounds, bounds, groups, lut, aggIndex0, aggIndex1, index0, index1);
+#else
testPair(pairs, bounds, bounds, groups, aggIndex0, aggIndex1, index0, index1);
+#endif
}
index1++;
}
@@ -1502,7 +1570,7 @@ void Aggregate::computeBounds(const BoundsArray& boundsArray, const float* conta
void SimpleAABBManager::reserveShapeSpace(PxU32 nbTotalBounds)
{
nbTotalBounds = Ps::nextPowerOfTwo(nbTotalBounds);
- mGroups.resize(nbTotalBounds, PX_INVALID_U32);
+ mGroups.resize(nbTotalBounds, Bp::FilterGroup::eINVALID);
mVolumeData.resize(nbTotalBounds); //KS - must be initialized so that userData is NULL for SQ-only shapes
mContactDistance.resizeUninitialized(nbTotalBounds);
mAddedHandleMap.resize(nbTotalBounds);
@@ -1513,7 +1581,9 @@ void SimpleAABBManager::reserveShapeSpace(PxU32 nbTotalBounds)
#pragma warning(disable: 4355 ) // "this" used in base member initializer list
#endif
-SimpleAABBManager::SimpleAABBManager(BroadPhase& bp, BoundsArray& boundsArray, Ps::Array<PxReal, Ps::VirtualAllocator>& contactDistance, PxU32 maxNbAggregates, PxU32 maxNbShapes, Ps::VirtualAllocator& allocator, PxU64 contextID) :
+SimpleAABBManager::SimpleAABBManager( BroadPhase& bp, BoundsArray& boundsArray, Ps::Array<PxReal, Ps::VirtualAllocator>& contactDistance,
+ PxU32 maxNbAggregates, PxU32 maxNbShapes, Ps::VirtualAllocator& allocator, PxU64 contextID,
+ PxPairFilteringMode::Enum kineKineFilteringMode, PxPairFilteringMode::Enum staticKineFilteringMode) :
mFinalizeUpdateTask (contextID),
mChangedHandleMap (allocator),
mGroups (allocator),
@@ -1536,13 +1606,38 @@ SimpleAABBManager::SimpleAABBManager(BroadPhase& bp, BoundsArray& boundsArray, P
mNbAggregates (0),
mFirstFreeAggregate (PX_INVALID_U32),
mTimestamp (0),
- mAggregateGroupTide (BP_INVALID_BP_HANDLE-1),
+#ifdef BP_USE_AGGREGATE_GROUP_TAIL
+ mAggregateGroupTide (PxU32(Bp::FilterGroup::eAGGREGATE_BASE)),
+#endif
mContextID (contextID)
{
PX_UNUSED(maxNbAggregates); // PT: TODO: use it or remove it
reserveShapeSpace(PxMax(maxNbShapes, 1u));
// mCreatedOverlaps.reserve(16000);
+#ifdef BP_FILTERING_USES_TYPE_IN_GROUP
+ {
+ const bool discardKineKine = kineKineFilteringMode==PxPairFilteringMode::eKILL ? true : false;
+ const bool discardStaticKine = staticKineFilteringMode==PxPairFilteringMode::eKILL ? true : false;
+
+ for(int j=0;j<Bp::FilterType::COUNT;j++)
+ for(int i=0;i<Bp::FilterType::COUNT;i++)
+ mLUT[j][i] = false;
+ mLUT[Bp::FilterType::STATIC][Bp::FilterType::DYNAMIC] = mLUT[Bp::FilterType::DYNAMIC][Bp::FilterType::STATIC] = true;
+ mLUT[Bp::FilterType::STATIC][Bp::FilterType::KINEMATIC] = mLUT[Bp::FilterType::KINEMATIC][Bp::FilterType::STATIC] = !discardStaticKine;
+ mLUT[Bp::FilterType::DYNAMIC][Bp::FilterType::KINEMATIC] = mLUT[Bp::FilterType::KINEMATIC][Bp::FilterType::DYNAMIC] = true;
+ mLUT[Bp::FilterType::DYNAMIC][Bp::FilterType::DYNAMIC] = true;
+ mLUT[Bp::FilterType::KINEMATIC][Bp::FilterType::KINEMATIC] = !discardKineKine;
+
+ mLUT[Bp::FilterType::STATIC][Bp::FilterType::AGGREGATE] = mLUT[Bp::FilterType::AGGREGATE][Bp::FilterType::STATIC] = true;
+ mLUT[Bp::FilterType::KINEMATIC][Bp::FilterType::AGGREGATE] = mLUT[Bp::FilterType::AGGREGATE][Bp::FilterType::KINEMATIC] = true;
+ mLUT[Bp::FilterType::DYNAMIC][Bp::FilterType::AGGREGATE] = mLUT[Bp::FilterType::AGGREGATE][Bp::FilterType::DYNAMIC] = true;
+ mLUT[Bp::FilterType::AGGREGATE][Bp::FilterType::AGGREGATE] = true;
+ }
+#else
+ PX_UNUSED(kineKineFilteringMode);
+ PX_UNUSED(staticKineFilteringMode);
+#endif
}
static void releasePairs(AggPairMap& map)
@@ -1626,7 +1721,7 @@ void SimpleAABBManager::reserveSpaceForBounds(BoundsIndex index)
}
// PT: TODO: what is the "userData" here?
-bool SimpleAABBManager::addBounds(BoundsIndex index, PxReal contactDistance, PxU32 group, void* userData, AggregateHandle aggregateHandle, PxU8 volumeType)
+bool SimpleAABBManager::addBounds(BoundsIndex index, PxReal contactDistance, Bp::FilterGroup::Enum group, void* userData, AggregateHandle aggregateHandle, PxU8 volumeType)
{
// PX_ASSERT(checkID(index));
@@ -1637,7 +1732,7 @@ bool SimpleAABBManager::addBounds(BoundsIndex index, PxReal contactDistance, PxU
{
mVolumeData[index].setSingleActor();
- mAddedHandleMap.set(index);
+ addBPEntry(index);
mPersistentStateChanged = true;
}
@@ -1673,12 +1768,8 @@ bool SimpleAABBManager::addBounds(BoundsIndex index, PxReal contactDistance, PxU
{
// PT: schedule the aggregate for BP insertion here, if we just added its first shape
if(!aggregate->getNbAggregated())
- {
- if(mRemovedHandleMap.test(aggregate->mIndex))
- mRemovedHandleMap.reset(aggregate->mIndex);
- else
- mAddedHandleMap.set(aggregate->mIndex);
- }
+ addBPEntry(aggregate->mIndex);
+
aggregate->addAggregated(index);
// PT: new actor added to aggregate => mark dirty to recompute bounds later
@@ -1734,7 +1825,7 @@ void SimpleAABBManager::removeBounds(BoundsIndex index)
}
// PT: TODO: the userData is actually a PxAggregate pointer. Maybe we could expose/use that.
-AggregateHandle SimpleAABBManager::createAggregate(BoundsIndex index, void* userData, const bool selfCollisions)
+AggregateHandle SimpleAABBManager::createAggregate(BoundsIndex index, Bp::FilterGroup::Enum group, void* userData, const bool selfCollisions)
{
// PX_ASSERT(checkID(index));
@@ -1753,7 +1844,18 @@ AggregateHandle SimpleAABBManager::createAggregate(BoundsIndex index, void* user
mAggregates[handle] = aggregate;
}
+#ifdef BP_USE_AGGREGATE_GROUP_TAIL
+/* #ifdef BP_FILTERING_USES_TYPE_IN_GROUP
+ PxU32 id = index;
+ id<<=2;
+ id|=FilterType::AGGREGATE;
+ initEntry(index, 0.0f, Bp::FilterGroup::Enum(id), userData);
+ #endif*/
initEntry(index, 0.0f, getAggregateGroup(), userData);
+ PX_UNUSED(group);
+#else
+ initEntry(index, 0.0f, group, userData);
+#endif
mVolumeData[index].setAggregate(handle);
@@ -1765,13 +1867,13 @@ AggregateHandle SimpleAABBManager::createAggregate(BoundsIndex index, void* user
return handle;
}
-BoundsIndex SimpleAABBManager::destroyAggregate(AggregateHandle aggregateHandle)
+bool SimpleAABBManager::destroyAggregate(BoundsIndex& index_, Bp::FilterGroup::Enum& group_, AggregateHandle aggregateHandle)
{
#if PX_CHECKED
if(aggregateHandle>=mAggregates.size())
{
Ps::getFoundation().error(PxErrorCode::eINVALID_PARAMETER, __FILE__, __LINE__, "AABBManager::destroyAggregate - aggregateId out of bounds\n");
- return BP_INVALID_BP_HANDLE;
+ return false;
}
{
@@ -1781,7 +1883,7 @@ BoundsIndex SimpleAABBManager::destroyAggregate(AggregateHandle aggregateHandle)
if(firstFreeAggregate==aggregateHandle)
{
Ps::getFoundation().error(PxErrorCode::eINVALID_PARAMETER, __FILE__, __LINE__, "AABBManager::destroyAggregate - aggregate has already been removed\n");
- return BP_INVALID_BP_HANDLE;
+ return false;
}
firstFreeAggregate = PxU32(reinterpret_cast<size_t>(mAggregates[firstFreeAggregate]));
}
@@ -1794,7 +1896,7 @@ BoundsIndex SimpleAABBManager::destroyAggregate(AggregateHandle aggregateHandle)
if(aggregate->getNbAggregated())
{
Ps::getFoundation().error(PxErrorCode::eINVALID_PARAMETER, __FILE__, __LINE__, "AABBManager::destroyAggregate - aggregate still has bounds that needs removed\n");
- return BP_INVALID_BP_HANDLE;
+ return false;
}
#endif
@@ -1813,7 +1915,12 @@ BoundsIndex SimpleAABBManager::destroyAggregate(AggregateHandle aggregateHandle)
// PT: TODO: shouldn't it be compared to mUsedSize?
PX_ASSERT(index < mVolumeData.size());
+ index_ = index;
+ group_ = mGroups[index];
+
+#ifdef BP_USE_AGGREGATE_GROUP_TAIL
releaseAggregateGroup(mGroups[index]);
+#endif
resetEntry(index);
mPersistentStateChanged = true;
@@ -1821,7 +1928,7 @@ BoundsIndex SimpleAABBManager::destroyAggregate(AggregateHandle aggregateHandle)
PX_ASSERT(mNbAggregates);
mNbAggregates--;
- return index;
+ return true;
}
void SimpleAABBManager::handleOriginShift()
@@ -1832,7 +1939,7 @@ void SimpleAABBManager::handleOriginShift()
// PT: TODO: check that aggregates code is correct here
for(PxU32 i=0; i<mUsedSize; i++)
{
- if(mGroups[i] == PX_INVALID_U32)
+ if(mGroups[i] == Bp::FilterGroup::eINVALID)
continue;
{
@@ -1986,7 +2093,7 @@ void SimpleAABBManager::updateAABBsAndBP(PxU32 numCpuTasks, Cm::FlushPool& flush
if(mVolumeData[handle].isSingleActor())
{
- PX_ASSERT(mGroups[handle] != PX_INVALID_U32);
+ PX_ASSERT(mGroups[handle] != Bp::FilterGroup::eINVALID);
mUpdatedHandles.pushBack(handle); // PT: TODO: BoundsIndex-to-ShapeHandle confusion here
}
else
@@ -2097,7 +2204,11 @@ void SimpleAABBManager::finalizeUpdate(PxU32 numCpuTasks, PxcScratchAllocator* s
const BroadPhaseUpdateData updateData( mAddedHandles.begin(), mAddedHandles.size(),
mUpdatedHandles.begin(), mUpdatedHandles.size(),
mRemovedHandles.begin(), mRemovedHandles.size(),
- mBoundsArray.begin(), mGroups.begin(), mContactDistance.begin(), mBoundsArray.getCapacity(),
+ mBoundsArray.begin(), mGroups.begin(),
+#ifdef BP_FILTERING_USES_TYPE_IN_GROUP
+ &mLUT[0][0],
+#endif
+ mContactDistance.begin(), mBoundsArray.getCapacity(),
mPersistentStateChanged || mBoundsArray.hasChanged());
mPersistentStateChanged = false;
@@ -2203,7 +2314,10 @@ static void computePairDeltas(/*const*/ Ps::Array<Pair>& newPairs, const Ps::Arr
}
#endif
-PX_FORCE_INLINE void PersistentPairs::updatePairs( PxU32 timestamp, const PxBounds3* bounds, const float* contactDistances, const PxU32* groups,
+PX_FORCE_INLINE void PersistentPairs::updatePairs( PxU32 timestamp, const PxBounds3* bounds, const float* contactDistances, const Bp::FilterGroup::Enum* groups,
+#ifdef BP_FILTERING_USES_TYPE_IN_GROUP
+ const bool* lut,
+#endif
Ps::Array<VolumeData>& volumeData, Ps::Array<AABBOverlap>* createdOverlaps, Ps::Array<AABBOverlap>* destroyedOverlaps)
{
if(mTimestamp==timestamp)
@@ -2212,7 +2326,11 @@ PX_FORCE_INLINE void PersistentPairs::updatePairs( PxU32 timestamp, const PxBoun
mTimestamp = timestamp;
#ifdef USE_MBP_PAIR_MANAGER
+ #ifdef BP_FILTERING_USES_TYPE_IN_GROUP
+ findOverlaps(mPM, bounds, contactDistances, groups, lut);
+ #else
findOverlaps(mPM, bounds, contactDistances, groups);
+ #endif
PxU32 i=0;
PxU32 nbActivePairs = mPM.mNbActivePairs;
@@ -2296,7 +2414,11 @@ PersistentAggregateAggregatePair* SimpleAABBManager::createPersistentAggregateAg
void SimpleAABBManager::updatePairs(PersistentPairs& p)
{
+#ifdef BP_FILTERING_USES_TYPE_IN_GROUP
+ p.updatePairs(mTimestamp, mBoundsArray.begin(), mContactDistance.begin(), mGroups.begin(), &mLUT[0][0], mVolumeData, mCreatedOverlaps, mDestroyedOverlaps);
+#else
p.updatePairs(mTimestamp, mBoundsArray.begin(), mContactDistance.begin(), mGroups.begin(), mVolumeData, mCreatedOverlaps, mDestroyedOverlaps);
+#endif
}
void SimpleAABBManager::processBPCreatedPair(const BroadPhasePair& pair)
@@ -2567,8 +2689,11 @@ void SimpleAABBManager::postBroadPhase(PxBaseTask*, PxBaseTask* narrowPhaseUnloc
}
}
- mAddedHandleMap.clear();
- mRemovedHandleMap.clear();
+ {
+ PX_PROFILE_ZONE("SimpleAABBManager::postBroadPhase - clear", getContextId());
+ mAddedHandleMap.clear();
+ mRemovedHandleMap.clear();
+ }
}
void SimpleAABBManager::freeBuffers()