From 6629708081012fd4152beb492eb2a707b5c48dde Mon Sep 17 00:00:00 2001 From: David Adam Date: Thu, 24 Jul 2008 11:31:05 +0200 Subject: [PATCH] d3dx8: Implement D3DXSphereBoundProbe. --- dlls/d3dx8/Makefile.in | 3 +- dlls/d3dx8/d3dx8.spec | 2 +- include/d3dx8mesh.h => dlls/d3dx8/mesh.c | 31 ++++++++++--------- dlls/d3dx8/tests/Makefile.in | 4 ++- dlls/d3dx8/tests/mesh.c | 51 ++++++++++++++++++++++++++++++++ include/d3dx8mesh.h | 3 +- 6 files changed, 76 insertions(+), 18 deletions(-) copy include/d3dx8mesh.h => dlls/d3dx8/mesh.c (54%) create mode 100644 dlls/d3dx8/tests/mesh.c diff --git a/dlls/d3dx8/Makefile.in b/dlls/d3dx8/Makefile.in index 4e45b53272c..0f61ee293a3 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 0ccfdf26e55..b7c8577654a 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/include/d3dx8mesh.h b/dlls/d3dx8/mesh.c similarity index 54% copy from include/d3dx8mesh.h copy to dlls/d3dx8/mesh.c index f1eab5cd43c..db490d44bf5 100644 --- a/include/d3dx8mesh.h +++ b/dlls/d3dx8/mesh.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008 Francois Gouget + * 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 @@ -16,21 +16,24 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#ifndef __WINE_D3DX8MESH_H -#define __WINE_D3DX8MESH_H +#include "windef.h" +#include "wingdi.h" +#include "d3dx8.h" -#include -#include +#include "wine/debug.h" -#ifdef __cplusplus -extern "C" { -#endif +WINE_DEFAULT_DEBUG_CHANNEL(d3dx); -HRESULT WINAPI D3DXCreateBuffer(DWORD,LPD3DXBUFFER*); -UINT WINAPI D3DXGetFVFVertexSize(DWORD); +BOOL WINAPI D3DXSphereBoundProbe(CONST D3DXVECTOR3 *pcenter, FLOAT radius, CONST D3DXVECTOR3 *prayposition, CONST D3DXVECTOR3 *praydirection) +{ + D3DXVECTOR3 difference; + FLOAT a, b, c; -#ifdef __cplusplus -} -#endif + a = D3DXVec3LengthSq(praydirection); + if (!D3DXVec3Subtract(&difference, prayposition, pcenter)) return FALSE; + b = D3DXVec3Dot(&difference, praydirection); + c = D3DXVec3LengthSq(&difference) - radius * radius; -#endif /* __WINE_D3DX8MESH_H */ + 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 79dce65d756..8869d711d58 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 00000000000..8f07b079d8f --- /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(¢er, 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(¢er, 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(¢er, 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 f1eab5cd43c..d063f6d67af 100644 --- a/include/d3dx8mesh.h +++ b/include/d3dx8mesh.h @@ -19,7 +19,7 @@ #ifndef __WINE_D3DX8MESH_H #define __WINE_D3DX8MESH_H -#include +#include #include #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 } -- 2.11.4.GIT