DHART
Loading...
Searching...
No Matches
HF::RayTracer::EmbreeRayTracer Class Reference

A wrapper for Intel's Embree Library. More...

#include <embree_raytracer.h>

+ Collaboration diagram for HF::RayTracer::EmbreeRayTracer:

Public Member Functions

 EmbreeRayTracer (bool use_precise=false)
 Construct an empty EmbreeRayTracer;. More...
 
 EmbreeRayTracer (std::vector< HF::Geometry::MeshInfo< float > > &MI, bool use_precise_intersection=false)
 Create a new EmbreeRayTracer and add a single mesh to the scene. More...
 
 EmbreeRayTracer (HF::Geometry::MeshInfo< float > &MI, bool use_precise=false)
 Construct the raytracer using only a single mesh. More...
 
 EmbreeRayTracer (const EmbreeRayTracer &ERT2)
 Construct a raytracer using another raytracer. More...
 
 EmbreeRayTracer (const std::vector< std::array< float, 3 > > &geometry)
 Create a new Raytracer and generate its BVH from a flat array of vertices. More...
 
bool AddMesh (std::vector< std::array< float, 3 > > &Mesh, int ID, bool Commit=false)
 Add a new mesh to this raytracer's BVH with the specified ID. More...
 
bool AddMesh (HF::Geometry::MeshInfo< float > &Mesh, bool Commit)
 Add a new mesh to the BVH with the specified ID. If False, then the addition failed, or the ID was already taken. More...
 
bool AddMesh (std::vector< HF::Geometry::MeshInfo< float > > &Meshes, bool Commit=true)
 Add several new meshes to the BVH. More...
 
bool PointIntersection (std::array< float, 3 > &origin, const std::array< float, 3 > &dir, float distance=-1, int mesh_id=-1)
 Cast a ray and overwrite the origin with the hitpoint if it intersects any geometry. More...
 
bool PointIntersection (float &x, float &y, float &z, float dx, float dy, float dz, float distance=-1, int mesh_id=-1)
 Cast a single ray and get the hitpoint. x , y ,and z are overridden with the hitpoint on a successful hit. More...
 
std::vector< char > PointIntersections (std::vector< std::array< float, 3 > > &origins, std::vector< std::array< float, 3 > > &directions, bool use_parallel=true, float max_distance=-1, int mesh_id=-1)
 Cast multiple rays and recieve hitpoints in return. More...
 
std::vector< char > Occlusions (const std::vector< std::array< float, 3 > > &origins, const std::vector< std::array< float, 3 > > &directions, float max_distance=-1, bool use_parallel=true)
 Cast multiple occlusion rays in parallel. More...
 
template<typename return_type = double, class N , class V >
HitStruct< return_type > Intersect (const N &node, const V &direction, float max_distance=-1.0f, int mesh_id=-0.1f)
 Cast a ray from origin in direction. More...
 
template<typename return_type = double, typename numeric1 = double, typename numeric2 = double>
HitStruct< return_type > Intersect (numeric1 x, numeric1 y, numeric1 z, numeric2 dx, numeric2 dy, numeric2 dz, float distance=-1.0f, int mesh_id=-1)
 Cast a ray from origin in direction. More...
 
template<typename N , typename V , typename return_type >
bool IntersectOutputArguments (const N &node, const V &direction, return_type &out_distance, int &out_meshid, float max_distance=-1.0f)
 Cast a ray from origin in direction and update the parameters instead of returning a hitstruct. More...
 
template<typename return_type , typename N , typename V >
std::vector< HitStruct< return_type > > Intersections (const N &nodes, const V &directions, float max_distance=-1.0f, const bool use_parallel=false)
 Cast multiple rays in parallel. More...
 
template<typename N , typename V >
bool Occluded (const N &origin, const V &direction, float max_distance=-1.0f, int mesh_id=-1)
 Determine if there is an intersection with any geometry. More...
 
template<typename numeric1 , typename numeric2 , typename dist_type = float>
bool Occluded (numeric1 x, numeric1 y, numeric1 z, numeric2 dx, numeric2 dy, numeric2 dz, dist_type max_distance=-1.0, int mesh_id=-1)
 Determine if there is an intersection with any geometry. More...
 
void operator= (const EmbreeRayTracer &ERT2)
 Increment reference counters to prevent destruction when a copy is made. More...
 
 ~EmbreeRayTracer ()
 Custom destructor to ensure cleanup of embree resources. More...
 

Private Member Functions

void SetupScene ()
 Performs all the necessary operations to set up the scene. More...
 
std::array< Vector3D, 3 > GetTriangle (unsigned int geomID, unsigned int primID) const
 Get the vertices for a specific triangle in a mesh. More...
 
int InsertGeom (RTCGeometry &geom, int id=-1)
 Attach geometry to the current scene. More...
 
double CalculatePreciseDistance (unsigned int geom_id, unsigned int prim_id, const Vector3D &origin, const Vector3D &direction) const
 Calculate the distance from origin to the point of intersection using an algorithm with higher precision. More...
 
RTCRayHit Intersect_IMPL (float x, float y, float z, float dx, float dy, float dz, float max_distance=-1, int mesh_id=-1)
 Implementation for fundamental ray intersection. More...
 
bool Occluded_IMPL (float x, float y, float z, float dx, float dy, float dz, float distance=-1, int mesh_id=-1)
 Implementation for fundamental occlusion ray intersection. More...
 
bool Occluded_IMPL (const std::array< float, 3 > &origin, const std::array< float, 3 > &direction, float max_dist=-1)
 Cast an occlusion ray using arrays as input. More...
 
RTCGeometry ConstructGeometryFromBuffers (std::vector< Triangle > &tris, std::vector< Vertex > &verts)
 Create a new instance of RTCGeometry from a triangle and vertex buffer. More...
 

Private Attributes

RTCDevice device
 All objects in Embree are created from this. https://www.embree.org/api.html#device-object. More...
 
RTCScene scene
 Container for a set of geometries, and the BVH. https://www.embree.org/api.html#scene-object. More...
 
RTCIntersectContext context
 Context to cast rays within. More...
 
Triangletriangles
 Triangle buffer. Is used in multiple places, but contents are dumped. More...
 
VertexVertices
 Vertex buffer. Is used in multiple places but contents are dumped. More...
 
bool use_precise = false
 If true, use custom triangle intersection intersection instead of embree's. More...
 
std::vector< RTCGeometry > geometry
 

Detailed Description

A wrapper for Intel's Embree Library.

