Merge branch 'master' of github.com:supertuxkart/stk-code

This commit is contained in:
hiker 2014-09-30 15:02:40 +10:00
commit 2f27d49198
2 changed files with 15 additions and 8 deletions

View File

@ -39,6 +39,7 @@ Explosion::Explosion(const Vec3& coord, const char* explosion_sound, const char
{
// short emision time, explosion, not constant flame
m_remaining_time = burst_time;
m_emission_frames = 0;
ParticleKindManager* pkm = ParticleKindManager::get();
ParticleKind* particles = pkm->getParticles(particle_file);
@ -67,6 +68,7 @@ bool Explosion::updateAndDelete(float dt)
// so no need to save the result of the update call.
HitSFX::updateAndDelete(dt);
m_emission_frames++;
m_remaining_time -= dt;
if (m_remaining_time < 0.0f && m_remaining_time >= -explosion_time)
@ -85,7 +87,6 @@ bool Explosion::updateAndDelete(float dt)
node->getMaterial(0).AmbientColor.setRed(intensity);
node->getMaterial(0).DiffuseColor.setRed(intensity);
node->getMaterial(0).EmissiveColor.setRed(intensity);
}
@ -96,11 +97,16 @@ bool Explosion::updateAndDelete(float dt)
// sfx will get aborted 'in the middle' when this explosion
// object is removed.
if (m_remaining_time > -explosion_time)
{
// if framerate is very low, emit for at least a few frames, in case
// burst time is lower than the time of 1 frame
if (m_emission_frames > 2)
{
// Stop the emitter and wait a little while for all particles to have time to fade out
m_emitter->getNode()->getEmitter()->setMinParticlesPerSecond(0);
m_emitter->getNode()->getEmitter()->setMaxParticlesPerSecond(0);
}
}
else
{
// Sound and animation finished, node can be removed now.

View File

@ -32,7 +32,7 @@ class Vec3;
class SFXBase;
class ParticleEmitter;
const float explosion_time = 1.5f;
const float explosion_time = 2.0f;
/**
* \ingroup graphics
@ -41,6 +41,7 @@ class Explosion : public HitSFX
{
private:
float m_remaining_time;
int m_emission_frames;
ParticleEmitter* m_emitter;
public: