Path Tracing
Loading...
Searching...
No Matches
bvh.cpp File Reference
#include "bvh.hpp"
#include <stdio.h>
#include <algorithm>
#include <cfloat>
Include dependency graph for bvh.cpp:

Classes

struct  TriInfo
 Pre-calculated triangle center stored for runtime. More...
struct  BVHBuilder

Functions

bool buildBVH (vector< GPUTriangle > &triangles, vector< BVHNode > &bvh_nodes)
 Builds the BVH using a triangle list. Recursively splits each triangle node at median along the longest axis of its AABB, reorders triangles in place so each leaf references a range. The resulting array is written to bvh_noes with root at index 0.
bool uploadBVH (const vector< BVHNode > &bvh_nodes, GLuint &ssbo)
 Uploads the BVH node array to GPU SSBO. Creates the buffer on first use and fills it with bvh_nodes. The shader reads this buffer starting from the root idx 0.

Function Documentation

◆ buildBVH()

bool buildBVH ( vector< GPUTriangle > & triangles,
vector< BVHNode > & bvh_nodes )

Builds the BVH using a triangle list. Recursively splits each triangle node at median along the longest axis of its AABB, reorders triangles in place so each leaf references a range. The resulting array is written to bvh_noes with root at index 0.

Parameters
trianglesIn-out triangle buffer
bvh_nodesOutput flattened node array
Returns
true on success

◆ uploadBVH()

bool uploadBVH ( const vector< BVHNode > & bvh_nodes,
GLuint & ssbo )

Uploads the BVH node array to GPU SSBO. Creates the buffer on first use and fills it with bvh_nodes. The shader reads this buffer starting from the root idx 0.

Parameters
bvh_nodesThe node array produced by buildBVH
ssboIn-out SSBO handle, created if zero
Returns
true on success
See also
buildBVH