RavEngine
Loading...
Searching...
No Matches
physx::Gu::BVH Class Reference

Represents a BVH. More...

#include <GuBVH.h>

Inheritance diagram for physx::Gu::BVH:
[legend]
Collaboration diagram for physx::Gu::BVH:
[legend]

Public Member Functions

PX_PHYSX_COMMON_API BVH (MeshFactory *factory)
 
PX_PHYSX_COMMON_API BVH (MeshFactory *factory, BVHData &data)
 
PX_PHYSX_COMMON_API BVH (const PxBVHInternalData &data)
 
PX_PHYSX_COMMON_API bool init (PxU32 nbPrims, AABBTreeBounds *bounds, const void *boundsData, PxU32 stride, BVHBuildStrategy bs, PxU32 nbPrimsPerLeaf, float enlargement)
 
bool load (PxInputStream &desc)
 
void release ()
 Releases the PxBase instance, please check documentation of release in derived class.
 
virtual bool raycast (const PxVec3 &origin, const PxVec3 &unitDir, float distance, RaycastCallback &cb, PxGeometryQueryFlags flags) const
 Raycast test against a BVH.
 
virtual bool overlap (const PxGeometry &geom, const PxTransform &pose, OverlapCallback &cb, PxGeometryQueryFlags flags) const
 Overlap test against a BVH.
 
virtual bool sweep (const PxGeometry &geom, const PxTransform &pose, const PxVec3 &unitDir, float distance, RaycastCallback &cb, PxGeometryQueryFlags flags) const
 Sweep test against a BVH.
 
virtual bool cull (PxU32 nbPlanes, const PxPlane *planes, OverlapCallback &cb, PxGeometryQueryFlags flags) const
 Frustum culling test against a BVH.
 
virtual PxU32 raycast (const PxVec3 &origin, const PxVec3 &unitDir, PxReal maxDist, PxU32 maxHits, PxU32 *PX_RESTRICT rayHits) const
 Raycast test against a BVH.
 
virtual PxU32 sweep (const PxBounds3 &aabb, const PxVec3 &unitDir, PxReal maxDist, PxU32 maxHits, PxU32 *PX_RESTRICT sweepHits) const
 Sweep test against a BVH.
 
virtual PxU32 overlap (const PxBounds3 &aabb, PxU32 maxHits, PxU32 *PX_RESTRICT overlapHits) const
 AABB overlap test against a BVH.
 
virtual PxU32 getNbBounds () const
 Returns the number of bounds in the BVH.
 
virtual const PxBounds3 * getBounds () const
 Retrieve the read-only bounds in the BVH.
 
virtual void refit ()
 Refit the BVH.
 
virtual bool updateBounds (PxU32 boundsIndex, const PxBounds3 &newBounds)
 Update single bounds.
 
virtual void partialRefit ()
 Refits subset of marked nodes.
 
virtual bool traverse (TraversalCallback &cb) const
 Generic BVH traversal function.
 
virtual void onRefCountZero ()
 
PX_FORCE_INLINE const BVHNode * getNodes () const
 
PX_FORCE_INLINE const PxU32 * getIndices () const
 
PX_FORCE_INLINE const BVHData & getData () const
 
bool getInternalData (PxBVHInternalData &, bool) const
 
bool updateBoundsInternal (PxU32 localIndex, const PxBounds3 &bounds)
 
bool overlap (const ShapeData &shapeData, OverlapCallback &cb, PxGeometryQueryFlags flags) const
 
bool sweep (const ShapeData &shapeData, const PxVec3 &unitDir, float distance, RaycastCallback &cb, PxGeometryQueryFlags flags) const
 
- Public Member Functions inherited from physx::PxBVH
PX_FORCE_INLINE PxBounds3 * getBoundsForModification ()
 Retrieve the bounds in the BVH.
 
virtual const char * getConcreteTypeName () const
 Returns string name of dynamic type.
 
- Public Member Functions inherited from physx::PxBase
template<class T >
T * is ()
 
template<class T >
const T * is () const
 
PX_FORCE_INLINE PxType getConcreteType () const
 Returns concrete type of object.
 
PX_FORCE_INLINE void setBaseFlag (PxBaseFlag::Enum flag, bool value)
 Set PxBaseFlag

 
PX_FORCE_INLINE void setBaseFlags (PxBaseFlags inFlags)
 Set PxBaseFlags

 
PX_FORCE_INLINE PxBaseFlags getBaseFlags () const
 Returns PxBaseFlags.
 
virtual bool isReleasable () const
 Whether the object is subordinate.
 
- 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 Member Functions inherited from physx::Cm::RefCountable
 RefCountable (const PxEMPTY)
 
