1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-04-16 07:06:44 +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(); removeEffects();
} }
ActorAnimation::~ActorAnimation() = default; ActorAnimation::~ActorAnimation()
{
removeFromSceneImpl();
}
PartHolderPtr ActorAnimation::attachMesh( PartHolderPtr ActorAnimation::attachMesh(
const std::string& model, std::string_view bonename, bool enchantedGlow, osg::Vec4f* glowColor) const std::string& model, std::string_view bonename, bool enchantedGlow, osg::Vec4f* glowColor)
@ -584,9 +587,13 @@ namespace MWRender
void ActorAnimation::removeFromScene() void ActorAnimation::removeFromScene()
{ {
for (const auto& [k, v] : mItemLights) removeFromSceneImpl();
mInsert->removeChild(v);
Animation::removeFromScene(); 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 addHiddenItemLight(const MWWorld::ConstPtr& item, const ESM::Light* esmLight);
void removeHiddenItemLight(const MWWorld::ConstPtr& item); void removeHiddenItemLight(const MWWorld::ConstPtr& item);
void resetControllers(osg::Node* node); void resetControllers(osg::Node* node);
void removeFromSceneImpl();
typedef std::map<MWWorld::ConstPtr, osg::ref_ptr<SceneUtil::LightSource>> ItemLightMap; typedef std::map<MWWorld::ConstPtr, osg::ref_ptr<SceneUtil::LightSource>> ItemLightMap;
ItemLightMap mItemLights; ItemLightMap mItemLights;

View file

@ -533,7 +533,10 @@ namespace MWRender
mLightListCallback = new SceneUtil::LightListCallback; mLightListCallback = new SceneUtil::LightListCallback;
} }
Animation::~Animation() = default; Animation::~Animation()
{
removeFromSceneImpl();
}
void Animation::setActive(int active) void Animation::setActive(int active)
{ {
@ -1791,6 +1794,11 @@ namespace MWRender
} }
void Animation::removeFromScene() void Animation::removeFromScene()
{
removeFromSceneImpl();
}
void Animation::removeFromSceneImpl()
{ {
if (mGlowLight != nullptr) if (mGlowLight != nullptr)
mInsert->removeChild(mGlowLight); mInsert->removeChild(mGlowLight);

View file

@ -344,6 +344,8 @@ namespace MWRender
*/ */
virtual void addControllers(); virtual void addControllers();
void removeFromSceneImpl();
public: public:
Animation( Animation(
const MWWorld::Ptr& ptr, osg::ref_ptr<osg::Group> parentNode, Resource::ResourceSystem* resourceSystem); const MWWorld::Ptr& ptr, osg::ref_ptr<osg::Group> parentNode, Resource::ResourceSystem* resourceSystem);