changeset 153:0b2866e25bf1

Add dmClamp(value, min, max) for clamping integer values.
author Matti Hamalainen <ccr@tnsp.org>
date Sat, 06 Oct 2012 04:43:35 +0300
parents c56f85a32912
children 969cefb2f8c3
files dmlib.h
diffstat 1 files changed, 6 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/dmlib.h	Sat Oct 06 04:22:46 2012 +0300
+++ b/dmlib.h	Sat Oct 06 04:43:35 2012 +0300
@@ -219,6 +219,12 @@
 }
 
 
+static inline int dmClamp(const int v, const int min, const int max)
+{
+    return (v < min ? min : (v > max ? max : v));
+}
+
+
 static inline DMFloat dmLerpSCurve(DMLerpContext *ctx, const DMFloat step)
 {
     const DMFloat n = step / ctx->nsteps;