Classes | Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
lvr2::BVHRaycaster< IntT > Class Template Reference

BVHRaycaster: CPU version of BVH Raycasting: WIP. More...

#include <BVHRaycaster.hpp>

Inheritance diagram for lvr2::BVHRaycaster< IntT >:
Inheritance graph
[legend]

Classes

struct  Ray
 Data type to store information about a ray. More...
 
struct  TriangleIntersectionResult
 A struct to return the calculation results of a triangle intersection. More...
 

Public Member Functions

 BVHRaycaster (const MeshBufferPtr mesh, unsigned int stack_size=64)
 Constructor: Stores mesh as member. More...
 
bool castRay (const Vector3f &origin, const Vector3f &direction, IntT &intersection)
 Cast a single ray onto the mesh. More...
 
- Public Member Functions inherited from lvr2::RaycasterBase< IntT >
virtual void castRays (const std::vector< Vector3f > &origins, const std::vector< std::vector< Vector3f > > &directions, std::vector< std::vector< IntT > > &intersections, std::vector< std::vector< uint8_t > > &hits)
 Cast rays with multiples origins. Each origin has multiples directions. More...
 
virtual void castRays (const std::vector< Vector3f > &origins, const std::vector< Vector3f > &directions, std::vector< IntT > &intersections, std::vector< uint8_t > &hits)
 Cast from multiple ray origin/direction pairs onto the mesh. More...
 
virtual void castRays (const Vector3f &origin, const std::vector< std::vector< Vector3f > > &directions, std::vector< std::vector< IntT > > &intersections, std::vector< std::vector< uint8_t > > &hits)
 Cast a ray from a single origin with multiple directions (in matrix form) onto the mesh. More...
 
virtual void castRays (const Vector3f &origin, const std::vector< Vector3f > &directions, std::vector< IntT > &intersections, std::vector< uint8_t > &hits)
 Cast a ray from single origin with multiple directions onto the mesh. More...
 
 RaycasterBase (const MeshBufferPtr mesh)
 Constructor: Stores mesh as member. More...
 

Protected Member Functions

Vector3f barycentric (const Vector3f &p, const Vector3f &a, const Vector3f &b, const Vector3f &c) const
 

Protected Attributes

BVHTree< BaseVector< float > > m_bvh
 
const unsigned int * m_BVHindicesOrTriLists
 
const float * m_BVHlimits
 
indexArray m_faces
 
const unsigned int m_stack_size
 
const float * m_TriangleIntersectionData
 
const unsigned int * m_TriIdxList
 
floatArr m_vertices
 

Private Member Functions

float distanceSquare (const Vector3f &a, const Vector3f &b) const
 Calculates the squared distance of two vectors. More...
 
TriangleIntersectionResult intersectTrianglesBVH (const unsigned int *clBVHindicesOrTriLists, Vector3f origin, Ray ray, const float *clBVHlimits, const float *clTriangleIntersectionData, const unsigned int *clTriIdxList)
 Calculates the closest intersection of a raycast into a scene of triangles, given a bounding volume hierarchy. More...
 
bool rayIntersectsBox (Vector3f origin, Ray ray, const float *boxPtr)
 Calculates whether a ray intersects a box. More...
 

Detailed Description

template<typename IntT>
class lvr2::BVHRaycaster< IntT >

BVHRaycaster: CPU version of BVH Raycasting: WIP.

Definition at line 56 of file BVHRaycaster.hpp.

Constructor & Destructor Documentation

◆ BVHRaycaster()

template<typename IntT >
lvr2::BVHRaycaster< IntT >::BVHRaycaster ( const MeshBufferPtr  mesh,
unsigned int  stack_size = 64 
)

Constructor: Stores mesh as member.

Member Function Documentation

◆ barycentric()

template<typename IntT >
Vector3f lvr2::BVHRaycaster< IntT >::barycentric ( const Vector3f p,
const Vector3f a,
const Vector3f b,
const Vector3f c 
) const
inlineprotected

Definition at line 101 of file BVHRaycaster.hpp.

◆ castRay()

template<typename IntT >
bool lvr2::BVHRaycaster< IntT >::castRay ( const Vector3f origin,
const Vector3f direction,
IntT &  intersection 
)
virtual

