ncannasse 12 лет назад
Родитель
Сommit
ffc67cbb24
1 измененных файлов с 8 добавлено и 0 удалено
  1. 8 0
      h3d/FMath.hx

+ 8 - 0
h3d/FMath.hx

@@ -23,6 +23,10 @@ class FMath {
 		return Math.floor(v * exp + .49999) * neg / exp;
 	}
 	
+	public static inline function clamp( f : Float, min = 0., max = 1. ) {
+		return f < min ? min : f > max ? max : f;
+	}
+	
 	public static inline function cos( f : Float ) {
 		return Math.cos(f);
 	}
@@ -66,5 +70,9 @@ class FMath {
 	public static inline function imin( a : Int, b : Int ) {
 		return a > b ? b : a;
 	}
+
+	public static inline function iclamp( v : Int, min : Int, max : Int ) {
+		return v < min ? min : (v > max ? max : v);
+	}
 	
 }