summaryrefslogtreecommitdiff
path: root/src/particle.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2008-10-26 15:41:57 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2008-10-26 15:41:57 +0000
commit3925d9c41709dece19fe60c0e4bb111247f1886e (patch)
tree9b46a1ed60547c4e3f075536a50faa5342cbbc28 /src/particle.cpp
parent6d426d55fed55f2c01bdafca348cc8bbb06ee063 (diff)
downloadMana-3925d9c41709dece19fe60c0e4bb111247f1886e.tar.gz
Mana-3925d9c41709dece19fe60c0e4bb111247f1886e.tar.bz2
Mana-3925d9c41709dece19fe60c0e4bb111247f1886e.tar.xz
Mana-3925d9c41709dece19fe60c0e4bb111247f1886e.zip
Merged revisions 4302,4338,4360-4362,4526,4528,4534,4547 via svnmerge from
https://themanaworld.svn.sourceforge.net/svnroot/themanaworld/tmw/branches/0.0 ........ r4302 | crush_tmw | 2008-05-28 18:51:26 +0200 (Wed, 28 May 2008) | 1 line Changed the way particle emitter skip is handled to make linear and circular emitters work with particleEmitterSkip enabled. ........ r4338 | crush_tmw | 2008-06-05 20:41:39 +0200 (Thu, 05 Jun 2008) | 1 line Lowered default particle detail level. ........ r4360 | crush_tmw | 2008-06-23 16:44:20 +0200 (Mon, 23 Jun 2008) | 1 line Implemented "alpha" particle property. ........ r4361 | crush_tmw | 2008-06-23 22:20:05 +0200 (Mon, 23 Jun 2008) | 1 line Forgot changelog with last commit. ........ r4362 | crush_tmw | 2008-06-24 14:29:33 +0200 (Tue, 24 Jun 2008) | 1 line Added particle property "follow-parent" which makes the particle move when its parent particle is moved. ........ r4526 | crush_tmw | 2008-08-24 20:52:00 +0200 (Sun, 24 Aug 2008) | 1 line Added new particle emitter property "output-pause" which allows to define a fixed (or random) interval between two outputs. ........ r4528 | crush_tmw | 2008-08-24 20:58:39 +0200 (Sun, 24 Aug 2008) | 1 line fix for an error in the last commit ........ r4534 | b_lindeijer | 2008-08-27 20:48:13 +0200 (Wed, 27 Aug 2008) | 3 lines Renamed "randomnes" to "randomness", so that it won't show up as part of Fate's patch. ........ r4547 | crush_tmw | 2008-08-29 00:44:43 +0200 (Fri, 29 Aug 2008) | 1 line Added output-pause to copy constructor of particle emitters. ........
Diffstat (limited to 'src/particle.cpp')
-rw-r--r--src/particle.cpp27
1 files changed, 20 insertions, 7 deletions
diff --git a/src/particle.cpp b/src/particle.cpp
index ba5386f6..c59d2c03 100644
--- a/src/particle.cpp
+++ b/src/particle.cpp
@@ -57,11 +57,13 @@ Particle::Particle(Map *map):
mLifetimePast(0),
mFadeOut(0),
mFadeIn(0),
+ mAlpha(1.0f),
mAutoDelete(true),
mMap(map),
mGravity(0.0f),
- mRandomnes(0),
+ mRandomness(0),
mBounce(0.0f),
+ mFollow(false),
mTarget(NULL),
mAcceleration(0.0f),
mInvDieDistance(-1.0f),
@@ -77,7 +79,7 @@ Particle::setupEngine()
{
Particle::maxCount = (int)config.getValue("particleMaxCount", 3000);
Particle::fastPhysics = (int)config.getValue("particleFastPhysics", 0);
- Particle::emitterSkip = (int)config.getValue("particleEmitterSkip", 0) + 1;
+ Particle::emitterSkip = (int)config.getValue("particleEmitterSkip", 1) + 1;
disableAutoDelete();
logger->log("Particle engine set up");
}
@@ -94,6 +96,8 @@ Particle::update()
mAlive = false;
}
+ Vector oldPos = mPos;
+
if (mAlive)
{
//calculate particle movement
@@ -135,11 +139,11 @@ Particle::update()
}
}
- if (mRandomnes > 0)
+ if (mRandomness > 0)
{
- mVelocity.x += (rand()%mRandomnes - rand()%mRandomnes) / 1000.0f;
- mVelocity.y += (rand()%mRandomnes - rand()%mRandomnes) / 1000.0f;
- mVelocity.z += (rand()%mRandomnes - rand()%mRandomnes) / 1000.0f;
+ mVelocity.x += (rand()%mRandomness - rand()%mRandomness) / 1000.0f;
+ mVelocity.y += (rand()%mRandomness - rand()%mRandomness) / 1000.0f;
+ mVelocity.z += (rand()%mRandomness - rand()%mRandomness) / 1000.0f;
}
mVelocity.z -= mGravity;
@@ -170,7 +174,7 @@ Particle::update()
}
// Update child emitters
- if (mLifetimePast%Particle::emitterSkip == 0)
+ if ((mLifetimePast-1)%Particle::emitterSkip == 0)
{
for ( EmitterIterator e = mChildEmitters.begin();
e != mChildEmitters.end();
@@ -190,10 +194,19 @@ Particle::update()
}
}
+ Vector change = mPos - oldPos;
+
// Update child particles
+
for (ParticleIterator p = mChildParticles.begin();
p != mChildParticles.end();)
{
+ //move particle with its parent if desired
+ if ((*p)->doesFollow())
+ {
+ (*p)->moveBy(change);
+ }
+ //update particle
if ((*p)->update())
{
p++;