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:
parent
c1f4448547
commit
08f06c6c2d
2 changed files with 19 additions and 9 deletions
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
|
Loading…
Reference in a new issue