/* * 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, d; a = D3DXVec3LengthSq(praydirection); if (!D3DXVec3Subtract(&difference, prayposition, pcenter)) return FALSE; b = D3DXVec3Dot(&difference, praydirection); c = D3DXVec3LengthSq(&difference) - radius * radius; d = b * b - a * c; if ( ( d <= 0.0f ) || ( sqrt(d) <= b ) ) return FALSE; return TRUE; }