DHART
Loading...
Searching...
No Matches
HF::RayTracer Namespace Reference

Cast rays to determine if and where they intersect geometry. More...

Classes

struct  double3
 
class  EmbreeRayTracer
 A wrapper for Intel's Embree Library. More...
 
struct  HitStruct
 A simple hit struct to carry all relevant information about hits. More...
 
struct  MultiRT
 
class  NanoRTRayTracer
 
struct  RayRequest
 
struct  Triangle
 A triangle. Used internally in Embree. More...
 
struct  Vector3D
 
struct  Vertex
 A vertex. Used internally in Embree. More...
 

Functions

template<typename numeric1 , typename numeric2 , typename dist_type = float>
RTCRayHit ConstructHit (numeric1 x, numeric1 y, numeric1 z, numeric2 dx, numeric2 dy, numeric2 dz, dist_type distance=-1.0f, int mesh_id=-1)
 
template<typename numeric1 , typename numeric2 , typename dist_type = float>
RTCRay ConstructRay (numeric1 x, numeric1 y, numeric1 z, numeric2 dx, numeric2 dy, numeric2 dz, dist_type distance=-1.0f, int mesh_id=-1)
 
RTCError CheckState (RTCDevice &device)
 Check an embree device for errors. More...
 
void vectorsToBuffers (const std::vector< std::array< float, 3 > > &vertices, std::vector< Triangle > &Tribuffer, std::vector< Vertex > &Vbuffer)
 Index a list of verticies and place them into a triangle and vertex buffer. More...
 
void buffersToStructs (std::vector< float > &in_vertices, std::vector< int > &in_indices, std::vector< Vertex > &out_vertices, std::vector< Triangle > &out_triangles)
 Package raw arrays of floats and indices in buffers to the required Embree types. More...
 
Vector3D cross (const Vector3D &x, const Vector3D &y)
 
double dot (const Vector3D &v1, const Vector3D &v2)
 
Vector3D InvertVector (const Vector3D &V)
 
double RayTriangleIntersection (const Vector3D &origin, const Vector3D &direction, const Vector3D &v1, const Vector3D &v2, const Vector3D &v3)
 Determine the distance between a ray's origin and it's point of intersection with a triangle. More...
 
Vector3D GetPointFromBuffer (int index, Vertex *buffer)
 
bool DidIntersect (int mesh_id)
 
void Log (MultiRT::RT_Type type, std::string Message="")
 

Variables

const int FAIL_ID = ((unsigned int)-1)
 

Detailed Description

Cast rays to determine if and where they intersect geometry.

The basics of raytracing entail casting a ray from an origin point in a specific direction and determining whether or not it intersects with a set of geometry. Certain functions can even determine where the intersection occured. Generally, every RayTracer will contain a set of geometry and provide functions for casting rays from an origin point in a specific direciton. Some generate an accelerated structure from geometry called a Bounding Volume Hierarchy, or BVH. A BVH can drastically decrease the time it takes to calculate ray intersections, but can be more complicated to manage compared to standard buffers of geometry.

See also
EmbreeRayTracer For an implementation of a raytracer using Intel's Embree library as a backend.

Class Documentation

◆ HF::RayTracer::Triangle

struct HF::RayTracer::Triangle

A triangle. Used internally in Embree.

Definition at line 82 of file embree_raytracer.cpp.

+ Collaboration diagram for HF::RayTracer::Triangle:
Class Members
int v0
int v1
int v2

◆ HF::RayTracer::Vertex

struct HF::RayTracer::Vertex

A vertex. Used internally in Embree.

Definition at line 77 of file embree_raytracer.cpp.

+ Collaboration diagram for HF::RayTracer::Vertex:
Class Members
float x
float y
float z

Function Documentation

◆ buffersToStructs()

void HF::RayTracer::buffersToStructs ( std::vector< float > &  in_vertices,
std::vector< int > &  in_indices,
std::vector< Vertex > &  out_vertices,
std::vector< Triangle > &  out_triangles 
)
inline

Package raw arrays of floats and indices in buffers to the required Embree types.

Parameters
in_verticesAn array of floats in which every 3 floats represents a vertex.
in_indicesAn array of integers in which every 3 integers represents a triangle.
out_verticesOutput array for vertexes.
out_trianglesOutput array for triangles.
Todo:
May be faster as a std::move or std::copy.

Definition at line 141 of file embree_raytracer.cpp.

Referenced by HF::RayTracer::EmbreeRayTracer::AddMesh().

+ Here is the caller graph for this function:

◆ CheckState()

RTCError HF::RayTracer::CheckState ( RTCDevice &  device)

Check an embree device for errors.

Parameters
deviceDevice to check for errors
Exceptions
std::exceptionSome error is found while casting rays.

Definition at line 69 of file embree_raytracer.cpp.

Referenced by HF::RayTracer::EmbreeRayTracer::InsertGeom().

+ Here is the caller graph for this function:

◆ ConstructHit()

