RParticleGlobalStuff.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. //
  2. // RParticleGlobalStuff.h
  3. // cocos2d_libs
  4. //
  5. // Created by 徐俊杰 on 2020/6/15.
  6. //
  7. #ifndef RParticleGlobalStuff_h
  8. #define RParticleGlobalStuff_h
  9. #include "rparticle/Macros/RParticleMacros.h"
  10. #include "rparticle/Math/FloatConversion.h"
  11. #include "base/allocator/CCAllocatorBase.h"
  12. NS_RRP_BEGIN
  13. #if ANDROID
  14. #define UNITY_LL_ALLOC(s,a) ::memalign(a, s)
  15. #define UNITY_LL_REALLOC(p,s,a) ::realloc(p, s)
  16. #define UNITY_LL_FREE(p) ::free(p)
  17. #else
  18. #define UNITY_LL_ALLOC(s,a) ::malloc(s)
  19. #define UNITY_LL_REALLOC(p,s,a) ::realloc(p, s)
  20. #define UNITY_LL_FREE(p) ::free(p)
  21. #endif
  22. void* malloc_internal(size_t size, int align);
  23. #define UNITY_MALLOC_ALIGNED(size, align) malloc_internal(size, align)
  24. #define ALLOC_TEMP_MANUAL(type,count) \
  25. (type*)UNITY_MALLOC_ALIGNED((count) * sizeof (type), cocos2d::allocator::AllocatorBase::kDefaultAlignment)
  26. //inline float FastInvSqrt( float f )
  27. //{
  28. // // The Newton iteration trick used in FastestInvSqrt is a bit faster on
  29. // // Pentium4 / Windows, but lower precision. Doing two iterations is precise enough,
  30. // // but actually a bit slower.
  31. // if (fabs(f) == 0.0F)
  32. // return f;
  33. // return 1.0F / sqrtf (f);
  34. //}
  35. inline Vector2f NormalizeFast (const Vector2f& inV)
  36. {
  37. float m = SqrMagnitude (inV);
  38. // GCC version of __frsqrte:
  39. // static inline double __frsqrte (double x) {
  40. // double y;
  41. // asm ( "frsqrte %0, %1" : /*OUT*/ "=f" (y) : /*IN*/ "f" (x) );
  42. // return y;
  43. // }
  44. return inV * FastInvSqrt (m);
  45. }
  46. //inline UInt32 FloorfToIntPos (float f)
  47. //{
  48. // DebugAssertIf (f < 0 || f > UINT_MAX);
  49. // return (UInt32)f;
  50. //}
  51. NS_RRP_END
  52. #endif /* RParticleGlobalStuff_h */