diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/particle/animationparticle.cpp | 11 | ||||
-rw-r--r-- | src/particle/animationparticle.h | 5 | ||||
-rw-r--r-- | src/particle/particle.cpp | 5 | ||||
-rw-r--r-- | src/particle/particle.h | 4 | ||||
-rw-r--r-- | src/particle/rotationalparticle.cpp | 11 | ||||
-rw-r--r-- | src/particle/rotationalparticle.h | 5 |
6 files changed, 17 insertions, 24 deletions
diff --git a/src/particle/animationparticle.cpp b/src/particle/animationparticle.cpp index 43623aee9..006c7942f 100644 --- a/src/particle/animationparticle.cpp +++ b/src/particle/animationparticle.cpp @@ -24,28 +24,25 @@ #include "resources/animation/simpleanimation.h" -#include "utils/delete2.h" - #include "debug.h" AnimationParticle::AnimationParticle(Animation *restrict const animation) : - ImageParticle(nullptr), - mAnimation(new SimpleAnimation(animation)) + ImageParticle(nullptr) { mType = ParticleType::Animation; + mAnimation = new SimpleAnimation(animation); } AnimationParticle::AnimationParticle(XmlNodePtrConst animationNode, const std::string &restrict dyePalettes) : - ImageParticle(nullptr), - mAnimation(new SimpleAnimation(animationNode, dyePalettes)) + ImageParticle(nullptr) { mType = ParticleType::Animation; + mAnimation = new SimpleAnimation(animationNode, dyePalettes); } AnimationParticle::~AnimationParticle() { - delete2(mAnimation); mImage = nullptr; } diff --git a/src/particle/animationparticle.h b/src/particle/animationparticle.h index 112c1f10a..3d069f92b 100644 --- a/src/particle/animationparticle.h +++ b/src/particle/animationparticle.h @@ -28,7 +28,6 @@ #include "utils/xml.h" class Animation; -class SimpleAnimation; class AnimationParticle final : public ImageParticle { @@ -45,10 +44,6 @@ class AnimationParticle final : public ImageParticle ~AnimationParticle(); bool update() restrict2 override final; - - private: - /**< Used animation for this particle */ - SimpleAnimation *restrict mAnimation; }; #endif // PARTICLE_ANIMATIONPARTICLE_H diff --git a/src/particle/particle.cpp b/src/particle/particle.cpp index 48edee676..0805aed8c 100644 --- a/src/particle/particle.cpp +++ b/src/particle/particle.cpp @@ -34,8 +34,11 @@ #include "resources/resourcemanager.h" +#include "resources/animation/simpleanimation.h" + #include "resources/dye/dye.h" +#include "utils/delete2.h" #include "utils/dtor.h" #include "utils/mathutils.h" @@ -56,6 +59,7 @@ Particle::Particle() : mVelocity(), mAlive(AliveStatus::ALIVE), mType(ParticleType::Normal), + mAnimation(nullptr), mChildEmitters(), mChildParticles(), mDeathEffect(), @@ -78,6 +82,7 @@ Particle::~Particle() { // Delete child emitters and child particles clear(); + delete2(mAnimation); ParticleEngine::particleCount--; } diff --git a/src/particle/particle.h b/src/particle/particle.h index f76557e11..eb971ec4a 100644 --- a/src/particle/particle.h +++ b/src/particle/particle.h @@ -36,6 +36,7 @@ class Color; class Font; class Particle; class ParticleEmitter; +class SimpleAnimation; /** * A particle spawned by a ParticleEmitter. @@ -264,6 +265,9 @@ class Particle notfinal : public Actor ParticleType mType; + /**< Used animation for this particle */ + SimpleAnimation *restrict mAnimation; + private: // List of child emitters. Emitters mChildEmitters; diff --git a/src/particle/rotationalparticle.cpp b/src/particle/rotationalparticle.cpp index 1fa9f93b9..a52e0ca4b 100644 --- a/src/particle/rotationalparticle.cpp +++ b/src/particle/rotationalparticle.cpp @@ -24,32 +24,29 @@ #include "resources/animation/simpleanimation.h" -#include "utils/delete2.h" - #include "debug.h" static const double PI = M_PI; static const float PI2 = 2 * M_PI; RotationalParticle::RotationalParticle(Animation *restrict const animation) : - ImageParticle(nullptr), - mAnimation(new SimpleAnimation(animation)) + ImageParticle(nullptr) { mType = ParticleType::Rotational; + mAnimation = new SimpleAnimation(animation); } RotationalParticle::RotationalParticle(const XmlNodePtr animationNode, const std::string &restrict dyePalettes) : - ImageParticle(nullptr), - mAnimation(new SimpleAnimation(animationNode, dyePalettes)) + ImageParticle(nullptr) { mType = ParticleType::Rotational; + mAnimation = new SimpleAnimation(animationNode, dyePalettes); } RotationalParticle::~RotationalParticle() { - delete2(mAnimation); mImage = nullptr; } diff --git a/src/particle/rotationalparticle.h b/src/particle/rotationalparticle.h index db9c4ed89..93ee5f81a 100644 --- a/src/particle/rotationalparticle.h +++ b/src/particle/rotationalparticle.h @@ -28,7 +28,6 @@ #include "utils/xml.h" class Animation; -class SimpleAnimation; class RotationalParticle final : public ImageParticle { @@ -44,10 +43,6 @@ class RotationalParticle final : public ImageParticle ~RotationalParticle(); bool update() restrict2 override final; - - private: - /**< Used animation for this particle */ - SimpleAnimation *restrict mAnimation A_NONNULLPOINTER; }; #endif // PARTICLE_ROTATIONALPARTICLE_H |