Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src/math
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-05-01 21:08:40 +0000
committerStijn Buys <ingar@osirion.org>2008-05-01 21:08:40 +0000
commit36ce28a7557c4b2b73316621471558354024ca54 (patch)
tree3aeb4502b3a4f91a54df5d25bedfd262e61d1cec /src/math
parenta22542f273de28d06ecaf2bd6fd741821e98512b (diff)
roll control
Diffstat (limited to 'src/math')
-rw-r--r--src/math/functions.h6
1 files changed, 6 insertions, 0 deletions
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__