90 QSSGMeshBVH() =
default;
93 [[nodiscard]] QSSGMeshBVHNode::Handle newHandle()
95 m_nodes.emplace_back();
96 return {
this, m_nodes.size() - 1 };
99 [[nodiscard]]
const QSSGMeshBVHTriangles &triangles()
const {
return m_triangles; }
100 [[nodiscard]]
const QSSGMeshBVHRoots &roots()
const {
return m_roots; }
101 [[nodiscard]]
const QSSGMeshBVHNodes &nodes()
const {
return m_nodes; }
104 friend class QSSGMeshBVHNode::Handle;
105 friend class QSSGMeshBVHBuilder;
106 using FallbackIndex = QSSGMeshBVHNode::FallbackIndex;
107 size_t getNodeIndex(size_t idx, FallbackIndex op)
const
109 const bool valid = (idx >= size_t(FallbackIndex::Count) && idx < m_nodes.size());
110 return (valid * idx) + (!valid * size_t(op));
113 QSSGMeshBVHNode &mutableValue(qsizetype idx)
115 return m_nodes[getNodeIndex(idx, FallbackIndex::InvalidWrite)];
118 const QSSGMeshBVHNode &value(qsizetype idx)
const
120 return m_nodes[getNodeIndex(idx, FallbackIndex::InvalidRead)];
123 QSSGMeshBVHRoots m_roots;
124 QSSGMeshBVHNodes m_nodes { { }, { } };
125 QSSGMeshBVHTriangles m_triangles;