RavEngine
Loading...
Searching...
No Matches
physx::PxBVH Class Referenceabstract

Class representing a bounding volume hierarchy. More...

#include <PxBVH.h>

Inheritance diagram for physx::PxBVH:
[legend]
Collaboration diagram for physx::PxBVH:
[legend]

Classes

struct  OverlapCallback
 
struct  RaycastCallback
 
struct  TraversalCallback
 

Public Member Functions

virtual PX_DEPRECATED PxU32 raycast (const PxVec3 &origin, const PxVec3 &unitDir, PxReal maxDist, PxU32 maxHits, PxU32 *PX_RESTRICT rayHits) const =0
 Raycast test against a BVH.
 
virtual PX_DEPRECATED PxU32 sweep (const PxBounds3 &aabb, const PxVec3 &unitDir, PxReal maxDist, PxU32 maxHits, PxU32 *PX_RESTRICT sweepHits) const =0
 Sweep test against a BVH.
 
virtual PX_DEPRECATED PxU32 overlap (const PxBounds3 &aabb, PxU32 maxHits, PxU32 *PX_RESTRICT overlapHits) const =0
 AABB overlap test against a BVH.
 
virtual bool raycast (const PxVec3 &origin, const PxVec3 &unitDir, float maxDist, RaycastCallback &cb, PxGeometryQueryFlags queryFlags=PxGeometryQueryFlag::eDEFAULT) const =0
 Raycast test against a BVH.
 
virtual bool sweep (const PxGeometry &geom, const PxTransform &pose, const PxVec3 &unitDir, float maxDist, RaycastCallback &cb, PxGeometryQueryFlags queryFlags=PxGeometryQueryFlag::eDEFAULT) const =0
 Sweep test against a BVH.
 
virtual bool overlap (const PxGeometry &geom, const PxTransform &pose, OverlapCallback &cb, PxGeometryQueryFlags queryFlags=PxGeometryQueryFlag::eDEFAULT) const =0
 Overlap test against a BVH.
 
virtual bool cull (PxU32 nbPlanes, const PxPlane *planes, OverlapCallback &cb, PxGeometryQueryFlags queryFlags=PxGeometryQueryFlag::eDEFAULT) const =0
 Frustum culling test against a BVH.
 
virtual PxU32 getNbBounds () const =0
 Returns the number of bounds in the BVH.
 
virtual const PxBounds3 * getBounds () const =0
 Retrieve the read-only bounds in the BVH.
 
PX_FORCE_INLINE PxBounds3 * getBoundsForModification ()
 Retrieve the bounds in the BVH.
 
virtual void refit ()=0
 Refit the BVH.
 
virtual bool updateBounds (PxU32 boundsIndex, const PxBounds3 &newBounds)=0
 Update single bounds.
 
virtual void partialRefit ()=0
 Refits subset of marked nodes.
 
virtual bool traverse (TraversalCallback &cb) const =0
 Generic BVH traversal function.
 
virtual const char * getConcreteTypeName () const
 Returns string name of dynamic type.
 
- Public Member Functions inherited from physx::PxBase
virtual void release ()=0
 Releases the PxBase instance, please check documentation of release in derived class.
 
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.
 

Protected Member Functions

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
 

Additional Inherited Members

- Protected Attributes inherited from physx::PxBase
PxType mConcreteType
 
PxBaseFlags mBaseFlags
 
PxU32 mBuiltInRefCount
 

Detailed Description

Class representing a bounding volume hierarchy.

PxBVH can be provided to PxScene::addActor. In this case the scene query pruning structure inside PhysX SDK will store/update one bound per actor. The scene queries against such an actor will query actor bounds and then make a local space query against the provided BVH, which is in actor's local space.

PxBVH can also be used as a standalone data-structure for arbitrary purposes, unrelated to PxScene / PxActor.

See also
PxScene::addActor

Member Function Documentation

◆ cull()

