forked from teamnwah/openmw-tes3coop
Fix NPC part attachment
This commit is contained in:
parent
3eaf937a1f
commit
ecbf1568a1
2 changed files with 20 additions and 14 deletions
|
@ -133,10 +133,10 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, Ogre::SceneNode* node, MWWor
|
|||
if(mNpc->mModel.length() > 0)
|
||||
insertSkeletonSource("meshes\\"+Misc::StringUtils::lowerCase(mNpc->mModel));
|
||||
|
||||
updateParts();
|
||||
updateParts(true);
|
||||
}
|
||||
|
||||
void NpcAnimation::updateParts()
|
||||
void NpcAnimation::updateParts(bool forceupdate)
|
||||
{
|
||||
static const struct {
|
||||
int numRemoveParts; // Max: 1
|
||||
|
@ -212,11 +212,21 @@ void NpcAnimation::updateParts()
|
|||
};
|
||||
static const size_t slotlistsize = sizeof(slotlist)/sizeof(slotlist[0]);
|
||||
|
||||
for(size_t i = 0;!forceupdate && i < slotlistsize;i++)
|
||||
{
|
||||
MWWorld::ContainerStoreIterator iter = mInv.getSlot(slotlist[i].slot);
|
||||
if(this->*slotlist[i].part != iter)
|
||||
{
|
||||
forceupdate = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!forceupdate)
|
||||
return;
|
||||
|
||||
for(size_t i = 0;i < slotlistsize;i++)
|
||||
{
|
||||
MWWorld::ContainerStoreIterator iter = mInv.getSlot(slotlist[i].slot);
|
||||
if(this->*slotlist[i].part == iter)
|
||||
continue;
|
||||
|
||||
this->*slotlist[i].part = iter;
|
||||
removePartGroup(slotlist[i].slot);
|
||||
|
@ -332,12 +342,12 @@ NifOgre::EntityList NpcAnimation::insertBoundedPart(const std::string &mesh, int
|
|||
|
||||
Ogre::Vector3 NpcAnimation::runAnimation(float timepassed)
|
||||
{
|
||||
if(mTimeToChange > .2)
|
||||
if(mTimeToChange <= 0.0f)
|
||||
{
|
||||
mTimeToChange = 0;
|
||||
mTimeToChange = 0.2f;
|
||||
updateParts();
|
||||
}
|
||||
mTimeToChange += timepassed;
|
||||
mTimeToChange -= timepassed;
|
||||
|
||||
Ogre::Vector3 ret = Animation::runAnimation(timepassed);
|
||||
const Ogre::SkeletonInstance *skelsrc = mEntityList.mSkelBase->getSkeleton();
|
||||
|
@ -441,9 +451,4 @@ void NpcAnimation::addPartGroup(int group, int priority, const std::vector<ESM::
|
|||
}
|
||||
}
|
||||
|
||||
void NpcAnimation::forceUpdate ()
|
||||
{
|
||||
updateParts();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ private:
|
|||
int mPartPriorities[sPartListSize];
|
||||
|
||||
NifOgre::EntityList insertBoundedPart(const std::string &mesh, int group, const std::string &bonename);
|
||||
void updateParts();
|
||||
void updateParts(bool forceupdate = false);
|
||||
void removeEntities(NifOgre::EntityList &entities);
|
||||
void removeIndividualPart(int type);
|
||||
void reserveIndividualPart(int type, int group, int priority);
|
||||
|
@ -73,7 +73,8 @@ public:
|
|||
|
||||
virtual Ogre::Vector3 runAnimation(float timepassed);
|
||||
|
||||
void forceUpdate();
|
||||
void forceUpdate()
|
||||
{ updateParts(true); }
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue