From 36ce28a7557c4b2b73316621471558354024ca54 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Thu, 1 May 2008 21:08:40 +0000 Subject: roll control --- src/math/functions.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/math') diff --git a/src/math/functions.h b/src/math/functions.h index d9f78df..b44a4e5 100644 --- a/src/math/functions.h +++ b/src/math/functions.h @@ -49,6 +49,12 @@ float degrees180f(float angle); /// return an angle in the [0,360[ range float degrees360f(float angle); +/// clamp a float to a specified range +inline void clamp(float &value, float min=0.0f, float max=1.0f) +{ + if (value < min) value = min; else if (value > max) value = max; +} + } // namespace math #endif // __INCLUDED_MATH_FUNCTIONS_H__ -- cgit v1.2.3