virtual bool physx::PxBVH::cull ( PxU32  nbPlanes,
const PxPlane *  planes,
OverlapCallback &  cb,
PxGeometryQueryFlags  queryFlags = PxGeometryQueryFlag::eDEFAULT 
) const
pure 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

Implemented in physx::Gu::BVH.

◆ getBounds()

virtual const PxBounds3 * physx::PxBVH::getBounds ( ) const
pure virtual

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()

Implemented in physx::Gu::BVH.

◆ getBoundsForModification()

PX_FORCE_INLINE PxBounds3 * physx::PxBVH::getBoundsForModification ( )
inline

Retrieve the bounds in the BVH.

These bounds can be modified. Call refit() after modifications are done.

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

◆ getConcreteTypeName()

virtual const char * physx::PxBVH::getConcreteTypeName ( ) const
inlinevirtual

Returns string name of dynamic type.

Returns
Class name of most derived type of this object.

Implements physx::PxBase.

◆ getNbBounds()

virtual PxU32 physx::PxBVH::getNbBounds ( ) const
pure virtual

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()

Implemented in physx::Gu::BVH.

◆ isKindOf()

virtual bool physx::PxBVH::isKindOf ( const char *  superClass) const
inlineprotectedvirtual

Returns whether a given type name matches with the type of this instance.

Reimplemented from physx::PxBase.

◆ overlap() [1/2]

virtual PX_DEPRECATED PxU32 physx::PxBVH::overlap ( const PxBounds3 &  aabb,
PxU32  maxHits,
PxU32 *PX_RESTRICT  overlapHits 
) const
pure 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:

Implemented in physx::Gu::BVH.

◆ overlap() [2/2]

virtual bool physx::PxBVH::overlap ( const PxGeometry &  geom,
const PxTransform &  pose,
OverlapCallback &  cb,
PxGeometryQueryFlags  queryFlags = PxGeometryQueryFlag::eDEFAULT 
) const
pure 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

Implemented in physx::Gu::BVH.

◆ partialRefit()

virtual void physx::PxBVH::partialRefit ( )
pure 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()

Implemented in physx::Gu::BVH.

◆ raycast() [1/2]

virtual bool physx::PxBVH::raycast ( const PxVec3 &  origin,
const PxVec3 &  unitDir,
float  maxDist,
RaycastCallback &  cb,
PxGeometryQueryFlags  queryFlags = PxGeometryQueryFlag::eDEFAULT 
) const
pure 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

Implemented in physx::Gu::BVH.

◆ raycast() [2/2]

virtual PX_DEPRECATED PxU32 physx::PxBVH::raycast ( const PxVec3 &  origin,
const PxVec3 &  unitDir,
PxReal  maxDist,
PxU32  maxHits,
PxU32 *PX_RESTRICT  rayHits 
) const
pure 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:

Implemented in physx::Gu::BVH.

◆ refit()

virtual void physx::PxBVH::refit ( )
pure 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()

Implemented in physx::Gu::BVH.

◆ sweep() [1/2]

virtual PX_DEPRECATED PxU32 physx::PxBVH::sweep ( const PxBounds3 &  aabb,
const PxVec3 &  unitDir,
PxReal  maxDist,
PxU32  maxHits,
PxU32 *PX_RESTRICT  sweepHits 
) const
pure 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:

Implemented in physx::Gu::BVH.

◆ sweep() [2/2]

virtual bool physx::PxBVH::sweep ( const PxGeometry &  geom,
const PxTransform &  pose,
const PxVec3 &  unitDir,
float  maxDist,
RaycastCallback &  cb,
PxGeometryQueryFlags  queryFlags = PxGeometryQueryFlag::eDEFAULT 
) const
pure 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

Implemented in physx::Gu::BVH.

◆ traverse()

virtual bool physx::PxBVH::traverse ( TraversalCallback &  cb) const
pure 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

Implemented in physx::Gu::BVH.

◆ updateBounds()

virtual bool physx::PxBVH::updateBounds ( PxU32  boundsIndex,
const PxBounds3 &  newBounds 
)
pure 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()

Implemented in physx::Gu::BVH.


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