From 6766f9c1a02f736777c9d6d3948b0c224226f4e6 Mon Sep 17 00:00:00 2001 From: Gerald Pfeifer Date: Sun, 24 Feb 2008 16:39:08 +0100 Subject: [PATCH] d3dx8: Simplify D3DXMatrixInverse(). --- dlls/d3dx8/math.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/dlls/d3dx8/math.c b/dlls/d3dx8/math.c index 6573c684a34..a65a934bb40 100644 --- a/dlls/d3dx8/math.c +++ b/dlls/d3dx8/math.c @@ -114,7 +114,7 @@ D3DXMATRIX* WINAPI D3DXMatrixInverse(D3DXMATRIX *pout, FLOAT *pdeterminant, CONS { int a, i, j; D3DXVECTOR4 v, vec[3]; - FLOAT cofactor, det; + FLOAT det; det = D3DXMatrixfDeterminant(pm); if ( !det ) return NULL; @@ -134,19 +134,12 @@ D3DXMATRIX* WINAPI D3DXMatrixInverse(D3DXMATRIX *pout, FLOAT *pdeterminant, CONS } } D3DXVec4Cross(&v, &vec[0], &vec[1], &vec[2]); - for (j=0; j<4; j++) - { - switch(j) - { - case 0: cofactor = v.x; break; - case 1: cofactor = v.y; break; - case 2: cofactor = v.z; break; - case 3: cofactor = v.w; break; - } - pout->u.m[j][i] = pow(-1.0f, i) * cofactor / det; - } + pout->u.m[0][i] = pow(-1.0f, i) * v.x / det; + pout->u.m[1][i] = pow(-1.0f, i) * v.y / det; + pout->u.m[2][i] = pow(-1.0f, i) * v.z / det; + pout->u.m[3][i] = pow(-1.0f, i) * v.w / det; } - return pout; + return pout; } D3DXMATRIX* WINAPI D3DXMatrixLookAtLH(D3DXMATRIX *pout, CONST D3DXVECTOR3 *peye, CONST D3DXVECTOR3 *pat, CONST D3DXVECTOR3 *pup)