From 2ec8662a8348b1c44faf95007dbb10dc9f71ec0c Mon Sep 17 00:00:00 2001 From: Dander7BD Date: Mon, 20 Jan 2014 18:46:08 +0100 Subject: [PATCH] Utility::Value::Clamp --- Code/Misc/Utilities.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Code/Misc/Utilities.h b/Code/Misc/Utilities.h index 7e76dbba..9c71a515 100644 --- a/Code/Misc/Utilities.h +++ b/Code/Misc/Utilities.h @@ -327,6 +327,10 @@ namespace Utility inline ValueType Min( const ValueType &valueA, const ValueType &valueB ) { return valueA < valueB ? valueA : valueB; } + template + inline ValueType Clamp( const ValueType &value, const ValueType &min, const ValueType &max ) + { return value < min ? Max( value, max ) : min; } + template inline ValueType Average( const ValueType &valueA, const ValueType &valueB ) { return (valueA + valueB) * 0.5f; }