mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-21 10:23:56 +00:00
Merge branch 'rotateproperlydummkopf' into 'master'
Always update the current matrix in KeyframeController (#6811) Closes #6811 See merge request OpenMW/openmw!2000
This commit is contained in:
commit
28746b5d18
3 changed files with 23 additions and 7 deletions
|
@ -171,9 +171,12 @@ void KeyframeController::operator() (NifOsg::MatrixTransform* node, osg::NodeVis
|
||||||
node->setRotation(mRotations.interpKey(time));
|
node->setRotation(mRotations.interpKey(time));
|
||||||
else if (!mXRotations.empty() || !mYRotations.empty() || !mZRotations.empty())
|
else if (!mXRotations.empty() || !mYRotations.empty() || !mZRotations.empty())
|
||||||
node->setRotation(getXYZRotation(time));
|
node->setRotation(getXYZRotation(time));
|
||||||
|
else
|
||||||
|
node->setRotation(node->mRotationScale);
|
||||||
|
|
||||||
if (!mScales.empty())
|
if (!mScales.empty())
|
||||||
node->setScale(mScales.interpKey(time));
|
node->setScale(mScales.interpKey(time));
|
||||||
|
|
||||||
if (!mTranslations.empty())
|
if (!mTranslations.empty())
|
||||||
node->setTranslation(mTranslations.interpKey(time));
|
node->setTranslation(mTranslations.interpKey(time));
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,16 +18,13 @@ namespace NifOsg
|
||||||
|
|
||||||
void MatrixTransform::setScale(float scale)
|
void MatrixTransform::setScale(float scale)
|
||||||
{
|
{
|
||||||
if (mScale == scale)
|
// Update the decomposed scale.
|
||||||
return;
|
mScale = scale;
|
||||||
|
|
||||||
// Rescale the node using the known decomposed rotation.
|
// Rescale the node using the known components.
|
||||||
for (int i = 0; i < 3; ++i)
|
for (int i = 0; i < 3; ++i)
|
||||||
for (int j = 0; j < 3; ++j)
|
for (int j = 0; j < 3; ++j)
|
||||||
_matrix(i,j) = mRotationScale.mValues[j][i] * scale; // NB: column/row major difference
|
_matrix(i,j) = mRotationScale.mValues[j][i] * mScale; // NB: column/row major difference
|
||||||
|
|
||||||
// Update the current decomposed scale.
|
|
||||||
mScale = scale;
|
|
||||||
|
|
||||||
_inverseDirty = true;
|
_inverseDirty = true;
|
||||||
dirtyBound();
|
dirtyBound();
|
||||||
|
@ -37,6 +34,7 @@ namespace NifOsg
|
||||||
{
|
{
|
||||||
// First override the rotation ignoring the scale.
|
// First override the rotation ignoring the scale.
|
||||||
_matrix.setRotate(rotation);
|
_matrix.setRotate(rotation);
|
||||||
|
|
||||||
for (int i = 0; i < 3; ++i)
|
for (int i = 0; i < 3; ++i)
|
||||||
{
|
{
|
||||||
for (int j = 0; j < 3; ++j)
|
for (int j = 0; j < 3; ++j)
|
||||||
|
@ -51,6 +49,20 @@ namespace NifOsg
|
||||||
dirtyBound();
|
dirtyBound();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MatrixTransform::setRotation(const Nif::Matrix3 &rotation)
|
||||||
|
{
|
||||||
|
// Update the decomposed rotation.
|
||||||
|
mRotationScale = rotation;
|
||||||
|
|
||||||
|
// Reorient the node using the known components.
|
||||||
|
for (int i = 0; i < 3; ++i)
|
||||||
|
for (int j = 0; j < 3; ++j)
|
||||||
|
_matrix(i,j) = mRotationScale.mValues[j][i] * mScale; // NB: column/row major difference
|
||||||
|
|
||||||
|
_inverseDirty = true;
|
||||||
|
dirtyBound();
|
||||||
|
}
|
||||||
|
|
||||||
void MatrixTransform::setTranslation(const osg::Vec3f &translation)
|
void MatrixTransform::setTranslation(const osg::Vec3f &translation)
|
||||||
{
|
{
|
||||||
// The translation is independent from the rotation and scale so we can apply it directly.
|
// The translation is independent from the rotation and scale so we can apply it directly.
|
||||||
|
|
|
@ -30,6 +30,7 @@ namespace NifOsg
|
||||||
// unless you're sure you know what you are doing.
|
// unless you're sure you know what you are doing.
|
||||||
void setScale(float scale);
|
void setScale(float scale);
|
||||||
void setRotation(const osg::Quat &rotation);
|
void setRotation(const osg::Quat &rotation);
|
||||||
|
void setRotation(const Nif::Matrix3 &rotation);
|
||||||
void setTranslation(const osg::Vec3f &translation);
|
void setTranslation(const osg::Vec3f &translation);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue