[PATCH] d3dx9: Implement D3DXPlaneTransformArray.

Philip Nilsson pnilsson at nullref.se
Thu Jul 24 11:46:46 CDT 2008


---
 dlls/d3dx9_36/d3dx9_36.spec |    2 +-
 dlls/d3dx9_36/math.c        |   18 ++++++++++++++++++
 dlls/d3dx9_36/tests/math.c  |   29 +++++++++++++++++++++++++++--
 include/d3dx9math.h         |    1 +
 4 files changed, 47 insertions(+), 3 deletions(-)

diff --git a/dlls/d3dx9_36/d3dx9_36.spec b/dlls/d3dx9_36/d3dx9_36.spec
index 9629dc0..c615a6a 100644
--- a/dlls/d3dx9_36/d3dx9_36.spec
+++ b/dlls/d3dx9_36/d3dx9_36.spec
@@ -235,7 +235,7 @@
 @ stdcall D3DXPlaneIntersectLine(ptr ptr ptr ptr) d3dx8.D3DXPlaneIntersectLine
 @ stdcall D3DXPlaneNormalize(ptr ptr) d3dx8.D3DXPlaneNormalize
 @ stdcall D3DXPlaneTransform(ptr ptr ptr) d3dx8.D3DXPlaneTransform
-@ stub D3DXPlaneTransformArray
+@ stdcall D3DXPlaneTransformArray(ptr long ptr long ptr long)
 @ stub D3DXPreprocessShader
 @ stub D3DXPreprocessShaderFromFileA
 @ stub D3DXPreprocessShaderFromFileW
diff --git a/dlls/d3dx9_36/math.c b/dlls/d3dx9_36/math.c
index 3a95951..7da5bb7 100644
--- a/dlls/d3dx9_36/math.c
+++ b/dlls/d3dx9_36/math.c
@@ -27,6 +27,24 @@
 WINE_DEFAULT_DEBUG_CHANNEL(d3dx);
 
 /*************************************************************************
+ * D3DXPlaneTransformArray
+ */
+D3DXPLANE* WINAPI D3DXPlaneTransformArray(
+    D3DXPLANE* out, UINT outstride, CONST D3DXPLANE* in, UINT instride,
+    CONST D3DXMATRIX* matrix, UINT elements)
+{
+    unsigned int i;
+    TRACE("\n");
+    for (i = 0; i < elements; ++i) {
+        D3DXPlaneTransform(
+            (D3DXPLANE*)((char*)out + outstride * i),
+            (CONST D3DXPLANE*)((const char*)in + instride * i),
+            matrix);
+    }
+    return out;
+}
+
+/*************************************************************************
  * D3DXVec2TransformArray
  *
  * Transform an array of vectors by a matrix.
diff --git a/dlls/d3dx9_36/tests/math.c b/dlls/d3dx9_36/tests/math.c
index 8c760ed..511fc3b 100644
--- a/dlls/d3dx9_36/tests/math.c
+++ b/dlls/d3dx9_36/tests/math.c
@@ -34,6 +34,17 @@
             exp[i].x, exp[i].y, exp[i].z, exp[i].w, \
             i); \
     }
+#define compare_planes(exp, out) \
+    for (i = 0; i < ARRAY_SIZE + 2; ++i) { \
+        ok(relative_error(exp[i].a, out[i].a) < admitted_error && \
+           relative_error(exp[i].b, out[i].b) < admitted_error && \
+           relative_error(exp[i].c, out[i].c) < admitted_error && \
+           relative_error(exp[i].d, out[i].d) < admitted_error, \
+            "Got (%f, %f, %f, %f), expected (%f, %f, %f, %f) for index %d.\n", \
+            out[i].a, out[i].b, out[i].c, out[i].d, \
+            exp[i].a, exp[i].b, exp[i].c, exp[i].d, \
+            i); \
+    }
 
 /* The mathematical properties are checked in the d3dx8 testsuite.
  *
@@ -56,6 +67,9 @@ static void test_D3DXVec_Array(void)
     D3DXVECTOR4 inp_vec[ARRAY_SIZE];
     D3DXVECTOR4 out_vec[ARRAY_SIZE + 2];
     D3DXVECTOR4 exp_vec[ARRAY_SIZE + 2];
+    D3DXPLANE inp_plane[ARRAY_SIZE];
+    D3DXPLANE out_plane[ARRAY_SIZE + 2];
+    D3DXPLANE exp_plane[ARRAY_SIZE + 2];
 
     viewport.Width = 800; viewport.MinZ = 0.2f; viewport.X = 10;
     viewport.Height = 680; viewport.MaxZ = 0.9f; viewport.Y = 5;
@@ -63,11 +77,13 @@ static void test_D3DXVec_Array(void)
     for (i = 0; i < ARRAY_SIZE + 2; ++i) {
         out_vec[i].x = out_vec[i].y = out_vec[i].z = out_vec[i].w = 0.0f;
         exp_vec[i].x = exp_vec[i].y = exp_vec[i].z = exp_vec[i].w = 0.0f;
+        out_plane[i].a = out_plane[i].b = out_plane[i].c = out_plane[i].d = 0.0f;
+        exp_plane[i].a = exp_plane[i].b = exp_plane[i].c = exp_plane[i].d = 0.0f;
     }
 
     for (i = 0; i < ARRAY_SIZE; ++i) {
-        inp_vec[i].x = inp_vec[i].z = i;
-        inp_vec[i].y = inp_vec[i].w = ARRAY_SIZE - i;
+        inp_plane[i].a = inp_plane[i].c = inp_vec[i].x = inp_vec[i].z = i;
+        inp_plane[i].b = inp_plane[i].d = inp_vec[i].y = inp_vec[i].w = ARRAY_SIZE - i;
     }
 
     U(mat).m[0][0] = 1.0f; U(mat).m[0][1] = 2.0f; U(mat).m[0][2] = 3.0f; U(mat).m[0][3] = 4.0f;
@@ -169,6 +185,15 @@ static void test_D3DXVec_Array(void)
     exp_vec[5].x = 58.0f; exp_vec[5].y = 68.0f;  exp_vec[5].z = 78.0f;  exp_vec[5].w = 88.0f;
     D3DXVec4TransformArray(out_vec + 1, sizeof(D3DXVECTOR4), inp_vec, sizeof(D3DXVECTOR4), &mat, ARRAY_SIZE);
     compare_vectors(exp_vec, out_vec);
+
+    /* D3DXPlaneTransformArray */
+    exp_plane[1].a = 90.0f; exp_plane[1].b = 100.0f; exp_plane[1].c = 110.0f; exp_plane[1].d = 120.0f;
+    exp_plane[2].a = 82.0f; exp_plane[2].b = 92.0f;  exp_plane[2].c = 102.0f; exp_plane[2].d = 112.0f;
+    exp_plane[3].a = 74.0f; exp_plane[3].b = 84.0f;  exp_plane[3].c = 94.0f;  exp_plane[3].d = 104.0f;
+    exp_plane[4].a = 66.0f; exp_plane[4].b = 76.0f;  exp_plane[4].c = 86.0f;  exp_plane[4].d = 96.0f;
+    exp_plane[5].a = 58.0f; exp_plane[5].b = 68.0f;  exp_plane[5].c = 78.0f;  exp_plane[5].d = 88.0f;
+    D3DXPlaneTransformArray(out_plane + 1, sizeof(D3DXPLANE), inp_plane, sizeof(D3DXPLANE), &mat, ARRAY_SIZE);
+    compare_planes(exp_plane, out_plane);
 }
 
 START_TEST(math)
