summaryrefslogtreecommitdiff
path: root/indra/llmath
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llmath')
-rw-r--r--indra/llmath/llcalcparser.h6
-rw-r--r--indra/llmath/tests/mathmisc_test.cpp32
-rw-r--r--indra/llmath/v3math.h15
3 files changed, 41 insertions, 12 deletions
diff --git a/indra/llmath/llcalcparser.h b/indra/llmath/llcalcparser.h
index ea71752ebc..ec7f6a2cb6 100644
--- a/indra/llmath/llcalcparser.h
+++ b/indra/llmath/llcalcparser.h
@@ -131,14 +131,14 @@ struct LLCalcParser : grammar<LLCalcParser>
power =
unary_expr[power.value = arg1] >>
- *('^' >> assert_syntax(unary_expr[power.value = phoenix::bind(&powf)(power.value, arg1)]))
+ *('^' >> assert_syntax(unary_expr[power.value = phoenix::bind(&LLCalcParser::_pow)(self, power.value, arg1)]))
;
term =
power[term.value = arg1] >>
*(('*' >> assert_syntax(power[term.value *= arg1])) |
('/' >> assert_syntax(power[term.value /= arg1])) |
- ('%' >> assert_syntax(power[term.value = phoenix::bind(&fmodf)(term.value, arg1)]))
+ ('%' >> assert_syntax(power[term.value = phoenix::bind(&LLCalcParser::_fmod)(self, term.value, arg1)]))
)
;
@@ -177,6 +177,8 @@ private:
F32 _floor(const F32& a) const { return (F32)llfloor(a); }
F32 _ceil(const F32& a) const { return (F32)llceil(a); }
F32 _atan2(const F32& a,const F32& b) const { return atan2(a,b); }
+ F32 _pow(const F32& a, const F32& b) const { return powf(a, b); }
+ F32 _fmod(const F32&a, const F32& b) const { return fmodf(a, b); }
LLCalc::calc_map_t* mConstants;
LLCalc::calc_map_t* mVariables;
diff --git a/indra/llmath/tests/mathmisc_test.cpp b/indra/llmath/tests/mathmisc_test.cpp
index ff0899e975..2b23987616 100644
--- a/indra/llmath/tests/mathmisc_test.cpp
+++ b/indra/llmath/tests/mathmisc_test.cpp
@@ -709,14 +709,34 @@ namespace tut
first_plane,
second_plane);
- ensure("plane intersection should succeed", success);
+ try
+ {
+ ensure("plane intersection should succeed", success);
- F32 dot = fabs(known_intersection.getDirection() * measured_intersection.getDirection());
- ensure("measured intersection should be parallel to known intersection",
- dot > ALMOST_PARALLEL);
+ F32 dot = fabs(known_intersection.getDirection() * measured_intersection.getDirection());
+ ensure("measured intersection should be parallel to known intersection",
+ dot > ALMOST_PARALLEL);
- ensure("measured intersection should pass near known point",
- measured_intersection.intersects(some_point, LARGE_RADIUS * allowable_relative_error));
+ ensure("measured intersection should pass near known point",
+ measured_intersection.intersects(some_point, LARGE_RADIUS * allowable_relative_error));
+ }
+ catch (const failure&)
+ {
+ // If any of these assertions fail, since the values involved
+ // are randomly generated, unless we report them, we have no
+ // hope of diagnosing the problem.
+ LL_INFOS() << "some_point = " << some_point << '\n'
+ << "another_point = " << another_point << '\n'
+ << "known_intersection = " << known_intersection << '\n'
+ << "point_on_plane = " << point_on_plane << '\n'
+ << "plane_normal = " << plane_normal << '\n'
+ << "first_plane = " << first_plane << '\n'
+ << "point_on_different_plane = " << point_on_different_plane << '\n'
+ << "different_plane_normal = " << different_plane_normal << '\n'
+ << "second_plane = " << second_plane << '\n'
+ << "measured_intersection = " << measured_intersection << LL_ENDL;
+ throw;
+ }
}
}
}
diff --git a/indra/llmath/v3math.h b/indra/llmath/v3math.h
index d063b15c74..4fc7585a46 100644
--- a/indra/llmath/v3math.h
+++ b/indra/llmath/v3math.h
@@ -459,10 +459,17 @@ inline const LLVector3& operator*=(LLVector3 &a, const LLVector3 &b)
inline const LLVector3& operator/=(LLVector3 &a, F32 k)
{
- F32 t = 1.f / k;
- a.mV[0] *= t;
- a.mV[1] *= t;
- a.mV[2] *= t;
+ a.mV[0] /= k;
+ a.mV[1] /= k;
+ a.mV[2] /= k;
+ return a;
+}
+
+inline const LLVector3& operator/=(LLVector3& a, const LLVector3& b)
+{
+ a.mV[0] /= b.mV[0];
+ a.mV[1] /= b.mV[1];
+ a.mV[2] /= b.mV[2];
return a;
}