[PATCH] Implement D3DXQuaternionIdentity with a test
David Adam
David.Adam at math.cnrs.fr
Thu Oct 18 14:01:24 CDT 2007
---
dlls/d3dx8/tests/math.c | 8 ++++++++
include/d3dx8math.inl | 9 +++++++++
2 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/dlls/d3dx8/tests/math.c b/dlls/d3dx8/tests/math.c
index 10a2ad8..0d826c6 100644
--- a/dlls/d3dx8/tests/math.c
+++ b/dlls/d3dx8/tests/math.c
@@ -62,6 +62,14 @@ static void D3X8QuaternionTest(void)
got =3D D3DXQuaternionDot(NULL,NULL);
ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", =
expected, got);
=20
+/*_______________D3DXQuaternionIdentity________________*/
+ expectedquat.x =3D 0.0f; expectedquat.y =3D 0.0f; expectedquat.z =3D 0.=
0f; expectedquat.w =3D 1.0f;
+ D3DXQuaternionIdentity(&gotquat);
+ expect_vec4(expectedquat,gotquat);
+ /* Test the NULL case */
+ funcpointer =3D D3DXQuaternionIdentity(NULL);
+ ok(funcpointer =3D=3D NULL, "Expected: %p, Got: %p\n", NULL, funcpointe=
r);
+
/*_______________D3DXQuaternionLength__________________________*/
expected =3D 11.0f;
got =3D D3DXQuaternionLength(&q);
diff --git a/include/d3dx8math.inl b/include/d3dx8math.inl
index 95590cf..0380cdf 100644
--- a/include/d3dx8math.inl
+++ b/include/d3dx8math.inl
@@ -274,6 +274,16 @@ static inline FLOAT D3DXQuaternionDot(CONST D3DXQUATERN=
ION *pq1, CONST D3DXQUATE
return (pq1->x) * (pq2->x) + (pq1->y) * (pq2->y) + (pq1->z) * (pq2->z) =
+ (pq1->w) * (pq2->w);
}
=20
+static inline D3DXQUATERNION* D3DXQuaternionIdentity(D3DXQUATERNION *pout)
+{
+ if ( !pout) return NULL;
+ pout->x =3D 0.0f;
+ pout->y =3D 0.0f;
+ pout->z =3D 0.0f;
+ pout->w =3D 1.0f;
+ return pout;
+}
+
static inline FLOAT D3DXQuaternionLength(CONST D3DXQUATERNION *pq)
{
if (!pq) return 0.0f;
--=20
1.5.3.2
--=_4m3ejggb11k4--
More information about the wine-patches
mailing list