|
@@ -99,43 +99,27 @@ const char* Transform::getTypeName() const
|
|
|
|
|
|
|
|
const Matrix& Transform::getMatrix() const
|
|
const Matrix& Transform::getMatrix() const
|
|
|
{
|
|
{
|
|
|
- if (_matrixDirtyBits)
|
|
|
|
|
|
|
+ if (_matrixDirtyBits & (DIRTY_TRANSLATION | DIRTY_ROTATION | DIRTY_SCALE))
|
|
|
{
|
|
{
|
|
|
if (!isStatic())
|
|
if (!isStatic())
|
|
|
{
|
|
{
|
|
|
- bool hasTranslation = !_translation.isZero();
|
|
|
|
|
bool hasScale = !_scale.isOne();
|
|
bool hasScale = !_scale.isOne();
|
|
|
bool hasRotation = !_rotation.isIdentity();
|
|
bool hasRotation = !_rotation.isIdentity();
|
|
|
|
|
|
|
|
// Compose the matrix in TRS order since we use column-major matrices with column vectors and
|
|
// Compose the matrix in TRS order since we use column-major matrices with column vectors and
|
|
|
// multiply M*v (as opposed to XNA and DirectX that use row-major matrices with row vectors and multiply v*M).
|
|
// multiply M*v (as opposed to XNA and DirectX that use row-major matrices with row vectors and multiply v*M).
|
|
|
- if (hasTranslation || (_matrixDirtyBits & DIRTY_TRANSLATION) == DIRTY_TRANSLATION)
|
|
|
|
|
|
|
+ Matrix::createTranslation(_translation, &_matrix);
|
|
|
|
|
+ if (hasRotation)
|
|
|
{
|
|
{
|
|
|
- Matrix::createTranslation(_translation, &_matrix);
|
|
|
|
|
- if (hasRotation || (_matrixDirtyBits & DIRTY_ROTATION) == DIRTY_ROTATION)
|
|
|
|
|
- {
|
|
|
|
|
- _matrix.rotate(_rotation);
|
|
|
|
|
- }
|
|
|
|
|
- if (hasScale || (_matrixDirtyBits & DIRTY_SCALE) == DIRTY_SCALE)
|
|
|
|
|
- {
|
|
|
|
|
- _matrix.scale(_scale);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ _matrix.rotate(_rotation);
|
|
|
}
|
|
}
|
|
|
- else if (hasRotation || (_matrixDirtyBits & DIRTY_ROTATION) == DIRTY_ROTATION)
|
|
|
|
|
|
|
+ if (hasScale)
|
|
|
{
|
|
{
|
|
|
- Matrix::createRotation(_rotation, &_matrix);
|
|
|
|
|
- if (hasScale || (_matrixDirtyBits & DIRTY_SCALE) == DIRTY_SCALE)
|
|
|
|
|
- {
|
|
|
|
|
- _matrix.scale(_scale);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- else if (hasScale || (_matrixDirtyBits & DIRTY_SCALE) == DIRTY_SCALE)
|
|
|
|
|
- {
|
|
|
|
|
- Matrix::createScale(_scale, &_matrix);
|
|
|
|
|
|
|
+ _matrix.scale(_scale);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- _matrixDirtyBits &= ~DIRTY_TRANSLATION & ~DIRTY_ROTATION & ~DIRTY_SCALE;
|
|
|
|
|
|
|
+ _matrixDirtyBits &= ~(DIRTY_TRANSLATION | DIRTY_ROTATION | DIRTY_SCALE);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return _matrix;
|
|
return _matrix;
|