[PATCH] Implement D3DXPlaneDot with a test

David Adam David.Adam at math.cnrs.fr
Tue Oct 23 03:58:41 CDT 2007


---
 dlls/d3dx8/tests/math.c |   22 ++++++++++++++++++++++
 include/d3dx8math.inl   |    8 ++++++++
 2 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/dlls/d3dx8/tests/math.c b/dlls/d3dx8/tests/math.c
index c5d731b..2d5bdbb 100644
--- a/dlls/d3dx8/tests/math.c
+++ b/dlls/d3dx8/tests/math.c
@@ -30,6 +30,27 @@
=20
 #define expect_vec4(expectedvec,gotvec) ok((fabs(expectedvec.x-gotvec.x)<ad=
mitted_error)&&(fabs(expectedvec.y-gotvec.y)<admitted_error)&&(fabs(expected=
vec.z-gotvec.z)<admitted_error)&&(fabs(expectedvec.w-gotvec.w)<admitted_erro=
r),"Expected Vector=3D (%f, %f, %f, %f)\n , Got Vector=3D (%f, %f, %f, %f)\n=
", expectedvec.x, expectedvec.y, expectedvec.z, expectedvec.w, gotvec.x, got=
vec.y, gotvec.z, gotvec.w);
=20
+static void D3DXPlaneTest(void)
+{
+    D3DXPLANE plane;
+    D3DXVECTOR4 vec;
+    FLOAT expected, got;
+
+    plane.a =3D -3.0f; plane.b =3D -1.0f; plane.c =3D 4.0f; plane.d =3D 7.0=
f;
+    vec.x =3D 2.0f; vec.y =3D 5.0f; vec.z =3D -6.0f; vec.w =3D 11.0f;
+
+/*_______________D3DXPlaneDot________________*/
+    expected =3D 42.0f;
+    got =3D D3DXPlaneDot(&plane,&vec),
+    ok( expected =3D=3D got, "Expected : %f, Got : %f\n",expected, got);
+    expected =3D 0.0f;
+    got =3D D3DXPlaneDot(NULL,&vec),
+    ok( expected =3D=3D got, "Expected : %f, Got : %f\n",expected, got);
+    expected =3D 0.0f;
+    got =3D D3DXPlaneDot(NULL,NULL),
+    ok( expected =3D=3D got, "Expected : %f, Got : %f\n",expected, got);
+}
+
 static void D3X8QuaternionTest(void)
 {
     D3DXQUATERNION expectedquat, gotquat, q, r, s;
@@ -430,6 +451,7 @@ static void D3X8Vector4Test(void)
=20
 START_TEST(math)
 {
+    D3DXPlaneTest();
     D3X8QuaternionTest();
     D3X8Vector2Test();
     D3X8Vector3Test();
diff --git a/include/d3dx8math.inl b/include/d3dx8math.inl
index 066dce2..78146ec 100644
--- a/include/d3dx8math.inl
+++ b/include/d3dx8math.inl
@@ -258,6 +258,14 @@ static inline D3DXVECTOR4* D3DXVec4Subtract(D3DXVECTOR4=
 *pout, CONST D3DXVECTOR4
=20
 /*__________________D3DXQUATERNION____________________*/
=20
+static inline FLOAT D3DXPlaneDot( CONST D3DXPLANE *pp, CONST D3DXVECTOR4 *p=
v)
+{
+    if ( !pp || !pv ) return 0.0f;
+    return ( (pp->a) * (pv->x) + (pp->b) * (pv->y) + (pp->c) * (pv->z) + (p=
p->d) * (pv->w) );
+}
+
+/*__________________D3DXQUATERNION____________________*/
+
 static inline D3DXQUATERNION* D3DXQuaternionConjugate(D3DXQUATERNION *pout,=
 CONST D3DXQUATERNION *pq)
 {
     if ( !pout || !pq) return NULL;
--=20
1.5.3.2


--=_6fqhba0dsf8k--



More information about the wine-patches mailing list