Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/math/functions.h')
-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__