void preExportDataReset ()
 
 RefCountable (PxU32 initialCount=1)
 
void incRefCount ()
 
void decRefCount ()
 
PX_FORCE_INLINE PxU32 getRefCount () const
 

Additional Inherited Members

- Static Public Member Functions inherited from physx::Cm::RefCountable
static void getBinaryMetaData (PxOutputStream &stream)
 
- Protected Member Functions inherited from physx::PxBVH
PX_INLINE PxBVH (PxType concreteType, PxBaseFlags baseFlags)
 
PX_INLINE PxBVH (PxBaseFlags baseFlags)
 
virtual bool isKindOf (const char *name) const
 Returns whether a given type name matches with the type of this instance.
 
- Protected Member Functions inherited from physx::PxBase
PX_INLINE PxBase (PxType concreteType, PxBaseFlags baseFlags)
 Constructor setting concrete type and base flags.
 
PX_INLINE PxBase (PxBaseFlags baseFlags)
 Deserialization constructor setting base flags.
 
virtual ~PxBase ()
 Destructor.
 
template<class T >
bool typeMatch () const
 
- Protected Attributes inherited from physx::PxBase
PxType mConcreteType
 
PxBaseFlags mBaseFlags
 
PxU32 mBuiltInRefCount
 

Detailed Description

Represents a BVH.

Member Function Documentation

◆ cull()

bool BVH::cull ( PxU32  nbPlanes,
const PxPlane *  planes,
OverlapCallback &  cb,
PxGeometryQueryFlags  queryFlags 
) const
virtual

Frustum culling test against a BVH.

This is similar in spirit to an overlap query using a convex object around the frustum. However this specialized query has better performance, and can support more than the 6 planes of a frustum, which can be useful in portal-based engines.

On the other hand this test only returns a conservative number of bounds, i.e. some of the returned bounds may actually be outside the frustum volume, close to it but not touching it. This is usually an ok performance trade-off when the function is used for view-frustum culling.

Parameters
[in]nbPlanesNumber of planes. Only 32 planes max are supported.
[in]planesArray of planes, should be in the same space as the BVH.
[in]cbOverlap callback, called once per visible object
[in]queryFlagsOptional flags controlling the query.
Returns
false if query has been aborted

Implements physx::PxBVH.

◆ getBounds()

virtual const PxBounds3 * physx::Gu::BVH::getBounds ( ) const
inlinevirtual

Retrieve the read-only bounds in the BVH.

Note
These are the user-defined bounds passed to the BVH builder, not the internal bounds around each BVH node.
See also
PxBounds3 getNbBounds() getBoundsForModification()

Implements physx::PxBVH.

◆ getNbBounds()

virtual PxU32 physx::Gu::BVH::getNbBounds ( ) const
inlinevirtual

Returns the number of bounds in the BVH.

You can use getBounds() to retrieve the bounds.

Note
These are the user-defined bounds passed to the BVH builder, not the internal bounds around each BVH node.
Returns
Number of bounds in the BVH.
See also
getBounds() getBoundsForModification()

Implements physx::PxBVH.

◆ onRefCountZero()

void BVH::onRefCountZero ( )
virtual

Calls 'delete this;'. It needs to be overloaded for classes also deriving from PxBase and call 'Cm::deletePxBase(this);' instead.

Reimplemented from physx::Cm::RefCountable.

◆ overlap() [1/2]

PxU32 BVH::overlap ( const PxBounds3 &  aabb,
PxU32  maxHits,
PxU32 *PX_RESTRICT  overlapHits 
) const
virtual

AABB overlap test against a BVH.

Parameters
[in]aabbThe axis aligned bounding box
[in]maxHitsMax number of returned hits = size of 'overlapHits' buffer
[out]overlapHitsOverlap hits information, bounds indices
Returns
Number of hits
Deprecated:

Implements physx::PxBVH.

◆ overlap() [2/2]

bool BVH::overlap ( const PxGeometry &  geom,
const PxTransform &  pose,
OverlapCallback &  cb,
PxGeometryQueryFlags  queryFlags 
) const
virtual

Overlap test against a BVH.

Parameters
[in]geomThe query volume
[in]poseThe pose of the query volume
[in]cbOverlap callback, called once per hit
[in]queryFlagsOptional flags controlling the query.
Returns
false if query has been aborted

Implements physx::PxBVH.

◆ partialRefit()

void BVH::partialRefit ( )
virtual

Refits subset of marked nodes.

This is an alternative to the refit() function, to be called after updateBounds() calls. See updateBounds() for details.

See also
getNbBounds() getBoundsForModification() refit() updateBounds()

Implements physx::PxBVH.

◆ raycast() [1/2]