Provides several functions to quickly and simply perform ray intersections using Embree. This class will automatically dispose of Embree buffers when destroyed, incrementing Embree's reference counters on copy, and decrementing them on deletion. This class also provides methods for adding geometry to Embree's geometry buffers.

Todo:
Many functions support MeshID but don't actually check for it.

Definition at line 80 of file embree_raytracer.h.

Constructor & Destructor Documentation

◆ EmbreeRayTracer() [1/5]

HF::RayTracer::EmbreeRayTracer::EmbreeRayTracer ( bool  use_precise = false)

Construct an empty EmbreeRayTracer;.

Parameters
use_preciseIf set to true, use a more precise intesection algorithm to determine the distance between rays origin points and their points of intesection
// Requires #include "embree_raytracer.h", #include "objloader.h"
// For brevity
// Create the EmbreeRayTracer, no arguments
A wrapper for Intel's Embree Library.

Definition at line 166 of file embree_raytracer.cpp.

References SetupScene().

+ Here is the call graph for this function:

◆ EmbreeRayTracer() [2/5]

HF::RayTracer::EmbreeRayTracer::EmbreeRayTracer ( std::vector< HF::Geometry::MeshInfo< float > > &  MI,
bool  use_precise_intersection = false 
)

Create a new EmbreeRayTracer and add a single mesh to the scene.

Parameters
MIThe mesh to use for scene construction.
use_preciseIf set to true, use a more precise intesection algorithm to determine the distance between rays origin pointsand their points of intesection
Exceptions
ExceptionThrown if MI contains no vertices.
Todo:
This function calls throw; which is meant to only be used to rethrow previously thrown exceptions. This should be throwing HF::Exceptions::InvalidOBJ
// Requires #include "embree_raytracer.h", #include "objloader.h"
// For brevity
// Prepare the obj file path
std::string teapot_path = "teapot.obj";
std::vector<MeshInfo<float>> geom = HF::Geometry::LoadMeshObjects(teapot_path, HF::Geometry::ONLY_FILE);
// Create the EmbreeRayTracer
auto ert = EmbreeRayTracer(geom);
vector< MeshInfo< float > > LoadMeshObjects(std::string path, GROUP_METHOD gm, bool change_coords, int scale)
Create MeshInfo instances from the OBJ at path.
Definition: objloader.cpp:195
@ ONLY_FILE
Treat all the geometry in the file as a single mesh.
Definition: objloader.h:65
A collection of vertices and indices representing geometry.
Definition: meshinfo.h:124

Definition at line 172 of file embree_raytracer.cpp.

References AddMesh(), and SetupScene().

+ Here is the call graph for this function:

◆ EmbreeRayTracer() [3/5]

HF::RayTracer::EmbreeRayTracer::EmbreeRayTracer ( HF::Geometry::MeshInfo< float > &  MI,
bool  use_precise = false 
)

Construct the raytracer using only a single mesh.

Parameters
MIMeshInfo<float> instance to create the BVH with.
use_preciseIf set to true, use a more precise intesection algorithm to determine the distance between rays origin points and their points of intesection

Definition at line 184 of file embree_raytracer.cpp.

References AddMesh(), SetupScene(), and use_precise.

+ Here is the call graph for this function:

◆ EmbreeRayTracer() [4/5]

HF::RayTracer::EmbreeRayTracer::EmbreeRayTracer ( const EmbreeRayTracer ERT2)

Construct a raytracer using another raytracer.

Increments Embree's internal garbage collector to retain the scene and context.

Definition at line 199 of file embree_raytracer.cpp.

References context, device, geometry, and scene.

◆ EmbreeRayTracer() [5/5]

HF::RayTracer::EmbreeRayTracer::EmbreeRayTracer ( const std::vector< std::array< float, 3 > > &  geometry)

Create a new Raytracer and generate its BVH from a flat array of vertices.

Parameters
geometryA vector of float arrays representing geometry. Every 3 arrays should form a single triangle of the mesh

Use of this function is discouraged since it is slower and less memory efficent than building from an array of triangle indices and an array of vertices. Internally a hashmap is used to assign an ID to every vertex in order to generate the index array.

Exceptions
std::exceptionEmbree's geometry buffers could not be initialized.
// Requires #include "embree_raytracer.h", #include "objloader.h"
// Create a container of coordinates
std::vector<std::array<float, 3>> directions = {
{0, 0, 1},
{0, 1, 0},
{1, 0, 0},
{-1, 0, 0},
{0, -1, 0},
{0, 0, -1},
};
// Create the EmbreeRayTracer
auto ert = HF::RayTracer::EmbreeRayTracer(directions);

Definition at line 301 of file embree_raytracer.cpp.

References ConstructGeometryFromBuffers(), geometry, InsertGeom(), scene, SetupScene(), and HF::RayTracer::vectorsToBuffers().

+ Here is the call graph for this function:

◆ ~EmbreeRayTracer()

HF::RayTracer::EmbreeRayTracer::~EmbreeRayTracer ( )

Custom destructor to ensure cleanup of embree resources.

// Requires #include "embree_raytracer.h", #include "objloader.h"
// For brevity
// Prepare the obj file path
std::string teapot_path = "teapot.obj";
std::vector<MeshInfo<float>> geom = HF::Geometry::LoadMeshObjects(teapot_path, HF::Geometry::ONLY_FILE);
// Begin scope
{
// Create the EmbreeRayTracer
auto ert = EmbreeRayTracer(geom);
// Use ert within this scope
}
// end scope - destructor called at end of scope

Definition at line 644 of file embree_raytracer.cpp.

References device, and scene.

Member Function Documentation

◆ AddMesh() [1/3]

bool HF::RayTracer::EmbreeRayTracer::AddMesh ( HF::Geometry::MeshInfo< float > &  Mesh,
bool  Commit 
)

Add a new mesh to the BVH with the specified ID. If False, then the addition failed, or the ID was already taken.

Parameters
MeshA vector of 3d points composing the mesh
IDthe id of the mesh
CommitWhether or not to commit changes yet. This is slow, so only do this when you're done adding meshes.
Returns
True if successful
Exceptions
std::exceptionRTC failed to allocate vertex and or index buffers.
// Requires #include "embree_raytracer.h", #include "objloader.h"
// Create a container of coordinates
std::vector<std::array<float, 3>> directions = {
{0, 0, 1},
{0, 1, 0},
{1, 0, 0}
};
// Create the EmbreeRayTracer
auto ert = HF::RayTracer::EmbreeRayTracer(directions);
// Prepare coordinates to create a mesh
std::vector<std::array<float, 3>> mesh_coords = {
{-1, 0, 0},
{0, -1, 0},
{0, 0, -1}
};
// Create a mesh
const int id = 325;
const std::string mesh_name = "my mesh";
HF::Geometry::MeshInfo<float> mesh(mesh_coords, id, mesh_name);
// Determine if mesh insertion successful
if (ert.AddMesh(mesh, false)) {
std::cout << "Mesh insertion okay" << std::endl;
}
else {
std::cout << "Mesh insertion error" << std::endl;
}

