mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-03-30 16:20:21 +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();
|
removeEffects();
|
||||||
}
|
}
|
||||||
|
|
||||||
ActorAnimation::~ActorAnimation()
|
ActorAnimation::~ActorAnimation() = default;
|
||||||
{
|
|
||||||
for (ItemLightMap::iterator iter = mItemLights.begin(); iter != mItemLights.end(); ++iter)
|
|
||||||
{
|
|
||||||
mInsert->removeChild(iter->second);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
PartHolderPtr ActorAnimation::attachMesh(const std::string& model, const std::string& bonename, bool enchantedGlow, osg::Vec4f* glowColor)
|
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);
|
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 useShieldAnimations() const override;
|
||||||
bool updateCarriedLeftVisible(const int weaptype) const override;
|
bool updateCarriedLeftVisible(const int weaptype) const override;
|
||||||
|
|
||||||
|
void removeFromScene() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
osg::Group* getBoneByName(const std::string& boneName) const;
|
osg::Group* getBoneByName(const std::string& boneName) const;
|
||||||
virtual void updateHolsteredWeapon(bool showHolsteredWeapons);
|
virtual void updateHolsteredWeapon(bool showHolsteredWeapons);
|
||||||
|
@ -527,13 +527,7 @@ namespace MWRender
|
|||||||
mLightListCallback = new SceneUtil::LightListCallback;
|
mLightListCallback = new SceneUtil::LightListCallback;
|
||||||
}
|
}
|
||||||
|
|
||||||
Animation::~Animation()
|
Animation::~Animation() = default;
|
||||||
{
|
|
||||||
Animation::setLightEffect(0.f);
|
|
||||||
|
|
||||||
if (mObjectRoot)
|
|
||||||
mInsert->removeChild(mObjectRoot);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Animation::setActive(int active)
|
void Animation::setActive(int active)
|
||||||
{
|
{
|
||||||
@ -1769,6 +1763,15 @@ namespace MWRender
|
|||||||
return mHeadYawRadians;
|
return mHeadYawRadians;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Animation::removeFromScene()
|
||||||
|
{
|
||||||
|
if (mGlowLight != nullptr)
|
||||||
|
mInsert->removeChild(mGlowLight);
|
||||||
|
|
||||||
|
if (mObjectRoot != nullptr)
|
||||||
|
mInsert->removeChild(mObjectRoot);
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------
|
// ------------------------------------------------------
|
||||||
|
|
||||||
float Animation::AnimationTime::getValue(osg::NodeVisitor*)
|
float Animation::AnimationTime::getValue(osg::NodeVisitor*)
|
||||||
|
@ -497,6 +497,8 @@ public:
|
|||||||
virtual void setAccurateAiming(bool enabled) {}
|
virtual void setAccurateAiming(bool enabled) {}
|
||||||
virtual bool canBeHarvested() const { return false; }
|
virtual bool canBeHarvested() const { return false; }
|
||||||
|
|
||||||
|
virtual void removeFromScene();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Animation(const Animation&);
|
Animation(const Animation&);
|
||||||
void operator=(Animation&);
|
void operator=(Animation&);
|
||||||
|
@ -115,6 +115,7 @@ bool Objects::removeObject (const MWWorld::Ptr& ptr)
|
|||||||
const auto iter = mObjects.find(ptr.mRef);
|
const auto iter = mObjects.find(ptr.mRef);
|
||||||
if(iter != mObjects.end())
|
if(iter != mObjects.end())
|
||||||
{
|
{
|
||||||
|
iter->second->removeFromScene();
|
||||||
mObjects.erase(iter);
|
mObjects.erase(iter);
|
||||||
|
|
||||||
if (ptr.getClass().isActor())
|
if (ptr.getClass().isActor())
|
||||||
@ -148,7 +149,8 @@ void Objects::removeCell(const MWWorld::CellStore* store)
|
|||||||
ptr.getClass().getContainerStore(ptr).setContListener(nullptr);
|
ptr.getClass().getContainerStore(ptr).setContListener(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
mObjects.erase(iter++);
|
iter->second->removeFromScene();
|
||||||
|
iter = mObjects.erase(iter);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
++iter;
|
++iter;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user