1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-25 06:35:30 +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 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)
{
MWBase::World *world = MWBase::Environment::get().getWorld();

View File

@ -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);

View File

@ -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);
}

View File

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

View File

@ -2135,4 +2135,9 @@ namespace MWWorld
// 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 void castSpell (const MWWorld::Ptr& actor);
virtual void updateAnimParts(const MWWorld::Ptr& ptr);
};
}