>>>Mesh insertion okay

Definition at line 375 of file embree_raytracer.cpp.

References HF::RayTracer::buffersToStructs(), ConstructGeometryFromBuffers(), HF::Geometry::MeshInfo< numeric_type >::GetIndexedVertices(), HF::Geometry::MeshInfo< numeric_type >::getRawIndices(), InsertGeom(), HF::Geometry::MeshInfo< numeric_type >::meshid, HF::Geometry::MeshInfo< numeric_type >::NumTris(), HF::Geometry::MeshInfo< numeric_type >::NumVerts(), and scene.

+ Here is the call graph for this function:

◆ AddMesh() [2/3]

bool HF::RayTracer::EmbreeRayTracer::AddMesh ( std::vector< HF::Geometry::MeshInfo< float > > &  Meshes,
bool  Commit = true 
)

Add several new meshes to the BVH.

Parameters
MeshesA vector of meshinfo to each be added as a seperate mesh.
CommitWhether or not to commit changes to the scene after all meshes in Meshes have been added.
Returns
True.
// Requires #include "embree_raytracer.h", #include "objloader.h"
// For brevity
// Prepare the obj file path
std::string teapot_path = "teapot.obj";
std::vector<MeshInfo<float>> geom = HF::Geometry::LoadMeshObjects(teapot_path, HF::Geometry::ONLY_FILE);
// Create the EmbreeRayTracer
auto ert = EmbreeRayTracer(geom);
// Prepare coordinates to create a mesh
std::vector<std::array<float, 3>> mesh_coords_0 = {
{0, 0, 1},
{0, 1, 0},
{1, 0, 0}
};
std::vector<std::array<float, 3>> mesh_coords_1 = {
{-1, 0, 0},
{0, -1, 0},
{0, 0, -1}
};
// Prepare mesh IDs and names
const int mesh_id_0 = 241;
const int mesh_id_1 = 363;
const std::string mesh_name_0 = "this mesh";
const std::string mesh_name_1 = "that mesh";
// Create each MeshInfo<float>
MeshInfo<float> mesh_0(mesh_coords_0, mesh_id_0, mesh_name_0);
MeshInfo<float> mesh_1(mesh_coords_1, mesh_id_1, mesh_name_1);
// Create a container of MeshInfo<float>
std::vector<MeshInfo<float>> mesh_vec = { mesh_0, mesh_1 };
// Determine if mesh insertion successful
if (ert.AddMesh(mesh_vec, false)) {
std::cout << "Mesh insertion okay" << std::endl;
}
else {
std::cout << "Mesh insertion error" << std::endl;
}

Definition at line 398 of file embree_raytracer.cpp.

References AddMesh(), and scene.

+ Here is the call graph for this function:

◆ AddMesh() [3/3]

bool HF::RayTracer::EmbreeRayTracer::AddMesh ( std::vector< std::array< float, 3 > > &  Mesh,
int  ID,
bool  Commit = false 
)

Add a new mesh to this raytracer's BVH with the specified ID.

Parameters
MeshA vector of 3d points composing the mesh
IDthe id of the mesh
CommitWhether or not to commit changes yet. This is slow, so only do this when you're done adding meshes.
Returns
True if the mesh was added successfully, false if the addition failed or the ID was already taken.
Exceptions
std::exceptionEmbree failed to allocate vertex and or index buffers.
// Requires #include "embree_raytracer.h", #include "objloader.h"
// Create a container of coordinates
std::vector<std::array<float, 3>> directions = {
{0, 0, 1},
{0, 1, 0},
{1, 0, 0},
{-1, 0, 0},
{0, -1, 0},
{0, 0, -1},
};
// Create the EmbreeRayTracer
auto ert = HF::RayTracer::EmbreeRayTracer(directions);
// Prepare the mesh ID
const int id = 214;
// Insert the mesh, Commit parameter defaults to false
bool status = ert.AddMesh(directions, id);
// Retrieve status
std::string result = status ? "status okay" : "status not okay";
std::cout << result << std::endl;

>>>status okay

Definition at line 316 of file embree_raytracer.cpp.

References ConstructGeometryFromBuffers(), InsertGeom(), scene, and HF::RayTracer::vectorsToBuffers().

Referenced by EmbreeRayTracer(), AddMesh(), AddMesh(), and AddMeshes().

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

◆ CalculatePreciseDistance()

double HF::RayTracer::EmbreeRayTracer::CalculatePreciseDistance ( unsigned int  geom_id,
unsigned int  prim_id,
const Vector3D origin,
const Vector3D direction 
) const
private

Calculate the distance from origin to the point of intersection using an algorithm with higher precision.

Parameters
geom_idID of the geometry the ray intersected
prim_idID of the primitive in geometry the ray intersected
originThe origin point of the ray
directionthe direction the ray was casted in
Returns
The distance between origin and the triangle it intersected

Uses geom_id to get the buffers of the intersected geometry, then uses prim_id to get the 3 vertices comprising the intersected triangle. Once these are obtained, this function calls RayTriangleIntersection to calculate the precise point of intersection and returns the result. When use_precise is set to true, Intersect will call this function to calculate its distance value instead of returning the distance calculated by embree.

Remarks
This algorithm was implemented due to the relatively low precision of the distances returned from Embree which causes issues with certain analysis methods.
See also
GetTriangle for details on getting the geometry and triangle from embree
RayTriangleIntersection for details on the intersection algorithm itself

Definition at line 282 of file embree_raytracer.cpp.

References GetTriangle(), and HF::RayTracer::RayTriangleIntersection().

Referenced by Intersect().

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

◆ ConstructGeometryFromBuffers()

RTCGeometry HF::RayTracer::EmbreeRayTracer::ConstructGeometryFromBuffers ( std::vector< Triangle > &  tris,
std::vector< Vertex > &  verts 
)
private

Create a new instance of RTCGeometry from a triangle and vertex buffer.

Parameters
trisTriangle buffer to construct new geometry with
vertsVertex buffer to construct geometry with
Returns
Committed Geometry containing the specified triangles and vertices.

Definition at line 336 of file embree_raytracer.cpp.

References device, geometry, triangles, and Vertices.

Referenced by EmbreeRayTracer(), and AddMesh().

