10#include <Common/assertion.h>
11#include <Common/logging.h>
18template<
typename Index>
19inline void TBinaryBvhIntersector<Index>
22 rebuildWithIntersectables(intersectables);
25template<
typename Index>
29 return m_bvh.nearestTraversal(
31 [ray, &probe, originalProbe = probe](
34 -> std::optional<real>
36 PH_ASSERT(intersectable);
38 const Ray raySegment(segment, ray.getTime());
40 HitProbe trialProbe = originalProbe;
41 if(intersectable->isIntersecting(raySegment, trialProbe))
44 return trialProbe.getHitRayT();
53template<
typename Index>
54inline auto TBinaryBvhIntersector<Index>
60 return math::AABB3D::makeEmpty();
63 return m_bvh.getRoot().getAABB();
66template<
typename Index>
70 constexpr auto itemToAABB =
78 auto const rootInfoNode = builder.buildInformativeBvh(intersectables);
79 m_bvh.build(rootInfoNode, builder.totalInfoNodes(), builder.totalItems());
83 const std::size_t treeDepth = builder.calcMaxDepth(rootInfoNode);
86 "intersector: Binary BVH ({}-byte index), total intersectables: {}, total nodes: {}, "
87 "max tree depth: {}, memory usage: {} GiB",
sizeof(Index), m_bvh.numItems(),
88 m_bvh.numNodes(), treeDepth, math::bytes_to_GiB<double>(m_bvh.memoryUsage()));
90 if(treeDepth > m_bvh.TRAVERSAL_STACK_SIZE)
93 "BVH depth ({}) exceeds traversal stack size ({})",
94 treeDepth, m_bvh.TRAVERSAL_STACK_SIZE);
Lightweight ray intersection testing and reporting object. If an intersection is found,...
Definition HitProbe.h:27
An object in the scene that a ray can intersect with.
Definition Intersectable.h:31
Represents a ray in space.
Definition Ray.h:21
const math::TLineSegment< real > & getSegment() const
Definition Ray.h:229
Classic binary BVH acceleration structure.
Definition TBinaryBvhIntersector.h:16
math::AABB3D calcAABB() const override
Calculates Axis-Aligned Bounding Box (AABB) of itself.
Definition TBinaryBvhIntersector.ipp:55
Definition TBvhBuilder.h:25
Represents a line segment in space.
Definition TLineSegment.h:25
Miscellaneous math utilities.
The root for all renderer implementations.
Definition EEngineProject.h:6
std::span< const T, EXTENT > TSpanView
Same as TSpan, except that the objects are const-qualified. Note that for pointer types,...
Definition TSpan.h:19