diff --git a/include/omath/collision/simplex.hpp b/include/omath/collision/simplex.hpp index 46d7e1e..703afb4 100644 --- a/include/omath/collision/simplex.hpp +++ b/include/omath/collision/simplex.hpp @@ -55,10 +55,11 @@ namespace omath::collision bool handle_line(Simplex& points, Vector3& direction) { - Vector3 a = points[0]; - const Vector3 b = points[1]; + const Vector3& a = points[0]; + const Vector3& b = points[1]; - Vector3 ab = b - a; + const Vector3 ab = b - a; + // ReSharper disable once CppTooWideScopeInitStatement const Vector3 ao = -a; if (ab.point_to_same_direction(ao)) @@ -74,15 +75,15 @@ namespace omath::collision bool handle_triangle(Simplex& points, Vector3& direction) { - Vector3 a = points[0]; - Vector3 b = points[1]; - Vector3 c = points[2]; + const Vector3& a = points[0]; + const Vector3& b = points[1]; + const Vector3& c = points[2]; - Vector3 ab = b - a; - Vector3 ac = c - a; - Vector3 ao = -a; + const Vector3 ab = b - a; + const Vector3 ac = c - a; + const Vector3 ao = -a; - Vector3 abc = ab.cross(ac); + const Vector3 abc = ab.cross(ac); if (abc.cross(ac).point_to_same_direction(ao)) { @@ -99,7 +100,6 @@ namespace omath::collision if (ab.cross(abc).point_to_same_direction(ao)) return handle_line(points = {a, b}, direction); - if (abc.point_to_same_direction(ao)) { direction = abc; @@ -138,7 +138,6 @@ namespace omath::collision if (adb.point_to_same_direction(ao)) return handle_triangle(simplex = {a, d, b}, direction); - return true; }