From 5bf308139cabf8934db795bbde8171b613e6bfb1 Mon Sep 17 00:00:00 2001 From: engineer_apple Date: Sun, 23 Feb 2020 14:15:53 +0000 Subject: [PATCH] expf throws floating point underflow exception on every value in VS2017. switch to IEEE-compatible type double exp git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6099 dfc29bdd-3216-0410-991c-e03cc46cb475 --- examples/23.SMeshHandling/main.cpp | 2 +- source/Irrlicht/CSoftwareDriver2.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/23.SMeshHandling/main.cpp b/examples/23.SMeshHandling/main.cpp index d4ce20de..a4ef9ebc 100644 --- a/examples/23.SMeshHandling/main.cpp +++ b/examples/23.SMeshHandling/main.cpp @@ -57,7 +57,7 @@ typedef f32 generate_func(s16 x, s16 y, f32 s); f32 eggbox(s16 x, s16 y, f32 s) { const f32 r = 4.f*sqrtf((f32)(x*x + y*y))/s; - const f32 z = expf(-r * 2) * (cosf(0.2f * x) + cosf(0.2f * y)); + const f32 z = (f32)exp(-r * 2) * (cosf(0.2f * x) + cosf(0.2f * y)); return 0.25f+0.25f*z; } diff --git a/source/Irrlicht/CSoftwareDriver2.cpp b/source/Irrlicht/CSoftwareDriver2.cpp index 678070f3..906b86c9 100644 --- a/source/Irrlicht/CSoftwareDriver2.cpp +++ b/source/Irrlicht/CSoftwareDriver2.cpp @@ -1607,10 +1607,10 @@ void CBurningVideoDriver::VertexCache_fill(const u32 sourceIndex, const u32 dest fog_factor = (FogEnd - EyeSpace.vertex.z) * EyeSpace.fog_scale; break; case EFT_FOG_EXP: - fog_factor = expf(-FogDensity * EyeSpace.vertex.z); + fog_factor = (f32)exp(-FogDensity * EyeSpace.vertex.z); break; case EFT_FOG_EXP2: - fog_factor = expf(-FogDensity * FogDensity * EyeSpace.vertex.z * EyeSpace.vertex.z); + fog_factor = (f32)exp(-FogDensity * FogDensity * EyeSpace.vertex.z * EyeSpace.vertex.z); break; }