From 8b29d20866f733491d96ee709a7b760f7b3518ce Mon Sep 17 00:00:00 2001 From: hikerstk Date: Mon, 6 Sep 2010 11:07:41 +0000 Subject: [PATCH] Fixed missing stars animation, which is now moved completely into EmergencyAnimation (see bug 3059588). git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@5901 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- src/karts/emergency_animation.cpp | 27 +++++++++++++++++++++++++-- src/karts/emergency_animation.hpp | 6 +++++- src/karts/kart.cpp | 10 ---------- src/karts/kart.hpp | 4 ---- 4 files changed, 30 insertions(+), 17 deletions(-) diff --git a/src/karts/emergency_animation.cpp b/src/karts/emergency_animation.cpp index d3b913028..20215d504 100644 --- a/src/karts/emergency_animation.cpp +++ b/src/karts/emergency_animation.cpp @@ -19,6 +19,7 @@ #include "karts/emergency_animation.hpp" +#include "graphics/stars.hpp" #include "karts/kart.hpp" #include "modes/world.hpp" #include "physics/btKart.hpp" @@ -31,21 +32,36 @@ */ EmergencyAnimation::EmergencyAnimation(Kart *kart) { - m_kart = kart; + m_stars_effect = NULL; + m_kart = kart; // Setting kart mode here is important! If the mode should be rescue when // reset() is called, it is assumed that this was triggered by a restart, // and that the vehicle must be added back to the physics world. Since // reset() is also called at the very start, it must be guaranteed that // rescue is not set. - m_kart_mode = EA_NONE; + m_kart_mode = EA_NONE; }; // EmergencyAnimation +//----------------------------------------------------------------------------- +EmergencyAnimation::~EmergencyAnimation() +{ + if(m_stars_effect) + delete m_stars_effect; +} // ~EmergencyAnimation + //----------------------------------------------------------------------------- /** Resets all data at the beginning of a race. */ void EmergencyAnimation::reset() { + // Create the stars effect in the first reset + if(!m_stars_effect) + m_stars_effect = new Stars(m_kart->getNode()); + + // Reset star effect in case that it is currently being shown. + m_stars_effect->reset(); + // If the kart was eliminated or rescued, the body was removed from the // physics world. Add it again. if(playingEmergencyAnimation()) @@ -124,6 +140,7 @@ void EmergencyAnimation::handleExplosion(const Vec3 &pos, bool direct_hit) m_add_rotation.setHeading( (rand()%(2*max_rotation+1)-max_rotation)*f ); m_add_rotation.setPitch( (rand()%(2*max_rotation+1)-max_rotation)*f ); m_add_rotation.setRoll( (rand()%(2*max_rotation+1)-max_rotation)*f ); + m_stars_effect->showFor(6.0f); } // handleExplosion @@ -134,6 +151,12 @@ void EmergencyAnimation::handleExplosion(const Vec3 &pos, bool direct_hit) */ void EmergencyAnimation::update(float dt) { + if ( UserConfigParams::m_graphical_effects ) + { + // update star effect (call will do nothing if stars are not activated) + m_stars_effect->update(dt); + } + if(!playingEmergencyAnimation()) return; // See if the timer expires, if so return the kart to normal game play diff --git a/src/karts/emergency_animation.hpp b/src/karts/emergency_animation.hpp index 71497caee..8ac036565 100644 --- a/src/karts/emergency_animation.hpp +++ b/src/karts/emergency_animation.hpp @@ -23,6 +23,7 @@ #include "utils/vec3.hpp" class Kart; +class Stars; /** * \brief This class is a 'mixin' for kart, and handles the animated explosion. @@ -63,13 +64,16 @@ private: /** A pointer to the class to which this object belongs. */ Kart *m_kart; + /** For stars rotating around head effect */ + Stars *m_stars_effect; + /** Different kart modes: normal racing, being rescued, showing end * animation, explosions, kart eliminated. */ enum {EA_NONE, EA_RESCUE, EA_EXPLOSION} m_kart_mode; public: EmergencyAnimation(Kart *kart); - ~EmergencyAnimation() {}; + ~EmergencyAnimation(); void reset(); void handleExplosion(const Vec3& pos, bool direct_hit); void forceRescue(); diff --git a/src/karts/kart.cpp b/src/karts/kart.cpp index b2fa357d2..362d00c24 100644 --- a/src/karts/kart.cpp +++ b/src/karts/kart.cpp @@ -34,7 +34,6 @@ #include "graphics/skid_marks.hpp" #include "graphics/slip_stream.hpp" #include "graphics/smoke.hpp" -#include "graphics/stars.hpp" #include "graphics/water_splash.hpp" #include "modes/world.hpp" #include "io/file_manager.hpp" @@ -83,7 +82,6 @@ Kart::Kart (const std::string& ident, int position, m_shadow_enabled = false; m_shadow = NULL; m_smoke_system = NULL; - m_stars_effect = NULL; m_water_splash_system = NULL; m_nitro = NULL; m_slip_stream = NULL; @@ -307,7 +305,6 @@ Kart::~Kart() if(m_slip_stream) delete m_slip_stream; delete m_shadow; - delete m_stars_effect; if(m_skidmarks) delete m_skidmarks ; @@ -438,8 +435,6 @@ void Kart::reset() m_controls.m_drift = false; m_controls.m_fire = false; m_controls.m_look_back = false; - // Reset star effect in case that it is currently being shown. - m_stars_effect->reset(); m_slip_stream->reset(); m_vehicle->deactivateZipper(); @@ -708,9 +703,6 @@ void Kart::update(float dt) m_water_splash_system->update(dt); m_nitro->update(dt); m_slip_stream->update(dt); - // update star effect (call will do nothing if stars are not activated) - m_stars_effect->update(dt); - } // UserConfigParams::m_graphical_effects updatePhysics(dt); @@ -1377,8 +1369,6 @@ void Kart::loadData() m_shadow = new Shadow(m_kart_properties->getShadowTexture(), m_node); - - m_stars_effect = new Stars(m_node); } // loadData //----------------------------------------------------------------------------- diff --git a/src/karts/kart.hpp b/src/karts/kart.hpp index 5e110f944..49ef5b28c 100644 --- a/src/karts/kart.hpp +++ b/src/karts/kart.hpp @@ -47,7 +47,6 @@ class SFXBase; class SkidMarks; class SlipStream; class Smoke; -class Stars; class WaterSplash; /** The main kart class. All type of karts are of this object, but with @@ -140,9 +139,6 @@ private: /** Water splash when driving in water. */ WaterSplash *m_water_splash_system; - /** For stars rotating around head effect */ - Stars *m_stars_effect; - /** Graphical effect when using a nitro. */ Nitro *m_nitro;