Saga
Saga Game Engine
Loading...
Searching...
No Matches
Saga::BoundingVolumeHierarchy Class Reference

A tree of bounding volumes, with leaf nodes containing a collection of triangles. Useful as a space-accelerant structure to speed up collision detection. More...

#include <bvh.h>

Classes

struct  BoundedShapeData
 Data on a bounded triangle, which includes the triangle itself and its BoundingBox. More...
 
struct  TriangleData
 Data on a single triangles in the structure. More...
 

Public Types

using TracedData = std::tuple< TriangleData *, float >
 Information about a trace operation on this datastructure, including a pointer to the first TriangleData that the trace hits, as well as time t where it hits this triangle.
 

Public Member Functions

void build (const std::vector< TriangleData > &triangles)
 Build a BoundingVolumeHierarchy based on a collection of TriangleData.
 
std::optional< TracedDatatraceEllipsoid (glm::vec3 pos, glm::vec3 dir, glm::vec3 scale)
 Trace an ellipsoid through the Bounding Volume Hierarchy, reporting the first intersection if it exists.
 

Detailed Description

A tree of bounding volumes, with leaf nodes containing a collection of triangles. Useful as a space-accelerant structure to speed up collision detection.

Member Typedef Documentation

◆ TracedData

Information about a trace operation on this datastructure, including a pointer to the first TriangleData that the trace hits, as well as time t where it hits this triangle.

Member Function Documentation

◆ build()

void Saga::BoundingVolumeHierarchy::build ( const std::vector< TriangleData > &  triangles)

Build a BoundingVolumeHierarchy based on a collection of TriangleData.

Parameters
trianglesall the triangles to use to build this BoundingVolumeHierarchy.

◆ traceEllipsoid()

std::optional< BoundingVolumeHierarchy::TracedData > Saga::BoundingVolumeHierarchy::traceEllipsoid ( glm::vec3  pos,
glm::vec3  dir,
glm::vec3  scale 
)

Trace an ellipsoid through the Bounding Volume Hierarchy, reporting the first intersection if it exists.

Parameters
posthe starting position of the ellipsoid.
dirthe direction the ellipsoid is heading. We only trace up to this direction, meaning if the intersection happens further than pos + dir, we do not count it
scalethe radius of the ellipsoid in the three cardinal directions.
Returns
std::optional<TracedData> containing nothing, or a pair of TriangleData*, and a float t signifying that the intersection happens first at pos + dir
Here is the call graph for this function:

The documentation for this class was generated from the following files: