From 15740faf9fe9fe4be08965098bbf2947e096aeeb Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 14 Aug 2019 22:50:43 +0800 Subject: +Unity Runtime code --- .../Graphics/ParticleSystem/Modules/SizeModule.cpp | 41 ++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 Runtime/Graphics/ParticleSystem/Modules/SizeModule.cpp (limited to 'Runtime/Graphics/ParticleSystem/Modules/SizeModule.cpp') diff --git a/Runtime/Graphics/ParticleSystem/Modules/SizeModule.cpp b/Runtime/Graphics/ParticleSystem/Modules/SizeModule.cpp new file mode 100644 index 0000000..ad08a4a --- /dev/null +++ b/Runtime/Graphics/ParticleSystem/Modules/SizeModule.cpp @@ -0,0 +1,41 @@ +#include "UnityPrefix.h" +#include "SizeModule.h" +#include "Runtime/BaseClasses/ObjectDefines.h" +#include "Runtime/Serialize/TransferFunctions/SerializeTransfer.h" +#include "Runtime/Math/Random/Random.h" +#include "Runtime/Graphics/ParticleSystem/ParticleSystemUtils.h" + +template +void UpdateTpl(const MinMaxCurve& curve, const ParticleSystemParticles& ps, float* tempSize, size_t fromIndex, size_t toIndex) +{ + for (size_t q = fromIndex; q < toIndex; ++q) + { + const float time = NormalizedTime(ps, q); + const float random = GenerateRandom(ps.randomSeed[q] + kParticleSystemSizeCurveId); + tempSize[q] *= max(0.0f, Evaluate (curve, time, random)); + } +} + +SizeModule::SizeModule() : ParticleSystemModule(false) +{} + +void SizeModule::Update (const ParticleSystemParticles& ps, float* tempSize, size_t fromIndex, size_t toIndex) +{ + DebugAssert(toIndex <= ps.array_size ()); + if(m_Curve.minMaxState == kMMCScalar) + UpdateTpl(m_Curve, ps, tempSize, fromIndex, toIndex); + else if (m_Curve.IsOptimized() && m_Curve.UsesMinMax ()) + UpdateTpl(m_Curve, ps, tempSize, fromIndex, toIndex); + else if(m_Curve.IsOptimized()) + UpdateTpl(m_Curve, ps, tempSize, fromIndex, toIndex); + else + UpdateTpl(m_Curve, ps, tempSize, fromIndex, toIndex); +} + +template +void SizeModule::Transfer (TransferFunction& transfer) +{ + ParticleSystemModule::Transfer (transfer); + transfer.Transfer (m_Curve, "curve"); +} +INSTANTIATE_TEMPLATE_TRANSFER(SizeModule) -- cgit v1.1-26-g67d0