Avara3D 0.2.0
C++ API reference
a3d::HitTestResult Class Reference

Describes an intersection with scene geometry or a physics body. More...

#include <a3d/scene/HitTestResult.h>

Public Member Functions

std::shared_ptr< Nodenode () const
 Returns the hit node, or nullptr if it has since been destroyed. More...
 
const MeshElementmeshElement () const
 Returns the hit visual mesh element, or nullptr when no visual mesh element is identified. More...
 
std::optional< uint32_t > faceIndex () const
 Returns the zero-based triangle index within meshElement(). More...
 
const math::vec3localCoordinates () const
 Returns the hit position in the node's local coordinate system. More...
 
const math::vec3worldCoordinates () const
 Returns the hit position in world coordinates. More...
 
const math::vec3localNormal () const
 Returns the hit surface normal in the node's local coordinate system. More...
 
const math::vec3worldNormal () const
 Returns the hit surface normal in world coordinates. More...
 
const math::mat4modelTransform () const
 Returns the local-to-world model transform used for this hit. More...
 

Detailed Description

Describes an intersection with scene geometry or a physics body.

Coordinates, normals, and the model transform are snapshots from the time of the hit test. Visual geometry hits may identify a MeshElement and triangle face; physics hits do not necessarily have corresponding visual geometry.

The result retains any visual Mesh needed to keep meshElement() alive, but retains the hit Node weakly.

Definition at line 43 of file HitTestResult.h.

Member Function Documentation

◆ faceIndex()

std::optional< uint32_t > a3d::HitTestResult::faceIndex ( ) const

Returns the zero-based triangle index within meshElement().

Returns
Empty when the hit does not identify a specific triangle, such as a bounding-box-only visual hit or a physics hit.

◆ localCoordinates()

const math::vec3 & a3d::HitTestResult::localCoordinates ( ) const

Returns the hit position in the node's local coordinate system.

◆ localNormal()

const math::vec3 & a3d::HitTestResult::localNormal ( ) const

Returns the hit surface normal in the node's local coordinate system.

◆ meshElement()

const MeshElement * a3d::HitTestResult::meshElement ( ) const

Returns the hit visual mesh element, or nullptr when no visual mesh element is identified.

◆ modelTransform()

const math::mat4 & a3d::HitTestResult::modelTransform ( ) const

Returns the local-to-world model transform used for this hit.

◆ node()

std::shared_ptr< Node > a3d::HitTestResult::node ( ) const

Returns the hit node, or nullptr if it has since been destroyed.

◆ worldCoordinates()

const math::vec3 & a3d::HitTestResult::worldCoordinates ( ) const

Returns the hit position in world coordinates.

◆ worldNormal()

const math::vec3 & a3d::HitTestResult::worldNormal ( ) const

Returns the hit surface normal in world coordinates.


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