From 435cf0a5fe6183cbf232dd3ebbecbb30db36de4f Mon Sep 17 00:00:00 2001 From: hybrid Date: Wed, 17 Oct 2007 16:24:01 +0000 Subject: [PATCH] Fix the texture matrix translation method, discovered by vitek. git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@1031 dfc29bdd-3216-0410-991c-e03cc46cb475 --- include/matrix4.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/include/matrix4.h b/include/matrix4.h index 36876568..f541d204 100644 --- a/include/matrix4.h +++ b/include/matrix4.h @@ -252,12 +252,12 @@ namespace core construct 2D Texture transformations rotate about center, scale, and transform. */ - void setTextureScale ( f32 sx, f32 sy ); + void setTextureScale( f32 sx, f32 sy ); void setTextureRotationCenter( f32 radAngle ); void setTextureScaleCenter( f32 sx, f32 sy ); - void setTextureTranslate ( f32 x, f32 y ); + void setTextureTranslate( f32 x, f32 y ); void buildTextureTransform( f32 rotateRad, const core::vector2df &rotatecenter, @@ -1531,8 +1531,8 @@ namespace core const core::vector2df &translate, const core::vector2df &scale) { - f32 c = cosf(rotateRad); - f32 s = sinf(rotateRad); + const f32 c = cosf(rotateRad); + const f32 s = sinf(rotateRad); M[0] = (T)(c * scale.X); M[1] = (T)(s * scale.Y); @@ -1560,8 +1560,8 @@ namespace core template inline void CMatrix4::setTextureRotationCenter( f32 rotateRad ) { - f32 c = cosf(rotateRad); - f32 s = sinf(rotateRad); + const f32 c = cosf(rotateRad); + const f32 s = sinf(rotateRad); M[0] = (T)c; M[1] = (T)s; M[2] = (T)(-0.5f * ( c + s) + 0.5f); @@ -1575,9 +1575,9 @@ namespace core template inline void CMatrix4::setTextureTranslate ( f32 x, f32 y ) { - M[2] = (T)x; - M[6] = (T)y; - definitelyIdentityMatrix=false; + M[8] = (T)x; + M[9] = (T)y; + definitelyIdentityMatrix = definitelyIdentityMatrix && (x==0.0f) && (y==0.0f) ; } template @@ -1595,7 +1595,7 @@ namespace core M[2] = (T)(-0.5f * sx + 0.5f); M[5] = (T)sy; M[6] = (T)(-0.5f * sy + 0.5f); - definitelyIdentityMatrix=false; + definitelyIdentityMatrix = definitelyIdentityMatrix && (sx==1.0f) && (sy==1.0f) ; } //! sets all matrix data members at once