[PATCH] Implement D3DXQuaternionIsIdentity with a test
David Adam
David.Adam at math.cnrs.fr
Thu Oct 18 16:15:18 CDT 2007
---
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 0d826c6..12a6d0a 100644
--- a/dlls/d3dx8/tests/math.c
+++ b/dlls/d3dx8/tests/math.c
@@ -32,9 +32,10 @@
=20
static void D3X8QuaternionTest(void)
{
- D3DXQUATERNION expectedquat, gotquat, q, r;
+ D3DXQUATERNION expectedquat, gotquat, q, r, s;
LPD3DXQUATERNION funcpointer;
FLOAT expected, got;
+ BOOL expectedbool, gotbool;
=20
q.x =3D 1.0f, q.y =3D 2.0f; q.z =3D 4.0f; q.w =3D 10.0f;=20
r.x =3D -3.0f; r.y =3D 4.0f; r.z =3D -5.0f; r.w =3D 7.0;
@@ -49,7 +50,6 @@ static void D3X8QuaternionTest(void)
funcpointer =3D D3DXQuaternionConjugate(NULL,NULL);
ok(funcpointer =3D=3D NULL, "Expected: %p, Got: %p\n", NULL, funcpointe=
r);
=20
-
/*_______________D3DXQuaternionDot______________________*/
expected =3D 55.0f;
got =3D D3DXQuaternionDot(&q,&r);
@@ -70,6 +70,19 @@ static void D3X8QuaternionTest(void)
funcpointer =3D D3DXQuaternionIdentity(NULL);
ok(funcpointer =3D=3D NULL, "Expected: %p, Got: %p\n", NULL, funcpointe=
r);
=20
+/*_______________D3DXQuaternionIsIdentity________________*/
+ s.x =3D 0.0f; s.y =3D 0.0f; s.z =3D 0.0f; s.w =3D 1.0f;
+ expectedbool =3D TRUE;
+ gotbool =3D D3DXQuaternionIsIdentity(&s);
+ ok( expectedbool =3D=3D gotbool, "Expected boolean : %d, Got bool : %d\=
n", expectedbool, gotbool);=20
+ s.x =3D 2.3f; s.y =3D -4.2f; s.z =3D 1.2f; s.w=3D0.2f;
+ expectedbool =3D FALSE;
+ gotbool =3D D3DXQuaternionIsIdentity(&q);
+ ok( expectedbool =3D=3D gotbool, "Expected boolean : %d, Got bool : %d\=
n", expectedbool, gotbool);=20
+ /* Test the NULL case */
+ gotbool =3D D3DXQuaternionIsIdentity(NULL);
+ ok(gotbool =3D=3D FALSE, "Expected boolean: %d, Got boolean: %d\n", FAL=
SE, gotbool);
+
/*_______________D3DXQuaternionLength__________________________*/
expected =3D 11.0f;
got =3D D3DXQuaternionLength(&q);
diff --git a/include/d3dx8math.inl b/include/d3dx8math.inl
index ee6b663..df79a37 100644
--- a/include/d3dx8math.inl
+++ b/include/d3dx8math.inl
@@ -284,6 +284,12 @@ static inline D3DXQUATERNION* D3DXQuaternionIdentity(D3=
DXQUATERNION *pout)
return pout;
}
=20
+static inline BOOL D3DXQuaternionIsIdentity(D3DXQUATERNION *pq)
+{
+ if ( !pq) return FALSE;
+ return ( (pq->x =3D=3D 0.0f) && (pq->y =3D=3D 0.0f) && (pq->z =3D=3D 0.=
0f) && (pq->w =3D=3D 1.0f) );
+}
+
static inline FLOAT D3DXQuaternionLength(CONST D3DXQUATERNION *pq)
{
if (!pq) return 0.0f;
--=20
1.5.3.2
--=_5xb4abvl8x0k--
More information about the wine-patches
mailing list