d3dx9: Fix D3DXPlaneNormalize on 64 bits.

Matteo Bruni matteo.mystral at gmail.com
Fri Oct 8 09:32:26 CDT 2010


This patch changes D3DXPlaneNormalize to behave as native on 64 bits,
returning infinity in the fourth plane component when the norm is 0.
If this is not appropriate, I can resend without the implementation
changes, just fixing the tests.
-------------- next part --------------
From 3be21ad5dbaec540c0438c799b9b05d364657dc4 Mon Sep 17 00:00:00 2001
From: Matteo Bruni <mbruni at codeweavers.com>
Date: Fri, 1 Oct 2010 00:18:27 +0200
Subject: d3dx9: Fix D3DXPlaneNormalize on 64 bits.

---
 dlls/d3dx9_36/math.c       |   19 +++++++++++--------
 dlls/d3dx9_36/tests/math.c |   13 ++++++++++++-
 2 files changed, 23 insertions(+), 9 deletions(-)

diff --git a/dlls/d3dx9_36/math.c b/dlls/d3dx9_36/math.c
index eb29573..8eee27c 100644
--- a/dlls/d3dx9_36/math.c
+++ b/dlls/d3dx9_36/math.c
@@ -1105,17 +1105,20 @@ D3DXPLANE* WINAPI D3DXPlaneNormalize(D3DXPLANE *pout, CONST D3DXPLANE *pp)
     norm = sqrt(pp->a * pp->a + pp->b * pp->b + pp->c * pp->c);
     if ( norm )
     {
-     out.a = pp->a / norm;
-     out.b = pp->b / norm;
-     out.c = pp->c / norm;
-     out.d = pp->d / norm;
+        out.a = pp->a / norm;
+        out.b = pp->b / norm;
+        out.c = pp->c / norm;
+        out.d = pp->d / norm;
     }
     else
     {
-     out.a = 0.0f;
-     out.b = 0.0f;
-     out.c = 0.0f;
-     out.d = 0.0f;
+        out.a = 0.0f;
+        out.b = 0.0f;
+        out.c = 0.0f;
+        if ( sizeof(DWORD_PTR) == sizeof(DWORD) || !pp->d )
+            out.d = 0.0f;
+        else
+            out.d = pp->d / norm;
     }
     *pout = out;
     return pout;
diff --git a/dlls/d3dx9_36/tests/math.c b/dlls/d3dx9_36/tests/math.c
index 6d192f9..18fe2a2 100644
--- a/dlls/d3dx9_36/tests/math.c
+++ b/dlls/d3dx9_36/tests/math.c
@@ -620,7 +620,18 @@ static void D3DXPlaneTest(void)
     nulplane.a = 0.0; nulplane.b = 0.0f, nulplane.c = 0.0f; nulplane.d = 4.3f;
     expectedplane.a = 0.0f; expectedplane.b = 0.0f; expectedplane.c = 0.0f; expectedplane.d = 0.0f;
     D3DXPlaneNormalize(&gotplane, &nulplane);
-    expect_plane(expectedplane, gotplane);
+    if (sizeof(DWORD_PTR) == sizeof(DWORD))
+    {
+        expect_plane(expectedplane, gotplane);
+    }
+    else
+    {
+        ok(expectedplane.a == gotplane.a && expectedplane.b == gotplane.b
+           && expectedplane.c == gotplane.c && isinf(gotplane.d) == 1,
+           "Expected Plane= (%f, %f, %f, +INF)\n , Got Plane= (%f, %f, %f, %f)\n",
+           expectedplane.a, expectedplane.b, expectedplane.c,
+           gotplane.a, gotplane.b, gotplane.c, gotplane.d);
+    }
 
 /*_______________D3DXPlaneTransform____________*/
     expectedplane.a = 49.0f; expectedplane.b = -98.0f; expectedplane.c = 55.0f; expectedplane.d = -165.0f;
-- 
1.7.2.2


More information about the wine-patches mailing list