+ Here is the caller graph for this function:

◆ GetTriangle()

std::array< Vector3D, 3 > HF::RayTracer::EmbreeRayTracer::GetTriangle ( unsigned int  geomID,
unsigned int  primID 
) const
private

Get the vertices for a specific triangle in a mesh.

Parameters
geomIDID of the geometry the triangle belongs to
primIDId of the triangle to retrieve
Returns
The 3 vertices that comprise the triangle with ID primID in the geometry with id geomID
Precondition
1) geomID must be the ID of geometry that already exists within this raytracer's BVH
2) primID must be the ID of a triangle within the bounds of the geometry at geomID's buffers

Definition at line 450 of file embree_raytracer.cpp.

References HF::RayTracer::GetPointFromBuffer(), scene, HF::RayTracer::Triangle::v0, HF::RayTracer::Triangle::v1, and HF::RayTracer::Triangle::v2.

Referenced by CalculatePreciseDistance().

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

◆ InsertGeom()

int HF::RayTracer::EmbreeRayTracer::InsertGeom ( RTCGeometry &  geom,
int  id = -1 
)
private

Attach geometry to the current scene.

Parameters
geomGeometry to attach
idId to attempt to attach with. If this ID is already taken, the next available ID will be assigned, and the new ID will be returned
Returns
the New ID if a new ID needed to be given to the mesh or the ID given by ID.

Definition at line 212 of file embree_raytracer.cpp.

References HF::RayTracer::CheckState(), device, InsertGeom(), and scene.

Referenced by EmbreeRayTracer(), AddMesh(), and InsertGeom().

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

◆ Intersect() [1/2]

template<typename return_type = double, class N , class V >
HitStruct< return_type > HF::RayTracer::EmbreeRayTracer::Intersect ( const N &  node,
const V &  direction,
float  max_distance = -1.0f,
int  mesh_id = -0.1f 
)
inline

Cast a ray from origin in direction.

Template Parameters
return_typeNumeric type for the returned distance value i.e. double, long double, float, etc.
NX,Y,Z coordinates representing a point in space
VX,Y,Z Coordinates representing direction vector
Parameters
nodeA point in space. Must atleast have [0], [1], and [2] defined.
directionDirection to cast the ray in. Same constraints as node, but can be a different type.
max_distanceMaximum distance a ray can travel before intersections are ignored. Set to -1 for infinite distance.
mesh_idOnly consider intersections with the mesh at this ID. Set to -1 to consider intersections with all meshes.
Returns
The distance from origin to the ray's point of intersection. If no intersection was found the returned hitstruct's meshID will be -1. This is checkable with the hitstruct's DidHit() function.
Remarks
If use_precise is set to true then this will use a more precise algorithm to calculate returned distance value. This is one of the most basic forms of intersection for the raytracer and many other functions will call this internally.
See also
Intersections for a parallel version of this function

Definition at line 1001 of file embree_raytracer.h.

Referenced by PreciseIntersection().

+ Here is the caller graph for this function:

◆ Intersect() [2/2]

template<typename return_type = double, typename numeric1 = double, typename numeric2 = double>
HitStruct< return_type > HF::RayTracer::EmbreeRayTracer::Intersect ( numeric1  x,
numeric1  y,
numeric1  z,
numeric2  dx,
numeric2  dy,
numeric2  dz,
float  distance = -1.0f,
int  mesh_id = -1 
)
inline

Cast a ray from origin in direction.

Template Parameters
return_typeNumeric type used for the output distance value.
numeric1Numeric type used for the x,y,z components of the origin
numeric2Numeric type used for the x,y,z components of the direction
Parameters
xX component of the ray's origin.
yY component of the ray's origin.
zZ component of the ray's origin.
dxX component of the ray's direction.
dyY component of the ray's direction.
dzZ component of the ray's direction.
max_distanceMaximum distance a ray can travel before intersections are ignored. Set to -1 for infinite distance.
mesh_idIgnore intersections with any mesh other than the mesh with this ID. set to -1 to consider intersections with any geometry
Returns
The distance from origin to the ray's point of intersection. If no intersection was found the returned hitstruct's meshID will be -1. This is checkable with the hitstruct's DidHit() function.
Remarks
If use_precise is set to true then this will use a more precise algorithm to calculate returned distance value.This is one of the most basic forms of intersection for the raytracerand many other functions will call this internally.
See also
Intersections for a parallel version of this function
Example
// Create Plane
const vector<float> plane_vertices{
-10.0f, 10.0f, 0.0f,
-10.0f, -10.0f, 0.0f,
10.0f, 10.0f, 0.0f,
10.0f, -10.0f, 0.0f,
};
const vector<int> plane_indices{ 3, 1, 0, 2, 3, 0 };
// Create RayTracer
EmbreeRayTracer ert(vector<MeshInfo<float>>{MeshInfo<float>(plane_vertices, plane_indices, 0, " ")});
// Cast a ray straight down
auto straight_down = ert.Intersect(0, 0, 1, 0, 0, -1);
// Print distance if it connected
if (straight_down.DidHit()) std::cerr << straight_down.distance << std::endl;
else std::cerr << "Miss" << std::endl;
// Cast a ray straight up and ensure it misses
auto straight_up = ert.Intersect(0, 0, 1, 0, 0, 1);
if (straight_up.DidHit()) std::cerr << straight_up.distance << std::endl;
else std::cerr << "Miss" << std::endl;

Definition at line 1041 of file embree_raytracer.h.

References CalculatePreciseDistance(), HF::RayTracer::DidIntersect(), HF::RayTracer::HitStruct< numeric_type >::distance, Intersect_IMPL(), and HF::RayTracer::HitStruct< numeric_type >::meshid.

+ Here is the call graph for this function:

◆ Intersect_IMPL()

RTCRayHit HF::RayTracer::EmbreeRayTracer::Intersect_IMPL ( float  x,
float  y,
float  z,
float  dx,
float  dy,
float  dz,
float  max_distance = -1,
int  mesh_id = -1 
)
private

Implementation for fundamental ray intersection.

