unity3d-jp / MeshSync

A package for synchronizing meshes/models editing in DCC tools into Unity in real time.
Other
1.55k stars 174 forks source link

toMatrix() incompatible with assignMatrix() #925

Closed Puppy-M closed 10 months ago

Puppy-M commented 11 months ago
mu::float4x4 Transform::toMatrix();
void Transform::assignMatrix(const mu::float4x4& v);

I checked the code in function assignMatrix, and it seems the rotation is inversed due to the right-hand to left-hand convertion.

template<class TMat>
inline tquat<typename TMat::scalar_t> extract_rotation_impl(const TMat& m_)
{
...
    if (tr > T(1e-4f)) {
        s = sqrt(tr);
        q[3] = (float)s;
        s = T(1) / (T(4) * s);
        q[0] = (m[1][2] - m[2][1]) * s;
        q[1] = (m[2][0] - m[0][2]) * s;
        q[2] = (m[0][1] - m[1][0]) * s;
    }
...
}

However, in function mu::float4x4 Transform::toMatrix();, there is not this kind convertion. And this lead to the bug. While matrix_a is assigned to a Transform, matrix_b is the result of Transform.toMatrix(). The matrix_a is not equal to matrix_b!

Is this intentional? And why?

sindharta-tanuwijaya commented 11 months ago

Hi, unless you can provide us with information related to an actual bug or requirement, I regret to inform you that we are unable to provide support for questions specifically related to source code.