feat: updated engine version to 4.4-rc1
This commit is contained in:
parent
ee00efde1f
commit
21ba8e33af
5459 changed files with 1128836 additions and 198305 deletions
|
|
@ -455,6 +455,11 @@ void Basis::get_rotation_axis_angle_local(Vector3 &p_axis, real_t &p_angle) cons
|
|||
}
|
||||
|
||||
Vector3 Basis::get_euler(EulerOrder p_order) const {
|
||||
// This epsilon value results in angles within a +/- 0.04 degree range being simplified/truncated.
|
||||
// Based on testing, this is the largest the epsilon can be without the angle truncation becoming
|
||||
// visually noticeable.
|
||||
const real_t epsilon = 0.00000025;
|
||||
|
||||
switch (p_order) {
|
||||
case EulerOrder::XYZ: {
|
||||
// Euler angles in XYZ convention.
|
||||
|
|
@ -466,8 +471,8 @@ Vector3 Basis::get_euler(EulerOrder p_order) const {
|
|||
|
||||
Vector3 euler;
|
||||
real_t sy = rows[0][2];
|
||||
if (sy < (1.0f - (real_t)CMP_EPSILON)) {
|
||||
if (sy > -(1.0f - (real_t)CMP_EPSILON)) {
|
||||
if (sy < (1.0f - epsilon)) {
|
||||
if (sy > -(1.0f - epsilon)) {
|
||||
// is this a pure Y rotation?
|
||||
if (rows[1][0] == 0 && rows[0][1] == 0 && rows[1][2] == 0 && rows[2][1] == 0 && rows[1][1] == 1) {
|
||||
// return the simplest form (human friendlier in editor and scripts)
|
||||
|
|
@ -501,8 +506,8 @@ Vector3 Basis::get_euler(EulerOrder p_order) const {
|
|||
|
||||
Vector3 euler;
|
||||
real_t sz = rows[0][1];
|
||||
if (sz < (1.0f - (real_t)CMP_EPSILON)) {
|
||||
if (sz > -(1.0f - (real_t)CMP_EPSILON)) {
|
||||
if (sz < (1.0f - epsilon)) {
|
||||
if (sz > -(1.0f - epsilon)) {
|
||||
euler.x = Math::atan2(rows[2][1], rows[1][1]);
|
||||
euler.y = Math::atan2(rows[0][2], rows[0][0]);
|
||||
euler.z = Math::asin(-sz);
|
||||
|
|
@ -532,8 +537,8 @@ Vector3 Basis::get_euler(EulerOrder p_order) const {
|
|||
|
||||
real_t m12 = rows[1][2];
|
||||
|
||||
if (m12 < (1 - (real_t)CMP_EPSILON)) {
|
||||
if (m12 > -(1 - (real_t)CMP_EPSILON)) {
|
||||
if (m12 < (1 - epsilon)) {
|
||||
if (m12 > -(1 - epsilon)) {
|
||||
// is this a pure X rotation?
|
||||
if (rows[1][0] == 0 && rows[0][1] == 0 && rows[0][2] == 0 && rows[2][0] == 0 && rows[0][0] == 1) {
|
||||
// return the simplest form (human friendlier in editor and scripts)
|
||||
|
|
@ -568,8 +573,8 @@ Vector3 Basis::get_euler(EulerOrder p_order) const {
|
|||
|
||||
Vector3 euler;
|
||||
real_t sz = rows[1][0];
|
||||
if (sz < (1.0f - (real_t)CMP_EPSILON)) {
|
||||
if (sz > -(1.0f - (real_t)CMP_EPSILON)) {
|
||||
if (sz < (1.0f - epsilon)) {
|
||||
if (sz > -(1.0f - epsilon)) {
|
||||
euler.x = Math::atan2(-rows[1][2], rows[1][1]);
|
||||
euler.y = Math::atan2(-rows[2][0], rows[0][0]);
|
||||
euler.z = Math::asin(sz);
|
||||
|
|
@ -596,8 +601,8 @@ Vector3 Basis::get_euler(EulerOrder p_order) const {
|
|||
// -cx*sy sx cx*cy
|
||||
Vector3 euler;
|
||||
real_t sx = rows[2][1];
|
||||
if (sx < (1.0f - (real_t)CMP_EPSILON)) {
|
||||
if (sx > -(1.0f - (real_t)CMP_EPSILON)) {
|
||||
if (sx < (1.0f - epsilon)) {
|
||||
if (sx > -(1.0f - epsilon)) {
|
||||
euler.x = Math::asin(sx);
|
||||
euler.y = Math::atan2(-rows[2][0], rows[2][2]);
|
||||
euler.z = Math::atan2(-rows[0][1], rows[1][1]);
|
||||
|
|
@ -624,8 +629,8 @@ Vector3 Basis::get_euler(EulerOrder p_order) const {
|
|||
// -sy cy*sx cy*cx
|
||||
Vector3 euler;
|
||||
real_t sy = rows[2][0];
|
||||
if (sy < (1.0f - (real_t)CMP_EPSILON)) {
|
||||
if (sy > -(1.0f - (real_t)CMP_EPSILON)) {
|
||||
if (sy < (1.0f - epsilon)) {
|
||||
if (sy > -(1.0f - epsilon)) {
|
||||
euler.x = Math::atan2(rows[2][1], rows[2][2]);
|
||||
euler.y = Math::asin(-sy);
|
||||
euler.z = Math::atan2(rows[1][0], rows[0][0]);
|
||||
|
|
@ -1049,9 +1054,10 @@ Basis Basis::looking_at(const Vector3 &p_target, const Vector3 &p_up, bool p_use
|
|||
v_z = -v_z;
|
||||
}
|
||||
Vector3 v_x = p_up.cross(v_z);
|
||||
#ifdef MATH_CHECKS
|
||||
ERR_FAIL_COND_V_MSG(v_x.is_zero_approx(), Basis(), "The target vector and up vector can't be parallel to each other.");
|
||||
#endif
|
||||
if (v_x.is_zero_approx()) {
|
||||
WARN_PRINT("Target and up vectors are colinear. This is not advised as it may cause unwanted rotation around local Z axis.");
|
||||
v_x = p_up.get_any_perpendicular(); // Vectors are almost parallel.
|
||||
}
|
||||
v_x.normalize();
|
||||
Vector3 v_y = v_z.cross(v_x);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue