+ | BVH Working

This commit is contained in:
RedShip
2025-01-17 19:31:43 +01:00
parent f5482258ba
commit ce49ecb219
14 changed files with 201 additions and 152 deletions

View File

@ -3,10 +3,10 @@
/* ::: :::::::: */
/* BVH.hpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: TheRed <TheRed@students.42.fr> +#+ +:+ +#+ */
/* By: ycontre <ycontre@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/01/16 21:36:19 by TheRed #+# #+# */
/* Updated: 2025/01/16 21:36:19 by TheRed ### ########.fr */
/* Updated: 2025/01/17 18:59:28 by ycontre ### ########.fr */
/* */
/* ************************************************************************** */
@ -30,13 +30,13 @@ struct AABB
class BVH
{
public:
BVH(std::vector<GPUObject> primitives, int first_primitive, int primitive_count);
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);
void updateBounds(std::vector <GPUObject> &primitives);
void subdivide(std::vector<GPUObject> &primitives);
int size();

View File

@ -6,7 +6,7 @@
/* By: ycontre <ycontre@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/12/23 19:12:51 by ycontre #+# #+# */
/* Updated: 2025/01/13 18:43:18 by ycontre ### ########.fr */
/* Updated: 2025/01/17 18:17:30 by ycontre ### ########.fr */
/* */
/* ************************************************************************** */
@ -53,8 +53,8 @@ class Triangle : public Object
: Object(position, mat_index), _vertex2(vertex2), _vertex3(vertex3) {
// _vertex2 -= _position; //optimization
// _vertex3 -= _position; //optimization
_normal = glm::normalize(glm::cross(_vertex2, _vertex3)); //optimization
_normal = glm::normalize(glm::cross(_vertex2 - _position, _vertex3 - _position)); //optimization
}
const glm::vec3 &getVertex2() const { return (_vertex2); }