[PATCH v2] d3dx9: Simplify math in D3DXSphereBoundProbe

A abdaandroid at gmail.com
Thu Jul 9 04:17:18 CDT 2020


On 08/07/2020 10:31, Alex Henrie wrote:
> Signed-off-by: Alex Henrie <alexhenrie24 at gmail.com>
> ---
> v2: Calculating b isn't actually necessary at all.
> ---
>   dlls/d3dx9_36/mesh.c | 7 ++-----
>   1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/dlls/d3dx9_36/mesh.c b/dlls/d3dx9_36/mesh.c
> index 5e0bb98efc..381d19a2ee 100644
> --- a/dlls/d3dx9_36/mesh.c
> +++ b/dlls/d3dx9_36/mesh.c
> @@ -2413,16 +2413,13 @@ BOOL WINAPI D3DXSphereBoundProbe(const D3DXVECTOR3 *pcenter, float radius,
>           const D3DXVECTOR3 *prayposition, const D3DXVECTOR3 *praydirection)
>   {
>       D3DXVECTOR3 difference;
> -    FLOAT a, b, c, d;
> +    FLOAT a, c;
>   
>       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;
> +    return ( a * c < 0 );
>   }
>   
>   /*************************************************************************

It doesn't make much sense to me. You're ignoring the direction of the 
ray. From what I could tell, it seems like you rearranged the right hand 
side of the "or" operator in the existing code, while ignoring the left 
hand side.

Regards,

Ariel




More information about the wine-devel mailing list