RavEngine
Loading...
Searching...
No Matches
physx::Bp::BroadPhaseMBP Class Reference
Inheritance diagram for physx::Bp::BroadPhaseMBP:
[legend]
Collaboration diagram for physx::Bp::BroadPhaseMBP:
[legend]

Public Member Functions

 BroadPhaseMBP (PxU32 maxNbRegions, PxU32 maxNbBroadPhaseOverlaps, PxU32 maxNbStaticShapes, PxU32 maxNbDynamicShapes, PxU64 contextID)
 
virtual void getCaps (PxBroadPhaseCaps &caps) const
 Gets broad-phase caps.
 
virtual PxU32 getNbRegions () const
 Returns number of regions currently registered in the broad-phase.
 
virtual PxU32 getRegions (PxBroadPhaseRegionInfo *userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const
 Gets broad-phase regions.
 
virtual PxU32 addRegion (const PxBroadPhaseRegion &region, bool populateRegion, const PxBounds3 *boundsArray, const PxReal *contactDistance)
 Adds a new broad-phase region.
 
virtual bool removeRegion (PxU32 handle)
 Removes a broad-phase region.
 
virtual PxU32 getNbOutOfBoundsObjects () const
 
virtual const PxU32 * getOutOfBoundsObjects () const
 
virtual PxBroadPhaseType::Enum getType () const PX_OVERRIDE
 
virtual void release () PX_OVERRIDE
 Shutdown of the broadphase.
 
virtual void update (PxcScratchAllocator *scratchAllocator, const BroadPhaseUpdateData &updateData, physx::PxBaseTask *continuation) PX_OVERRIDE
 Updates the broadphase and computes the lists of created/deleted pairs.
 
virtual void preBroadPhase (const Bp::BroadPhaseUpdateData &) PX_OVERRIDE
 prepare broad phase data.
 
virtual void fetchBroadPhaseResults () PX_OVERRIDE
 Fetch the results of any asynchronous broad phase work.
 
virtual const BroadPhasePair * getCreatedPairs (PxU32 &) const PX_OVERRIDE
 
virtual const BroadPhasePair * getDeletedPairs (PxU32 &) const PX_OVERRIDE
 Get deleted pairs.
 
virtual void freeBuffers () PX_OVERRIDE
 After the broadphase has completed its update() function and the created/deleted pairs have been queried with getCreatedPairs/getDeletedPairs it is desirable to free any memory that was temporarily acquired for the update but is is no longer required post-update. This can be achieved with the function freeBuffers().
 
virtual void shiftOrigin (const PxVec3 &shift, const PxBounds3 *boundsArray, const PxReal *contactDistances) PX_OVERRIDE
 Adjust internal structures after all bounds have been adjusted due to a scene origin shift.
 
void setUpdateData (const BroadPhaseUpdateData &updateData)
 
void addObjects (const BroadPhaseUpdateData &updateData)
 
void removeObjects (const BroadPhaseUpdateData &updateData)
 
void updateObjects (const BroadPhaseUpdateData &updateData)
 
void update ()
 
void postUpdate ()
 
void allocateMappingArray (PxU32 newCapacity)
 
PxU32 getCurrentNbPairs () const
 
- Public Member Functions inherited from physx::PxUserAllocated
PX_INLINE void * operator new (size_t, void *address)
 
PX_INLINE void operator delete (void *, void *)
 
template<typename Alloc >
PX_INLINE void * operator new (size_t size, Alloc alloc, const char *fileName, int line)
 
template<typename Alloc >
PX_INLINE void * operator new (size_t size, size_t, Alloc alloc, const char *fileName, int line)
 
template<typename Alloc >
PX_INLINE void * operator new[] (size_t size, Alloc alloc, const char *fileName, int line)
 
template<typename Alloc >
PX_INLINE void * operator new[] (size_t size, size_t, Alloc alloc, const char *fileName, int line)
 
template<typename Alloc >
PX_INLINE void operator delete (void *ptr, Alloc alloc, const char *fileName, int line)
 
template<typename Alloc >
PX_INLINE void operator delete[] (void *ptr, Alloc alloc, const char *fileName, int line)
 
PX_INLINE void operator delete (void *ptr)
 
PX_INLINE void operator delete[] (void *ptr)
 

Public Attributes

internalMBP::MBP * mMBP
 
MBP_Handle * mMapping
 
PxU32 mCapacity
 
PxArray< BroadPhasePair > mCreated
 
PxArray< BroadPhasePair > mDeleted
 
const Bp::FilterGroup::Enum * mGroups
 
const BpFilter * mFilter
 
const PxU64 mContextID
 

Additional Inherited Members

- Static Public Member Functions inherited from physx::Bp::BroadPhase
static BroadPhase * create (const PxBroadPhaseType::Enum bpType, const PxU32 maxNbRegions, const PxU32 maxNbBroadPhaseOverlaps, const PxU32 maxNbStaticShapes, const PxU32 maxNbDynamicShapes, PxU64 contextID)
 Instantiate a BroadPhase instance.
 

Member Function Documentation

◆ addRegion()

PxU32 BroadPhaseMBP::addRegion ( const PxBroadPhaseRegion &  region,
bool  populateRegion,
const PxBounds3 *  bounds,
const PxReal *  distances 
)
virtual

Adds a new broad-phase region.

The total number of regions is limited to PxBroadPhaseCaps::mMaxNbRegions. If that number is exceeded, the call is ignored.

The newly added region will be automatically populated with already existing objects that touch it, if the 'populateRegion' parameter is set to true. Otherwise the newly added region will be empty, and it will only be populated with objects when those objects are added to the simulation, or updated if they already exist.

Using 'populateRegion=true' has a cost, so it is best to avoid it if possible. In particular it is more efficient to create the empty regions first (with populateRegion=false) and then add the objects afterwards (rather than the opposite).

Objects automatically move from one region to another during their lifetime. The system keeps tracks of what regions a given object is in. It is legal for an object to be in an arbitrary number of regions. However if an object leaves all regions, or is created outside of all regions, several things happen:

  • collisions get disabled for this object
  • the object appears in the getOutOfBoundsObjects() array

If an out-of-bounds object, whose collisions are disabled, re-enters a valid broadphase region, then collisions are re-enabled for that object.

Parameters
region[in] User-provided region data
populateRegion[in] True to automatically populate the newly added region with existing objects touching it
bounds[in] User-managed array of bounds
distances[in] User-managed array of distances
Returns
Handle for newly created region, or 0xffffffff in case of failure.
See also
PxBroadPhaseRegion getOutOfBoundsObjects()

Reimplemented from physx::Bp::BroadPhaseBase.

◆ fetchBroadPhaseResults()

virtual void physx::Bp::BroadPhaseMBP::fetchBroadPhaseResults ( )
inlinevirtual

Fetch the results of any asynchronous broad phase work.

Implements physx::Bp::BroadPhase.

◆ freeBuffers()

void BroadPhaseMBP::freeBuffers ( )
virtual

After the broadphase has completed its update() function and the created/deleted pairs have been queried with getCreatedPairs/getDeletedPairs it is desirable to free any memory that was temporarily acquired for the update but is is no longer required post-update. This can be achieved with the function freeBuffers().

Implements physx::Bp::BroadPhase.

◆ getCaps()

void BroadPhaseMBP::getCaps ( PxBroadPhaseCaps &  caps) const
virtual

Gets broad-phase caps.

Parameters
caps[out] Broad-phase caps

Reimplemented from physx::Bp::BroadPhaseBase.

◆ getCreatedPairs()

const BroadPhasePair * BroadPhaseMBP::getCreatedPairs ( PxU32 &  nbCreatedPairs) const
virtual

Implements physx::Bp::BroadPhase.

◆ getDeletedPairs()

const BroadPhasePair * BroadPhaseMBP::getDeletedPairs ( PxU32 &  nbDeletedPairs) const
virtual

Get deleted pairs.

Note that a deleted pair can only be reported if that pair has already appeared in the list of created pairs in an earlier update. A lost overlap occurs when a pair of bounds previously overlapped on all three axes but have now separated on at least one axis. A lost overlap must involve at least one of the bounds of the lost overlap pair appearing in the updated list. Lost overlaps arising from removal of bounds from the broadphase do not appear in the list of deleted pairs. It is impossible for the same pair to appear simultaneously in the list of created and deleted pairs.

Parameters
nbDeletedPairs[out] The number of deleted overlap pairs computed in the execution of update() that has just completed.
Returns
The array of deleted overlap pairs computed in the execution of update() that has just completed.

Implements physx::Bp::BroadPhase.

◆ getNbOutOfBoundsObjects()

PxU32 BroadPhaseMBP::getNbOutOfBoundsObjects ( ) const
virtual

Reimplemented from physx::Bp::BroadPhaseBase.

◆ getNbRegions()

PxU32 BroadPhaseMBP::getNbRegions ( ) const
virtual

Returns number of regions currently registered in the broad-phase.

Returns
Number of regions

Reimplemented from physx::Bp::BroadPhaseBase.

◆ getOutOfBoundsObjects()

const PxU32 * BroadPhaseMBP::getOutOfBoundsObjects ( ) const
virtual

Reimplemented from physx::Bp::BroadPhaseBase.

◆ getRegions()

PxU32 BroadPhaseMBP::getRegions ( PxBroadPhaseRegionInfo *  userBuffer,
PxU32  bufferSize,
PxU32  startIndex = 0 
) const
virtual

Gets broad-phase regions.

Parameters
userBuffer[out] Returned broad-phase regions
bufferSize[in] Size of provided userBuffer.
startIndex[in] Index of first desired region, in [0 ; getNbRegions()[
Returns
Number of written out regions.
See also
PxBroadPhaseRegionInfo

Reimplemented from physx::Bp::BroadPhaseBase.

◆ getType()

virtual PxBroadPhaseType::Enum physx::Bp::BroadPhaseMBP::getType ( ) const
inlinevirtual

Implements physx::Bp::BroadPhase.

◆ preBroadPhase()

virtual void physx::Bp::BroadPhaseMBP::preBroadPhase ( const Bp::BroadPhaseUpdateData &  updateData)
inlinevirtual

prepare broad phase data.

Implements physx::Bp::BroadPhase.

◆ release()

virtual void physx::Bp::BroadPhaseMBP::release ( )
inlinevirtual

Shutdown of the broadphase.

Implements physx::Bp::BroadPhase.

◆ removeRegion()

bool BroadPhaseMBP::removeRegion ( PxU32  handle)
virtual

Removes a broad-phase region.

If the region still contains objects, and if those objects do not overlap any region any more, they are not automatically removed from the simulation. Instead, the PxBroadPhaseCallback::onObjectOutOfBounds notification is used for each object. Users are responsible for removing the objects from the simulation if this is the desired behavior.

If the handle is invalid, or if a valid handle is removed twice, an error message is sent to the error stream.

Parameters
handle[in] Region's handle, as returned by addRegion
Returns
True if success

Reimplemented from physx::Bp::BroadPhaseBase.

◆ shiftOrigin()

void BroadPhaseMBP::shiftOrigin ( const PxVec3 &  shift,
const PxBounds3 *  boundsArray,
const PxReal *  contactDistances 
)
virtual

Adjust internal structures after all bounds have been adjusted due to a scene origin shift.

Implements physx::Bp::BroadPhase.

◆ update()

void BroadPhaseMBP::update ( PxcScratchAllocator *  scratchAllocator,
const BroadPhaseUpdateData &  updateData,
physx::PxBaseTask *  continuation 
)
virtual

Updates the broadphase and computes the lists of created/deleted pairs.

Parameters
[in]scratchAllocator- a PxcScratchAllocator instance used for temporary memory allocations. This must be non-null.
[in]updateDataa description of changes to the collection of aabbs since the last broadphase update. The changes detail the indices of the bounds that have been added/updated/removed as well as an array of all bound coordinates and an array of group ids used to filter pairs with the same id.
See also
BroadPhaseUpdateData
Parameters
[in]continuationthe task that is in the queue to be executed immediately after the broadphase has completed its update. NULL is not supported.
Note
In PX_CHECKED and PX_DEBUG build configurations illegal input data (that does not conform to the BroadPhaseUpdateData specifications) triggers a special code-path that entirely bypasses the broadphase and issues a warning message to the error stream. No guarantees can be made about the correctness/consistency of broadphase behavior with illegal input data in PX_RELEASE and PX_PROFILE configs because validity checks are not active in these builds.

Implements physx::Bp::BroadPhase.


The documentation for this class was generated from the following files: