summaryrefslogtreecommitdiff
path: root/indra/llmath
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llmath')
-rw-r--r--indra/llmath/llinterp.h4
-rw-r--r--indra/llmath/llmath.h7
-rw-r--r--indra/llmath/llvolume.cpp22
-rw-r--r--indra/llmath/llvolumemgr.cpp1
-rw-r--r--indra/llmath/raytrace.cpp2
-rw-r--r--indra/llmath/tests/v3dmath_test.cpp13
6 files changed, 19 insertions, 30 deletions
diff --git a/indra/llmath/llinterp.h b/indra/llmath/llinterp.h
index ef6a5e638d..336539fb2e 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 fa315291a3..0348dad8fe 100644
--- a/indra/llmath/llmath.h
+++ b/indra/llmath/llmath.h
@@ -358,10 +358,7 @@ inline F32 snap_to_sig_figs(F32 foo, S32 sig_figs)
return new_foo;
}
-inline F32 lerp(F32 a, F32 b, F32 u)
-{
- return a + ((b - a) * u);
-}
+using std::lerp;
inline F32 lerp2d(F32 x00, F32 x01, F32 x10, F32 x11, F32 u, F32 v)
{
@@ -486,7 +483,7 @@ inline U32 get_next_power_two(U32 val, U32 max_power_two)
//get the gaussian value given the linear distance from axis x and guassian value o
inline F32 llgaussian(F32 x, F32 o)
{
- return 1.f/(F_SQRT_TWO_PI*o)*powf(F_E, -(x*x)/(2*o*o));
+ return 1.f/(F_SQRT_TWO_PI*o)*powf(F_E, -(x*x)/(2.f*o*o));
}
//helper function for removing outliers
diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index 700e61467b..00a56edf68 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -1294,9 +1294,9 @@ void LLPath::genNGon(const LLPathParams& params, S32 sides, F32 startOff, F32 en
c = cos(ang)*lerp(radius_start, radius_end, t);
- pt->mPos.set(0 + lerp(0,params.getShear().mV[0],s)
+ pt->mPos.set(0 + lerp(0.f,params.getShear().mV[0],s)
+ lerp(-skew ,skew, t) * 0.5f,
- c + lerp(0,params.getShear().mV[1],s),
+ c + lerp(0.f,params.getShear().mV[1],s),
s);
pt->mScale.set(hole_x * lerp(taper_x_begin, taper_x_end, t),
hole_y * lerp(taper_y_begin, taper_y_end, t),
@@ -1327,9 +1327,9 @@ void LLPath::genNGon(const LLPathParams& params, S32 sides, F32 startOff, F32 en
c = cos(ang)*lerp(radius_start, radius_end, t);
s = sin(ang)*lerp(radius_start, radius_end, t);
- pt->mPos.set(0 + lerp(0,params.getShear().mV[0],s)
+ pt->mPos.set(0 + lerp(0.f,params.getShear().mV[0],s)
+ lerp(-skew ,skew, t) * 0.5f,
- c + lerp(0,params.getShear().mV[1],s),
+ c + lerp(0.f,params.getShear().mV[1],s),
s);
pt->mScale.set(hole_x * lerp(taper_x_begin, taper_x_end, t),
@@ -1354,9 +1354,9 @@ void LLPath::genNGon(const LLPathParams& params, S32 sides, F32 startOff, F32 en
c = cos(ang)*lerp(radius_start, radius_end, t);
s = sin(ang)*lerp(radius_start, radius_end, t);
- pt->mPos.set(0 + lerp(0,params.getShear().mV[0],s)
+ pt->mPos.set(0 + lerp(0.f,params.getShear().mV[0],s)
+ lerp(-skew ,skew, t) * 0.5f,
- c + lerp(0,params.getShear().mV[1],s),
+ c + lerp(0.f,params.getShear().mV[1],s),
s);
pt->mScale.set(hole_x * lerp(taper_x_begin, taper_x_end, t),
hole_y * lerp(taper_y_begin, taper_y_end, t),
@@ -1494,8 +1494,8 @@ bool LLPath::generate(const LLPathParams& params, F32 detail, S32 split,
for (S32 i=0;i<np;i++)
{
F32 t = lerp(params.getBegin(),params.getEnd(),(F32)i * mStep);
- mPath[i].mPos.set(lerp(0,params.getShear().mV[0],t),
- lerp(0,params.getShear().mV[1],t),
+ mPath[i].mPos.set(lerp(0.f,params.getShear().mV[0],t),
+ lerp(0.f,params.getShear().mV[1],t),
t - 0.5f);
LLQuaternion quat;
quat.setQuat(lerp(F_PI * params.getTwistBegin(),F_PI * params.getTwist(),t),0,0,1);
@@ -1559,10 +1559,10 @@ bool LLPath::generate(const LLPathParams& params, F32 detail, S32 split,
{
F32 t = (F32)i * mStep;
mPath[i].mPos.set(0,
- lerp(0, -sin(F_PI*params.getTwist()*t)*0.5f,t),
+ lerp(0.f, -sin(F_PI*params.getTwist()*t)*0.5f,t),
lerp(-0.5f, cos(F_PI*params.getTwist()*t)*0.5f,t));
- mPath[i].mScale.set(lerp(1,params.getScale().mV[0],t),
- lerp(1,params.getScale().mV[1],t), 0,1);
+ mPath[i].mScale.set(lerp(1.f,params.getScale().mV[0],t),
+ lerp(1.f,params.getScale().mV[1],t), 0.f, 1.f);
mPath[i].mTexT = t;
LLQuaternion quat;
quat.setQuat(F_PI * params.getTwist() * t,1,0,0);
diff --git a/indra/llmath/llvolumemgr.cpp b/indra/llmath/llvolumemgr.cpp
index bb0c94d513..d8f649140f 100644
--- a/indra/llmath/llvolumemgr.cpp
+++ b/indra/llmath/llvolumemgr.cpp
@@ -25,6 +25,7 @@
#include "linden_common.h"
+#include "llmutex.h"
#include "llvolumemgr.h"
#include "llvolume.h"
diff --git a/indra/llmath/raytrace.cpp b/indra/llmath/raytrace.cpp
index c0b5f48f2d..465e56b6f3 100644
--- a/indra/llmath/raytrace.cpp
+++ b/indra/llmath/raytrace.cpp
@@ -26,7 +26,7 @@
#include "linden_common.h"
-#include "math.h"
+#include <cmath>
#include "v3math.h"
#include "llquaternion.h"
#include "m3math.h"
diff --git a/indra/llmath/tests/v3dmath_test.cpp b/indra/llmath/tests/v3dmath_test.cpp
index db08419012..36ad1067a2 100644
--- a/indra/llmath/tests/v3dmath_test.cpp
+++ b/indra/llmath/tests/v3dmath_test.cpp
@@ -504,14 +504,11 @@ namespace tut
template<> template<>
void v3dmath_object::test<24>()
{
-#if LL_WINDOWS && _MSC_VER < 1400
- skip("This fails on VS2003!");
-#else
F64 x = 10., y = 20., z = -15.;
F64 angle1, angle2;
LLVector3d vec3Da(x,y,z), vec3Db(x,y,z);
angle1 = angle_between(vec3Da, vec3Db);
- ensure("1:angle_between: Fail ", (0 == angle1));
+ ensure_approximately_equals_range("1:angle_between: Fail ", angle1, 0., 1.5e-8);
F64 x1 = -1., y1 = -20., z1 = -1.;
vec3Da.clearVec();
vec3Da.setVec(x1,y1,z1);
@@ -520,12 +517,6 @@ namespace tut
vec3Da.normVec();
F64 angle = vec3Db*vec3Da;
angle = acos(angle);
-#if LL_WINDOWS && _MSC_VER > 1900
- skip("This fails on VS2017!");
-#else
- ensure("2:angle_between: Fail ", (angle == angle2));
-#endif
-
-#endif
+ ensure_equals("2:angle_between: Fail ", angle, angle2);
}
}