12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- //
- // ParticleSystemUtils.h
- // cocos2d_libs
- //
- // Created by 徐俊杰 on 2020/4/24.
- //
- #ifndef ParticleSystemUtils_h
- #define ParticleSystemUtils_h
- #include <random>
- //#include "cocos2d.h"
- #include "rparticle/Macros/RParticleMacros.h"
- #include "rparticle/Utilities/Utility.h"
- #include "rparticle/RParticleSystem.h"
- #include "rparticle/ParticleSystemCommon.h"
- #include "rparticle/ParticleSystemCurves.h"
- #include "rparticle/Math/Random/Random.h"
- NS_RRP_BEGIN
- //class Matrix4x4f;
- struct ParticleSystemParticles;
- struct ParticleSystemReadOnlyState;
- struct ParticleSystemState;
- struct ParticleSystemEmissionState;
- struct ParticleSystemSubEmitterData;
- //typedef srand Rand;
- //typedef rand Random01;
- inline float InverseLerpFast01 (const Vector2f& scaleOffset, float v)
- {
- return clamp01 (v * scaleOffset.x + scaleOffset.y);
- }
- inline float GenerateRandom(UInt32 randomIn)
- {
- Rand rand(randomIn);
- return Random01(rand);
- }
- inline void GenerateRandom3(Vector3f& randomOut, UInt32 randomIn)
- {
- Rand rand(randomIn);
- randomOut.x = Random01(rand);
- randomOut.y = Random01(rand);
- randomOut.z = Random01(rand);
- }
- inline UInt8 GenerateRandomByte (UInt32 seed)
- {
- Rand rand (seed);
- return Rand::GetByteFromInt (rand.Get ());
- }
- UInt32 GetGlobalRandomSeed ();
- void ResetGlobalRandomSeed ();
- Vector2f CalculateInverseLerpOffsetScale (const Vector2f& range);
- void KillParticle(const ParticleSystemReadOnlyState& roState, ParticleSystemState& state, ParticleSystemParticles& ps, size_t index, size_t& particleCount);
- 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);
- bool GetTransformationMatrix(Matrix4x4f& output, const bool isSystemInWorld, const bool isCurveInWorld, const Matrix4x4f& localToWorld);
- bool GetTransformationMatrices(Matrix4x4f& output, Matrix4x4f& outputInverse, const bool isSystemInWorld, const bool isCurveInWorld, const Matrix4x4f& localToWorld);
- NS_RRP_END
- #endif /* ParticleSystemUtils_h */
|