Template Class BVHTree
Defined in File BVH.hpp
Nested Relationships
Nested Types
Class Documentation
-
template<typename BaseVecT>
class BVHTree Implementation of an Bounding Volume Hierarchy Tree used for ray casting.
This class generates a BVHTree from the given triangle mesh represented by vertices and faces. AABB are used as bounding volumes. The Tree Contains inner nodes and leaf nodes. The leaf nodes are grouped into inner nodes using the surface area heuristic. The tree is represented in two ways: the normal tree structure and the cache friendly index representation.
- Template Parameters:
BaseVecT –
Public Functions
-
BVHTree(const vector<float> &vertices, const vector<uint32_t> &faces)
Constructs the tree itself and it’s cache friendly representation.
- Parameters:
vertices – Vertices of mesh to create tree for
faces – Faces of mesh to create tree for
-
BVHTree(const floatArr vertices, size_t n_vertices, const indexArray faces, size_t n_faces)
-
BVHTree(const MeshBufferPtr mesh)
-
const vector<uint32_t> &getTriIndexList() const
- Returns:
Index list (for getTrianglesIntersectionData) of triangles in the leaf nodes
-
const vector<float> &getLimits() const
- Returns:
Boundaries of the the AABB of all nodes
-
const vector<uint32_t> &getIndexesOrTrilists() const
- Returns:
Four values per node:
value: 1st bit of first value indicates, wether the current node is a leaf node or inner node. If it’s a leaf node the rest of the bits indicate the number of triangles in this node.
value: Only set, if the node is an inner node. Indicates the start index of the left sub tree in this vector.
value: Only set, if the node is an inner node. Indicates the start index of the right sub tree in this vector.
value: Only set, if the node is a leaf node. Contains the start index for triangles in getTriIndexList
-
const vector<float> &getTrianglesIntersectionData() const
Returns precalculated values for the triangle intersection tests.
- Returns:
16 values per triangle: 1-3: x, y, z of normal 4: normal.dot(point1) 5-7: x, y, z of edge plane vector 1 8: scalar product of point 1 and edge plane vector 1 9-11: x, y, z of edge plane vector 2 12: scalar product of point 2 and edge plane vector 2 13-15: x, y, z of edge plane vector 3 16: scalar product of point 3 and edge plane vector 3
-
const uint32_t getMaxDepth() const noexcept
Returns the depth of the tree at its deepest node.