Parameters
xx component of the ray's origin.
yy component of the ray's origin.
zz component of the ray's origin.
dxx component of the ray's direction.
dyy component of the ray's direction.
dzz component of the ray's direction.
max_distanceMaximum distance the ray can travel. Any intersections beyond this distance will be ignored. If set to -1, all intersections will be counted regardless of distance.
mesh_id(UNIMPLEMENTED) the id of the only mesh for this ray to collide with. Any geometry wihtout this ID is ignored.
Returns
A HitStruct containing information about the intersection if any occurred.
Example
// Requires #include "embree_raytracer.h", #include "meshinfo.h"
// for brevity
// Create Plane
const std::vector<float> plane_vertices{
-10.0f, 10.0f, 0.0f,
-10.0f, -10.0f, 0.0f,
10.0f, 10.0f, 0.0f,
10.0f, -10.0f, 0.0f,
};
const std::vector<int> plane_indices{ 3, 1, 0, 2, 3, 0 };
// Create RayTracer
EmbreeRayTracer ert(std::vector<MeshInfo<float>>{MeshInfo<float>(plane_vertices, plane_indices, 0, " ")});
HitStruct res;
// Cast a ray straight down
res = ert.Intersect_IMPL(0, 0, 1, 0, 0, -1);
// Print distance if it connected
if (res.DidHit()) std::cerr << res.distance << std::endl;
else std::cerr << "Miss" << std::endl;
// Cast a ray straight up
res = ert.Intersect_IMPL(0, 0, 1, 0, 0, 1);
//Print distance if it connected
if (res.DidHit()) std::cerr << res.distance << std::endl;
else std::cerr << "Miss" << std::endl;

>>>1
>>>Miss

Definition at line 543 of file embree_raytracer.cpp.

References HF::RayTracer::ConstructHit(), context, and scene.

Referenced by Intersect().

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

◆ Intersections()

template<typename return_type , typename N , typename V >
std::vector< HitStruct< return_type > > HF::RayTracer::EmbreeRayTracer::Intersections ( const N &  nodes,
const V &  directions,
float  max_distance = -1.0f,
const bool  use_parallel = false 
)
inline

Cast multiple rays in parallel.

Template Parameters
return_typeNumeric type for the returned distance value i.e. double, long double, float, etc.
NX,Y,Z A container of objects holding x,y,z coordinates for the origin points of every ray
VX,Y,Z A container of objects holding x,y,z coordinates for the direction points of every ray
Parameters
nodeOrigin points to cast rays from.
directionDirections to cast rays in.
max_distanceMaximum distance a ray can travel before intersections are ignored. Set to -1 for infinite distance.
mesh_idOnly consider intersections with the mesh at this ID. Set to -1 to consider intersections with all meshes.
Returns
An ordered array of results from casting a ray for every origin in origins in the direciton in directions with a matching index. Rays that do not result in an intersection will have hitstructs with meshids of -1. This can be checked by calling the HitStruct's .DidHit function.
Remarks
If use_precise is set to true then this will use a more precise algorithm to calculate returned distance value. This is one of the most basic forms of intersection for the raytracer and many other functions will call this internally.
Precondition
The length of nodes must match the length of directions.

Definition at line 1141 of file embree_raytracer.h.

◆ IntersectOutputArguments()

template<typename N , typename V , typename return_type >
bool HF::RayTracer::EmbreeRayTracer::IntersectOutputArguments ( const N &  node,
const V &  direction,
return_type &  out_distance,
int &  out_meshid,
float  max_distance = -1.0f 
)
inline

Cast a ray from origin in direction and update the parameters instead of returning a hitstruct.

Template Parameters
return_typeNumeric type for the returned distance value i.e. double, long double, float, etc.
NX,Y,Z coordinates representing a point in space
VX,Y,Z Coordinates representing direction vector
Parameters
nodeOrigin point of the ray.
directionDirection to cast the ray in.
max_distanceMaximum distance a ray can travel before intersections are ignored. Set to -1 for infinite distance.
out_distanceOn intersection will be updated to contain the distance from origin to the point of intersection.
out_meshidupdated to contain the ID of the intersected mesh.
Returns
true if the ray did intersect any geometry and the outputs were updated, false otherwise.
Remarks
It's suggested to use Intersect instead of this function.
See also
Intersections for a parallel version of this function

Definition at line 1098 of file embree_raytracer.h.

References HF::RayTracer::HitStruct< numeric_type >::DidHit(), HF::RayTracer::HitStruct< numeric_type >::distance, and HF::RayTracer::HitStruct< numeric_type >::meshid.

Referenced by CastRaysDistance(), and CastSingleRayDistance().

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

◆ Occluded() [1/2]

template<typename N , typename V >
bool HF::RayTracer::EmbreeRayTracer::Occluded ( const N &  origin,
const V &  direction,
float  max_distance = -1.0f,
int  mesh_id = -1 
)
inline

Determine if there is an intersection with any geometry.

Template Parameters
NX,Y,Z coordinates representing a point in space
VX,Y,Z Coordinates representing direction vector
Parameters
nodeA point in space. Must atleast have [0], [1], and [2] defined.
directionDirection to cast the ray in. Same constraints as node, but can be a different type.
max_distanceMaximum distance a ray can travel before intersections are ignored. Set to -1 for infinite distance.
Returns
true if the ray intersected with any geometry within max_distance, false otherwise
Remarks
Occlusion rays are much faster than other intersection functions however they are only able tell whether they intersected with anything or not. These rays are very useful for quick line of sight checks utilizing the max_distance parameter.
Example
// Create Plane
const vector<float> plane_vertices{
-10.0f, 10.0f, 0.0f,
-10.0f, -10.0f, 0.0f,
10.0f, 10.0f, 0.0f,
10.0f, -10.0f, 0.0f,
};
const vector<int> plane_indices{ 3, 1, 0, 2, 3, 0 };
// Create RayTracer
EmbreeRayTracer ert(vector<MeshInfo<float>>{MeshInfo<float>(plane_vertices, plane_indices, 0, " ")});
// Cast a ray straight down
bool straight_down = ert.Occluded(
std::array<float, 3>{0, 0, 1},
std::array<float, 3>{0, 0, -1}
);
if (straight_down) std::cerr << "True" << std::endl;
else std::cerr << "False" << std::endl;
// Cast a ray straight up
bool straight_up = ert.Occluded(
std::array<float, 3>{0, 0, 1},
std::array<float, 3>{0, 0, 1}
);
if (straight_up) std::cerr << "True" << std::endl;
else std::cerr << "False" << std::endl;

>>> True
>>> False

Definition at line 1186 of file embree_raytracer.h.

References Occluded_IMPL().

Referenced by HF::VisibilityGraph::HeightCheck(), and HF::VisibilityGraph::IsOcclusionBetween().

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

◆ Occluded() [2/2]

template<typename numeric1 , typename numeric2 , typename dist_type = float>
bool HF::RayTracer::EmbreeRayTracer::Occluded ( numeric1  x,
numeric1  y,
numeric1  z,
numeric2  dx,
numeric2  dy,
numeric2  dz,
dist_type  max_distance = -1.0,
int  mesh_id = -1 
)
inline

