1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-02-01 00:45:34 +00:00

Merge branch 'fix_reset_animation_48' into 'openmw-48'

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

See merge request OpenMW/openmw!2449
This commit is contained in:
psi29a 2022-10-02 13:44:43 +00:00
commit fedd9191d5
4 changed files with 23 additions and 4 deletions

View file

@ -58,7 +58,10 @@ ActorAnimation::ActorAnimation(const MWWorld::Ptr& ptr, osg::ref_ptr<osg::Group>
removeEffects(); removeEffects();
} }
ActorAnimation::~ActorAnimation() = default; ActorAnimation::~ActorAnimation()
{
removeFromSceneImpl();
}
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)
{ {
@ -573,9 +576,14 @@ void ActorAnimation::removeHiddenItemLight(const MWWorld::ConstPtr& item)
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

@ -65,6 +65,7 @@ class ActorAnimation : public Animation, public MWWorld::ContainerStoreListener
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

@ -543,7 +543,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)
{ {
@ -1783,6 +1786,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 @@ protected:
*/ */
virtual void addControllers(); virtual void addControllers();
void removeFromSceneImpl();
public: public:
Animation(const MWWorld::Ptr &ptr, osg::ref_ptr<osg::Group> parentNode, Resource::ResourceSystem* resourceSystem); Animation(const MWWorld::Ptr &ptr, osg::ref_ptr<osg::Group> parentNode, Resource::ResourceSystem* resourceSystem);