1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-16 19:19:56 +00:00

Fix a crash that could occur with actors that define 'bip01 spine1' but do not define 'bip01 spine2' (Fixes #3223).

This commit is contained in:
scrawl 2016-03-01 16:57:11 +01:00
parent c1f4448547
commit 08f06c6c2d
2 changed files with 19 additions and 9 deletions

View file

@ -182,23 +182,30 @@ void WeaponAnimation::deleteControllers()
void WeaponAnimation::configureControllers(float characterPitchRadians) void WeaponAnimation::configureControllers(float characterPitchRadians)
{ {
if (!mSpineControllers[0])
return;
if (mPitchFactor == 0.f || characterPitchRadians == 0.f) if (mPitchFactor == 0.f || characterPitchRadians == 0.f)
{ {
for (int i=0; i<2; ++i) setControllerEnabled(false);
mSpineControllers[i]->setEnabled(false);
return; return;
} }
float pitch = characterPitchRadians * mPitchFactor; float pitch = characterPitchRadians * mPitchFactor;
osg::Quat rotate (pitch/2, osg::Vec3f(-1,0,0)); osg::Quat rotate (pitch/2, osg::Vec3f(-1,0,0));
setControllerRotate(rotate);
setControllerEnabled(true);
}
void WeaponAnimation::setControllerRotate(const osg::Quat& rotate)
{
for (int i=0; i<2; ++i) for (int i=0; i<2; ++i)
{ if (mSpineControllers[i])
mSpineControllers[i]->setRotate(rotate); mSpineControllers[i]->setRotate(rotate);
mSpineControllers[i]->setEnabled(true); }
}
void WeaponAnimation::setControllerEnabled(bool enabled)
{
for (int i=0; i<2; ++i)
if (mSpineControllers[i])
mSpineControllers[i]->setEnabled(enabled);
} }
} }

View file

@ -52,6 +52,9 @@ namespace MWRender
osg::ref_ptr<RotateController> mSpineControllers[2]; osg::ref_ptr<RotateController> mSpineControllers[2];
void setControllerRotate(const osg::Quat& rotate);
void setControllerEnabled(bool enabled);
virtual osg::Group* getArrowBone() = 0; virtual osg::Group* getArrowBone() = 0;
virtual osg::Node* getWeaponNode() = 0; virtual osg::Node* getWeaponNode() = 0;
virtual Resource::ResourceSystem* getResourceSystem() = 0; virtual Resource::ResourceSystem* getResourceSystem() = 0;