1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-26 09:35:28 +00:00

Update actor model on inventory change

This commit is contained in:
Emanuel Guevel 2013-10-25 22:16:52 +02:00
parent f428921b93
commit 467bd91651
7 changed files with 44 additions and 1 deletions

View File

@ -413,6 +413,8 @@ namespace MWBase
virtual bool toggleGodMode() = 0; virtual bool toggleGodMode() = 0;
virtual void castSpell (const MWWorld::Ptr& actor) = 0; virtual void castSpell (const MWWorld::Ptr& actor) = 0;
virtual void updateAnimParts(const MWWorld::Ptr& ptr) = 0;
}; };
} }

View File

@ -327,6 +327,19 @@ void RenderingManager::rebuildPtr(const MWWorld::Ptr &ptr)
} }
} }
void RenderingManager::updateAnimParts(const MWWorld::Ptr& ptr)
{
NpcAnimation *anim = NULL;
if(ptr.getRefData().getHandle() == "player")
anim = mPlayerAnimation;
else if(MWWorld::Class::get(ptr).isActor())
anim = dynamic_cast<NpcAnimation*>(mActors.getAnimation(ptr));
if(anim)
anim->updateParts();
}
void RenderingManager::update (float duration, bool paused) void RenderingManager::update (float duration, bool paused)
{ {
MWBase::World *world = MWBase::Environment::get().getWorld(); MWBase::World *world = MWBase::Environment::get().getWorld();

View File

@ -141,6 +141,9 @@ public:
/// and equipment. /// and equipment.
void rebuildPtr(const MWWorld::Ptr &ptr); void rebuildPtr(const MWWorld::Ptr &ptr);
/// Update actor model parts.
void updateAnimParts(const MWWorld::Ptr &ptr);
void update (float duration, bool paused); void update (float duration, bool paused);
void setAmbientColour(const Ogre::ColourValue& colour); void setAmbientColour(const Ogre::ColourValue& colour);

View File

@ -41,6 +41,7 @@ void MWWorld::InventoryStore::initSlots (TSlots& slots)
MWWorld::InventoryStore::InventoryStore() : mMagicEffectsUpToDate (false) MWWorld::InventoryStore::InventoryStore() : mMagicEffectsUpToDate (false)
, mSelectedEnchantItem(end()) , mSelectedEnchantItem(end())
, mActorModelUpdateEnabled (true)
{ {
initSlots (mSlots); initSlots (mSlots);
} }
@ -114,6 +115,8 @@ void MWWorld::InventoryStore::equip (int slot, const ContainerStoreIterator& ite
mSlots[slot] = iterator; mSlots[slot] = iterator;
flagAsModified(); flagAsModified();
updateActorModel(actor);
} }
void MWWorld::InventoryStore::unequipAll(const MWWorld::Ptr& actor) void MWWorld::InventoryStore::unequipAll(const MWWorld::Ptr& actor)
@ -148,6 +151,9 @@ void MWWorld::InventoryStore::autoEquip (const MWWorld::Ptr& npc)
TSlots slots; TSlots slots;
initSlots (slots); initSlots (slots);
// Disable model update during auto-equip
mActorModelUpdateEnabled = false;
for (ContainerStoreIterator iter (begin()); iter!=end(); ++iter) for (ContainerStoreIterator iter (begin()); iter!=end(); ++iter)
{ {
Ptr test = *iter; Ptr test = *iter;
@ -236,9 +242,12 @@ void MWWorld::InventoryStore::autoEquip (const MWWorld::Ptr& npc)
changed = true; changed = true;
} }
mActorModelUpdateEnabled = true;
if (changed) if (changed)
{ {
mSlots.swap (slots); mSlots.swap (slots);
updateActorModel(npc);
flagAsModified(); flagAsModified();
} }
} }
@ -379,7 +388,7 @@ MWWorld::ContainerStoreIterator MWWorld::InventoryStore::unequipSlot(int slot, c
} }
} }
/// \todo update actor model updateActorModel(actor);
return retval; return retval;
} }
@ -398,3 +407,9 @@ MWWorld::ContainerStoreIterator MWWorld::InventoryStore::unequipItem(const MWWor
throw std::runtime_error ("attempt to unequip an item that is not currently equipped"); throw std::runtime_error ("attempt to unequip an item that is not currently equipped");
} }
void MWWorld::InventoryStore::updateActorModel(const MWWorld::Ptr& actor)
{
if (mActorModelUpdateEnabled)
MWBase::Environment::get().getWorld()->updateAnimParts(actor);
}

View File

@ -45,6 +45,7 @@ namespace MWWorld
mutable MWMechanics::MagicEffects mMagicEffects; mutable MWMechanics::MagicEffects mMagicEffects;
mutable bool mMagicEffectsUpToDate; mutable bool mMagicEffectsUpToDate;
bool mActorModelUpdateEnabled;
typedef std::vector<ContainerStoreIterator> TSlots; typedef std::vector<ContainerStoreIterator> TSlots;
@ -57,6 +58,8 @@ namespace MWWorld
void initSlots (TSlots& slots); void initSlots (TSlots& slots);
void updateActorModel (const Ptr& actor);
public: public:
InventoryStore(); InventoryStore();

View File

@ -2135,4 +2135,9 @@ namespace MWWorld
// TODO: RT_Range, RT_Touch // TODO: RT_Range, RT_Touch
} }
} }
void World::updateAnimParts(const Ptr& actor)
{
mRendering->updateAnimParts(actor);
}
} }

View File

@ -473,6 +473,8 @@ namespace MWWorld
virtual bool toggleGodMode(); virtual bool toggleGodMode();
virtual void castSpell (const MWWorld::Ptr& actor); virtual void castSpell (const MWWorld::Ptr& actor);
virtual void updateAnimParts(const MWWorld::Ptr& ptr);
}; };
} }