diff options
59 files changed, 1081 insertions, 1078 deletions
diff --git a/core/io/marshalls.cpp b/core/io/marshalls.cpp index 0c767c102d..bb9606c94b 100644 --- a/core/io/marshalls.cpp +++ b/core/io/marshalls.cpp @@ -291,7 +291,7 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int ERR_FAIL_COND_V((size_t)len < sizeof(double) * 6, ERR_INVALID_DATA); for (int i = 0; i < 3; i++) { for (int j = 0; j < 2; j++) { - val.elements[i][j] = decode_double(&buf[(i * 2 + j) * sizeof(double)]); + val.columns[i][j] = decode_double(&buf[(i * 2 + j) * sizeof(double)]); } } @@ -302,7 +302,7 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int ERR_FAIL_COND_V((size_t)len < sizeof(float) * 6, ERR_INVALID_DATA); for (int i = 0; i < 3; i++) { for (int j = 0; j < 2; j++) { - val.elements[i][j] = decode_float(&buf[(i * 2 + j) * sizeof(float)]); + val.columns[i][j] = decode_float(&buf[(i * 2 + j) * sizeof(float)]); } } @@ -401,7 +401,7 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int ERR_FAIL_COND_V((size_t)len < sizeof(double) * 9, ERR_INVALID_DATA); for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { - val.elements[i][j] = decode_double(&buf[(i * 3 + j) * sizeof(double)]); + val.rows[i][j] = decode_double(&buf[(i * 3 + j) * sizeof(double)]); } } @@ -412,7 +412,7 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int ERR_FAIL_COND_V((size_t)len < sizeof(float) * 9, ERR_INVALID_DATA); for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { - val.elements[i][j] = decode_float(&buf[(i * 3 + j) * sizeof(float)]); + val.rows[i][j] = decode_float(&buf[(i * 3 + j) * sizeof(float)]); } } @@ -429,7 +429,7 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int ERR_FAIL_COND_V((size_t)len < sizeof(double) * 12, ERR_INVALID_DATA); for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { - val.basis.elements[i][j] = decode_double(&buf[(i * 3 + j) * sizeof(double)]); + val.basis.rows[i][j] = decode_double(&buf[(i * 3 + j) * sizeof(double)]); } } val.origin[0] = decode_double(&buf[sizeof(double) * 9]); @@ -443,7 +443,7 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int ERR_FAIL_COND_V((size_t)len < sizeof(float) * 12, ERR_INVALID_DATA); for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { - val.basis.elements[i][j] = decode_float(&buf[(i * 3 + j) * sizeof(float)]); + val.basis.rows[i][j] = decode_float(&buf[(i * 3 + j) * sizeof(float)]); } } val.origin[0] = decode_float(&buf[sizeof(float) * 9]); @@ -1261,7 +1261,7 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo Transform2D val = p_variant; for (int i = 0; i < 3; i++) { for (int j = 0; j < 2; j++) { - memcpy(&buf[(i * 2 + j) * sizeof(real_t)], &val.elements[i][j], sizeof(real_t)); + memcpy(&buf[(i * 2 + j) * sizeof(real_t)], &val.columns[i][j], sizeof(real_t)); } } } @@ -1312,7 +1312,7 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo Basis val = p_variant; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { - memcpy(&buf[(i * 3 + j) * sizeof(real_t)], &val.elements[i][j], sizeof(real_t)); + memcpy(&buf[(i * 3 + j) * sizeof(real_t)], &val.rows[i][j], sizeof(real_t)); } } } @@ -1325,7 +1325,7 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo Transform3D val = p_variant; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { - memcpy(&buf[(i * 3 + j) * sizeof(real_t)], &val.basis.elements[i][j], sizeof(real_t)); + memcpy(&buf[(i * 3 + j) * sizeof(real_t)], &val.basis.rows[i][j], sizeof(real_t)); } } diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp index dec78aa218..c9eb0e5234 100644 --- a/core/io/resource_format_binary.cpp +++ b/core/io/resource_format_binary.cpp @@ -266,40 +266,40 @@ Error ResourceLoaderBinary::parse_variant(Variant &r_v) { } break; case VARIANT_TRANSFORM2D: { Transform2D v; - v.elements[0].x = f->get_real(); - v.elements[0].y = f->get_real(); - v.elements[1].x = f->get_real(); - v.elements[1].y = f->get_real(); - v.elements[2].x = f->get_real(); - v.elements[2].y = f->get_real(); + v.columns[0].x = f->get_real(); + v.columns[0].y = f->get_real(); + v.columns[1].x = f->get_real(); + v.columns[1].y = f->get_real(); + v.columns[2].x = f->get_real(); + v.columns[2].y = f->get_real(); r_v = v; } break; case VARIANT_BASIS: { Basis v; - v.elements[0].x = f->get_real(); - v.elements[0].y = f->get_real(); - v.elements[0].z = f->get_real(); - v.elements[1].x = f->get_real(); - v.elements[1].y = f->get_real(); - v.elements[1].z = f->get_real(); - v.elements[2].x = f->get_real(); - v.elements[2].y = f->get_real(); - v.elements[2].z = f->get_real(); + v.rows[0].x = f->get_real(); + v.rows[0].y = f->get_real(); + v.rows[0].z = f->get_real(); + v.rows[1].x = f->get_real(); + v.rows[1].y = f->get_real(); + v.rows[1].z = f->get_real(); + v.rows[2].x = f->get_real(); + v.rows[2].y = f->get_real(); + v.rows[2].z = f->get_real(); r_v = v; } break; case VARIANT_TRANSFORM3D: { Transform3D v; - v.basis.elements[0].x = f->get_real(); - v.basis.elements[0].y = f->get_real(); - v.basis.elements[0].z = f->get_real(); - v.basis.elements[1].x = f->get_real(); - v.basis.elements[1].y = f->get_real(); - v.basis.elements[1].z = f->get_real(); - v.basis.elements[2].x = f->get_real(); - v.basis.elements[2].y = f->get_real(); - v.basis.elements[2].z = f->get_real(); + v.basis.rows[0].x = f->get_real(); + v.basis.rows[0].y = f->get_real(); + v.basis.rows[0].z = f->get_real(); + v.basis.rows[1].x = f->get_real(); + v.basis.rows[1].y = f->get_real(); + v.basis.rows[1].z = f->get_real(); + v.basis.rows[2].x = f->get_real(); + v.basis.rows[2].y = f->get_real(); + v.basis.rows[2].z = f->get_real(); v.origin.x = f->get_real(); v.origin.y = f->get_real(); v.origin.z = f->get_real(); @@ -1474,40 +1474,40 @@ void ResourceFormatSaverBinaryInstance::write_variant(Ref<FileAccess> f, const V case Variant::TRANSFORM2D: { f->store_32(VARIANT_TRANSFORM2D); Transform2D val = p_property; - f->store_real(val.elements[0].x); - f->store_real(val.elements[0].y); - f->store_real(val.elements[1].x); - f->store_real(val.elements[1].y); - f->store_real(val.elements[2].x); - f->store_real(val.elements[2].y); + f->store_real(val.columns[0].x); + f->store_real(val.columns[0].y); + f->store_real(val.columns[1].x); + f->store_real(val.columns[1].y); + f->store_real(val.columns[2].x); + f->store_real(val.columns[2].y); } break; case Variant::BASIS: { f->store_32(VARIANT_BASIS); Basis val = p_property; - f->store_real(val.elements[0].x); - f->store_real(val.elements[0].y); - f->store_real(val.elements[0].z); - f->store_real(val.elements[1].x); - f->store_real(val.elements[1].y); - f->store_real(val.elements[1].z); - f->store_real(val.elements[2].x); - f->store_real(val.elements[2].y); - f->store_real(val.elements[2].z); + f->store_real(val.rows[0].x); + f->store_real(val.rows[0].y); + f->store_real(val.rows[0].z); + f->store_real(val.rows[1].x); + f->store_real(val.rows[1].y); + f->store_real(val.rows[1].z); + f->store_real(val.rows[2].x); + f->store_real(val.rows[2].y); + f->store_real(val.rows[2].z); } break; case Variant::TRANSFORM3D: { f->store_32(VARIANT_TRANSFORM3D); Transform3D val = p_property; - f->store_real(val.basis.elements[0].x); - f->store_real(val.basis.elements[0].y); - f->store_real(val.basis.elements[0].z); - f->store_real(val.basis.elements[1].x); - f->store_real(val.basis.elements[1].y); - f->store_real(val.basis.elements[1].z); - f->store_real(val.basis.elements[2].x); - f->store_real(val.basis.elements[2].y); - f->store_real(val.basis.elements[2].z); + f->store_real(val.basis.rows[0].x); + f->store_real(val.basis.rows[0].y); + f->store_real(val.basis.rows[0].z); + f->store_real(val.basis.rows[1].x); + f->store_real(val.basis.rows[1].y); + f->store_real(val.basis.rows[1].z); + f->store_real(val.basis.rows[2].x); + f->store_real(val.basis.rows[2].y); + f->store_real(val.basis.rows[2].z); f->store_real(val.origin.x); f->store_real(val.origin.y); f->store_real(val.origin.z); diff --git a/core/math/basis.cpp b/core/math/basis.cpp index eb6703aff2..faec5735b9 100644 --- a/core/math/basis.cpp +++ b/core/math/basis.cpp @@ -34,32 +34,32 @@ #include "core/string/print_string.h" #define cofac(row1, col1, row2, col2) \ - (elements[row1][col1] * elements[row2][col2] - elements[row1][col2] * elements[row2][col1]) + (rows[row1][col1] * rows[row2][col2] - rows[row1][col2] * rows[row2][col1]) void Basis::from_z(const Vector3 &p_z) { if (Math::abs(p_z.z) > (real_t)Math_SQRT12) { // choose p in y-z plane real_t a = p_z[1] * p_z[1] + p_z[2] * p_z[2]; real_t k = 1.0f / Math::sqrt(a); - elements[0] = Vector3(0, -p_z[2] * k, p_z[1] * k); - elements[1] = Vector3(a * k, -p_z[0] * elements[0][2], p_z[0] * elements[0][1]); + rows[0] = Vector3(0, -p_z[2] * k, p_z[1] * k); + rows[1] = Vector3(a * k, -p_z[0] * rows[0][2], p_z[0] * rows[0][1]); } else { // choose p in x-y plane real_t a = p_z.x * p_z.x + p_z.y * p_z.y; real_t k = 1.0f / Math::sqrt(a); - elements[0] = Vector3(-p_z.y * k, p_z.x * k, 0); - elements[1] = Vector3(-p_z.z * elements[0].y, p_z.z * elements[0].x, a * k); + rows[0] = Vector3(-p_z.y * k, p_z.x * k, 0); + rows[1] = Vector3(-p_z.z * rows[0].y, p_z.z * rows[0].x, a * k); } - elements[2] = p_z; + rows[2] = p_z; } void Basis::invert() { real_t co[3] = { cofac(1, 1, 2, 2), cofac(1, 2, 2, 0), cofac(1, 0, 2, 1) }; - real_t det = elements[0][0] * co[0] + - elements[0][1] * co[1] + - elements[0][2] * co[2]; + real_t det = rows[0][0] * co[0] + + rows[0][1] * co[1] + + rows[0][2] * co[2]; #ifdef MATH_CHECKS ERR_FAIL_COND(det == 0); #endif @@ -115,9 +115,9 @@ bool Basis::is_orthogonal() const { bool Basis::is_diagonal() const { return ( - Math::is_zero_approx(elements[0][1]) && Math::is_zero_approx(elements[0][2]) && - Math::is_zero_approx(elements[1][0]) && Math::is_zero_approx(elements[1][2]) && - Math::is_zero_approx(elements[2][0]) && Math::is_zero_approx(elements[2][1])); + Math::is_zero_approx(rows[0][1]) && Math::is_zero_approx(rows[0][2]) && + Math::is_zero_approx(rows[1][0]) && Math::is_zero_approx(rows[1][2]) && + Math::is_zero_approx(rows[2][0]) && Math::is_zero_approx(rows[2][1])); } bool Basis::is_rotation() const { @@ -127,13 +127,13 @@ bool Basis::is_rotation() const { #ifdef MATH_CHECKS // This method is only used once, in diagonalize. If it's desired elsewhere, feel free to remove the #ifdef. bool Basis::is_symmetric() const { - if (!Math::is_equal_approx(elements[0][1], elements[1][0])) { + if (!Math::is_equal_approx(rows[0][1], rows[1][0])) { return false; } - if (!Math::is_equal_approx(elements[0][2], elements[2][0])) { + if (!Math::is_equal_approx(rows[0][2], rows[2][0])) { return false; } - if (!Math::is_equal_approx(elements[1][2], elements[2][1])) { + if (!Math::is_equal_approx(rows[1][2], rows[2][1])) { return false; } @@ -149,14 +149,14 @@ Basis Basis::diagonalize() { #endif const int ite_max = 1024; - real_t off_matrix_norm_2 = elements[0][1] * elements[0][1] + elements[0][2] * elements[0][2] + elements[1][2] * elements[1][2]; + real_t off_matrix_norm_2 = rows[0][1] * rows[0][1] + rows[0][2] * rows[0][2] + rows[1][2] * rows[1][2]; int ite = 0; Basis acc_rot; while (off_matrix_norm_2 > (real_t)CMP_EPSILON2 && ite++ < ite_max) { - real_t el01_2 = elements[0][1] * elements[0][1]; - real_t el02_2 = elements[0][2] * elements[0][2]; - real_t el12_2 = elements[1][2] * elements[1][2]; + real_t el01_2 = rows[0][1] * rows[0][1]; + real_t el02_2 = rows[0][2] * rows[0][2]; + real_t el12_2 = rows[1][2] * rows[1][2]; // Find the pivot element int i, j; if (el01_2 > el02_2) { @@ -179,19 +179,19 @@ Basis Basis::diagonalize() { // Compute the rotation angle real_t angle; - if (Math::is_equal_approx(elements[j][j], elements[i][i])) { + if (Math::is_equal_approx(rows[j][j], rows[i][i])) { angle = Math_PI / 4; } else { - angle = 0.5f * Math::atan(2 * elements[i][j] / (elements[j][j] - elements[i][i])); + angle = 0.5f * Math::atan(2 * rows[i][j] / (rows[j][j] - rows[i][i])); } // Compute the rotation matrix Basis rot; - rot.elements[i][i] = rot.elements[j][j] = Math::cos(angle); - rot.elements[i][j] = -(rot.elements[j][i] = Math::sin(angle)); + rot.rows[i][i] = rot.rows[j][j] = Math::cos(angle); + rot.rows[i][j] = -(rot.rows[j][i] = Math::sin(angle)); // Update the off matrix norm - off_matrix_norm_2 -= elements[i][j] * elements[i][j]; + off_matrix_norm_2 -= rows[i][j] * rows[i][j]; // Apply the rotation *this = rot * *this * rot.transposed(); @@ -208,9 +208,9 @@ Basis Basis::inverse() const { } void Basis::transpose() { - SWAP(elements[0][1], elements[1][0]); - SWAP(elements[0][2], elements[2][0]); - SWAP(elements[1][2], elements[2][1]); + SWAP(rows[0][1], rows[1][0]); + SWAP(rows[0][2], rows[2][0]); + SWAP(rows[1][2], rows[2][1]); } Basis Basis::transposed() const { @@ -226,15 +226,15 @@ Basis Basis::from_scale(const Vector3 &p_scale) { // Multiplies the matrix from left by the scaling matrix: M -> S.M // See the comment for Basis::rotated for further explanation. void Basis::scale(const Vector3 &p_scale) { - elements[0][0] *= p_scale.x; - elements[0][1] *= p_scale.x; - elements[0][2] *= p_scale.x; - elements[1][0] *= p_scale.y; - elements[1][1] *= p_scale.y; - elements[1][2] *= p_scale.y; - elements[2][0] *= p_scale.z; - elements[2][1] *= p_scale.z; - elements[2][2] *= p_scale.z; + rows[0][0] *= p_scale.x; + rows[0][1] *= p_scale.x; + rows[0][2] *= p_scale.x; + rows[1][0] *= p_scale.y; + rows[1][1] *= p_scale.y; + rows[1][2] *= p_scale.y; + rows[2][0] *= p_scale.z; + rows[2][1] *= p_scale.z; + rows[2][2] *= p_scale.z; } Basis Basis::scaled(const Vector3 &p_scale) const { @@ -268,14 +268,14 @@ Basis Basis::scaled_orthogonal(const Vector3 &p_scale) const { } float Basis::get_uniform_scale() const { - return (elements[0].length() + elements[1].length() + elements[2].length()) / 3.0f; + return (rows[0].length() + rows[1].length() + rows[2].length()) / 3.0f; } void Basis::make_scale_uniform() { - float l = (elements[0].length() + elements[1].length() + elements[2].length()) / 3.0f; + float l = (rows[0].length() + rows[1].length() + rows[2].length()) / 3.0f; for (int i = 0; i < 3; i++) { - elements[i].normalize(); - elements[i] *= l; + rows[i].normalize(); + rows[i] *= l; } } @@ -285,14 +285,14 @@ Basis Basis::scaled_local(const Vector3 &p_scale) const { Vector3 Basis::get_scale_abs() const { return Vector3( - Vector3(elements[0][0], elements[1][0], elements[2][0]).length(), - Vector3(elements[0][1], elements[1][1], elements[2][1]).length(), - Vector3(elements[0][2], elements[1][2], elements[2][2]).length()); + Vector3(rows[0][0], rows[1][0], rows[2][0]).length(), + Vector3(rows[0][1], rows[1][1], rows[2][1]).length(), + Vector3(rows[0][2], rows[1][2], rows[2][2]).length()); } Vector3 Basis::get_scale_local() const { real_t det_sign = SIGN(determinant()); - return det_sign * Vector3(elements[0].length(), elements[1].length(), elements[2].length()); + return det_sign * Vector3(rows[0].length(), rows[1].length(), rows[2].length()); } // get_scale works with get_rotation, use get_scale_abs if you need to enforce positive signature. @@ -462,27 +462,27 @@ Vector3 Basis::get_euler(EulerOrder p_order) const { // -cx*cz*sy+sx*sz cz*sx+cx*sy*sz cx*cy Vector3 euler; - real_t sy = elements[0][2]; + real_t sy = rows[0][2]; if (sy < (1.0f - (real_t)CMP_EPSILON)) { if (sy > -(1.0f - (real_t)CMP_EPSILON)) { // is this a pure Y rotation? - if (elements[1][0] == 0 && elements[0][1] == 0 && elements[1][2] == 0 && elements[2][1] == 0 && elements[1][1] == 1) { + 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) euler.x = 0; - euler.y = atan2(elements[0][2], elements[0][0]); + euler.y = atan2(rows[0][2], rows[0][0]); euler.z = 0; } else { - euler.x = Math::atan2(-elements[1][2], elements[2][2]); + euler.x = Math::atan2(-rows[1][2], rows[2][2]); euler.y = Math::asin(sy); - euler.z = Math::atan2(-elements[0][1], elements[0][0]); + euler.z = Math::atan2(-rows[0][1], rows[0][0]); } } else { - euler.x = Math::atan2(elements[2][1], elements[1][1]); + euler.x = Math::atan2(rows[2][1], rows[1][1]); euler.y = -Math_PI / 2.0f; euler.z = 0.0f; } } else { - euler.x = Math::atan2(elements[2][1], elements[1][1]); + euler.x = Math::atan2(rows[2][1], rows[1][1]); euler.y = Math_PI / 2.0f; euler.z = 0.0f; } @@ -497,21 +497,21 @@ Vector3 Basis::get_euler(EulerOrder p_order) const { // cy*sx*sz cz*sx cx*cy+sx*sz*sy Vector3 euler; - real_t sz = elements[0][1]; + real_t sz = rows[0][1]; if (sz < (1.0f - (real_t)CMP_EPSILON)) { if (sz > -(1.0f - (real_t)CMP_EPSILON)) { - euler.x = Math::atan2(elements[2][1], elements[1][1]); - euler.y = Math::atan2(elements[0][2], elements[0][0]); + 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); } else { // It's -1 - euler.x = -Math::atan2(elements[1][2], elements[2][2]); + euler.x = -Math::atan2(rows[1][2], rows[2][2]); euler.y = 0.0f; euler.z = Math_PI / 2.0f; } } else { // It's 1 - euler.x = -Math::atan2(elements[1][2], elements[2][2]); + euler.x = -Math::atan2(rows[1][2], rows[2][2]); euler.y = 0.0f; euler.z = -Math_PI / 2.0f; } @@ -527,29 +527,29 @@ Vector3 Basis::get_euler(EulerOrder p_order) const { Vector3 euler; - real_t m12 = elements[1][2]; + real_t m12 = rows[1][2]; if (m12 < (1 - (real_t)CMP_EPSILON)) { if (m12 > -(1 - (real_t)CMP_EPSILON)) { // is this a pure X rotation? - if (elements[1][0] == 0 && elements[0][1] == 0 && elements[0][2] == 0 && elements[2][0] == 0 && elements[0][0] == 1) { + 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) - euler.x = atan2(-m12, elements[1][1]); + euler.x = atan2(-m12, rows[1][1]); euler.y = 0; euler.z = 0; } else { euler.x = asin(-m12); - euler.y = atan2(elements[0][2], elements[2][2]); - euler.z = atan2(elements[1][0], elements[1][1]); + euler.y = atan2(rows[0][2], rows[2][2]); + euler.z = atan2(rows[1][0], rows[1][1]); } } else { // m12 == -1 euler.x = Math_PI * 0.5f; - euler.y = atan2(elements[0][1], elements[0][0]); + euler.y = atan2(rows[0][1], rows[0][0]); euler.z = 0; } } else { // m12 == 1 euler.x = -Math_PI * 0.5f; - euler.y = -atan2(elements[0][1], elements[0][0]); + euler.y = -atan2(rows[0][1], rows[0][0]); euler.z = 0; } @@ -564,21 +564,21 @@ Vector3 Basis::get_euler(EulerOrder p_order) const { // -cz*sy cy*sx+cx*sy*sz cy*cx-sy*sz*sx Vector3 euler; - real_t sz = elements[1][0]; + real_t sz = rows[1][0]; if (sz < (1.0f - (real_t)CMP_EPSILON)) { if (sz > -(1.0f - (real_t)CMP_EPSILON)) { - euler.x = Math::atan2(-elements[1][2], elements[1][1]); - euler.y = Math::atan2(-elements[2][0], elements[0][0]); + 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); } else { // It's -1 - euler.x = Math::atan2(elements[2][1], elements[2][2]); + euler.x = Math::atan2(rows[2][1], rows[2][2]); euler.y = 0.0f; euler.z = -Math_PI / 2.0f; } } else { // It's 1 - euler.x = Math::atan2(elements[2][1], elements[2][2]); + euler.x = Math::atan2(rows[2][1], rows[2][2]); euler.y = 0.0f; euler.z = Math_PI / 2.0f; } @@ -592,22 +592,22 @@ Vector3 Basis::get_euler(EulerOrder p_order) const { // cy*sz+cz*sx*sy cz*cx sz*sy-cz*cy*sx // -cx*sy sx cx*cy Vector3 euler; - real_t sx = elements[2][1]; + real_t sx = rows[2][1]; if (sx < (1.0f - (real_t)CMP_EPSILON)) { if (sx > -(1.0f - (real_t)CMP_EPSILON)) { euler.x = Math::asin(sx); - euler.y = Math::atan2(-elements[2][0], elements[2][2]); - euler.z = Math::atan2(-elements[0][1], elements[1][1]); + euler.y = Math::atan2(-rows[2][0], rows[2][2]); + euler.z = Math::atan2(-rows[0][1], rows[1][1]); } else { // It's -1 euler.x = -Math_PI / 2.0f; - euler.y = Math::atan2(elements[0][2], elements[0][0]); + euler.y = Math::atan2(rows[0][2], rows[0][0]); euler.z = 0; } } else { // It's 1 euler.x = Math_PI / 2.0f; - euler.y = Math::atan2(elements[0][2], elements[0][0]); + euler.y = Math::atan2(rows[0][2], rows[0][0]); euler.z = 0; } return euler; @@ -620,23 +620,23 @@ Vector3 Basis::get_euler(EulerOrder p_order) const { // cy*sz cz*cx+sz*sy*sx cx*sz*sy-cz*sx // -sy cy*sx cy*cx Vector3 euler; - real_t sy = elements[2][0]; + real_t sy = rows[2][0]; if (sy < (1.0f - (real_t)CMP_EPSILON)) { if (sy > -(1.0f - (real_t)CMP_EPSILON)) { - euler.x = Math::atan2(elements[2][1], elements[2][2]); + euler.x = Math::atan2(rows[2][1], rows[2][2]); euler.y = Math::asin(-sy); - euler.z = Math::atan2(elements[1][0], elements[0][0]); + euler.z = Math::atan2(rows[1][0], rows[0][0]); } else { // It's -1 euler.x = 0; euler.y = Math_PI / 2.0f; - euler.z = -Math::atan2(elements[0][1], elements[1][1]); + euler.z = -Math::atan2(rows[0][1], rows[1][1]); } } else { // It's 1 euler.x = 0; euler.y = -Math_PI / 2.0f; - euler.z = -Math::atan2(elements[0][1], elements[1][1]); + euler.z = -Math::atan2(rows[0][1], rows[1][1]); } return euler; } break; @@ -688,13 +688,13 @@ void Basis::set_euler(const Vector3 &p_euler, EulerOrder p_order) { } bool Basis::is_equal_approx(const Basis &p_basis) const { - return elements[0].is_equal_approx(p_basis.elements[0]) && elements[1].is_equal_approx(p_basis.elements[1]) && elements[2].is_equal_approx(p_basis.elements[2]); + return rows[0].is_equal_approx(p_basis.rows[0]) && rows[1].is_equal_approx(p_basis.rows[1]) && rows[2].is_equal_approx(p_basis.rows[2]); } bool Basis::operator==(const Basis &p_matrix) const { for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { - if (elements[i][j] != p_matrix.elements[i][j]) { + if (rows[i][j] != p_matrix.rows[i][j]) { return false; } } @@ -719,7 +719,7 @@ Quaternion Basis::get_quaternion() const { #endif /* Allow getting a quaternion from an unnormalized transform */ Basis m = *this; - real_t trace = m.elements[0][0] + m.elements[1][1] + m.elements[2][2]; + real_t trace = m.rows[0][0] + m.rows[1][1] + m.rows[2][2]; real_t temp[4]; if (trace > 0.0f) { @@ -727,23 +727,23 @@ Quaternion Basis::get_quaternion() const { temp[3] = (s * 0.5f); s = 0.5f / s; - temp[0] = ((m.elements[2][1] - m.elements[1][2]) * s); - temp[1] = ((m.elements[0][2] - m.elements[2][0]) * s); - temp[2] = ((m.elements[1][0] - m.elements[0][1]) * s); + temp[0] = ((m.rows[2][1] - m.rows[1][2]) * s); + temp[1] = ((m.rows[0][2] - m.rows[2][0]) * s); + temp[2] = ((m.rows[1][0] - m.rows[0][1]) * s); } else { - int i = m.elements[0][0] < m.elements[1][1] - ? (m.elements[1][1] < m.elements[2][2] ? 2 : 1) - : (m.elements[0][0] < m.elements[2][2] ? 2 : 0); + int i = m.rows[0][0] < m.rows[1][1] + ? (m.rows[1][1] < m.rows[2][2] ? 2 : 1) + : (m.rows[0][0] < m.rows[2][2] ? 2 : 0); int j = (i + 1) % 3; int k = (i + 2) % 3; - real_t s = Math::sqrt(m.elements[i][i] - m.elements[j][j] - m.elements[k][k] + 1.0f); + real_t s = Math::sqrt(m.rows[i][i] - m.rows[j][j] - m.rows[k][k] + 1.0f); temp[i] = s * 0.5f; s = 0.5f / s; - temp[3] = (m.elements[k][j] - m.elements[j][k]) * s; - temp[j] = (m.elements[j][i] + m.elements[i][j]) * s; - temp[k] = (m.elements[k][i] + m.elements[i][k]) * s; + temp[3] = (m.rows[k][j] - m.rows[j][k]) * s; + temp[j] = (m.rows[j][i] + m.rows[i][j]) * s; + temp[k] = (m.rows[k][i] + m.rows[i][k]) * s; } return Quaternion(temp[0], temp[1], temp[2], temp[3]); @@ -820,11 +820,11 @@ void Basis::get_axis_angle(Vector3 &r_axis, real_t &r_angle) const { real_t epsilon = 0.01; // margin to allow for rounding errors real_t epsilon2 = 0.1; // margin to distinguish between 0 and 180 degrees - if ((Math::abs(elements[1][0] - elements[0][1]) < epsilon) && (Math::abs(elements[2][0] - elements[0][2]) < epsilon) && (Math::abs(elements[2][1] - elements[1][2]) < epsilon)) { + if ((Math::abs(rows[1][0] - rows[0][1]) < epsilon) && (Math::abs(rows[2][0] - rows[0][2]) < epsilon) && (Math::abs(rows[2][1] - rows[1][2]) < epsilon)) { // singularity found // first check for identity matrix which must have +1 for all terms // in leading diagonal and zero in other terms - if ((Math::abs(elements[1][0] + elements[0][1]) < epsilon2) && (Math::abs(elements[2][0] + elements[0][2]) < epsilon2) && (Math::abs(elements[2][1] + elements[1][2]) < epsilon2) && (Math::abs(elements[0][0] + elements[1][1] + elements[2][2] - 3) < epsilon2)) { + if ((Math::abs(rows[1][0] + rows[0][1]) < epsilon2) && (Math::abs(rows[2][0] + rows[0][2]) < epsilon2) && (Math::abs(rows[2][1] + rows[1][2]) < epsilon2) && (Math::abs(rows[0][0] + rows[1][1] + rows[2][2] - 3) < epsilon2)) { // this singularity is identity matrix so angle = 0 r_axis = Vector3(0, 1, 0); r_angle = 0; @@ -832,13 +832,13 @@ void Basis::get_axis_angle(Vector3 &r_axis, real_t &r_angle) const { } // otherwise this singularity is angle = 180 angle = Math_PI; - real_t xx = (elements[0][0] + 1) / 2; - real_t yy = (elements[1][1] + 1) / 2; - real_t zz = (elements[2][2] + 1) / 2; - real_t xy = (elements[1][0] + elements[0][1]) / 4; - real_t xz = (elements[2][0] + elements[0][2]) / 4; - real_t yz = (elements[2][1] + elements[1][2]) / 4; - if ((xx > yy) && (xx > zz)) { // elements[0][0] is the largest diagonal term + real_t xx = (rows[0][0] + 1) / 2; + real_t yy = (rows[1][1] + 1) / 2; + real_t zz = (rows[2][2] + 1) / 2; + real_t xy = (rows[1][0] + rows[0][1]) / 4; + real_t xz = (rows[2][0] + rows[0][2]) / 4; + real_t yz = (rows[2][1] + rows[1][2]) / 4; + if ((xx > yy) && (xx > zz)) { // rows[0][0] is the largest diagonal term if (xx < epsilon) { x = 0; y = Math_SQRT12; @@ -848,7 +848,7 @@ void Basis::get_axis_angle(Vector3 &r_axis, real_t &r_angle) const { y = xy / x; z = xz / x; } - } else if (yy > zz) { // elements[1][1] is the largest diagonal term + } else if (yy > zz) { // rows[1][1] is the largest diagonal term if (yy < epsilon) { x = Math_SQRT12; y = 0; @@ -858,7 +858,7 @@ void Basis::get_axis_angle(Vector3 &r_axis, real_t &r_angle) const { x = xy / y; z = yz / y; } - } else { // elements[2][2] is the largest diagonal term so base result on this + } else { // rows[2][2] is the largest diagonal term so base result on this if (zz < epsilon) { x = Math_SQRT12; y = Math_SQRT12; @@ -874,15 +874,15 @@ void Basis::get_axis_angle(Vector3 &r_axis, real_t &r_angle) const { return; } // as we have reached here there are no singularities so we can handle normally - real_t s = Math::sqrt((elements[1][2] - elements[2][1]) * (elements[1][2] - elements[2][1]) + (elements[2][0] - elements[0][2]) * (elements[2][0] - elements[0][2]) + (elements[0][1] - elements[1][0]) * (elements[0][1] - elements[1][0])); // s=|axis||sin(angle)|, used to normalise + real_t s = Math::sqrt((rows[1][2] - rows[2][1]) * (rows[1][2] - rows[2][1]) + (rows[2][0] - rows[0][2]) * (rows[2][0] - rows[0][2]) + (rows[0][1] - rows[1][0]) * (rows[0][1] - rows[1][0])); // s=|axis||sin(angle)|, used to normalise - angle = Math::acos((elements[0][0] + elements[1][1] + elements[2][2] - 1) / 2); + angle = Math::acos((rows[0][0] + rows[1][1] + rows[2][2] - 1) / 2); if (angle < 0) { s = -s; } - x = (elements[2][1] - elements[1][2]) / s; - y = (elements[0][2] - elements[2][0]) / s; - z = (elements[1][0] - elements[0][1]) / s; + x = (rows[2][1] - rows[1][2]) / s; + y = (rows[0][2] - rows[2][0]) / s; + z = (rows[1][0] - rows[0][1]) / s; r_axis = Vector3(x, y, z); r_angle = angle; @@ -907,27 +907,27 @@ void Basis::set_axis_angle(const Vector3 &p_axis, real_t p_phi) { #endif Vector3 axis_sq(p_axis.x * p_axis.x, p_axis.y * p_axis.y, p_axis.z * p_axis.z); real_t cosine = Math::cos(p_phi); - elements[0][0] = axis_sq.x + cosine * (1.0f - axis_sq.x); - elements[1][1] = axis_sq.y + cosine * (1.0f - axis_sq.y); - elements[2][2] = axis_sq.z + cosine * (1.0f - axis_sq.z); + rows[0][0] = axis_sq.x + cosine * (1.0f - axis_sq.x); + rows[1][1] = axis_sq.y + cosine * (1.0f - axis_sq.y); + rows[2][2] = axis_sq.z + cosine * (1.0f - axis_sq.z); real_t sine = Math::sin(p_phi); real_t t = 1 - cosine; real_t xyzt = p_axis.x * p_axis.y * t; real_t zyxs = p_axis.z * sine; - elements[0][1] = xyzt - zyxs; - elements[1][0] = xyzt + zyxs; + rows[0][1] = xyzt - zyxs; + rows[1][0] = xyzt + zyxs; xyzt = p_axis.x * p_axis.z * t; zyxs = p_axis.y * sine; - elements[0][2] = xyzt + zyxs; - elements[2][0] = xyzt - zyxs; + rows[0][2] = xyzt + zyxs; + rows[2][0] = xyzt - zyxs; xyzt = p_axis.y * p_axis.z * t; zyxs = p_axis.x * sine; - elements[1][2] = xyzt - zyxs; - elements[2][1] = xyzt + zyxs; + rows[1][2] = xyzt - zyxs; + rows[2][1] = xyzt + zyxs; } void Basis::set_axis_angle_scale(const Vector3 &p_axis, real_t p_phi, const Vector3 &p_scale) { @@ -948,24 +948,24 @@ void Basis::set_quaternion_scale(const Quaternion &p_quaternion, const Vector3 & // This also sets the non-diagonal elements to 0, which is misleading from the // name, so we want this method to be private. Use `from_scale` externally. void Basis::_set_diagonal(const Vector3 &p_diag) { - elements[0][0] = p_diag.x; - elements[0][1] = 0; - elements[0][2] = 0; + rows[0][0] = p_diag.x; + rows[0][1] = 0; + rows[0][2] = 0; - elements[1][0] = 0; - elements[1][1] = p_diag.y; - elements[1][2] = 0; + rows[1][0] = 0; + rows[1][1] = p_diag.y; + rows[1][2] = 0; - elements[2][0] = 0; - elements[2][1] = 0; - elements[2][2] = p_diag.z; + rows[2][0] = 0; + rows[2][1] = 0; + rows[2][2] = p_diag.z; } Basis Basis::lerp(const Basis &p_to, const real_t &p_weight) const { Basis b; - b.elements[0] = elements[0].lerp(p_to.elements[0], p_weight); - b.elements[1] = elements[1].lerp(p_to.elements[1], p_weight); - b.elements[2] = elements[2].lerp(p_to.elements[2], p_weight); + b.rows[0] = rows[0].lerp(p_to.rows[0], p_weight); + b.rows[1] = rows[1].lerp(p_to.rows[1], p_weight); + b.rows[2] = rows[2].lerp(p_to.rows[2], p_weight); return b; } @@ -976,9 +976,9 @@ Basis Basis::slerp(const Basis &p_to, const real_t &p_weight) const { Quaternion to(p_to); Basis b(from.slerp(to, p_weight)); - b.elements[0] *= Math::lerp(elements[0].length(), p_to.elements[0].length(), p_weight); - b.elements[1] *= Math::lerp(elements[1].length(), p_to.elements[1].length(), p_weight); - b.elements[2] *= Math::lerp(elements[2].length(), p_to.elements[2].length(), p_weight); + b.rows[0] *= Math::lerp(rows[0].length(), p_to.rows[0].length(), p_weight); + b.rows[1] *= Math::lerp(rows[1].length(), p_to.rows[1].length(), p_weight); + b.rows[2] *= Math::lerp(rows[2].length(), p_to.rows[2].length(), p_weight); return b; } @@ -1004,15 +1004,15 @@ void Basis::rotate_sh(real_t *p_values) { const real_t src[9] = { p_values[0], p_values[1], p_values[2], p_values[3], p_values[4], p_values[5], p_values[6], p_values[7], p_values[8] }; - real_t m00 = elements[0][0]; - real_t m01 = elements[0][1]; - real_t m02 = elements[0][2]; - real_t m10 = elements[1][0]; - real_t m11 = elements[1][1]; - real_t m12 = elements[1][2]; - real_t m20 = elements[2][0]; - real_t m21 = elements[2][1]; - real_t m22 = elements[2][2]; + real_t m00 = rows[0][0]; + real_t m01 = rows[0][1]; + real_t m02 = rows[0][2]; + real_t m10 = rows[1][0]; + real_t m11 = rows[1][1]; + real_t m12 = rows[1][2]; + real_t m20 = rows[2][0]; + real_t m21 = rows[2][1]; + real_t m22 = rows[2][2]; p_values[0] = src[0]; p_values[1] = m11 * src[1] - m12 * src[2] + m10 * src[3]; diff --git a/core/math/basis.h b/core/math/basis.h index 683f05150c..7bd75be091 100644 --- a/core/math/basis.h +++ b/core/math/basis.h @@ -35,17 +35,17 @@ #include "core/math/vector3.h" struct _NO_DISCARD_ Basis { - Vector3 elements[3] = { + Vector3 rows[3] = { Vector3(1, 0, 0), Vector3(0, 1, 0), Vector3(0, 0, 1) }; _FORCE_INLINE_ const Vector3 &operator[](int axis) const { - return elements[axis]; + return rows[axis]; } _FORCE_INLINE_ Vector3 &operator[](int axis) { - return elements[axis]; + return rows[axis]; } void invert(); @@ -59,14 +59,14 @@ struct _NO_DISCARD_ Basis { void from_z(const Vector3 &p_z); _FORCE_INLINE_ Vector3 get_axis(int p_axis) const { - // get actual basis axis (elements is transposed for performance) - return Vector3(elements[0][p_axis], elements[1][p_axis], elements[2][p_axis]); + // get actual basis axis column (we store transposed as rows for performance) + return Vector3(rows[0][p_axis], rows[1][p_axis], rows[2][p_axis]); } _FORCE_INLINE_ void set_axis(int p_axis, const Vector3 &p_value) { - // get actual basis axis (elements is transposed for performance) - elements[0][p_axis] = p_value.x; - elements[1][p_axis] = p_value.y; - elements[2][p_axis] = p_value.z; + // get actual basis axis column (we store transposed as rows for performance) + rows[0][p_axis] = p_value.x; + rows[1][p_axis] = p_value.y; + rows[2][p_axis] = p_value.z; } void rotate(const Vector3 &p_axis, real_t p_phi); @@ -135,13 +135,13 @@ struct _NO_DISCARD_ Basis { // transposed dot products _FORCE_INLINE_ real_t tdotx(const Vector3 &v) const { - return elements[0][0] * v[0] + elements[1][0] * v[1] + elements[2][0] * v[2]; + return rows[0][0] * v[0] + rows[1][0] * v[1] + rows[2][0] * v[2]; } _FORCE_INLINE_ real_t tdoty(const Vector3 &v) const { - return elements[0][1] * v[0] + elements[1][1] * v[1] + elements[2][1] * v[2]; + return rows[0][1] * v[0] + rows[1][1] * v[1] + rows[2][1] * v[2]; } _FORCE_INLINE_ real_t tdotz(const Vector3 &v) const { - return elements[0][2] * v[0] + elements[1][2] * v[1] + elements[2][2] * v[2]; + return rows[0][2] * v[0] + rows[1][2] * v[1] + rows[2][2] * v[2]; } bool is_equal_approx(const Basis &p_basis) const; @@ -176,15 +176,15 @@ struct _NO_DISCARD_ Basis { /* create / set */ _FORCE_INLINE_ void set(real_t xx, real_t xy, real_t xz, real_t yx, real_t yy, real_t yz, real_t zx, real_t zy, real_t zz) { - elements[0][0] = xx; - elements[0][1] = xy; - elements[0][2] = xz; - elements[1][0] = yx; - elements[1][1] = yy; - elements[1][2] = yz; - elements[2][0] = zx; - elements[2][1] = zy; - elements[2][2] = zz; + rows[0][0] = xx; + rows[0][1] = xy; + rows[0][2] = xz; + rows[1][0] = yx; + rows[1][1] = yy; + rows[1][2] = yz; + rows[2][0] = zx; + rows[2][1] = zy; + rows[2][2] = zz; } _FORCE_INLINE_ void set(const Vector3 &p_x, const Vector3 &p_y, const Vector3 &p_z) { set_axis(0, p_x); @@ -192,39 +192,39 @@ struct _NO_DISCARD_ Basis { set_axis(2, p_z); } _FORCE_INLINE_ Vector3 get_column(int i) const { - return Vector3(elements[0][i], elements[1][i], elements[2][i]); + return Vector3(rows[0][i], rows[1][i], rows[2][i]); } _FORCE_INLINE_ Vector3 get_row(int i) const { - return Vector3(elements[i][0], elements[i][1], elements[i][2]); + return Vector3(rows[i][0], rows[i][1], rows[i][2]); } _FORCE_INLINE_ Vector3 get_main_diagonal() const { - return Vector3(elements[0][0], elements[1][1], elements[2][2]); + return Vector3(rows[0][0], rows[1][1], rows[2][2]); } _FORCE_INLINE_ void set_row(int i, const Vector3 &p_row) { - elements[i][0] = p_row.x; - elements[i][1] = p_row.y; - elements[i][2] = p_row.z; + rows[i][0] = p_row.x; + rows[i][1] = p_row.y; + rows[i][2] = p_row.z; } _FORCE_INLINE_ void set_zero() { - elements[0].zero(); - elements[1].zero(); - elements[2].zero(); + rows[0].zero(); + rows[1].zero(); + rows[2].zero(); } _FORCE_INLINE_ Basis transpose_xform(const Basis &m) const { return Basis( - elements[0].x * m[0].x + elements[1].x * m[1].x + elements[2].x * m[2].x, - elements[0].x * m[0].y + elements[1].x * m[1].y + elements[2].x * m[2].y, - elements[0].x * m[0].z + elements[1].x * m[1].z + elements[2].x * m[2].z, - elements[0].y * m[0].x + elements[1].y * m[1].x + elements[2].y * m[2].x, - elements[0].y * m[0].y + elements[1].y * m[1].y + elements[2].y * m[2].y, - elements[0].y * m[0].z + elements[1].y * m[1].z + elements[2].y * m[2].z, - elements[0].z * m[0].x + elements[1].z * m[1].x + elements[2].z * m[2].x, - elements[0].z * m[0].y + elements[1].z * m[1].y + elements[2].z * m[2].y, - elements[0].z * m[0].z + elements[1].z * m[1].z + elements[2].z * m[2].z); + rows[0].x * m[0].x + rows[1].x * m[1].x + rows[2].x * m[2].x, + rows[0].x * m[0].y + rows[1].x * m[1].y + rows[2].x * m[2].y, + rows[0].x * m[0].z + rows[1].x * m[1].z + rows[2].x * m[2].z, + rows[0].y * m[0].x + rows[1].y * m[1].x + rows[2].y * m[2].x, + rows[0].y * m[0].y + rows[1].y * m[1].y + rows[2].y * m[2].y, + rows[0].y * m[0].z + rows[1].y * m[1].z + rows[2].y * m[2].z, + rows[0].z * m[0].x + rows[1].z * m[1].x + rows[2].z * m[2].x, + rows[0].z * m[0].y + rows[1].z * m[1].y + rows[2].z * m[2].y, + rows[0].z * m[0].z + rows[1].z * m[1].z + rows[2].z * m[2].z); } Basis(real_t xx, real_t xy, real_t xz, real_t yx, real_t yy, real_t yz, real_t zx, real_t zy, real_t zz) { set(xx, xy, xz, yx, yy, yz, zx, zy, zz); @@ -253,9 +253,9 @@ struct _NO_DISCARD_ Basis { static Basis from_scale(const Vector3 &p_scale); _FORCE_INLINE_ Basis(const Vector3 &row0, const Vector3 &row1, const Vector3 &row2) { - elements[0] = row0; - elements[1] = row1; - elements[2] = row2; + rows[0] = row0; + rows[1] = row1; + rows[2] = row2; } _FORCE_INLINE_ Basis() {} @@ -267,22 +267,22 @@ private: _FORCE_INLINE_ void Basis::operator*=(const Basis &p_matrix) { set( - p_matrix.tdotx(elements[0]), p_matrix.tdoty(elements[0]), p_matrix.tdotz(elements[0]), - p_matrix.tdotx(elements[1]), p_matrix.tdoty(elements[1]), p_matrix.tdotz(elements[1]), - p_matrix.tdotx(elements[2]), p_matrix.tdoty(elements[2]), p_matrix.tdotz(elements[2])); + p_matrix.tdotx(rows[0]), p_matrix.tdoty(rows[0]), p_matrix.tdotz(rows[0]), + p_matrix.tdotx(rows[1]), p_matrix.tdoty(rows[1]), p_matrix.tdotz(rows[1]), + p_matrix.tdotx(rows[2]), p_matrix.tdoty(rows[2]), p_matrix.tdotz(rows[2])); } _FORCE_INLINE_ Basis Basis::operator*(const Basis &p_matrix) const { return Basis( - p_matrix.tdotx(elements[0]), p_matrix.tdoty(elements[0]), p_matrix.tdotz(elements[0]), - p_matrix.tdotx(elements[1]), p_matrix.tdoty(elements[1]), p_matrix.tdotz(elements[1]), - p_matrix.tdotx(elements[2]), p_matrix.tdoty(elements[2]), p_matrix.tdotz(elements[2])); + p_matrix.tdotx(rows[0]), p_matrix.tdoty(rows[0]), p_matrix.tdotz(rows[0]), + p_matrix.tdotx(rows[1]), p_matrix.tdoty(rows[1]), p_matrix.tdotz(rows[1]), + p_matrix.tdotx(rows[2]), p_matrix.tdoty(rows[2]), p_matrix.tdotz(rows[2])); } _FORCE_INLINE_ void Basis::operator+=(const Basis &p_matrix) { - elements[0] += p_matrix.elements[0]; - elements[1] += p_matrix.elements[1]; - elements[2] += p_matrix.elements[2]; + rows[0] += p_matrix.rows[0]; + rows[1] += p_matrix.rows[1]; + rows[2] += p_matrix.rows[2]; } _FORCE_INLINE_ Basis Basis::operator+(const Basis &p_matrix) const { @@ -292,9 +292,9 @@ _FORCE_INLINE_ Basis Basis::operator+(const Basis &p_matrix) const { } _FORCE_INLINE_ void Basis::operator-=(const Basis &p_matrix) { - elements[0] -= p_matrix.elements[0]; - elements[1] -= p_matrix.elements[1]; - elements[2] -= p_matrix.elements[2]; + rows[0] -= p_matrix.rows[0]; + rows[1] -= p_matrix.rows[1]; + rows[2] -= p_matrix.rows[2]; } _FORCE_INLINE_ Basis Basis::operator-(const Basis &p_matrix) const { @@ -304,9 +304,9 @@ _FORCE_INLINE_ Basis Basis::operator-(const Basis &p_matrix) const { } _FORCE_INLINE_ void Basis::operator*=(const real_t p_val) { - elements[0] *= p_val; - elements[1] *= p_val; - elements[2] *= p_val; + rows[0] *= p_val; + rows[1] *= p_val; + rows[2] *= p_val; } _FORCE_INLINE_ Basis Basis::operator*(const real_t p_val) const { @@ -317,22 +317,22 @@ _FORCE_INLINE_ Basis Basis::operator*(const real_t p_val) const { Vector3 Basis::xform(const Vector3 &p_vector) const { return Vector3( - elements[0].dot(p_vector), - elements[1].dot(p_vector), - elements[2].dot(p_vector)); + rows[0].dot(p_vector), + rows[1].dot(p_vector), + rows[2].dot(p_vector)); } Vector3 Basis::xform_inv(const Vector3 &p_vector) const { return Vector3( - (elements[0][0] * p_vector.x) + (elements[1][0] * p_vector.y) + (elements[2][0] * p_vector.z), - (elements[0][1] * p_vector.x) + (elements[1][1] * p_vector.y) + (elements[2][1] * p_vector.z), - (elements[0][2] * p_vector.x) + (elements[1][2] * p_vector.y) + (elements[2][2] * p_vector.z)); + (rows[0][0] * p_vector.x) + (rows[1][0] * p_vector.y) + (rows[2][0] * p_vector.z), + (rows[0][1] * p_vector.x) + (rows[1][1] * p_vector.y) + (rows[2][1] * p_vector.z), + (rows[0][2] * p_vector.x) + (rows[1][2] * p_vector.y) + (rows[2][2] * p_vector.z)); } real_t Basis::determinant() const { - return elements[0][0] * (elements[1][1] * elements[2][2] - elements[2][1] * elements[1][2]) - - elements[1][0] * (elements[0][1] * elements[2][2] - elements[2][1] * elements[0][2]) + - elements[2][0] * (elements[0][1] * elements[1][2] - elements[1][1] * elements[0][2]); + return rows[0][0] * (rows[1][1] * rows[2][2] - rows[2][1] * rows[1][2]) - + rows[1][0] * (rows[0][1] * rows[2][2] - rows[2][1] * rows[0][2]) + + rows[2][0] * (rows[0][1] * rows[1][2] - rows[1][1] * rows[0][2]); } #endif // BASIS_H diff --git a/core/math/camera_matrix.cpp b/core/math/camera_matrix.cpp index f4392c74b7..9443addd22 100644 --- a/core/math/camera_matrix.cpp +++ b/core/math/camera_matrix.cpp @@ -714,17 +714,17 @@ CameraMatrix::operator Transform3D() const { Transform3D tr; const real_t *m = &matrix[0][0]; - tr.basis.elements[0][0] = m[0]; - tr.basis.elements[1][0] = m[1]; - tr.basis.elements[2][0] = m[2]; + tr.basis.rows[0][0] = m[0]; + tr.basis.rows[1][0] = m[1]; + tr.basis.rows[2][0] = m[2]; - tr.basis.elements[0][1] = m[4]; - tr.basis.elements[1][1] = m[5]; - tr.basis.elements[2][1] = m[6]; + tr.basis.rows[0][1] = m[4]; + tr.basis.rows[1][1] = m[5]; + tr.basis.rows[2][1] = m[6]; - tr.basis.elements[0][2] = m[8]; - tr.basis.elements[1][2] = m[9]; - tr.basis.elements[2][2] = m[10]; + tr.basis.rows[0][2] = m[8]; + tr.basis.rows[1][2] = m[9]; + tr.basis.rows[2][2] = m[10]; tr.origin.x = m[12]; tr.origin.y = m[13]; @@ -737,17 +737,17 @@ CameraMatrix::CameraMatrix(const Transform3D &p_transform) { const Transform3D &tr = p_transform; real_t *m = &matrix[0][0]; - m[0] = tr.basis.elements[0][0]; - m[1] = tr.basis.elements[1][0]; - m[2] = tr.basis.elements[2][0]; + m[0] = tr.basis.rows[0][0]; + m[1] = tr.basis.rows[1][0]; + m[2] = tr.basis.rows[2][0]; m[3] = 0.0; - m[4] = tr.basis.elements[0][1]; - m[5] = tr.basis.elements[1][1]; - m[6] = tr.basis.elements[2][1]; + m[4] = tr.basis.rows[0][1]; + m[5] = tr.basis.rows[1][1]; + m[6] = tr.basis.rows[2][1]; m[7] = 0.0; - m[8] = tr.basis.elements[0][2]; - m[9] = tr.basis.elements[1][2]; - m[10] = tr.basis.elements[2][2]; + m[8] = tr.basis.rows[0][2]; + m[9] = tr.basis.rows[1][2]; + m[10] = tr.basis.rows[2][2]; m[11] = 0.0; m[12] = tr.origin.x; m[13] = tr.origin.y; diff --git a/core/math/math_fieldwise.cpp b/core/math/math_fieldwise.cpp index 1717ecd74b..4be4809e3f 100644 --- a/core/math/math_fieldwise.cpp +++ b/core/math/math_fieldwise.cpp @@ -115,12 +115,12 @@ Variant fieldwise_assign(const Variant &p_target, const Variant &p_source, const case Variant::TRANSFORM2D: { SETUP_TYPE(Transform2D) - /**/ TRY_TRANSFER_FIELD("xx", elements[0][0]) - else TRY_TRANSFER_FIELD("xy", elements[0][1]) - else TRY_TRANSFER_FIELD("yx", elements[1][0]) - else TRY_TRANSFER_FIELD("yy", elements[1][1]) - else TRY_TRANSFER_FIELD("ox", elements[2][0]) - else TRY_TRANSFER_FIELD("oy", elements[2][1]) + /**/ TRY_TRANSFER_FIELD("xx", columns[0][0]) + else TRY_TRANSFER_FIELD("xy", columns[0][1]) + else TRY_TRANSFER_FIELD("yx", columns[1][0]) + else TRY_TRANSFER_FIELD("yy", columns[1][1]) + else TRY_TRANSFER_FIELD("ox", columns[2][0]) + else TRY_TRANSFER_FIELD("oy", columns[2][1]) return target; } @@ -128,15 +128,15 @@ Variant fieldwise_assign(const Variant &p_target, const Variant &p_source, const case Variant::BASIS: { SETUP_TYPE(Basis) - /**/ TRY_TRANSFER_FIELD("xx", elements[0][0]) - else TRY_TRANSFER_FIELD("xy", elements[0][1]) - else TRY_TRANSFER_FIELD("xz", elements[0][2]) - else TRY_TRANSFER_FIELD("yx", elements[1][0]) - else TRY_TRANSFER_FIELD("yy", elements[1][1]) - else TRY_TRANSFER_FIELD("yz", elements[1][2]) - else TRY_TRANSFER_FIELD("zx", elements[2][0]) - else TRY_TRANSFER_FIELD("zy", elements[2][1]) - else TRY_TRANSFER_FIELD("zz", elements[2][2]) + /**/ TRY_TRANSFER_FIELD("xx", rows[0][0]) + else TRY_TRANSFER_FIELD("xy", rows[0][1]) + else TRY_TRANSFER_FIELD("xz", rows[0][2]) + else TRY_TRANSFER_FIELD("yx", rows[1][0]) + else TRY_TRANSFER_FIELD("yy", rows[1][1]) + else TRY_TRANSFER_FIELD("yz", rows[1][2]) + else TRY_TRANSFER_FIELD("zx", rows[2][0]) + else TRY_TRANSFER_FIELD("zy", rows[2][1]) + else TRY_TRANSFER_FIELD("zz", rows[2][2]) return target; } @@ -144,15 +144,15 @@ Variant fieldwise_assign(const Variant &p_target, const Variant &p_source, const case Variant::TRANSFORM3D: { SETUP_TYPE(Transform3D) - /**/ TRY_TRANSFER_FIELD("xx", basis.elements[0][0]) - else TRY_TRANSFER_FIELD("xy", basis.elements[0][1]) - else TRY_TRANSFER_FIELD("xz", basis.elements[0][2]) - else TRY_TRANSFER_FIELD("yx", basis.elements[1][0]) - else TRY_TRANSFER_FIELD("yy", basis.elements[1][1]) - else TRY_TRANSFER_FIELD("yz", basis.elements[1][2]) - else TRY_TRANSFER_FIELD("zx", basis.elements[2][0]) - else TRY_TRANSFER_FIELD("zy", basis.elements[2][1]) - else TRY_TRANSFER_FIELD("zz", basis.elements[2][2]) + /**/ TRY_TRANSFER_FIELD("xx", basis.rows[0][0]) + else TRY_TRANSFER_FIELD("xy", basis.rows[0][1]) + else TRY_TRANSFER_FIELD("xz", basis.rows[0][2]) + else TRY_TRANSFER_FIELD("yx", basis.rows[1][0]) + else TRY_TRANSFER_FIELD("yy", basis.rows[1][1]) + else TRY_TRANSFER_FIELD("yz", basis.rows[1][2]) + else TRY_TRANSFER_FIELD("zx", basis.rows[2][0]) + else TRY_TRANSFER_FIELD("zy", basis.rows[2][1]) + else TRY_TRANSFER_FIELD("zz", basis.rows[2][2]) else TRY_TRANSFER_FIELD("xo", origin.x) else TRY_TRANSFER_FIELD("yo", origin.y) else TRY_TRANSFER_FIELD("zo", origin.z) diff --git a/core/math/rect2.cpp b/core/math/rect2.cpp index d6e20bdc3c..9e78ead816 100644 --- a/core/math/rect2.cpp +++ b/core/math/rect2.cpp @@ -201,33 +201,33 @@ next4: Vector2(position.x + size.x, position.y + size.y), }; - real_t maxa = p_xform.elements[0].dot(xf_points2[0]); + real_t maxa = p_xform.columns[0].dot(xf_points2[0]); real_t mina = maxa; - real_t dp = p_xform.elements[0].dot(xf_points2[1]); + real_t dp = p_xform.columns[0].dot(xf_points2[1]); maxa = MAX(dp, maxa); mina = MIN(dp, mina); - dp = p_xform.elements[0].dot(xf_points2[2]); + dp = p_xform.columns[0].dot(xf_points2[2]); maxa = MAX(dp, maxa); mina = MIN(dp, mina); - dp = p_xform.elements[0].dot(xf_points2[3]); + dp = p_xform.columns[0].dot(xf_points2[3]); maxa = MAX(dp, maxa); mina = MIN(dp, mina); - real_t maxb = p_xform.elements[0].dot(xf_points[0]); + real_t maxb = p_xform.columns[0].dot(xf_points[0]); real_t minb = maxb; - dp = p_xform.elements[0].dot(xf_points[1]); + dp = p_xform.columns[0].dot(xf_points[1]); maxb = MAX(dp, maxb); minb = MIN(dp, minb); - dp = p_xform.elements[0].dot(xf_points[2]); + dp = p_xform.columns[0].dot(xf_points[2]); maxb = MAX(dp, maxb); minb = MIN(dp, minb); - dp = p_xform.elements[0].dot(xf_points[3]); + dp = p_xform.columns[0].dot(xf_points[3]); maxb = MAX(dp, maxb); minb = MIN(dp, minb); @@ -238,33 +238,33 @@ next4: return false; } - maxa = p_xform.elements[1].dot(xf_points2[0]); + maxa = p_xform.columns[1].dot(xf_points2[0]); mina = maxa; - dp = p_xform.elements[1].dot(xf_points2[1]); + dp = p_xform.columns[1].dot(xf_points2[1]); maxa = MAX(dp, maxa); mina = MIN(dp, mina); - dp = p_xform.elements[1].dot(xf_points2[2]); + dp = p_xform.columns[1].dot(xf_points2[2]); maxa = MAX(dp, maxa); mina = MIN(dp, mina); - dp = p_xform.elements[1].dot(xf_points2[3]); + dp = p_xform.columns[1].dot(xf_points2[3]); maxa = MAX(dp, maxa); mina = MIN(dp, mina); - maxb = p_xform.elements[1].dot(xf_points[0]); + maxb = p_xform.columns[1].dot(xf_points[0]); minb = maxb; - dp = p_xform.elements[1].dot(xf_points[1]); + dp = p_xform.columns[1].dot(xf_points[1]); maxb = MAX(dp, maxb); minb = MIN(dp, minb); - dp = p_xform.elements[1].dot(xf_points[2]); + dp = p_xform.columns[1].dot(xf_points[2]); maxb = MAX(dp, maxb); minb = MIN(dp, minb); - dp = p_xform.elements[1].dot(xf_points[3]); + dp = p_xform.columns[1].dot(xf_points[3]); maxb = MAX(dp, maxb); minb = MIN(dp, minb); diff --git a/core/math/transform_2d.cpp b/core/math/transform_2d.cpp index 71953e4130..5c946d550b 100644 --- a/core/math/transform_2d.cpp +++ b/core/math/transform_2d.cpp @@ -35,8 +35,8 @@ void Transform2D::invert() { // FIXME: this function assumes the basis is a rotation matrix, with no scaling. // Transform2D::affine_inverse can handle matrices with scaling, so GDScript should eventually use that. - SWAP(elements[0][1], elements[1][0]); - elements[2] = basis_xform(-elements[2]); + SWAP(columns[0][1], columns[1][0]); + columns[2] = basis_xform(-columns[2]); } Transform2D Transform2D::inverse() const { @@ -52,11 +52,11 @@ void Transform2D::affine_invert() { #endif real_t idet = 1.0f / det; - SWAP(elements[0][0], elements[1][1]); - elements[0] *= Vector2(idet, -idet); - elements[1] *= Vector2(-idet, idet); + SWAP(columns[0][0], columns[1][1]); + columns[0] *= Vector2(idet, -idet); + columns[1] *= Vector2(-idet, idet); - elements[2] = basis_xform(-elements[2]); + columns[2] = basis_xform(-columns[2]); } Transform2D Transform2D::affine_inverse() const { @@ -71,69 +71,69 @@ void Transform2D::rotate(const real_t p_phi) { real_t Transform2D::get_skew() const { real_t det = basis_determinant(); - return Math::acos(elements[0].normalized().dot(SIGN(det) * elements[1].normalized())) - (real_t)Math_PI * 0.5f; + return Math::acos(columns[0].normalized().dot(SIGN(det) * columns[1].normalized())) - (real_t)Math_PI * 0.5f; } void Transform2D::set_skew(const real_t p_angle) { real_t det = basis_determinant(); - elements[1] = SIGN(det) * elements[0].rotated(((real_t)Math_PI * 0.5f + p_angle)).normalized() * elements[1].length(); + columns[1] = SIGN(det) * columns[0].rotated(((real_t)Math_PI * 0.5f + p_angle)).normalized() * columns[1].length(); } real_t Transform2D::get_rotation() const { - return Math::atan2(elements[0].y, elements[0].x); + return Math::atan2(columns[0].y, columns[0].x); } void Transform2D::set_rotation(const real_t p_rot) { Size2 scale = get_scale(); real_t cr = Math::cos(p_rot); real_t sr = Math::sin(p_rot); - elements[0][0] = cr; - elements[0][1] = sr; - elements[1][0] = -sr; - elements[1][1] = cr; + columns[0][0] = cr; + columns[0][1] = sr; + columns[1][0] = -sr; + columns[1][1] = cr; set_scale(scale); } Transform2D::Transform2D(const real_t p_rot, const Vector2 &p_pos) { real_t cr = Math::cos(p_rot); real_t sr = Math::sin(p_rot); - elements[0][0] = cr; - elements[0][1] = sr; - elements[1][0] = -sr; - elements[1][1] = cr; - elements[2] = p_pos; + columns[0][0] = cr; + columns[0][1] = sr; + columns[1][0] = -sr; + columns[1][1] = cr; + columns[2] = p_pos; } Transform2D::Transform2D(const real_t p_rot, const Size2 &p_scale, const real_t p_skew, const Vector2 &p_pos) { - elements[0][0] = Math::cos(p_rot) * p_scale.x; - elements[1][1] = Math::cos(p_rot + p_skew) * p_scale.y; - elements[1][0] = -Math::sin(p_rot + p_skew) * p_scale.y; - elements[0][1] = Math::sin(p_rot) * p_scale.x; - elements[2] = p_pos; + columns[0][0] = Math::cos(p_rot) * p_scale.x; + columns[1][1] = Math::cos(p_rot + p_skew) * p_scale.y; + columns[1][0] = -Math::sin(p_rot + p_skew) * p_scale.y; + columns[0][1] = Math::sin(p_rot) * p_scale.x; + columns[2] = p_pos; } Size2 Transform2D::get_scale() const { real_t det_sign = SIGN(basis_determinant()); - return Size2(elements[0].length(), det_sign * elements[1].length()); + return Size2(columns[0].length(), det_sign * columns[1].length()); } void Transform2D::set_scale(const Size2 &p_scale) { - elements[0].normalize(); - elements[1].normalize(); - elements[0] *= p_scale.x; - elements[1] *= p_scale.y; + columns[0].normalize(); + columns[1].normalize(); + columns[0] *= p_scale.x; + columns[1] *= p_scale.y; } void Transform2D::scale(const Size2 &p_scale) { scale_basis(p_scale); - elements[2] *= p_scale; + columns[2] *= p_scale; } void Transform2D::scale_basis(const Size2 &p_scale) { - elements[0][0] *= p_scale.x; - elements[0][1] *= p_scale.y; - elements[1][0] *= p_scale.x; - elements[1][1] *= p_scale.y; + columns[0][0] *= p_scale.x; + columns[0][1] *= p_scale.y; + columns[1][0] *= p_scale.x; + columns[1][1] *= p_scale.y; } void Transform2D::translate(const real_t p_tx, const real_t p_ty) { @@ -141,21 +141,21 @@ void Transform2D::translate(const real_t p_tx, const real_t p_ty) { } void Transform2D::translate(const Vector2 &p_translation) { - elements[2] += basis_xform(p_translation); + columns[2] += basis_xform(p_translation); } void Transform2D::orthonormalize() { // Gram-Schmidt Process - Vector2 x = elements[0]; - Vector2 y = elements[1]; + Vector2 x = columns[0]; + Vector2 y = columns[1]; x.normalize(); y = (y - x * (x.dot(y))); y.normalize(); - elements[0] = x; - elements[1] = y; + columns[0] = x; + columns[1] = y; } Transform2D Transform2D::orthonormalized() const { @@ -165,7 +165,7 @@ Transform2D Transform2D::orthonormalized() const { } bool Transform2D::is_equal_approx(const Transform2D &p_transform) const { - return elements[0].is_equal_approx(p_transform.elements[0]) && elements[1].is_equal_approx(p_transform.elements[1]) && elements[2].is_equal_approx(p_transform.elements[2]); + return columns[0].is_equal_approx(p_transform.columns[0]) && columns[1].is_equal_approx(p_transform.columns[1]) && columns[2].is_equal_approx(p_transform.columns[2]); } Transform2D Transform2D::looking_at(const Vector2 &p_target) const { @@ -177,7 +177,7 @@ Transform2D Transform2D::looking_at(const Vector2 &p_target) const { bool Transform2D::operator==(const Transform2D &p_transform) const { for (int i = 0; i < 3; i++) { - if (elements[i] != p_transform.elements[i]) { + if (columns[i] != p_transform.columns[i]) { return false; } } @@ -187,7 +187,7 @@ bool Transform2D::operator==(const Transform2D &p_transform) const { bool Transform2D::operator!=(const Transform2D &p_transform) const { for (int i = 0; i < 3; i++) { - if (elements[i] != p_transform.elements[i]) { + if (columns[i] != p_transform.columns[i]) { return true; } } @@ -196,19 +196,19 @@ bool Transform2D::operator!=(const Transform2D &p_transform) const { } void Transform2D::operator*=(const Transform2D &p_transform) { - elements[2] = xform(p_transform.elements[2]); + columns[2] = xform(p_transform.columns[2]); real_t x0, x1, y0, y1; - x0 = tdotx(p_transform.elements[0]); - x1 = tdoty(p_transform.elements[0]); - y0 = tdotx(p_transform.elements[1]); - y1 = tdoty(p_transform.elements[1]); + x0 = tdotx(p_transform.columns[0]); + x1 = tdoty(p_transform.columns[0]); + y0 = tdotx(p_transform.columns[1]); + y1 = tdoty(p_transform.columns[1]); - elements[0][0] = x0; - elements[0][1] = x1; - elements[1][0] = y0; - elements[1][1] = y1; + columns[0][0] = x0; + columns[0][1] = x1; + columns[1][0] = y0; + columns[1][1] = y1; } Transform2D Transform2D::operator*(const Transform2D &p_transform) const { @@ -231,7 +231,7 @@ Transform2D Transform2D::basis_scaled(const Size2 &p_scale) const { Transform2D Transform2D::untranslated() const { Transform2D copy = *this; - copy.elements[2] = Vector2(); + copy.columns[2] = Vector2(); return copy; } @@ -248,7 +248,7 @@ Transform2D Transform2D::rotated(const real_t p_phi) const { } real_t Transform2D::basis_determinant() const { - return elements[0].x * elements[1].y - elements[0].y * elements[1].x; + return columns[0].x * columns[1].y - columns[0].y * columns[1].x; } Transform2D Transform2D::interpolate_with(const Transform2D &p_transform, const real_t p_c) const { @@ -287,9 +287,9 @@ Transform2D Transform2D::interpolate_with(const Transform2D &p_transform, const } void Transform2D::operator*=(const real_t p_val) { - elements[0] *= p_val; - elements[1] *= p_val; - elements[2] *= p_val; + columns[0] *= p_val; + columns[1] *= p_val; + columns[2] *= p_val; } Transform2D Transform2D::operator*(const real_t p_val) const { @@ -299,7 +299,7 @@ Transform2D Transform2D::operator*(const real_t p_val) const { } Transform2D::operator String() const { - return "[X: " + elements[0].operator String() + - ", Y: " + elements[1].operator String() + - ", O: " + elements[2].operator String() + "]"; + return "[X: " + columns[0].operator String() + + ", Y: " + columns[1].operator String() + + ", O: " + columns[2].operator String() + "]"; } diff --git a/core/math/transform_2d.h b/core/math/transform_2d.h index f4546c13c8..1ad874aef9 100644 --- a/core/math/transform_2d.h +++ b/core/math/transform_2d.h @@ -39,32 +39,32 @@ class String; struct _NO_DISCARD_ Transform2D { - // Warning #1: basis of Transform2D is stored differently from Basis. In terms of elements array, the basis matrix looks like "on paper": - // M = (elements[0][0] elements[1][0]) - // (elements[0][1] elements[1][1]) - // This is such that the columns, which can be interpreted as basis vectors of the coordinate system "painted" on the object, can be accessed as elements[i]. - // Note that this is the opposite of the indices in mathematical texts, meaning: $M_{12}$ in a math book corresponds to elements[1][0] here. + // Warning #1: basis of Transform2D is stored differently from Basis. In terms of columns array, the basis matrix looks like "on paper": + // M = (columns[0][0] columns[1][0]) + // (columns[0][1] columns[1][1]) + // This is such that the columns, which can be interpreted as basis vectors of the coordinate system "painted" on the object, can be accessed as columns[i]. + // Note that this is the opposite of the indices in mathematical texts, meaning: $M_{12}$ in a math book corresponds to columns[1][0] here. // This requires additional care when working with explicit indices. // See https://en.wikipedia.org/wiki/Row-_and_column-major_order for further reading. // Warning #2: 2D be aware that unlike 3D code, 2D code uses a left-handed coordinate system: Y-axis points down, // and angle is measure from +X to +Y in a clockwise-fashion. - Vector2 elements[3]; + Vector2 columns[3]; - _FORCE_INLINE_ real_t tdotx(const Vector2 &v) const { return elements[0][0] * v.x + elements[1][0] * v.y; } - _FORCE_INLINE_ real_t tdoty(const Vector2 &v) const { return elements[0][1] * v.x + elements[1][1] * v.y; } + _FORCE_INLINE_ real_t tdotx(const Vector2 &v) const { return columns[0][0] * v.x + columns[1][0] * v.y; } + _FORCE_INLINE_ real_t tdoty(const Vector2 &v) const { return columns[0][1] * v.x + columns[1][1] * v.y; } - const Vector2 &operator[](int p_idx) const { return elements[p_idx]; } - Vector2 &operator[](int p_idx) { return elements[p_idx]; } + const Vector2 &operator[](int p_idx) const { return columns[p_idx]; } + Vector2 &operator[](int p_idx) { return columns[p_idx]; } _FORCE_INLINE_ Vector2 get_axis(int p_axis) const { ERR_FAIL_INDEX_V(p_axis, 3, Vector2()); - return elements[p_axis]; + return columns[p_axis]; } _FORCE_INLINE_ void set_axis(int p_axis, const Vector2 &p_vec) { ERR_FAIL_INDEX(p_axis, 3); - elements[p_axis] = p_vec; + columns[p_axis] = p_vec; } void invert(); @@ -91,8 +91,8 @@ struct _NO_DISCARD_ Transform2D { Size2 get_scale() const; void set_scale(const Size2 &p_scale); - _FORCE_INLINE_ const Vector2 &get_origin() const { return elements[2]; } - _FORCE_INLINE_ void set_origin(const Vector2 &p_origin) { elements[2] = p_origin; } + _FORCE_INLINE_ const Vector2 &get_origin() const { return columns[2]; } + _FORCE_INLINE_ void set_origin(const Vector2 &p_origin) { columns[2] = p_origin; } Transform2D scaled(const Size2 &p_scale) const; Transform2D basis_scaled(const Size2 &p_scale) const; @@ -129,18 +129,18 @@ struct _NO_DISCARD_ Transform2D { operator String() const; Transform2D(const real_t xx, const real_t xy, const real_t yx, const real_t yy, const real_t ox, const real_t oy) { - elements[0][0] = xx; - elements[0][1] = xy; - elements[1][0] = yx; - elements[1][1] = yy; - elements[2][0] = ox; - elements[2][1] = oy; + columns[0][0] = xx; + columns[0][1] = xy; + columns[1][0] = yx; + columns[1][1] = yy; + columns[2][0] = ox; + columns[2][1] = oy; } Transform2D(const Vector2 &p_x, const Vector2 &p_y, const Vector2 &p_origin) { - elements[0] = p_x; - elements[1] = p_y; - elements[2] = p_origin; + columns[0] = p_x; + columns[1] = p_y; + columns[2] = p_origin; } Transform2D(const real_t p_rot, const Vector2 &p_pos); @@ -148,8 +148,8 @@ struct _NO_DISCARD_ Transform2D { Transform2D(const real_t p_rot, const Size2 &p_scale, const real_t p_skew, const Vector2 &p_pos); Transform2D() { - elements[0][0] = 1.0; - elements[1][1] = 1.0; + columns[0][0] = 1.0; + columns[1][1] = 1.0; } }; @@ -161,28 +161,28 @@ Vector2 Transform2D::basis_xform(const Vector2 &p_vec) const { Vector2 Transform2D::basis_xform_inv(const Vector2 &p_vec) const { return Vector2( - elements[0].dot(p_vec), - elements[1].dot(p_vec)); + columns[0].dot(p_vec), + columns[1].dot(p_vec)); } Vector2 Transform2D::xform(const Vector2 &p_vec) const { return Vector2( tdotx(p_vec), tdoty(p_vec)) + - elements[2]; + columns[2]; } Vector2 Transform2D::xform_inv(const Vector2 &p_vec) const { - Vector2 v = p_vec - elements[2]; + Vector2 v = p_vec - columns[2]; return Vector2( - elements[0].dot(v), - elements[1].dot(v)); + columns[0].dot(v), + columns[1].dot(v)); } Rect2 Transform2D::xform(const Rect2 &p_rect) const { - Vector2 x = elements[0] * p_rect.size.x; - Vector2 y = elements[1] * p_rect.size.y; + Vector2 x = columns[0] * p_rect.size.x; + Vector2 y = columns[1] * p_rect.size.y; Vector2 pos = xform(p_rect.position); Rect2 new_rect; @@ -194,17 +194,17 @@ Rect2 Transform2D::xform(const Rect2 &p_rect) const { } void Transform2D::set_rotation_and_scale(const real_t p_rot, const Size2 &p_scale) { - elements[0][0] = Math::cos(p_rot) * p_scale.x; - elements[1][1] = Math::cos(p_rot) * p_scale.y; - elements[1][0] = -Math::sin(p_rot) * p_scale.y; - elements[0][1] = Math::sin(p_rot) * p_scale.x; + columns[0][0] = Math::cos(p_rot) * p_scale.x; + columns[1][1] = Math::cos(p_rot) * p_scale.y; + columns[1][0] = -Math::sin(p_rot) * p_scale.y; + columns[0][1] = Math::sin(p_rot) * p_scale.x; } void Transform2D::set_rotation_scale_and_skew(const real_t p_rot, const Size2 &p_scale, const real_t p_skew) { - elements[0][0] = Math::cos(p_rot) * p_scale.x; - elements[1][1] = Math::cos(p_rot + p_skew) * p_scale.y; - elements[1][0] = -Math::sin(p_rot + p_skew) * p_scale.y; - elements[0][1] = Math::sin(p_rot) * p_scale.x; + columns[0][0] = Math::cos(p_rot) * p_scale.x; + columns[1][1] = Math::cos(p_rot + p_skew) * p_scale.y; + columns[1][0] = -Math::sin(p_rot + p_skew) * p_scale.y; + columns[0][1] = Math::sin(p_rot) * p_scale.x; } Rect2 Transform2D::xform_inv(const Rect2 &p_rect) const { diff --git a/core/math/transform_3d.h b/core/math/transform_3d.h index 3b4762e221..3f2f62b548 100644 --- a/core/math/transform_3d.h +++ b/core/math/transform_3d.h @@ -135,9 +135,9 @@ _FORCE_INLINE_ Vector3 Transform3D::xform_inv(const Vector3 &p_vector) const { Vector3 v = p_vector - origin; return Vector3( - (basis.elements[0][0] * v.x) + (basis.elements[1][0] * v.y) + (basis.elements[2][0] * v.z), - (basis.elements[0][1] * v.x) + (basis.elements[1][1] * v.y) + (basis.elements[2][1] * v.z), - (basis.elements[0][2] * v.x) + (basis.elements[1][2] * v.y) + (basis.elements[2][2] * v.z)); + (basis.rows[0][0] * v.x) + (basis.rows[1][0] * v.y) + (basis.rows[2][0] * v.z), + (basis.rows[0][1] * v.x) + (basis.rows[1][1] * v.y) + (basis.rows[2][1] * v.z), + (basis.rows[0][2] * v.x) + (basis.rows[1][2] * v.y) + (basis.rows[2][2] * v.z)); } // Neither the plane regular xform or xform_inv are particularly efficient, diff --git a/core/variant/variant.cpp b/core/variant/variant.cpp index 0eb93a72b4..e79da748e9 100644 --- a/core/variant/variant.cpp +++ b/core/variant/variant.cpp @@ -1908,12 +1908,12 @@ Variant::operator Transform3D() const { } else if (type == TRANSFORM2D) { const Transform2D &t = *_data._transform2d; Transform3D m; - m.basis.elements[0][0] = t.elements[0][0]; - m.basis.elements[1][0] = t.elements[0][1]; - m.basis.elements[0][1] = t.elements[1][0]; - m.basis.elements[1][1] = t.elements[1][1]; - m.origin[0] = t.elements[2][0]; - m.origin[1] = t.elements[2][1]; + m.basis.rows[0][0] = t.columns[0][0]; + m.basis.rows[1][0] = t.columns[0][1]; + m.basis.rows[0][1] = t.columns[1][0]; + m.basis.rows[1][1] = t.columns[1][1]; + m.origin[0] = t.columns[2][0]; + m.origin[1] = t.columns[2][1]; return m; } else { return Transform3D(); @@ -1926,12 +1926,12 @@ Variant::operator Transform2D() const { } else if (type == TRANSFORM3D) { const Transform3D &t = *_data._transform3d; Transform2D m; - m.elements[0][0] = t.basis.elements[0][0]; - m.elements[0][1] = t.basis.elements[1][0]; - m.elements[1][0] = t.basis.elements[0][1]; - m.elements[1][1] = t.basis.elements[1][1]; - m.elements[2][0] = t.origin[0]; - m.elements[2][1] = t.origin[1]; + m.columns[0][0] = t.basis.rows[0][0]; + m.columns[0][1] = t.basis.rows[1][0]; + m.columns[1][0] = t.basis.rows[0][1]; + m.columns[1][1] = t.basis.rows[1][1]; + m.columns[2][0] = t.origin[0]; + m.columns[2][1] = t.origin[1]; return m; } else { return Transform2D(); @@ -2790,7 +2790,7 @@ uint32_t Variant::recursive_hash(int recursion_count) const { uint32_t hash = 5831; for (int i = 0; i < 3; i++) { for (int j = 0; j < 2; j++) { - hash = hash_djb2_one_float(_data._transform2d->elements[i][j], hash); + hash = hash_djb2_one_float(_data._transform2d->columns[i][j], hash); } } @@ -2834,7 +2834,7 @@ uint32_t Variant::recursive_hash(int recursion_count) const { uint32_t hash = 5831; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { - hash = hash_djb2_one_float(_data._basis->elements[i][j], hash); + hash = hash_djb2_one_float(_data._basis->rows[i][j], hash); } } @@ -2845,7 +2845,7 @@ uint32_t Variant::recursive_hash(int recursion_count) const { uint32_t hash = 5831; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { - hash = hash_djb2_one_float(_data._transform3d->basis.elements[i][j], hash); + hash = hash_djb2_one_float(_data._transform3d->basis.rows[i][j], hash); } hash = hash_djb2_one_float(_data._transform3d->origin[i], hash); } @@ -3112,7 +3112,7 @@ bool Variant::hash_compare(const Variant &p_variant, int recursion_count) const Transform2D *r = p_variant._data._transform2d; for (int i = 0; i < 3; i++) { - if (!(hash_compare_vector2(l->elements[i], r->elements[i]))) { + if (!(hash_compare_vector2(l->columns[i], r->columns[i]))) { return false; } } @@ -3162,7 +3162,7 @@ bool Variant::hash_compare(const Variant &p_variant, int recursion_count) const const Basis *r = p_variant._data._basis; for (int i = 0; i < 3; i++) { - if (!(hash_compare_vector3(l->elements[i], r->elements[i]))) { + if (!(hash_compare_vector3(l->rows[i], r->rows[i]))) { return false; } } @@ -3175,7 +3175,7 @@ bool Variant::hash_compare(const Variant &p_variant, int recursion_count) const const Transform3D *r = p_variant._data._transform3d; for (int i = 0; i < 3; i++) { - if (!(hash_compare_vector3(l->basis.elements[i], r->basis.elements[i]))) { + if (!(hash_compare_vector3(l->basis.rows[i], r->basis.rows[i]))) { return false; } } diff --git a/core/variant/variant_parser.cpp b/core/variant/variant_parser.cpp index bd13f66a09..2864d0c956 100644 --- a/core/variant/variant_parser.cpp +++ b/core/variant/variant_parser.cpp @@ -1555,7 +1555,7 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str if (i != 0 || j != 0) { s += ", "; } - s += rtos_fix(m3.elements[i][j]); + s += rtos_fix(m3.columns[i][j]); } } @@ -1570,7 +1570,7 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str if (i != 0 || j != 0) { s += ", "; } - s += rtos_fix(m3.elements[i][j]); + s += rtos_fix(m3.rows[i][j]); } } @@ -1586,7 +1586,7 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str if (i != 0 || j != 0) { s += ", "; } - s += rtos_fix(m3.elements[i][j]); + s += rtos_fix(m3.rows[i][j]); } } diff --git a/core/variant/variant_setget.cpp b/core/variant/variant_setget.cpp index 397a57f59f..09097e30e0 100644 --- a/core/variant/variant_setget.cpp +++ b/core/variant/variant_setget.cpp @@ -789,7 +789,7 @@ INDEXED_SETGET_STRUCT_BULTIN_NUMERIC(Vector3i, int64_t, int32_t, 3) INDEXED_SETGET_STRUCT_BULTIN_NUMERIC(Quaternion, double, real_t, 4) INDEXED_SETGET_STRUCT_BULTIN_NUMERIC(Color, double, float, 4) -INDEXED_SETGET_STRUCT_BULTIN_ACCESSOR(Transform2D, Vector2, .elements, 3) +INDEXED_SETGET_STRUCT_BULTIN_ACCESSOR(Transform2D, Vector2, .columns, 3) INDEXED_SETGET_STRUCT_BULTIN_FUNC(Basis, Vector3, set_axis, get_axis, 3) INDEXED_SETGET_STRUCT_TYPED_NUMERIC(PackedByteArray, int64_t, uint8_t) diff --git a/core/variant/variant_setget.h b/core/variant/variant_setget.h index 28277fa5d0..2083e64125 100644 --- a/core/variant/variant_setget.h +++ b/core/variant/variant_setget.h @@ -293,9 +293,9 @@ SETGET_STRUCT(AABB, Vector3, position) SETGET_STRUCT(AABB, Vector3, size) SETGET_STRUCT_FUNC(AABB, Vector3, end, set_end, get_end) -SETGET_STRUCT_CUSTOM(Transform2D, Vector2, x, elements[0]) -SETGET_STRUCT_CUSTOM(Transform2D, Vector2, y, elements[1]) -SETGET_STRUCT_CUSTOM(Transform2D, Vector2, origin, elements[2]) +SETGET_STRUCT_CUSTOM(Transform2D, Vector2, x, columns[0]) +SETGET_STRUCT_CUSTOM(Transform2D, Vector2, y, columns[1]) +SETGET_STRUCT_CUSTOM(Transform2D, Vector2, origin, columns[2]) SETGET_NUMBER_STRUCT_CUSTOM(Plane, double, x, normal.x) SETGET_NUMBER_STRUCT_CUSTOM(Plane, double, y, normal.y) diff --git a/drivers/gles3/rasterizer_canvas_gles3.cpp b/drivers/gles3/rasterizer_canvas_gles3.cpp index e14018c562..1197f4aac1 100644 --- a/drivers/gles3/rasterizer_canvas_gles3.cpp +++ b/drivers/gles3/rasterizer_canvas_gles3.cpp @@ -57,57 +57,57 @@ //}; void RasterizerCanvasGLES3::_update_transform_2d_to_mat4(const Transform2D &p_transform, float *p_mat4) { - p_mat4[0] = p_transform.elements[0][0]; - p_mat4[1] = p_transform.elements[0][1]; + p_mat4[0] = p_transform.columns[0][0]; + p_mat4[1] = p_transform.columns[0][1]; p_mat4[2] = 0; p_mat4[3] = 0; - p_mat4[4] = p_transform.elements[1][0]; - p_mat4[5] = p_transform.elements[1][1]; + p_mat4[4] = p_transform.columns[1][0]; + p_mat4[5] = p_transform.columns[1][1]; p_mat4[6] = 0; p_mat4[7] = 0; p_mat4[8] = 0; p_mat4[9] = 0; p_mat4[10] = 1; p_mat4[11] = 0; - p_mat4[12] = p_transform.elements[2][0]; - p_mat4[13] = p_transform.elements[2][1]; + p_mat4[12] = p_transform.columns[2][0]; + p_mat4[13] = p_transform.columns[2][1]; p_mat4[14] = 0; p_mat4[15] = 1; } void RasterizerCanvasGLES3::_update_transform_2d_to_mat2x4(const Transform2D &p_transform, float *p_mat2x4) { - p_mat2x4[0] = p_transform.elements[0][0]; - p_mat2x4[1] = p_transform.elements[1][0]; + p_mat2x4[0] = p_transform.columns[0][0]; + p_mat2x4[1] = p_transform.columns[1][0]; p_mat2x4[2] = 0; - p_mat2x4[3] = p_transform.elements[2][0]; + p_mat2x4[3] = p_transform.columns[2][0]; - p_mat2x4[4] = p_transform.elements[0][1]; - p_mat2x4[5] = p_transform.elements[1][1]; + p_mat2x4[4] = p_transform.columns[0][1]; + p_mat2x4[5] = p_transform.columns[1][1]; p_mat2x4[6] = 0; - p_mat2x4[7] = p_transform.elements[2][1]; + p_mat2x4[7] = p_transform.columns[2][1]; } void RasterizerCanvasGLES3::_update_transform_2d_to_mat2x3(const Transform2D &p_transform, float *p_mat2x3) { - p_mat2x3[0] = p_transform.elements[0][0]; - p_mat2x3[1] = p_transform.elements[0][1]; - p_mat2x3[2] = p_transform.elements[1][0]; - p_mat2x3[3] = p_transform.elements[1][1]; - p_mat2x3[4] = p_transform.elements[2][0]; - p_mat2x3[5] = p_transform.elements[2][1]; + p_mat2x3[0] = p_transform.columns[0][0]; + p_mat2x3[1] = p_transform.columns[0][1]; + p_mat2x3[2] = p_transform.columns[1][0]; + p_mat2x3[3] = p_transform.columns[1][1]; + p_mat2x3[4] = p_transform.columns[2][0]; + p_mat2x3[5] = p_transform.columns[2][1]; } void RasterizerCanvasGLES3::_update_transform_to_mat4(const Transform3D &p_transform, float *p_mat4) { - p_mat4[0] = p_transform.basis.elements[0][0]; - p_mat4[1] = p_transform.basis.elements[1][0]; - p_mat4[2] = p_transform.basis.elements[2][0]; + p_mat4[0] = p_transform.basis.rows[0][0]; + p_mat4[1] = p_transform.basis.rows[1][0]; + p_mat4[2] = p_transform.basis.rows[2][0]; p_mat4[3] = 0; - p_mat4[4] = p_transform.basis.elements[0][1]; - p_mat4[5] = p_transform.basis.elements[1][1]; - p_mat4[6] = p_transform.basis.elements[2][1]; + p_mat4[4] = p_transform.basis.rows[0][1]; + p_mat4[5] = p_transform.basis.rows[1][1]; + p_mat4[6] = p_transform.basis.rows[2][1]; p_mat4[7] = 0; - p_mat4[8] = p_transform.basis.elements[0][2]; - p_mat4[9] = p_transform.basis.elements[1][2]; - p_mat4[10] = p_transform.basis.elements[2][2]; + p_mat4[8] = p_transform.basis.rows[0][2]; + p_mat4[9] = p_transform.basis.rows[1][2]; + p_mat4[10] = p_transform.basis.rows[2][2]; p_mat4[11] = 0; p_mat4[12] = p_transform.origin.x; p_mat4[13] = p_transform.origin.y; @@ -142,9 +142,9 @@ void RasterizerCanvasGLES3::canvas_render_items(RID p_to_render_target, Item *p_ _update_transform_2d_to_mat4(p_canvas_transform, state_buffer.canvas_transform); Transform2D normal_transform = p_canvas_transform; - normal_transform.elements[0].normalize(); - normal_transform.elements[1].normalize(); - normal_transform.elements[2] = Vector2(); + normal_transform.columns[0].normalize(); + normal_transform.columns[1].normalize(); + normal_transform.columns[2] = Vector2(); _update_transform_2d_to_mat4(normal_transform, state_buffer.canvas_normal_transform); state_buffer.canvas_modulate[0] = p_modulate.r; diff --git a/drivers/gles3/shaders/SCsub b/drivers/gles3/shaders/SCsub index 8443b5df85..79247f38d4 100644 --- a/drivers/gles3/shaders/SCsub +++ b/drivers/gles3/shaders/SCsub @@ -2,6 +2,9 @@ Import("env") +env.Depends("#drivers/gles3/shaders/copy.glsl.gen.h", "#core/math/basis.h") +env.Depends("#drivers/gles3/shaders/copy.glsl.gen.h", "#core/math/transform_2d.h") + if "GLES3_GLSL" in env["BUILDERS"]: env.GLES3_GLSL("canvas.glsl") env.GLES3_GLSL("copy.glsl") diff --git a/drivers/gles3/storage/material_storage.cpp b/drivers/gles3/storage/material_storage.cpp index 8bfb09b83b..d14d26346c 100644 --- a/drivers/gles3/storage/material_storage.cpp +++ b/drivers/gles3/storage/material_storage.cpp @@ -558,13 +558,13 @@ _FORCE_INLINE_ static void _fill_std140_variant_ubo_value(ShaderLanguage::DataTy Transform2D v = value; //in std140 members of mat2 are treated as vec4s - gui[0] = v.elements[0][0]; - gui[1] = v.elements[0][1]; + gui[0] = v.columns[0][0]; + gui[1] = v.columns[0][1]; gui[2] = 0; // ignored gui[3] = 0; // ignored - gui[4] = v.elements[1][0]; - gui[5] = v.elements[1][1]; + gui[4] = v.columns[1][0]; + gui[5] = v.columns[1][1]; gui[6] = 0; // ignored gui[7] = 0; // ignored } @@ -608,19 +608,19 @@ _FORCE_INLINE_ static void _fill_std140_variant_ubo_value(ShaderLanguage::DataTy } } else { Basis v = value; - gui[0] = v.elements[0][0]; - gui[1] = v.elements[1][0]; - gui[2] = v.elements[2][0]; + gui[0] = v.rows[0][0]; + gui[1] = v.rows[1][0]; + gui[2] = v.rows[2][0]; gui[3] = 0; // ignored - gui[4] = v.elements[0][1]; - gui[5] = v.elements[1][1]; - gui[6] = v.elements[2][1]; + gui[4] = v.rows[0][1]; + gui[5] = v.rows[1][1]; + gui[6] = v.rows[2][1]; gui[7] = 0; // ignored - gui[8] = v.elements[0][2]; - gui[9] = v.elements[1][2]; - gui[10] = v.elements[2][2]; + gui[8] = v.rows[0][2]; + gui[9] = v.rows[1][2]; + gui[10] = v.rows[2][2]; gui[11] = 0; // ignored } } break; @@ -676,19 +676,19 @@ _FORCE_INLINE_ static void _fill_std140_variant_ubo_value(ShaderLanguage::DataTy } } else { Transform3D v = value; - gui[0] = v.basis.elements[0][0]; - gui[1] = v.basis.elements[1][0]; - gui[2] = v.basis.elements[2][0]; + gui[0] = v.basis.rows[0][0]; + gui[1] = v.basis.rows[1][0]; + gui[2] = v.basis.rows[2][0]; gui[3] = 0; - gui[4] = v.basis.elements[0][1]; - gui[5] = v.basis.elements[1][1]; - gui[6] = v.basis.elements[2][1]; + gui[4] = v.basis.rows[0][1]; + gui[5] = v.basis.rows[1][1]; + gui[6] = v.basis.rows[2][1]; gui[7] = 0; - gui[8] = v.basis.elements[0][2]; - gui[9] = v.basis.elements[1][2]; - gui[10] = v.basis.elements[2][2]; + gui[8] = v.basis.rows[0][2]; + gui[9] = v.basis.rows[1][2]; + gui[10] = v.basis.rows[2][2]; gui[11] = 0; gui[12] = v.origin.x; @@ -1908,19 +1908,19 @@ void MaterialStorage::_global_variable_store_in_buffer(int32_t p_index, RS::Glob case RS::GLOBAL_VAR_TYPE_MAT3: { GlobalVariables::Value *bv = &global_variables.buffer_values[p_index]; Basis v = p_value; - bv[0].x = v.elements[0][0]; - bv[0].y = v.elements[1][0]; - bv[0].z = v.elements[2][0]; + bv[0].x = v.rows[0][0]; + bv[0].y = v.rows[1][0]; + bv[0].z = v.rows[2][0]; bv[0].w = 0; - bv[1].x = v.elements[0][1]; - bv[1].y = v.elements[1][1]; - bv[1].z = v.elements[2][1]; + bv[1].x = v.rows[0][1]; + bv[1].y = v.rows[1][1]; + bv[1].z = v.rows[2][1]; bv[1].w = 0; - bv[2].x = v.elements[0][2]; - bv[2].y = v.elements[1][2]; - bv[2].z = v.elements[2][2]; + bv[2].x = v.rows[0][2]; + bv[2].y = v.rows[1][2]; + bv[2].z = v.rows[2][2]; bv[2].w = 0; } break; @@ -1956,18 +1956,18 @@ void MaterialStorage::_global_variable_store_in_buffer(int32_t p_index, RS::Glob case RS::GLOBAL_VAR_TYPE_TRANSFORM_2D: { GlobalVariables::Value *bv = &global_variables.buffer_values[p_index]; Transform2D v = p_value; - bv[0].x = v.elements[0][0]; - bv[0].y = v.elements[0][1]; + bv[0].x = v.columns[0][0]; + bv[0].y = v.columns[0][1]; bv[0].z = 0; bv[0].w = 0; - bv[1].x = v.elements[1][0]; - bv[1].y = v.elements[1][1]; + bv[1].x = v.columns[1][0]; + bv[1].y = v.columns[1][1]; bv[1].z = 0; bv[1].w = 0; - bv[2].x = v.elements[2][0]; - bv[2].y = v.elements[2][1]; + bv[2].x = v.columns[2][0]; + bv[2].y = v.columns[2][1]; bv[2].z = 1; bv[2].w = 0; @@ -1975,19 +1975,19 @@ void MaterialStorage::_global_variable_store_in_buffer(int32_t p_index, RS::Glob case RS::GLOBAL_VAR_TYPE_TRANSFORM: { GlobalVariables::Value *bv = &global_variables.buffer_values[p_index]; Transform3D v = p_value; - bv[0].x = v.basis.elements[0][0]; - bv[0].y = v.basis.elements[1][0]; - bv[0].z = v.basis.elements[2][0]; + bv[0].x = v.basis.rows[0][0]; + bv[0].y = v.basis.rows[1][0]; + bv[0].z = v.basis.rows[2][0]; bv[0].w = 0; - bv[1].x = v.basis.elements[0][1]; - bv[1].y = v.basis.elements[1][1]; - bv[1].z = v.basis.elements[2][1]; + bv[1].x = v.basis.rows[0][1]; + bv[1].y = v.basis.rows[1][1]; + bv[1].z = v.basis.rows[2][1]; bv[1].w = 0; - bv[2].x = v.basis.elements[0][2]; - bv[2].y = v.basis.elements[1][2]; - bv[2].z = v.basis.elements[2][2]; + bv[2].x = v.basis.rows[0][2]; + bv[2].y = v.basis.rows[1][2]; + bv[2].z = v.basis.rows[2][2]; bv[2].w = 0; bv[3].x = v.origin.x; diff --git a/drivers/gles3/storage/mesh_storage.cpp b/drivers/gles3/storage/mesh_storage.cpp index 934f746423..41b5107b6c 100644 --- a/drivers/gles3/storage/mesh_storage.cpp +++ b/drivers/gles3/storage/mesh_storage.cpp @@ -384,12 +384,12 @@ AABB MeshStorage::mesh_get_aabb(RID p_mesh, RID p_skeleton) { Transform3D mtx; - mtx.basis.elements[0].x = dataptr[0]; - mtx.basis.elements[1].x = dataptr[1]; + mtx.basis.rows[0].x = dataptr[0]; + mtx.basis.rows[1].x = dataptr[1]; mtx.origin.x = dataptr[3]; - mtx.basis.elements[0].y = dataptr[4]; - mtx.basis.elements[1].y = dataptr[5]; + mtx.basis.rows[0].y = dataptr[4]; + mtx.basis.rows[1].y = dataptr[5]; mtx.origin.y = dataptr[7]; AABB baabb = mtx.xform(skbones[j]); @@ -411,17 +411,17 @@ AABB MeshStorage::mesh_get_aabb(RID p_mesh, RID p_skeleton) { Transform3D mtx; - mtx.basis.elements[0][0] = dataptr[0]; - mtx.basis.elements[0][1] = dataptr[1]; - mtx.basis.elements[0][2] = dataptr[2]; + mtx.basis.rows[0][0] = dataptr[0]; + mtx.basis.rows[0][1] = dataptr[1]; + mtx.basis.rows[0][2] = dataptr[2]; mtx.origin.x = dataptr[3]; - mtx.basis.elements[1][0] = dataptr[4]; - mtx.basis.elements[1][1] = dataptr[5]; - mtx.basis.elements[1][2] = dataptr[6]; + mtx.basis.rows[1][0] = dataptr[4]; + mtx.basis.rows[1][1] = dataptr[5]; + mtx.basis.rows[1][2] = dataptr[6]; mtx.origin.y = dataptr[7]; - mtx.basis.elements[2][0] = dataptr[8]; - mtx.basis.elements[2][1] = dataptr[9]; - mtx.basis.elements[2][2] = dataptr[10]; + mtx.basis.rows[2][0] = dataptr[8]; + mtx.basis.rows[2][1] = dataptr[9]; + mtx.basis.rows[2][2] = dataptr[10]; mtx.origin.z = dataptr[11]; AABB baabb = mtx.xform(skbones[j]); @@ -975,26 +975,26 @@ void MeshStorage::_multimesh_re_create_aabb(MultiMesh *multimesh, const float *p Transform3D t; if (multimesh->xform_format == RS::MULTIMESH_TRANSFORM_3D) { - t.basis.elements[0][0] = data[0]; - t.basis.elements[0][1] = data[1]; - t.basis.elements[0][2] = data[2]; + t.basis.rows[0][0] = data[0]; + t.basis.rows[0][1] = data[1]; + t.basis.rows[0][2] = data[2]; t.origin.x = data[3]; - t.basis.elements[1][0] = data[4]; - t.basis.elements[1][1] = data[5]; - t.basis.elements[1][2] = data[6]; + t.basis.rows[1][0] = data[4]; + t.basis.rows[1][1] = data[5]; + t.basis.rows[1][2] = data[6]; t.origin.y = data[7]; - t.basis.elements[2][0] = data[8]; - t.basis.elements[2][1] = data[9]; - t.basis.elements[2][2] = data[10]; + t.basis.rows[2][0] = data[8]; + t.basis.rows[2][1] = data[9]; + t.basis.rows[2][2] = data[10]; t.origin.z = data[11]; } else { - t.basis.elements[0].x = data[0]; - t.basis.elements[1].x = data[1]; + t.basis.rows[0].x = data[0]; + t.basis.rows[1].x = data[1]; t.origin.x = data[3]; - t.basis.elements[0].y = data[4]; - t.basis.elements[1].y = data[5]; + t.basis.rows[0].y = data[4]; + t.basis.rows[1].y = data[5]; t.origin.y = data[7]; } @@ -1021,17 +1021,17 @@ void MeshStorage::multimesh_instance_set_transform(RID p_multimesh, int p_index, float *dataptr = w + p_index * multimesh->stride_cache; - dataptr[0] = p_transform.basis.elements[0][0]; - dataptr[1] = p_transform.basis.elements[0][1]; - dataptr[2] = p_transform.basis.elements[0][2]; + dataptr[0] = p_transform.basis.rows[0][0]; + dataptr[1] = p_transform.basis.rows[0][1]; + dataptr[2] = p_transform.basis.rows[0][2]; dataptr[3] = p_transform.origin.x; - dataptr[4] = p_transform.basis.elements[1][0]; - dataptr[5] = p_transform.basis.elements[1][1]; - dataptr[6] = p_transform.basis.elements[1][2]; + dataptr[4] = p_transform.basis.rows[1][0]; + dataptr[5] = p_transform.basis.rows[1][1]; + dataptr[6] = p_transform.basis.rows[1][2]; dataptr[7] = p_transform.origin.y; - dataptr[8] = p_transform.basis.elements[2][0]; - dataptr[9] = p_transform.basis.elements[2][1]; - dataptr[10] = p_transform.basis.elements[2][2]; + dataptr[8] = p_transform.basis.rows[2][0]; + dataptr[9] = p_transform.basis.rows[2][1]; + dataptr[10] = p_transform.basis.rows[2][2]; dataptr[11] = p_transform.origin.z; } @@ -1051,14 +1051,14 @@ void MeshStorage::multimesh_instance_set_transform_2d(RID p_multimesh, int p_ind float *dataptr = w + p_index * multimesh->stride_cache; - dataptr[0] = p_transform.elements[0][0]; - dataptr[1] = p_transform.elements[1][0]; + dataptr[0] = p_transform.columns[0][0]; + dataptr[1] = p_transform.columns[1][0]; dataptr[2] = 0; - dataptr[3] = p_transform.elements[2][0]; - dataptr[4] = p_transform.elements[0][1]; - dataptr[5] = p_transform.elements[1][1]; + dataptr[3] = p_transform.columns[2][0]; + dataptr[4] = p_transform.columns[0][1]; + dataptr[5] = p_transform.columns[1][1]; dataptr[6] = 0; - dataptr[7] = p_transform.elements[2][1]; + dataptr[7] = p_transform.columns[2][1]; } _multimesh_mark_dirty(multimesh, p_index, true); @@ -1138,17 +1138,17 @@ Transform3D MeshStorage::multimesh_instance_get_transform(RID p_multimesh, int p const float *dataptr = r + p_index * multimesh->stride_cache; - t.basis.elements[0][0] = dataptr[0]; - t.basis.elements[0][1] = dataptr[1]; - t.basis.elements[0][2] = dataptr[2]; + t.basis.rows[0][0] = dataptr[0]; + t.basis.rows[0][1] = dataptr[1]; + t.basis.rows[0][2] = dataptr[2]; t.origin.x = dataptr[3]; - t.basis.elements[1][0] = dataptr[4]; - t.basis.elements[1][1] = dataptr[5]; - t.basis.elements[1][2] = dataptr[6]; + t.basis.rows[1][0] = dataptr[4]; + t.basis.rows[1][1] = dataptr[5]; + t.basis.rows[1][2] = dataptr[6]; t.origin.y = dataptr[7]; - t.basis.elements[2][0] = dataptr[8]; - t.basis.elements[2][1] = dataptr[9]; - t.basis.elements[2][2] = dataptr[10]; + t.basis.rows[2][0] = dataptr[8]; + t.basis.rows[2][1] = dataptr[9]; + t.basis.rows[2][2] = dataptr[10]; t.origin.z = dataptr[11]; } @@ -1169,12 +1169,12 @@ Transform2D MeshStorage::multimesh_instance_get_transform_2d(RID p_multimesh, in const float *dataptr = r + p_index * multimesh->stride_cache; - t.elements[0][0] = dataptr[0]; - t.elements[1][0] = dataptr[1]; - t.elements[2][0] = dataptr[3]; - t.elements[0][1] = dataptr[4]; - t.elements[1][1] = dataptr[5]; - t.elements[2][1] = dataptr[7]; + t.columns[0][0] = dataptr[0]; + t.columns[1][0] = dataptr[1]; + t.columns[2][0] = dataptr[3]; + t.columns[0][1] = dataptr[4]; + t.columns[1][1] = dataptr[5]; + t.columns[2][1] = dataptr[7]; } return t; diff --git a/editor/debugger/debug_adapter/debug_adapter_protocol.cpp b/editor/debugger/debug_adapter/debug_adapter_protocol.cpp index 745ca17efd..fea4c2b156 100644 --- a/editor/debugger/debug_adapter/debug_adapter_protocol.cpp +++ b/editor/debugger/debug_adapter/debug_adapter_protocol.cpp @@ -268,12 +268,12 @@ int DebugAdapterProtocol::parse_variant(const Variant &p_var) { x.type = type_vec2; y.type = type_vec2; origin.type = type_vec2; - x.value = transform.elements[0]; - y.value = transform.elements[1]; - origin.value = transform.elements[2]; - x.variablesReference = parse_variant(transform.elements[0]); - y.variablesReference = parse_variant(transform.elements[1]); - origin.variablesReference = parse_variant(transform.elements[2]); + x.value = transform.columns[0]; + y.value = transform.columns[1]; + origin.value = transform.columns[2]; + x.variablesReference = parse_variant(transform.columns[0]); + y.variablesReference = parse_variant(transform.columns[1]); + origin.variablesReference = parse_variant(transform.columns[2]); Array arr; arr.push_back(x.to_json()); @@ -357,12 +357,12 @@ int DebugAdapterProtocol::parse_variant(const Variant &p_var) { x.type = type_vec3; y.type = type_vec3; z.type = type_vec3; - x.value = basis.elements[0]; - y.value = basis.elements[1]; - z.value = basis.elements[2]; - x.variablesReference = parse_variant(basis.elements[0]); - y.variablesReference = parse_variant(basis.elements[1]); - z.variablesReference = parse_variant(basis.elements[2]); + x.value = basis.rows[0]; + y.value = basis.rows[1]; + z.value = basis.rows[2]; + x.variablesReference = parse_variant(basis.rows[0]); + y.variablesReference = parse_variant(basis.rows[1]); + z.variablesReference = parse_variant(basis.rows[2]); Array arr; arr.push_back(x.to_json()); diff --git a/editor/debugger/script_editor_debugger.cpp b/editor/debugger/script_editor_debugger.cpp index 98391d286a..1c8d66e4be 100644 --- a/editor/debugger/script_editor_debugger.cpp +++ b/editor/debugger/script_editor_debugger.cpp @@ -812,7 +812,7 @@ void ScriptEditorDebugger::_notification(int p_what) { Transform2D transform; transform.scale_basis(Size2(zoom, zoom)); - transform.elements[2] = -offset * zoom; + transform.columns[2] = -offset * zoom; Array msg; msg.push_back(transform); diff --git a/editor/import/collada.cpp b/editor/import/collada.cpp index af91ced570..e68c5e9a22 100644 --- a/editor/import/collada.cpp +++ b/editor/import/collada.cpp @@ -105,15 +105,15 @@ Transform3D Collada::fix_transform(const Transform3D &p_transform) { static Transform3D _read_transform_from_array(const Vector<float> &array, int ofs = 0) { Transform3D tr; // i wonder why collada matrices are transposed, given that's opposed to opengl.. - tr.basis.elements[0][0] = array[0 + ofs]; - tr.basis.elements[0][1] = array[1 + ofs]; - tr.basis.elements[0][2] = array[2 + ofs]; - tr.basis.elements[1][0] = array[4 + ofs]; - tr.basis.elements[1][1] = array[5 + ofs]; - tr.basis.elements[1][2] = array[6 + ofs]; - tr.basis.elements[2][0] = array[8 + ofs]; - tr.basis.elements[2][1] = array[9 + ofs]; - tr.basis.elements[2][2] = array[10 + ofs]; + tr.basis.rows[0][0] = array[0 + ofs]; + tr.basis.rows[0][1] = array[1 + ofs]; + tr.basis.rows[0][2] = array[2 + ofs]; + tr.basis.rows[1][0] = array[4 + ofs]; + tr.basis.rows[1][1] = array[5 + ofs]; + tr.basis.rows[1][2] = array[6 + ofs]; + tr.basis.rows[2][0] = array[8 + ofs]; + tr.basis.rows[2][1] = array[9 + ofs]; + tr.basis.rows[2][2] = array[10 + ofs]; tr.origin.x = array[3 + ofs]; tr.origin.y = array[7 + ofs]; tr.origin.z = array[11 + ofs]; @@ -210,15 +210,15 @@ Vector<float> Collada::AnimationTrack::get_value_at_time(float p_time) const { ret.resize(16); Transform3D tr; // i wonder why collada matrices are transposed, given that's opposed to opengl.. - ret.write[0] = interp.basis.elements[0][0]; - ret.write[1] = interp.basis.elements[0][1]; - ret.write[2] = interp.basis.elements[0][2]; - ret.write[4] = interp.basis.elements[1][0]; - ret.write[5] = interp.basis.elements[1][1]; - ret.write[6] = interp.basis.elements[1][2]; - ret.write[8] = interp.basis.elements[2][0]; - ret.write[9] = interp.basis.elements[2][1]; - ret.write[10] = interp.basis.elements[2][2]; + ret.write[0] = interp.basis.rows[0][0]; + ret.write[1] = interp.basis.rows[0][1]; + ret.write[2] = interp.basis.rows[0][2]; + ret.write[4] = interp.basis.rows[1][0]; + ret.write[5] = interp.basis.rows[1][1]; + ret.write[6] = interp.basis.rows[1][2]; + ret.write[8] = interp.basis.rows[2][0]; + ret.write[9] = interp.basis.rows[2][1]; + ret.write[10] = interp.basis.rows[2][2]; ret.write[3] = interp.origin.x; ret.write[7] = interp.origin.y; ret.write[11] = interp.origin.z; diff --git a/editor/plugins/animation_state_machine_editor.cpp b/editor/plugins/animation_state_machine_editor.cpp index fba59e701e..d3f25d7a85 100644 --- a/editor/plugins/animation_state_machine_editor.cpp +++ b/editor/plugins/animation_state_machine_editor.cpp @@ -1087,9 +1087,9 @@ void AnimationNodeStateMachineEditor::_connection_draw(const Vector2 &p_from, co Ref<Texture2D> icon = icons[p_mode + (p_auto_advance ? 3 : 0)]; Transform2D xf; - xf.elements[0] = (p_to - p_from).normalized(); - xf.elements[1] = xf.elements[0].orthogonal(); - xf.elements[2] = (p_from + p_to) * 0.5 - xf.elements[1] * icon->get_height() * 0.5 - xf.elements[0] * icon->get_height() * 0.5; + xf.columns[0] = (p_to - p_from).normalized(); + xf.columns[1] = xf.columns[0].orthogonal(); + xf.columns[2] = (p_from + p_to) * 0.5 - xf.columns[1] * icon->get_height() * 0.5 - xf.columns[0] * icon->get_height() * 0.5; state_machine_draw->draw_set_transform_matrix(xf); if (p_multi_transitions) { diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 5d1e9705d8..d237697597 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -3675,7 +3675,7 @@ void CanvasItemEditor::_draw_viewport() { // Update the transform transform = Transform2D(); transform.scale_basis(Size2(zoom, zoom)); - transform.elements[2] = -view_offset * zoom; + transform.columns[2] = -view_offset * zoom; EditorNode::get_singleton()->get_scene_root()->set_global_canvas_transform(transform); // hide/show buttons depending on the selection diff --git a/editor/plugins/polygon_2d_editor_plugin.cpp b/editor/plugins/polygon_2d_editor_plugin.cpp index 8566e92b22..a682bb455c 100644 --- a/editor/plugins/polygon_2d_editor_plugin.cpp +++ b/editor/plugins/polygon_2d_editor_plugin.cpp @@ -455,7 +455,7 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) { } Transform2D mtx; - mtx.elements[2] = -uv_draw_ofs; + mtx.columns[2] = -uv_draw_ofs; mtx.scale_basis(Vector2(uv_draw_zoom, uv_draw_zoom)); Ref<InputEventMouseButton> mb = p_input; @@ -970,7 +970,7 @@ void Polygon2DEditor::_uv_draw() { String warning; Transform2D mtx; - mtx.elements[2] = -uv_draw_ofs; + mtx.columns[2] = -uv_draw_ofs; mtx.scale_basis(Vector2(uv_draw_zoom, uv_draw_zoom)); RS::get_singleton()->canvas_item_add_set_transform(uv_edit_draw->get_canvas_item(), mtx); diff --git a/editor/plugins/texture_region_editor_plugin.cpp b/editor/plugins/texture_region_editor_plugin.cpp index 3fa12233a8..455592aa26 100644 --- a/editor/plugins/texture_region_editor_plugin.cpp +++ b/editor/plugins/texture_region_editor_plugin.cpp @@ -78,7 +78,7 @@ void TextureRegionEditor::_region_draw() { } Transform2D mtx; - mtx.elements[2] = -draw_ofs * draw_zoom; + mtx.columns[2] = -draw_ofs * draw_zoom; mtx.scale_basis(Vector2(draw_zoom, draw_zoom)); RS::get_singleton()->canvas_item_add_set_transform(edit_draw->get_canvas_item(), mtx); @@ -267,7 +267,7 @@ void TextureRegionEditor::_region_input(const Ref<InputEvent> &p_input) { } Transform2D mtx; - mtx.elements[2] = -draw_ofs * draw_zoom; + mtx.columns[2] = -draw_ofs * draw_zoom; mtx.scale_basis(Vector2(draw_zoom, draw_zoom)); const real_t handle_radius = 8 * EDSCALE; diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp index f9c4fae405..5effdf0b36 100644 --- a/editor/property_editor.cpp +++ b/editor/property_editor.cpp @@ -768,7 +768,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: Transform2D basis = v; for (int i = 0; i < 6; i++) { - value_editor[i]->set_text(String::num(basis.elements[i / 2][i % 2])); + value_editor[i]->set_text(String::num(basis.columns[i / 2][i % 2])); } } break; @@ -786,7 +786,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: Basis basis = v; for (int i = 0; i < 9; i++) { - value_editor[i]->set_text(String::num(basis.elements[i / 3][i % 3])); + value_editor[i]->set_text(String::num(basis.rows[i / 3][i % 3])); } } break; @@ -807,7 +807,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: Transform3D tr = v; for (int i = 0; i < 9; i++) { - value_editor[(i / 3) * 4 + i % 3]->set_text(String::num(tr.basis.elements[i / 3][i % 3])); + value_editor[(i / 3) * 4 + i % 3]->set_text(String::num(tr.basis.rows[i / 3][i % 3])); } value_editor[3]->set_text(String::num(tr.origin.x)); @@ -1568,7 +1568,7 @@ void CustomPropertyEditor::_modified(String p_string) { case Variant::TRANSFORM2D: { Transform2D m; for (int i = 0; i < 6; i++) { - m.elements[i / 2][i % 2] = _parse_real_expression(value_editor[i]->get_text()); + m.columns[i / 2][i % 2] = _parse_real_expression(value_editor[i]->get_text()); } v = m; @@ -1580,7 +1580,7 @@ void CustomPropertyEditor::_modified(String p_string) { case Variant::BASIS: { Basis m; for (int i = 0; i < 9; i++) { - m.elements[i / 3][i % 3] = _parse_real_expression(value_editor[i]->get_text()); + m.rows[i / 3][i % 3] = _parse_real_expression(value_editor[i]->get_text()); } v = m; @@ -1592,7 +1592,7 @@ void CustomPropertyEditor::_modified(String p_string) { case Variant::TRANSFORM3D: { Basis basis; for (int i = 0; i < 9; i++) { - basis.elements[i / 3][i % 3] = _parse_real_expression(value_editor[(i / 3) * 4 + i % 3]->get_text()); + basis.rows[i / 3][i % 3] = _parse_real_expression(value_editor[(i / 3) * 4 + i % 3]->get_text()); } Vector3 origin; diff --git a/gles3_builders.py b/gles3_builders.py index 15446d345f..6b2d315603 100644 --- a/gles3_builders.py +++ b/gles3_builders.py @@ -375,17 +375,17 @@ def build_gles3_header(filename, include, class_suffix, output_attribs): const Transform3D &tr = p_transform; GLfloat matrix[16]={ /* build a 16x16 matrix */ - (GLfloat)tr.basis.elements[0][0], - (GLfloat)tr.basis.elements[1][0], - (GLfloat)tr.basis.elements[2][0], + (GLfloat)tr.basis.rows[0][0], + (GLfloat)tr.basis.rows[1][0], + (GLfloat)tr.basis.rows[2][0], (GLfloat)0, - (GLfloat)tr.basis.elements[0][1], - (GLfloat)tr.basis.elements[1][1], - (GLfloat)tr.basis.elements[2][1], + (GLfloat)tr.basis.rows[0][1], + (GLfloat)tr.basis.rows[1][1], + (GLfloat)tr.basis.rows[2][1], (GLfloat)0, - (GLfloat)tr.basis.elements[0][2], - (GLfloat)tr.basis.elements[1][2], - (GLfloat)tr.basis.elements[2][2], + (GLfloat)tr.basis.rows[0][2], + (GLfloat)tr.basis.rows[1][2], + (GLfloat)tr.basis.rows[2][2], (GLfloat)0, (GLfloat)tr.origin.x, (GLfloat)tr.origin.y, @@ -410,20 +410,20 @@ def build_gles3_header(filename, include, class_suffix, output_attribs): const Transform2D &tr = p_transform; GLfloat matrix[16]={ /* build a 16x16 matrix */ - (GLfloat)tr.elements[0][0], - (GLfloat)tr.elements[0][1], + (GLfloat)tr.columns[0][0], + (GLfloat)tr.columns[0][1], (GLfloat)0, (GLfloat)0, - (GLfloat)tr.elements[1][0], - (GLfloat)tr.elements[1][1], + (GLfloat)tr.columns[1][0], + (GLfloat)tr.columns[1][1], (GLfloat)0, (GLfloat)0, (GLfloat)0, (GLfloat)0, (GLfloat)1, (GLfloat)0, - (GLfloat)tr.elements[2][0], - (GLfloat)tr.elements[2][1], + (GLfloat)tr.columns[2][0], + (GLfloat)tr.columns[2][1], (GLfloat)0, (GLfloat)1 }; diff --git a/modules/lightmapper_rd/lightmapper_rd.cpp b/modules/lightmapper_rd/lightmapper_rd.cpp index faa1d21490..214c60091c 100644 --- a/modules/lightmapper_rd/lightmapper_rd.cpp +++ b/modules/lightmapper_rd/lightmapper_rd.cpp @@ -1028,17 +1028,17 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d push_constant.atlas_slice = 0; push_constant.region_ofs[0] = 0; push_constant.region_ofs[1] = 0; - push_constant.environment_xform[0] = p_environment_transform.elements[0][0]; - push_constant.environment_xform[1] = p_environment_transform.elements[1][0]; - push_constant.environment_xform[2] = p_environment_transform.elements[2][0]; + push_constant.environment_xform[0] = p_environment_transform.rows[0][0]; + push_constant.environment_xform[1] = p_environment_transform.rows[1][0]; + push_constant.environment_xform[2] = p_environment_transform.rows[2][0]; push_constant.environment_xform[3] = 0; - push_constant.environment_xform[4] = p_environment_transform.elements[0][1]; - push_constant.environment_xform[5] = p_environment_transform.elements[1][1]; - push_constant.environment_xform[6] = p_environment_transform.elements[2][1]; + push_constant.environment_xform[4] = p_environment_transform.rows[0][1]; + push_constant.environment_xform[5] = p_environment_transform.rows[1][1]; + push_constant.environment_xform[6] = p_environment_transform.rows[2][1]; push_constant.environment_xform[7] = 0; - push_constant.environment_xform[8] = p_environment_transform.elements[0][2]; - push_constant.environment_xform[9] = p_environment_transform.elements[1][2]; - push_constant.environment_xform[10] = p_environment_transform.elements[2][2]; + push_constant.environment_xform[8] = p_environment_transform.rows[0][2]; + push_constant.environment_xform[9] = p_environment_transform.rows[1][2]; + push_constant.environment_xform[10] = p_environment_transform.rows[2][2]; push_constant.environment_xform[11] = 0; } diff --git a/modules/mobile_vr/mobile_vr_interface.cpp b/modules/mobile_vr/mobile_vr_interface.cpp index 8cd23ffb24..f5aef56724 100644 --- a/modules/mobile_vr/mobile_vr_interface.cpp +++ b/modules/mobile_vr/mobile_vr_interface.cpp @@ -112,9 +112,9 @@ Basis MobileVRInterface::combine_acc_mag(const Vector3 &p_grav, const Vector3 &p // We use our gravity and magnetometer vectors to construct our matrix Basis acc_mag_m3; - acc_mag_m3.elements[0] = -magneto_east; - acc_mag_m3.elements[1] = up; - acc_mag_m3.elements[2] = magneto; + acc_mag_m3.rows[0] = -magneto_east; + acc_mag_m3.rows[1] = up; + acc_mag_m3.rows[2] = magneto; return acc_mag_m3; }; diff --git a/modules/mono/editor/bindings_generator.cpp b/modules/mono/editor/bindings_generator.cpp index 2a93c15282..54c65c21e8 100644 --- a/modules/mono/editor/bindings_generator.cpp +++ b/modules/mono/editor/bindings_generator.cpp @@ -3202,7 +3202,7 @@ bool BindingsGenerator::_arg_default_value_from_variant(const Variant &p_val, Ar if (transform == Transform2D()) { r_iarg.default_argument = "Transform2D.Identity"; } else { - r_iarg.default_argument = "new Transform2D(new Vector2" + transform.elements[0].operator String() + ", new Vector2" + transform.elements[1].operator String() + ", new Vector2" + transform.elements[2].operator String() + ")"; + r_iarg.default_argument = "new Transform2D(new Vector2" + transform.columns[0].operator String() + ", new Vector2" + transform.columns[1].operator String() + ", new Vector2" + transform.columns[2].operator String() + ")"; } r_iarg.def_param_mode = ArgumentInterface::NULLABLE_VAL; } break; diff --git a/modules/mono/mono_gd/gd_mono_marshal.h b/modules/mono/mono_gd/gd_mono_marshal.h index eb33c6119e..778e52b6cb 100644 --- a/modules/mono/mono_gd/gd_mono_marshal.h +++ b/modules/mono/mono_gd/gd_mono_marshal.h @@ -367,9 +367,9 @@ struct M_Transform2D { static _FORCE_INLINE_ M_Transform2D convert_from(const Transform2D &p_from) { M_Transform2D ret = { - M_Vector2::convert_from(p_from.elements[0]), - M_Vector2::convert_from(p_from.elements[1]), - M_Vector2::convert_from(p_from.elements[2]) + M_Vector2::convert_from(p_from.columns[0]), + M_Vector2::convert_from(p_from.columns[1]), + M_Vector2::convert_from(p_from.columns[2]) }; return ret; } @@ -412,9 +412,9 @@ struct M_Basis { static _FORCE_INLINE_ M_Basis convert_from(const Basis &p_from) { M_Basis ret = { - M_Vector3::convert_from(p_from.elements[0]), - M_Vector3::convert_from(p_from.elements[1]), - M_Vector3::convert_from(p_from.elements[2]) + M_Vector3::convert_from(p_from.rows[0]), + M_Vector3::convert_from(p_from.rows[1]), + M_Vector3::convert_from(p_from.rows[2]) }; return ret; } diff --git a/modules/text_server_adv/text_server_adv.cpp b/modules/text_server_adv/text_server_adv.cpp index 8e0bedd8f6..ba249aff7a 100644 --- a/modules/text_server_adv/text_server_adv.cpp +++ b/modules/text_server_adv/text_server_adv.cpp @@ -1329,7 +1329,7 @@ _FORCE_INLINE_ bool TextServerAdvanced::_ensure_cache_for_size(FontDataAdvanced fd->underline_position = (-FT_MulFix(fd->face->underline_position, fd->face->size->metrics.y_scale) / 64.0) / fd->oversampling * fd->scale; fd->underline_thickness = (FT_MulFix(fd->face->underline_thickness, fd->face->size->metrics.y_scale) / 64.0) / fd->oversampling * fd->scale; - hb_font_set_synthetic_slant(fd->hb_handle, p_font_data->transform.elements[0][1]); + hb_font_set_synthetic_slant(fd->hb_handle, p_font_data->transform.columns[0][1]); if (!p_font_data->face_init) { // Get style flags and name. diff --git a/modules/webxr/webxr_interface_js.cpp b/modules/webxr/webxr_interface_js.cpp index debfe8e950..74e744402b 100644 --- a/modules/webxr/webxr_interface_js.cpp +++ b/modules/webxr/webxr_interface_js.cpp @@ -291,15 +291,15 @@ void WebXRInterfaceJS::uninitialize() { Transform3D WebXRInterfaceJS::_js_matrix_to_transform(float *p_js_matrix) { Transform3D transform; - transform.basis.elements[0].x = p_js_matrix[0]; - transform.basis.elements[1].x = p_js_matrix[1]; - transform.basis.elements[2].x = p_js_matrix[2]; - transform.basis.elements[0].y = p_js_matrix[4]; - transform.basis.elements[1].y = p_js_matrix[5]; - transform.basis.elements[2].y = p_js_matrix[6]; - transform.basis.elements[0].z = p_js_matrix[8]; - transform.basis.elements[1].z = p_js_matrix[9]; - transform.basis.elements[2].z = p_js_matrix[10]; + transform.basis.rows[0].x = p_js_matrix[0]; + transform.basis.rows[1].x = p_js_matrix[1]; + transform.basis.rows[2].x = p_js_matrix[2]; + transform.basis.rows[0].y = p_js_matrix[4]; + transform.basis.rows[1].y = p_js_matrix[5]; + transform.basis.rows[2].y = p_js_matrix[6]; + transform.basis.rows[0].z = p_js_matrix[8]; + transform.basis.rows[1].z = p_js_matrix[9]; + transform.basis.rows[2].z = p_js_matrix[10]; transform.origin.x = p_js_matrix[12]; transform.origin.y = p_js_matrix[13]; transform.origin.z = p_js_matrix[14]; diff --git a/scene/2d/cpu_particles_2d.cpp b/scene/2d/cpu_particles_2d.cpp index 24c66622f1..888ad374d8 100644 --- a/scene/2d/cpu_particles_2d.cpp +++ b/scene/2d/cpu_particles_2d.cpp @@ -969,13 +969,13 @@ void CPUParticles2D::_particles_process(double p_delta) { if (particle_flags[PARTICLE_FLAG_ALIGN_Y_TO_VELOCITY]) { if (p.velocity.length() > 0.0) { - p.transform.elements[1] = p.velocity.normalized(); - p.transform.elements[0] = p.transform.elements[1].orthogonal(); + p.transform.columns[1] = p.velocity.normalized(); + p.transform.columns[0] = p.transform.columns[1].orthogonal(); } } else { - p.transform.elements[0] = Vector2(Math::cos(p.rotation), -Math::sin(p.rotation)); - p.transform.elements[1] = Vector2(Math::sin(p.rotation), Math::cos(p.rotation)); + p.transform.columns[0] = Vector2(Math::cos(p.rotation), -Math::sin(p.rotation)); + p.transform.columns[1] = Vector2(Math::sin(p.rotation), Math::cos(p.rotation)); } //scale by scale @@ -986,8 +986,8 @@ void CPUParticles2D::_particles_process(double p_delta) { if (base_scale.y < 0.00001) { base_scale.y = 0.00001; } - p.transform.elements[0] *= base_scale.x; - p.transform.elements[1] *= base_scale.y; + p.transform.columns[0] *= base_scale.x; + p.transform.columns[1] *= base_scale.y; p.transform[2] += p.velocity * local_delta; } @@ -1029,14 +1029,14 @@ void CPUParticles2D::_update_particle_data_buffer() { } if (r[idx].active) { - ptr[0] = t.elements[0][0]; - ptr[1] = t.elements[1][0]; + ptr[0] = t.columns[0][0]; + ptr[1] = t.columns[1][0]; ptr[2] = 0; - ptr[3] = t.elements[2][0]; - ptr[4] = t.elements[0][1]; - ptr[5] = t.elements[1][1]; + ptr[3] = t.columns[2][0]; + ptr[4] = t.columns[0][1]; + ptr[5] = t.columns[1][1]; ptr[6] = 0; - ptr[7] = t.elements[2][1]; + ptr[7] = t.columns[2][1]; } else { memset(ptr, 0, sizeof(float) * 8); @@ -1137,14 +1137,14 @@ void CPUParticles2D::_notification(int p_what) { Transform2D t = inv_emission_transform * r[i].transform; if (r[i].active) { - ptr[0] = t.elements[0][0]; - ptr[1] = t.elements[1][0]; + ptr[0] = t.columns[0][0]; + ptr[1] = t.columns[1][0]; ptr[2] = 0; - ptr[3] = t.elements[2][0]; - ptr[4] = t.elements[0][1]; - ptr[5] = t.elements[1][1]; + ptr[3] = t.columns[2][0]; + ptr[4] = t.columns[0][1]; + ptr[5] = t.columns[1][1]; ptr[6] = 0; - ptr[7] = t.elements[2][1]; + ptr[7] = t.columns[2][1]; } else { memset(ptr, 0, sizeof(float) * 8); diff --git a/scene/2d/node_2d.cpp b/scene/2d/node_2d.cpp index 42c8daa4c7..0e8bb1aad7 100644 --- a/scene/2d/node_2d.cpp +++ b/scene/2d/node_2d.cpp @@ -111,7 +111,7 @@ void Node2D::_edit_set_rect(const Rect2 &p_edit_rect) { #endif void Node2D::_update_xform_values() { - position = transform.elements[2]; + position = transform.columns[2]; rotation = transform.get_rotation(); scale = transform.get_scale(); skew = transform.get_skew(); @@ -120,7 +120,7 @@ void Node2D::_update_xform_values() { void Node2D::_update_transform() { transform.set_rotation_scale_and_skew(rotation, scale, skew); - transform.elements[2] = position; + transform.columns[2] = position; RenderingServer::get_singleton()->canvas_item_set_transform(get_canvas_item(), transform); diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp index 677878d40f..88f68e4142 100644 --- a/scene/2d/physics_body_2d.cpp +++ b/scene/2d/physics_body_2d.cpp @@ -123,7 +123,7 @@ bool PhysicsBody2D::move_and_collide(const PhysicsServer2D::MotionParameters &p_ if (!p_test_only) { Transform2D gt = p_parameters.from; - gt.elements[2] += r_result.travel; + gt.columns[2] += r_result.travel; set_global_transform(gt); } @@ -928,7 +928,7 @@ TypedArray<String> RigidDynamicBody2D::get_configuration_warnings() const { TypedArray<String> warnings = CollisionObject2D::get_configuration_warnings(); - if (ABS(t.elements[0].length() - 1.0) > 0.05 || ABS(t.elements[1].length() - 1.0) > 0.05) { + if (ABS(t.columns[0].length() - 1.0) > 0.05 || ABS(t.columns[1].length() - 1.0) > 0.05) { warnings.push_back(RTR("Size changes to RigidDynamicBody2D will be overridden by the physics engine when running.\nChange the size in children collision shapes instead.")); } @@ -1110,7 +1110,7 @@ bool CharacterBody2D::move_and_slide() { Vector2 current_platform_velocity = platform_velocity; Transform2D gt = get_global_transform(); - previous_position = gt.elements[2]; + previous_position = gt.columns[2]; if ((on_floor || on_wall) && platform_rid.is_valid()) { bool excluded = false; @@ -1123,7 +1123,7 @@ bool CharacterBody2D::move_and_slide() { //this approach makes sure there is less delay between the actual body velocity and the one we saved PhysicsDirectBodyState2D *bs = PhysicsServer2D::get_singleton()->body_get_direct_state(platform_rid); if (bs) { - Vector2 local_position = gt.elements[2] - bs->get_transform().elements[2]; + Vector2 local_position = gt.columns[2] - bs->get_transform().columns[2]; current_platform_velocity = bs->get_velocity_at_local_position(local_position); } else { // Body is removed or destroyed, invalidate floor. @@ -1204,7 +1204,7 @@ void CharacterBody2D::_move_and_slide_grounded(double p_delta, bool p_was_on_flo for (int iteration = 0; iteration < max_slides; ++iteration) { PhysicsServer2D::MotionParameters parameters(get_global_transform(), motion, margin); - Vector2 prev_position = parameters.from.elements[2]; + Vector2 prev_position = parameters.from.columns[2]; PhysicsServer2D::MotionResult result; bool collided = move_and_collide(parameters, result, false, !sliding_enabled); @@ -1231,7 +1231,7 @@ void CharacterBody2D::_move_and_slide_grounded(double p_delta, bool p_was_on_flo if (on_floor && floor_stop_on_slope && (velocity.normalized() + up_direction).length() < 0.01) { Transform2D gt = get_global_transform(); if (result.travel.length() <= margin + CMP_EPSILON) { - gt.elements[2] -= result.travel; + gt.columns[2] -= result.travel; } set_global_transform(gt); velocity = Vector2(); @@ -1253,7 +1253,7 @@ void CharacterBody2D::_move_and_slide_grounded(double p_delta, bool p_was_on_flo if (result.travel.length() <= margin + CMP_EPSILON) { // Cancels the motion. Transform2D gt = get_global_transform(); - gt.elements[2] -= result.travel; + gt.columns[2] -= result.travel; set_global_transform(gt); } // Determines if you are on the ground. @@ -1312,7 +1312,7 @@ void CharacterBody2D::_move_and_slide_grounded(double p_delta, bool p_was_on_flo can_apply_constant_speed = false; sliding_enabled = true; Transform2D gt = get_global_transform(); - gt.elements[2] = prev_position; + gt.columns[2] = prev_position; set_global_transform(gt); Vector2 motion_slide_norm = motion.slide(prev_floor_normal).normalized(); @@ -1425,7 +1425,7 @@ void CharacterBody2D::_snap_on_floor(bool p_was_on_floor, bool p_vel_dir_facing_ } } - parameters.from.elements[2] += result.travel; + parameters.from.columns[2] += result.travel; set_global_transform(parameters.from); } } @@ -1521,7 +1521,7 @@ const Vector2 &CharacterBody2D::get_last_motion() const { } Vector2 CharacterBody2D::get_position_delta() const { - return get_global_transform().elements[2] - previous_position; + return get_global_transform().columns[2] - previous_position; } const Vector2 &CharacterBody2D::get_real_velocity() const { diff --git a/scene/3d/cpu_particles_3d.cpp b/scene/3d/cpu_particles_3d.cpp index 0befda4168..d244fd1a1b 100644 --- a/scene/3d/cpu_particles_3d.cpp +++ b/scene/3d/cpu_particles_3d.cpp @@ -1187,17 +1187,17 @@ void CPUParticles3D::_update_particle_data_buffer() { } if (r[idx].active) { - ptr[0] = t.basis.elements[0][0]; - ptr[1] = t.basis.elements[0][1]; - ptr[2] = t.basis.elements[0][2]; + ptr[0] = t.basis.rows[0][0]; + ptr[1] = t.basis.rows[0][1]; + ptr[2] = t.basis.rows[0][2]; ptr[3] = t.origin.x; - ptr[4] = t.basis.elements[1][0]; - ptr[5] = t.basis.elements[1][1]; - ptr[6] = t.basis.elements[1][2]; + ptr[4] = t.basis.rows[1][0]; + ptr[5] = t.basis.rows[1][1]; + ptr[6] = t.basis.rows[1][2]; ptr[7] = t.origin.y; - ptr[8] = t.basis.elements[2][0]; - ptr[9] = t.basis.elements[2][1]; - ptr[10] = t.basis.elements[2][2]; + ptr[8] = t.basis.rows[2][0]; + ptr[9] = t.basis.rows[2][1]; + ptr[10] = t.basis.rows[2][2]; ptr[11] = t.origin.z; } else { memset(ptr, 0, sizeof(Transform3D)); @@ -1293,17 +1293,17 @@ void CPUParticles3D::_notification(int p_what) { Transform3D t = inv_emission_transform * r[i].transform; if (r[i].active) { - ptr[0] = t.basis.elements[0][0]; - ptr[1] = t.basis.elements[0][1]; - ptr[2] = t.basis.elements[0][2]; + ptr[0] = t.basis.rows[0][0]; + ptr[1] = t.basis.rows[0][1]; + ptr[2] = t.basis.rows[0][2]; ptr[3] = t.origin.x; - ptr[4] = t.basis.elements[1][0]; - ptr[5] = t.basis.elements[1][1]; - ptr[6] = t.basis.elements[1][2]; + ptr[4] = t.basis.rows[1][0]; + ptr[5] = t.basis.rows[1][1]; + ptr[6] = t.basis.rows[1][2]; ptr[7] = t.origin.y; - ptr[8] = t.basis.elements[2][0]; - ptr[9] = t.basis.elements[2][1]; - ptr[10] = t.basis.elements[2][2]; + ptr[8] = t.basis.rows[2][0]; + ptr[9] = t.basis.rows[2][1]; + ptr[10] = t.basis.rows[2][2]; ptr[11] = t.origin.z; } else { memset(ptr, 0, sizeof(float) * 12); diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp index 24fbc1e431..a52902f8c6 100644 --- a/scene/animation/tween.cpp +++ b/scene/animation/tween.cpp @@ -456,12 +456,12 @@ Variant Tween::interpolate_variant(Variant p_initial_val, Variant p_delta_val, f Transform2D d = p_delta_val; Transform2D r; - APPLY_EQUATION(elements[0][0]); - APPLY_EQUATION(elements[0][1]); - APPLY_EQUATION(elements[1][0]); - APPLY_EQUATION(elements[1][1]); - APPLY_EQUATION(elements[2][0]); - APPLY_EQUATION(elements[2][1]); + APPLY_EQUATION(columns[0][0]); + APPLY_EQUATION(columns[0][1]); + APPLY_EQUATION(columns[1][0]); + APPLY_EQUATION(columns[1][1]); + APPLY_EQUATION(columns[2][0]); + APPLY_EQUATION(columns[2][1]); return r; } @@ -496,15 +496,15 @@ Variant Tween::interpolate_variant(Variant p_initial_val, Variant p_delta_val, f Basis d = p_delta_val; Basis r; - APPLY_EQUATION(elements[0][0]); - APPLY_EQUATION(elements[0][1]); - APPLY_EQUATION(elements[0][2]); - APPLY_EQUATION(elements[1][0]); - APPLY_EQUATION(elements[1][1]); - APPLY_EQUATION(elements[1][2]); - APPLY_EQUATION(elements[2][0]); - APPLY_EQUATION(elements[2][1]); - APPLY_EQUATION(elements[2][2]); + APPLY_EQUATION(rows[0][0]); + APPLY_EQUATION(rows[0][1]); + APPLY_EQUATION(rows[0][2]); + APPLY_EQUATION(rows[1][0]); + APPLY_EQUATION(rows[1][1]); + APPLY_EQUATION(rows[1][2]); + APPLY_EQUATION(rows[2][0]); + APPLY_EQUATION(rows[2][1]); + APPLY_EQUATION(rows[2][2]); return r; } @@ -513,15 +513,15 @@ Variant Tween::interpolate_variant(Variant p_initial_val, Variant p_delta_val, f Transform3D d = p_delta_val; Transform3D r; - APPLY_EQUATION(basis.elements[0][0]); - APPLY_EQUATION(basis.elements[0][1]); - APPLY_EQUATION(basis.elements[0][2]); - APPLY_EQUATION(basis.elements[1][0]); - APPLY_EQUATION(basis.elements[1][1]); - APPLY_EQUATION(basis.elements[1][2]); - APPLY_EQUATION(basis.elements[2][0]); - APPLY_EQUATION(basis.elements[2][1]); - APPLY_EQUATION(basis.elements[2][2]); + APPLY_EQUATION(basis.rows[0][0]); + APPLY_EQUATION(basis.rows[0][1]); + APPLY_EQUATION(basis.rows[0][2]); + APPLY_EQUATION(basis.rows[1][0]); + APPLY_EQUATION(basis.rows[1][1]); + APPLY_EQUATION(basis.rows[1][2]); + APPLY_EQUATION(basis.rows[2][0]); + APPLY_EQUATION(basis.rows[2][1]); + APPLY_EQUATION(basis.rows[2][2]); APPLY_EQUATION(origin.x); APPLY_EQUATION(origin.y); APPLY_EQUATION(origin.z); @@ -570,12 +570,12 @@ Variant Tween::calculate_delta_value(Variant p_intial_val, Variant p_final_val) case Variant::TRANSFORM2D: { Transform2D i = p_intial_val; Transform2D f = p_final_val; - return Transform2D(f.elements[0][0] - i.elements[0][0], - f.elements[0][1] - i.elements[0][1], - f.elements[1][0] - i.elements[1][0], - f.elements[1][1] - i.elements[1][1], - f.elements[2][0] - i.elements[2][0], - f.elements[2][1] - i.elements[2][1]); + return Transform2D(f.columns[0][0] - i.columns[0][0], + f.columns[0][1] - i.columns[0][1], + f.columns[1][0] - i.columns[1][0], + f.columns[1][1] - i.columns[1][1], + f.columns[2][0] - i.columns[2][0], + f.columns[2][1] - i.columns[2][1]); } case Variant::AABB: { @@ -587,29 +587,29 @@ Variant Tween::calculate_delta_value(Variant p_intial_val, Variant p_final_val) case Variant::BASIS: { Basis i = p_intial_val; Basis f = p_final_val; - return Basis(f.elements[0][0] - i.elements[0][0], - f.elements[0][1] - i.elements[0][1], - f.elements[0][2] - i.elements[0][2], - f.elements[1][0] - i.elements[1][0], - f.elements[1][1] - i.elements[1][1], - f.elements[1][2] - i.elements[1][2], - f.elements[2][0] - i.elements[2][0], - f.elements[2][1] - i.elements[2][1], - f.elements[2][2] - i.elements[2][2]); + return Basis(f.rows[0][0] - i.rows[0][0], + f.rows[0][1] - i.rows[0][1], + f.rows[0][2] - i.rows[0][2], + f.rows[1][0] - i.rows[1][0], + f.rows[1][1] - i.rows[1][1], + f.rows[1][2] - i.rows[1][2], + f.rows[2][0] - i.rows[2][0], + f.rows[2][1] - i.rows[2][1], + f.rows[2][2] - i.rows[2][2]); } case Variant::TRANSFORM3D: { Transform3D i = p_intial_val; Transform3D f = p_final_val; - return Transform3D(f.basis.elements[0][0] - i.basis.elements[0][0], - f.basis.elements[0][1] - i.basis.elements[0][1], - f.basis.elements[0][2] - i.basis.elements[0][2], - f.basis.elements[1][0] - i.basis.elements[1][0], - f.basis.elements[1][1] - i.basis.elements[1][1], - f.basis.elements[1][2] - i.basis.elements[1][2], - f.basis.elements[2][0] - i.basis.elements[2][0], - f.basis.elements[2][1] - i.basis.elements[2][1], - f.basis.elements[2][2] - i.basis.elements[2][2], + return Transform3D(f.basis.rows[0][0] - i.basis.rows[0][0], + f.basis.rows[0][1] - i.basis.rows[0][1], + f.basis.rows[0][2] - i.basis.rows[0][2], + f.basis.rows[1][0] - i.basis.rows[1][0], + f.basis.rows[1][1] - i.basis.rows[1][1], + f.basis.rows[1][2] - i.basis.rows[1][2], + f.basis.rows[2][0] - i.basis.rows[2][0], + f.basis.rows[2][1] - i.basis.rows[2][1], + f.basis.rows[2][2] - i.basis.rows[2][2], f.origin.x - i.origin.x, f.origin.y - i.origin.y, f.origin.z - i.origin.z); diff --git a/scene/main/canvas_layer.cpp b/scene/main/canvas_layer.cpp index 7aa4d391f8..da96246de2 100644 --- a/scene/main/canvas_layer.cpp +++ b/scene/main/canvas_layer.cpp @@ -96,7 +96,7 @@ void CanvasLayer::_update_xform() { } void CanvasLayer::_update_locrotscale() { - ofs = transform.elements[2]; + ofs = transform.columns[2]; rot = transform.get_rotation(); scale = transform.get_scale(); locrotscale_dirty = false; diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index 5fef8d4b5f..d7e58ed707 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -1104,7 +1104,7 @@ Transform2D Viewport::_get_input_pre_xform() const { Transform2D pre_xf; if (to_screen_rect.size.x != 0 && to_screen_rect.size.y != 0) { - pre_xf.elements[2] = -to_screen_rect.position; + pre_xf.columns[2] = -to_screen_rect.position; pre_xf.scale(Vector2(size) / to_screen_rect.size); } diff --git a/scene/resources/multimesh.cpp b/scene/resources/multimesh.cpp index c30e748f66..e5fc61ade5 100644 --- a/scene/resources/multimesh.cpp +++ b/scene/resources/multimesh.cpp @@ -101,9 +101,9 @@ void MultiMesh::_set_transform_2d_array(const Vector<Vector2> &p_array) { for (int i = 0; i < len / 3; i++) { Transform2D t; - t.elements[0] = r[i * 3 + 0]; - t.elements[1] = r[i * 3 + 1]; - t.elements[2] = r[i * 3 + 2]; + t.columns[0] = r[i * 3 + 0]; + t.columns[1] = r[i * 3 + 1]; + t.columns[2] = r[i * 3 + 2]; set_instance_transform_2d(i, t); } @@ -125,9 +125,9 @@ Vector<Vector2> MultiMesh::_get_transform_2d_array() const { for (int i = 0; i < instance_count; i++) { Transform2D t = get_instance_transform_2d(i); - w[i * 3 + 0] = t.elements[0]; - w[i * 3 + 1] = t.elements[1]; - w[i * 3 + 2] = t.elements[2]; + w[i * 3 + 0] = t.columns[0]; + w[i * 3 + 1] = t.columns[1]; + w[i * 3 + 2] = t.columns[2]; } return xforms; diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp index 1aab0d5930..72a4324b68 100644 --- a/scene/resources/texture.cpp +++ b/scene/resources/texture.cpp @@ -1717,8 +1717,8 @@ void MeshTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_mo Transform2D xform; xform.set_origin(p_pos); if (p_transpose) { - SWAP(xform.elements[0][1], xform.elements[1][0]); - SWAP(xform.elements[0][0], xform.elements[1][1]); + SWAP(xform.columns[0][1], xform.columns[1][0]); + SWAP(xform.columns[0][0], xform.columns[1][1]); } RenderingServer::get_singleton()->canvas_item_add_mesh(p_canvas_item, mesh->get_rid(), xform, p_modulate, base_texture->get_rid()); } @@ -1739,8 +1739,8 @@ void MeshTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, xform.set_scale(p_rect.size / size); if (p_transpose) { - SWAP(xform.elements[0][1], xform.elements[1][0]); - SWAP(xform.elements[0][0], xform.elements[1][1]); + SWAP(xform.columns[0][1], xform.columns[1][0]); + SWAP(xform.columns[0][0], xform.columns[1][1]); } RenderingServer::get_singleton()->canvas_item_add_mesh(p_canvas_item, mesh->get_rid(), xform, p_modulate, base_texture->get_rid()); } @@ -1761,8 +1761,8 @@ void MeshTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const xform.set_scale(p_rect.size / size); if (p_transpose) { - SWAP(xform.elements[0][1], xform.elements[1][0]); - SWAP(xform.elements[0][0], xform.elements[1][1]); + SWAP(xform.columns[0][1], xform.columns[1][0]); + SWAP(xform.columns[0][0], xform.columns[1][1]); } RenderingServer::get_singleton()->canvas_item_add_mesh(p_canvas_item, mesh->get_rid(), xform, p_modulate, base_texture->get_rid()); } diff --git a/servers/physics_2d/godot_body_pair_2d.cpp b/servers/physics_2d/godot_body_pair_2d.cpp index 6e76697a1b..be3e832b88 100644 --- a/servers/physics_2d/godot_body_pair_2d.cpp +++ b/servers/physics_2d/godot_body_pair_2d.cpp @@ -260,7 +260,7 @@ bool GodotBodyPair2D::setup(real_t p_step) { Transform2D xform_A = xform_Au * A->get_shape_transform(shape_A); Transform2D xform_Bu = B->get_transform(); - xform_Bu.elements[2] -= offset_A; + xform_Bu.columns[2] -= offset_A; Transform2D xform_B = xform_Bu * B->get_shape_transform(shape_B); GodotShape2D *shape_A_ptr = A->get_shape(shape_A); @@ -351,7 +351,7 @@ bool GodotBodyPair2D::pre_solve(real_t p_step) { Transform2D xform_A = xform_Au * A->get_shape_transform(shape_A); Transform2D xform_Bu = B->get_transform(); - xform_Bu.elements[2] -= offset_A; + xform_Bu.columns[2] -= offset_A; Transform2D xform_B = xform_Bu * B->get_shape_transform(shape_B); if (A->get_continuous_collision_detection_mode() == PhysicsServer2D::CCD_MODE_CAST_RAY && collide_A) { diff --git a/servers/physics_2d/godot_collision_solver_2d.cpp b/servers/physics_2d/godot_collision_solver_2d.cpp index e1b49b77a3..0d7b42b80d 100644 --- a/servers/physics_2d/godot_collision_solver_2d.cpp +++ b/servers/physics_2d/godot_collision_solver_2d.cpp @@ -185,13 +185,13 @@ bool GodotCollisionSolver2D::solve_concave(const GodotShape2D *p_shape_A, const cinfo.aabb_tests = 0; Transform2D rel_transform = p_transform_A; - rel_transform.elements[2] -= p_transform_B.get_origin(); + rel_transform.columns[2] -= p_transform_B.get_origin(); //quickly compute a local Rect2 Rect2 local_aabb; for (int i = 0; i < 2; i++) { - Vector2 axis(p_transform_B.elements[i]); + Vector2 axis(p_transform_B.columns[i]); real_t axis_scale = 1.0 / axis.length(); axis *= axis_scale; diff --git a/servers/physics_2d/godot_collision_solver_2d_sat.cpp b/servers/physics_2d/godot_collision_solver_2d_sat.cpp index d758d1e3b1..77186d3810 100644 --- a/servers/physics_2d/godot_collision_solver_2d_sat.cpp +++ b/servers/physics_2d/godot_collision_solver_2d_sat.cpp @@ -477,11 +477,11 @@ static void _collision_segment_rectangle(const GodotShape2D *p_a, const Transfor return; } - if (!separator.test_axis(p_transform_b.elements[0].normalized())) { + if (!separator.test_axis(p_transform_b.columns[0].normalized())) { return; } - if (!separator.test_axis(p_transform_b.elements[1].normalized())) { + if (!separator.test_axis(p_transform_b.columns[1].normalized())) { return; } @@ -548,22 +548,22 @@ static void _collision_segment_capsule(const GodotShape2D *p_a, const Transform2 return; } - if (!separator.test_axis(p_transform_b.elements[0].normalized())) { + if (!separator.test_axis(p_transform_b.columns[0].normalized())) { return; } real_t capsule_dir = capsule_B->get_height() * 0.5 - capsule_B->get_radius(); - if (TEST_POINT(p_transform_a.xform(segment_A->get_a()), (p_transform_b.get_origin() + p_transform_b.elements[1] * capsule_dir))) { + if (TEST_POINT(p_transform_a.xform(segment_A->get_a()), (p_transform_b.get_origin() + p_transform_b.columns[1] * capsule_dir))) { return; } - if (TEST_POINT(p_transform_a.xform(segment_A->get_a()), (p_transform_b.get_origin() - p_transform_b.elements[1] * capsule_dir))) { + if (TEST_POINT(p_transform_a.xform(segment_A->get_a()), (p_transform_b.get_origin() - p_transform_b.columns[1] * capsule_dir))) { return; } - if (TEST_POINT(p_transform_a.xform(segment_A->get_b()), (p_transform_b.get_origin() + p_transform_b.elements[1] * capsule_dir))) { + if (TEST_POINT(p_transform_a.xform(segment_A->get_b()), (p_transform_b.get_origin() + p_transform_b.columns[1] * capsule_dir))) { return; } - if (TEST_POINT(p_transform_a.xform(segment_A->get_b()), (p_transform_b.get_origin() - p_transform_b.elements[1] * capsule_dir))) { + if (TEST_POINT(p_transform_a.xform(segment_A->get_b()), (p_transform_b.get_origin() - p_transform_b.columns[1] * capsule_dir))) { return; } @@ -646,8 +646,8 @@ static void _collision_circle_rectangle(const GodotShape2D *p_a, const Transform return; } - const Vector2 &sphere = p_transform_a.elements[2]; - const Vector2 *axis = &p_transform_b.elements[0]; + const Vector2 &sphere = p_transform_a.columns[2]; + const Vector2 *axis = &p_transform_b.columns[0]; //const Vector2& half_extents = rectangle_B->get_half_extents(); if (!separator.test_axis(axis[0].normalized())) { @@ -705,17 +705,17 @@ static void _collision_circle_capsule(const GodotShape2D *p_a, const Transform2D } //capsule axis - if (!separator.test_axis(p_transform_b.elements[0].normalized())) { + if (!separator.test_axis(p_transform_b.columns[0].normalized())) { return; } real_t capsule_dir = capsule_B->get_height() * 0.5 - capsule_B->get_radius(); //capsule endpoints - if (TEST_POINT(p_transform_a.get_origin(), (p_transform_b.get_origin() + p_transform_b.elements[1] * capsule_dir))) { + if (TEST_POINT(p_transform_a.get_origin(), (p_transform_b.get_origin() + p_transform_b.columns[1] * capsule_dir))) { return; } - if (TEST_POINT(p_transform_a.get_origin(), (p_transform_b.get_origin() - p_transform_b.elements[1] * capsule_dir))) { + if (TEST_POINT(p_transform_a.get_origin(), (p_transform_b.get_origin() - p_transform_b.columns[1] * capsule_dir))) { return; } @@ -769,20 +769,20 @@ static void _collision_rectangle_rectangle(const GodotShape2D *p_a, const Transf } //box faces A - if (!separator.test_axis(p_transform_a.elements[0].normalized())) { + if (!separator.test_axis(p_transform_a.columns[0].normalized())) { return; } - if (!separator.test_axis(p_transform_a.elements[1].normalized())) { + if (!separator.test_axis(p_transform_a.columns[1].normalized())) { return; } //box faces B - if (!separator.test_axis(p_transform_b.elements[0].normalized())) { + if (!separator.test_axis(p_transform_b.columns[0].normalized())) { return; } - if (!separator.test_axis(p_transform_b.elements[1].normalized())) { + if (!separator.test_axis(p_transform_b.columns[1].normalized())) { return; } @@ -796,10 +796,10 @@ static void _collision_rectangle_rectangle(const GodotShape2D *p_a, const Transf if (castA || castB) { Transform2D aofs = p_transform_a; - aofs.elements[2] += p_motion_a; + aofs.columns[2] += p_motion_a; Transform2D bofs = p_transform_b; - bofs.elements[2] += p_motion_b; + bofs.columns[2] += p_motion_b; Transform2D aofsinv = aofs.affine_inverse(); Transform2D bofsinv = bofs.affine_inverse(); @@ -843,16 +843,16 @@ static void _collision_rectangle_capsule(const GodotShape2D *p_a, const Transfor } //box faces - if (!separator.test_axis(p_transform_a.elements[0].normalized())) { + if (!separator.test_axis(p_transform_a.columns[0].normalized())) { return; } - if (!separator.test_axis(p_transform_a.elements[1].normalized())) { + if (!separator.test_axis(p_transform_a.columns[1].normalized())) { return; } //capsule axis - if (!separator.test_axis(p_transform_b.elements[0].normalized())) { + if (!separator.test_axis(p_transform_b.columns[0].normalized())) { return; } @@ -864,7 +864,7 @@ static void _collision_rectangle_capsule(const GodotShape2D *p_a, const Transfor for (int i = 0; i < 2; i++) { { - Vector2 capsule_endpoint = p_transform_b.get_origin() + p_transform_b.elements[1] * capsule_dir; + Vector2 capsule_endpoint = p_transform_b.get_origin() + p_transform_b.columns[1] * capsule_dir; if (!separator.test_axis(rectangle_A->get_circle_axis(p_transform_a, boxinv, capsule_endpoint))) { return; @@ -872,7 +872,7 @@ static void _collision_rectangle_capsule(const GodotShape2D *p_a, const Transfor } if (castA) { - Vector2 capsule_endpoint = p_transform_b.get_origin() + p_transform_b.elements[1] * capsule_dir; + Vector2 capsule_endpoint = p_transform_b.get_origin() + p_transform_b.columns[1] * capsule_dir; capsule_endpoint -= p_motion_a; if (!separator.test_axis(rectangle_A->get_circle_axis(p_transform_a, boxinv, capsule_endpoint))) { @@ -881,7 +881,7 @@ static void _collision_rectangle_capsule(const GodotShape2D *p_a, const Transfor } if (castB) { - Vector2 capsule_endpoint = p_transform_b.get_origin() + p_transform_b.elements[1] * capsule_dir; + Vector2 capsule_endpoint = p_transform_b.get_origin() + p_transform_b.columns[1] * capsule_dir; capsule_endpoint += p_motion_b; if (!separator.test_axis(rectangle_A->get_circle_axis(p_transform_a, boxinv, capsule_endpoint))) { @@ -890,7 +890,7 @@ static void _collision_rectangle_capsule(const GodotShape2D *p_a, const Transfor } if (castA && castB) { - Vector2 capsule_endpoint = p_transform_b.get_origin() + p_transform_b.elements[1] * capsule_dir; + Vector2 capsule_endpoint = p_transform_b.get_origin() + p_transform_b.columns[1] * capsule_dir; capsule_endpoint -= p_motion_a; capsule_endpoint += p_motion_b; @@ -921,11 +921,11 @@ static void _collision_rectangle_convex_polygon(const GodotShape2D *p_a, const T } //box faces - if (!separator.test_axis(p_transform_a.elements[0].normalized())) { + if (!separator.test_axis(p_transform_a.columns[0].normalized())) { return; } - if (!separator.test_axis(p_transform_a.elements[1].normalized())) { + if (!separator.test_axis(p_transform_a.columns[1].normalized())) { return; } @@ -984,11 +984,11 @@ static void _collision_capsule_capsule(const GodotShape2D *p_a, const Transform2 //capsule axis - if (!separator.test_axis(p_transform_b.elements[0].normalized())) { + if (!separator.test_axis(p_transform_b.columns[0].normalized())) { return; } - if (!separator.test_axis(p_transform_a.elements[0].normalized())) { + if (!separator.test_axis(p_transform_a.columns[0].normalized())) { return; } @@ -996,11 +996,11 @@ static void _collision_capsule_capsule(const GodotShape2D *p_a, const Transform2 real_t capsule_dir_A = capsule_A->get_height() * 0.5 - capsule_A->get_radius(); for (int i = 0; i < 2; i++) { - Vector2 capsule_endpoint_A = p_transform_a.get_origin() + p_transform_a.elements[1] * capsule_dir_A; + Vector2 capsule_endpoint_A = p_transform_a.get_origin() + p_transform_a.columns[1] * capsule_dir_A; real_t capsule_dir_B = capsule_B->get_height() * 0.5 - capsule_B->get_radius(); for (int j = 0; j < 2; j++) { - Vector2 capsule_endpoint_B = p_transform_b.get_origin() + p_transform_b.elements[1] * capsule_dir_B; + Vector2 capsule_endpoint_B = p_transform_b.get_origin() + p_transform_b.columns[1] * capsule_dir_B; if (TEST_POINT(capsule_endpoint_A, capsule_endpoint_B)) { return; @@ -1032,7 +1032,7 @@ static void _collision_capsule_convex_polygon(const GodotShape2D *p_a, const Tra //capsule axis - if (!separator.test_axis(p_transform_a.elements[0].normalized())) { + if (!separator.test_axis(p_transform_a.columns[0].normalized())) { return; } @@ -1042,7 +1042,7 @@ static void _collision_capsule_convex_polygon(const GodotShape2D *p_a, const Tra real_t capsule_dir = capsule_A->get_height() * 0.5 - capsule_A->get_radius(); for (int j = 0; j < 2; j++) { - Vector2 capsule_endpoint_A = p_transform_a.get_origin() + p_transform_a.elements[1] * capsule_dir; + Vector2 capsule_endpoint_A = p_transform_a.get_origin() + p_transform_a.columns[1] * capsule_dir; if (TEST_POINT(capsule_endpoint_A, cpoint)) { return; diff --git a/servers/physics_2d/godot_shape_2d.h b/servers/physics_2d/godot_shape_2d.h index fb52cbce20..9b3477cea8 100644 --- a/servers/physics_2d/godot_shape_2d.h +++ b/servers/physics_2d/godot_shape_2d.h @@ -134,7 +134,7 @@ public: real_t mina, maxa; \ real_t minb, maxb; \ Transform2D ofsb = p_transform; \ - ofsb.elements[2] += p_cast; \ + ofsb.columns[2] += p_cast; \ project_range(p_normal, p_transform, mina, maxa); \ project_range(p_normal, ofsb, minb, maxb); \ r_min = MIN(mina, minb); \ diff --git a/servers/physics_2d/godot_space_2d.cpp b/servers/physics_2d/godot_space_2d.cpp index a2459501c8..8b75d8cde4 100644 --- a/servers/physics_2d/godot_space_2d.cpp +++ b/servers/physics_2d/godot_space_2d.cpp @@ -710,7 +710,7 @@ bool GodotSpace2D::test_body_motion(GodotBody2D *p_body, const PhysicsServer2D:: break; } - body_transform.elements[2] += recover_motion; + body_transform.columns[2] += recover_motion; body_aabb.position += recover_motion; recover_attempts--; @@ -881,7 +881,7 @@ bool GodotSpace2D::test_body_motion(GodotBody2D *p_body, const PhysicsServer2D:: //it collided, let's get the rest info in unsafe advance Transform2D ugt = body_transform; - ugt.elements[2] += p_parameters.motion * unsafe; + ugt.columns[2] += p_parameters.motion * unsafe; _RestCallbackData2D rcd; diff --git a/servers/rendering/renderer_canvas_cull.cpp b/servers/rendering/renderer_canvas_cull.cpp index f4d09ded64..84ab19880c 100644 --- a/servers/rendering/renderer_canvas_cull.cpp +++ b/servers/rendering/renderer_canvas_cull.cpp @@ -84,7 +84,7 @@ void _collect_ysort_children(RendererCanvasCull::Item *p_canvas_item, Transform2 if (r_items) { r_items[r_index] = child_items[i]; child_items[i]->ysort_xform = p_transform; - child_items[i]->ysort_pos = p_transform.xform(child_items[i]->xform.elements[2]); + child_items[i]->ysort_pos = p_transform.xform(child_items[i]->xform.columns[2]); child_items[i]->material_owner = child_items[i]->use_parent_material ? p_material_owner : nullptr; child_items[i]->ysort_index = r_index; } @@ -236,7 +236,7 @@ void RendererCanvasCull::_cull_canvas_item(Item *p_canvas_item, const Transform2 Transform2D xform = ci->xform; if (snapping_2d_transforms_to_pixel) { - xform.elements[2] = xform.elements[2].floor(); + xform.columns[2] = xform.columns[2].floor(); } xform = p_transform * xform; diff --git a/servers/rendering/renderer_rd/cluster_builder_rd.h b/servers/rendering/renderer_rd/cluster_builder_rd.h index 7f6750fa7e..456a7e03f4 100644 --- a/servers/rendering/renderer_rd/cluster_builder_rd.h +++ b/servers/rendering/renderer_rd/cluster_builder_rd.h @@ -331,9 +331,9 @@ public: //extract scale and scale the matrix by it, makes things simpler Vector3 scale = p_half_extents; for (uint32_t i = 0; i < 3; i++) { - float s = xform.basis.elements[i].length(); + float s = xform.basis.rows[i].length(); scale[i] *= s; - xform.basis.elements[i] /= s; + xform.basis.rows[i] /= s; }; float box_depth = Math::abs(xform.basis.xform_inv(Vector3(0, 0, -1)).dot(scale)); diff --git a/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp b/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp index 506fc3b2ab..386bc18fcd 100644 --- a/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp @@ -41,57 +41,57 @@ #include "servers/rendering/rendering_server_default.h" void RendererCanvasRenderRD::_update_transform_2d_to_mat4(const Transform2D &p_transform, float *p_mat4) { - p_mat4[0] = p_transform.elements[0][0]; - p_mat4[1] = p_transform.elements[0][1]; + p_mat4[0] = p_transform.columns[0][0]; + p_mat4[1] = p_transform.columns[0][1]; p_mat4[2] = 0; p_mat4[3] = 0; - p_mat4[4] = p_transform.elements[1][0]; - p_mat4[5] = p_transform.elements[1][1]; + p_mat4[4] = p_transform.columns[1][0]; + p_mat4[5] = p_transform.columns[1][1]; p_mat4[6] = 0; p_mat4[7] = 0; p_mat4[8] = 0; p_mat4[9] = 0; p_mat4[10] = 1; p_mat4[11] = 0; - p_mat4[12] = p_transform.elements[2][0]; - p_mat4[13] = p_transform.elements[2][1]; + p_mat4[12] = p_transform.columns[2][0]; + p_mat4[13] = p_transform.columns[2][1]; p_mat4[14] = 0; p_mat4[15] = 1; } void RendererCanvasRenderRD::_update_transform_2d_to_mat2x4(const Transform2D &p_transform, float *p_mat2x4) { - p_mat2x4[0] = p_transform.elements[0][0]; - p_mat2x4[1] = p_transform.elements[1][0]; + p_mat2x4[0] = p_transform.columns[0][0]; + p_mat2x4[1] = p_transform.columns[1][0]; p_mat2x4[2] = 0; - p_mat2x4[3] = p_transform.elements[2][0]; + p_mat2x4[3] = p_transform.columns[2][0]; - p_mat2x4[4] = p_transform.elements[0][1]; - p_mat2x4[5] = p_transform.elements[1][1]; + p_mat2x4[4] = p_transform.columns[0][1]; + p_mat2x4[5] = p_transform.columns[1][1]; p_mat2x4[6] = 0; - p_mat2x4[7] = p_transform.elements[2][1]; + p_mat2x4[7] = p_transform.columns[2][1]; } void RendererCanvasRenderRD::_update_transform_2d_to_mat2x3(const Transform2D &p_transform, float *p_mat2x3) { - p_mat2x3[0] = p_transform.elements[0][0]; - p_mat2x3[1] = p_transform.elements[0][1]; - p_mat2x3[2] = p_transform.elements[1][0]; - p_mat2x3[3] = p_transform.elements[1][1]; - p_mat2x3[4] = p_transform.elements[2][0]; - p_mat2x3[5] = p_transform.elements[2][1]; + p_mat2x3[0] = p_transform.columns[0][0]; + p_mat2x3[1] = p_transform.columns[0][1]; + p_mat2x3[2] = p_transform.columns[1][0]; + p_mat2x3[3] = p_transform.columns[1][1]; + p_mat2x3[4] = p_transform.columns[2][0]; + p_mat2x3[5] = p_transform.columns[2][1]; } void RendererCanvasRenderRD::_update_transform_to_mat4(const Transform3D &p_transform, float *p_mat4) { - p_mat4[0] = p_transform.basis.elements[0][0]; - p_mat4[1] = p_transform.basis.elements[1][0]; - p_mat4[2] = p_transform.basis.elements[2][0]; + p_mat4[0] = p_transform.basis.rows[0][0]; + p_mat4[1] = p_transform.basis.rows[1][0]; + p_mat4[2] = p_transform.basis.rows[2][0]; p_mat4[3] = 0; - p_mat4[4] = p_transform.basis.elements[0][1]; - p_mat4[5] = p_transform.basis.elements[1][1]; - p_mat4[6] = p_transform.basis.elements[2][1]; + p_mat4[4] = p_transform.basis.rows[0][1]; + p_mat4[5] = p_transform.basis.rows[1][1]; + p_mat4[6] = p_transform.basis.rows[2][1]; p_mat4[7] = 0; - p_mat4[8] = p_transform.basis.elements[0][2]; - p_mat4[9] = p_transform.basis.elements[1][2]; - p_mat4[10] = p_transform.basis.elements[2][2]; + p_mat4[8] = p_transform.basis.rows[0][2]; + p_mat4[9] = p_transform.basis.rows[1][2]; + p_mat4[10] = p_transform.basis.rows[2][2]; p_mat4[11] = 0; p_mat4[12] = p_transform.origin.x; p_mat4[13] = p_transform.origin.y; @@ -1175,7 +1175,7 @@ void RendererCanvasRenderRD::canvas_render_items(RID p_to_render_target, Item *p ERR_CONTINUE(!clight); } - Vector2 canvas_light_dir = l->xform_cache.elements[1].normalized(); + Vector2 canvas_light_dir = l->xform_cache.columns[1].normalized(); state.light_uniforms[index].position[0] = -canvas_light_dir.x; state.light_uniforms[index].position[1] = -canvas_light_dir.y; @@ -1246,7 +1246,7 @@ void RendererCanvasRenderRD::canvas_render_items(RID p_to_render_target, Item *p _update_transform_2d_to_mat2x4(to_light_xform, state.light_uniforms[index].matrix); _update_transform_2d_to_mat2x4(l->xform_cache.affine_inverse(), state.light_uniforms[index].shadow_matrix); - state.light_uniforms[index].height = l->height * (p_canvas_transform.elements[0].length() + p_canvas_transform.elements[1].length()) * 0.5; //approximate height conversion to the canvas size, since all calculations are done in canvas coords to avoid precision loss + state.light_uniforms[index].height = l->height * (p_canvas_transform.columns[0].length() + p_canvas_transform.columns[1].length()) * 0.5; //approximate height conversion to the canvas size, since all calculations are done in canvas coords to avoid precision loss for (int i = 0; i < 4; i++) { state.light_uniforms[index].shadow_color[i] = uint8_t(CLAMP(int32_t(l->shadow_color[i] * 255.0), 0, 255)); state.light_uniforms[index].color[i] = l->color[i]; @@ -1310,9 +1310,9 @@ void RendererCanvasRenderRD::canvas_render_items(RID p_to_render_target, Item *p _update_transform_2d_to_mat4(p_canvas_transform, state_buffer.canvas_transform); Transform2D normal_transform = p_canvas_transform; - normal_transform.elements[0].normalize(); - normal_transform.elements[1].normalize(); - normal_transform.elements[2] = Vector2(); + normal_transform.columns[0].normalize(); + normal_transform.columns[1].normalize(); + normal_transform.columns[2] = Vector2(); _update_transform_2d_to_mat4(normal_transform, state_buffer.canvas_normal_transform); state_buffer.canvas_modulate[0] = p_modulate.r; @@ -1645,7 +1645,7 @@ void RendererCanvasRenderRD::light_update_directional_shadow(RID p_rid, int p_sh _update_shadow_atlas(); - Vector2 light_dir = p_light_xform.elements[1].normalized(); + Vector2 light_dir = p_light_xform.columns[1].normalized(); Vector2 center = p_clip_rect.get_center(); @@ -1713,8 +1713,8 @@ void RendererCanvasRenderRD::light_update_directional_shadow(RID p_rid, int p_sh RD::get_singleton()->draw_list_end(); Transform2D to_shadow; - to_shadow.elements[0].x = 1.0 / -(half_size * 2.0); - to_shadow.elements[2].x = 0.5; + to_shadow.columns[0].x = 1.0 / -(half_size * 2.0); + to_shadow.columns[2].x = 0.5; cl->shadow.directional_xform = to_shadow * to_light_xform; } @@ -1726,14 +1726,14 @@ void RendererCanvasRenderRD::render_sdf(RID p_render_target, LightOccluderInstan Rect2i rect = texture_storage->render_target_get_sdf_rect(p_render_target); Transform2D to_sdf; - to_sdf.elements[0] *= rect.size.width; - to_sdf.elements[1] *= rect.size.height; - to_sdf.elements[2] = rect.position; + to_sdf.columns[0] *= rect.size.width; + to_sdf.columns[1] *= rect.size.height; + to_sdf.columns[2] = rect.position; Transform2D to_clip; - to_clip.elements[0] *= 2.0; - to_clip.elements[1] *= 2.0; - to_clip.elements[2] = -Vector2(1.0, 1.0); + to_clip.columns[0] *= 2.0; + to_clip.columns[1] *= 2.0; + to_clip.columns[2] = -Vector2(1.0, 1.0); to_clip = to_clip * to_sdf.affine_inverse(); diff --git a/servers/rendering/renderer_rd/renderer_scene_gi_rd.cpp b/servers/rendering/renderer_rd/renderer_scene_gi_rd.cpp index 0a16bf4bd1..6eebf84934 100644 --- a/servers/rendering/renderer_rd/renderer_scene_gi_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_scene_gi_rd.cpp @@ -1228,17 +1228,17 @@ void RendererSceneGIRD::SDFGI::debug_draw(const CameraMatrix &p_projection, cons push_constant.cam_extent[1] = vp_half.y; push_constant.cam_extent[2] = -p_projection.get_z_near(); - push_constant.cam_transform[0] = p_transform.basis.elements[0][0]; - push_constant.cam_transform[1] = p_transform.basis.elements[1][0]; - push_constant.cam_transform[2] = p_transform.basis.elements[2][0]; + push_constant.cam_transform[0] = p_transform.basis.rows[0][0]; + push_constant.cam_transform[1] = p_transform.basis.rows[1][0]; + push_constant.cam_transform[2] = p_transform.basis.rows[2][0]; push_constant.cam_transform[3] = 0; - push_constant.cam_transform[4] = p_transform.basis.elements[0][1]; - push_constant.cam_transform[5] = p_transform.basis.elements[1][1]; - push_constant.cam_transform[6] = p_transform.basis.elements[2][1]; + push_constant.cam_transform[4] = p_transform.basis.rows[0][1]; + push_constant.cam_transform[5] = p_transform.basis.rows[1][1]; + push_constant.cam_transform[6] = p_transform.basis.rows[2][1]; push_constant.cam_transform[7] = 0; - push_constant.cam_transform[8] = p_transform.basis.elements[0][2]; - push_constant.cam_transform[9] = p_transform.basis.elements[1][2]; - push_constant.cam_transform[10] = p_transform.basis.elements[2][2]; + push_constant.cam_transform[8] = p_transform.basis.rows[0][2]; + push_constant.cam_transform[9] = p_transform.basis.rows[1][2]; + push_constant.cam_transform[10] = p_transform.basis.rows[2][2]; push_constant.cam_transform[11] = 0; push_constant.cam_transform[12] = p_transform.origin.x; push_constant.cam_transform[13] = p_transform.origin.y; @@ -3070,17 +3070,17 @@ void RendererSceneGIRD::setup_voxel_gi_instances(RID p_render_buffers, const Tra Transform3D to_cell = storage->voxel_gi_get_to_cell_xform(gipi->probe) * gipi->transform.affine_inverse() * to_camera; - gipd.xform[0] = to_cell.basis.elements[0][0]; - gipd.xform[1] = to_cell.basis.elements[1][0]; - gipd.xform[2] = to_cell.basis.elements[2][0]; + gipd.xform[0] = to_cell.basis.rows[0][0]; + gipd.xform[1] = to_cell.basis.rows[1][0]; + gipd.xform[2] = to_cell.basis.rows[2][0]; gipd.xform[3] = 0; - gipd.xform[4] = to_cell.basis.elements[0][1]; - gipd.xform[5] = to_cell.basis.elements[1][1]; - gipd.xform[6] = to_cell.basis.elements[2][1]; + gipd.xform[4] = to_cell.basis.rows[0][1]; + gipd.xform[5] = to_cell.basis.rows[1][1]; + gipd.xform[6] = to_cell.basis.rows[2][1]; gipd.xform[7] = 0; - gipd.xform[8] = to_cell.basis.elements[0][2]; - gipd.xform[9] = to_cell.basis.elements[1][2]; - gipd.xform[10] = to_cell.basis.elements[2][2]; + gipd.xform[8] = to_cell.basis.rows[0][2]; + gipd.xform[9] = to_cell.basis.rows[1][2]; + gipd.xform[10] = to_cell.basis.rows[2][2]; gipd.xform[11] = 0; gipd.xform[12] = to_cell.origin.x; gipd.xform[13] = to_cell.origin.y; diff --git a/servers/rendering/renderer_rd/renderer_scene_sky_rd.cpp b/servers/rendering/renderer_rd/renderer_scene_sky_rd.cpp index a3d53e00af..51cf0e952b 100644 --- a/servers/rendering/renderer_rd/renderer_scene_sky_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_scene_sky_rd.cpp @@ -252,17 +252,17 @@ RendererSceneSkyRD::SkyMaterialData::~SkyMaterialData() { // Render sky static _FORCE_INLINE_ void store_transform_3x3(const Basis &p_basis, float *p_array) { - p_array[0] = p_basis.elements[0][0]; - p_array[1] = p_basis.elements[1][0]; - p_array[2] = p_basis.elements[2][0]; + p_array[0] = p_basis.rows[0][0]; + p_array[1] = p_basis.rows[1][0]; + p_array[2] = p_basis.rows[2][0]; p_array[3] = 0; - p_array[4] = p_basis.elements[0][1]; - p_array[5] = p_basis.elements[1][1]; - p_array[6] = p_basis.elements[2][1]; + p_array[4] = p_basis.rows[0][1]; + p_array[5] = p_basis.rows[1][1]; + p_array[6] = p_basis.rows[2][1]; p_array[7] = 0; - p_array[8] = p_basis.elements[0][2]; - p_array[9] = p_basis.elements[1][2]; - p_array[10] = p_basis.elements[2][2]; + p_array[8] = p_basis.rows[0][2]; + p_array[9] = p_basis.rows[1][2]; + p_array[10] = p_basis.rows[2][2]; p_array[11] = 0; } diff --git a/servers/rendering/renderer_rd/renderer_storage_rd.h b/servers/rendering/renderer_rd/renderer_storage_rd.h index 37c76f9c62..1e7e8c27a3 100644 --- a/servers/rendering/renderer_rd/renderer_storage_rd.h +++ b/servers/rendering/renderer_rd/renderer_storage_rd.h @@ -45,17 +45,17 @@ class RendererStorageRD : public RendererStorage { public: static _FORCE_INLINE_ void store_transform(const Transform3D &p_mtx, float *p_array) { - p_array[0] = p_mtx.basis.elements[0][0]; - p_array[1] = p_mtx.basis.elements[1][0]; - p_array[2] = p_mtx.basis.elements[2][0]; + p_array[0] = p_mtx.basis.rows[0][0]; + p_array[1] = p_mtx.basis.rows[1][0]; + p_array[2] = p_mtx.basis.rows[2][0]; p_array[3] = 0; - p_array[4] = p_mtx.basis.elements[0][1]; - p_array[5] = p_mtx.basis.elements[1][1]; - p_array[6] = p_mtx.basis.elements[2][1]; + p_array[4] = p_mtx.basis.rows[0][1]; + p_array[5] = p_mtx.basis.rows[1][1]; + p_array[6] = p_mtx.basis.rows[2][1]; p_array[7] = 0; - p_array[8] = p_mtx.basis.elements[0][2]; - p_array[9] = p_mtx.basis.elements[1][2]; - p_array[10] = p_mtx.basis.elements[2][2]; + p_array[8] = p_mtx.basis.rows[0][2]; + p_array[9] = p_mtx.basis.rows[1][2]; + p_array[10] = p_mtx.basis.rows[2][2]; p_array[11] = 0; p_array[12] = p_mtx.origin.x; p_array[13] = p_mtx.origin.y; @@ -64,47 +64,47 @@ public: } static _FORCE_INLINE_ void store_basis_3x4(const Basis &p_mtx, float *p_array) { - p_array[0] = p_mtx.elements[0][0]; - p_array[1] = p_mtx.elements[1][0]; - p_array[2] = p_mtx.elements[2][0]; + p_array[0] = p_mtx.rows[0][0]; + p_array[1] = p_mtx.rows[1][0]; + p_array[2] = p_mtx.rows[2][0]; p_array[3] = 0; - p_array[4] = p_mtx.elements[0][1]; - p_array[5] = p_mtx.elements[1][1]; - p_array[6] = p_mtx.elements[2][1]; + p_array[4] = p_mtx.rows[0][1]; + p_array[5] = p_mtx.rows[1][1]; + p_array[6] = p_mtx.rows[2][1]; p_array[7] = 0; - p_array[8] = p_mtx.elements[0][2]; - p_array[9] = p_mtx.elements[1][2]; - p_array[10] = p_mtx.elements[2][2]; + p_array[8] = p_mtx.rows[0][2]; + p_array[9] = p_mtx.rows[1][2]; + p_array[10] = p_mtx.rows[2][2]; p_array[11] = 0; } static _FORCE_INLINE_ void store_transform_3x3(const Basis &p_mtx, float *p_array) { - p_array[0] = p_mtx.elements[0][0]; - p_array[1] = p_mtx.elements[1][0]; - p_array[2] = p_mtx.elements[2][0]; + p_array[0] = p_mtx.rows[0][0]; + p_array[1] = p_mtx.rows[1][0]; + p_array[2] = p_mtx.rows[2][0]; p_array[3] = 0; - p_array[4] = p_mtx.elements[0][1]; - p_array[5] = p_mtx.elements[1][1]; - p_array[6] = p_mtx.elements[2][1]; + p_array[4] = p_mtx.rows[0][1]; + p_array[5] = p_mtx.rows[1][1]; + p_array[6] = p_mtx.rows[2][1]; p_array[7] = 0; - p_array[8] = p_mtx.elements[0][2]; - p_array[9] = p_mtx.elements[1][2]; - p_array[10] = p_mtx.elements[2][2]; + p_array[8] = p_mtx.rows[0][2]; + p_array[9] = p_mtx.rows[1][2]; + p_array[10] = p_mtx.rows[2][2]; p_array[11] = 0; } static _FORCE_INLINE_ void store_transform_transposed_3x4(const Transform3D &p_mtx, float *p_array) { - p_array[0] = p_mtx.basis.elements[0][0]; - p_array[1] = p_mtx.basis.elements[0][1]; - p_array[2] = p_mtx.basis.elements[0][2]; + p_array[0] = p_mtx.basis.rows[0][0]; + p_array[1] = p_mtx.basis.rows[0][1]; + p_array[2] = p_mtx.basis.rows[0][2]; p_array[3] = p_mtx.origin.x; - p_array[4] = p_mtx.basis.elements[1][0]; - p_array[5] = p_mtx.basis.elements[1][1]; - p_array[6] = p_mtx.basis.elements[1][2]; + p_array[4] = p_mtx.basis.rows[1][0]; + p_array[5] = p_mtx.basis.rows[1][1]; + p_array[6] = p_mtx.basis.rows[1][2]; p_array[7] = p_mtx.origin.y; - p_array[8] = p_mtx.basis.elements[2][0]; - p_array[9] = p_mtx.basis.elements[2][1]; - p_array[10] = p_mtx.basis.elements[2][2]; + p_array[8] = p_mtx.basis.rows[2][0]; + p_array[9] = p_mtx.basis.rows[2][1]; + p_array[10] = p_mtx.basis.rows[2][2]; p_array[11] = p_mtx.origin.z; } diff --git a/servers/rendering/renderer_rd/storage_rd/material_storage.cpp b/servers/rendering/renderer_rd/storage_rd/material_storage.cpp index 3f177e553b..9ca2973fd4 100644 --- a/servers/rendering/renderer_rd/storage_rd/material_storage.cpp +++ b/servers/rendering/renderer_rd/storage_rd/material_storage.cpp @@ -554,13 +554,13 @@ _FORCE_INLINE_ static void _fill_std140_variant_ubo_value(ShaderLanguage::DataTy Transform2D v = value; //in std140 members of mat2 are treated as vec4s - gui[0] = v.elements[0][0]; - gui[1] = v.elements[0][1]; + gui[0] = v.columns[0][0]; + gui[1] = v.columns[0][1]; gui[2] = 0; // ignored gui[3] = 0; // ignored - gui[4] = v.elements[1][0]; - gui[5] = v.elements[1][1]; + gui[4] = v.columns[1][0]; + gui[5] = v.columns[1][1]; gui[6] = 0; // ignored gui[7] = 0; // ignored } @@ -604,19 +604,19 @@ _FORCE_INLINE_ static void _fill_std140_variant_ubo_value(ShaderLanguage::DataTy } } else { Basis v = value; - gui[0] = v.elements[0][0]; - gui[1] = v.elements[1][0]; - gui[2] = v.elements[2][0]; + gui[0] = v.rows[0][0]; + gui[1] = v.rows[1][0]; + gui[2] = v.rows[2][0]; gui[3] = 0; // ignored - gui[4] = v.elements[0][1]; - gui[5] = v.elements[1][1]; - gui[6] = v.elements[2][1]; + gui[4] = v.rows[0][1]; + gui[5] = v.rows[1][1]; + gui[6] = v.rows[2][1]; gui[7] = 0; // ignored - gui[8] = v.elements[0][2]; - gui[9] = v.elements[1][2]; - gui[10] = v.elements[2][2]; + gui[8] = v.rows[0][2]; + gui[9] = v.rows[1][2]; + gui[10] = v.rows[2][2]; gui[11] = 0; // ignored } } break; @@ -672,19 +672,19 @@ _FORCE_INLINE_ static void _fill_std140_variant_ubo_value(ShaderLanguage::DataTy } } else { Transform3D v = value; - gui[0] = v.basis.elements[0][0]; - gui[1] = v.basis.elements[1][0]; - gui[2] = v.basis.elements[2][0]; + gui[0] = v.basis.rows[0][0]; + gui[1] = v.basis.rows[1][0]; + gui[2] = v.basis.rows[2][0]; gui[3] = 0; - gui[4] = v.basis.elements[0][1]; - gui[5] = v.basis.elements[1][1]; - gui[6] = v.basis.elements[2][1]; + gui[4] = v.basis.rows[0][1]; + gui[5] = v.basis.rows[1][1]; + gui[6] = v.basis.rows[2][1]; gui[7] = 0; - gui[8] = v.basis.elements[0][2]; - gui[9] = v.basis.elements[1][2]; - gui[10] = v.basis.elements[2][2]; + gui[8] = v.basis.rows[0][2]; + gui[9] = v.basis.rows[1][2]; + gui[10] = v.basis.rows[2][2]; gui[11] = 0; gui[12] = v.origin.x; @@ -1767,19 +1767,19 @@ void MaterialStorage::_global_variable_store_in_buffer(int32_t p_index, RS::Glob case RS::GLOBAL_VAR_TYPE_MAT3: { GlobalVariables::Value *bv = &global_variables.buffer_values[p_index]; Basis v = p_value; - bv[0].x = v.elements[0][0]; - bv[0].y = v.elements[1][0]; - bv[0].z = v.elements[2][0]; + bv[0].x = v.rows[0][0]; + bv[0].y = v.rows[1][0]; + bv[0].z = v.rows[2][0]; bv[0].w = 0; - bv[1].x = v.elements[0][1]; - bv[1].y = v.elements[1][1]; - bv[1].z = v.elements[2][1]; + bv[1].x = v.rows[0][1]; + bv[1].y = v.rows[1][1]; + bv[1].z = v.rows[2][1]; bv[1].w = 0; - bv[2].x = v.elements[0][2]; - bv[2].y = v.elements[1][2]; - bv[2].z = v.elements[2][2]; + bv[2].x = v.rows[0][2]; + bv[2].y = v.rows[1][2]; + bv[2].z = v.rows[2][2]; bv[2].w = 0; } break; @@ -1815,18 +1815,18 @@ void MaterialStorage::_global_variable_store_in_buffer(int32_t p_index, RS::Glob case RS::GLOBAL_VAR_TYPE_TRANSFORM_2D: { GlobalVariables::Value *bv = &global_variables.buffer_values[p_index]; Transform2D v = p_value; - bv[0].x = v.elements[0][0]; - bv[0].y = v.elements[0][1]; + bv[0].x = v.columns[0][0]; + bv[0].y = v.columns[0][1]; bv[0].z = 0; bv[0].w = 0; - bv[1].x = v.elements[1][0]; - bv[1].y = v.elements[1][1]; + bv[1].x = v.columns[1][0]; + bv[1].y = v.columns[1][1]; bv[1].z = 0; bv[1].w = 0; - bv[2].x = v.elements[2][0]; - bv[2].y = v.elements[2][1]; + bv[2].x = v.columns[2][0]; + bv[2].y = v.columns[2][1]; bv[2].z = 1; bv[2].w = 0; @@ -1834,19 +1834,19 @@ void MaterialStorage::_global_variable_store_in_buffer(int32_t p_index, RS::Glob case RS::GLOBAL_VAR_TYPE_TRANSFORM: { GlobalVariables::Value *bv = &global_variables.buffer_values[p_index]; Transform3D v = p_value; - bv[0].x = v.basis.elements[0][0]; - bv[0].y = v.basis.elements[1][0]; - bv[0].z = v.basis.elements[2][0]; + bv[0].x = v.basis.rows[0][0]; + bv[0].y = v.basis.rows[1][0]; + bv[0].z = v.basis.rows[2][0]; bv[0].w = 0; - bv[1].x = v.basis.elements[0][1]; - bv[1].y = v.basis.elements[1][1]; - bv[1].z = v.basis.elements[2][1]; + bv[1].x = v.basis.rows[0][1]; + bv[1].y = v.basis.rows[1][1]; + bv[1].z = v.basis.rows[2][1]; bv[1].w = 0; - bv[2].x = v.basis.elements[0][2]; - bv[2].y = v.basis.elements[1][2]; - bv[2].z = v.basis.elements[2][2]; + bv[2].x = v.basis.rows[0][2]; + bv[2].y = v.basis.rows[1][2]; + bv[2].z = v.basis.rows[2][2]; bv[2].w = 0; bv[3].x = v.origin.x; diff --git a/servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp b/servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp index 0f74c591c6..9b7b0d2c25 100644 --- a/servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp +++ b/servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp @@ -609,12 +609,12 @@ AABB MeshStorage::mesh_get_aabb(RID p_mesh, RID p_skeleton) { Transform3D mtx; - mtx.basis.elements[0].x = dataptr[0]; - mtx.basis.elements[1].x = dataptr[1]; + mtx.basis.rows[0].x = dataptr[0]; + mtx.basis.rows[1].x = dataptr[1]; mtx.origin.x = dataptr[3]; - mtx.basis.elements[0].y = dataptr[4]; - mtx.basis.elements[1].y = dataptr[5]; + mtx.basis.rows[0].y = dataptr[4]; + mtx.basis.rows[1].y = dataptr[5]; mtx.origin.y = dataptr[7]; AABB baabb = mtx.xform(skbones[j]); @@ -636,17 +636,17 @@ AABB MeshStorage::mesh_get_aabb(RID p_mesh, RID p_skeleton) { Transform3D mtx; - mtx.basis.elements[0][0] = dataptr[0]; - mtx.basis.elements[0][1] = dataptr[1]; - mtx.basis.elements[0][2] = dataptr[2]; + mtx.basis.rows[0][0] = dataptr[0]; + mtx.basis.rows[0][1] = dataptr[1]; + mtx.basis.rows[0][2] = dataptr[2]; mtx.origin.x = dataptr[3]; - mtx.basis.elements[1][0] = dataptr[4]; - mtx.basis.elements[1][1] = dataptr[5]; - mtx.basis.elements[1][2] = dataptr[6]; + mtx.basis.rows[1][0] = dataptr[4]; + mtx.basis.rows[1][1] = dataptr[5]; + mtx.basis.rows[1][2] = dataptr[6]; mtx.origin.y = dataptr[7]; - mtx.basis.elements[2][0] = dataptr[8]; - mtx.basis.elements[2][1] = dataptr[9]; - mtx.basis.elements[2][2] = dataptr[10]; + mtx.basis.rows[2][0] = dataptr[8]; + mtx.basis.rows[2][1] = dataptr[9]; + mtx.basis.rows[2][2] = dataptr[10]; mtx.origin.z = dataptr[11]; AABB baabb = mtx.xform(skbones[j]); @@ -1331,26 +1331,26 @@ void MeshStorage::_multimesh_re_create_aabb(MultiMesh *multimesh, const float *p Transform3D t; if (multimesh->xform_format == RS::MULTIMESH_TRANSFORM_3D) { - t.basis.elements[0][0] = data[0]; - t.basis.elements[0][1] = data[1]; - t.basis.elements[0][2] = data[2]; + t.basis.rows[0][0] = data[0]; + t.basis.rows[0][1] = data[1]; + t.basis.rows[0][2] = data[2]; t.origin.x = data[3]; - t.basis.elements[1][0] = data[4]; - t.basis.elements[1][1] = data[5]; - t.basis.elements[1][2] = data[6]; + t.basis.rows[1][0] = data[4]; + t.basis.rows[1][1] = data[5]; + t.basis.rows[1][2] = data[6]; t.origin.y = data[7]; - t.basis.elements[2][0] = data[8]; - t.basis.elements[2][1] = data[9]; - t.basis.elements[2][2] = data[10]; + t.basis.rows[2][0] = data[8]; + t.basis.rows[2][1] = data[9]; + t.basis.rows[2][2] = data[10]; t.origin.z = data[11]; } else { - t.basis.elements[0].x = data[0]; - t.basis.elements[1].x = data[1]; + t.basis.rows[0].x = data[0]; + t.basis.rows[1].x = data[1]; t.origin.x = data[3]; - t.basis.elements[0].y = data[4]; - t.basis.elements[1].y = data[5]; + t.basis.rows[0].y = data[4]; + t.basis.rows[1].y = data[5]; t.origin.y = data[7]; } @@ -1377,17 +1377,17 @@ void MeshStorage::multimesh_instance_set_transform(RID p_multimesh, int p_index, float *dataptr = w + p_index * multimesh->stride_cache; - dataptr[0] = p_transform.basis.elements[0][0]; - dataptr[1] = p_transform.basis.elements[0][1]; - dataptr[2] = p_transform.basis.elements[0][2]; + dataptr[0] = p_transform.basis.rows[0][0]; + dataptr[1] = p_transform.basis.rows[0][1]; + dataptr[2] = p_transform.basis.rows[0][2]; dataptr[3] = p_transform.origin.x; - dataptr[4] = p_transform.basis.elements[1][0]; - dataptr[5] = p_transform.basis.elements[1][1]; - dataptr[6] = p_transform.basis.elements[1][2]; + dataptr[4] = p_transform.basis.rows[1][0]; + dataptr[5] = p_transform.basis.rows[1][1]; + dataptr[6] = p_transform.basis.rows[1][2]; dataptr[7] = p_transform.origin.y; - dataptr[8] = p_transform.basis.elements[2][0]; - dataptr[9] = p_transform.basis.elements[2][1]; - dataptr[10] = p_transform.basis.elements[2][2]; + dataptr[8] = p_transform.basis.rows[2][0]; + dataptr[9] = p_transform.basis.rows[2][1]; + dataptr[10] = p_transform.basis.rows[2][2]; dataptr[11] = p_transform.origin.z; } @@ -1407,14 +1407,14 @@ void MeshStorage::multimesh_instance_set_transform_2d(RID p_multimesh, int p_ind float *dataptr = w + p_index * multimesh->stride_cache; - dataptr[0] = p_transform.elements[0][0]; - dataptr[1] = p_transform.elements[1][0]; + dataptr[0] = p_transform.columns[0][0]; + dataptr[1] = p_transform.columns[1][0]; dataptr[2] = 0; - dataptr[3] = p_transform.elements[2][0]; - dataptr[4] = p_transform.elements[0][1]; - dataptr[5] = p_transform.elements[1][1]; + dataptr[3] = p_transform.columns[2][0]; + dataptr[4] = p_transform.columns[0][1]; + dataptr[5] = p_transform.columns[1][1]; dataptr[6] = 0; - dataptr[7] = p_transform.elements[2][1]; + dataptr[7] = p_transform.columns[2][1]; } _multimesh_mark_dirty(multimesh, p_index, true); @@ -1485,17 +1485,17 @@ Transform3D MeshStorage::multimesh_instance_get_transform(RID p_multimesh, int p const float *dataptr = r + p_index * multimesh->stride_cache; - t.basis.elements[0][0] = dataptr[0]; - t.basis.elements[0][1] = dataptr[1]; - t.basis.elements[0][2] = dataptr[2]; + t.basis.rows[0][0] = dataptr[0]; + t.basis.rows[0][1] = dataptr[1]; + t.basis.rows[0][2] = dataptr[2]; t.origin.x = dataptr[3]; - t.basis.elements[1][0] = dataptr[4]; - t.basis.elements[1][1] = dataptr[5]; - t.basis.elements[1][2] = dataptr[6]; + t.basis.rows[1][0] = dataptr[4]; + t.basis.rows[1][1] = dataptr[5]; + t.basis.rows[1][2] = dataptr[6]; t.origin.y = dataptr[7]; - t.basis.elements[2][0] = dataptr[8]; - t.basis.elements[2][1] = dataptr[9]; - t.basis.elements[2][2] = dataptr[10]; + t.basis.rows[2][0] = dataptr[8]; + t.basis.rows[2][1] = dataptr[9]; + t.basis.rows[2][2] = dataptr[10]; t.origin.z = dataptr[11]; } @@ -1516,12 +1516,12 @@ Transform2D MeshStorage::multimesh_instance_get_transform_2d(RID p_multimesh, in const float *dataptr = r + p_index * multimesh->stride_cache; - t.elements[0][0] = dataptr[0]; - t.elements[1][0] = dataptr[1]; - t.elements[2][0] = dataptr[3]; - t.elements[0][1] = dataptr[4]; - t.elements[1][1] = dataptr[5]; - t.elements[2][1] = dataptr[7]; + t.columns[0][0] = dataptr[0]; + t.columns[1][0] = dataptr[1]; + t.columns[2][0] = dataptr[3]; + t.columns[0][1] = dataptr[4]; + t.columns[1][1] = dataptr[5]; + t.columns[2][1] = dataptr[7]; } return t; @@ -1800,17 +1800,17 @@ void MeshStorage::skeleton_bone_set_transform(RID p_skeleton, int p_bone, const float *dataptr = skeleton->data.ptrw() + p_bone * 12; - dataptr[0] = p_transform.basis.elements[0][0]; - dataptr[1] = p_transform.basis.elements[0][1]; - dataptr[2] = p_transform.basis.elements[0][2]; + dataptr[0] = p_transform.basis.rows[0][0]; + dataptr[1] = p_transform.basis.rows[0][1]; + dataptr[2] = p_transform.basis.rows[0][2]; dataptr[3] = p_transform.origin.x; - dataptr[4] = p_transform.basis.elements[1][0]; - dataptr[5] = p_transform.basis.elements[1][1]; - dataptr[6] = p_transform.basis.elements[1][2]; + dataptr[4] = p_transform.basis.rows[1][0]; + dataptr[5] = p_transform.basis.rows[1][1]; + dataptr[6] = p_transform.basis.rows[1][2]; dataptr[7] = p_transform.origin.y; - dataptr[8] = p_transform.basis.elements[2][0]; - dataptr[9] = p_transform.basis.elements[2][1]; - dataptr[10] = p_transform.basis.elements[2][2]; + dataptr[8] = p_transform.basis.rows[2][0]; + dataptr[9] = p_transform.basis.rows[2][1]; + dataptr[10] = p_transform.basis.rows[2][2]; dataptr[11] = p_transform.origin.z; _skeleton_make_dirty(skeleton); @@ -1827,17 +1827,17 @@ Transform3D MeshStorage::skeleton_bone_get_transform(RID p_skeleton, int p_bone) Transform3D t; - t.basis.elements[0][0] = dataptr[0]; - t.basis.elements[0][1] = dataptr[1]; - t.basis.elements[0][2] = dataptr[2]; + t.basis.rows[0][0] = dataptr[0]; + t.basis.rows[0][1] = dataptr[1]; + t.basis.rows[0][2] = dataptr[2]; t.origin.x = dataptr[3]; - t.basis.elements[1][0] = dataptr[4]; - t.basis.elements[1][1] = dataptr[5]; - t.basis.elements[1][2] = dataptr[6]; + t.basis.rows[1][0] = dataptr[4]; + t.basis.rows[1][1] = dataptr[5]; + t.basis.rows[1][2] = dataptr[6]; t.origin.y = dataptr[7]; - t.basis.elements[2][0] = dataptr[8]; - t.basis.elements[2][1] = dataptr[9]; - t.basis.elements[2][2] = dataptr[10]; + t.basis.rows[2][0] = dataptr[8]; + t.basis.rows[2][1] = dataptr[9]; + t.basis.rows[2][2] = dataptr[10]; t.origin.z = dataptr[11]; return t; @@ -1852,14 +1852,14 @@ void MeshStorage::skeleton_bone_set_transform_2d(RID p_skeleton, int p_bone, con float *dataptr = skeleton->data.ptrw() + p_bone * 8; - dataptr[0] = p_transform.elements[0][0]; - dataptr[1] = p_transform.elements[1][0]; + dataptr[0] = p_transform.columns[0][0]; + dataptr[1] = p_transform.columns[1][0]; dataptr[2] = 0; - dataptr[3] = p_transform.elements[2][0]; - dataptr[4] = p_transform.elements[0][1]; - dataptr[5] = p_transform.elements[1][1]; + dataptr[3] = p_transform.columns[2][0]; + dataptr[4] = p_transform.columns[0][1]; + dataptr[5] = p_transform.columns[1][1]; dataptr[6] = 0; - dataptr[7] = p_transform.elements[2][1]; + dataptr[7] = p_transform.columns[2][1]; _skeleton_make_dirty(skeleton); } @@ -1874,12 +1874,12 @@ Transform2D MeshStorage::skeleton_bone_get_transform_2d(RID p_skeleton, int p_bo const float *dataptr = skeleton->data.ptr() + p_bone * 8; Transform2D t; - t.elements[0][0] = dataptr[0]; - t.elements[1][0] = dataptr[1]; - t.elements[2][0] = dataptr[3]; - t.elements[0][1] = dataptr[4]; - t.elements[1][1] = dataptr[5]; - t.elements[2][1] = dataptr[7]; + t.columns[0][0] = dataptr[0]; + t.columns[1][0] = dataptr[1]; + t.columns[2][0] = dataptr[3]; + t.columns[0][1] = dataptr[4]; + t.columns[1][1] = dataptr[5]; + t.columns[2][1] = dataptr[7]; return t; } diff --git a/servers/rendering/renderer_rd/storage_rd/particles_storage.cpp b/servers/rendering/renderer_rd/storage_rd/particles_storage.cpp index 13b171979a..094120f908 100644 --- a/servers/rendering/renderer_rd/storage_rd/particles_storage.cpp +++ b/servers/rendering/renderer_rd/storage_rd/particles_storage.cpp @@ -800,25 +800,25 @@ void ParticlesStorage::_particles_process(Particles *p_particles, double p_delta Transform2D xform = p_particles->sdf_collision_transform; //will use dotproduct manually so invert beforehand Transform2D revert = xform.affine_inverse(); frame_params.collider_count = 1; - frame_params.colliders[0].transform[0] = xform.elements[0][0]; - frame_params.colliders[0].transform[1] = xform.elements[0][1]; + frame_params.colliders[0].transform[0] = xform.columns[0][0]; + frame_params.colliders[0].transform[1] = xform.columns[0][1]; frame_params.colliders[0].transform[2] = 0; - frame_params.colliders[0].transform[3] = xform.elements[2][0]; + frame_params.colliders[0].transform[3] = xform.columns[2][0]; - frame_params.colliders[0].transform[4] = xform.elements[1][0]; - frame_params.colliders[0].transform[5] = xform.elements[1][1]; + frame_params.colliders[0].transform[4] = xform.columns[1][0]; + frame_params.colliders[0].transform[5] = xform.columns[1][1]; frame_params.colliders[0].transform[6] = 0; - frame_params.colliders[0].transform[7] = xform.elements[2][1]; + frame_params.colliders[0].transform[7] = xform.columns[2][1]; - frame_params.colliders[0].transform[8] = revert.elements[0][0]; - frame_params.colliders[0].transform[9] = revert.elements[0][1]; + frame_params.colliders[0].transform[8] = revert.columns[0][0]; + frame_params.colliders[0].transform[9] = revert.columns[0][1]; frame_params.colliders[0].transform[10] = 0; - frame_params.colliders[0].transform[11] = revert.elements[2][0]; + frame_params.colliders[0].transform[11] = revert.columns[2][0]; - frame_params.colliders[0].transform[12] = revert.elements[1][0]; - frame_params.colliders[0].transform[13] = revert.elements[1][1]; + frame_params.colliders[0].transform[12] = revert.columns[1][0]; + frame_params.colliders[0].transform[13] = revert.columns[1][1]; frame_params.colliders[0].transform[14] = 0; - frame_params.colliders[0].transform[15] = revert.elements[2][1]; + frame_params.colliders[0].transform[15] = revert.columns[2][1]; frame_params.colliders[0].extents[0] = p_particles->sdf_collision_to_screen.size.x; frame_params.colliders[0].extents[1] = p_particles->sdf_collision_to_screen.size.y; diff --git a/servers/rendering/renderer_scene_cull.cpp b/servers/rendering/renderer_scene_cull.cpp index 528f381139..885b37d462 100644 --- a/servers/rendering/renderer_scene_cull.cpp +++ b/servers/rendering/renderer_scene_cull.cpp @@ -860,7 +860,7 @@ void RendererSceneCull::instance_set_transform(RID p_instance, const Transform3D #ifdef DEBUG_ENABLED for (int i = 0; i < 4; i++) { - const Vector3 &v = i < 3 ? p_transform.basis.elements[i] : p_transform.origin; + const Vector3 &v = i < 3 ? p_transform.basis.rows[i] : p_transform.origin; ERR_FAIL_COND(Math::is_inf(v.x)); ERR_FAIL_COND(Math::is_nan(v.x)); ERR_FAIL_COND(Math::is_inf(v.y)); diff --git a/servers/rendering/renderer_viewport.cpp b/servers/rendering/renderer_viewport.cpp index 99e8d22b75..7e18eac6ae 100644 --- a/servers/rendering/renderer_viewport.cpp +++ b/servers/rendering/renderer_viewport.cpp @@ -43,7 +43,7 @@ static Transform2D _canvas_get_transform(RendererViewport::Viewport *p_viewport, if (p_viewport->canvas_map.has(p_canvas->parent)) { Transform2D c_xform = p_viewport->canvas_map[p_canvas->parent].transform; if (p_viewport->snap_2d_transforms_to_pixel) { - c_xform.elements[2] = c_xform.elements[2].floor(); + c_xform.columns[2] = c_xform.columns[2].floor(); } xf = xf * c_xform; scale = p_canvas->parent_scale; @@ -52,7 +52,7 @@ static Transform2D _canvas_get_transform(RendererViewport::Viewport *p_viewport, Transform2D c_xform = p_canvas_data->transform; if (p_viewport->snap_2d_transforms_to_pixel) { - c_xform.elements[2] = c_xform.elements[2].floor(); + c_xform.columns[2] = c_xform.columns[2].floor(); } xf = xf * c_xform; @@ -301,7 +301,7 @@ void RendererViewport::_draw_viewport(Viewport *p_viewport) { // cl->texture_cache = nullptr; Transform2D scale; scale.scale(cl->rect_cache.size); - scale.elements[2] = cl->rect_cache.position; + scale.columns[2] = cl->rect_cache.position; cl->light_shader_xform = cl->xform * scale; //cl->light_shader_pos = cl->xform_cache[2]; if (cl->use_shadow) { @@ -328,7 +328,7 @@ void RendererViewport::_draw_viewport(Viewport *p_viewport) { cl->filter_next_ptr = directional_lights; directional_lights = cl; cl->xform_cache = xf * cl->xform; - cl->xform_cache.elements[2] = Vector2(); //translation is pointless + cl->xform_cache.columns[2] = Vector2(); //translation is pointless if (cl->use_shadow) { cl->shadows_next_ptr = directional_lights_with_shadow; directional_lights_with_shadow = cl; @@ -386,7 +386,7 @@ void RendererViewport::_draw_viewport(Viewport *p_viewport) { //update shadows if any RendererCanvasRender::Light *light = directional_lights_with_shadow; while (light) { - Vector2 light_dir = -light->xform_cache.elements[1].normalized(); // Y is light direction + Vector2 light_dir = -light->xform_cache.columns[1].normalized(); // Y is light direction float cull_distance = light->directional_distance; Vector2 light_dir_sign; diff --git a/servers/xr_server.cpp b/servers/xr_server.cpp index e32b41c7ae..6e231237e4 100644 --- a/servers/xr_server.cpp +++ b/servers/xr_server.cpp @@ -131,7 +131,7 @@ void XRServer::center_on_hmd(RotationMode p_rotation_mode, bool p_keep_height) { // remove our tilt if (p_rotation_mode == 1) { // take the Y out of our Z - new_reference_frame.basis.set_axis(2, Vector3(new_reference_frame.basis.elements[0][2], 0.0, new_reference_frame.basis.elements[2][2]).normalized()); + new_reference_frame.basis.set_axis(2, Vector3(new_reference_frame.basis.rows[0][2], 0.0, new_reference_frame.basis.rows[2][2]).normalized()); // Y is straight up new_reference_frame.basis.set_axis(1, Vector3(0.0, 1.0, 0.0)); |