+ | BVH Sah

This commit is contained in:
TheRedShip
2025-01-19 17:58:11 +01:00
parent 71df788350
commit 0ae411d8ea
6 changed files with 104 additions and 2703 deletions

View File

@ -25,9 +25,18 @@ struct AABB
glm::vec3 max;
AABB(glm::vec3 min, glm::vec3 max) : min(min), max(max) {}
void grow( glm::vec3 p ) { min = glm::min( min, p ), max = glm::max( max, p ); }
float area()
{
glm::vec3 e = max - min;
return (e.x * e.y + e.y * e.z + e.z * e.x);
}
};
struct BVHStats {
struct BVHStats
{
int min_triangles;
int max_triangles;
float average_triangles;
@ -44,6 +53,8 @@ class BVH
void updateBounds(std::vector <GPUTriangle> &primitives);
void subdivide(std::vector<GPUTriangle> &primitives);
float evaluateSah(std::vector<GPUTriangle> &primitives, int axis, float pos);
int getSize();
int getLeaves();
BVHStats analyzeBVHLeaves(BVH* root);