Determine if there is an intersection with any geometry.

Template Parameters
numeric1Numeric type used for the x,y,z components of the origin
numeric2Numeric type used for the x,y,z components of the direction
dist_typeNumeric type used for the distance parameter.
Parameters
xX component of the ray's origin.
yY component of the ray's origin.
zZ component of the ray's origin.
dxX component of the ray's direction.
dyY component of the ray's direction.
dzZ component of the ray's direction.
max_distanceMaximum distance a ray can travel before intersections are ignored. Set to -1 for infinite distance.
mesh_idIgnore intersections with any mesh other than the mesh with this ID. set to -1 to consider intersections with any geometry
Returns
true if the ray intersected with any geometry within max_distance, false otherwise
Remarks
Occlusion rays are much faster than other intersection functions however they are only able tell whether they intersected with anything or not. These rays are very useful for quick line of sight checks utilizing the max_distance parameter.
Example
// Create Plane
const vector<float> plane_vertices{
-10.0f, 10.0f, 0.0f,
-10.0f, -10.0f, 0.0f,
10.0f, 10.0f, 0.0f,
10.0f, -10.0f, 0.0f,
};
const vector<int> plane_indices{ 3, 1, 0, 2, 3, 0 };
// Create RayTracer
EmbreeRayTracer ert(vector<MeshInfo<float>>{MeshInfo<float>(plane_vertices, plane_indices, 0, " ")});
// Cast a ray straight down
bool straight_down = ert.Occluded(0, 0, 1, 0, 0, -1);
if (straight_down) std::cerr << "True" << std::endl;
else std::cerr << "False" << std::endl;
// Cast a ray straight up
bool straight_up = ert.Occluded(0, 0, 1, 0, 0, 1);
if (straight_up) std::cerr << "True" << std::endl;
else std::cerr << "False" << std::endl;

>>> True
>>> False

Definition at line 1233 of file embree_raytracer.h.

References Occluded_IMPL().

+ Here is the call graph for this function:

◆ Occluded_IMPL() [1/2]

bool HF::RayTracer::EmbreeRayTracer::Occluded_IMPL ( const std::array< float, 3 > &  origin,
const std::array< float, 3 > &  direction,
float  max_dist = -1 
)
private

Cast an occlusion ray using arrays as input.

Parameters
originStart point of the ray.
directionDirection of the ray.
max_distMaximum distance of the ray. Any hits beyond this distance will not be counted. If negative, count all hits regardless of distance.
Returns
True if The ray intersected any geometry, False otherwise.

Occulsion rays are faster than the other ray functions, but can only tell if a ray intersected any geometry or it didn't. use the other functions for information such as distance, hitpoint, or meshid.

Example
// Requires #include "embree_raytracer.h", #include "meshinfo.h"
// for brevity
// Create Plane
const std::vector<float> plane_vertices{
-10.0f, 10.0f, 0.0f,
-10.0f, -10.0f, 0.0f,
10.0f, 10.0f, 0.0f,
10.0f, -10.0f, 0.0f,
};
const std::vector<int> plane_indices{ 3, 1, 0, 2, 3, 0 };
// Create RayTracer
EmbreeRayTracer ert(std::vector<MeshInfo<float>>{MeshInfo<float>(plane_vertices, plane_indices, 0, " ")});
// Cast a ray straight down
bool res = ert.Occluded_IMPL(
std::array<float, 3>{ 0, 0, 1 },
std::array<float, 3>{ 0, 0, -1 }
);
// Print Result
if (res) std::cerr << "True" << std::endl;
else std::cerr << "False" << std::endl;
// Cast a ray straight up
res = ert.Occluded_IMPL(
std::array<float, 3>{ 0, 0, 1 },
std::array<float, 3>{ 0, 0, 1 }
);
// Print Result.
if (res) std::cerr << "True" << std::endl;
else std::cerr << "False" << std::endl;

>>> True
>>> False

Definition at line 555 of file embree_raytracer.cpp.

References Occluded_IMPL().

+ Here is the call graph for this function:

◆ Occluded_IMPL() [2/2]

bool HF::RayTracer::EmbreeRayTracer::Occluded_IMPL ( float  x,
float  y,
float  z,
float  dx,
float  dy,
float  dz,
float  distance = -1,
int  mesh_id = -1 
)
private

Implementation for fundamental occlusion ray intersection.

Parameters
xx component of the ray's origin.
yy component of the ray's origin.
zz component of the ray's origin.
dxx component of the ray's direction.
dyy component of the ray's direction.
dzz component of the ray's direction.
distanceMaximum distance of the ray. Any hits beyond this distance will not be counted. If negative, count all hits regardless of distance.
mesh_id(NOT IMPLEMENTED) The id of the only mesh for this ray to collide with. -1 for all.
Returns
True if the ray intersected any geometry. False otherwise.
Example
// Requires #include "embree_raytracer.h", #include "meshinfo.h"
// for brevity
// Create Plane
const std::vector<float> plane_vertices{
-10.0f, 10.0f, 0.0f,
-10.0f, -10.0f, 0.0f,
10.0f, 10.0f, 0.0f,
10.0f, -10.0f, 0.0f,
};
const std::vector<int> plane_indices{ 3, 1, 0, 2, 3, 0 };
// Create RayTracer
EmbreeRayTracer ert(std::vector<MeshInfo<float>>{MeshInfo<float>(plane_vertices, plane_indices, 0, " ")});
// Cast a ray straight down
bool res = ert.Occluded_IMPL(0, 0, 1, 0, 0, -1);
// Print Results
if (res) std::cerr << "True" << std::endl;
else std::cerr << "False" << std::endl;
// Cast a ray straight up
res = ert.Occluded_IMPL(0, 0, 1, 0, 0, 1);
// Print results
if (res) std::cerr << "True" << std::endl;
else std::cerr << "False" << std::endl;

>>> True
>>> False

Definition at line 624 of file embree_raytracer.cpp.

References HF::RayTracer::ConstructRay(), context, and scene.

Referenced by Occluded(), Occluded_IMPL(), and Occlusions().

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

◆ Occlusions()

std::vector< char > HF::RayTracer::EmbreeRayTracer::Occlusions ( const std::vector< std::array< float, 3 > > &  origins,
const std::vector< std::array< float, 3 > > &  directions,
float  max_distance = -1,
bool  use_parallel = true 
)

Cast multiple occlusion rays in parallel.

