// Retrieve the Source and get the stream
if(!mStreamBasePos)
{
- mStreamBasePos = static_cast<FireSource*>(&mEmitter.GetSource().GetSourceCallback())->mStreamBasePos;
+ auto handle = mEmitter.GetHandle();
+ if(!handle)
+ {
+ return;
+ }
+ mStreamBasePos = static_cast<FireSource*>(&handle.GetSource().GetSourceCallback())->mStreamBasePos;
}
// Missing stream, return!
#include <dali-toolkit/public-api/particle-system/particle-list.h>
#include <dali-toolkit/public-api/particle-system/particle.h>
#include <dali/public-api/common/vector-wrapper.h>
+#include <dali/public-api/object/weak-handle.h>
#include <ctime>
namespace Dali::ParticleEffect
void Update(ParticleList& particleList, uint32_t first, uint32_t count) override;
ColorGradient mFireGradient;
- ParticleEmitter mEmitter;
+ Dali::WeakHandle<ParticleEmitter> mEmitter;
uint32_t mStreamBasePos{0u};
uint32_t mAngle{0u};
};
void FireSource::Init()
{
- mStreamBasePos = mEmitter.GetParticleList().AddLocalStream<Vector3>(Vector3::ZERO);
+ auto handle = mEmitter.GetHandle();
+ if(handle)
+ {
+ mStreamBasePos = handle.GetParticleList().AddLocalStream<Vector3>(Vector3::ZERO);
+ }
}
uint32_t FireSource::Update(ParticleList& particleList, uint32_t count)
#include <dali-toolkit/public-api/particle-system/particle-modifier.h>
#include <dali-toolkit/public-api/particle-system/particle-list.h>
#include <dali-toolkit/public-api/particle-system/particle.h>
+#include <dali/public-api/object/weak-handle.h>
#include <ctime>
namespace Dali::ParticleEffect
void UpdateParticle(Vector3& position, Vector3& basePosition, Vector4& color, Vector3& velocity, Vector3& scale);
- ParticleEmitter mEmitter;
+ Dali::WeakHandle<ParticleEmitter> mEmitter;
Dali::Vector2 mRadius;
// Retrieve the Source and get the stream
if(!mStreamBasePos)
{
- mStreamBasePos = static_cast<ImageExplodeEffectSource*>(&mEmitter.GetSource().GetSourceCallback())->mStreamBasePos;
+ auto handle = mEmitter.GetHandle();
+ if(!handle)
+ {
+ return;
+ }
+ mStreamBasePos = static_cast<ImageExplodeEffectSource*>(&handle.GetSource().GetSourceCallback())->mStreamBasePos;
}
// Missing stream, return!
#include <dali-toolkit/public-api/particle-system/particle-modifier.h>
#include <dali-toolkit/public-api/particle-system/particle-list.h>
#include <dali-toolkit/public-api/particle-system/particle.h>
+#include <dali/public-api/object/weak-handle.h>
#include <ctime>
namespace Dali::ParticleEffect
void Update(ParticleList& particleList, uint32_t first, uint32_t count) override;
- ParticleEmitter mEmitter;
+ WeakHandle<ParticleEmitter> mEmitter;
uint32_t mStreamBasePos{0u};
float mAngle{0.0f};
void ImageExplodeEffectSource::Init()
{
- mStreamBasePos = mEmitter.GetParticleList().AddLocalStream<Vector3>(Vector3::ZERO);
+ auto handle = mEmitter.GetHandle();
+ if(handle)
+ {
+ mStreamBasePos = handle.GetParticleList().AddLocalStream<Vector3>(Vector3::ZERO);
+ }
}
uint32_t ImageExplodeEffectSource::Update(ParticleList& particleList, uint32_t count)
{
- if(!mShouldEmit)
+ if(!mShouldEmit || !mStreamBasePos)
{
return 0;
}
#include <dali-toolkit/public-api/particle-system/particle-list.h>
#include <dali-toolkit/public-api/particle-system/particle.h>
#include <dali/devel-api/adaptor-framework/pixel-buffer.h>
+#include <dali/public-api/object/weak-handle.h>
#include <ctime>
namespace Dali::ParticleEffect
void Init() override;
- ParticleEmitter mEmitter;
+ WeakHandle<ParticleEmitter> mEmitter;
uint32_t mImageWidth{0u};
uint32_t mImageHeight{0u};
~ParticleEffect();
Dali::Toolkit::ParticleSystem::ParticleEmitter CreateEffectEmitter( EffectType effectType, Actor parentActor, const ParticleEffectParams& params );
-
-private:
-
-
};
}
mAngle = ((mAngle + 2) % 360);
// Retrieve the Source and get the stream
+ auto handle = mEmitter.GetHandle();
+ if(!handle)
+ {
+ return;
+ }
if(!mStreamBasePos)
{
- mStreamBasePos = static_cast<SparklesSource*>(&mEmitter.GetSource().GetSourceCallback())->mStreamBasePos;
+ mStreamBasePos = static_cast<SparklesSource*>(&handle.GetSource().GetSourceCallback())->mStreamBasePos;
}
if(!mStreamBaseAngle)
{
- mStreamBaseAngle = static_cast<SparklesSource*>(&mEmitter.GetSource().GetSourceCallback())->mStreamBaseAngle;
+ mStreamBaseAngle = static_cast<SparklesSource*>(&handle.GetSource().GetSourceCallback())->mStreamBaseAngle;
}
// Missing stream, return!
auto angle = particle.GetByIndex<float>(mStreamBaseAngle);
auto radians = ((angle * M_PI)/180.f);
float lifetime = particle.Get<float>(ParticleStream::LIFETIME_STREAM_BIT);
- position.y += velocity.y *sin(radians);
+ position.y += velocity.y * sin(radians);
position.x += velocity.x * cos(radians);
velocity *= 0.990f;
#include <dali-toolkit/public-api/particle-system/particle-list.h>
#include <dali-toolkit/public-api/particle-system/particle.h>
#include <dali/public-api/common/vector-wrapper.h>
+#include <dali/public-api/object/weak-handle.h>
#include <ctime>
namespace Dali::ParticleEffect
void Update(ParticleList& particleList, uint32_t first, uint32_t count) override;
- ParticleEmitter mEmitter;
+ Dali::WeakHandle<ParticleEmitter> mEmitter;
uint32_t mStreamBasePos{0u};
uint32_t mStreamBaseAngle{0u};
uint32_t mAngle{0u};
void SparklesSource::Init()
{
- mStreamBasePos = mEmitter.GetParticleList().AddLocalStream<Vector3>(Vector3::ZERO);
- mStreamBaseAngle = mEmitter.GetParticleList().AddLocalStream<float>(0.0f);
+ auto handle = mEmitter.GetHandle();
+ if(!handle)
+ {
+ return;
+ }
+ mStreamBasePos = handle.GetParticleList().AddLocalStream<Vector3>(Vector3::ZERO);
+ mStreamBaseAngle = handle.GetParticleList().AddLocalStream<float>(0.0f);
}
uint32_t SparklesSource::Update(ParticleList& particleList, uint32_t count)
{
+ if(!mStreamBasePos || !mStreamBaseAngle)
+ {
+ return 0u;
+ }
+
while(count--)
{
auto particle = particleList.NewParticle(LIFETIME);
#include <dali-toolkit/public-api/particle-system/particle-modifier.h>
#include <dali-toolkit/public-api/particle-system/particle-list.h>
#include <dali-toolkit/public-api/particle-system/particle.h>
+#include <dali/public-api/object/weak-handle.h>
+
#include <ctime>
namespace Dali::ParticleEffect
void UpdateParticle(Vector3& position, Vector3& basePosition, Vector4& color, Vector3& velocity, Vector3& scale, float& angle);
- ParticleEmitter mEmitter;
+ Dali::WeakHandle<ParticleEmitter> mEmitter;
Dali::Vector2 mRadius;