ParticleSystemUtils.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. //
  2. // ParticleSystemUtils.h
  3. // cocos2d_libs
  4. //
  5. // Created by 徐俊杰 on 2020/4/24.
  6. //
  7. #ifndef ParticleSystemUtils_h
  8. #define ParticleSystemUtils_h
  9. #include <random>
  10. //#include "cocos2d.h"
  11. #include "rparticle/Macros/RParticleMacros.h"
  12. #include "rparticle/Utilities/Utility.h"
  13. #include "rparticle/RParticleSystem.h"
  14. #include "rparticle/ParticleSystemCommon.h"
  15. #include "rparticle/ParticleSystemCurves.h"
  16. #include "rparticle/Math/Random/Random.h"
  17. NS_RRP_BEGIN
  18. //class Matrix4x4f;
  19. struct ParticleSystemParticles;
  20. struct ParticleSystemReadOnlyState;
  21. struct ParticleSystemState;
  22. struct ParticleSystemEmissionState;
  23. struct ParticleSystemSubEmitterData;
  24. //typedef srand Rand;
  25. //typedef rand Random01;
  26. inline float InverseLerpFast01 (const Vector2f& scaleOffset, float v)
  27. {
  28. return clamp01 (v * scaleOffset.x + scaleOffset.y);
  29. }
  30. inline float GenerateRandom(UInt32 randomIn)
  31. {
  32. Rand rand(randomIn);
  33. return Random01(rand);
  34. }
  35. inline void GenerateRandom3(Vector3f& randomOut, UInt32 randomIn)
  36. {
  37. Rand rand(randomIn);
  38. randomOut.x = Random01(rand);
  39. randomOut.y = Random01(rand);
  40. randomOut.z = Random01(rand);
  41. }
  42. inline UInt8 GenerateRandomByte (UInt32 seed)
  43. {
  44. Rand rand (seed);
  45. return Rand::GetByteFromInt (rand.Get ());
  46. }
  47. UInt32 GetGlobalRandomSeed ();
  48. void ResetGlobalRandomSeed ();
  49. Vector2f CalculateInverseLerpOffsetScale (const Vector2f& range);
  50. void KillParticle(const ParticleSystemReadOnlyState& roState, ParticleSystemState& state, ParticleSystemParticles& ps, size_t index, size_t& particleCount);
  51. void RecordEmit(ParticleSystemEmissionState& emissionState, const ParticleSystemSubEmitterData& subEmitterData, const ParticleSystemReadOnlyState& roState, ParticleSystemState& state, ParticleSystemParticles& ps, ParticleSystemSubType type, int subEmitterIndex, size_t particleIndex, float t, float dt, float length);
  52. bool GetTransformationMatrix(Matrix4x4f& output, const bool isSystemInWorld, const bool isCurveInWorld, const Matrix4x4f& localToWorld);
  53. bool GetTransformationMatrices(Matrix4x4f& output, Matrix4x4f& outputInverse, const bool isSystemInWorld, const bool isCurveInWorld, const Matrix4x4f& localToWorld);
  54. NS_RRP_END
  55. #endif /* ParticleSystemUtils_h */