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

move
scrawl 9 years ago
parent c1f4448547
commit 08f06c6c2d

@ -182,23 +182,30 @@ void WeaponAnimation::deleteControllers()
void WeaponAnimation::configureControllers(float characterPitchRadians)
{
if (!mSpineControllers[0])
return;
if (mPitchFactor == 0.f || characterPitchRadians == 0.f)
{
for (int i=0; i<2; ++i)
mSpineControllers[i]->setEnabled(false);
setControllerEnabled(false);
return;
}
float pitch = characterPitchRadians * mPitchFactor;
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)
{
mSpineControllers[i]->setRotate(rotate);
mSpineControllers[i]->setEnabled(true);
}
if (mSpineControllers[i])
mSpineControllers[i]->setRotate(rotate);
}
void WeaponAnimation::setControllerEnabled(bool enabled)
{
for (int i=0; i<2; ++i)
if (mSpineControllers[i])
mSpineControllers[i]->setEnabled(enabled);
}
}

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

Loading…
Cancel
Save