Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
TIndexedKdtreeIntersector.h
Go to the documentation of this file.
1#pragma once
2
5
6#include <Common/assertion.h>
7#include <Common/primitive_type.h>
8
9#include <vector>
10
11namespace ph
12{
13
14template<typename Index = uint32>
16{
17public:
19
20 void update(TSpanView<const Intersectable*> intersectables) override;
21 bool isIntersecting(const Ray& ray, HitProbe& probe) const override;
22 math::AABB3D calcAABB() const override;
23
24private:
25 struct IndexedIntersectables
26 {
27 std::vector<const Intersectable*> vec;
28
29 const Intersectable* operator () (const std::size_t index) const
30 {
31 PH_ASSERT_LT(index, vec.size());
32
33 return vec[index];
34 }
35 };
36
37 struct IntersectableAABBCalculator
38 {
39 math::AABB3D operator () (const Intersectable* const intersectable) const
40 {
41 PH_ASSERT(intersectable);
42
43 return intersectable->calcAABB();
44 }
45 };
46
48 IndexedIntersectables,
49 IntersectableAABBCalculator,
50 Index>;
51
52 Tree m_tree;
54};
55
56}// end namespace ph
57
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
virtual math::AABB3D calcAABB() const =0
Calculates Axis-Aligned Bounding Box (AABB) of itself.
Definition Intersector.h:14
Represents a ray in space.
Definition Ray.h:21
Definition TIndexedKdtreeIntersector.h:16
TIndexedKdtreeIntersector(math::IndexedKdtreeParams params=math::IndexedKdtreeParams())
Definition TIndexedKdtreeIntersector.ipp:14
void update(TSpanView< const Intersectable * > intersectables) override
Definition TIndexedKdtreeIntersector.ipp:28
bool isIntersecting(const Ray &ray, HitProbe &probe) const override
Determine whether a given ray hits the object.
Definition TIndexedKdtreeIntersector.ipp:46
math::AABB3D calcAABB() const override
Calculates Axis-Aligned Bounding Box (AABB) of itself.
Definition TIndexedKdtreeIntersector.ipp:75
Definition IndexedKdtreeParams.h:9
Definition TIndexedKdtree.h:28
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