PxHitCallback< HitType > Struct Template Referenceabstract

This callback class facilitates reporting scene query hits (intersections) to the user. More...

#include <PxQueryReport.h>

Inheritance diagram for PxHitCallback< HitType >:
Collaboration diagram for PxHitCallback< HitType >:

Public Member Functions

 PxHitCallback (HitType *aTouches, PxU32 aMaxNbTouches)
 Initializes the class with user provided buffer. More...
 
virtual PxAgain processTouches (const HitType *buffer, PxU32 nbHits)=0
 virtual callback function used to communicate query results to the user. More...
 
virtual void finalizeQuery ()
 Query finalization callback, called after the last processTouches callback. More...
 
virtual ~PxHitCallback ()
 
PX_FORCE_INLINE bool hasAnyHits ()
 Returns true if any blocking or touching hits were encountered during a query. More...
 

Public Attributes

HitType block
 Holds the closest blocking hit result for the query. Invalid if hasBlock is false. More...
 
bool hasBlock
 Set to true if there was a blocking hit during query. More...
 
HitType * touches
 User specified buffer for touching hits. More...
 
PxU32 maxNbTouches
 Size of the user specified touching hits buffer. More...
 
PxU32 nbTouches
 Number of touching hits returned by the query. Used with PxHitBuffer. More...
 

Detailed Description

template<typename HitType>
struct PxHitCallback< HitType >

This callback class facilitates reporting scene query hits (intersections) to the user.

User overrides the virtual processTouches function to receive hits in (possibly multiple) fixed size blocks.

Note
PxHitBuffer derives from this class and is used to receive touching hits in a fixed size buffer.
Since the compiler doesn't look in template dependent base classes when looking for non-dependent names
with some compilers it will be necessary to use "this->hasBlock" notation to access a parent variable
in a child callback class.
Pre-made typedef shorthands, such as PxRaycastCallback can be used for raycast, overlap and sweep queries.
See also
PxHitBuffer PxRaycastHit PxSweepHit PxOverlapHit PxRaycastCallback PxOverlapCallback PxSweepCallback

Constructor & Destructor Documentation

◆ PxHitCallback()

template<typename HitType>
PxHitCallback< HitType >::PxHitCallback ( HitType *  aTouches,
PxU32  aMaxNbTouches 
)
inline

Initializes the class with user provided buffer.

Parameters
[in]aTouchesOptional buffer for recording PxQueryHitType::eTOUCH type hits.
[in]aMaxNbTouchesSize of touch buffer.
Note
if aTouches is NULL and aMaxNbTouches is 0, only the closest blocking hit will be recorded by the query.
If PxQueryFlag::eANY_HIT flag is used as a query parameter, hasBlock will be set to true and blockingHit will be used to receive the result.
Both eTOUCH and eBLOCK hits will be registered as hasBlock=true and stored in PxHitCallback.block when eANY_HIT flag is used.
See also
PxHitCallback.hasBlock PxHitCallback.block

◆ ~PxHitCallback()

template<typename HitType>
virtual PxHitCallback< HitType >::~PxHitCallback ( )
inlinevirtual

Member Function Documentation

◆ finalizeQuery()

template<typename HitType>
virtual void PxHitCallback< HitType >::finalizeQuery ( )
inlinevirtual

Query finalization callback, called after the last processTouches callback.

◆ hasAnyHits()

template<typename HitType>
PX_FORCE_INLINE bool PxHitCallback< HitType >::hasAnyHits ( )
inline

Returns true if any blocking or touching hits were encountered during a query.

◆ processTouches()

template<typename HitType>
virtual PxAgain PxHitCallback< HitType >::processTouches ( const HitType *  buffer,
PxU32  nbHits 
)
pure virtual

virtual callback function used to communicate query results to the user.

This callback will always be invoked with touches as a buffer if touches was specified as non-NULL. All reported touch hits are guaranteed to be closer than the closest blocking hit.

Parameters
[in]bufferCallback will report touch hits to the user in this buffer. This pointer will be the same as touches.
[in]nbHitsNumber of touch hits reported in buffer. This number will not exceed maxNbTouches.
Note
There is a significant performance penalty in case multiple touch callbacks are issued (up to 2x)
to avoid the penalty use a bigger buffer so that all touching hits can be reported in a single buffer.
If true (again) is returned from the callback, nbTouches will be reset to 0,
If false is returned, nbTouched will remain unchanged.
By the time processTouches is first called, the globally closest blocking hit is already determined,
values of hasBlock and block are final and all touch hits are guaranteed to be closer than the blocking hit.
touches and maxNbTouches can be modified inside of processTouches callback.
Returns
true to continue receiving callbacks in case there are more hits or false to stop.
See also
PxAgain PxRaycastHit PxSweepHit PxOverlapHit

Implemented in PxHitBuffer< HitType >, PxHitBuffer< PxOverlapHit >, PxHitBuffer< PxRaycastHit >, and PxHitBuffer< PxSweepHit >.

Member Data Documentation

◆ block

template<typename HitType>
HitType PxHitCallback< HitType >::block

Holds the closest blocking hit result for the query. Invalid if hasBlock is false.

◆ hasBlock

template<typename HitType>
bool PxHitCallback< HitType >::hasBlock

Set to true if there was a blocking hit during query.

◆ maxNbTouches

template<typename HitType>
PxU32 PxHitCallback< HitType >::maxNbTouches

Size of the user specified touching hits buffer.

Note
If set to 0 all hits will default to PxQueryHitType::eBLOCK, otherwise to PxQueryHitType::eTOUCH
Hit type returned from pre-filter overrides this default

◆ nbTouches

template<typename HitType>
PxU32 PxHitCallback< HitType >::nbTouches

Number of touching hits returned by the query. Used with PxHitBuffer.

Note
If true (PxAgain) is returned from the callback, nbTouches will be reset to 0.

◆ touches

template<typename HitType>
HitType* PxHitCallback< HitType >::touches

User specified buffer for touching hits.


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