EBGeometry
Compact, header-only C++ library for fast evaluation of signed distance functions
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Public Attributes | List of all members
EBGeometry::BVH::RayQuery< T > Struct Template Reference

A ray tracked through a BVH: the key of a box is the distance along the ray at which it enters the box, or +infinity if it misses it. More...

#include <EBGeometry_BVHQuery.hpp>

Public Types

using Scalar = T
 Floating-point precision.
 
using Key = T
 Key type: a distance along the ray.
 

Public Member Functions

 RayQuery (const Vec3T< T > &a_origin, const Vec3T< T > &a_direction, T a_tMin=T(0)) noexcept
 The ray origin + t * direction, t >= tMin.
 
template<size_t K>
Array< T, K > keys (const ChildBoxes< T, K > &a_row) const noexcept
 Where the ray enters the K child boxes of a node (+infinity where it misses one).
 
template<size_t K>
T key (const ChildBoxes< T, K > &a_row, size_t a_k) const noexcept
 Where the ray enters one child box, bit for bit what keys() gives it.
 
T key (const BoundingVolumes::AABBT< T > &a_box) const noexcept
 Where the ray enters a box (the root's).
 

Public Attributes

Vec3T< T > m_origin
 Ray origin.
 
Vec3T< T > m_inverseDirection
 1 / direction, per component (+-infinity for a zero component).
 
T m_tMin
 Start of the ray: crossings before it are ignored.
 

Detailed Description

template<class T>
struct EBGeometry::BVH::RayQuery< T >

A ray tracked through a BVH: the key of a box is the distance along the ray at which it enters the box, or +infinity if it misses it.

The ray is origin + t * direction for t >= tMin, with a unit direction so that t is a distance. The caller's bound is the far end: the nearest crossing found so far for a closest-hit query, a segment's length for a segment, or -infinity to end the walk (any-hit after the first crossing). The slab test is robust to a zero direction component (its inverse is +-infinity) and drops the NaN of 0 * infinity; boxes are padded by a few ulps so a ray through a face or edge shared by two boxes enters one of them. This type holds no RayT or HitT: those belong to the ray queries built on it.

Template Parameters
TFloating-point precision.

Constructor & Destructor Documentation

◆ RayQuery()

template<class T >
EBGeometry::BVH::RayQuery< T >::RayQuery ( const Vec3T< T > &  a_origin,
const Vec3T< T > &  a_direction,
T  a_tMin = T(0) 
)
inlinenoexcept

The ray origin + t * direction, t >= tMin.

Parameters
[in]a_originOrigin.
[in]a_directionUnit direction.
[in]a_tMinStart of the ray.

Member Function Documentation

◆ key() [1/2]

template<class T >
T EBGeometry::BVH::RayQuery< T >::key ( const BoundingVolumes::AABBT< T > &  a_box) const
inlinenoexcept

Where the ray enters a box (the root's).

Parameters
[in]a_boxBox.
Returns
The entry distance, or +infinity.

◆ key() [2/2]

template<class T >
template<size_t K>
T EBGeometry::BVH::RayQuery< T >::key ( const ChildBoxes< T, K > &  a_row,
size_t  a_k 
) const
inlinenoexcept

Where the ray enters one child box, bit for bit what keys() gives it.

Template Parameters
KBranching factor.
Parameters
[in]a_rowThe node's child boxes.
[in]a_kChild slot, below K.
Returns
The entry distance, or +infinity.

◆ keys()

template<class T >
template<size_t K>
Array< T, K > EBGeometry::BVH::RayQuery< T >::keys ( const ChildBoxes< T, K > &  a_row) const
inlinenoexcept

Where the ray enters the K child boxes of a node (+infinity where it misses one).

One slab test per axis across the K children: SIMD on the host, a scalar loop on a device.

Template Parameters
KBranching factor.
Parameters
[in]a_rowThe node's child boxes.
Returns
One entry distance per child.

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