namespace Dali::Toolkit::ParticleSystem::Internal
{
-
constexpr uint32_t DEFAULT_PARTICLE_COUNT = 100u; ///< Default number of particles in system if not set by user
/**
~FrameCallback() = default;
private:
- void Update(Dali::UpdateProxy& updateProxy, float elapsedSeconds) override
+ bool Update(Dali::UpdateProxy& updateProxy, float elapsedSeconds) override
{
mEmitter->Update();
+ return true;
}
Internal::ParticleEmitter* mEmitter;
void ParticleEmitter::SetParticleCount(uint32_t maxParticleCount)
{
- // Default particle list has no data streams, it will replace old list
- mParticleList = ParticleSystem::ParticleList::New(maxParticleCount,
- ParticleStream::POSITION_STREAM_BIT |
- ParticleStream::COLOR_STREAM_BIT |
- ParticleStream::VELOCITY_STREAM_BIT |
- ParticleStream::SCALE_STREAM_BIT |
- ParticleStream::LIFETIME_STREAM_BIT);
+ if(!mParticleList || maxParticleCount != GetImplementation(mParticleList).GetParticleCount())
+ {
+ // Default particle list has no data streams, it will replace old list
+ mParticleList = ParticleSystem::ParticleList::New(maxParticleCount,
+ ParticleStream::POSITION_STREAM_BIT |
+ ParticleStream::COLOR_STREAM_BIT |
+ ParticleStream::VELOCITY_STREAM_BIT |
+ ParticleStream::SCALE_STREAM_BIT |
+ ParticleStream::LIFETIME_STREAM_BIT);
+ }
+}
+
+uint32_t ParticleEmitter::GetParticleCount()
+{
+ return GetImplementation(mParticleList).GetParticleCount();
}
ParticleSystem::ParticleList& ParticleEmitter::GetParticleList()
void ParticleEmitter::RemoveModifierAt(uint32_t index)
{
- mModifiers.erase(mModifiers.begin()+index);
+ mModifiers.erase(mModifiers.begin() + index);
}
void ParticleEmitter::Start()
}
updateTasks.emplace_back(GetImplementation(modifier), mParticleList, index, count);
- tasks.emplace_back([&task = updateTasks.back()](uint32_t n)
- {
- //printf("Updating modifier: %d\n", n);
- task.Update(); });
+ tasks.emplace_back([&task = updateTasks.back()](uint32_t n) { task.Update(); });
}
auto future = threadPool.SubmitTasks(tasks, 0);
SetParticleCount(DEFAULT_PARTICLE_COUNT);
}
+ParticleEmitter::~ParticleEmitter()
+{
+ if(mParticleRenderer)
+ {
+ GetImplementation(mParticleRenderer).PrepareToDie();
+ }
+}
+
} // namespace Dali::Toolkit::ParticleSystem::Internal
namespace Dali::Toolkit::ParticleSystem
{
// NOTE: this function shouldn't be called from multiple thread anyway
if(!gThreadPool)
{
- std::call_once(onceFlag, [&threadPool = gThreadPool]
- { threadPool = std::make_unique<Dali::ThreadPool>();
+ std::call_once(onceFlag, [&threadPool = gThreadPool] { threadPool = std::make_unique<Dali::ThreadPool>();
threadPool->Initialize(4u); });
}