change GPUBvh struct to have only one index

This commit is contained in:
2025-01-25 15:19:53 +01:00
parent 6378ed0737
commit e1e53b99fe
5 changed files with 21 additions and 32 deletions

View File

@ -6,7 +6,7 @@
/* By: ycontre <ycontre@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/01/16 21:48:48 by TheRed #+# #+# */
/* Updated: 2025/01/24 19:36:07 by ycontre ### ########.fr */
/* Updated: 2025/01/25 14:25:57 by tomoron ### ########.fr */
/* */
/* ************************************************************************** */
@ -146,7 +146,7 @@ GPUBvh BVH::toGPUBvh()
{
GPUBvh bvh;
bvh.first_primitive = _first_primitive;
bvh.index = _first_primitive;
bvh.primitive_count = _primitive_count;
bvh.max = _aabb.max;
bvh.min = _aabb.min;
@ -159,15 +159,11 @@ void BVH::flatten(std::vector<GPUBvh> &bvhs, int &currentIndex)
GPUBvh self_bvh = toGPUBvh();
int self_index = currentIndex++;
self_bvh.left_index = -1;
self_bvh.right_index = -1;
if (!_is_leaf)
{
self_bvh.left_index = currentIndex;
_left->flatten(bvhs, currentIndex);
self_bvh.right_index = currentIndex;
self_bvh.index = currentIndex;
_right->flatten(bvhs, currentIndex);
}
@ -244,4 +240,4 @@ BVHStats BVH::analyzeBVHLeaves(BVH *root)
right.average_triangles * right_leaf_count) / total_leaf_count;
return {min_count, max_count, avg_count};
}
}