diff --git a/src/items/plunger.cpp b/src/items/plunger.cpp index 367e49db3..2ce20d07e 100644 --- a/src/items/plunger.cpp +++ b/src/items/plunger.cpp @@ -121,7 +121,7 @@ Plunger::Plunger(Kart *kart) : Flyable(kart, PowerupManager::POWERUP_PLUNGER) Plunger::~Plunger() { if(m_rubber_band) - m_rubber_band->removeFromScene(); + delete m_rubber_band; } // ~Plunger // ----------------------------------------------------------------------------- diff --git a/src/items/rubber_band.cpp b/src/items/rubber_band.cpp index 8b765ba04..72d12ba71 100644 --- a/src/items/rubber_band.cpp +++ b/src/items/rubber_band.cpp @@ -82,14 +82,17 @@ RubberBand::RubberBand(Plunger *plunger, const Kart &kart) : } // RubberBand // ---------------------------------------------------------------------------- -/** Removes the rubber band from the scene. Is called when the plunger - * explodes. - */ -void RubberBand::removeFromScene() +RubberBand::~RubberBand() { irr_driver->removeNode(m_node); - irr_driver->removeMesh(m_mesh); -} // removeFromScene + + // This mesh is self made and so not stored in the + // mesh cache. So no reason to call + // irr_driver->removeMesh(m_mesh); + // But it was implicitly 'grabbed' during creation, so we have + // to drop it here. + m_mesh->drop(); +} // RubberBand // ---------------------------------------------------------------------------- /** Updates the position of the rubber band. It especially sets the diff --git a/src/items/rubber_band.hpp b/src/items/rubber_band.hpp index 38cdf02ec..687060933 100644 --- a/src/items/rubber_band.hpp +++ b/src/items/rubber_band.hpp @@ -64,8 +64,8 @@ private: public: RubberBand(Plunger *plunger, const Kart &kart); + ~RubberBand(); void update(float dt); - void removeFromScene(); void hit(Kart *kart_hit, const Vec3 *track_xyz=NULL); }; // RubberBand #endif