Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
TBvhInfoNode.h
Go to the documentation of this file.
1#pragma once
2
4#include "Math/constant.h"
5#include "Utility/TSpan.h"
6
7#include <cstddef>
8#include <array>
9
10namespace ph::math
11{
12
13template<typename Item>
14class TBvhItemInfo;
15
19template<std::size_t N, typename Item>
20class TBvhInfoNode final
21{
22 static_assert(N >= 2);
23
24public:
26
27 static auto makeInternal(
28 const std::array<const TBvhInfoNode*, N>& children,
29 std::size_t singleSplitAxis)
30 -> TBvhInfoNode;
31
32 static auto makeLeaf(
34 const AABB3D& leafAabb)
35 -> TBvhInfoNode;
36
37 static constexpr bool isBinary();
38 static constexpr std::size_t numChildren();
39 static constexpr std::size_t noAxisFlag();
40
41public:
43
44 bool isBinaryLeaf() const;
45 bool isBinaryInternal() const;
46 bool isLeaf() const;
47 bool isInternal() const;
48
49 auto getChild(std::size_t childIdx) const
50 -> const TBvhInfoNode*;
51
52 auto getItems() const
54
55 auto getAABB() const
56 -> const AABB3D&;
57
58 auto getSingleSplitAxis() const
59 -> std::size_t;
60
64 auto getSplitAxis(std::size_t childIdx) const
65 -> std::size_t;
66
67 bool isSingleSplitAxis() const;
68
69private:
70 inline static constexpr uint8 NO_AXIS_FLAG = 0b11;
71
72 static_assert(
73 constant::X_AXIS < NO_AXIS_FLAG &&
74 constant::Y_AXIS < NO_AXIS_FLAG &&
75 constant::Z_AXIS < NO_AXIS_FLAG);
76
77 struct ChildFlags
78 {
79 uint8 splitAxis : 2 = NO_AXIS_FLAG;
80 };
81
82 std::array<const TBvhInfoNode*, N> m_children;
84 AABB3D m_aabb;
85
87 std::array<ChildFlags, N> m_perChildFlags;
88
90 uint32f m_singleSplitAxis : 2;
91
92 uint32f m_isLeaf : 1;
93};
94
95}// end namespace ph::math
96
if constexpr(IS_ROBUST)
Definition TBvhSimdComputingContext.h:561
General BVH node packed with additional information. This node type is typically used for building ot...
Definition TLinearDepthFirstWideBvh.h:21
auto getSplitAxis(std::size_t childIdx) const -> std::size_t
Definition TBvhInfoNode.ipp:164
static constexpr std::size_t noAxisFlag()
Definition TBvhInfoNode.ipp:73
bool isBinaryLeaf() const
Definition TBvhInfoNode.ipp:90
auto getItems() const -> TSpanView< ItemInfoType >
Definition TBvhInfoNode.ipp:137
bool isInternal() const
Definition TBvhInfoNode.ipp:120
static auto makeInternal(const std::array< const TBvhInfoNode *, N > &children, std::size_t singleSplitAxis) -> TBvhInfoNode
Definition TBvhInfoNode.ipp:14
bool isBinaryInternal() const
Definition TBvhInfoNode.ipp:102
static constexpr bool isBinary()
Definition TBvhInfoNode.ipp:58
TBvhInfoNode()
Definition TBvhInfoNode.ipp:80
auto getSingleSplitAxis() const -> std::size_t
Definition TBvhInfoNode.ipp:153
auto getAABB() const -> const AABB3D &
Definition TBvhInfoNode.ipp:145
bool isLeaf() const
Definition TBvhInfoNode.ipp:113
auto getChild(std::size_t childIdx) const -> const TBvhInfoNode *
Definition TBvhInfoNode.ipp:127
bool isSingleSplitAxis() const
Definition TBvhInfoNode.ipp:175
static constexpr std::size_t numChildren()
Definition TBvhInfoNode.ipp:65
static auto makeLeaf(TSpanView< ItemInfoType > leafItems, const AABB3D &leafAabb) -> TBvhInfoNode
Definition TBvhInfoNode.ipp:43
Definition TBvhItemInfo.h:11
Math functions and utilities.
Definition TransformInfo.h:10
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
Definition TAABB2D.h:96