d3dx8: Implement D3DXSphereBoundProbe.

This commit is contained in:
David Adam 2008-07-24 11:31:05 +02:00 committed by Alexandre Julliard
parent fee6b384e1
commit 6629708081
6 changed files with 98 additions and 4 deletions

View File

@ -9,7 +9,8 @@ IMPORTS = dxguid uuid kernel32
C_SRCS = \ C_SRCS = \
d3dx8_main.c \ d3dx8_main.c \
d3dxbuffer.c \ d3dxbuffer.c \
math.c math.c \
mesh.c
@MAKE_DLL_RULES@ @MAKE_DLL_RULES@

View File

@ -108,7 +108,7 @@
@ stub D3DXFVFFromDeclarator @ stub D3DXFVFFromDeclarator
@ stub D3DXWeldVertices @ stub D3DXWeldVertices
@ stub D3DXIntersect @ stub D3DXIntersect
@ stub D3DXSphereBoundProbe @ stdcall D3DXSphereBoundProbe(ptr long ptr ptr)
@ stub D3DXBoxBoundProbe @ stub D3DXBoxBoundProbe
@ stub D3DXCreatePolygon @ stub D3DXCreatePolygon
@ stub D3DXCreateBox @ stub D3DXCreateBox

39
dlls/d3dx8/mesh.c Normal file
View File

@ -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;
}

View File

@ -5,7 +5,9 @@ VPATH = @srcdir@
TESTDLL = d3dx8.dll TESTDLL = d3dx8.dll
IMPORTS = d3dx8 kernel32 IMPORTS = d3dx8 kernel32
CTESTS = math.c CTESTS = \
math.c \
mesh.c
@MAKE_TEST_RULES@ @MAKE_TEST_RULES@

51
dlls/d3dx8/tests/mesh.c Normal file
View File

@ -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();
}

View File

@ -19,7 +19,7 @@
#ifndef __WINE_D3DX8MESH_H #ifndef __WINE_D3DX8MESH_H
#define __WINE_D3DX8MESH_H #define __WINE_D3DX8MESH_H
#include <d3d8.h> #include <d3dx8.h>
#include <dxfile.h> #include <dxfile.h>
#ifdef __cplusplus #ifdef __cplusplus
@ -28,6 +28,7 @@ extern "C" {
HRESULT WINAPI D3DXCreateBuffer(DWORD,LPD3DXBUFFER*); HRESULT WINAPI D3DXCreateBuffer(DWORD,LPD3DXBUFFER*);
UINT WINAPI D3DXGetFVFVertexSize(DWORD); UINT WINAPI D3DXGetFVFVertexSize(DWORD);
BOOL WINAPI D3DXSphereBoundProbe(CONST D3DXVECTOR3 *,FLOAT,CONST D3DXVECTOR3 *,CONST D3DXVECTOR3 *);
#ifdef __cplusplus #ifdef __cplusplus
} }