1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-02-24 09:39:51 +00:00

Merge branch 'fix_reset_animation' into 'master'

Fix resetting player's animation on game loading (#7030)

Closes #7030

See merge request OpenMW/openmw!2448
This commit is contained in:
psi29a 2022-10-02 14:21:05 +00:00
commit 5875fbcc4c
4 changed files with 22 additions and 4 deletions

View File

@ -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);
}
}

View File

@ -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;

View File

@ -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);

View File

@ -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);