Cast a single ray onto the mesh.

Parameters
[in]originRay origin
[in]directionRay direction
[out]intersectionUser defined intersection output
Returns
true Intersection found
false Not intersection found

Implements lvr2::RaycasterBase< IntT >.

Reimplemented in lvr2::CLRaycaster< IntT >.

◆ distanceSquare()

template<typename IntT >
float lvr2::BVHRaycaster< IntT >::distanceSquare ( const Vector3f a,
const Vector3f b 
) const
inlineprivate

Calculates the squared distance of two vectors.

Parameters
aFirst vector
bSecond vector
Returns
The square distance

Definition at line 143 of file BVHRaycaster.hpp.

◆ intersectTrianglesBVH()

template<typename IntT >
TriangleIntersectionResult lvr2::BVHRaycaster< IntT >::intersectTrianglesBVH ( const unsigned int *  clBVHindicesOrTriLists,
Vector3f  origin,
Ray  ray,
const float *  clBVHlimits,
const float *  clTriangleIntersectionData,
const unsigned int *  clTriIdxList 
)
private

Calculates the closest intersection of a raycast into a scene of triangles, given a bounding volume hierarchy.

Parameters
clBVHindicesOrTriListsCompressed BVH Node data, that stores for each node, whether it is a leaf node and triangle indices lists for leaf nodes and the indices of their child nodes for inner nodes
originOrigin of the ray
rayDirection of the ray
clBVHlimits3d upper and lower limits for each bounding box in the BVH
clTriangleIntersectionDataPrecomputed intersection data for each triangle
clTriIdxListList of triangle indices
Returns
The TriangleIntersectionResult, containing information about the triangle intersection

◆ rayIntersectsBox()

template<typename IntT >
bool lvr2::BVHRaycaster< IntT >::rayIntersectsBox ( Vector3f  origin,
Ray  ray,
const float *  boxPtr 
)
private

Calculates whether a ray intersects a box.

Parameters
originThe origin of the ray
rayThe ray
boxPtrA pointer to the box data
Returns
A boolean indicating whether the ray hits the box

Member Data Documentation

◆ m_bvh

template<typename IntT >
BVHTree<BaseVector<float> > lvr2::BVHRaycaster< IntT >::m_bvh
protected

Definition at line 124 of file BVHRaycaster.hpp.

◆ m_BVHindicesOrTriLists

template<typename IntT >
const unsigned int* lvr2::BVHRaycaster< IntT >::m_BVHindicesOrTriLists
protected

Definition at line 129 of file BVHRaycaster.hpp.

◆ m_BVHlimits

template<typename IntT >
const float* lvr2::BVHRaycaster< IntT >::m_BVHlimits
protected

Definition at line 130 of file BVHRaycaster.hpp.

◆ m_faces

template<typename IntT >
indexArray lvr2::BVHRaycaster< IntT >::m_faces
protected

Definition at line 126 of file BVHRaycaster.hpp.

◆ m_stack_size

template<typename IntT >
const unsigned int lvr2::BVHRaycaster< IntT >::m_stack_size
protected

Definition at line 133 of file BVHRaycaster.hpp.

◆ m_TriangleIntersectionData

template<typename IntT >
const float* lvr2::BVHRaycaster< IntT >::m_TriangleIntersectionData
protected

Definition at line 131 of file BVHRaycaster.hpp.

◆ m_TriIdxList

template<typename IntT >
const unsigned int* lvr2::BVHRaycaster< IntT >::m_TriIdxList
protected

Definition at line 132 of file BVHRaycaster.hpp.

◆ m_vertices

template<typename IntT >
floatArr lvr2::BVHRaycaster< IntT >::m_vertices
protected

Definition at line 127 of file BVHRaycaster.hpp.


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


lvr2
Author(s): Thomas Wiemann , Sebastian Pütz , Alexander Mock , Lars Kiesow , Lukas Kalbertodt , Tristan Igelbrink , Johan M. von Behren , Dominik Feldschnieders , Alexander Löhr
autogenerated on Wed Mar 2 2022 00:37:27