diff options
| author | Sheikh Dawood <[email protected]> | 2018-05-25 09:54:38 -0500 |
|---|---|---|
| committer | Sheikh Dawood <[email protected]> | 2018-05-25 09:54:38 -0500 |
| commit | b99b3783cd7e3fb1bb0a07dc472b2fc000c4cdc1 (patch) | |
| tree | de67d7adc7cc66d44c3e0a399d94d1db6bcebd0c /PhysX_3.4/Source/LowLevelAABB/include | |
| parent | PhysX 3.4, APEX 1.4 patch release @23933511 (diff) | |
| download | physx-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/include')
4 files changed, 182 insertions, 89 deletions
diff --git a/PhysX_3.4/Source/LowLevelAABB/include/BpAABBManagerTasks.h b/PhysX_3.4/Source/LowLevelAABB/include/BpAABBManagerTasks.h index 829b9ef1..d61bd727 100644 --- a/PhysX_3.4/Source/LowLevelAABB/include/BpAABBManagerTasks.h +++ b/PhysX_3.4/Source/LowLevelAABB/include/BpAABBManagerTasks.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/include/BpBroadPhase.h b/PhysX_3.4/Source/LowLevelAABB/include/BpBroadPhase.h index 5d96af54..b69825dd 100644 --- a/PhysX_3.4/Source/LowLevelAABB/include/BpBroadPhase.h +++ b/PhysX_3.4/Source/LowLevelAABB/include/BpBroadPhase.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/include/BpBroadPhaseUpdate.h b/PhysX_3.4/Source/LowLevelAABB/include/BpBroadPhaseUpdate.h index c6c738f1..b6ab1a61 100644 --- a/PhysX_3.4/Source/LowLevelAABB/include/BpBroadPhaseUpdate.h +++ b/PhysX_3.4/Source/LowLevelAABB/include/BpBroadPhaseUpdate.h @@ -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. - #ifndef BP_BROADPHASE_UPDATE_H #define BP_BROADPHASE_UPDATE_H @@ -39,22 +38,106 @@ namespace physx { - namespace Bp { +typedef PxU32 ShapeHandle; +typedef PxU32 BpHandle; +#define BP_INVALID_BP_HANDLE 0x3fffffff + +#define ALIGN_SIZE_16(size) ((unsigned(size)+15)&(unsigned(~15))) + +#define BP_USE_AGGREGATE_GROUP_TAIL +#define BP_FILTERING_USES_TYPE_IN_GROUP + + /* + \brief AABBManager volumes with the same filter group value are guaranteed never to generate an overlap pair. + \note To ensure that static pairs never overlap, add static shapes with eSTATICS. + To ensure that particle bounds never overlap, add particle bounds with ePARTICLES. + To ensure that cloth bounds never overlap, add cloth bounds with eCLOTH. + To ensure that cloth bounds never overlap with cloth or particle bounds, use eCLOTH_NO_PARTICLE_INTERACTION. + The value eDYNAMICS_BASE provides a minimum recommended group value for dynamic shapes. + If dynamics shapes are assigned group values greater than or equal to eDYNAMICS_BASE then + they are allowed to generate broadphase overlaps with particles and statics, and other dynamic shapes provided + they have different group values. + @see AABBManager::createVolume + */ + struct FilterGroup + { + enum Enum + { + eSTATICS = 0, + ePARTICLES = 1, + eCLOTH_NO_PARTICLE_INTERACTION = ePARTICLES, + eCLOTH = 2, + eDYNAMICS_BASE = 3, +#ifdef BP_USE_AGGREGATE_GROUP_TAIL + eAGGREGATE_BASE = 0xfffffffe, +#endif + eINVALID = 0xffffffff + }; + }; + +#ifdef BP_FILTERING_USES_TYPE_IN_GROUP + // PT: the cloth & particles use the DYNAMIC type here. + struct FilterType + { + enum Enum + { + STATIC = 0, + KINEMATIC = 1, + DYNAMIC = 2, + AGGREGATE = 3, + + COUNT = 4 + }; + }; +#endif + + PX_FORCE_INLINE Bp::FilterGroup::Enum getFilterGroup_Statics() + { + return Bp::FilterGroup::eSTATICS; + } -#if PX_USE_16_BIT_HANDLES - typedef PxU16 ShapeHandle; - typedef PxU16 BpHandle; -#define BP_INVALID_BP_HANDLE 0xffff + PX_FORCE_INLINE Bp::FilterGroup::Enum getFilterGroup_Dynamics(PxU32 rigidId, bool isKinematic) + { + const PxU32 group = rigidId + Bp::FilterGroup::eDYNAMICS_BASE; +#ifdef BP_FILTERING_USES_TYPE_IN_GROUP + const PxU32 type = isKinematic ? FilterType::KINEMATIC : FilterType::DYNAMIC; + return Bp::FilterGroup::Enum((group<<2)|type); #else - typedef PxU32 ShapeHandle; - typedef PxU32 BpHandle; -#define BP_INVALID_BP_HANDLE 0x3fffffff + PX_UNUSED(isKinematic); + return Bp::FilterGroup::Enum(group); #endif + } -#define ALIGN_SIZE_16(size) ((unsigned(size)+15)&(unsigned(~15))) + PX_FORCE_INLINE Bp::FilterGroup::Enum getFilterGroup(bool isStatic, PxU32 rigidId, bool isKinematic) + { + return isStatic ? getFilterGroup_Statics() : getFilterGroup_Dynamics(rigidId, isKinematic); + } +#ifdef BP_FILTERING_USES_TYPE_IN_GROUP + PX_FORCE_INLINE bool groupFiltering(const Bp::FilterGroup::Enum group0, const Bp::FilterGroup::Enum group1, const bool* PX_RESTRICT lut) + { +/* const int g0 = group0 & ~3; + const int g1 = group1 & ~3; + if(g0==g1) + return false;*/ + if(group0==group1) + { + PX_ASSERT((group0 & ~3)==(group1 & ~3)); + return false; + } + + const int type0 = group0 & 3; + const int type1 = group1 & 3; + return lut[type0*4+type1]; + } +#else + PX_FORCE_INLINE bool groupFiltering(const Bp::FilterGroup::Enum group0, const Bp::FilterGroup::Enum group1) + { + return group0!=group1; + } +#endif /* \brief Encode a single float value with lossless encoding to integer @@ -86,7 +169,6 @@ namespace Bp @see BroadPhaseUpdateData */ - typedef PxU32 ValType; class IntegerAABB @@ -296,7 +378,6 @@ public: mMinMax[MAX_X] = mMinMax[MAX_Y] = mMinMax[MAX_Z] = 0x00800000; ///PX_IR(0.0f); } - ValType mMinMax[6]; private: @@ -313,7 +394,6 @@ PX_FORCE_INLINE ValType encodeMin(const PxBounds3& bounds, PxU32 axis, PxReal co const PxU32 min = PxUnionCast<PxU32, PxF32>(val); const PxU32 m = IntegerAABB::encodeFloatMin(min); return m; - } PX_FORCE_INLINE ValType encodeMax(const PxBounds3& bounds, PxU32 axis, PxReal contactDistance) @@ -374,7 +454,11 @@ public: const ShapeHandle* created, const PxU32 createdSize, const ShapeHandle* updated, const PxU32 updatedSize, const ShapeHandle* removed, const PxU32 removedSize, - const PxBounds3* boxBounds, const ShapeHandle* boxGroups, const PxReal* boxContactDistances, const PxU32 boxesCapacity, + const PxBounds3* boxBounds, const Bp::FilterGroup::Enum* boxGroups, +#ifdef BP_FILTERING_USES_TYPE_IN_GROUP + const bool* lut, +#endif + const PxReal* boxContactDistances, const PxU32 boxesCapacity, const bool stateChanged) : mCreated (created), mCreatedSize (createdSize), @@ -384,28 +468,34 @@ public: mRemovedSize (removedSize), mBoxBounds (boxBounds), mBoxGroups (boxGroups), +#ifdef BP_FILTERING_USES_TYPE_IN_GROUP + mLUT (lut), +#endif mContactDistance(boxContactDistances), mBoxesCapacity (boxesCapacity), mStateChanged (stateChanged) { } - PX_FORCE_INLINE const ShapeHandle* getCreatedHandles() const { return mCreated; } - PX_FORCE_INLINE PxU32 getNumCreatedHandles() const { return mCreatedSize; } + PX_FORCE_INLINE const ShapeHandle* getCreatedHandles() const { return mCreated; } + PX_FORCE_INLINE PxU32 getNumCreatedHandles() const { return mCreatedSize; } - PX_FORCE_INLINE const ShapeHandle* getUpdatedHandles() const { return mUpdated; } - PX_FORCE_INLINE PxU32 getNumUpdatedHandles() const { return mUpdatedSize; } + PX_FORCE_INLINE const ShapeHandle* getUpdatedHandles() const { return mUpdated; } + PX_FORCE_INLINE PxU32 getNumUpdatedHandles() const { return mUpdatedSize; } - PX_FORCE_INLINE const ShapeHandle* getRemovedHandles() const { return mRemoved; } - PX_FORCE_INLINE PxU32 getNumRemovedHandles() const { return mRemovedSize; } + PX_FORCE_INLINE const ShapeHandle* getRemovedHandles() const { return mRemoved; } + PX_FORCE_INLINE PxU32 getNumRemovedHandles() const { return mRemovedSize; } - PX_FORCE_INLINE const PxBounds3* getAABBs() const { return mBoxBounds; } - PX_FORCE_INLINE const ShapeHandle* getGroups() const { return mBoxGroups; } - PX_FORCE_INLINE PxU32 getCapacity() const { return mBoxesCapacity; } + PX_FORCE_INLINE const PxBounds3* getAABBs() const { return mBoxBounds; } + PX_FORCE_INLINE const Bp::FilterGroup::Enum* getGroups() const { return mBoxGroups; } +#ifdef BP_FILTERING_USES_TYPE_IN_GROUP + PX_FORCE_INLINE const bool* getLUT() const { return mLUT; } +#endif + PX_FORCE_INLINE PxU32 getCapacity() const { return mBoxesCapacity; } - PX_FORCE_INLINE const PxReal* getContactDistance() const { return mContactDistance; } + PX_FORCE_INLINE const PxReal* getContactDistance() const { return mContactDistance; } - PX_FORCE_INLINE bool getStateChanged() const { return mStateChanged; } + PX_FORCE_INLINE bool getStateChanged() const { return mStateChanged; } #if PX_CHECKED static bool isValid(const BroadPhaseUpdateData& updateData, const BroadPhase& bp); @@ -414,20 +504,23 @@ public: private: - const ShapeHandle* mCreated; - PxU32 mCreatedSize; + const ShapeHandle* mCreated; + PxU32 mCreatedSize; - const ShapeHandle* mUpdated; - PxU32 mUpdatedSize; + const ShapeHandle* mUpdated; + PxU32 mUpdatedSize; - const ShapeHandle* mRemoved; - PxU32 mRemovedSize; + const ShapeHandle* mRemoved; + PxU32 mRemovedSize; - const PxBounds3* mBoxBounds; - const ShapeHandle* mBoxGroups; - const PxReal* mContactDistance; - PxU32 mBoxesCapacity; - bool mStateChanged; + const PxBounds3* mBoxBounds; + const Bp::FilterGroup::Enum* mBoxGroups; +#ifdef BP_FILTERING_USES_TYPE_IN_GROUP + const bool* mLUT; +#endif + const PxReal* mContactDistance; + PxU32 mBoxesCapacity; + bool mStateChanged; }; } //namespace Bp diff --git a/PhysX_3.4/Source/LowLevelAABB/include/BpSimpleAABBManager.h b/PhysX_3.4/Source/LowLevelAABB/include/BpSimpleAABBManager.h index 0cc146bc..8044cdeb 100644 --- a/PhysX_3.4/Source/LowLevelAABB/include/BpSimpleAABBManager.h +++ b/PhysX_3.4/Source/LowLevelAABB/include/BpSimpleAABBManager.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. @@ -42,7 +42,7 @@ #include "PsFoundation.h" #include "BpAABBManagerTasks.h" #include "PsHashSet.h" - +#include "PxFiltering.h" /** \brief The maximum number of bounds allowed in an aggregate @@ -101,30 +101,6 @@ namespace Bp void* mPairUserData; //For deleted pairs, this is the user data written by the application to the pair }; - /* - \brief AABBManager volumes with the same filter group value are guaranteed never to generate an overlap pair. - \note To ensure that static pairs never overlap, add static shapes with eSTATICS. - To ensure that particle bounds never overlap, add particle bounds with ePARTICLES. - To ensure that cloth bounds never overlap, add cloth bounds with eCLOTH. - To ensure that cloth bounds never overlap with cloth or particle bounds, use eCLOTH_NO_PARTICLE_INTERACTION. - The value eDYNAMICS_BASE provides a minimum recommended group value for dynamic shapes. - If dynamics shapes are assigned group values greater than or equal to eDYNAMICS_BASE then - they are allowed to generate broadphase overlaps with particles and statics, and other dynamic shapes provided - they have different group values. - @see AABBManager::createVolume - */ - struct FilterGroup - { - enum Enum - { - eSTATICS, - ePARTICLES, - eCLOTH_NO_PARTICLE_INTERACTION = ePARTICLES, - eCLOTH, - eDYNAMICS_BASE - }; - }; - class BoundsArray : public Ps::UserAllocated { PX_NOCOPY(BoundsArray) @@ -317,14 +293,16 @@ namespace Bp PX_NOCOPY(SimpleAABBManager) public: - SimpleAABBManager(BroadPhase& bp, BoundsArray& boundsArray, Ps::Array<PxReal, Ps::VirtualAllocator>& contactDistance, PxU32 maxNbAggregates, PxU32 maxNbShapes, Ps::VirtualAllocator& allocator, PxU64 contextID); + 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); void destroy(); - AggregateHandle createAggregate(BoundsIndex index, void* userData, const bool selfCollisions); - BoundsIndex destroyAggregate(AggregateHandle aggregateHandle); + AggregateHandle createAggregate(BoundsIndex index, Bp::FilterGroup::Enum group, void* userData, const bool selfCollisions); + bool destroyAggregate(BoundsIndex& index, Bp::FilterGroup::Enum& group, AggregateHandle aggregateHandle); - bool addBounds(BoundsIndex index, PxReal contactDistance, PxU32 group, void* userdata, AggregateHandle aggregateHandle, PxU8 volumeType); + bool addBounds(BoundsIndex index, PxReal contactDistance, Bp::FilterGroup::Enum group, void* userdata, AggregateHandle aggregateHandle, PxU8 volumeType); void reserveSpaceForBounds(BoundsIndex index); void removeBounds(BoundsIndex index); @@ -341,6 +319,13 @@ namespace Bp mVolumeData[handle].setVolumeType(volumeType); } + void setBPGroup(BoundsIndex index, Bp::FilterGroup::Enum group) + { + PX_ASSERT((index + 1) < mVolumeData.size()); + PX_ASSERT(group != Bp::FilterGroup::eINVALID); // PT: we use group == Bp::FilterGroup::eINVALID to mark removed/invalid entries + mGroups[index] = group; + } + // PT: TODO: revisit name: we don't "update AABBs" here anymore void updateAABBsAndBP( PxU32 numCpuTasks, Cm::FlushPool& flushPool, @@ -410,7 +395,6 @@ namespace Bp private: void reserveShapeSpace(PxU32 nbShapes); - //Cm::DelegateTask<SimpleAABBManager, &SimpleAABBManager::postBroadPhase> mPostBroadPhase; FinalizeUpdateTask mFinalizeUpdateTask; @@ -429,17 +413,24 @@ namespace Bp mRemovedHandleMap.set(index); // PT: else we need to remove it from the BP } + PX_FORCE_INLINE void addBPEntry(BoundsIndex index) + { + if(mRemovedHandleMap.test(index)) + mRemovedHandleMap.reset(index); + else + mAddedHandleMap.set(index); + } + // PT: TODO: when do we need 'Ps::VirtualAllocator' and when don't we? When memory is passed to GPU BP? - // PT: TODO: this group array won't compile on platforms where PX_USE_16_BIT_HANDLES is true, because it's silently - // passed to BroadPhaseUpdateData, which expects ShapeHandle for groups (not PxU32). I cannot change it immediately - // because of the comment below, saying it sticks PX_INVALID_U32 in there. Not sure if 0xffff would work. //ML: we create mGroups and mContactDistance in the SimpleAABBManager constructor. Ps::Array will take Ps::VirtualAllocator as a parameter. Therefore, if GPU BP is using, //we will passed a pinned host memory allocator, otherwise, we will just pass a normal allocator. - Ps::Array<PxU32, Ps::VirtualAllocator> mGroups; // NOTE: we stick PX_INVALID_U32 in this slot to indicate that the entry is invalid (removed or never inserted.) + Ps::Array<Bp::FilterGroup::Enum, Ps::VirtualAllocator> mGroups; // NOTE: we stick Bp::FilterGroup::eINVALID in this slot to indicate that the entry is invalid (removed or never inserted.) Ps::Array<PxReal, Ps::VirtualAllocator>& mContactDistance; Ps::Array<VolumeData> mVolumeData; - - PX_FORCE_INLINE void initEntry(BoundsIndex index, PxReal contactDistance, PxU32 group, void* userData) +#ifdef BP_FILTERING_USES_TYPE_IN_GROUP + bool mLUT[Bp::FilterType::COUNT][Bp::FilterType::COUNT]; +#endif + PX_FORCE_INLINE void initEntry(BoundsIndex index, PxReal contactDistance, Bp::FilterGroup::Enum group, void* userData) { if((index+1) >= mVolumeData.size()) reserveShapeSpace(index+1); @@ -447,7 +438,7 @@ namespace Bp // PT: TODO: why is this needed at all? Why aren't size() and capacity() enough? mUsedSize = PxMax(index+1, mUsedSize); - PX_ASSERT(group != PX_INVALID_U32); // PT: we use group == PX_INVALID_U32 to mark removed/invalid entries + PX_ASSERT(group != Bp::FilterGroup::eINVALID); // PT: we use group == Bp::FilterGroup::eINVALID to mark removed/invalid entries mGroups[index] = group; mContactDistance.begin()[index] = contactDistance; mVolumeData[index].setUserData(userData); @@ -455,7 +446,7 @@ namespace Bp PX_FORCE_INLINE void resetEntry(BoundsIndex index) { - mGroups[index] = PX_INVALID_U32; + mGroups[index] = Bp::FilterGroup::eINVALID; mContactDistance.begin()[index] = 0.0f; mVolumeData[index].reset(); } @@ -490,12 +481,13 @@ namespace Bp AggPairMap mActorAggregatePairs; AggPairMap mAggregateAggregatePairs; +#ifdef BP_USE_AGGREGATE_GROUP_TAIL // PT: TODO: even in the 3.4 trunk this stuff is a clumsy mess: groups are "BpHandle" suddenly passed // to BroadPhaseUpdateData as "ShapeHandle". //Free aggregate group ids. - BpHandle mAggregateGroupTide; - Ps::Array<BpHandle> mFreeAggregateGroups; // PT: TODO: remove this useless array - + PxU32 mAggregateGroupTide; + Ps::Array<Bp::FilterGroup::Enum> mFreeAggregateGroups; // PT: TODO: remove this useless array +#endif Ps::HashSet<Pair> mCreatedPairs; PxU64 mContextID; @@ -506,23 +498,31 @@ namespace Bp return mAggregates[handle]; } - PX_FORCE_INLINE void releaseAggregateGroup(const BpHandle group) +#ifdef BP_USE_AGGREGATE_GROUP_TAIL + PX_FORCE_INLINE void releaseAggregateGroup(const Bp::FilterGroup::Enum group) { - PX_ASSERT(group != BP_INVALID_BP_HANDLE); + PX_ASSERT(group != Bp::FilterGroup::eINVALID); mFreeAggregateGroups.pushBack(group); } - PX_FORCE_INLINE BpHandle getAggregateGroup() + PX_FORCE_INLINE Bp::FilterGroup::Enum getAggregateGroup() { - BpHandle group; + PxU32 id; if(mFreeAggregateGroups.size()) - group = mFreeAggregateGroups.popBack(); + id = mFreeAggregateGroups.popBack(); else - group = mAggregateGroupTide--; - PX_ASSERT(group!=BP_INVALID_BP_HANDLE); + { + id = mAggregateGroupTide--; + #ifdef BP_FILTERING_USES_TYPE_IN_GROUP + id<<=2; + id|=FilterType::AGGREGATE; + #endif + } + const Bp::FilterGroup::Enum group = Bp::FilterGroup::Enum(id); + PX_ASSERT(group != Bp::FilterGroup::eINVALID); return group; } - +#endif void startAggregateBoundsComputationTasks(PxU32 nbToGo, PxU32 numCpuTasks, Cm::FlushPool& flushPool); PersistentActorAggregatePair* createPersistentActorAggregatePair(ShapeHandle volA, ShapeHandle volB); PersistentAggregateAggregatePair* createPersistentAggregateAggregatePair(ShapeHandle volA, ShapeHandle volB); |