Parameters
originsA list of origins. If only one is supplied then it will be cast for every direction in directions.
directionsA list of directions. If only one is supplied then it will be cast for every origin in origins
max_distanceMaximum distance the ray can travel
parallelWhether or not to cast the rays in parallel.
Returns
An ordered array of bools where every true indicates a hit and every false indicates a miss.

Can be cast in 3 configurations:

  • Equal amount of directions/origins: Cast a ray for every pair of origin/direction in order. i.e. (origin[0], direction[0]), (origin[1], direction[1])
  • One direction, multiple origins: Cast a ray in the given direction from each origin point in origins.
  • One origin, multiple directions: Cast a ray from the origin point in each direction in directions.
Example
// Requires #include "embree_raytracer.h", #include "meshinfo.h"
// for brevity
// Create Plane
const std::vector<float> plane_vertices{
-10.0f, 10.0f, 0.0f,
-10.0f, -10.0f, 0.0f,
10.0f, 10.0f, 0.0f,
10.0f, -10.0f, 0.0f,
};
const std::vector<int> plane_indices{ 3, 1, 0, 2, 3, 0 };
// Create RayTracer
EmbreeRayTracer ert(std::vector<MeshInfo<float>>{MeshInfo<float>(plane_vertices, plane_indices, 0, " ")});
// Create an array of directions all containing {0,0,-1}
std::vector<std::array<float, 3>> directions(10, std::array<float, 3>{0, 0, -1});
// Create an array of origins with the first 5 values being above the plane and
// the last five values being under it.
std::vector<std::array<float, 3>> origins(10);
for (int i = 0; i < 5; i++) origins[i] = std::array<float, 3>{ 0.0f, 0.0f, 1.0f };
for (int i = 5; i < 10; i++) origins[i] = std::array<float, 3>{ 0.0f, 0.0f, -1.0f };
// Cast every occlusion ray
std::vector<char> results = ert.Occlusions(origins, directions);
// Iterate through all results to print them
std::cout << "[";
for (int i = 0; i < 10; i++) {
// Print true if the ray intersected, false otherwise
if (results[i]) std::cout << "True";
else std::cout << "False";
// Add a comma if it's not the last member
if (i != 9) std::cout << ", ";
}
std::cout << "]" << std::endl;

>>> [True, True, True, True, True, False, False, False, False, False]

Definition at line 563 of file embree_raytracer.cpp.

References Occluded_IMPL().

Referenced by CastOcclusionRays().

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

◆ operator=()

void HF::RayTracer::EmbreeRayTracer::operator= ( const EmbreeRayTracer ERT2)

Increment reference counters to prevent destruction when a copy is made.

Parameters
ERT2Reference to EmbreeRayTracer, the right-hand side of the = statement
// Requires #include "embree_raytracer.h"
// Create a container of coordinates
std::vector<std::array<float, 3>> directions = {
{0, 0, 1},
{0, 1, 0},
{1, 0, 0},
{-1, 0, 0},
{0, -1, 0},
{0, 0, -1},
};
// Create the EmbreeRayTracer
// Create an EmbreeRayTracer, no arguments
// If and when ert_0 goes out of scope,
// data within ert_0 will be retained inside of ert_1.
ert_1 = ert_0;

Definition at line 632 of file embree_raytracer.cpp.

References context, device, geometry, scene, and use_precise.

◆ PointIntersection() [1/2]

bool HF::RayTracer::EmbreeRayTracer::PointIntersection ( float &  x,
float &  y,
float &  z,
float  dx,
float  dy,
float  dz,
float  distance = -1,
int  mesh_id = -1 
)

Cast a single ray and get the hitpoint. x , y ,and z are overridden with the hitpoint on a successful hit.

Parameters
xx component of the ray's origin.
yy component of the ray's origin.
zz component of the ray's origin.
dxx component of the ray's direction.
dyy component of the ray's direction.
dzz component of the ray's direction.
distanceAny intersections beyond this distance are ignored. Set to -1 count any hit regardless of distance.
mesh_id(UNUSED) The id of the only mesh for this ray to collide with. Any geometry wihtout this ID is ignored
Warning
The ray direction must be a unit vector.
Returns
true if the ray hit, false otherwise
Example
// Requires #include "embree_raytracer.h", #include "meshinfo.h"
// for brevity
// Create Plane
const std::vector<float> plane_vertices{
-10.0f, 10.0f, 0.0f,
-10.0f, -10.0f, 0.0f,
10.0f, 10.0f, 0.0f,
10.0f, -10.0f, 0.0f,
};
const std::vector<int> plane_indices{ 3, 1, 0, 2, 3, 0 };
// Create RayTracer
EmbreeRayTracer ert(std::vector<MeshInfo<float>>{MeshInfo<float>(plane_vertices, plane_indices, 0, " ")});
bool res;
// Cast a ray straight down directly at the plane
float x = 0; float y = 0; float z = 1;
res = ert.PointIntersection(x, y, z, 0, 0, -1);
// Print output
if (res) std::cerr << "(" << x << ", " << y << ", " << z << ")" << std::endl;
else std::cerr << "Miss" << std::endl;
// Cast a ray straight up
x = 0; y = 0; z = 1;
res = ert.PointIntersection(x, y, z, 0, 0, 1);
// Print output
if (res) std::cerr << "(" << x << ", " << y << ", " << z << ")" << std::endl;
else std::cerr << "Miss" << std::endl;

>>>(0, 0, 0)
>>>Miss

Definition at line 420 of file embree_raytracer.cpp.

References HF::RayTracer::HitStruct< numeric_type >::DidHit(), and HF::RayTracer::HitStruct< numeric_type >::distance.

+ Here is the call graph for this function:

◆ PointIntersection() [2/2]

bool HF::RayTracer::EmbreeRayTracer::PointIntersection ( std::array< float, 3 > &  origin,
const std::array< float, 3 > &  dir,
float  distance = -1,
int  mesh_id = -1 
)

Cast a ray and overwrite the origin with the hitpoint if it intersects any geometry.

