// // RParticleGlobalStuff.h // cocos2d_libs // // Created by 徐俊杰 on 2020/6/15. // #ifndef RParticleGlobalStuff_h #define RParticleGlobalStuff_h #include "rparticle/Macros/RParticleMacros.h" #include "rparticle/Math/FloatConversion.h" #include "base/allocator/CCAllocatorBase.h" NS_RRP_BEGIN #if ANDROID #define UNITY_LL_ALLOC(s,a) ::memalign(a, s) #define UNITY_LL_REALLOC(p,s,a) ::realloc(p, s) #define UNITY_LL_FREE(p) ::free(p) #else #define UNITY_LL_ALLOC(s,a) ::malloc(s) #define UNITY_LL_REALLOC(p,s,a) ::realloc(p, s) #define UNITY_LL_FREE(p) ::free(p) #endif void* malloc_internal(size_t size, int align); #define UNITY_MALLOC_ALIGNED(size, align) malloc_internal(size, align) #define ALLOC_TEMP_MANUAL(type,count) \ (type*)UNITY_MALLOC_ALIGNED((count) * sizeof (type), cocos2d::allocator::AllocatorBase::kDefaultAlignment) //inline float FastInvSqrt( float f ) //{ // // The Newton iteration trick used in FastestInvSqrt is a bit faster on // // Pentium4 / Windows, but lower precision. Doing two iterations is precise enough, // // but actually a bit slower. // if (fabs(f) == 0.0F) // return f; // return 1.0F / sqrtf (f); //} inline Vector2f NormalizeFast (const Vector2f& inV) { float m = SqrMagnitude (inV); // GCC version of __frsqrte: // static inline double __frsqrte (double x) { // double y; // asm ( "frsqrte %0, %1" : /*OUT*/ "=f" (y) : /*IN*/ "f" (x) ); // return y; // } return inV * FastInvSqrt (m); } //inline UInt32 FloorfToIntPos (float f) //{ // DebugAssertIf (f < 0 || f > UINT_MAX); // return (UInt32)f; //} NS_RRP_END #endif /* RParticleGlobalStuff_h */