Fix: incorrect safe float4x4 to quaternion conversion
The issue was that when a 4x4 matrix is normalized, it does not always mean that any inner 3x3 matrix is normalized too.
This commit is contained in:
@@ -351,7 +351,7 @@ static ColorGeometry4f byte_color_to_color(const ColorGeometry4b &a)
|
||||
|
||||
static math::Quaternion float4x4_to_quaternion(const float4x4 &a)
|
||||
{
|
||||
return math::normalized_to_quaternion_safe(math::normalize(a));
|
||||
return math::normalized_to_quaternion_safe(math::normalize(float3x3(a)));
|
||||
}
|
||||
|
||||
static float3 quaternion_to_float3(const math::Quaternion &a)
|
||||
|
||||
@@ -1234,12 +1234,6 @@ template<typename T>
|
||||
return to_quaternion(to_euler(mat));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
[[nodiscard]] inline QuaternionBase<T> normalized_to_quaternion_safe(const MatBase<T, 4, 4> &mat)
|
||||
{
|
||||
return to_quaternion(to_euler(mat));
|
||||
}
|
||||
|
||||
template<bool AllowNegativeScale, typename T, int NumCol, int NumRow>
|
||||
[[nodiscard]] inline VecBase<T, 3> to_scale(const MatBase<T, NumCol, NumRow> &mat)
|
||||
{
|
||||
|
||||
@@ -52,7 +52,8 @@ class SeparateTransformFunction : public mf::MultiFunction {
|
||||
}
|
||||
else if (!rotation.is_empty() && scale.is_empty()) {
|
||||
mask.foreach_index([&](const int64_t i) {
|
||||
rotation[i] = math::normalized_to_quaternion_safe(math::normalize(transforms[i]));
|
||||
rotation[i] = math::normalized_to_quaternion_safe(
|
||||
math::normalize(float3x3(transforms[i])));
|
||||
});
|
||||
}
|
||||
else if (!rotation.is_empty() && !scale.is_empty()) {
|
||||
|
||||
Reference in New Issue
Block a user