[PATCH] Implement D3DXPlaneTransform with a test

David Adam David.Adam at math.cnrs.fr
Mon Nov 19 08:05:50 CST 2007


---
 dlls/d3dx8/d3dx8.spec   |    2 +-
 dlls/d3dx8/math.c       |    9 +++++++++
 dlls/d3dx8/tests/math.c |   14 ++++++++++++++
 include/d3dx8math.h     |    1 +
 4 files changed, 25 insertions(+), 1 deletions(-)

diff --git a/dlls/d3dx8/d3dx8.spec b/dlls/d3dx8/d3dx8.spec
index 4dd230b..3a27e1a 100644
--- a/dlls/d3dx8/d3dx8.spec
+++ b/dlls/d3dx8/d3dx8.spec
@@ -65,7 +65,7 @@
 @ stdcall D3DXPlaneIntersectLine(ptr ptr ptr ptr)
 @ stdcall D3DXPlaneFromPointNormal(ptr ptr ptr)
 @ stdcall D3DXPlaneFromPoints(ptr ptr ptr ptr)
-@ stub D3DXPlaneTransform
+@ stdcall D3DXPlaneTransform(ptr ptr ptr)
 @ stub D3DXColorAdjustSaturation
 @ stub D3DXColorAdjustContrast
 @ stub D3DXCreateMatrixStack
diff --git a/dlls/d3dx8/math.c b/dlls/d3dx8/math.c
index 0727492..6372271 100644
--- a/dlls/d3dx8/math.c
+++ b/dlls/d3dx8/math.c
@@ -547,6 +547,15 @@ D3DXPLANE* WINAPI D3DXPlaneNormalize(D3DXPLANE *pout, C=
ONST D3DXPLANE *pp)
     return pout;
 }
=20
+D3DXPLANE* WINAPI D3DXPlaneTransform(D3DXPLANE *pout, CONST D3DXPLANE *ppla=
ne, CONST D3DXMATRIX *pm)
+{
+     pout->a =3D pm->u.m[0][0] * pplane->a + pm->u.m[1][0] * pplane->b + pm=
->u.m[2][0] * pplane->c + pm->u.m[3][0] * pplane->d;
+     pout->b =3D pm->u.m[0][1] * pplane->a + pm->u.m[1][1] * pplane->b + pm=
->u.m[2][1] * pplane->c + pm->u.m[3][1] * pplane->d;
+     pout->c =3D pm->u.m[0][2] * pplane->a + pm->u.m[1][2] * pplane->b + pm=
->u.m[2][2] * pplane->c + pm->u.m[3][2] * pplane->d;
+     pout->d =3D pm->u.m[0][3] * pplane->a + pm->u.m[1][3] * pplane->b + pm=
->u.m[2][3] * pplane->c + pm->u.m[3][3] * pplane->d;
+    return pout;
+}
+
 /*_________________D3DXQUATERNION________________*/
=20
 D3DXQUATERNION* WINAPI D3DXQuaternionNormalize(D3DXQUATERNION *pout, CONST =
D3DXQUATERNION *pq)
diff --git a/dlls/d3dx8/tests/math.c b/dlls/d3dx8/tests/math.c
index 05b84fb..cb72b31 100644
--- a/dlls/d3dx8/tests/math.c
+++ b/dlls/d3dx8/tests/math.c
@@ -436,12 +436,21 @@ static void D3DXMatrixTest(void)
=20
 static void D3DXPlaneTest(void)
 {
+
+    D3DXMATRIX mat;
     D3DXPLANE expectedplane, gotplane, nulplane, plane;
     D3DXVECTOR3 expectedvec, gotvec, vec1, vec2, vec3;
     LPD3DXVECTOR3 funcpointer;
     D3DXVECTOR4 vec;
     FLOAT expected, got;
=20
+    U(mat).m[0][1] =3D 5.0f; U(mat).m[0][2] =3D 7.0f; U(mat).m[0][3] =3D 8.=
0f;
+    U(mat).m[1][0] =3D 11.0f; U(mat).m[1][2] =3D 16.0f; U(mat).m[1][3] =3D =
33.0f;
+    U(mat).m[2][0] =3D 19.0f; U(mat).m[2][1] =3D -21.0f; U(mat).m[2][3] =3D=
 43.0f;
+    U(mat).m[3][0] =3D 2.0f; U(mat).m[3][1] =3D 3.0f; U(mat).m[3][2] =3D -4=
.0f;
+    U(mat).m[0][0] =3D 10.0f; U(mat).m[1][1] =3D 20.0f; U(mat).m[2][2] =3D =
30.0f;
+    U(mat).m[3][3] =3D -40.0f;
+
     plane.a =3D -3.0f; plane.b =3D -1.0f; plane.c =3D 4.0f; plane.d =3D 7.0=
f;
=20
     vec.x =3D 2.0f; vec.y =3D 5.0f; vec.z =3D -6.0f; vec.w =3D 11.0f;
@@ -524,6 +533,11 @@ static void D3DXPlaneTest(void)
     expectedplane.a =3D 0.0f; expectedplane.b =3D 0.0f; expectedplane.c =3D=
 0.0f; expectedplane.d =3D 0.0f;
     D3DXPlaneNormalize(&gotplane, &nulplane);
     expect_plane(expectedplane, gotplane);
+
+/*_______________D3DXPlaneTransform____________*/
+    expectedplane.a =3D 49.0f; expectedplane.b =3D -98.0f; expectedplane.c =
=3D 55.0f; expectedplane.d =3D -165.0f;
+    D3DXPlaneTransform(&gotplane,&plane,&mat);
+    expect_plane(expectedplane, gotplane);
 }
=20
 static void D3X8QuaternionTest(void)
diff --git a/include/d3dx8math.h b/include/d3dx8math.h
index 8082876..06bc562 100644
--- a/include/d3dx8math.h
+++ b/include/d3dx8math.h
@@ -297,6 +297,7 @@ D3DXPLANE* WINAPI D3DXPlaneFromPointNormal(D3DXPLANE *po=
ut, CONST D3DXVECTOR3 *p
 D3DXPLANE* WINAPI D3DXPlaneFromPoints(D3DXPLANE *pout, CONST D3DXVECTOR3 *p=
v1, CONST D3DXVECTOR3 *pv2, CONST D3DXVECTOR3 *pv3);
 D3DXVECTOR3* WINAPI D3DXPlaneIntersectLine(D3DXVECTOR3 *pout, CONST D3DXPLA=
NE *pp, CONST D3DXVECTOR3 *pv1, CONST D3DXVECTOR3 *pv2);
 D3DXPLANE* WINAPI D3DXPlaneNormalize(D3DXPLANE *pout, CONST D3DXPLANE *pp);
+D3DXPLANE* WINAPI D3DXPlaneTransform(D3DXPLANE *pout, CONST D3DXPLANE *ppla=
ne, CONST D3DXMATRIX *pm);
=20
 D3DXQUATERNION* WINAPI D3DXQuaternionNormalize(D3DXQUATERNION *pout, CONST =
D3DXQUATERNION *pq);
=20
--=20
1.5.3.2


--=_6a2bdaih0tss--



More information about the wine-patches mailing list