Signed-off-by: Alex Henrie alexhenrie24@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 ); }
/*************************************************************************
On 08/07/2020 10:31, Alex Henrie wrote:
Signed-off-by: Alex Henrie alexhenrie24@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
On Thu, Jul 9, 2020 at 11:17 AM A abdaandroid@gmail.com wrote:
On 08/07/2020 10:31, Alex Henrie wrote:
Signed-off-by: Alex Henrie alexhenrie24@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
True. I'm not sure that the original code made much sense either (e.g. not normalizing the ray direction vector seems suspicious)... I'm going to have a proper look at this.