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,7 +39,8 @@ Explosion::Explosion(const Vec3& coord, const char* explosion_sound, const char
{ {
// short emision time, explosion, not constant flame // short emision time, explosion, not constant flame
m_remaining_time = burst_time; m_remaining_time = burst_time;
m_emission_frames = 0;
ParticleKindManager* pkm = ParticleKindManager::get(); ParticleKindManager* pkm = ParticleKindManager::get();
ParticleKind* particles = pkm->getParticles(particle_file); ParticleKind* particles = pkm->getParticles(particle_file);
m_emitter = new ParticleEmitter(particles, coord, NULL); m_emitter = new ParticleEmitter(particles, coord, NULL);
@ -67,6 +68,7 @@ bool Explosion::updateAndDelete(float dt)
// so no need to save the result of the update call. // so no need to save the result of the update call.
HitSFX::updateAndDelete(dt); HitSFX::updateAndDelete(dt);
m_emission_frames++;
m_remaining_time -= dt; m_remaining_time -= dt;
if (m_remaining_time < 0.0f && m_remaining_time >= -explosion_time) if (m_remaining_time < 0.0f && m_remaining_time >= -explosion_time)
@ -77,15 +79,14 @@ bool Explosion::updateAndDelete(float dt)
node->getMaterial(0).AmbientColor.setGreen(intensity); node->getMaterial(0).AmbientColor.setGreen(intensity);
node->getMaterial(0).DiffuseColor.setGreen(intensity); node->getMaterial(0).DiffuseColor.setGreen(intensity);
node->getMaterial(0).EmissiveColor.setGreen(intensity); node->getMaterial(0).EmissiveColor.setGreen(intensity);
node->getMaterial(0).AmbientColor.setBlue(intensity); node->getMaterial(0).AmbientColor.setBlue(intensity);
node->getMaterial(0).DiffuseColor.setBlue(intensity); node->getMaterial(0).DiffuseColor.setBlue(intensity);
node->getMaterial(0).EmissiveColor.setBlue(intensity); node->getMaterial(0).EmissiveColor.setBlue(intensity);
node->getMaterial(0).AmbientColor.setRed(intensity); node->getMaterial(0).AmbientColor.setRed(intensity);
node->getMaterial(0).DiffuseColor.setRed(intensity); node->getMaterial(0).DiffuseColor.setRed(intensity);
node->getMaterial(0).EmissiveColor.setRed(intensity); node->getMaterial(0).EmissiveColor.setRed(intensity);
} }
@ -97,9 +98,14 @@ bool Explosion::updateAndDelete(float dt)
// object is removed. // object is removed.
if (m_remaining_time > -explosion_time) if (m_remaining_time > -explosion_time)
{ {
// Stop the emitter and wait a little while for all particles to have time to fade out // if framerate is very low, emit for at least a few frames, in case
m_emitter->getNode()->getEmitter()->setMinParticlesPerSecond(0); // burst time is lower than the time of 1 frame
m_emitter->getNode()->getEmitter()->setMaxParticlesPerSecond(0); 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 else
{ {

View File

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