From a02c1312c477344cf6688dfebe63afafef29dcbe Mon Sep 17 00:00:00 2001 From: Garux Date: Thu, 8 Mar 2018 16:57:47 +0300 Subject: [PATCH] try to increase precision of matrix transform vector operations --- libs/math/matrix.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/libs/math/matrix.h b/libs/math/matrix.h index 386104f1..56ab757c 100644 --- a/libs/math/matrix.h +++ b/libs/math/matrix.h @@ -374,9 +374,9 @@ inline void matrix4_affine_premultiply_by_matrix4( Matrix4& self, const Matrix4& template inline BasicVector3 matrix4_transformed_point( const Matrix4& self, const BasicVector3& point ){ return BasicVector3( - static_cast( self[0] * point[0] + self[4] * point[1] + self[8] * point[2] + self[12] ), - static_cast( self[1] * point[0] + self[5] * point[1] + self[9] * point[2] + self[13] ), - static_cast( self[2] * point[0] + self[6] * point[1] + self[10] * point[2] + self[14] ) + static_cast( point[0] * self[0] + point[1] * self[4] + point[2] * self[8] + self[12] ), + static_cast( point[0] * self[1] + point[1] * self[5] + point[2] * self[9] + self[13] ), + static_cast( point[0] * self[2] + point[1] * self[6] + point[2] * self[10] + self[14] ) ); } @@ -390,9 +390,9 @@ inline void matrix4_transform_point( const Matrix4& self, BasicVector3& template inline BasicVector3 matrix4_transformed_direction( const Matrix4& self, const BasicVector3& direction ){ return BasicVector3( - static_cast( self[0] * direction[0] + self[4] * direction[1] + self[8] * direction[2] ), - static_cast( self[1] * direction[0] + self[5] * direction[1] + self[9] * direction[2] ), - static_cast( self[2] * direction[0] + self[6] * direction[1] + self[10] * direction[2] ) + static_cast( direction[0] * self[0] + direction[1] * self[4] + direction[2] * self[8] ), + static_cast( direction[0] * self[1] + direction[1] * self[5] + direction[2] * self[9] ), + static_cast( direction[0] * self[2] + direction[1] * self[6] + direction[2] * self[10] ) ); } @@ -406,10 +406,10 @@ inline void matrix4_transform_direction( const Matrix4& self, BasicVector3 inline BasicVector4 matrix4_transformed_vector4( const Matrix4& self, const BasicVector4& vector4 ){ return BasicVector4( - static_cast( self[0] * vector4[0] + self[4] * vector4[1] + self[8] * vector4[2] + self[12] * vector4[3] ), - static_cast( self[1] * vector4[0] + self[5] * vector4[1] + self[9] * vector4[2] + self[13] * vector4[3] ), - static_cast( self[2] * vector4[0] + self[6] * vector4[1] + self[10] * vector4[2] + self[14] * vector4[3] ), - static_cast( self[3] * vector4[0] + self[7] * vector4[1] + self[11] * vector4[2] + self[15] * vector4[3] ) + static_cast( vector4[0] * self[0] + vector4[1] * self[4] + vector4[2] * self[8] + vector4[3] * self[12] ), + static_cast( vector4[0] * self[1] + vector4[1] * self[5] + vector4[2] * self[9] + vector4[3] * self[13] ), + static_cast( vector4[0] * self[2] + vector4[1] * self[6] + vector4[2] * self[10] + vector4[3] * self[14] ), + static_cast( vector4[0] * self[3] + vector4[1] * self[7] + vector4[2] * self[11] + vector4[3] * self[15] ) ); }