mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-03 17:15:35 +00:00
Crash fix for creatures with no skeleton base (Fixes #2419)
This commit is contained in:
parent
0ad514b29b
commit
191c0104f6
3 changed files with 37 additions and 20 deletions
|
@ -1271,7 +1271,11 @@ void Animation::addEffect(const std::string &model, int effectId, bool loop, con
|
|||
if (bonename.empty())
|
||||
params.mObjects = NifOgre::Loader::createObjects(mInsert, model);
|
||||
else
|
||||
{
|
||||
if (!mSkelBase)
|
||||
return;
|
||||
params.mObjects = NifOgre::Loader::createObjects(mSkelBase, bonename, "", mInsert, model);
|
||||
}
|
||||
|
||||
setRenderProperties(params.mObjects, RV_Effects,
|
||||
RQG_Main, RQG_Alpha, 0.f, false, NULL);
|
||||
|
|
|
@ -88,6 +88,9 @@ void CreatureWeaponAnimation::updateParts()
|
|||
|
||||
void CreatureWeaponAnimation::updatePart(NifOgre::ObjectScenePtr& scene, int slot)
|
||||
{
|
||||
if (!mSkelBase)
|
||||
return;
|
||||
|
||||
MWWorld::InventoryStore& inv = mPtr.getClass().getInventoryStore(mPtr);
|
||||
MWWorld::ContainerStoreIterator it = inv.getSlot(slot);
|
||||
|
||||
|
@ -181,6 +184,8 @@ void CreatureWeaponAnimation::releaseArrow()
|
|||
Ogre::Vector3 CreatureWeaponAnimation::runAnimation(float duration)
|
||||
{
|
||||
Ogre::Vector3 ret = Animation::runAnimation(duration);
|
||||
|
||||
if (mSkelBase)
|
||||
pitchSkeleton(mPtr.getRefData().getPosition().rot[0], mSkelBase->getSkeleton());
|
||||
|
||||
if (!mWeapon.isNull())
|
||||
|
|
|
@ -336,6 +336,9 @@ void NpcAnimation::updateNpcBase()
|
|||
|
||||
void NpcAnimation::updateParts()
|
||||
{
|
||||
if (!mSkelBase)
|
||||
return;
|
||||
|
||||
mAlpha = 1.f;
|
||||
const MWWorld::Class &cls = mPtr.getClass();
|
||||
|
||||
|
@ -626,6 +629,8 @@ Ogre::Vector3 NpcAnimation::runAnimation(float timepassed)
|
|||
|
||||
mHeadAnimationTime->update(timepassed);
|
||||
|
||||
if (mSkelBase)
|
||||
{
|
||||
Ogre::SkeletonInstance *baseinst = mSkelBase->getSkeleton();
|
||||
if(mViewMode == VM_FirstPerson)
|
||||
{
|
||||
|
@ -646,6 +651,7 @@ Ogre::Vector3 NpcAnimation::runAnimation(float timepassed)
|
|||
if (node)
|
||||
node->rotate(Ogre::Quaternion(mHeadYaw, Ogre::Vector3::UNIT_Z) * Ogre::Quaternion(mHeadPitch, Ogre::Vector3::UNIT_X), Ogre::Node::TS_WORLD);
|
||||
}
|
||||
}
|
||||
mFirstPersonOffset = 0.f; // reset the X, Y, Z offset for the next frame.
|
||||
|
||||
for(size_t i = 0;i < ESM::PRT_Count;i++)
|
||||
|
@ -659,7 +665,9 @@ Ogre::Vector3 NpcAnimation::runAnimation(float timepassed)
|
|||
if (!isSkinned(mObjectParts[i]))
|
||||
continue;
|
||||
|
||||
updateSkeletonInstance(baseinst, mObjectParts[i]->mSkelBase->getSkeleton());
|
||||
if (mSkelBase)
|
||||
updateSkeletonInstance(mSkelBase->getSkeleton(), mObjectParts[i]->mSkelBase->getSkeleton());
|
||||
|
||||
mObjectParts[i]->mSkelBase->getAllAnimationStates()->_notifyDirty();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue