summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2024-09-26 12:35:27 -0400
committerNat Goodspeed <nat@lindenlab.com>2024-09-26 12:35:27 -0400
commitd7f6b96e36c3cadb7a2731c6417709ee9668f2d7 (patch)
treea11049d64197bd45b75010534132c7c9f917dfa6
parent6ac59d1d5e200cccd3ddaa6d1c3b0d8d116a06be (diff)
Reinstate our lerp() function, avoid "math.h" header.
For reasons that remain unclear, MSVC likes our lerp() function better than its own std::lerp() function: publishing the latter into the global namespace, instead of defining our own, produces fatal argument conversion warnings. "math.h" publishes all of <cmath> into the global namespace, which causes a GCC conflict between std::lerp() and our lerp() function. Including <cmath> instead leaves std::lerp() in the std namespace, eliminating the conflict.
-rw-r--r--indra/llmath/llinterp.h4
-rw-r--r--indra/llmath/llmath.h11
-rw-r--r--indra/newview/llcylinder.cpp2
-rw-r--r--indra/newview/llsky.cpp2
-rw-r--r--indra/newview/llsprite.cpp2
-rw-r--r--indra/newview/llworldmipmap.cpp2
6 files changed, 14 insertions, 9 deletions
diff --git a/indra/llmath/llinterp.h b/indra/llmath/llinterp.h
index f4faa82a82..386679ffe9 100644
--- a/indra/llmath/llinterp.h
+++ b/indra/llmath/llinterp.h
@@ -29,11 +29,11 @@
#if defined(LL_WINDOWS)
// macro definitions for common math constants (e.g. M_PI) are declared under the _USE_MATH_DEFINES
// on Windows system.
-// So, let's define _USE_MATH_DEFINES before including math.h
+// So, let's define _USE_MATH_DEFINES before including cmath
#define _USE_MATH_DEFINES
#endif
-#include "math.h"
+#include <cmath>
// Class from which different types of interpolators can be derived
diff --git a/indra/llmath/llmath.h b/indra/llmath/llmath.h
index 09b685a68b..75284ef57e 100644
--- a/indra/llmath/llmath.h
+++ b/indra/llmath/llmath.h
@@ -358,9 +358,14 @@ inline F32 snap_to_sig_figs(F32 foo, S32 sig_figs)
return new_foo;
}
-// We used to define a simple lerp(F32, F32, F32) that probably predated
-// std::lerp(). By now, do we need our own definition any longer?
-using std::lerp;
+// Even though there's now a std::lerp() function that appears to do the same
+// as this function, for some reason MSVC likes this one better. Publishing
+// std::lerp() into the global namespace instead of defining this function
+// results in fatal argument conversion warnings.
+inline F32 lerp(F32 a, F32 b, F32 u)
+{
+ return a + ((b - a) * u);
+}
inline F32 lerp2d(F32 x00, F32 x01, F32 x10, F32 x11, F32 u, F32 v)
{
diff --git a/indra/newview/llcylinder.cpp b/indra/newview/llcylinder.cpp
index c347d3e1be..d5f1e25151 100644
--- a/indra/newview/llcylinder.cpp
+++ b/indra/newview/llcylinder.cpp
@@ -29,7 +29,7 @@
#include "llcylinder.h"
#include "llerror.h"
-#include "math.h"
+#include <cmath>
#include "llmath.h"
#include "noise.h"
#include "v3math.h"
diff --git a/indra/newview/llsky.cpp b/indra/newview/llsky.cpp
index 82caa14433..66fbe0029a 100644
--- a/indra/newview/llsky.cpp
+++ b/indra/newview/llsky.cpp
@@ -39,7 +39,7 @@
// linden library includes
#include "llerror.h"
#include "llmath.h"
-#include "math.h"
+#include <cmath>
#include "v4color.h"
#include "llviewerobjectlist.h"
diff --git a/indra/newview/llsprite.cpp b/indra/newview/llsprite.cpp
index e51aeb6080..09c57eaf1d 100644
--- a/indra/newview/llsprite.cpp
+++ b/indra/newview/llsprite.cpp
@@ -37,7 +37,7 @@
#include "llsprite.h"
-#include "math.h"
+#include <cmath>
#include "lldrawable.h"
#include "llface.h"
diff --git a/indra/newview/llworldmipmap.cpp b/indra/newview/llworldmipmap.cpp
index d8ea2b884f..d198f7a33b 100644
--- a/indra/newview/llworldmipmap.cpp
+++ b/indra/newview/llworldmipmap.cpp
@@ -30,7 +30,7 @@
#include "llviewercontrol.h" // LLControlGroup
#include "llviewertexturelist.h"
-#include "math.h" // log()
+#include <cmath> // log()
// Turn this on to output tile stats in the standard output
#define DEBUG_TILES_STAT 0