David Adam : d3dx8: Implement D3DXPlaneMatrixIsIdentity.

Alexandre Julliard julliard at winehq.org
Wed Oct 24 11:04:51 CDT 2007


Module: wine
Branch: master
Commit: 5edd2cfaa7d0be682f31d4f827523351e4ed41d6
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=5edd2cfaa7d0be682f31d4f827523351e4ed41d6

Author: David Adam <David.Adam at math.cnrs.fr>
Date:   Tue Oct 23 14:12:25 2007 +0200

d3dx8: Implement D3DXPlaneMatrixIsIdentity.

---

 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 7b80988..0e70183 100644
--- a/dlls/d3dx8/tests/math.c
+++ b/dlls/d3dx8/tests/math.c
@@ -122,6 +122,33 @@ static void D3DXColorTest(void)
     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
 }
 
+static void D3DXMatrixTest(void)
+{
+    D3DXMATRIX mat;
+    BOOL expected, got;
+
+/*____________D3DXMatrixIsIdentity______________*/
+    mat.m[0][1] = 0.0f; mat.m[0][2] = 7.0f; mat.m[0][3] = 8.0f;
+    mat.m[1][0] = 11.0f; mat.m[1][2] = 0.0f; mat.m[1][3] = 0.0f;
+    mat.m[2][0] = 0.0f; mat.m[2][1] = 0.0f; mat.m[2][3] = 0.0f;
+    mat.m[3][0] = 0.0f; mat.m[3][1] = 0.0f; mat.m[3][2] = 0.0f;
+    mat.m[0][0] = 1.0f; mat.m[1][1] = 1.0f; mat.m[2][2] = 1.0f;
+    mat.m[3][3] = 1.0f;
+    expected = FALSE;
+    got = D3DXMatrixIsIdentity(&mat);
+    ok(expected == got, "Expected : %d, Got : %d\n", expected, got);
+    D3DXMatrixIdentity(&mat);
+    expected = TRUE;
+    got = D3DXMatrixIsIdentity(&mat);
+    ok(expected == got, "Expected : %d, Got : %d\n", expected, got);
+    /* Test the NULL case */
+    expected = FALSE;
+    got = D3DXMatrixIsIdentity(NULL);
+    ok(expected == 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
 
 /*__________________D3DXMatrix____________________*/
 
-static inline D3DXMATRIX* D3DXMatrixIdentity(D3DXMATRIX *pout )
+static inline D3DXMATRIX* D3DXMatrixIdentity(D3DXMATRIX *pout)
 {
     if ( !pout ) return NULL;
     pout->m[0][1] = 0.0f;
@@ -342,6 +342,23 @@ static inline D3DXMATRIX* D3DXMatrixIdentity(D3DXMATRIX *pout )
     return pout;
 }
 
+static inline BOOL D3DXMatrixIsIdentity(D3DXMATRIX *pm)
+{
+    int i,j;
+    D3DXMATRIX testmatrix;
+    BOOL equal=TRUE;
+
+    if ( !pm ) return FALSE;
+    D3DXMatrixIdentity(&testmatrix);
+    for (i=0; i<4; i++)
+    {
+     for (j=0; j<4; j++)
+     {
+      if ( fabs(pm->m[i][j] - testmatrix.m[i][j]) > 0.0001 ) equal = FALSE;
+     }
+    }
+    return equal;
+}
 
 /*__________________D3DXPLANE____________________*/
 




More information about the wine-cvs mailing list