From efebfaaf44c8104ececcdfddd710560b4e4108a6 Mon Sep 17 00:00:00 2001 From: hyzboy Date: Mon, 15 Jul 2019 22:36:03 +0800 Subject: [PATCH] =?UTF-8?q?=E7=8B=AC=E7=AB=8B=E6=A8=A1=E6=9D=BF=E5=87=BD?= =?UTF-8?q?=E6=95=B0hgl=5Fclamp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- inc/hgl/TypeFunc.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/inc/hgl/TypeFunc.h b/inc/hgl/TypeFunc.h index d925004b..cf4596ad 100644 --- a/inc/hgl/TypeFunc.h +++ b/inc/hgl/TypeFunc.h @@ -398,6 +398,14 @@ namespace hgl memcpy(&x,&y,sizeof(T)); memcpy(&y,&t,sizeof(T)); } + + template T hgl_clamp(const T &cur,const T &min_value,const T &max_value) + { + if(curmax_value)return max_value; + + return cur; + } template inline T hgl_abs(const T &v){return (v>=0?v:-v);}