独立模板函数hgl_clamp
This commit is contained in:
parent
1460840334
commit
efebfaaf44
@ -399,6 +399,14 @@ namespace hgl
|
|||||||
memcpy(&y,&t,sizeof(T));
|
memcpy(&y,&t,sizeof(T));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T> T hgl_clamp(const T &cur,const T &min_value,const T &max_value)
|
||||||
|
{
|
||||||
|
if(cur<min_value)return min_value;
|
||||||
|
if(cur>max_value)return max_value;
|
||||||
|
|
||||||
|
return cur;
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T> inline T hgl_abs(const T &v){return (v>=0?v:-v);}
|
template<typename T> inline T hgl_abs(const T &v){return (v>=0?v:-v);}
|
||||||
|
|
||||||
template<typename T> inline T hgl_min(const T &a,const T &b){return (a>b?b:a);}
|
template<typename T> inline T hgl_min(const T &a,const T &b){return (a>b?b:a);}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user