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/dlls/d3dx8/mesh.c b/dlls/d3dx8/mesh.c new file mode 100644 index 00000000000..db490d44bf5 --- /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 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 }