Simplify dlls/d3dx8/math.c a tad
Gerald Pfeifer
gerald at pfeifer.com
Sun Feb 24 09:39:08 CST 2008
I originally noticed this looking at a (bogus) compiler warning, and
believe the new version is user to understand for human reads and it
certainly is for the compiler (and indeed the new .o file is a bit
smaller).
Gerald
ChangeLog:
Simplify D3DXMatrixInverse().
Index: dlls/d3dx8/math.c
===================================================================
RCS file: /home/wine/wine/dlls/d3dx8/math.c,v
retrieving revision 1.63
diff -u -3 -p -r1.63 math.c
--- dlls/d3dx8/math.c 5 Feb 2008 12:38:24 -0000 1.63
+++ dlls/d3dx8/math.c 24 Feb 2008 15:36:40 -0000
@@ -114,7 +114,7 @@ D3DXMATRIX* WINAPI D3DXMatrixInverse(D3D
{
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(D3D
}
}
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)
More information about the wine-patches
mailing list