David Adam : d3dx8: Only the points in the positive ray are taken in account in D3DXSphereBoundProbe .

Alexandre Julliard julliard at winehq.org
Tue Jul 29 07:16:39 CDT 2008


Module: wine
Branch: master
Commit: 170023e30d0b8e7e636524f22405508a8e6b1c95
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=170023e30d0b8e7e636524f22405508a8e6b1c95

Author: David Adam <david.adam.cnrs at gmail.com>
Date:   Mon Jul 28 18:32:55 2008 +0200

d3dx8: Only the points in the positive ray are taken in account in D3DXSphereBoundProbe.

---

 dlls/d3dx8/mesh.c       |    5 +++--
 dlls/d3dx8/tests/mesh.c |    4 ++++
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/dlls/d3dx8/mesh.c b/dlls/d3dx8/mesh.c
index db490d4..6846d5d 100644
--- a/dlls/d3dx8/mesh.c
+++ b/dlls/d3dx8/mesh.c
@@ -27,13 +27,14 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3dx);
 BOOL WINAPI D3DXSphereBoundProbe(CONST D3DXVECTOR3 *pcenter, FLOAT radius, CONST D3DXVECTOR3 *prayposition, CONST D3DXVECTOR3 *praydirection)
 {
     D3DXVECTOR3 difference;
-    FLOAT a, b, c;
+    FLOAT a, b, c, d;
 
     a = D3DXVec3LengthSq(praydirection);
     if (!D3DXVec3Subtract(&difference, prayposition, pcenter)) return FALSE;
     b = D3DXVec3Dot(&difference, praydirection);
     c = D3DXVec3LengthSq(&difference) - radius * radius;
+    d = b * b - a * c;
 
-    if ( b * b - a * c <= 0.0f ) return FALSE;
+    if ( ( d <= 0.0f ) || ( sqrt(d) <= b ) ) return FALSE;
     return TRUE;
 }
diff --git a/dlls/d3dx8/tests/mesh.c b/dlls/d3dx8/tests/mesh.c
index 8f07b07..5a5eb67 100644
--- a/dlls/d3dx8/tests/mesh.c
+++ b/dlls/d3dx8/tests/mesh.c
@@ -36,6 +36,10 @@ static void D3DXBoundProbeTest(void)
     result = D3DXSphereBoundProbe(&center, radius, &rayposition, &raydirection);
     ok(result == TRUE, "expected TRUE, received FALSE\n");
 
+    rayposition.x = 45.0f; rayposition.y = -75.0f; rayposition.z = 49.0f;
+    result = D3DXSphereBoundProbe(&center, radius, &rayposition, &raydirection);
+    ok(result == FALSE, "expected FALSE, received TRUE\n");
+
     rayposition.x = 5.0f; rayposition.y = 7.0f; rayposition.z = 9.0f;
     result = D3DXSphereBoundProbe(&center, radius, &rayposition, &raydirection);
     ok(result == FALSE, "expected FALSE, received TRUE\n");




More information about the wine-cvs mailing list