Parameters
dirDirection to cast the ray in.
originStart point of the ray. Updated to contain the hitpoint if successful.
distanceAny hits beyond this distance are ignored. Set to -1 to count all intersections regardless of distance.
mesh_id(UNUSED) The id of the only mesh for this ray to collide with. -1 for all
Returns
True if the ray intersected some geometry and the origin is updated with the hit point. False otherwise.
Example
// Requires #include "embree_raytracer.h", #include "meshinfo.h"
// for brevity
// Create Plane
const std::vector<float> plane_vertices{
-10.0f, 10.0f, 0.0f,
-10.0f, -10.0f, 0.0f,
10.0f, 10.0f, 0.0f,
10.0f, -10.0f, 0.0f,
};
const std::vector<int> plane_indices{ 3, 1, 0, 2, 3, 0 };
// Create RayTracer
EmbreeRayTracer ert(std::vector<MeshInfo<float>>{MeshInfo<float>(plane_vertices, plane_indices, 0, " ")});
// Cast a ray straight down
std::array<float, 3> origin{ 0,0,1 };
bool res = ert.PointIntersection(
origin,
std::array<float, 3>{0, 0, -1}
);
// Print Results
if (res) std::cerr << "(" << origin[0] << ", " << origin[1] << ", " << origin[2] << ")" << std::endl;
else std::cerr << "Miss" << std::endl;
// Cast a ray straight up
origin = std::array<float, 3>{ 0, 0, 1 };
res = ert.PointIntersection(
origin,
std::array<float, 3>{0, 0, 1}
);
// Print Results
if (res) std::cerr << "(" << origin[0] << ", " << origin[1] << ", " << origin[2] << ")" << std::endl;
else std::cerr << "Miss" << std::endl;

>>>(0,0,0)
>>>Miss

Definition at line 411 of file embree_raytracer.cpp.

References PointIntersection().

Referenced by CastRay(), PointIntersection(), and PointIntersections().

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

◆ PointIntersections()

std::vector< char > HF::RayTracer::EmbreeRayTracer::PointIntersections ( std::vector< std::array< float, 3 > > &  origins,
std::vector< std::array< float, 3 > > &  directions,
bool  use_parallel = true,
float  max_distance = -1,
int  mesh_id = -1 
)

Cast multiple rays and recieve hitpoints in return.

Parameters
originsAn array of x,y,z coordinates to cast rays from.
directionsAn array of x,y,z directions to cast in.
use_parallelCast rays in parallel if true, if not cast in serial. All available cores will be used.
max_distanceMaximum distance the ray can travel. Any intersections beyond this distance will be ignored. If set to 1, all intersections will be counted regardless of distance.
mesh_id(UNUSED) Only intersect with the mesh of this ID
Returns
A vector of Vector3D for the hitpoint of each ray cast. If a ray didn't hit, its point will be invalid, checkable using Vector3D.IsValid().

Can be cast in 3 configurations:

  • Equal amount of directions/origins: Cast a ray for every pair of origin/direction in order. i.e. (origin[0], direction[0]), (origin[1], direction[1])
  • One direction, multiple origins: Cast a ray in the given direction from each origin point in origins.
  • One origin, multiple directions: Cast a ray from the origin point in each direction in directions.
Exceptions
System.ArgumentExceptionLength of directions and origins did not match any of the valid cases.
Example
// Requires #include "embree_raytracer.h", #include "meshinfo.h"
// for brevity
// Create plane
const std::vector<float> plane_vertices{
-10.0f, 10.0f, 0.0f,
-10.0f, -10.0f, 0.0f,
10.0f, 10.0f, 0.0f,
10.0f, -10.0f, 0.0f,
};
const std::vector<int> plane_indices{ 3, 1, 0, 2, 3, 0 };
// Create RayTracer
EmbreeRayTracer ert(std::vector<MeshInfo<float>>{MeshInfo<float>(plane_vertices, plane_indices, 0, " ")});
// Create an array of directions all containing {0,0,-1}
std::vector<std::array<float, 3>> directions(10, std::array<float, 3>{ 0, 0, -1 });
// Create an array of origin points moving further to the left with each point
std::vector<std::array<float, 3>> origins(10);
for (int i = 0; i < 10; i++) origins[i] = std::array<float, 3>{static_cast<float>(2 * i), 0, 1};
// Cast every ray.
auto results = ert.PointIntersections(origins, directions);
// Print results
std::cout << "[";
for (int i = 0; i < 10; i++) {
if (results[i])
std::cout << "(" << origins[i][0] << ", " << origins[i][1] << ", " << origins[i][2] << ")";
else
std::cout << "Miss";
if (i != 9) std::cout << ", ";
}
std::cout << "]" << std::endl;

>>> [(0, 0, 0), (1.99, 0, 0), (3.98, 0, 0), (5.97, 0, 0), (7.96, 0, 0), (9.95, 0, 0), Miss, Miss, Miss, Miss]

Definition at line 480 of file embree_raytracer.cpp.

References PointIntersection().

Referenced by CastMultipleDirectionsOneOrigin(), CastMultipleOriginsOneDirection(), and CastMultipleRays().

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

◆ SetupScene()

void HF::RayTracer::EmbreeRayTracer::SetupScene ( )
private

Performs all the necessary operations to set up the scene.

1) Creates device 2) Creates the scene using device 3) Sets the build quality of the scene 4) Sets scene flags 5) Inits Intersect_IMPL context

Remarks
Any changes to the internal settings of embree should be handled here. I.E. Enforcing That all bvh's used be of robust quality, assigning a custom context, etc.

Definition at line 190 of file embree_raytracer.cpp.

References context, device, and scene.

Referenced by EmbreeRayTracer().

+ Here is the caller graph for this function:

Member Data Documentation

◆ context

RTCIntersectContext HF::RayTracer::EmbreeRayTracer::context
private

Context to cast rays within.

Definition at line 86 of file embree_raytracer.h.

Referenced by EmbreeRayTracer(), Intersect_IMPL(), Occluded_IMPL(), operator=(), and SetupScene().

◆ device

RTCDevice HF::RayTracer::EmbreeRayTracer::device
private

◆ geometry

std::vector<RTCGeometry> HF::RayTracer::EmbreeRayTracer::geometry
private

Definition at line 94 of file embree_raytracer.h.

Referenced by EmbreeRayTracer(), ConstructGeometryFromBuffers(), and operator=().

◆ scene

RTCScene HF::RayTracer::EmbreeRayTracer::scene
private

◆ triangles

Triangle* HF::RayTracer::EmbreeRayTracer::triangles
private

Triangle buffer. Is used in multiple places, but contents are dumped.

Definition at line 88 of file embree_raytracer.h.

Referenced by ConstructGeometryFromBuffers().

◆ use_precise

bool HF::RayTracer::EmbreeRayTracer::use_precise = false
private

If true, use custom triangle intersection intersection instead of embree's.

Definition at line 92 of file embree_raytracer.h.

Referenced by EmbreeRayTracer(), and operator=().

◆ Vertices

Vertex* HF::RayTracer::EmbreeRayTracer::Vertices
private

Vertex buffer. Is used in multiple places but contents are dumped.

Definition at line 90 of file embree_raytracer.h.

Referenced by ConstructGeometryFromBuffers().


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