Browse Source

Added fclamp and fsaturate.

bkaradzic 12 years ago
parent
commit
b36a26528a
1 changed files with 10 additions and 0 deletions
  1. 10 0
      examples/common/fpumath.h

+ 10 - 0
examples/common/fpumath.h

@@ -22,6 +22,16 @@ inline float fmax(float _a, float _b)
 	return _a > _b ? _a : _b;
 	return _a > _b ? _a : _b;
 }
 }
 
 
+inline float fclamp(float _a, float _min, float _max)
+{
+	return fmin(fmax(_a, _min), _max);
+}
+
+inline float fsaturate(float _a)
+{
+	return fclamp(_a, 0.0f, 1.0f);
+}
+
 inline float flerp(float _a, float _b, float _t)
 inline float flerp(float _a, float _b, float _t)
 {
 {
 	return _a + (_b - _a) * _t;
 	return _a + (_b - _a) * _t;