7#include <cgv/math/fray.h>
8#include <cgv/math/fvec.h>
9#include <cgv/media/axis_aligned_box.h>
19 float t = std::numeric_limits<float>::max();
129 void build(
const std::vector<const ray_intersectable*>& primitives,
size_t max_depth = 8);
138 std::vector<const ray_intersectable*> _primitives;
142 std::unique_ptr<bvh_node> _root = std::make_unique<bvh_node>();
149 void split(
bvh_node* node,
int depth = 0);
155#include <cgv/config/lib_end.h>
A Bounding Volume Hierarchy(BVH) using axis-aligned bounding boxes to partition primitives into a bin...
An interface to define objects that are intersectable with a ray.
virtual bool intersect(const cgv::ray3 &ray, ray_intersection_info &info) const =0
Test if the object is intersected by the given ray.
virtual cgv::box3 get_bounds() const =0
Return the axis-aligned bounding box of the primitive.
this header is dependency free
A single node of a bounding volume hierarchy.
std::vector< size_t > primitive_indices
The list of primitive indices contained in this node. After building the tree, only leaf nodes will h...
cgv::box3 bounds
The node's axis aligned bounding box.
std::unique_ptr< bvh_node > child_b
The second child node of this node.
std::unique_ptr< bvh_node > child_a
The first child node of this node.
The result of a BVH intersection test.
size_t primitive_index
The index of the hit primitive as given during BVH construction.
ray_intersection_info intersection
Intersection information of the hit.
bool is_hit
True if a primitive was hit.
const ray_intersectable * primitive
A pointer to the hit primitive.
Holds information about a single intersection of a ray and primitive.
cgv::vec3 normal
The intersection surface normal.
cgv::vec2 uv
The intersection surface texture coordinates.
float t
The ray parameter.
Struct template for fixed n-dimensional rays with arbitrary data type defined by origin and direction...