mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-21 07:09:42 +00:00
Fix resetting player's animation on game loading
When game is loaded player's animation is replaced by a new object. Old object is destructed without explicit removeFromScene call.
This commit is contained in:
parent
6e71804048
commit
da15db295e
4 changed files with 22 additions and 4 deletions
|
@ -60,7 +60,10 @@ namespace MWRender
|
|||
removeEffects();
|
||||
}
|
||||
|
||||
ActorAnimation::~ActorAnimation() = default;
|
||||
ActorAnimation::~ActorAnimation()
|
||||
{
|
||||
removeFromSceneImpl();
|
||||
}
|
||||
|
||||
PartHolderPtr ActorAnimation::attachMesh(
|
||||
const std::string& model, std::string_view bonename, bool enchantedGlow, osg::Vec4f* glowColor)
|
||||
|
@ -584,9 +587,13 @@ namespace MWRender
|
|||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,6 +68,7 @@ namespace MWRender
|
|||
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<MWWorld::ConstPtr, osg::ref_ptr<SceneUtil::LightSource>> ItemLightMap;
|
||||
ItemLightMap mItemLights;
|
||||
|
|
|
@ -533,7 +533,10 @@ namespace MWRender
|
|||
mLightListCallback = new SceneUtil::LightListCallback;
|
||||
}
|
||||
|
||||
Animation::~Animation() = default;
|
||||
Animation::~Animation()
|
||||
{
|
||||
removeFromSceneImpl();
|
||||
}
|
||||
|
||||
void Animation::setActive(int active)
|
||||
{
|
||||
|
@ -1791,6 +1794,11 @@ namespace MWRender
|
|||
}
|
||||
|
||||
void Animation::removeFromScene()
|
||||
{
|
||||
removeFromSceneImpl();
|
||||
}
|
||||
|
||||
void Animation::removeFromSceneImpl()
|
||||
{
|
||||
if (mGlowLight != nullptr)
|
||||
mInsert->removeChild(mGlowLight);
|
||||
|
|
|
@ -344,6 +344,8 @@ namespace MWRender
|
|||
*/
|
||||
virtual void addControllers();
|
||||
|
||||
void removeFromSceneImpl();
|
||||
|
||||
public:
|
||||
Animation(
|
||||
const MWWorld::Ptr& ptr, osg::ref_ptr<osg::Group> parentNode, Resource::ResourceSystem* resourceSystem);
|
||||
|
|
Loading…
Reference in a new issue