1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00
luanti/irr/include/Transform.h
Lars Mueller 503d7cf081 progress
2025-05-24 17:29:17 +02:00

44 lines
No EOL
788 B
C++

#pragma once
#include "irrMath.h"
#include <matrix4.h>
#include <variant>
#include <vector3d.h>
#include <quaternion.h>
namespace irr
{
namespace core
{
struct Transform {
vector3df translation;
quaternion rotation;
vector3df scale{1};
// Tries to decompose the matrix, if there is one.
static Transform decompose(const core::matrix4 &mat)
{
auto scale = mat.getScale();
return {
mat.getTranslation(),
quaternion(mat.getRotationDegrees(scale) * DEGTORAD),
scale,
};
}
matrix4 buildMatrix() const
{
matrix4 T;
T.setTranslation(translation);
matrix4 R;
// TODO this is sussy. probably shouldn't be doing this.
rotation.getMatrix_transposed(R);
matrix4 S;
S.setScale(scale);
return T * R * S;
}
};
} // end namespace core
} // end namespace irr