David Adam : d3dx8: Implement D3DXQuaternionIsIdentity.

Alexandre Julliard julliard at winehq.org
Mon Oct 22 09:55:48 CDT 2007


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

Author: David Adam <David.Adam at math.cnrs.fr>
Date:   Thu Oct 18 23:15:18 2007 +0200

d3dx8: Implement D3DXQuaternionIsIdentity.

---

 dlls/d3dx8/tests/math.c |   17 +++++++++++++++--
 include/d3dx8math.inl   |    6 ++++++
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/dlls/d3dx8/tests/math.c b/dlls/d3dx8/tests/math.c
index 42898c8..c5d731b 100644
--- a/dlls/d3dx8/tests/math.c
+++ b/dlls/d3dx8/tests/math.c
@@ -32,9 +32,10 @@
 
 static void D3X8QuaternionTest(void)
 {
-    D3DXQUATERNION expectedquat, gotquat, q, r;
+    D3DXQUATERNION expectedquat, gotquat, q, r, s;
     LPD3DXQUATERNION funcpointer;
     FLOAT expected, got;
+    BOOL expectedbool, gotbool;
 
     q.x = 1.0f, q.y = 2.0f; q.z = 4.0f; q.w = 10.0f;
     r.x = -3.0f; r.y = 4.0f; r.z = -5.0f; r.w = 7.0;
@@ -49,7 +50,6 @@ static void D3X8QuaternionTest(void)
     funcpointer = D3DXQuaternionConjugate(NULL,NULL);
     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
 
-
 /*_______________D3DXQuaternionDot______________________*/
     expected = 55.0f;
     got = D3DXQuaternionDot(&q,&r);
@@ -70,6 +70,19 @@ static void D3X8QuaternionTest(void)
     funcpointer = D3DXQuaternionIdentity(NULL);
     ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer);
 
+/*_______________D3DXQuaternionIsIdentity________________*/
+    s.x = 0.0f; s.y = 0.0f; s.z = 0.0f; s.w = 1.0f;
+    expectedbool = TRUE;
+    gotbool = D3DXQuaternionIsIdentity(&s);
+    ok( expectedbool == gotbool, "Expected boolean : %d, Got bool : %d\n", expectedbool, gotbool);
+    s.x = 2.3f; s.y = -4.2f; s.z = 1.2f; s.w=0.2f;
+    expectedbool = FALSE;
+    gotbool = D3DXQuaternionIsIdentity(&q);
+    ok( expectedbool == gotbool, "Expected boolean : %d, Got bool : %d\n", expectedbool, gotbool);
+    /* Test the NULL case */
+    gotbool = D3DXQuaternionIsIdentity(NULL);
+    ok(gotbool == FALSE, "Expected boolean: %d, Got boolean: %d\n", FALSE, gotbool);
+
 /*_______________D3DXQuaternionLength__________________________*/
    expected = 11.0f;
    got = D3DXQuaternionLength(&q);
diff --git a/include/d3dx8math.inl b/include/d3dx8math.inl
index 0a4b24c..066dce2 100644
--- a/include/d3dx8math.inl
+++ b/include/d3dx8math.inl
@@ -284,6 +284,12 @@ static inline D3DXQUATERNION* D3DXQuaternionIdentity(D3DXQUATERNION *pout)
     return pout;
 }
 
+static inline BOOL D3DXQuaternionIsIdentity(D3DXQUATERNION *pq)
+{
+    if ( !pq) return FALSE;
+    return ( (pq->x == 0.0f) && (pq->y == 0.0f) && (pq->z == 0.0f) && (pq->w == 1.0f) );
+}
+
 static inline FLOAT D3DXQuaternionLength(CONST D3DXQUATERNION *pq)
 {
     if (!pq) return 0.0f;




More information about the wine-cvs mailing list