David Adam : d3dx8: Implement D3DXSphereBoundProbe.

Alexandre Julliard julliard at winehq.org
Fri Jul 25 08:15:08 CDT 2008


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

Author: David Adam <david.adam.cnrs at gmail.com>
Date:   Thu Jul 24 11:31:05 2008 +0200

d3dx8: Implement D3DXSphereBoundProbe.

---

 dlls/d3dx8/Makefile.in       |    3 +-
 dlls/d3dx8/d3dx8.spec        |    2 +-
 dlls/d3dx8/mesh.c            |   39 ++++++++++++++++++++++++++++++++
 dlls/d3dx8/tests/Makefile.in |    4 ++-
 dlls/d3dx8/tests/mesh.c      |   51 ++++++++++++++++++++++++++++++++++++++++++
 include/d3dx8mesh.h          |    3 +-
 6 files changed, 98 insertions(+), 4 deletions(-)

diff --git a/dlls/d3dx8/Makefile.in b/dlls/d3dx8/Makefile.in
index 4e45b53..0f61ee2 100644
--- a/dlls/d3dx8/Makefile.in
+++ b/dlls/d3dx8/Makefile.in
@@ -9,7 +9,8 @@ IMPORTS   = dxguid uuid kernel32
 C_SRCS = \
 	d3dx8_main.c \
 	d3dxbuffer.c \
-	math.c
+	math.c \
+	mesh.c
 
 @MAKE_DLL_RULES@
 
diff --git a/dlls/d3dx8/d3dx8.spec b/dlls/d3dx8/d3dx8.spec
index 0ccfdf2..b7c8577 100644
--- a/dlls/d3dx8/d3dx8.spec
+++ b/dlls/d3dx8/d3dx8.spec
@@ -108,7 +108,7 @@
 @ stub D3DXFVFFromDeclarator
 @ stub D3DXWeldVertices
 @ stub D3DXIntersect
-@ stub D3DXSphereBoundProbe
+@ stdcall D3DXSphereBoundProbe(ptr long ptr ptr)
 @ stub D3DXBoxBoundProbe
 @ stub D3DXCreatePolygon
 @ stub D3DXCreateBox
diff --git a/dlls/d3dx8/mesh.c b/dlls/d3dx8/mesh.c
new file mode 100644
index 0000000..db490d4
--- /dev/null
+++ b/dlls/d3dx8/mesh.c
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2008 David Adam
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include "windef.h"
+#include "wingdi.h"
+#include "d3dx8.h"
+
+#include "wine/debug.h"
+
+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;
+
+    a = D3DXVec3LengthSq(praydirection);
+    if (!D3DXVec3Subtract(&difference, prayposition, pcenter)) return FALSE;
+    b = D3DXVec3Dot(&difference, praydirection);
+    c = D3DXVec3LengthSq(&difference) - radius * radius;
+
+    if ( b * b - a * c <= 0.0f ) return FALSE;
+    return TRUE;
+}
diff --git a/dlls/d3dx8/tests/Makefile.in b/dlls/d3dx8/tests/Makefile.in
index 79dce65..8869d71 100644
--- a/dlls/d3dx8/tests/Makefile.in
+++ b/dlls/d3dx8/tests/Makefile.in
@@ -5,7 +5,9 @@ VPATH     = @srcdir@
 TESTDLL   = d3dx8.dll
 IMPORTS   = d3dx8 kernel32
 
-CTESTS = math.c
+CTESTS = \
+	math.c \
+	mesh.c
 
 @MAKE_TEST_RULES@
 
diff --git a/dlls/d3dx8/tests/mesh.c b/dlls/d3dx8/tests/mesh.c
new file mode 100644
index 0000000..8f07b07
--- /dev/null
+++ b/dlls/d3dx8/tests/mesh.c
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2008 David Adam
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include "d3dx8.h"
+
+#include "wine/test.h"
+
+static void D3DXBoundProbeTest(void)
+{
+/*____________Test the Sphere case________________________*/
+
+    BOOL result;
+    D3DXVECTOR3 center, raydirection, rayposition;
+    FLOAT radius;
+
+    radius = sqrt(77.0f);
+    center.x = 1.0f; center.y = 2.0f; center.z = 3.0f;
+    raydirection.x = 2.0f; raydirection.y = -4.0f; raydirection.z = 2.0f;
+
+    rayposition.x = 5.0f; rayposition.y = 5.0f; rayposition.z = 9.0f;
+    result = D3DXSphereBoundProbe(&center, radius, &rayposition, &raydirection);
+    ok(result == TRUE, "expected TRUE, received FALSE\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");
+
+    rayposition.x = 5.0f; rayposition.y = 11.0f; rayposition.z = 9.0f;
+    result = D3DXSphereBoundProbe(&center, radius, &rayposition, &raydirection);
+    ok(result == FALSE, "expected FALSE, received TRUE\n");
+}
+
+START_TEST(mesh)
+{
+    D3DXBoundProbeTest();
+}
diff --git a/include/d3dx8mesh.h b/include/d3dx8mesh.h
index f1eab5c..d063f6d 100644
--- a/include/d3dx8mesh.h
+++ b/include/d3dx8mesh.h
@@ -19,7 +19,7 @@
 #ifndef __WINE_D3DX8MESH_H
 #define __WINE_D3DX8MESH_H
 
-#include <d3d8.h>
+#include <d3dx8.h>
 #include <dxfile.h>
 
 #ifdef __cplusplus
@@ -28,6 +28,7 @@ extern "C" {
 
 HRESULT WINAPI D3DXCreateBuffer(DWORD,LPD3DXBUFFER*);
 UINT    WINAPI D3DXGetFVFVertexSize(DWORD);
+BOOL    WINAPI D3DXSphereBoundProbe(CONST D3DXVECTOR3 *,FLOAT,CONST D3DXVECTOR3 *,CONST D3DXVECTOR3 *);
 
 #ifdef __cplusplus
 }




More information about the wine-cvs mailing list