mirror of
https://github.com/TheRedShip/RT_GPU.git
synced 2025-09-27 18:48:36 +02:00
+ | Starting bvh
This commit is contained in:
54
includes/RT/BVH.hpp
Normal file
54
includes/RT/BVH.hpp
Normal file
@ -0,0 +1,54 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* BVH.hpp :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: TheRed <TheRed@students.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/01/16 21:36:19 by TheRed #+# #+# */
|
||||
/* Updated: 2025/01/16 21:36:19 by TheRed ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef RT_BVH__HPP
|
||||
# define RT_BVH__HPP
|
||||
|
||||
# include "RT.hpp"
|
||||
|
||||
struct AABB
|
||||
{
|
||||
glm::vec3 min;
|
||||
glm::vec3 max;
|
||||
|
||||
AABB(glm::vec3 min, glm::vec3 max) : min(min), max(max) {}
|
||||
};
|
||||
|
||||
struct GPUObject;
|
||||
|
||||
class BVH
|
||||
{
|
||||
public:
|
||||
BVH(std::vector<GPUObject> primitives, int first_primitive, int primitive_count);
|
||||
|
||||
|
||||
void showAABB(Scene *scene);
|
||||
|
||||
void updateBounds(std::vector<GPUObject> primitives);
|
||||
void subdivide(std::vector<GPUObject> primitives);
|
||||
|
||||
const AABB &getAABB() const;
|
||||
|
||||
|
||||
private:
|
||||
AABB _aabb;
|
||||
|
||||
BVH *_left;
|
||||
BVH *_right;
|
||||
|
||||
bool _is_leaf;
|
||||
|
||||
int _first_primitive;
|
||||
int _primitive_count;
|
||||
};
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user