mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-21 06:23:53 +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));
|
||||
else if (!mXRotations.empty() || !mYRotations.empty() || !mZRotations.empty())
|
||||
node->setRotation(getXYZRotation(time));
|
||||
else
|
||||
node->setRotation(node->mRotationScale);
|
||||
|
||||
if (!mScales.empty())
|
||||
node->setScale(mScales.interpKey(time));
|
||||
|
||||
if (!mTranslations.empty())
|
||||
node->setTranslation(mTranslations.interpKey(time));
|
||||
}
|
||||
|
|
|
@ -18,16 +18,13 @@ namespace NifOsg
|
|||
|
||||
void MatrixTransform::setScale(float scale)
|
||||
{
|
||||
if (mScale == scale)
|
||||
return;
|
||||
// Update the decomposed scale.
|
||||
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 j = 0; j < 3; ++j)
|
||||
_matrix(i,j) = mRotationScale.mValues[j][i] * scale; // NB: column/row major difference
|
||||
|
||||
// Update the current decomposed scale.
|
||||
mScale = scale;
|
||||
_matrix(i,j) = mRotationScale.mValues[j][i] * mScale; // NB: column/row major difference
|
||||
|
||||
_inverseDirty = true;
|
||||
dirtyBound();
|
||||
|
@ -37,6 +34,7 @@ namespace NifOsg
|
|||
{
|
||||
// First override the rotation ignoring the scale.
|
||||
_matrix.setRotate(rotation);
|
||||
|
||||
for (int i = 0; i < 3; ++i)
|
||||
{
|
||||
for (int j = 0; j < 3; ++j)
|
||||
|
@ -51,6 +49,20 @@ namespace NifOsg
|
|||
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)
|
||||
{
|
||||
// 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.
|
||||
void setScale(float scale);
|
||||
void setRotation(const osg::Quat &rotation);
|
||||
void setRotation(const Nif::Matrix3 &rotation);
|
||||
void setTranslation(const osg::Vec3f &translation);
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue