9#include <Common/assertion.h>
10#include <Common/logging.h>
11#include <Common/math_basics.h>
18template<std::
size_t N,
typename Index>
19inline void TWideBvhIntersector<N, Index>
22 rebuildWithIntersectables(intersectables);
25template<std::
size_t N,
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<std::
size_t N,
typename Index>
54inline auto TWideBvhIntersector<N, Index>
61template<std::
size_t N,
typename Index>
65 constexpr auto itemToAABB =
73 params.
splitMethod = math::EBvhNodeSplitMethod::SAH_Buckets_OneAxis;
80 auto const rootInfoNode = builder.buildInformativeBvh(intersectables);
81 m_bvh.build(rootInfoNode, builder.totalInfoNodes(), builder.totalItems());
84 m_rootAABB = math::AABB3D::makeEmpty();
87 for(std::size_t ci = 0; ci < N; ++ci)
89 m_rootAABB.unionWith(m_bvh.getRoot().getAABB(ci));
100 const std::size_t treeDepth = builder.calcMaxDepth(rootInfoNode);
103 "intersector: BVH{} ({}-byte index), total intersectables: {}, total nodes: {}, "
104 "max tree depth: {}, memory usage: {} GiB", N,
sizeof(Index), m_bvh.numItems(),
105 m_bvh.numNodes(), treeDepth, math::bytes_to_GiB<double>(m_bvh.memoryUsage()));
107 if(treeDepth > m_bvh.TRAVERSAL_STACK_SIZE)
109 PH_DEFAULT_LOG(Error,
110 "BVH{} depth ({}) exceeds traversal stack size ({})",
111 N, 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
Wide BVH acceleration structure supporting arbitrary branch factor.
Definition TWideBvhIntersector.h:20
math::AABB3D calcAABB() const override
Calculates Axis-Aligned Bounding Box (AABB) of itself.
Definition TWideBvhIntersector.ipp:55
Definition BvhParams.h:20
uint32 numSahBuckets
Definition BvhParams.h:26
EBvhNodeSplitMethod splitMethod
Definition BvhParams.h:35
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