diff --git a/apps/openmw/mwbase/world.hpp b/apps/openmw/mwbase/world.hpp index 4eb9d30880..ddf8417448 100644 --- a/apps/openmw/mwbase/world.hpp +++ b/apps/openmw/mwbase/world.hpp @@ -413,6 +413,8 @@ namespace MWBase virtual bool toggleGodMode() = 0; virtual void castSpell (const MWWorld::Ptr& actor) = 0; + + virtual void updateAnimParts(const MWWorld::Ptr& ptr) = 0; }; } diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index 93425191dd..817a2d236d 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -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(mActors.getAnimation(ptr)); + + if(anim) + anim->updateParts(); +} + void RenderingManager::update (float duration, bool paused) { MWBase::World *world = MWBase::Environment::get().getWorld(); diff --git a/apps/openmw/mwrender/renderingmanager.hpp b/apps/openmw/mwrender/renderingmanager.hpp index 2d08139128..8913e0a789 100644 --- a/apps/openmw/mwrender/renderingmanager.hpp +++ b/apps/openmw/mwrender/renderingmanager.hpp @@ -141,6 +141,9 @@ public: /// and equipment. void rebuildPtr(const MWWorld::Ptr &ptr); + /// Update actor model parts. + void updateAnimParts(const MWWorld::Ptr &ptr); + void update (float duration, bool paused); void setAmbientColour(const Ogre::ColourValue& colour); diff --git a/apps/openmw/mwworld/inventorystore.cpp b/apps/openmw/mwworld/inventorystore.cpp index 4291c120f3..dbb5a80b54 100644 --- a/apps/openmw/mwworld/inventorystore.cpp +++ b/apps/openmw/mwworld/inventorystore.cpp @@ -41,6 +41,7 @@ void MWWorld::InventoryStore::initSlots (TSlots& slots) MWWorld::InventoryStore::InventoryStore() : mMagicEffectsUpToDate (false) , mSelectedEnchantItem(end()) + , mActorModelUpdateEnabled (true) { initSlots (mSlots); } @@ -114,6 +115,8 @@ void MWWorld::InventoryStore::equip (int slot, const ContainerStoreIterator& ite mSlots[slot] = iterator; flagAsModified(); + + updateActorModel(actor); } void MWWorld::InventoryStore::unequipAll(const MWWorld::Ptr& actor) @@ -148,6 +151,9 @@ void MWWorld::InventoryStore::autoEquip (const MWWorld::Ptr& npc) TSlots slots; initSlots (slots); + // Disable model update during auto-equip + mActorModelUpdateEnabled = false; + for (ContainerStoreIterator iter (begin()); iter!=end(); ++iter) { Ptr test = *iter; @@ -236,9 +242,12 @@ void MWWorld::InventoryStore::autoEquip (const MWWorld::Ptr& npc) changed = true; } + mActorModelUpdateEnabled = true; + if (changed) { mSlots.swap (slots); + updateActorModel(npc); flagAsModified(); } } @@ -379,7 +388,7 @@ MWWorld::ContainerStoreIterator MWWorld::InventoryStore::unequipSlot(int slot, c } } - /// \todo update actor model + updateActorModel(actor); 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"); } + +void MWWorld::InventoryStore::updateActorModel(const MWWorld::Ptr& actor) +{ + if (mActorModelUpdateEnabled) + MWBase::Environment::get().getWorld()->updateAnimParts(actor); +} diff --git a/apps/openmw/mwworld/inventorystore.hpp b/apps/openmw/mwworld/inventorystore.hpp index 199c422435..02d65d54a0 100644 --- a/apps/openmw/mwworld/inventorystore.hpp +++ b/apps/openmw/mwworld/inventorystore.hpp @@ -45,6 +45,7 @@ namespace MWWorld mutable MWMechanics::MagicEffects mMagicEffects; mutable bool mMagicEffectsUpToDate; + bool mActorModelUpdateEnabled; typedef std::vector TSlots; @@ -57,6 +58,8 @@ namespace MWWorld void initSlots (TSlots& slots); + void updateActorModel (const Ptr& actor); + public: InventoryStore(); diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index e1a2fb096d..be71bebeee 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -2135,4 +2135,9 @@ namespace MWWorld // TODO: RT_Range, RT_Touch } } + + void World::updateAnimParts(const Ptr& actor) + { + mRendering->updateAnimParts(actor); + } } diff --git a/apps/openmw/mwworld/worldimp.hpp b/apps/openmw/mwworld/worldimp.hpp index cd982aceee..602d8d5e74 100644 --- a/apps/openmw/mwworld/worldimp.hpp +++ b/apps/openmw/mwworld/worldimp.hpp @@ -473,6 +473,8 @@ namespace MWWorld virtual bool toggleGodMode(); virtual void castSpell (const MWWorld::Ptr& actor); + + virtual void updateAnimParts(const MWWorld::Ptr& ptr); }; }