mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-29 09:32:45 +00:00
Update magic effect particles after building new animation (bug #2254)
This commit is contained in:
parent
e81faf5f2f
commit
53ef345680
@ -491,6 +491,8 @@ namespace MWBase
|
||||
virtual void launchProjectile (MWWorld::Ptr actor, MWWorld::ConstPtr projectile,
|
||||
const osg::Vec3f& worldPos, const osg::Quat& orient, MWWorld::Ptr bow, float speed, float attackStrength) = 0;
|
||||
|
||||
virtual void applyLoopingParticles(const MWWorld::Ptr& ptr) = 0;
|
||||
|
||||
virtual const std::vector<std::string>& getContentFiles() const = 0;
|
||||
|
||||
virtual void breakInvisibility (const MWWorld::Ptr& actor) = 0;
|
||||
|
@ -24,7 +24,6 @@
|
||||
|
||||
#include "../mwrender/animation.hpp"
|
||||
|
||||
#include "magiceffects.hpp"
|
||||
#include "npcstats.hpp"
|
||||
#include "actorutil.hpp"
|
||||
#include "aifollow.hpp"
|
||||
@ -609,7 +608,6 @@ namespace MWMechanics
|
||||
|
||||
std::string texture = magicEffect->mParticle;
|
||||
|
||||
// TODO: VFX are no longer active after saving/reloading the game
|
||||
bool loop = (magicEffect->mData.mFlags & ESM::MagicEffect::ContinuousVfx) != 0;
|
||||
// Note: in case of non actor, a free effect should be fine as well
|
||||
MWRender::Animation* anim = MWBase::Environment::get().getWorld()->getAnimation(target);
|
||||
@ -1314,4 +1312,24 @@ namespace MWMechanics
|
||||
return MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find(it->second)->getString();
|
||||
}
|
||||
|
||||
void ApplyLoopingParticlesVisitor::visit (MWMechanics::EffectKey key,
|
||||
const std::string& /*sourceName*/, const std::string& /*sourceId*/, int /*casterActorId*/,
|
||||
float /*magnitude*/, float /*remainingTime*/, float /*totalTime*/)
|
||||
{
|
||||
const ESM::MagicEffect *magicEffect =
|
||||
MWBase::Environment::get().getWorld()->getStore().get<ESM::MagicEffect>().find(key.mId);
|
||||
|
||||
const ESM::Static* castStatic;
|
||||
if (!magicEffect->mHit.empty())
|
||||
castStatic = MWBase::Environment::get().getWorld()->getStore().get<ESM::Static>().find (magicEffect->mHit);
|
||||
else
|
||||
castStatic = MWBase::Environment::get().getWorld()->getStore().get<ESM::Static>().find ("VFX_DefaultHit");
|
||||
|
||||
std::string texture = magicEffect->mParticle;
|
||||
|
||||
bool loop = (magicEffect->mData.mFlags & ESM::MagicEffect::ContinuousVfx) != 0;
|
||||
MWRender::Animation* anim = MWBase::Environment::get().getWorld()->getAnimation(mActor);
|
||||
if (anim && loop)
|
||||
anim->addEffect("meshes\\" + castStatic->mModel, magicEffect->mIndex, loop, "", texture);
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,8 @@
|
||||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
||||
#include "magiceffects.hpp"
|
||||
|
||||
namespace ESM
|
||||
{
|
||||
struct Spell;
|
||||
@ -119,6 +121,21 @@ namespace MWMechanics
|
||||
bool applyInstantEffect (const MWWorld::Ptr& target, const MWWorld::Ptr& caster, const MWMechanics::EffectKey& effect, float magnitude);
|
||||
};
|
||||
|
||||
class ApplyLoopingParticlesVisitor : public EffectSourceVisitor
|
||||
{
|
||||
private:
|
||||
MWWorld::Ptr mActor;
|
||||
|
||||
public:
|
||||
ApplyLoopingParticlesVisitor(const MWWorld::Ptr& actor)
|
||||
: mActor(actor)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void visit (MWMechanics::EffectKey key,
|
||||
const std::string& /*sourceName*/, const std::string& /*sourceId*/, int /*casterActorId*/,
|
||||
float /*magnitude*/, float /*remainingTime*/ = -1, float /*totalTime*/ = -1);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -79,6 +79,9 @@ namespace
|
||||
|
||||
if (ptr.getClass().isActor())
|
||||
rendering.addWaterRippleEmitter(ptr);
|
||||
|
||||
// Restore effect particles
|
||||
MWBase::Environment::get().getWorld()->applyLoopingParticles(ptr);
|
||||
}
|
||||
|
||||
void updateObjectRotation (const MWWorld::Ptr& ptr, MWPhysics::PhysicsSystem& physics,
|
||||
|
@ -2244,6 +2244,8 @@ namespace MWWorld
|
||||
model = Misc::ResourceHelpers::correctActorModelPath(model, mResourceSystem->getVFS());
|
||||
mPhysics->remove(getPlayerPtr());
|
||||
mPhysics->addActor(getPlayerPtr(), model);
|
||||
|
||||
applyLoopingParticles(player);
|
||||
}
|
||||
|
||||
int World::canRest ()
|
||||
@ -2831,6 +2833,19 @@ namespace MWWorld
|
||||
mProjectileManager->launchMagicBolt(spellId, caster, fallbackDirection);
|
||||
}
|
||||
|
||||
void World::applyLoopingParticles(const MWWorld::Ptr& ptr)
|
||||
{
|
||||
const MWWorld::Class &cls = ptr.getClass();
|
||||
if (cls.isActor())
|
||||
{
|
||||
MWMechanics::ApplyLoopingParticlesVisitor visitor(ptr);
|
||||
cls.getCreatureStats(ptr).getActiveSpells().visitEffectSources(visitor);
|
||||
cls.getCreatureStats(ptr).getSpells().visitEffectSources(visitor);
|
||||
if (cls.hasInventoryStore(ptr))
|
||||
cls.getInventoryStore(ptr).visitEffectSources(visitor);
|
||||
}
|
||||
}
|
||||
|
||||
const std::vector<std::string>& World::getContentFiles() const
|
||||
{
|
||||
return mContentFiles;
|
||||
|
@ -604,6 +604,7 @@ namespace MWWorld
|
||||
void launchProjectile (MWWorld::Ptr actor, MWWorld::ConstPtr projectile,
|
||||
const osg::Vec3f& worldPos, const osg::Quat& orient, MWWorld::Ptr bow, float speed, float attackStrength) override;
|
||||
|
||||
void applyLoopingParticles(const MWWorld::Ptr& ptr);
|
||||
|
||||
const std::vector<std::string>& getContentFiles() const override;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user