/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* TopBVH.hpp :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: ycontre +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/01/16 21:36:19 by TheRed #+# #+# */ /* Updated: 2025/01/17 18:59:28 by ycontre ### ########.fr */ /* */ /* ************************************************************************** */ #ifndef RT_TOPBVH__HPP # define RT_TOPBVH__HPP # include "RT.hpp" struct GPUBvhData; struct GPUTopBvh; struct AABB; struct TopBVHStats { int min_bvh; int max_bvh; float average_bvh; }; class TopBVH { public: TopBVH(std::vector &bvhs_data, std::vector &bvhs, int first_bvh, int bvh_count); void updateBounds(std::vector &bvhs_data, std::vector &bvhs); void subdivide(std::vector &bvhs_data, std::vector &bvhs); float evaluateSah(std::vector &bvhs_data, std::vector &bvhs, int axis, float pos); int getSize(); int getLeaves(); std::vector getGPUTopBvhs(); void flatten(std::vector &top_bvhs, int ¤tIndex); TopBVHStats analyzeBVHLeaves(); private: AABB _aabb; TopBVH *_left; TopBVH *_right; bool _is_leaf; int _first_bvh; int _bvh_count; }; #endif