// // Utility.h // cocos2d_libs // // Created by 徐俊杰 on 2020/5/7. // #ifndef Utility_h #define Utility_h //#include "cocos2d.h" #include "rparticle/Macros/RParticleMacros.h" NS_RRP_BEGIN template inline T clamp (const T&t, const T& t0, const T& t1) { if (t < t0) return t0; else if (t > t1) return t1; else return t; } template <> inline float clamp (const float&t, const float& t0, const float& t1) { #if UNITY_XENON || UNITY_PS3 return FloatMin(FloatMax(t, t0), t1); #else if (t < t0) return t0; else if (t > t1) return t1; else return t; #endif } template inline T clamp01 (const T& t) { if (t < 0) return 0; else if (t > 1) return 1; else return t; } template <> inline float clamp01 (const float& t) { #if UNITY_XENON || UNITY_PS3 return FloatMin(FloatMax(t, 0.0f), 1.0f); #else if (t < 0.0F) return 0.0F; else if (t > 1.0F) return 1.0F; else return t; #endif } NS_RRP_END #endif /* Utility_h */