diff --git a/apps/openmw/mwrender/actoranimation.cpp b/apps/openmw/mwrender/actoranimation.cpp index 3d5daf74e0..b77115f2dd 100644 --- a/apps/openmw/mwrender/actoranimation.cpp +++ b/apps/openmw/mwrender/actoranimation.cpp @@ -58,7 +58,10 @@ ActorAnimation::ActorAnimation(const MWWorld::Ptr& ptr, osg::ref_ptr removeEffects(); } -ActorAnimation::~ActorAnimation() = default; +ActorAnimation::~ActorAnimation() +{ + removeFromSceneImpl(); +} PartHolderPtr ActorAnimation::attachMesh(const std::string& model, const std::string& bonename, bool enchantedGlow, osg::Vec4f* glowColor) { @@ -573,9 +576,14 @@ void ActorAnimation::removeHiddenItemLight(const MWWorld::ConstPtr& item) void ActorAnimation::removeFromScene() { - for (const auto& [k, v] : mItemLights) - mInsert->removeChild(v); + removeFromSceneImpl(); Animation::removeFromScene(); } +void ActorAnimation::removeFromSceneImpl() +{ + for (const auto& [k, v] : mItemLights) + mInsert->removeChild(v); +} + } diff --git a/apps/openmw/mwrender/actoranimation.hpp b/apps/openmw/mwrender/actoranimation.hpp index 41978eb785..d1f89295a3 100644 --- a/apps/openmw/mwrender/actoranimation.hpp +++ b/apps/openmw/mwrender/actoranimation.hpp @@ -65,6 +65,7 @@ class ActorAnimation : public Animation, public MWWorld::ContainerStoreListener void addHiddenItemLight(const MWWorld::ConstPtr& item, const ESM::Light* esmLight); void removeHiddenItemLight(const MWWorld::ConstPtr& item); void resetControllers(osg::Node* node); + void removeFromSceneImpl(); typedef std::map > ItemLightMap; ItemLightMap mItemLights; diff --git a/apps/openmw/mwrender/animation.cpp b/apps/openmw/mwrender/animation.cpp index 9d910c00f9..a394e67cf5 100644 --- a/apps/openmw/mwrender/animation.cpp +++ b/apps/openmw/mwrender/animation.cpp @@ -543,7 +543,10 @@ namespace MWRender mLightListCallback = new SceneUtil::LightListCallback; } - Animation::~Animation() = default; + Animation::~Animation() + { + removeFromSceneImpl(); + } void Animation::setActive(int active) { @@ -1783,6 +1786,11 @@ namespace MWRender } void Animation::removeFromScene() + { + removeFromSceneImpl(); + } + + void Animation::removeFromSceneImpl() { if (mGlowLight != nullptr) mInsert->removeChild(mGlowLight); diff --git a/apps/openmw/mwrender/animation.hpp b/apps/openmw/mwrender/animation.hpp index 1b5f5aa298..f3731c5423 100644 --- a/apps/openmw/mwrender/animation.hpp +++ b/apps/openmw/mwrender/animation.hpp @@ -344,6 +344,8 @@ protected: */ virtual void addControllers(); + void removeFromSceneImpl(); + public: Animation(const MWWorld::Ptr &ptr, osg::ref_ptr parentNode, Resource::ResourceSystem* resourceSystem);