[PATCH] Implement D3DXMatrixIsIdentity with a test
David Adam
David.Adam at math.cnrs.fr
Tue Oct 23 07:12:25 CDT 2007
---
dlls/d3dx8/tests/math.c | 28 ++++++++++++++++++++++++++++
include/d3dx8math.inl | 19 ++++++++++++++++++-
2 files changed, 46 insertions(+), 1 deletions(-)
diff --git a/dlls/d3dx8/tests/math.c b/dlls/d3dx8/tests/math.c
index 97d8562..d39364c 100644
--- a/dlls/d3dx8/tests/math.c
+++ b/dlls/d3dx8/tests/math.c
@@ -122,6 +122,33 @@ static void D3DXColorTest(void)
ok(funcpointer =3D=3D NULL, "Expected: %p, Got: %p\n", NULL, funcpointe=
r);
}
=20
+static void D3DXMatrixTest(void)
+{
+ D3DXMATRIX mat;
+ BOOL expected, got;
+
+/*____________D3DXMatrixIsIdentity______________*/
+ mat.m[0][1] =3D 0.0f; mat.m[0][2] =3D 7.0f; mat.m[0][3] =3D 8.0f;
+ mat.m[1][0] =3D 11.0f; mat.m[1][2] =3D 0.0f; mat.m[1][3] =3D 0.0f;
+ mat.m[2][0] =3D 0.0f; mat.m[2][1] =3D 0.0f; mat.m[2][3] =3D 0.0f;
+ mat.m[3][0] =3D 0.0f; mat.m[3][1] =3D 0.0f; mat.m[3][2] =3D 0.0f;
+ mat.m[0][0] =3D 1.0f; mat.m[1][1] =3D 1.0f; mat.m[2][2] =3D 1.0f;
+ mat.m[3][3] =3D 1.0f;
+ expected =3D FALSE;
+ got =3D D3DXMatrixIsIdentity(&mat);
+ ok(expected =3D=3D got, "Expected : %d, Got : %d\n", expected, got);
+ D3DXMatrixIdentity(&mat);
+ expected =3D TRUE;
+ got =3D D3DXMatrixIsIdentity(&mat);
+ ok(expected =3D=3D got, "Expected : %d, Got : %d\n", expected, got);
+ /* Test the NULL case */
+ expected =3D FALSE;
+ got =3D D3DXMatrixIsIdentity(NULL);
+ ok(expected =3D=3D got, "Expected : %d, Got : %d\n", expected, got);
+}
+
+
+
static void D3DXPlaneTest(void)
{
D3DXPLANE plane;
@@ -566,6 +593,7 @@ static void D3X8Vector4Test(void)
START_TEST(math)
{
D3DXColorTest();
+ D3DXMatrixTest();
D3DXPlaneTest();
D3X8QuaternionTest();
D3X8Vector2Test();
diff --git a/include/d3dx8math.inl b/include/d3dx8math.inl
index 59d0012..4df1f9e 100644
--- a/include/d3dx8math.inl
+++ b/include/d3dx8math.inl
@@ -320,7 +320,7 @@ static inline D3DXVECTOR4* D3DXVec4Subtract(D3DXVECTOR4 =
*pout, CONST D3DXVECTOR4
=20
/*__________________D3DXMatrix____________________*/
=20
-static inline D3DXMATRIX* D3DXMatrixIdentity(D3DXMATRIX *pout )
+static inline D3DXMATRIX* D3DXMatrixIdentity(D3DXMATRIX *pout)
{
if ( !pout ) return NULL;
pout->m[0][1] =3D 0.0f;
@@ -342,6 +342,23 @@ static inline D3DXMATRIX* D3DXMatrixIdentity(D3DXMATRIX=
*pout )
return pout;
}
=20
+static inline BOOL D3DXMatrixIsIdentity(D3DXMATRIX *pm)
+{
+ int i,j;
+ D3DXMATRIX testmatrix;
+ BOOL equal=3DTRUE;
+
+ if ( !pm ) return FALSE;
+ D3DXMatrixIdentity(&testmatrix);
+ for (i=3D0; i<4; i++)
+ {
+ for (j=3D0; j<4; j++)
+ {
+ if ( fabs(pm->m[i][j] - testmatrix.m[i][j]) > 0.0001 ) equal =3D FALS=
E;
+ }
+ }
+ return equal;
+}
=20
/*__________________D3DXPLANE____________________*/
=20
--=20
1.5.3.2
--=_ejpxdtn2zeo--
More information about the wine-patches
mailing list