Display the Y angle properly when rotating from gizmo, partially helps #1479
This commit is contained in:
parent
e12b422c90
commit
cd9539f85d
1 changed files with 11 additions and 3 deletions
|
@ -30,7 +30,7 @@
|
|||
#include "matrix3.h"
|
||||
#include "math_funcs.h"
|
||||
#include "os/copymem.h"
|
||||
|
||||
#include "print_string.h"
|
||||
#define cofac(row1, col1, row2, col2) \
|
||||
(elements[row1][col1] * elements[row2][col2] - elements[row1][col2] * elements[row2][col1])
|
||||
|
||||
|
@ -364,8 +364,16 @@ Vector3 Basis::get_euler() const {
|
|||
euler.y = Math::asin(elements[0][2]);
|
||||
if (euler.y < Math_PI * 0.5) {
|
||||
if (euler.y > -Math_PI * 0.5) {
|
||||
euler.x = Math::atan2(-elements[1][2], elements[2][2]);
|
||||
euler.z = Math::atan2(-elements[0][1], elements[0][0]);
|
||||
//if rotation is Y-only, return a proper -pi,pi range like in x or z for the same case.
|
||||
if (elements[1][0] == 0.0 && elements[0][1] == 0.0 && elements[0][0] < 0.0) {
|
||||
if (euler.y > 0.0)
|
||||
euler.y = Math_PI - euler.y;
|
||||
else
|
||||
euler.y = -(Math_PI + euler.y);
|
||||
} else {
|
||||
euler.x = Math::atan2(-elements[1][2], elements[2][2]);
|
||||
euler.z = Math::atan2(-elements[0][1], elements[0][0]);
|
||||
}
|
||||
|
||||
} else {
|
||||
real_t r = Math::atan2(elements[1][0], elements[1][1]);
|
||||
|
|
Loading…
Reference in a new issue