Fix world rotation extraction with scaled parents
This commit is contained in:
@@ -308,7 +308,33 @@ Vector3 Matrix4::GetTranslation() const {
|
||||
}
|
||||
|
||||
Quaternion Matrix4::GetRotation() const {
|
||||
return Quaternion::FromRotationMatrix(*this);
|
||||
Matrix4 rotationMatrix = *this;
|
||||
const Vector3 scale = GetScale();
|
||||
|
||||
if (scale.x > EPSILON) {
|
||||
rotationMatrix.m[0][0] /= scale.x;
|
||||
rotationMatrix.m[1][0] /= scale.x;
|
||||
rotationMatrix.m[2][0] /= scale.x;
|
||||
}
|
||||
if (scale.y > EPSILON) {
|
||||
rotationMatrix.m[0][1] /= scale.y;
|
||||
rotationMatrix.m[1][1] /= scale.y;
|
||||
rotationMatrix.m[2][1] /= scale.y;
|
||||
}
|
||||
if (scale.z > EPSILON) {
|
||||
rotationMatrix.m[0][2] /= scale.z;
|
||||
rotationMatrix.m[1][2] /= scale.z;
|
||||
rotationMatrix.m[2][2] /= scale.z;
|
||||
}
|
||||
|
||||
rotationMatrix.m[0][3] = 0.0f;
|
||||
rotationMatrix.m[1][3] = 0.0f;
|
||||
rotationMatrix.m[2][3] = 0.0f;
|
||||
rotationMatrix.m[3][0] = 0.0f;
|
||||
rotationMatrix.m[3][1] = 0.0f;
|
||||
rotationMatrix.m[3][2] = 0.0f;
|
||||
rotationMatrix.m[3][3] = 1.0f;
|
||||
return Quaternion::FromRotationMatrix(rotationMatrix);
|
||||
}
|
||||
|
||||
Vector3 Matrix4::GetScale() const {
|
||||
|
||||
Reference in New Issue
Block a user