19 #if !defined(__NORI_BVH_H)
22 #include <nori/shape.h>
47 BVH() { m_shapeOffset.push_back(0u); }
81 bool shadowRay =
false)
const;
106 auto it = std::lower_bound(m_shapeOffset.begin(), m_shapeOffset.end(), idx+1) - 1;
108 return (uint32_t) (it - m_shapeOffset.begin());
114 return m_shapes[shapeIdx]->getBoundingBox(index);
118 Point3f getCentroid(uint32_t index)
const {
120 return m_shapes[shapeIdx]->getCentroid(index);
124 std::pair<float, uint32_t>
statistics(uint32_t index = 0)
const;
145 bool isLeaf()
const {
146 return leaf.flag == 1;
149 bool isInner()
const {
150 return leaf.flag == 0;
153 bool isUnused()
const {
157 uint32_t start()
const {
161 uint32_t end()
const {
162 return leaf.start + leaf.size;
166 std::vector<Shape *> m_shapes;
167 std::vector<uint32_t> m_shapeOffset;
168 std::vector<BVHNode> m_nodes;
169 std::vector<uint32_t> m_indices;
Build task for parallel BVH construction.
Bounding Volume Hierarchy for fast ray intersection queries.
uint32_t findShape(uint32_t &idx) const
Compute the shape and primitive indices corresponding to a primitive index used by the underlying gen...
bool rayIntersect(const Ray3f &ray, Intersection &its, bool shadowRay=false) const
Intersect a ray against all shapes registered with the BVH.
Shape * getShape(uint32_t idx)
Return one of the registered shapes.
std::pair< float, uint32_t > statistics(uint32_t index=0) const
Compute internal tree statistics.
uint32_t getPrimitiveCount() const
Return the total number of internally represented primitives.
virtual ~BVH()
Release all resources.
void build()
Build the BVH.
const Shape * getShape(uint32_t idx) const
Return one of the registered shapes (const version)
void clear()
Release all resources.
uint32_t getShapeCount() const
Return the total number of shapes registered with the BVH.
BVH()
Create a new and empty BVH.
void addShape(Shape *shape)
Register a shape for inclusion in the BVH.
Superclass of all shapes.
Intersection data structure.