bool BVH::raycast ( const PxVec3 &  origin,
const PxVec3 &  unitDir,
float  maxDist,
RaycastCallback &  cb,
PxGeometryQueryFlags  queryFlags 
) const
virtual

Raycast test against a BVH.

Parameters
[in]originThe origin of the ray.
[in]unitDirNormalized direction of the ray.
[in]maxDistMaximum ray length, has to be in the [0, inf) range
[in]cbRaycast callback, called once per hit
[in]queryFlagsOptional flags controlling the query.
Returns
false if query has been aborted

Implements physx::PxBVH.

◆ raycast() [2/2]

PxU32 BVH::raycast ( const PxVec3 &  origin,
const PxVec3 &  unitDir,
PxReal  maxDist,
PxU32  maxHits,
PxU32 *PX_RESTRICT  rayHits 
) const
virtual

Raycast test against a BVH.

Parameters
[in]originThe origin of the ray.
[in]unitDirNormalized direction of the ray.
[in]maxDistMaximum ray length, has to be in the [0, inf) range
[in]maxHitsMax number of returned hits = size of 'rayHits' buffer
[out]rayHitsRaycast hits information, bounds indices
Returns
Number of hits
Deprecated:

Implements physx::PxBVH.

◆ refit()

void BVH::refit ( )
virtual

Refit the BVH.

This function "refits" the tree, i.e. takes the new (leaf) bounding boxes into account and recomputes all the BVH bounds accordingly. This is an O(n) operation with n = number of bounds in the BVH.

This works best with minor bounds modifications, i.e. when the bounds remain close to their initial values. With large modifications the tree quality degrades more and more, and subsequent query performance suffers. It might be a better strategy to create a brand new BVH if bounds change drastically.

This function refits the whole tree after an arbitrary number of bounds have potentially been modified by users (via getBoundsForModification()). If you only have a small number of bounds to update, it might be more efficient to use setBounds() and partialRefit() instead.

See also
getNbBounds() getBoundsForModification() updateBounds() partialRefit()

Implements physx::PxBVH.

◆ release()

void BVH::release ( )
virtual

Releases the PxBase instance, please check documentation of release in derived class.

Implements physx::PxBase.

◆ sweep() [1/2]

PxU32 BVH::sweep ( const PxBounds3 &  aabb,
const PxVec3 &  unitDir,
PxReal  maxDist,
PxU32  maxHits,
PxU32 *PX_RESTRICT  sweepHits 
) const
virtual

Sweep test against a BVH.

Parameters
[in]aabbThe axis aligned bounding box to sweep
[in]unitDirNormalized direction of the sweep.
[in]maxDistMaximum sweep length, has to be in the [0, inf) range
[in]maxHitsMax number of returned hits = size of 'sweepHits' buffer
[out]sweepHitsSweep hits information, bounds indices
Returns
Number of hits
Deprecated:

Implements physx::PxBVH.

◆ sweep() [2/2]

bool BVH::sweep ( const PxGeometry &  geom,
const PxTransform &  pose,
const PxVec3 &  unitDir,
float  maxDist,
RaycastCallback &  cb,
PxGeometryQueryFlags  queryFlags 
) const
virtual

Sweep test against a BVH.

Parameters
[in]geomThe query volume
[in]poseThe pose of the query volume
[in]unitDirNormalized direction of the sweep.
[in]maxDistMaximum sweep length, has to be in the [0, inf) range
[in]cbRaycast callback, called once per hit
[in]queryFlagsOptional flags controlling the query.
Returns
false if query has been aborted

Implements physx::PxBVH.

◆ traverse()

bool BVH::traverse ( TraversalCallback &  cb) const
virtual

Generic BVH traversal function.

This can be used to implement custom BVH traversal functions if provided ones are not enough. In particular this can be used to visualize the tree's bounds.

Parameters
[in]cbTraversal callback, called for each visited node
Returns
false if query has been aborted

Implements physx::PxBVH.

◆ updateBounds()

bool BVH::updateBounds ( PxU32  boundsIndex,
const PxBounds3 &  newBounds 
)
virtual

Update single bounds.

This is an alternative to getBoundsForModification() / refit(). If you only have a small set of bounds to update, it can be inefficient to call the refit() function, because it refits the whole BVH.

Instead, one can update individual bounds with this updateBounds() function. It sets the new bounds and marks the corresponding BVH nodes for partial refit. Once all the individual bounds have been updated, call partialRefit() to only refit the subset of marked nodes.

Parameters
[in]boundsIndexIndex of updated bounds. Valid range is between 0 and getNbBounds().
[in]newBoundsUpdated bounds.
Returns
true if success
See also
getNbBounds() getBoundsForModification() refit() partialRefit()

Implements physx::PxBVH.


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