Allows to cast rays against a polygonal mesh, on the CPU. Relies on an internal acceleration structure to speed up intersection queries.
More...
#include <Raycaster.hpp>
|
std::vector< TriangleInfos > | _triangles |
| Merged triangles informations.
|
|
std::vector< glm::vec3 > | _vertices |
| Merged vertices.
|
|
std::vector< Node > | _hierarchy |
| Acceleration structure.
|
|
unsigned int | _meshCount = 0 |
| Number of meshes stored in the raycaster.
|
|
Allows to cast rays against a polygonal mesh, on the CPU. Relies on an internal acceleration structure to speed up intersection queries.
◆ Raycaster() [1/3]
◆ Raycaster() [2/3]
◆ Raycaster() [3/3]
◆ addMesh()
void Raycaster::addMesh |
( |
const Mesh & |
mesh, |
|
|
const glm::mat4 & |
model |
|
) |
| |
Adds a mesh to the internal geometry.
- Parameters
-
mesh | the mesh to add |
model | the transformation matrix to apply to the vertices |
◆ interpolateAttribute()
template<typename T >
static T Raycaster::interpolateAttribute |
( |
const Hit & |
hit, |
|
|
const Mesh & |
geometry, |
|
|
const std::vector< T > & |
attribute |
|
) |
| |
|
inlinestatic |
Return the interpolated attribute for a hit at the surface of the mesh.
- Parameters
-
hit | the intersection record |
geometry | the mesh geometry information |
attribute | the vector containing per-vertex values for the attribute |
- Returns
- the interpolated attribute
◆ intersects() [1/3]
Raycaster::Hit Raycaster::intersects |
( |
const glm::vec3 & |
origin, |
|
|
const glm::vec3 & |
direction, |
|
|
float |
mini = 0.0001f , |
|
|
float |
maxi = 1e8f |
|
) |
| const |
Find the closest intersection of a ray with the geometry.
- Parameters
-
origin | ray origin |
direction | ray direction (not necessarily normalized) |
mini | the minimum distance allowed for the intersection |
maxi | the maximum distance allowed for the intersection |
- Returns
- a hit object containg the potential hit informations
◆ intersects() [2/3]
static bool Raycaster::intersects |
( |
const Ray & |
ray, |
|
|
const BoundingBox & |
box, |
|
|
float |
mini, |
|
|
float |
maxi |
|
) |
| |
|
staticprivate |
Test a ray and bounding box intersection.
- Parameters
-
ray | the ray |
box | the bounding box |
mini | the minimum allowed distance along the ray |
maxi | the maximum allowed distance along the ray |
- Returns
- a boolean denoting intersection
◆ intersects() [3/3]
Test a ray and triangle intersection using the Muller-Trumbore test.
- Parameters
-
ray | the ray |
tri | the triangle infos |
mini | the minimum allowed distance along the ray |
maxi | the maximum allowed distance along the ray |
- Returns
- a hit object containg the potential hit informations
◆ intersectsAny()
bool Raycaster::intersectsAny |
( |
const glm::vec3 & |
origin, |
|
|
const glm::vec3 & |
direction, |
|
|
float |
mini = 0.0001f , |
|
|
float |
maxi = 1e8f |
|
) |
| const |
Intersect a ray with the geometry.
- Parameters
-
origin | ray origin |
direction | ray direction (not necessarily normalized) |
mini | the minimum distance allowed for the intersection |
maxi | the maximum distance allowed for the intersection |
- Returns
- true if the ray intersected geometry
◆ operator=() [1/2]
Copy assignment.
- Returns
- a reference to the object assigned to
◆ operator=() [2/2]
Move assignment.
- Returns
- a reference to the object assigned to
◆ updateHierarchy()
void Raycaster::updateHierarchy |
( |
| ) |
|
Update the internal bounding volume hierarchy.
- Note
- This operation can be costful in time.
◆ visible()
bool Raycaster::visible |
( |
const glm::vec3 & |
p0, |
|
|
const glm::vec3 & |
p1 |
|
) |
| const |
Test visibility between two points.
- Parameters
-
p0 | first point |
p1 | second point |
- Returns
- true if the two points are joined by a free-space segment
- Note
- A ray is shot from the first to the second point to test for visibility.
The documentation for this class was generated from the following files:
- src/engine/raycaster/Raycaster.hpp
- src/engine/raycaster/Raycaster.cpp