[PATCH] d3dx9: Check the square instead of the square root in D3DXSphereBoundProbe
Alex Henrie
alexhenrie24 at gmail.com
Wed Jul 8 02:07:06 CDT 2020
Signed-off-by: Alex Henrie <alexhenrie24 at gmail.com>
---
As far as I can tell, there is no need to call an expensive math
function here. In my tests, replacing the square root with a simple
multiplication on the other side of the equation reduces the time spent
in D3DXSphereBoundProbe by about 6% when the condition must be
evaluated.
---
dlls/d3dx9_36/mesh.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/d3dx9_36/mesh.c b/dlls/d3dx9_36/mesh.c
index 5e0bb98efc..65c5ead7ba 100644
--- a/dlls/d3dx9_36/mesh.c
+++ b/dlls/d3dx9_36/mesh.c
@@ -2421,7 +2421,7 @@ BOOL WINAPI D3DXSphereBoundProbe(const D3DXVECTOR3 *pcenter, float radius,
c = D3DXVec3LengthSq(&difference) - radius * radius;
d = b * b - a * c;
- if ( ( d <= 0.0f ) || ( sqrt(d) <= b ) ) return FALSE;
+ if ( ( d <= 0.0f ) || ( d <= b * b ) ) return FALSE;
return TRUE;
}
--
2.27.0
More information about the wine-devel
mailing list