mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-03-30 07:21:12 +00:00
Fix blending with additional offsets (sneaking issue)
This commit is contained in:
parent
9beb380c7d
commit
ddbd87e2a1
@ -1,4 +1,5 @@
|
|||||||
#include "animblendcontroller.hpp"
|
#include "animblendcontroller.hpp"
|
||||||
|
#include "rotatecontroller.hpp"
|
||||||
|
|
||||||
#include <components/debug/debuglog.hpp>
|
#include <components/debug/debuglog.hpp>
|
||||||
|
|
||||||
@ -308,10 +309,31 @@ namespace MWRender
|
|||||||
{
|
{
|
||||||
mBlendTrigger = false;
|
mBlendTrigger = false;
|
||||||
mBlendStartTime = time;
|
mBlendStartTime = time;
|
||||||
// Nif mRotation is used here because it's unaffected by the side-effects of RotationController
|
|
||||||
|
// Nif mRotationScale is used here because it's unaffected by the side-effects of RotationController
|
||||||
mBlendStartRot = node->mRotationScale.toOsgMatrix().getRotate();
|
mBlendStartRot = node->mRotationScale.toOsgMatrix().getRotate();
|
||||||
mBlendStartTrans = node->getMatrix().getTrans();
|
mBlendStartTrans = node->getMatrix().getTrans();
|
||||||
mBlendStartScale = node->mScale;
|
mBlendStartScale = node->mScale;
|
||||||
|
|
||||||
|
// Subtract any rotate controller's offset from start transform (if it appears after this callback)
|
||||||
|
// this is required otherwise the blend start will be with an offset, then offset could be applied again
|
||||||
|
// fixes an issue with camera jumping during first person sneak jumping camera
|
||||||
|
osg::Callback* updateCb = node->getUpdateCallback()->getNestedCallback();
|
||||||
|
while (updateCb)
|
||||||
|
{
|
||||||
|
MWRender::RotateController* rotateController = dynamic_cast<MWRender::RotateController*>(updateCb);
|
||||||
|
if (rotateController)
|
||||||
|
{
|
||||||
|
const osg::Quat rotate = rotateController->getRotate();
|
||||||
|
const osg::Vec3f offset = rotateController->getOffset();
|
||||||
|
const osg::Quat worldOrient = rotateController->getWorldOrientation(node) * rotate.inverse();
|
||||||
|
const osg::Quat worldOrientInverse = worldOrient.inverse();
|
||||||
|
|
||||||
|
mBlendStartTrans -= worldOrientInverse * offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
updateCb = updateCb->getNestedCallback();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
calculateInterpFactor(time);
|
calculateInterpFactor(time);
|
||||||
|
@ -20,10 +20,20 @@ namespace MWRender
|
|||||||
public:
|
public:
|
||||||
RotateController(osg::Node* relativeTo);
|
RotateController(osg::Node* relativeTo);
|
||||||
|
|
||||||
|
osg::Quat getWorldOrientation(osg::Node* node);
|
||||||
|
|
||||||
void setEnabled(bool enabled);
|
void setEnabled(bool enabled);
|
||||||
void setOffset(const osg::Vec3f& offset);
|
void setOffset(const osg::Vec3f& offset);
|
||||||
void setRotate(const osg::Quat& rotate);
|
void setRotate(const osg::Quat& rotate);
|
||||||
|
|
||||||
|
const osg::Vec3f getOffset() const {
|
||||||
|
return mOffset;
|
||||||
|
}
|
||||||
|
|
||||||
|
const osg::Quat getRotate() const {
|
||||||
|
return mRotate;
|
||||||
|
}
|
||||||
|
|
||||||
void operator()(osg::MatrixTransform* node, osg::NodeVisitor* nv);
|
void operator()(osg::MatrixTransform* node, osg::NodeVisitor* nv);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user