mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-15 15:49:56 +00:00
46825e8a4d
This makes sure it's never erroneously optimized out. NodeIndexHolders don't need to be cloned as their record index is never supposed to be changed.
56 lines
1.5 KiB
C++
56 lines
1.5 KiB
C++
#include "matrixtransform.hpp"
|
|
|
|
namespace NifOsg
|
|
{
|
|
MatrixTransform::MatrixTransform()
|
|
: osg::MatrixTransform()
|
|
{
|
|
}
|
|
|
|
MatrixTransform::MatrixTransform(const Nif::Transformation &trafo)
|
|
: osg::MatrixTransform(trafo.toMatrix())
|
|
, mScale(trafo.scale)
|
|
, mRotationScale(trafo.rotation)
|
|
{
|
|
}
|
|
|
|
MatrixTransform::MatrixTransform(const MatrixTransform ©, const osg::CopyOp ©op)
|
|
: osg::MatrixTransform(copy, copyop)
|
|
, mScale(copy.mScale)
|
|
, mRotationScale(copy.mRotationScale)
|
|
{
|
|
}
|
|
|
|
void MatrixTransform::applyCurrentRotation()
|
|
{
|
|
for (int i = 0; i < 3; ++i)
|
|
for (int j = 0; j < 3; ++j)
|
|
_matrix(j,i) = mRotationScale.mValues[i][j]; // NB column/row major difference
|
|
}
|
|
|
|
void MatrixTransform::applyCurrentScale()
|
|
{
|
|
for (int i = 0; i < 3; ++i)
|
|
for (int j = 0; j < 3; ++j)
|
|
_matrix(i,j) *= mScale;
|
|
}
|
|
|
|
void MatrixTransform::updateRotation(const osg::Quat& rotation)
|
|
{
|
|
_matrix.setRotate(rotation);
|
|
for (int i = 0; i < 3; ++i)
|
|
for (int j = 0; j < 3; ++j)
|
|
mRotationScale.mValues[i][j] = _matrix(j,i); // NB column/row major difference
|
|
}
|
|
|
|
void MatrixTransform::updateScale(const float scale)
|
|
{
|
|
mScale = scale;
|
|
applyCurrentScale();
|
|
}
|
|
|
|
void MatrixTransform::setTranslation(const osg::Vec3f& translation)
|
|
{
|
|
_matrix.setTrans(translation);
|
|
}
|
|
}
|