2008-07-24 11:31:05 +02:00
|
|
|
/*
|
|
|
|
* 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;
|
2008-07-28 18:32:55 +02:00
|
|
|
FLOAT a, b, c, d;
|
2008-07-24 11:31:05 +02:00
|
|
|
|
|
|
|
a = D3DXVec3LengthSq(praydirection);
|
|
|
|
if (!D3DXVec3Subtract(&difference, prayposition, pcenter)) return FALSE;
|
|
|
|
b = D3DXVec3Dot(&difference, praydirection);
|
|
|
|
c = D3DXVec3LengthSq(&difference) - radius * radius;
|
2008-07-28 18:32:55 +02:00
|
|
|
d = b * b - a * c;
|
2008-07-24 11:31:05 +02:00
|
|
|
|
2008-07-28 18:32:55 +02:00
|
|
|
if ( ( d <= 0.0f ) || ( sqrt(d) <= b ) ) return FALSE;
|
2008-07-24 11:31:05 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|