+ | Some opti

This commit is contained in:
RedShip
2025-01-23 19:44:55 +01:00
parent 896cd02e45
commit c050caa789
12 changed files with 39 additions and 197 deletions

View File

@ -6,7 +6,7 @@
/* By: ycontre <ycontre@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/12/23 18:30:18 by ycontre #+# #+# */
/* Updated: 2025/01/19 18:46:38 by ycontre ### ########.fr */
/* Updated: 2025/01/23 18:30:18 by ycontre ### ########.fr */
/* */
/* ************************************************************************** */
@ -89,6 +89,7 @@ struct GPUBvh
struct GPUBvhData
{
glm::mat4 transform;
glm::mat4 inv_transform;
alignas(16) glm::vec3 offset;
float scale;

View File

@ -6,7 +6,7 @@
/* By: ycontre <ycontre@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/12/23 19:12:51 by ycontre #+# #+# */
/* Updated: 2025/01/17 18:17:30 by ycontre ### ########.fr */
/* Updated: 2025/01/23 19:39:33 by ycontre ### ########.fr */
/* */
/* ************************************************************************** */
@ -42,21 +42,23 @@ class Triangle : public Object
_vertex2 = glm::vec3(x2, y2, z2);
_vertex3 = glm::vec3(x3, y3, z3);
// _vertex2 -= _position; //optimization
// _vertex3 -= _position; //optimization
_normal = glm::normalize(glm::cross(_vertex2 - _position, _vertex3 - _position)); //optimization
_centroid = (_position + _vertex2 + _vertex3) / 3.0f;
// _vertex2 -= _position; //optimization
// _vertex3 -= _position; //optimization
_mat_index = mat_index;
}
Triangle(const glm::vec3& position, const glm::vec3& vertex2, const glm::vec3& vertex3, const int mat_index)
: Object(position, mat_index), _vertex2(vertex2), _vertex3(vertex3) {
// _vertex2 -= _position; //optimization
// _vertex3 -= _position; //optimization
_normal = glm::normalize(glm::cross(_vertex2 - _position, _vertex3 - _position)); //optimization
_centroid = (_position + _vertex2 + _vertex3) / 3.0f;
// _vertex2 -= _position; //optimization
// _vertex3 -= _position; //optimization
}
const glm::vec3 &getVertex2() const { return (_vertex2); }