Merge branch 'harvest' into 'master'

Do not recreate animation object when harvesting a plant

See merge request OpenMW/openmw!4744
This commit is contained in:
Alexei Kotov 2025-07-06 22:24:20 +03:00
commit abbbeefdbd
3 changed files with 19 additions and 9 deletions

View File

@ -2095,6 +2095,12 @@ namespace MWRender
if (Settings::game().mGraphicHerbalism && ptr.getRefData().getCustomData() != nullptr
&& ObjectAnimation::canBeHarvested())
{
harvest(ptr);
}
}
void ObjectAnimation::harvest(const MWWorld::Ptr& ptr)
{
const MWWorld::ContainerStore& store = ptr.getClass().getContainerStore(ptr);
if (!store.hasVisibleItems())
@ -2103,7 +2109,6 @@ namespace MWRender
mObjectRoot->accept(visitor);
}
}
}
bool ObjectAnimation::canBeHarvested() const
{

View File

@ -483,6 +483,7 @@ namespace MWRender
virtual void setAccurateAiming(bool enabled) {}
virtual bool canBeHarvested() const { return false; }
virtual void harvest(const MWWorld::Ptr& ptr) {}
virtual void removeFromScene();
@ -498,6 +499,7 @@ namespace MWRender
bool animated, bool allowLight);
bool canBeHarvested() const override;
void harvest(const MWWorld::Ptr& ptr) override;
};
class UpdateVfxCallback : public SceneUtil::NodeCallback<UpdateVfxCallback>

View File

@ -11,6 +11,8 @@
#include "../mwbase/windowmanager.hpp"
#include "../mwbase/world.hpp"
#include "../mwrender/animation.hpp"
#include "class.hpp"
#include "containerstore.hpp"
@ -89,8 +91,9 @@ namespace MWWorld
MWBase::Environment::get().getWindowManager()->messageBox(tooltip);
}
// Update animation object
MWBase::Environment::get().getWorld()->disable(target);
MWBase::Environment::get().getWorld()->enable(target);
auto world = MWBase::Environment::get().getWorld();
MWRender::Animation* anim = world->getAnimation(target);
if (anim != nullptr)
anim->harvest(target);
}
}