diff --git a/include/d3dx9math.h b/include/d3dx9math.h
index 63f2be7..9801504 100644
--- a/include/d3dx9math.h
+++ b/include/d3dx9math.h
@@ -302,6 +302,7 @@ D3DXPLANE* WINAPI D3DXPlaneFromPoints(D3DXPLANE *pout, CONST D3DXVECTOR3 *pv1, C
 D3DXVECTOR3* WINAPI D3DXPlaneIntersectLine(D3DXVECTOR3 *pout, CONST D3DXPLANE *pp, CONST D3DXVECTOR3 *pv1, CONST D3DXVECTOR3 *pv2);
 D3DXPLANE* WINAPI D3DXPlaneNormalize(D3DXPLANE *pout, CONST D3DXPLANE *pp);
 D3DXPLANE* WINAPI D3DXPlaneTransform(D3DXPLANE *pout, CONST D3DXPLANE *pplane, CONST D3DXMATRIX *pm);
+D3DXPLANE* WINAPI D3DXPlaneTransformArray(D3DXPLANE *pout, UINT outstride, CONST D3DXPLANE *pplane, UINT pstride, CONST D3DXMATRIX *pm, UINT n);
 
 D3DXQUATERNION* WINAPI D3DXQuaternionBaryCentric(D3DXQUATERNION *pout, CONST D3DXQUATERNION *pq1, CONST D3DXQUATERNION *pq2, CONST D3DXQUATERNION *pq3, FLOAT f, FLOAT g);
 D3DXQUATERNION* WINAPI D3DXQuaternionExp(D3DXQUATERNION *pout, CONST D3DXQUATERNION *pq);
-- 
1.5.6.4


--YiEDa0DAkWCtVeE4--



More information about the wine-patches mailing list