From 24285fae18139a500884facb556e20cdd54568ec Mon Sep 17 00:00:00 2001 From: kj16609 Date: Mon, 12 Aug 2024 16:40:45 -0400 Subject: [PATCH] Fixes bounding box matrix math --- src/engine/primitives/boxes/OrientedBoundingBox.hpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/engine/primitives/boxes/OrientedBoundingBox.hpp b/src/engine/primitives/boxes/OrientedBoundingBox.hpp index 594de1c..64c92a0 100644 --- a/src/engine/primitives/boxes/OrientedBoundingBox.hpp +++ b/src/engine/primitives/boxes/OrientedBoundingBox.hpp @@ -76,9 +76,14 @@ namespace fgl::engine assert( bounding_box.scale != glm::vec3( 0.0f ) ); const Coordinate< EvolvedType< MType >() > new_middle { matrix * bounding_box.middle }; - const glm::vec3 new_scale { matrix * glm::vec4( bounding_box.scale, 0.0f ) }; - //TODO: Fix this stupid rot shit - const Rotation new_rot { bounding_box.rotation }; + + const glm::vec3 matrix_scale { glm::length( glm::vec3( matrix[ 0 ] ) ), + glm::length( glm::vec3( matrix[ 1 ] ) ), + glm::length( glm::vec3( matrix[ 2 ] ) ) }; + + const glm::vec3 new_scale { bounding_box.scale * matrix_scale }; + + const Rotation new_rot { glm::quat_cast( matrix.rotmat() ) * bounding_box.rotation }; return OrientedBoundingBox< EvolvedType< MType >() >( new_middle, new_scale, new_rot ); }