59 std::vector<BoundedShapeData*> shapes;
64 std::vector<std::shared_ptr<Node>> children;
72 void build(
const std::vector<TriangleData> &triangles);
86 std::optional<TracedData>
traceEllipsoid(glm::vec3 pos, glm::vec3 dir, glm::vec3 scale);
96 static const int NUM_TRIANGLES_PER_LEAF = 10;
106 void build(std::shared_ptr<Node> node, std::vector<BoundedShapeData*> &shapes);
108 std::shared_ptr<Node> root;
109 std::vector<BoundedShapeData> allShapes;
123 void traceEllipsoid(glm::vec3 pos, glm::vec3 dir, glm::vec3 scale,
124 std::shared_ptr<Node> node, std::optional<TracedData> &result);
A tree of bounding volumes, with leaf nodes containing a collection of triangles. Useful as a space-a...
Definition: bvh.h:19
void build(const std::vector< TriangleData > &triangles)
Build a BoundingVolumeHierarchy based on a collection of TriangleData.
std::tuple< TriangleData *, float > TracedData
Information about a trace operation on this datastructure, including a pointer to the first TriangleD...
Definition: bvh.h:49
std::optional< TracedData > traceEllipsoid(glm::vec3 pos, glm::vec3 dir, glm::vec3 scale)
Trace an ellipsoid through the Bounding Volume Hierarchy, reporting the first intersection if it exis...
Definition: bvh.cpp:105
Represents a bounding box.
Definition: boundingBox.h:13
Data on a bounded triangle, which includes the triangle itself and its BoundingBox.
Definition: bvh.h:33
void computeBound()
Recompute the bounding box of the triangle inside the data field. Call this function after assigning ...
Definition: bvh.cpp:130
BoundingBox box
triangle's bounding box.
Definition: bvh.h:34
TriangleData data
triangle's information.
Definition: bvh.h:35
Data on a single triangles in the structure.
Definition: bvh.h:24
glm::vec3 triangle[3]
coordinates of the triangle, in CCW order.
Definition: bvh.h:25
Entity entity
the entity the triangle is attached to.
Definition: bvh.h:26