mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-03-17 19:20:49 +00:00
Remove animation objects from scene outside destructor
This commit is contained in:
parent
34fd8abf5f
commit
1e7989c5e5
@ -58,13 +58,7 @@ ActorAnimation::ActorAnimation(const MWWorld::Ptr& ptr, osg::ref_ptr<osg::Group>
|
||||
removeEffects();
|
||||
}
|
||||
|
||||
ActorAnimation::~ActorAnimation()
|
||||
{
|
||||
for (ItemLightMap::iterator iter = mItemLights.begin(); iter != mItemLights.end(); ++iter)
|
||||
{
|
||||
mInsert->removeChild(iter->second);
|
||||
}
|
||||
}
|
||||
ActorAnimation::~ActorAnimation() = default;
|
||||
|
||||
PartHolderPtr ActorAnimation::attachMesh(const std::string& model, const std::string& bonename, bool enchantedGlow, osg::Vec4f* glowColor)
|
||||
{
|
||||
@ -594,4 +588,11 @@ void ActorAnimation::removeHiddenItemLight(const MWWorld::ConstPtr& item)
|
||||
mItemLights.erase(iter);
|
||||
}
|
||||
|
||||
void ActorAnimation::removeFromScene()
|
||||
{
|
||||
for (const auto& [k, v] : mItemLights)
|
||||
mInsert->removeChild(v);
|
||||
Animation::removeFromScene();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -40,6 +40,8 @@ class ActorAnimation : public Animation, public MWWorld::ContainerStoreListener
|
||||
bool useShieldAnimations() const override;
|
||||
bool updateCarriedLeftVisible(const int weaptype) const override;
|
||||
|
||||
void removeFromScene() override;
|
||||
|
||||
protected:
|
||||
osg::Group* getBoneByName(const std::string& boneName) const;
|
||||
virtual void updateHolsteredWeapon(bool showHolsteredWeapons);
|
||||
|
@ -527,13 +527,7 @@ namespace MWRender
|
||||
mLightListCallback = new SceneUtil::LightListCallback;
|
||||
}
|
||||
|
||||
Animation::~Animation()
|
||||
{
|
||||
Animation::setLightEffect(0.f);
|
||||
|
||||
if (mObjectRoot)
|
||||
mInsert->removeChild(mObjectRoot);
|
||||
}
|
||||
Animation::~Animation() = default;
|
||||
|
||||
void Animation::setActive(int active)
|
||||
{
|
||||
@ -1769,6 +1763,15 @@ namespace MWRender
|
||||
return mHeadYawRadians;
|
||||
}
|
||||
|
||||
void Animation::removeFromScene()
|
||||
{
|
||||
if (mGlowLight != nullptr)
|
||||
mInsert->removeChild(mGlowLight);
|
||||
|
||||
if (mObjectRoot != nullptr)
|
||||
mInsert->removeChild(mObjectRoot);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------
|
||||
|
||||
float Animation::AnimationTime::getValue(osg::NodeVisitor*)
|
||||
|
@ -497,6 +497,8 @@ public:
|
||||
virtual void setAccurateAiming(bool enabled) {}
|
||||
virtual bool canBeHarvested() const { return false; }
|
||||
|
||||
virtual void removeFromScene();
|
||||
|
||||
private:
|
||||
Animation(const Animation&);
|
||||
void operator=(Animation&);
|
||||
|
@ -115,6 +115,7 @@ bool Objects::removeObject (const MWWorld::Ptr& ptr)
|
||||
const auto iter = mObjects.find(ptr.mRef);
|
||||
if(iter != mObjects.end())
|
||||
{
|
||||
iter->second->removeFromScene();
|
||||
mObjects.erase(iter);
|
||||
|
||||
if (ptr.getClass().isActor())
|
||||
@ -148,7 +149,8 @@ void Objects::removeCell(const MWWorld::CellStore* store)
|
||||
ptr.getClass().getContainerStore(ptr).setContListener(nullptr);
|
||||
}
|
||||
|
||||
mObjects.erase(iter++);
|
||||
iter->second->removeFromScene();
|
||||
iter = mObjects.erase(iter);
|
||||
}
|
||||
else
|
||||
++iter;
|
||||
|
Loading…
x
Reference in New Issue
Block a user