template<typename numeric1 , typename numeric2 , typename dist_type = float>
RTCRayHit HF::RayTracer::ConstructHit ( numeric1  x,
numeric1  y,
numeric1  z,
numeric2  dx,
numeric2  dy,
numeric2  dz,
dist_type  distance = -1.0f,
int  mesh_id = -1 
)
inline

Definition at line 24 of file embree_raytracer.cpp.

Referenced by HF::RayTracer::EmbreeRayTracer::Intersect_IMPL().

+ Here is the caller graph for this function:

◆ ConstructRay()

template<typename numeric1 , typename numeric2 , typename dist_type = float>
RTCRay HF::RayTracer::ConstructRay ( numeric1  x,
numeric1  y,
numeric1  z,
numeric2  dx,
numeric2  dy,
numeric2  dz,
dist_type  distance = -1.0f,
int  mesh_id = -1 
)
inline

Definition at line 48 of file embree_raytracer.cpp.

Referenced by HF::RayTracer::EmbreeRayTracer::Occluded_IMPL().

+ Here is the caller graph for this function:

◆ cross()

Vector3D HF::RayTracer::cross ( const Vector3D x,
const Vector3D y 
)
inline

Definition at line 229 of file embree_raytracer.cpp.

References HF::RayTracer::Vector3D::x, HF::RayTracer::Vector3D::y, and HF::RayTracer::Vector3D::z.

Referenced by RayTriangleIntersection().

+ Here is the caller graph for this function:

◆ DidIntersect()

bool HF::RayTracer::DidIntersect ( int  mesh_id)
inline

Definition at line 23 of file HitStruct.h.

References FAIL_ID.

Referenced by HF::RayTracer::HitStruct< numeric_type >::DidHit(), and HF::RayTracer::EmbreeRayTracer::Intersect().

+ Here is the caller graph for this function:

◆ dot()

double HF::RayTracer::dot ( const Vector3D v1,
const Vector3D v2 
)
inline

Definition at line 237 of file embree_raytracer.cpp.

References HF::RayTracer::Vector3D::x, HF::RayTracer::Vector3D::y, and HF::RayTracer::Vector3D::z.

Referenced by RayTriangleIntersection().

+ Here is the caller graph for this function:

◆ GetPointFromBuffer()

Vector3D HF::RayTracer::GetPointFromBuffer ( int  index,
Vertex buffer 
)
inline

Definition at line 446 of file embree_raytracer.cpp.

References HF::RayTracer::Vertex::x, HF::RayTracer::Vertex::y, and HF::RayTracer::Vertex::z.

Referenced by HF::RayTracer::EmbreeRayTracer::GetTriangle().

+ Here is the caller graph for this function:

◆ InvertVector()

Vector3D HF::RayTracer::InvertVector ( const Vector3D V)
inline

◆ Log()

void HF::RayTracer::Log ( MultiRT::RT_Type  type,
std::string  Message = "" 
)
inline

Definition at line 9 of file MultiRT.cpp.

References HF::RayTracer::MultiRT::EMBREE, and HF::RayTracer::MultiRT::NANO_RT.

◆ RayTriangleIntersection()

double HF::RayTracer::RayTriangleIntersection ( const Vector3D origin,
const Vector3D direction,
const Vector3D v1,
const Vector3D v2,
const Vector3D v3 
)

Determine the distance between a ray's origin and it's point of intersection with a triangle.

Parameters
originOrigin point of the ray.
directionDirection the ray was casted in
v1First vertex of the triangle
v2Second vertex of a triangle
v3Third vertex of a triangle
Returns
The distance between the ray's origin point and the point of intersection with the triangle defined by v1, v2, and v3 OR -1 if there was no intersection between the ray and the triangle.
Remarks
This algorithm is based on an implementation of the Möller–Trumbore intersection algorithm written on the wikipedia page https://en.wikipedia.org/wiki/M%C3%B6ller%E2%80%93Trumbore_intersection_algorithm.

Definition at line 246 of file embree_raytracer.cpp.

References cross(), and dot().

Referenced by HF::RayTracer::EmbreeRayTracer::CalculatePreciseDistance().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vectorsToBuffers()

void HF::RayTracer::vectorsToBuffers ( const std::vector< std::array< float, 3 > > &  vertices,
std::vector< Triangle > &  Tribuffer,
std::vector< Vertex > &  Vbuffer 
)
inline

Index a list of verticies and place them into a triangle and vertex buffer.

Parameters
verticesMesh vertices.
TribufferOutput triangle buffer.
VbufferOutput Vertex Buffer.

Internally, this uses a hashmap to create an index map of vertices.

Todo:
Performance here can be improved by using indexing.

Definition at line 92 of file embree_raytracer.cpp.

Referenced by HF::RayTracer::EmbreeRayTracer::EmbreeRayTracer(), and HF::RayTracer::EmbreeRayTracer::AddMesh().

+ Here is the caller graph for this function:

Variable Documentation

◆ FAIL_ID

const int HF::RayTracer::FAIL_ID = ((unsigned int)-1)

Definition at line 22 of file HitStruct.h.

Referenced by DidIntersect().