Rename Basis "elements" to "rows"

This commit is contained in:
Aaron Franke 2022-04-24 17:07:35 -05:00
parent b831fb0a54
commit 1bf94dff3a
No known key found for this signature in database
GPG Key ID: 40A1750B977E56BF
31 changed files with 679 additions and 679 deletions

View File

@ -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); ERR_FAIL_COND_V((size_t)len < sizeof(double) * 9, ERR_INVALID_DATA);
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) { 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); ERR_FAIL_COND_V((size_t)len < sizeof(float) * 9, ERR_INVALID_DATA);
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) { 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); ERR_FAIL_COND_V((size_t)len < sizeof(double) * 12, ERR_INVALID_DATA);
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) { 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]); 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); ERR_FAIL_COND_V((size_t)len < sizeof(float) * 12, ERR_INVALID_DATA);
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) { 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]); val.origin[0] = decode_float(&buf[sizeof(float) * 9]);
@ -1312,7 +1312,7 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
Basis val = p_variant; Basis val = p_variant;
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) { 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; Transform3D val = p_variant;
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) { 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));
} }
} }

View File

@ -277,29 +277,29 @@ Error ResourceLoaderBinary::parse_variant(Variant &r_v) {
} break; } break;
case VARIANT_BASIS: { case VARIANT_BASIS: {
Basis v; Basis v;
v.elements[0].x = f->get_real(); v.rows[0].x = f->get_real();
v.elements[0].y = f->get_real(); v.rows[0].y = f->get_real();
v.elements[0].z = f->get_real(); v.rows[0].z = f->get_real();
v.elements[1].x = f->get_real(); v.rows[1].x = f->get_real();
v.elements[1].y = f->get_real(); v.rows[1].y = f->get_real();
v.elements[1].z = f->get_real(); v.rows[1].z = f->get_real();
v.elements[2].x = f->get_real(); v.rows[2].x = f->get_real();
v.elements[2].y = f->get_real(); v.rows[2].y = f->get_real();
v.elements[2].z = f->get_real(); v.rows[2].z = f->get_real();
r_v = v; r_v = v;
} break; } break;
case VARIANT_TRANSFORM3D: { case VARIANT_TRANSFORM3D: {
Transform3D v; Transform3D v;
v.basis.elements[0].x = f->get_real(); v.basis.rows[0].x = f->get_real();
v.basis.elements[0].y = f->get_real(); v.basis.rows[0].y = f->get_real();
v.basis.elements[0].z = f->get_real(); v.basis.rows[0].z = f->get_real();
v.basis.elements[1].x = f->get_real(); v.basis.rows[1].x = f->get_real();
v.basis.elements[1].y = f->get_real(); v.basis.rows[1].y = f->get_real();
v.basis.elements[1].z = f->get_real(); v.basis.rows[1].z = f->get_real();
v.basis.elements[2].x = f->get_real(); v.basis.rows[2].x = f->get_real();
v.basis.elements[2].y = f->get_real(); v.basis.rows[2].y = f->get_real();
v.basis.elements[2].z = f->get_real(); v.basis.rows[2].z = f->get_real();
v.origin.x = f->get_real(); v.origin.x = f->get_real();
v.origin.y = f->get_real(); v.origin.y = f->get_real();
v.origin.z = f->get_real(); v.origin.z = f->get_real();
@ -1484,29 +1484,29 @@ void ResourceFormatSaverBinaryInstance::write_variant(Ref<FileAccess> f, const V
case Variant::BASIS: { case Variant::BASIS: {
f->store_32(VARIANT_BASIS); f->store_32(VARIANT_BASIS);
Basis val = p_property; Basis val = p_property;
f->store_real(val.elements[0].x); f->store_real(val.rows[0].x);
f->store_real(val.elements[0].y); f->store_real(val.rows[0].y);
f->store_real(val.elements[0].z); f->store_real(val.rows[0].z);
f->store_real(val.elements[1].x); f->store_real(val.rows[1].x);
f->store_real(val.elements[1].y); f->store_real(val.rows[1].y);
f->store_real(val.elements[1].z); f->store_real(val.rows[1].z);
f->store_real(val.elements[2].x); f->store_real(val.rows[2].x);
f->store_real(val.elements[2].y); f->store_real(val.rows[2].y);
f->store_real(val.elements[2].z); f->store_real(val.rows[2].z);
} break; } break;
case Variant::TRANSFORM3D: { case Variant::TRANSFORM3D: {
f->store_32(VARIANT_TRANSFORM3D); f->store_32(VARIANT_TRANSFORM3D);
Transform3D val = p_property; Transform3D val = p_property;
f->store_real(val.basis.elements[0].x); f->store_real(val.basis.rows[0].x);
f->store_real(val.basis.elements[0].y); f->store_real(val.basis.rows[0].y);
f->store_real(val.basis.elements[0].z); f->store_real(val.basis.rows[0].z);
f->store_real(val.basis.elements[1].x); f->store_real(val.basis.rows[1].x);
f->store_real(val.basis.elements[1].y); f->store_real(val.basis.rows[1].y);
f->store_real(val.basis.elements[1].z); f->store_real(val.basis.rows[1].z);
f->store_real(val.basis.elements[2].x); f->store_real(val.basis.rows[2].x);
f->store_real(val.basis.elements[2].y); f->store_real(val.basis.rows[2].y);
f->store_real(val.basis.elements[2].z); f->store_real(val.basis.rows[2].z);
f->store_real(val.origin.x); f->store_real(val.origin.x);
f->store_real(val.origin.y); f->store_real(val.origin.y);
f->store_real(val.origin.z); f->store_real(val.origin.z);

View File

@ -34,32 +34,32 @@
#include "core/string/print_string.h" #include "core/string/print_string.h"
#define cofac(row1, col1, row2, col2) \ #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) { void Basis::from_z(const Vector3 &p_z) {
if (Math::abs(p_z.z) > (real_t)Math_SQRT12) { if (Math::abs(p_z.z) > (real_t)Math_SQRT12) {
// choose p in y-z plane // choose p in y-z plane
real_t a = p_z[1] * p_z[1] + p_z[2] * p_z[2]; real_t a = p_z[1] * p_z[1] + p_z[2] * p_z[2];
real_t k = 1.0f / Math::sqrt(a); real_t k = 1.0f / Math::sqrt(a);
elements[0] = Vector3(0, -p_z[2] * k, p_z[1] * k); rows[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[1] = Vector3(a * k, -p_z[0] * rows[0][2], p_z[0] * rows[0][1]);
} else { } else {
// choose p in x-y plane // choose p in x-y plane
real_t a = p_z.x * p_z.x + p_z.y * p_z.y; real_t a = p_z.x * p_z.x + p_z.y * p_z.y;
real_t k = 1.0f / Math::sqrt(a); real_t k = 1.0f / Math::sqrt(a);
elements[0] = Vector3(-p_z.y * k, p_z.x * k, 0); rows[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[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() { void Basis::invert() {
real_t co[3] = { real_t co[3] = {
cofac(1, 1, 2, 2), cofac(1, 2, 2, 0), cofac(1, 0, 2, 1) cofac(1, 1, 2, 2), cofac(1, 2, 2, 0), cofac(1, 0, 2, 1)
}; };
real_t det = elements[0][0] * co[0] + real_t det = rows[0][0] * co[0] +
elements[0][1] * co[1] + rows[0][1] * co[1] +
elements[0][2] * co[2]; rows[0][2] * co[2];
#ifdef MATH_CHECKS #ifdef MATH_CHECKS
ERR_FAIL_COND(det == 0); ERR_FAIL_COND(det == 0);
#endif #endif
@ -115,9 +115,9 @@ bool Basis::is_orthogonal() const {
bool Basis::is_diagonal() const { bool Basis::is_diagonal() const {
return ( return (
Math::is_zero_approx(elements[0][1]) && Math::is_zero_approx(elements[0][2]) && Math::is_zero_approx(rows[0][1]) && Math::is_zero_approx(rows[0][2]) &&
Math::is_zero_approx(elements[1][0]) && Math::is_zero_approx(elements[1][2]) && Math::is_zero_approx(rows[1][0]) && Math::is_zero_approx(rows[1][2]) &&
Math::is_zero_approx(elements[2][0]) && Math::is_zero_approx(elements[2][1])); Math::is_zero_approx(rows[2][0]) && Math::is_zero_approx(rows[2][1]));
} }
bool Basis::is_rotation() const { bool Basis::is_rotation() const {
@ -127,13 +127,13 @@ bool Basis::is_rotation() const {
#ifdef MATH_CHECKS #ifdef MATH_CHECKS
// This method is only used once, in diagonalize. If it's desired elsewhere, feel free to remove the #ifdef. // This method is only used once, in diagonalize. If it's desired elsewhere, feel free to remove the #ifdef.
bool Basis::is_symmetric() const { 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; 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; 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; return false;
} }
@ -149,14 +149,14 @@ Basis Basis::diagonalize() {
#endif #endif
const int ite_max = 1024; 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; int ite = 0;
Basis acc_rot; Basis acc_rot;
while (off_matrix_norm_2 > (real_t)CMP_EPSILON2 && ite++ < ite_max) { while (off_matrix_norm_2 > (real_t)CMP_EPSILON2 && ite++ < ite_max) {
real_t el01_2 = elements[0][1] * elements[0][1]; real_t el01_2 = rows[0][1] * rows[0][1];
real_t el02_2 = elements[0][2] * elements[0][2]; real_t el02_2 = rows[0][2] * rows[0][2];
real_t el12_2 = elements[1][2] * elements[1][2]; real_t el12_2 = rows[1][2] * rows[1][2];
// Find the pivot element // Find the pivot element
int i, j; int i, j;
if (el01_2 > el02_2) { if (el01_2 > el02_2) {
@ -179,19 +179,19 @@ Basis Basis::diagonalize() {
// Compute the rotation angle // Compute the rotation angle
real_t 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; angle = Math_PI / 4;
} else { } 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 // Compute the rotation matrix
Basis rot; Basis rot;
rot.elements[i][i] = rot.elements[j][j] = Math::cos(angle); rot.rows[i][i] = rot.rows[j][j] = Math::cos(angle);
rot.elements[i][j] = -(rot.elements[j][i] = Math::sin(angle)); rot.rows[i][j] = -(rot.rows[j][i] = Math::sin(angle));
// Update the off matrix norm // 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 // Apply the rotation
*this = rot * *this * rot.transposed(); *this = rot * *this * rot.transposed();
@ -208,9 +208,9 @@ Basis Basis::inverse() const {
} }
void Basis::transpose() { void Basis::transpose() {
SWAP(elements[0][1], elements[1][0]); SWAP(rows[0][1], rows[1][0]);
SWAP(elements[0][2], elements[2][0]); SWAP(rows[0][2], rows[2][0]);
SWAP(elements[1][2], elements[2][1]); SWAP(rows[1][2], rows[2][1]);
} }
Basis Basis::transposed() const { 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 // Multiplies the matrix from left by the scaling matrix: M -> S.M
// See the comment for Basis::rotated for further explanation. // See the comment for Basis::rotated for further explanation.
void Basis::scale(const Vector3 &p_scale) { void Basis::scale(const Vector3 &p_scale) {
elements[0][0] *= p_scale.x; rows[0][0] *= p_scale.x;
elements[0][1] *= p_scale.x; rows[0][1] *= p_scale.x;
elements[0][2] *= p_scale.x; rows[0][2] *= p_scale.x;
elements[1][0] *= p_scale.y; rows[1][0] *= p_scale.y;
elements[1][1] *= p_scale.y; rows[1][1] *= p_scale.y;
elements[1][2] *= p_scale.y; rows[1][2] *= p_scale.y;
elements[2][0] *= p_scale.z; rows[2][0] *= p_scale.z;
elements[2][1] *= p_scale.z; rows[2][1] *= p_scale.z;
elements[2][2] *= p_scale.z; rows[2][2] *= p_scale.z;
} }
Basis Basis::scaled(const Vector3 &p_scale) const { 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 { 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() { 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++) { for (int i = 0; i < 3; i++) {
elements[i].normalize(); rows[i].normalize();
elements[i] *= l; rows[i] *= l;
} }
} }
@ -285,14 +285,14 @@ Basis Basis::scaled_local(const Vector3 &p_scale) const {
Vector3 Basis::get_scale_abs() const { Vector3 Basis::get_scale_abs() const {
return Vector3( return Vector3(
Vector3(elements[0][0], elements[1][0], elements[2][0]).length(), Vector3(rows[0][0], rows[1][0], rows[2][0]).length(),
Vector3(elements[0][1], elements[1][1], elements[2][1]).length(), Vector3(rows[0][1], rows[1][1], rows[2][1]).length(),
Vector3(elements[0][2], elements[1][2], elements[2][2]).length()); Vector3(rows[0][2], rows[1][2], rows[2][2]).length());
} }
Vector3 Basis::get_scale_local() const { Vector3 Basis::get_scale_local() const {
real_t det_sign = SIGN(determinant()); 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. // 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 // -cx*cz*sy+sx*sz cz*sx+cx*sy*sz cx*cy
Vector3 euler; 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)) {
if (sy > -(1.0f - (real_t)CMP_EPSILON)) { if (sy > -(1.0f - (real_t)CMP_EPSILON)) {
// is this a pure Y rotation? // 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) // return the simplest form (human friendlier in editor and scripts)
euler.x = 0; euler.x = 0;
euler.y = atan2(elements[0][2], elements[0][0]); euler.y = atan2(rows[0][2], rows[0][0]);
euler.z = 0; euler.z = 0;
} else { } 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.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 { } 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.y = -Math_PI / 2.0f;
euler.z = 0.0f; euler.z = 0.0f;
} }
} else { } 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.y = Math_PI / 2.0f;
euler.z = 0.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 // cy*sx*sz cz*sx cx*cy+sx*sz*sy
Vector3 euler; 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)) {
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.x = Math::atan2(rows[2][1], rows[1][1]);
euler.y = Math::atan2(elements[0][2], elements[0][0]); euler.y = Math::atan2(rows[0][2], rows[0][0]);
euler.z = Math::asin(-sz); euler.z = Math::asin(-sz);
} else { } else {
// It's -1 // 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.y = 0.0f;
euler.z = Math_PI / 2.0f; euler.z = Math_PI / 2.0f;
} }
} else { } else {
// It's 1 // 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.y = 0.0f;
euler.z = -Math_PI / 2.0f; euler.z = -Math_PI / 2.0f;
} }
@ -527,29 +527,29 @@ Vector3 Basis::get_euler(EulerOrder p_order) const {
Vector3 euler; 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)) {
if (m12 > -(1 - (real_t)CMP_EPSILON)) { if (m12 > -(1 - (real_t)CMP_EPSILON)) {
// is this a pure X rotation? // 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) // 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.y = 0;
euler.z = 0; euler.z = 0;
} else { } else {
euler.x = asin(-m12); euler.x = asin(-m12);
euler.y = atan2(elements[0][2], elements[2][2]); euler.y = atan2(rows[0][2], rows[2][2]);
euler.z = atan2(elements[1][0], elements[1][1]); euler.z = atan2(rows[1][0], rows[1][1]);
} }
} else { // m12 == -1 } else { // m12 == -1
euler.x = Math_PI * 0.5f; 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; euler.z = 0;
} }
} else { // m12 == 1 } else { // m12 == 1
euler.x = -Math_PI * 0.5f; 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; 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 // -cz*sy cy*sx+cx*sy*sz cy*cx-sy*sz*sx
Vector3 euler; 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)) {
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.x = Math::atan2(-rows[1][2], rows[1][1]);
euler.y = Math::atan2(-elements[2][0], elements[0][0]); euler.y = Math::atan2(-rows[2][0], rows[0][0]);
euler.z = Math::asin(sz); euler.z = Math::asin(sz);
} else { } else {
// It's -1 // 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.y = 0.0f;
euler.z = -Math_PI / 2.0f; euler.z = -Math_PI / 2.0f;
} }
} else { } else {
// It's 1 // 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.y = 0.0f;
euler.z = Math_PI / 2.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 // cy*sz+cz*sx*sy cz*cx sz*sy-cz*cy*sx
// -cx*sy sx cx*cy // -cx*sy sx cx*cy
Vector3 euler; 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)) {
if (sx > -(1.0f - (real_t)CMP_EPSILON)) { if (sx > -(1.0f - (real_t)CMP_EPSILON)) {
euler.x = Math::asin(sx); euler.x = Math::asin(sx);
euler.y = Math::atan2(-elements[2][0], elements[2][2]); euler.y = Math::atan2(-rows[2][0], rows[2][2]);
euler.z = Math::atan2(-elements[0][1], elements[1][1]); euler.z = Math::atan2(-rows[0][1], rows[1][1]);
} else { } else {
// It's -1 // It's -1
euler.x = -Math_PI / 2.0f; 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; euler.z = 0;
} }
} else { } else {
// It's 1 // It's 1
euler.x = Math_PI / 2.0f; 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; euler.z = 0;
} }
return euler; 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 // cy*sz cz*cx+sz*sy*sx cx*sz*sy-cz*sx
// -sy cy*sx cy*cx // -sy cy*sx cy*cx
Vector3 euler; 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)) {
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.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 { } else {
// It's -1 // It's -1
euler.x = 0; euler.x = 0;
euler.y = Math_PI / 2.0f; 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 { } else {
// It's 1 // It's 1
euler.x = 0; euler.x = 0;
euler.y = -Math_PI / 2.0f; 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; return euler;
} break; } 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 { 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 { bool Basis::operator==(const Basis &p_matrix) const {
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) { 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; return false;
} }
} }
@ -719,7 +719,7 @@ Quaternion Basis::get_quaternion() const {
#endif #endif
/* Allow getting a quaternion from an unnormalized transform */ /* Allow getting a quaternion from an unnormalized transform */
Basis m = *this; 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]; real_t temp[4];
if (trace > 0.0f) { if (trace > 0.0f) {
@ -727,23 +727,23 @@ Quaternion Basis::get_quaternion() const {
temp[3] = (s * 0.5f); temp[3] = (s * 0.5f);
s = 0.5f / s; s = 0.5f / s;
temp[0] = ((m.elements[2][1] - m.elements[1][2]) * s); temp[0] = ((m.rows[2][1] - m.rows[1][2]) * s);
temp[1] = ((m.elements[0][2] - m.elements[2][0]) * s); temp[1] = ((m.rows[0][2] - m.rows[2][0]) * s);
temp[2] = ((m.elements[1][0] - m.elements[0][1]) * s); temp[2] = ((m.rows[1][0] - m.rows[0][1]) * s);
} else { } else {
int i = m.elements[0][0] < m.elements[1][1] int i = m.rows[0][0] < m.rows[1][1]
? (m.elements[1][1] < m.elements[2][2] ? 2 : 1) ? (m.rows[1][1] < m.rows[2][2] ? 2 : 1)
: (m.elements[0][0] < m.elements[2][2] ? 2 : 0); : (m.rows[0][0] < m.rows[2][2] ? 2 : 0);
int j = (i + 1) % 3; int j = (i + 1) % 3;
int k = (i + 2) % 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; temp[i] = s * 0.5f;
s = 0.5f / s; s = 0.5f / s;
temp[3] = (m.elements[k][j] - m.elements[j][k]) * s; temp[3] = (m.rows[k][j] - m.rows[j][k]) * s;
temp[j] = (m.elements[j][i] + m.elements[i][j]) * s; temp[j] = (m.rows[j][i] + m.rows[i][j]) * s;
temp[k] = (m.elements[k][i] + m.elements[i][k]) * s; temp[k] = (m.rows[k][i] + m.rows[i][k]) * s;
} }
return Quaternion(temp[0], temp[1], temp[2], temp[3]); 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 epsilon = 0.01; // margin to allow for rounding errors
real_t epsilon2 = 0.1; // margin to distinguish between 0 and 180 degrees 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 // singularity found
// first check for identity matrix which must have +1 for all terms // first check for identity matrix which must have +1 for all terms
// in leading diagonal and zero in other 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 // this singularity is identity matrix so angle = 0
r_axis = Vector3(0, 1, 0); r_axis = Vector3(0, 1, 0);
r_angle = 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 // otherwise this singularity is angle = 180
angle = Math_PI; angle = Math_PI;
real_t xx = (elements[0][0] + 1) / 2; real_t xx = (rows[0][0] + 1) / 2;
real_t yy = (elements[1][1] + 1) / 2; real_t yy = (rows[1][1] + 1) / 2;
real_t zz = (elements[2][2] + 1) / 2; real_t zz = (rows[2][2] + 1) / 2;
real_t xy = (elements[1][0] + elements[0][1]) / 4; real_t xy = (rows[1][0] + rows[0][1]) / 4;
real_t xz = (elements[2][0] + elements[0][2]) / 4; real_t xz = (rows[2][0] + rows[0][2]) / 4;
real_t yz = (elements[2][1] + elements[1][2]) / 4; real_t yz = (rows[2][1] + rows[1][2]) / 4;
if ((xx > yy) && (xx > zz)) { // elements[0][0] is the largest diagonal term if ((xx > yy) && (xx > zz)) { // rows[0][0] is the largest diagonal term
if (xx < epsilon) { if (xx < epsilon) {
x = 0; x = 0;
y = Math_SQRT12; y = Math_SQRT12;
@ -848,7 +848,7 @@ void Basis::get_axis_angle(Vector3 &r_axis, real_t &r_angle) const {
y = xy / x; y = xy / x;
z = xz / 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) { if (yy < epsilon) {
x = Math_SQRT12; x = Math_SQRT12;
y = 0; y = 0;
@ -858,7 +858,7 @@ void Basis::get_axis_angle(Vector3 &r_axis, real_t &r_angle) const {
x = xy / y; x = xy / y;
z = yz / 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) { if (zz < epsilon) {
x = Math_SQRT12; x = Math_SQRT12;
y = Math_SQRT12; y = Math_SQRT12;
@ -874,15 +874,15 @@ void Basis::get_axis_angle(Vector3 &r_axis, real_t &r_angle) const {
return; return;
} }
// as we have reached here there are no singularities so we can handle normally // 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) { if (angle < 0) {
s = -s; s = -s;
} }
x = (elements[2][1] - elements[1][2]) / s; x = (rows[2][1] - rows[1][2]) / s;
y = (elements[0][2] - elements[2][0]) / s; y = (rows[0][2] - rows[2][0]) / s;
z = (elements[1][0] - elements[0][1]) / s; z = (rows[1][0] - rows[0][1]) / s;
r_axis = Vector3(x, y, z); r_axis = Vector3(x, y, z);
r_angle = angle; r_angle = angle;
@ -907,27 +907,27 @@ void Basis::set_axis_angle(const Vector3 &p_axis, real_t p_phi) {
#endif #endif
Vector3 axis_sq(p_axis.x * p_axis.x, p_axis.y * p_axis.y, p_axis.z * p_axis.z); 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); real_t cosine = Math::cos(p_phi);
elements[0][0] = axis_sq.x + cosine * (1.0f - axis_sq.x); rows[0][0] = axis_sq.x + cosine * (1.0f - axis_sq.x);
elements[1][1] = axis_sq.y + cosine * (1.0f - axis_sq.y); rows[1][1] = axis_sq.y + cosine * (1.0f - axis_sq.y);
elements[2][2] = axis_sq.z + cosine * (1.0f - axis_sq.z); rows[2][2] = axis_sq.z + cosine * (1.0f - axis_sq.z);
real_t sine = Math::sin(p_phi); real_t sine = Math::sin(p_phi);
real_t t = 1 - cosine; real_t t = 1 - cosine;
real_t xyzt = p_axis.x * p_axis.y * t; real_t xyzt = p_axis.x * p_axis.y * t;
real_t zyxs = p_axis.z * sine; real_t zyxs = p_axis.z * sine;
elements[0][1] = xyzt - zyxs; rows[0][1] = xyzt - zyxs;
elements[1][0] = xyzt + zyxs; rows[1][0] = xyzt + zyxs;
xyzt = p_axis.x * p_axis.z * t; xyzt = p_axis.x * p_axis.z * t;
zyxs = p_axis.y * sine; zyxs = p_axis.y * sine;
elements[0][2] = xyzt + zyxs; rows[0][2] = xyzt + zyxs;
elements[2][0] = xyzt - zyxs; rows[2][0] = xyzt - zyxs;
xyzt = p_axis.y * p_axis.z * t; xyzt = p_axis.y * p_axis.z * t;
zyxs = p_axis.x * sine; zyxs = p_axis.x * sine;
elements[1][2] = xyzt - zyxs; rows[1][2] = xyzt - zyxs;
elements[2][1] = 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) { 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 // 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. // name, so we want this method to be private. Use `from_scale` externally.
void Basis::_set_diagonal(const Vector3 &p_diag) { void Basis::_set_diagonal(const Vector3 &p_diag) {
elements[0][0] = p_diag.x; rows[0][0] = p_diag.x;
elements[0][1] = 0; rows[0][1] = 0;
elements[0][2] = 0; rows[0][2] = 0;
elements[1][0] = 0; rows[1][0] = 0;
elements[1][1] = p_diag.y; rows[1][1] = p_diag.y;
elements[1][2] = 0; rows[1][2] = 0;
elements[2][0] = 0; rows[2][0] = 0;
elements[2][1] = 0; rows[2][1] = 0;
elements[2][2] = p_diag.z; rows[2][2] = p_diag.z;
} }
Basis Basis::lerp(const Basis &p_to, const real_t &p_weight) const { Basis Basis::lerp(const Basis &p_to, const real_t &p_weight) const {
Basis b; Basis b;
b.elements[0] = elements[0].lerp(p_to.elements[0], p_weight); b.rows[0] = rows[0].lerp(p_to.rows[0], p_weight);
b.elements[1] = elements[1].lerp(p_to.elements[1], p_weight); b.rows[1] = rows[1].lerp(p_to.rows[1], p_weight);
b.elements[2] = elements[2].lerp(p_to.elements[2], p_weight); b.rows[2] = rows[2].lerp(p_to.rows[2], p_weight);
return b; return b;
} }
@ -976,9 +976,9 @@ Basis Basis::slerp(const Basis &p_to, const real_t &p_weight) const {
Quaternion to(p_to); Quaternion to(p_to);
Basis b(from.slerp(to, p_weight)); Basis b(from.slerp(to, p_weight));
b.elements[0] *= Math::lerp(elements[0].length(), p_to.elements[0].length(), p_weight); b.rows[0] *= Math::lerp(rows[0].length(), p_to.rows[0].length(), p_weight);
b.elements[1] *= Math::lerp(elements[1].length(), p_to.elements[1].length(), p_weight); b.rows[1] *= Math::lerp(rows[1].length(), p_to.rows[1].length(), p_weight);
b.elements[2] *= Math::lerp(elements[2].length(), p_to.elements[2].length(), p_weight); b.rows[2] *= Math::lerp(rows[2].length(), p_to.rows[2].length(), p_weight);
return b; 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] }; 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 m00 = rows[0][0];
real_t m01 = elements[0][1]; real_t m01 = rows[0][1];
real_t m02 = elements[0][2]; real_t m02 = rows[0][2];
real_t m10 = elements[1][0]; real_t m10 = rows[1][0];
real_t m11 = elements[1][1]; real_t m11 = rows[1][1];
real_t m12 = elements[1][2]; real_t m12 = rows[1][2];
real_t m20 = elements[2][0]; real_t m20 = rows[2][0];
real_t m21 = elements[2][1]; real_t m21 = rows[2][1];
real_t m22 = elements[2][2]; real_t m22 = rows[2][2];
p_values[0] = src[0]; p_values[0] = src[0];
p_values[1] = m11 * src[1] - m12 * src[2] + m10 * src[3]; p_values[1] = m11 * src[1] - m12 * src[2] + m10 * src[3];

View File

@ -35,17 +35,17 @@
#include "core/math/vector3.h" #include "core/math/vector3.h"
struct _NO_DISCARD_ Basis { struct _NO_DISCARD_ Basis {
Vector3 elements[3] = { Vector3 rows[3] = {
Vector3(1, 0, 0), Vector3(1, 0, 0),
Vector3(0, 1, 0), Vector3(0, 1, 0),
Vector3(0, 0, 1) Vector3(0, 0, 1)
}; };
_FORCE_INLINE_ const Vector3 &operator[](int axis) const { _FORCE_INLINE_ const Vector3 &operator[](int axis) const {
return elements[axis]; return rows[axis];
} }
_FORCE_INLINE_ Vector3 &operator[](int axis) { _FORCE_INLINE_ Vector3 &operator[](int axis) {
return elements[axis]; return rows[axis];
} }
void invert(); void invert();
@ -59,14 +59,14 @@ struct _NO_DISCARD_ Basis {
void from_z(const Vector3 &p_z); void from_z(const Vector3 &p_z);
_FORCE_INLINE_ Vector3 get_axis(int p_axis) const { _FORCE_INLINE_ Vector3 get_axis(int p_axis) const {
// get actual basis axis (elements is transposed for performance) // get actual basis axis column (we store transposed as rows for performance)
return Vector3(elements[0][p_axis], elements[1][p_axis], elements[2][p_axis]); 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) { _FORCE_INLINE_ void set_axis(int p_axis, const Vector3 &p_value) {
// get actual basis axis (elements is transposed for performance) // get actual basis axis column (we store transposed as rows for performance)
elements[0][p_axis] = p_value.x; rows[0][p_axis] = p_value.x;
elements[1][p_axis] = p_value.y; rows[1][p_axis] = p_value.y;
elements[2][p_axis] = p_value.z; rows[2][p_axis] = p_value.z;
} }
void rotate(const Vector3 &p_axis, real_t p_phi); void rotate(const Vector3 &p_axis, real_t p_phi);
@ -135,13 +135,13 @@ struct _NO_DISCARD_ Basis {
// transposed dot products // transposed dot products
_FORCE_INLINE_ real_t tdotx(const Vector3 &v) const { _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 { _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 { _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; bool is_equal_approx(const Basis &p_basis) const;
@ -176,15 +176,15 @@ struct _NO_DISCARD_ Basis {
/* create / set */ /* 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) { _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; rows[0][0] = xx;
elements[0][1] = xy; rows[0][1] = xy;
elements[0][2] = xz; rows[0][2] = xz;
elements[1][0] = yx; rows[1][0] = yx;
elements[1][1] = yy; rows[1][1] = yy;
elements[1][2] = yz; rows[1][2] = yz;
elements[2][0] = zx; rows[2][0] = zx;
elements[2][1] = zy; rows[2][1] = zy;
elements[2][2] = zz; rows[2][2] = zz;
} }
_FORCE_INLINE_ void set(const Vector3 &p_x, const Vector3 &p_y, const Vector3 &p_z) { _FORCE_INLINE_ void set(const Vector3 &p_x, const Vector3 &p_y, const Vector3 &p_z) {
set_axis(0, p_x); set_axis(0, p_x);
@ -192,39 +192,39 @@ struct _NO_DISCARD_ Basis {
set_axis(2, p_z); set_axis(2, p_z);
} }
_FORCE_INLINE_ Vector3 get_column(int i) const { _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 { _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 { _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) { _FORCE_INLINE_ void set_row(int i, const Vector3 &p_row) {
elements[i][0] = p_row.x; rows[i][0] = p_row.x;
elements[i][1] = p_row.y; rows[i][1] = p_row.y;
elements[i][2] = p_row.z; rows[i][2] = p_row.z;
} }
_FORCE_INLINE_ void set_zero() { _FORCE_INLINE_ void set_zero() {
elements[0].zero(); rows[0].zero();
elements[1].zero(); rows[1].zero();
elements[2].zero(); rows[2].zero();
} }
_FORCE_INLINE_ Basis transpose_xform(const Basis &m) const { _FORCE_INLINE_ Basis transpose_xform(const Basis &m) const {
return Basis( return Basis(
elements[0].x * m[0].x + elements[1].x * m[1].x + elements[2].x * m[2].x, rows[0].x * m[0].x + rows[1].x * m[1].x + rows[2].x * m[2].x,
elements[0].x * m[0].y + elements[1].x * m[1].y + elements[2].x * m[2].y, rows[0].x * m[0].y + rows[1].x * m[1].y + rows[2].x * m[2].y,
elements[0].x * m[0].z + elements[1].x * m[1].z + elements[2].x * m[2].z, rows[0].x * m[0].z + rows[1].x * m[1].z + rows[2].x * m[2].z,
elements[0].y * m[0].x + elements[1].y * m[1].x + elements[2].y * m[2].x, rows[0].y * m[0].x + rows[1].y * m[1].x + rows[2].y * m[2].x,
elements[0].y * m[0].y + elements[1].y * m[1].y + elements[2].y * m[2].y, rows[0].y * m[0].y + rows[1].y * m[1].y + rows[2].y * m[2].y,
elements[0].y * m[0].z + elements[1].y * m[1].z + elements[2].y * m[2].z, rows[0].y * m[0].z + rows[1].y * m[1].z + rows[2].y * m[2].z,
elements[0].z * m[0].x + elements[1].z * m[1].x + elements[2].z * m[2].x, rows[0].z * m[0].x + rows[1].z * m[1].x + rows[2].z * m[2].x,
elements[0].z * m[0].y + elements[1].z * m[1].y + elements[2].z * m[2].y, rows[0].z * m[0].y + rows[1].z * m[1].y + rows[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].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) { 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); 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); static Basis from_scale(const Vector3 &p_scale);
_FORCE_INLINE_ Basis(const Vector3 &row0, const Vector3 &row1, const Vector3 &row2) { _FORCE_INLINE_ Basis(const Vector3 &row0, const Vector3 &row1, const Vector3 &row2) {
elements[0] = row0; rows[0] = row0;
elements[1] = row1; rows[1] = row1;
elements[2] = row2; rows[2] = row2;
} }
_FORCE_INLINE_ Basis() {} _FORCE_INLINE_ Basis() {}
@ -267,22 +267,22 @@ private:
_FORCE_INLINE_ void Basis::operator*=(const Basis &p_matrix) { _FORCE_INLINE_ void Basis::operator*=(const Basis &p_matrix) {
set( set(
p_matrix.tdotx(elements[0]), p_matrix.tdoty(elements[0]), p_matrix.tdotz(elements[0]), p_matrix.tdotx(rows[0]), p_matrix.tdoty(rows[0]), p_matrix.tdotz(rows[0]),
p_matrix.tdotx(elements[1]), p_matrix.tdoty(elements[1]), p_matrix.tdotz(elements[1]), p_matrix.tdotx(rows[1]), p_matrix.tdoty(rows[1]), p_matrix.tdotz(rows[1]),
p_matrix.tdotx(elements[2]), p_matrix.tdoty(elements[2]), p_matrix.tdotz(elements[2])); 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 { _FORCE_INLINE_ Basis Basis::operator*(const Basis &p_matrix) const {
return Basis( return Basis(
p_matrix.tdotx(elements[0]), p_matrix.tdoty(elements[0]), p_matrix.tdotz(elements[0]), p_matrix.tdotx(rows[0]), p_matrix.tdoty(rows[0]), p_matrix.tdotz(rows[0]),
p_matrix.tdotx(elements[1]), p_matrix.tdoty(elements[1]), p_matrix.tdotz(elements[1]), p_matrix.tdotx(rows[1]), p_matrix.tdoty(rows[1]), p_matrix.tdotz(rows[1]),
p_matrix.tdotx(elements[2]), p_matrix.tdoty(elements[2]), p_matrix.tdotz(elements[2])); p_matrix.tdotx(rows[2]), p_matrix.tdoty(rows[2]), p_matrix.tdotz(rows[2]));
} }
_FORCE_INLINE_ void Basis::operator+=(const Basis &p_matrix) { _FORCE_INLINE_ void Basis::operator+=(const Basis &p_matrix) {
elements[0] += p_matrix.elements[0]; rows[0] += p_matrix.rows[0];
elements[1] += p_matrix.elements[1]; rows[1] += p_matrix.rows[1];
elements[2] += p_matrix.elements[2]; rows[2] += p_matrix.rows[2];
} }
_FORCE_INLINE_ Basis Basis::operator+(const Basis &p_matrix) const { _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) { _FORCE_INLINE_ void Basis::operator-=(const Basis &p_matrix) {
elements[0] -= p_matrix.elements[0]; rows[0] -= p_matrix.rows[0];
elements[1] -= p_matrix.elements[1]; rows[1] -= p_matrix.rows[1];
elements[2] -= p_matrix.elements[2]; rows[2] -= p_matrix.rows[2];
} }
_FORCE_INLINE_ Basis Basis::operator-(const Basis &p_matrix) const { _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) { _FORCE_INLINE_ void Basis::operator*=(const real_t p_val) {
elements[0] *= p_val; rows[0] *= p_val;
elements[1] *= p_val; rows[1] *= p_val;
elements[2] *= p_val; rows[2] *= p_val;
} }
_FORCE_INLINE_ Basis Basis::operator*(const real_t p_val) const { _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 { Vector3 Basis::xform(const Vector3 &p_vector) const {
return Vector3( return Vector3(
elements[0].dot(p_vector), rows[0].dot(p_vector),
elements[1].dot(p_vector), rows[1].dot(p_vector),
elements[2].dot(p_vector)); rows[2].dot(p_vector));
} }
Vector3 Basis::xform_inv(const Vector3 &p_vector) const { Vector3 Basis::xform_inv(const Vector3 &p_vector) const {
return Vector3( return Vector3(
(elements[0][0] * p_vector.x) + (elements[1][0] * p_vector.y) + (elements[2][0] * p_vector.z), (rows[0][0] * p_vector.x) + (rows[1][0] * p_vector.y) + (rows[2][0] * p_vector.z),
(elements[0][1] * p_vector.x) + (elements[1][1] * p_vector.y) + (elements[2][1] * p_vector.z), (rows[0][1] * p_vector.x) + (rows[1][1] * p_vector.y) + (rows[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][2] * p_vector.x) + (rows[1][2] * p_vector.y) + (rows[2][2] * p_vector.z));
} }
real_t Basis::determinant() const { real_t Basis::determinant() const {
return elements[0][0] * (elements[1][1] * elements[2][2] - elements[2][1] * elements[1][2]) - return rows[0][0] * (rows[1][1] * rows[2][2] - rows[2][1] * rows[1][2]) -
elements[1][0] * (elements[0][1] * elements[2][2] - elements[2][1] * elements[0][2]) + rows[1][0] * (rows[0][1] * rows[2][2] - rows[2][1] * rows[0][2]) +
elements[2][0] * (elements[0][1] * elements[1][2] - elements[1][1] * elements[0][2]); rows[2][0] * (rows[0][1] * rows[1][2] - rows[1][1] * rows[0][2]);
} }
#endif // BASIS_H #endif // BASIS_H

View File

@ -714,17 +714,17 @@ CameraMatrix::operator Transform3D() const {
Transform3D tr; Transform3D tr;
const real_t *m = &matrix[0][0]; const real_t *m = &matrix[0][0];
tr.basis.elements[0][0] = m[0]; tr.basis.rows[0][0] = m[0];
tr.basis.elements[1][0] = m[1]; tr.basis.rows[1][0] = m[1];
tr.basis.elements[2][0] = m[2]; tr.basis.rows[2][0] = m[2];
tr.basis.elements[0][1] = m[4]; tr.basis.rows[0][1] = m[4];
tr.basis.elements[1][1] = m[5]; tr.basis.rows[1][1] = m[5];
tr.basis.elements[2][1] = m[6]; tr.basis.rows[2][1] = m[6];
tr.basis.elements[0][2] = m[8]; tr.basis.rows[0][2] = m[8];
tr.basis.elements[1][2] = m[9]; tr.basis.rows[1][2] = m[9];
tr.basis.elements[2][2] = m[10]; tr.basis.rows[2][2] = m[10];
tr.origin.x = m[12]; tr.origin.x = m[12];
tr.origin.y = m[13]; tr.origin.y = m[13];
@ -737,17 +737,17 @@ CameraMatrix::CameraMatrix(const Transform3D &p_transform) {
const Transform3D &tr = p_transform; const Transform3D &tr = p_transform;
real_t *m = &matrix[0][0]; real_t *m = &matrix[0][0];
m[0] = tr.basis.elements[0][0]; m[0] = tr.basis.rows[0][0];
m[1] = tr.basis.elements[1][0]; m[1] = tr.basis.rows[1][0];
m[2] = tr.basis.elements[2][0]; m[2] = tr.basis.rows[2][0];
m[3] = 0.0; m[3] = 0.0;
m[4] = tr.basis.elements[0][1]; m[4] = tr.basis.rows[0][1];
m[5] = tr.basis.elements[1][1]; m[5] = tr.basis.rows[1][1];
m[6] = tr.basis.elements[2][1]; m[6] = tr.basis.rows[2][1];
m[7] = 0.0; m[7] = 0.0;
m[8] = tr.basis.elements[0][2]; m[8] = tr.basis.rows[0][2];
m[9] = tr.basis.elements[1][2]; m[9] = tr.basis.rows[1][2];
m[10] = tr.basis.elements[2][2]; m[10] = tr.basis.rows[2][2];
m[11] = 0.0; m[11] = 0.0;
m[12] = tr.origin.x; m[12] = tr.origin.x;
m[13] = tr.origin.y; m[13] = tr.origin.y;

View File

@ -128,15 +128,15 @@ Variant fieldwise_assign(const Variant &p_target, const Variant &p_source, const
case Variant::BASIS: { case Variant::BASIS: {
SETUP_TYPE(Basis) SETUP_TYPE(Basis)
/**/ TRY_TRANSFER_FIELD("xx", elements[0][0]) /**/ TRY_TRANSFER_FIELD("xx", rows[0][0])
else TRY_TRANSFER_FIELD("xy", elements[0][1]) else TRY_TRANSFER_FIELD("xy", rows[0][1])
else TRY_TRANSFER_FIELD("xz", elements[0][2]) else TRY_TRANSFER_FIELD("xz", rows[0][2])
else TRY_TRANSFER_FIELD("yx", elements[1][0]) else TRY_TRANSFER_FIELD("yx", rows[1][0])
else TRY_TRANSFER_FIELD("yy", elements[1][1]) else TRY_TRANSFER_FIELD("yy", rows[1][1])
else TRY_TRANSFER_FIELD("yz", elements[1][2]) else TRY_TRANSFER_FIELD("yz", rows[1][2])
else TRY_TRANSFER_FIELD("zx", elements[2][0]) else TRY_TRANSFER_FIELD("zx", rows[2][0])
else TRY_TRANSFER_FIELD("zy", elements[2][1]) else TRY_TRANSFER_FIELD("zy", rows[2][1])
else TRY_TRANSFER_FIELD("zz", elements[2][2]) else TRY_TRANSFER_FIELD("zz", rows[2][2])
return target; return target;
} }
@ -144,15 +144,15 @@ Variant fieldwise_assign(const Variant &p_target, const Variant &p_source, const
case Variant::TRANSFORM3D: { case Variant::TRANSFORM3D: {
SETUP_TYPE(Transform3D) SETUP_TYPE(Transform3D)
/**/ TRY_TRANSFER_FIELD("xx", basis.elements[0][0]) /**/ TRY_TRANSFER_FIELD("xx", basis.rows[0][0])
else TRY_TRANSFER_FIELD("xy", basis.elements[0][1]) else TRY_TRANSFER_FIELD("xy", basis.rows[0][1])
else TRY_TRANSFER_FIELD("xz", basis.elements[0][2]) else TRY_TRANSFER_FIELD("xz", basis.rows[0][2])
else TRY_TRANSFER_FIELD("yx", basis.elements[1][0]) else TRY_TRANSFER_FIELD("yx", basis.rows[1][0])
else TRY_TRANSFER_FIELD("yy", basis.elements[1][1]) else TRY_TRANSFER_FIELD("yy", basis.rows[1][1])
else TRY_TRANSFER_FIELD("yz", basis.elements[1][2]) else TRY_TRANSFER_FIELD("yz", basis.rows[1][2])
else TRY_TRANSFER_FIELD("zx", basis.elements[2][0]) else TRY_TRANSFER_FIELD("zx", basis.rows[2][0])
else TRY_TRANSFER_FIELD("zy", basis.elements[2][1]) else TRY_TRANSFER_FIELD("zy", basis.rows[2][1])
else TRY_TRANSFER_FIELD("zz", basis.elements[2][2]) else TRY_TRANSFER_FIELD("zz", basis.rows[2][2])
else TRY_TRANSFER_FIELD("xo", origin.x) else TRY_TRANSFER_FIELD("xo", origin.x)
else TRY_TRANSFER_FIELD("yo", origin.y) else TRY_TRANSFER_FIELD("yo", origin.y)
else TRY_TRANSFER_FIELD("zo", origin.z) else TRY_TRANSFER_FIELD("zo", origin.z)

View File

@ -135,9 +135,9 @@ _FORCE_INLINE_ Vector3 Transform3D::xform_inv(const Vector3 &p_vector) const {
Vector3 v = p_vector - origin; Vector3 v = p_vector - origin;
return Vector3( return Vector3(
(basis.elements[0][0] * v.x) + (basis.elements[1][0] * v.y) + (basis.elements[2][0] * v.z), (basis.rows[0][0] * v.x) + (basis.rows[1][0] * v.y) + (basis.rows[2][0] * v.z),
(basis.elements[0][1] * v.x) + (basis.elements[1][1] * v.y) + (basis.elements[2][1] * v.z), (basis.rows[0][1] * v.x) + (basis.rows[1][1] * v.y) + (basis.rows[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][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, // Neither the plane regular xform or xform_inv are particularly efficient,

View File

@ -1908,10 +1908,10 @@ Variant::operator Transform3D() const {
} else if (type == TRANSFORM2D) { } else if (type == TRANSFORM2D) {
const Transform2D &t = *_data._transform2d; const Transform2D &t = *_data._transform2d;
Transform3D m; Transform3D m;
m.basis.elements[0][0] = t.columns[0][0]; m.basis.rows[0][0] = t.columns[0][0];
m.basis.elements[1][0] = t.columns[0][1]; m.basis.rows[1][0] = t.columns[0][1];
m.basis.elements[0][1] = t.columns[1][0]; m.basis.rows[0][1] = t.columns[1][0];
m.basis.elements[1][1] = t.columns[1][1]; m.basis.rows[1][1] = t.columns[1][1];
m.origin[0] = t.columns[2][0]; m.origin[0] = t.columns[2][0];
m.origin[1] = t.columns[2][1]; m.origin[1] = t.columns[2][1];
return m; return m;
@ -1926,10 +1926,10 @@ Variant::operator Transform2D() const {
} else if (type == TRANSFORM3D) { } else if (type == TRANSFORM3D) {
const Transform3D &t = *_data._transform3d; const Transform3D &t = *_data._transform3d;
Transform2D m; Transform2D m;
m.columns[0][0] = t.basis.elements[0][0]; m.columns[0][0] = t.basis.rows[0][0];
m.columns[0][1] = t.basis.elements[1][0]; m.columns[0][1] = t.basis.rows[1][0];
m.columns[1][0] = t.basis.elements[0][1]; m.columns[1][0] = t.basis.rows[0][1];
m.columns[1][1] = t.basis.elements[1][1]; m.columns[1][1] = t.basis.rows[1][1];
m.columns[2][0] = t.origin[0]; m.columns[2][0] = t.origin[0];
m.columns[2][1] = t.origin[1]; m.columns[2][1] = t.origin[1];
return m; return m;
@ -2834,7 +2834,7 @@ uint32_t Variant::recursive_hash(int recursion_count) const {
uint32_t hash = 5831; uint32_t hash = 5831;
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) { 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; uint32_t hash = 5831;
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) { 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); hash = hash_djb2_one_float(_data._transform3d->origin[i], hash);
} }
@ -3162,7 +3162,7 @@ bool Variant::hash_compare(const Variant &p_variant, int recursion_count) const
const Basis *r = p_variant._data._basis; const Basis *r = p_variant._data._basis;
for (int i = 0; i < 3; i++) { 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; 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; const Transform3D *r = p_variant._data._transform3d;
for (int i = 0; i < 3; i++) { 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; return false;
} }
} }

View File

@ -1570,7 +1570,7 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
if (i != 0 || j != 0) { if (i != 0 || j != 0) {
s += ", "; 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) { if (i != 0 || j != 0) {
s += ", "; s += ", ";
} }
s += rtos_fix(m3.elements[i][j]); s += rtos_fix(m3.rows[i][j]);
} }
} }

View File

@ -97,17 +97,17 @@ void RasterizerCanvasGLES3::_update_transform_2d_to_mat2x3(const Transform2D &p_
} }
void RasterizerCanvasGLES3::_update_transform_to_mat4(const Transform3D &p_transform, float *p_mat4) { void RasterizerCanvasGLES3::_update_transform_to_mat4(const Transform3D &p_transform, float *p_mat4) {
p_mat4[0] = p_transform.basis.elements[0][0]; p_mat4[0] = p_transform.basis.rows[0][0];
p_mat4[1] = p_transform.basis.elements[1][0]; p_mat4[1] = p_transform.basis.rows[1][0];
p_mat4[2] = p_transform.basis.elements[2][0]; p_mat4[2] = p_transform.basis.rows[2][0];
p_mat4[3] = 0; p_mat4[3] = 0;
p_mat4[4] = p_transform.basis.elements[0][1]; p_mat4[4] = p_transform.basis.rows[0][1];
p_mat4[5] = p_transform.basis.elements[1][1]; p_mat4[5] = p_transform.basis.rows[1][1];
p_mat4[6] = p_transform.basis.elements[2][1]; p_mat4[6] = p_transform.basis.rows[2][1];
p_mat4[7] = 0; p_mat4[7] = 0;
p_mat4[8] = p_transform.basis.elements[0][2]; p_mat4[8] = p_transform.basis.rows[0][2];
p_mat4[9] = p_transform.basis.elements[1][2]; p_mat4[9] = p_transform.basis.rows[1][2];
p_mat4[10] = p_transform.basis.elements[2][2]; p_mat4[10] = p_transform.basis.rows[2][2];
p_mat4[11] = 0; p_mat4[11] = 0;
p_mat4[12] = p_transform.origin.x; p_mat4[12] = p_transform.origin.x;
p_mat4[13] = p_transform.origin.y; p_mat4[13] = p_transform.origin.y;

View File

@ -574,19 +574,19 @@ _FORCE_INLINE_ static void _fill_std140_variant_ubo_value(ShaderLanguage::DataTy
} }
} else { } else {
Basis v = value; Basis v = value;
gui[0] = v.elements[0][0]; gui[0] = v.rows[0][0];
gui[1] = v.elements[1][0]; gui[1] = v.rows[1][0];
gui[2] = v.elements[2][0]; gui[2] = v.rows[2][0];
gui[3] = 0; // ignored gui[3] = 0; // ignored
gui[4] = v.elements[0][1]; gui[4] = v.rows[0][1];
gui[5] = v.elements[1][1]; gui[5] = v.rows[1][1];
gui[6] = v.elements[2][1]; gui[6] = v.rows[2][1];
gui[7] = 0; // ignored gui[7] = 0; // ignored
gui[8] = v.elements[0][2]; gui[8] = v.rows[0][2];
gui[9] = v.elements[1][2]; gui[9] = v.rows[1][2];
gui[10] = v.elements[2][2]; gui[10] = v.rows[2][2];
gui[11] = 0; // ignored gui[11] = 0; // ignored
} }
} break; } break;
@ -642,19 +642,19 @@ _FORCE_INLINE_ static void _fill_std140_variant_ubo_value(ShaderLanguage::DataTy
} }
} else { } else {
Transform3D v = value; Transform3D v = value;
gui[0] = v.basis.elements[0][0]; gui[0] = v.basis.rows[0][0];
gui[1] = v.basis.elements[1][0]; gui[1] = v.basis.rows[1][0];
gui[2] = v.basis.elements[2][0]; gui[2] = v.basis.rows[2][0];
gui[3] = 0; gui[3] = 0;
gui[4] = v.basis.elements[0][1]; gui[4] = v.basis.rows[0][1];
gui[5] = v.basis.elements[1][1]; gui[5] = v.basis.rows[1][1];
gui[6] = v.basis.elements[2][1]; gui[6] = v.basis.rows[2][1];
gui[7] = 0; gui[7] = 0;
gui[8] = v.basis.elements[0][2]; gui[8] = v.basis.rows[0][2];
gui[9] = v.basis.elements[1][2]; gui[9] = v.basis.rows[1][2];
gui[10] = v.basis.elements[2][2]; gui[10] = v.basis.rows[2][2];
gui[11] = 0; gui[11] = 0;
gui[12] = v.origin.x; gui[12] = v.origin.x;
@ -1874,19 +1874,19 @@ void MaterialStorage::_global_variable_store_in_buffer(int32_t p_index, RS::Glob
case RS::GLOBAL_VAR_TYPE_MAT3: { case RS::GLOBAL_VAR_TYPE_MAT3: {
GlobalVariables::Value *bv = &global_variables.buffer_values[p_index]; GlobalVariables::Value *bv = &global_variables.buffer_values[p_index];
Basis v = p_value; Basis v = p_value;
bv[0].x = v.elements[0][0]; bv[0].x = v.rows[0][0];
bv[0].y = v.elements[1][0]; bv[0].y = v.rows[1][0];
bv[0].z = v.elements[2][0]; bv[0].z = v.rows[2][0];
bv[0].w = 0; bv[0].w = 0;
bv[1].x = v.elements[0][1]; bv[1].x = v.rows[0][1];
bv[1].y = v.elements[1][1]; bv[1].y = v.rows[1][1];
bv[1].z = v.elements[2][1]; bv[1].z = v.rows[2][1];
bv[1].w = 0; bv[1].w = 0;
bv[2].x = v.elements[0][2]; bv[2].x = v.rows[0][2];
bv[2].y = v.elements[1][2]; bv[2].y = v.rows[1][2];
bv[2].z = v.elements[2][2]; bv[2].z = v.rows[2][2];
bv[2].w = 0; bv[2].w = 0;
} break; } break;
@ -1941,19 +1941,19 @@ void MaterialStorage::_global_variable_store_in_buffer(int32_t p_index, RS::Glob
case RS::GLOBAL_VAR_TYPE_TRANSFORM: { case RS::GLOBAL_VAR_TYPE_TRANSFORM: {
GlobalVariables::Value *bv = &global_variables.buffer_values[p_index]; GlobalVariables::Value *bv = &global_variables.buffer_values[p_index];
Transform3D v = p_value; Transform3D v = p_value;
bv[0].x = v.basis.elements[0][0]; bv[0].x = v.basis.rows[0][0];
bv[0].y = v.basis.elements[1][0]; bv[0].y = v.basis.rows[1][0];
bv[0].z = v.basis.elements[2][0]; bv[0].z = v.basis.rows[2][0];
bv[0].w = 0; bv[0].w = 0;
bv[1].x = v.basis.elements[0][1]; bv[1].x = v.basis.rows[0][1];
bv[1].y = v.basis.elements[1][1]; bv[1].y = v.basis.rows[1][1];
bv[1].z = v.basis.elements[2][1]; bv[1].z = v.basis.rows[2][1];
bv[1].w = 0; bv[1].w = 0;
bv[2].x = v.basis.elements[0][2]; bv[2].x = v.basis.rows[0][2];
bv[2].y = v.basis.elements[1][2]; bv[2].y = v.basis.rows[1][2];
bv[2].z = v.basis.elements[2][2]; bv[2].z = v.basis.rows[2][2];
bv[2].w = 0; bv[2].w = 0;
bv[3].x = v.origin.x; bv[3].x = v.origin.x;

View File

@ -384,12 +384,12 @@ AABB MeshStorage::mesh_get_aabb(RID p_mesh, RID p_skeleton) {
Transform3D mtx; Transform3D mtx;
mtx.basis.elements[0].x = dataptr[0]; mtx.basis.rows[0].x = dataptr[0];
mtx.basis.elements[1].x = dataptr[1]; mtx.basis.rows[1].x = dataptr[1];
mtx.origin.x = dataptr[3]; mtx.origin.x = dataptr[3];
mtx.basis.elements[0].y = dataptr[4]; mtx.basis.rows[0].y = dataptr[4];
mtx.basis.elements[1].y = dataptr[5]; mtx.basis.rows[1].y = dataptr[5];
mtx.origin.y = dataptr[7]; mtx.origin.y = dataptr[7];
AABB baabb = mtx.xform(skbones[j]); AABB baabb = mtx.xform(skbones[j]);
@ -411,17 +411,17 @@ AABB MeshStorage::mesh_get_aabb(RID p_mesh, RID p_skeleton) {
Transform3D mtx; Transform3D mtx;
mtx.basis.elements[0][0] = dataptr[0]; mtx.basis.rows[0][0] = dataptr[0];
mtx.basis.elements[0][1] = dataptr[1]; mtx.basis.rows[0][1] = dataptr[1];
mtx.basis.elements[0][2] = dataptr[2]; mtx.basis.rows[0][2] = dataptr[2];
mtx.origin.x = dataptr[3]; mtx.origin.x = dataptr[3];
mtx.basis.elements[1][0] = dataptr[4]; mtx.basis.rows[1][0] = dataptr[4];
mtx.basis.elements[1][1] = dataptr[5]; mtx.basis.rows[1][1] = dataptr[5];
mtx.basis.elements[1][2] = dataptr[6]; mtx.basis.rows[1][2] = dataptr[6];
mtx.origin.y = dataptr[7]; mtx.origin.y = dataptr[7];
mtx.basis.elements[2][0] = dataptr[8]; mtx.basis.rows[2][0] = dataptr[8];
mtx.basis.elements[2][1] = dataptr[9]; mtx.basis.rows[2][1] = dataptr[9];
mtx.basis.elements[2][2] = dataptr[10]; mtx.basis.rows[2][2] = dataptr[10];
mtx.origin.z = dataptr[11]; mtx.origin.z = dataptr[11];
AABB baabb = mtx.xform(skbones[j]); AABB baabb = mtx.xform(skbones[j]);
@ -975,26 +975,26 @@ void MeshStorage::_multimesh_re_create_aabb(MultiMesh *multimesh, const float *p
Transform3D t; Transform3D t;
if (multimesh->xform_format == RS::MULTIMESH_TRANSFORM_3D) { if (multimesh->xform_format == RS::MULTIMESH_TRANSFORM_3D) {
t.basis.elements[0][0] = data[0]; t.basis.rows[0][0] = data[0];
t.basis.elements[0][1] = data[1]; t.basis.rows[0][1] = data[1];
t.basis.elements[0][2] = data[2]; t.basis.rows[0][2] = data[2];
t.origin.x = data[3]; t.origin.x = data[3];
t.basis.elements[1][0] = data[4]; t.basis.rows[1][0] = data[4];
t.basis.elements[1][1] = data[5]; t.basis.rows[1][1] = data[5];
t.basis.elements[1][2] = data[6]; t.basis.rows[1][2] = data[6];
t.origin.y = data[7]; t.origin.y = data[7];
t.basis.elements[2][0] = data[8]; t.basis.rows[2][0] = data[8];
t.basis.elements[2][1] = data[9]; t.basis.rows[2][1] = data[9];
t.basis.elements[2][2] = data[10]; t.basis.rows[2][2] = data[10];
t.origin.z = data[11]; t.origin.z = data[11];
} else { } else {
t.basis.elements[0].x = data[0]; t.basis.rows[0].x = data[0];
t.basis.elements[1].x = data[1]; t.basis.rows[1].x = data[1];
t.origin.x = data[3]; t.origin.x = data[3];
t.basis.elements[0].y = data[4]; t.basis.rows[0].y = data[4];
t.basis.elements[1].y = data[5]; t.basis.rows[1].y = data[5];
t.origin.y = data[7]; 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; float *dataptr = w + p_index * multimesh->stride_cache;
dataptr[0] = p_transform.basis.elements[0][0]; dataptr[0] = p_transform.basis.rows[0][0];
dataptr[1] = p_transform.basis.elements[0][1]; dataptr[1] = p_transform.basis.rows[0][1];
dataptr[2] = p_transform.basis.elements[0][2]; dataptr[2] = p_transform.basis.rows[0][2];
dataptr[3] = p_transform.origin.x; dataptr[3] = p_transform.origin.x;
dataptr[4] = p_transform.basis.elements[1][0]; dataptr[4] = p_transform.basis.rows[1][0];
dataptr[5] = p_transform.basis.elements[1][1]; dataptr[5] = p_transform.basis.rows[1][1];
dataptr[6] = p_transform.basis.elements[1][2]; dataptr[6] = p_transform.basis.rows[1][2];
dataptr[7] = p_transform.origin.y; dataptr[7] = p_transform.origin.y;
dataptr[8] = p_transform.basis.elements[2][0]; dataptr[8] = p_transform.basis.rows[2][0];
dataptr[9] = p_transform.basis.elements[2][1]; dataptr[9] = p_transform.basis.rows[2][1];
dataptr[10] = p_transform.basis.elements[2][2]; dataptr[10] = p_transform.basis.rows[2][2];
dataptr[11] = p_transform.origin.z; dataptr[11] = p_transform.origin.z;
} }
@ -1138,17 +1138,17 @@ Transform3D MeshStorage::multimesh_instance_get_transform(RID p_multimesh, int p
const float *dataptr = r + p_index * multimesh->stride_cache; const float *dataptr = r + p_index * multimesh->stride_cache;
t.basis.elements[0][0] = dataptr[0]; t.basis.rows[0][0] = dataptr[0];
t.basis.elements[0][1] = dataptr[1]; t.basis.rows[0][1] = dataptr[1];
t.basis.elements[0][2] = dataptr[2]; t.basis.rows[0][2] = dataptr[2];
t.origin.x = dataptr[3]; t.origin.x = dataptr[3];
t.basis.elements[1][0] = dataptr[4]; t.basis.rows[1][0] = dataptr[4];
t.basis.elements[1][1] = dataptr[5]; t.basis.rows[1][1] = dataptr[5];
t.basis.elements[1][2] = dataptr[6]; t.basis.rows[1][2] = dataptr[6];
t.origin.y = dataptr[7]; t.origin.y = dataptr[7];
t.basis.elements[2][0] = dataptr[8]; t.basis.rows[2][0] = dataptr[8];
t.basis.elements[2][1] = dataptr[9]; t.basis.rows[2][1] = dataptr[9];
t.basis.elements[2][2] = dataptr[10]; t.basis.rows[2][2] = dataptr[10];
t.origin.z = dataptr[11]; t.origin.z = dataptr[11];
} }

View File

@ -357,12 +357,12 @@ int DebugAdapterProtocol::parse_variant(const Variant &p_var) {
x.type = type_vec3; x.type = type_vec3;
y.type = type_vec3; y.type = type_vec3;
z.type = type_vec3; z.type = type_vec3;
x.value = basis.elements[0]; x.value = basis.rows[0];
y.value = basis.elements[1]; y.value = basis.rows[1];
z.value = basis.elements[2]; z.value = basis.rows[2];
x.variablesReference = parse_variant(basis.elements[0]); x.variablesReference = parse_variant(basis.rows[0]);
y.variablesReference = parse_variant(basis.elements[1]); y.variablesReference = parse_variant(basis.rows[1]);
z.variablesReference = parse_variant(basis.elements[2]); z.variablesReference = parse_variant(basis.rows[2]);
Array arr; Array arr;
arr.push_back(x.to_json()); arr.push_back(x.to_json());

View File

@ -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) { static Transform3D _read_transform_from_array(const Vector<float> &array, int ofs = 0) {
Transform3D tr; Transform3D tr;
// i wonder why collada matrices are transposed, given that's opposed to opengl.. // i wonder why collada matrices are transposed, given that's opposed to opengl..
tr.basis.elements[0][0] = array[0 + ofs]; tr.basis.rows[0][0] = array[0 + ofs];
tr.basis.elements[0][1] = array[1 + ofs]; tr.basis.rows[0][1] = array[1 + ofs];
tr.basis.elements[0][2] = array[2 + ofs]; tr.basis.rows[0][2] = array[2 + ofs];
tr.basis.elements[1][0] = array[4 + ofs]; tr.basis.rows[1][0] = array[4 + ofs];
tr.basis.elements[1][1] = array[5 + ofs]; tr.basis.rows[1][1] = array[5 + ofs];
tr.basis.elements[1][2] = array[6 + ofs]; tr.basis.rows[1][2] = array[6 + ofs];
tr.basis.elements[2][0] = array[8 + ofs]; tr.basis.rows[2][0] = array[8 + ofs];
tr.basis.elements[2][1] = array[9 + ofs]; tr.basis.rows[2][1] = array[9 + ofs];
tr.basis.elements[2][2] = array[10 + ofs]; tr.basis.rows[2][2] = array[10 + ofs];
tr.origin.x = array[3 + ofs]; tr.origin.x = array[3 + ofs];
tr.origin.y = array[7 + ofs]; tr.origin.y = array[7 + ofs];
tr.origin.z = array[11 + 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); ret.resize(16);
Transform3D tr; Transform3D tr;
// i wonder why collada matrices are transposed, given that's opposed to opengl.. // i wonder why collada matrices are transposed, given that's opposed to opengl..
ret.write[0] = interp.basis.elements[0][0]; ret.write[0] = interp.basis.rows[0][0];
ret.write[1] = interp.basis.elements[0][1]; ret.write[1] = interp.basis.rows[0][1];
ret.write[2] = interp.basis.elements[0][2]; ret.write[2] = interp.basis.rows[0][2];
ret.write[4] = interp.basis.elements[1][0]; ret.write[4] = interp.basis.rows[1][0];
ret.write[5] = interp.basis.elements[1][1]; ret.write[5] = interp.basis.rows[1][1];
ret.write[6] = interp.basis.elements[1][2]; ret.write[6] = interp.basis.rows[1][2];
ret.write[8] = interp.basis.elements[2][0]; ret.write[8] = interp.basis.rows[2][0];
ret.write[9] = interp.basis.elements[2][1]; ret.write[9] = interp.basis.rows[2][1];
ret.write[10] = interp.basis.elements[2][2]; ret.write[10] = interp.basis.rows[2][2];
ret.write[3] = interp.origin.x; ret.write[3] = interp.origin.x;
ret.write[7] = interp.origin.y; ret.write[7] = interp.origin.y;
ret.write[11] = interp.origin.z; ret.write[11] = interp.origin.z;

View File

@ -786,7 +786,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
Basis basis = v; Basis basis = v;
for (int i = 0; i < 9; i++) { 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; } break;
@ -807,7 +807,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
Transform3D tr = v; Transform3D tr = v;
for (int i = 0; i < 9; i++) { 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)); value_editor[3]->set_text(String::num(tr.origin.x));
@ -1580,7 +1580,7 @@ void CustomPropertyEditor::_modified(String p_string) {
case Variant::BASIS: { case Variant::BASIS: {
Basis m; Basis m;
for (int i = 0; i < 9; i++) { 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; v = m;
@ -1592,7 +1592,7 @@ void CustomPropertyEditor::_modified(String p_string) {
case Variant::TRANSFORM3D: { case Variant::TRANSFORM3D: {
Basis basis; Basis basis;
for (int i = 0; i < 9; i++) { 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; Vector3 origin;

View File

@ -375,17 +375,17 @@ def build_gles3_header(filename, include, class_suffix, output_attribs):
const Transform3D &tr = p_transform; const Transform3D &tr = p_transform;
GLfloat matrix[16]={ /* build a 16x16 matrix */ GLfloat matrix[16]={ /* build a 16x16 matrix */
(GLfloat)tr.basis.elements[0][0], (GLfloat)tr.basis.rows[0][0],
(GLfloat)tr.basis.elements[1][0], (GLfloat)tr.basis.rows[1][0],
(GLfloat)tr.basis.elements[2][0], (GLfloat)tr.basis.rows[2][0],
(GLfloat)0, (GLfloat)0,
(GLfloat)tr.basis.elements[0][1], (GLfloat)tr.basis.rows[0][1],
(GLfloat)tr.basis.elements[1][1], (GLfloat)tr.basis.rows[1][1],
(GLfloat)tr.basis.elements[2][1], (GLfloat)tr.basis.rows[2][1],
(GLfloat)0, (GLfloat)0,
(GLfloat)tr.basis.elements[0][2], (GLfloat)tr.basis.rows[0][2],
(GLfloat)tr.basis.elements[1][2], (GLfloat)tr.basis.rows[1][2],
(GLfloat)tr.basis.elements[2][2], (GLfloat)tr.basis.rows[2][2],
(GLfloat)0, (GLfloat)0,
(GLfloat)tr.origin.x, (GLfloat)tr.origin.x,
(GLfloat)tr.origin.y, (GLfloat)tr.origin.y,

View File

@ -1028,17 +1028,17 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d
push_constant.atlas_slice = 0; push_constant.atlas_slice = 0;
push_constant.region_ofs[0] = 0; push_constant.region_ofs[0] = 0;
push_constant.region_ofs[1] = 0; push_constant.region_ofs[1] = 0;
push_constant.environment_xform[0] = p_environment_transform.elements[0][0]; push_constant.environment_xform[0] = p_environment_transform.rows[0][0];
push_constant.environment_xform[1] = p_environment_transform.elements[1][0]; push_constant.environment_xform[1] = p_environment_transform.rows[1][0];
push_constant.environment_xform[2] = p_environment_transform.elements[2][0]; push_constant.environment_xform[2] = p_environment_transform.rows[2][0];
push_constant.environment_xform[3] = 0; push_constant.environment_xform[3] = 0;
push_constant.environment_xform[4] = p_environment_transform.elements[0][1]; push_constant.environment_xform[4] = p_environment_transform.rows[0][1];
push_constant.environment_xform[5] = p_environment_transform.elements[1][1]; push_constant.environment_xform[5] = p_environment_transform.rows[1][1];
push_constant.environment_xform[6] = p_environment_transform.elements[2][1]; push_constant.environment_xform[6] = p_environment_transform.rows[2][1];
push_constant.environment_xform[7] = 0; push_constant.environment_xform[7] = 0;
push_constant.environment_xform[8] = p_environment_transform.elements[0][2]; push_constant.environment_xform[8] = p_environment_transform.rows[0][2];
push_constant.environment_xform[9] = p_environment_transform.elements[1][2]; push_constant.environment_xform[9] = p_environment_transform.rows[1][2];
push_constant.environment_xform[10] = p_environment_transform.elements[2][2]; push_constant.environment_xform[10] = p_environment_transform.rows[2][2];
push_constant.environment_xform[11] = 0; push_constant.environment_xform[11] = 0;
} }

View File

@ -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 // We use our gravity and magnetometer vectors to construct our matrix
Basis acc_mag_m3; Basis acc_mag_m3;
acc_mag_m3.elements[0] = -magneto_east; acc_mag_m3.rows[0] = -magneto_east;
acc_mag_m3.elements[1] = up; acc_mag_m3.rows[1] = up;
acc_mag_m3.elements[2] = magneto; acc_mag_m3.rows[2] = magneto;
return acc_mag_m3; return acc_mag_m3;
}; };

View File

@ -412,9 +412,9 @@ struct M_Basis {
static _FORCE_INLINE_ M_Basis convert_from(const Basis &p_from) { static _FORCE_INLINE_ M_Basis convert_from(const Basis &p_from) {
M_Basis ret = { M_Basis ret = {
M_Vector3::convert_from(p_from.elements[0]), M_Vector3::convert_from(p_from.rows[0]),
M_Vector3::convert_from(p_from.elements[1]), M_Vector3::convert_from(p_from.rows[1]),
M_Vector3::convert_from(p_from.elements[2]) M_Vector3::convert_from(p_from.rows[2])
}; };
return ret; return ret;
} }

View File

@ -291,15 +291,15 @@ void WebXRInterfaceJS::uninitialize() {
Transform3D WebXRInterfaceJS::_js_matrix_to_transform(float *p_js_matrix) { Transform3D WebXRInterfaceJS::_js_matrix_to_transform(float *p_js_matrix) {
Transform3D transform; Transform3D transform;
transform.basis.elements[0].x = p_js_matrix[0]; transform.basis.rows[0].x = p_js_matrix[0];
transform.basis.elements[1].x = p_js_matrix[1]; transform.basis.rows[1].x = p_js_matrix[1];
transform.basis.elements[2].x = p_js_matrix[2]; transform.basis.rows[2].x = p_js_matrix[2];
transform.basis.elements[0].y = p_js_matrix[4]; transform.basis.rows[0].y = p_js_matrix[4];
transform.basis.elements[1].y = p_js_matrix[5]; transform.basis.rows[1].y = p_js_matrix[5];
transform.basis.elements[2].y = p_js_matrix[6]; transform.basis.rows[2].y = p_js_matrix[6];
transform.basis.elements[0].z = p_js_matrix[8]; transform.basis.rows[0].z = p_js_matrix[8];
transform.basis.elements[1].z = p_js_matrix[9]; transform.basis.rows[1].z = p_js_matrix[9];
transform.basis.elements[2].z = p_js_matrix[10]; transform.basis.rows[2].z = p_js_matrix[10];
transform.origin.x = p_js_matrix[12]; transform.origin.x = p_js_matrix[12];
transform.origin.y = p_js_matrix[13]; transform.origin.y = p_js_matrix[13];
transform.origin.z = p_js_matrix[14]; transform.origin.z = p_js_matrix[14];

View File

@ -1187,17 +1187,17 @@ void CPUParticles3D::_update_particle_data_buffer() {
} }
if (r[idx].active) { if (r[idx].active) {
ptr[0] = t.basis.elements[0][0]; ptr[0] = t.basis.rows[0][0];
ptr[1] = t.basis.elements[0][1]; ptr[1] = t.basis.rows[0][1];
ptr[2] = t.basis.elements[0][2]; ptr[2] = t.basis.rows[0][2];
ptr[3] = t.origin.x; ptr[3] = t.origin.x;
ptr[4] = t.basis.elements[1][0]; ptr[4] = t.basis.rows[1][0];
ptr[5] = t.basis.elements[1][1]; ptr[5] = t.basis.rows[1][1];
ptr[6] = t.basis.elements[1][2]; ptr[6] = t.basis.rows[1][2];
ptr[7] = t.origin.y; ptr[7] = t.origin.y;
ptr[8] = t.basis.elements[2][0]; ptr[8] = t.basis.rows[2][0];
ptr[9] = t.basis.elements[2][1]; ptr[9] = t.basis.rows[2][1];
ptr[10] = t.basis.elements[2][2]; ptr[10] = t.basis.rows[2][2];
ptr[11] = t.origin.z; ptr[11] = t.origin.z;
} else { } else {
memset(ptr, 0, sizeof(Transform3D)); memset(ptr, 0, sizeof(Transform3D));
@ -1293,17 +1293,17 @@ void CPUParticles3D::_notification(int p_what) {
Transform3D t = inv_emission_transform * r[i].transform; Transform3D t = inv_emission_transform * r[i].transform;
if (r[i].active) { if (r[i].active) {
ptr[0] = t.basis.elements[0][0]; ptr[0] = t.basis.rows[0][0];
ptr[1] = t.basis.elements[0][1]; ptr[1] = t.basis.rows[0][1];
ptr[2] = t.basis.elements[0][2]; ptr[2] = t.basis.rows[0][2];
ptr[3] = t.origin.x; ptr[3] = t.origin.x;
ptr[4] = t.basis.elements[1][0]; ptr[4] = t.basis.rows[1][0];
ptr[5] = t.basis.elements[1][1]; ptr[5] = t.basis.rows[1][1];
ptr[6] = t.basis.elements[1][2]; ptr[6] = t.basis.rows[1][2];
ptr[7] = t.origin.y; ptr[7] = t.origin.y;
ptr[8] = t.basis.elements[2][0]; ptr[8] = t.basis.rows[2][0];
ptr[9] = t.basis.elements[2][1]; ptr[9] = t.basis.rows[2][1];
ptr[10] = t.basis.elements[2][2]; ptr[10] = t.basis.rows[2][2];
ptr[11] = t.origin.z; ptr[11] = t.origin.z;
} else { } else {
memset(ptr, 0, sizeof(float) * 12); memset(ptr, 0, sizeof(float) * 12);

View File

@ -491,15 +491,15 @@ Variant Tween::interpolate_variant(Variant p_initial_val, Variant p_delta_val, f
Basis d = p_delta_val; Basis d = p_delta_val;
Basis r; Basis r;
APPLY_EQUATION(elements[0][0]); APPLY_EQUATION(rows[0][0]);
APPLY_EQUATION(elements[0][1]); APPLY_EQUATION(rows[0][1]);
APPLY_EQUATION(elements[0][2]); APPLY_EQUATION(rows[0][2]);
APPLY_EQUATION(elements[1][0]); APPLY_EQUATION(rows[1][0]);
APPLY_EQUATION(elements[1][1]); APPLY_EQUATION(rows[1][1]);
APPLY_EQUATION(elements[1][2]); APPLY_EQUATION(rows[1][2]);
APPLY_EQUATION(elements[2][0]); APPLY_EQUATION(rows[2][0]);
APPLY_EQUATION(elements[2][1]); APPLY_EQUATION(rows[2][1]);
APPLY_EQUATION(elements[2][2]); APPLY_EQUATION(rows[2][2]);
return r; return r;
} }
@ -508,15 +508,15 @@ Variant Tween::interpolate_variant(Variant p_initial_val, Variant p_delta_val, f
Transform3D d = p_delta_val; Transform3D d = p_delta_val;
Transform3D r; Transform3D r;
APPLY_EQUATION(basis.elements[0][0]); APPLY_EQUATION(basis.rows[0][0]);
APPLY_EQUATION(basis.elements[0][1]); APPLY_EQUATION(basis.rows[0][1]);
APPLY_EQUATION(basis.elements[0][2]); APPLY_EQUATION(basis.rows[0][2]);
APPLY_EQUATION(basis.elements[1][0]); APPLY_EQUATION(basis.rows[1][0]);
APPLY_EQUATION(basis.elements[1][1]); APPLY_EQUATION(basis.rows[1][1]);
APPLY_EQUATION(basis.elements[1][2]); APPLY_EQUATION(basis.rows[1][2]);
APPLY_EQUATION(basis.elements[2][0]); APPLY_EQUATION(basis.rows[2][0]);
APPLY_EQUATION(basis.elements[2][1]); APPLY_EQUATION(basis.rows[2][1]);
APPLY_EQUATION(basis.elements[2][2]); APPLY_EQUATION(basis.rows[2][2]);
APPLY_EQUATION(origin.x); APPLY_EQUATION(origin.x);
APPLY_EQUATION(origin.y); APPLY_EQUATION(origin.y);
APPLY_EQUATION(origin.z); APPLY_EQUATION(origin.z);
@ -582,29 +582,29 @@ Variant Tween::calculate_delta_value(Variant p_intial_val, Variant p_final_val)
case Variant::BASIS: { case Variant::BASIS: {
Basis i = p_intial_val; Basis i = p_intial_val;
Basis f = p_final_val; Basis f = p_final_val;
return Basis(f.elements[0][0] - i.elements[0][0], return Basis(f.rows[0][0] - i.rows[0][0],
f.elements[0][1] - i.elements[0][1], f.rows[0][1] - i.rows[0][1],
f.elements[0][2] - i.elements[0][2], f.rows[0][2] - i.rows[0][2],
f.elements[1][0] - i.elements[1][0], f.rows[1][0] - i.rows[1][0],
f.elements[1][1] - i.elements[1][1], f.rows[1][1] - i.rows[1][1],
f.elements[1][2] - i.elements[1][2], f.rows[1][2] - i.rows[1][2],
f.elements[2][0] - i.elements[2][0], f.rows[2][0] - i.rows[2][0],
f.elements[2][1] - i.elements[2][1], f.rows[2][1] - i.rows[2][1],
f.elements[2][2] - i.elements[2][2]); f.rows[2][2] - i.rows[2][2]);
} }
case Variant::TRANSFORM3D: { case Variant::TRANSFORM3D: {
Transform3D i = p_intial_val; Transform3D i = p_intial_val;
Transform3D f = p_final_val; Transform3D f = p_final_val;
return Transform3D(f.basis.elements[0][0] - i.basis.elements[0][0], return Transform3D(f.basis.rows[0][0] - i.basis.rows[0][0],
f.basis.elements[0][1] - i.basis.elements[0][1], f.basis.rows[0][1] - i.basis.rows[0][1],
f.basis.elements[0][2] - i.basis.elements[0][2], f.basis.rows[0][2] - i.basis.rows[0][2],
f.basis.elements[1][0] - i.basis.elements[1][0], f.basis.rows[1][0] - i.basis.rows[1][0],
f.basis.elements[1][1] - i.basis.elements[1][1], f.basis.rows[1][1] - i.basis.rows[1][1],
f.basis.elements[1][2] - i.basis.elements[1][2], f.basis.rows[1][2] - i.basis.rows[1][2],
f.basis.elements[2][0] - i.basis.elements[2][0], f.basis.rows[2][0] - i.basis.rows[2][0],
f.basis.elements[2][1] - i.basis.elements[2][1], f.basis.rows[2][1] - i.basis.rows[2][1],
f.basis.elements[2][2] - i.basis.elements[2][2], f.basis.rows[2][2] - i.basis.rows[2][2],
f.origin.x - i.origin.x, f.origin.x - i.origin.x,
f.origin.y - i.origin.y, f.origin.y - i.origin.y,
f.origin.z - i.origin.z); f.origin.z - i.origin.z);

View File

@ -331,9 +331,9 @@ public:
//extract scale and scale the matrix by it, makes things simpler //extract scale and scale the matrix by it, makes things simpler
Vector3 scale = p_half_extents; Vector3 scale = p_half_extents;
for (uint32_t i = 0; i < 3; i++) { 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; 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)); float box_depth = Math::abs(xform.basis.xform_inv(Vector3(0, 0, -1)).dot(scale));

View File

@ -81,17 +81,17 @@ void RendererCanvasRenderRD::_update_transform_2d_to_mat2x3(const Transform2D &p
} }
void RendererCanvasRenderRD::_update_transform_to_mat4(const Transform3D &p_transform, float *p_mat4) { void RendererCanvasRenderRD::_update_transform_to_mat4(const Transform3D &p_transform, float *p_mat4) {
p_mat4[0] = p_transform.basis.elements[0][0]; p_mat4[0] = p_transform.basis.rows[0][0];
p_mat4[1] = p_transform.basis.elements[1][0]; p_mat4[1] = p_transform.basis.rows[1][0];
p_mat4[2] = p_transform.basis.elements[2][0]; p_mat4[2] = p_transform.basis.rows[2][0];
p_mat4[3] = 0; p_mat4[3] = 0;
p_mat4[4] = p_transform.basis.elements[0][1]; p_mat4[4] = p_transform.basis.rows[0][1];
p_mat4[5] = p_transform.basis.elements[1][1]; p_mat4[5] = p_transform.basis.rows[1][1];
p_mat4[6] = p_transform.basis.elements[2][1]; p_mat4[6] = p_transform.basis.rows[2][1];
p_mat4[7] = 0; p_mat4[7] = 0;
p_mat4[8] = p_transform.basis.elements[0][2]; p_mat4[8] = p_transform.basis.rows[0][2];
p_mat4[9] = p_transform.basis.elements[1][2]; p_mat4[9] = p_transform.basis.rows[1][2];
p_mat4[10] = p_transform.basis.elements[2][2]; p_mat4[10] = p_transform.basis.rows[2][2];
p_mat4[11] = 0; p_mat4[11] = 0;
p_mat4[12] = p_transform.origin.x; p_mat4[12] = p_transform.origin.x;
p_mat4[13] = p_transform.origin.y; p_mat4[13] = p_transform.origin.y;

View File

@ -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[1] = vp_half.y;
push_constant.cam_extent[2] = -p_projection.get_z_near(); 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[0] = p_transform.basis.rows[0][0];
push_constant.cam_transform[1] = p_transform.basis.elements[1][0]; push_constant.cam_transform[1] = p_transform.basis.rows[1][0];
push_constant.cam_transform[2] = p_transform.basis.elements[2][0]; push_constant.cam_transform[2] = p_transform.basis.rows[2][0];
push_constant.cam_transform[3] = 0; push_constant.cam_transform[3] = 0;
push_constant.cam_transform[4] = p_transform.basis.elements[0][1]; push_constant.cam_transform[4] = p_transform.basis.rows[0][1];
push_constant.cam_transform[5] = p_transform.basis.elements[1][1]; push_constant.cam_transform[5] = p_transform.basis.rows[1][1];
push_constant.cam_transform[6] = p_transform.basis.elements[2][1]; push_constant.cam_transform[6] = p_transform.basis.rows[2][1];
push_constant.cam_transform[7] = 0; push_constant.cam_transform[7] = 0;
push_constant.cam_transform[8] = p_transform.basis.elements[0][2]; push_constant.cam_transform[8] = p_transform.basis.rows[0][2];
push_constant.cam_transform[9] = p_transform.basis.elements[1][2]; push_constant.cam_transform[9] = p_transform.basis.rows[1][2];
push_constant.cam_transform[10] = p_transform.basis.elements[2][2]; push_constant.cam_transform[10] = p_transform.basis.rows[2][2];
push_constant.cam_transform[11] = 0; push_constant.cam_transform[11] = 0;
push_constant.cam_transform[12] = p_transform.origin.x; push_constant.cam_transform[12] = p_transform.origin.x;
push_constant.cam_transform[13] = p_transform.origin.y; 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; 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[0] = to_cell.basis.rows[0][0];
gipd.xform[1] = to_cell.basis.elements[1][0]; gipd.xform[1] = to_cell.basis.rows[1][0];
gipd.xform[2] = to_cell.basis.elements[2][0]; gipd.xform[2] = to_cell.basis.rows[2][0];
gipd.xform[3] = 0; gipd.xform[3] = 0;
gipd.xform[4] = to_cell.basis.elements[0][1]; gipd.xform[4] = to_cell.basis.rows[0][1];
gipd.xform[5] = to_cell.basis.elements[1][1]; gipd.xform[5] = to_cell.basis.rows[1][1];
gipd.xform[6] = to_cell.basis.elements[2][1]; gipd.xform[6] = to_cell.basis.rows[2][1];
gipd.xform[7] = 0; gipd.xform[7] = 0;
gipd.xform[8] = to_cell.basis.elements[0][2]; gipd.xform[8] = to_cell.basis.rows[0][2];
gipd.xform[9] = to_cell.basis.elements[1][2]; gipd.xform[9] = to_cell.basis.rows[1][2];
gipd.xform[10] = to_cell.basis.elements[2][2]; gipd.xform[10] = to_cell.basis.rows[2][2];
gipd.xform[11] = 0; gipd.xform[11] = 0;
gipd.xform[12] = to_cell.origin.x; gipd.xform[12] = to_cell.origin.x;
gipd.xform[13] = to_cell.origin.y; gipd.xform[13] = to_cell.origin.y;

View File

@ -256,17 +256,17 @@ RendererSceneSkyRD::SkyMaterialData::~SkyMaterialData() {
// Render sky // Render sky
static _FORCE_INLINE_ void store_transform_3x3(const Basis &p_basis, float *p_array) { static _FORCE_INLINE_ void store_transform_3x3(const Basis &p_basis, float *p_array) {
p_array[0] = p_basis.elements[0][0]; p_array[0] = p_basis.rows[0][0];
p_array[1] = p_basis.elements[1][0]; p_array[1] = p_basis.rows[1][0];
p_array[2] = p_basis.elements[2][0]; p_array[2] = p_basis.rows[2][0];
p_array[3] = 0; p_array[3] = 0;
p_array[4] = p_basis.elements[0][1]; p_array[4] = p_basis.rows[0][1];
p_array[5] = p_basis.elements[1][1]; p_array[5] = p_basis.rows[1][1];
p_array[6] = p_basis.elements[2][1]; p_array[6] = p_basis.rows[2][1];
p_array[7] = 0; p_array[7] = 0;
p_array[8] = p_basis.elements[0][2]; p_array[8] = p_basis.rows[0][2];
p_array[9] = p_basis.elements[1][2]; p_array[9] = p_basis.rows[1][2];
p_array[10] = p_basis.elements[2][2]; p_array[10] = p_basis.rows[2][2];
p_array[11] = 0; p_array[11] = 0;
} }

View File

@ -45,17 +45,17 @@
class RendererStorageRD : public RendererStorage { class RendererStorageRD : public RendererStorage {
public: public:
static _FORCE_INLINE_ void store_transform(const Transform3D &p_mtx, float *p_array) { static _FORCE_INLINE_ void store_transform(const Transform3D &p_mtx, float *p_array) {
p_array[0] = p_mtx.basis.elements[0][0]; p_array[0] = p_mtx.basis.rows[0][0];
p_array[1] = p_mtx.basis.elements[1][0]; p_array[1] = p_mtx.basis.rows[1][0];
p_array[2] = p_mtx.basis.elements[2][0]; p_array[2] = p_mtx.basis.rows[2][0];
p_array[3] = 0; p_array[3] = 0;
p_array[4] = p_mtx.basis.elements[0][1]; p_array[4] = p_mtx.basis.rows[0][1];
p_array[5] = p_mtx.basis.elements[1][1]; p_array[5] = p_mtx.basis.rows[1][1];
p_array[6] = p_mtx.basis.elements[2][1]; p_array[6] = p_mtx.basis.rows[2][1];
p_array[7] = 0; p_array[7] = 0;
p_array[8] = p_mtx.basis.elements[0][2]; p_array[8] = p_mtx.basis.rows[0][2];
p_array[9] = p_mtx.basis.elements[1][2]; p_array[9] = p_mtx.basis.rows[1][2];
p_array[10] = p_mtx.basis.elements[2][2]; p_array[10] = p_mtx.basis.rows[2][2];
p_array[11] = 0; p_array[11] = 0;
p_array[12] = p_mtx.origin.x; p_array[12] = p_mtx.origin.x;
p_array[13] = p_mtx.origin.y; 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) { static _FORCE_INLINE_ void store_basis_3x4(const Basis &p_mtx, float *p_array) {
p_array[0] = p_mtx.elements[0][0]; p_array[0] = p_mtx.rows[0][0];
p_array[1] = p_mtx.elements[1][0]; p_array[1] = p_mtx.rows[1][0];
p_array[2] = p_mtx.elements[2][0]; p_array[2] = p_mtx.rows[2][0];
p_array[3] = 0; p_array[3] = 0;
p_array[4] = p_mtx.elements[0][1]; p_array[4] = p_mtx.rows[0][1];
p_array[5] = p_mtx.elements[1][1]; p_array[5] = p_mtx.rows[1][1];
p_array[6] = p_mtx.elements[2][1]; p_array[6] = p_mtx.rows[2][1];
p_array[7] = 0; p_array[7] = 0;
p_array[8] = p_mtx.elements[0][2]; p_array[8] = p_mtx.rows[0][2];
p_array[9] = p_mtx.elements[1][2]; p_array[9] = p_mtx.rows[1][2];
p_array[10] = p_mtx.elements[2][2]; p_array[10] = p_mtx.rows[2][2];
p_array[11] = 0; p_array[11] = 0;
} }
static _FORCE_INLINE_ void store_transform_3x3(const Basis &p_mtx, float *p_array) { static _FORCE_INLINE_ void store_transform_3x3(const Basis &p_mtx, float *p_array) {
p_array[0] = p_mtx.elements[0][0]; p_array[0] = p_mtx.rows[0][0];
p_array[1] = p_mtx.elements[1][0]; p_array[1] = p_mtx.rows[1][0];
p_array[2] = p_mtx.elements[2][0]; p_array[2] = p_mtx.rows[2][0];
p_array[3] = 0; p_array[3] = 0;
p_array[4] = p_mtx.elements[0][1]; p_array[4] = p_mtx.rows[0][1];
p_array[5] = p_mtx.elements[1][1]; p_array[5] = p_mtx.rows[1][1];
p_array[6] = p_mtx.elements[2][1]; p_array[6] = p_mtx.rows[2][1];
p_array[7] = 0; p_array[7] = 0;
p_array[8] = p_mtx.elements[0][2]; p_array[8] = p_mtx.rows[0][2];
p_array[9] = p_mtx.elements[1][2]; p_array[9] = p_mtx.rows[1][2];
p_array[10] = p_mtx.elements[2][2]; p_array[10] = p_mtx.rows[2][2];
p_array[11] = 0; p_array[11] = 0;
} }
static _FORCE_INLINE_ void store_transform_transposed_3x4(const Transform3D &p_mtx, float *p_array) { 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[0] = p_mtx.basis.rows[0][0];
p_array[1] = p_mtx.basis.elements[0][1]; p_array[1] = p_mtx.basis.rows[0][1];
p_array[2] = p_mtx.basis.elements[0][2]; p_array[2] = p_mtx.basis.rows[0][2];
p_array[3] = p_mtx.origin.x; p_array[3] = p_mtx.origin.x;
p_array[4] = p_mtx.basis.elements[1][0]; p_array[4] = p_mtx.basis.rows[1][0];
p_array[5] = p_mtx.basis.elements[1][1]; p_array[5] = p_mtx.basis.rows[1][1];
p_array[6] = p_mtx.basis.elements[1][2]; p_array[6] = p_mtx.basis.rows[1][2];
p_array[7] = p_mtx.origin.y; p_array[7] = p_mtx.origin.y;
p_array[8] = p_mtx.basis.elements[2][0]; p_array[8] = p_mtx.basis.rows[2][0];
p_array[9] = p_mtx.basis.elements[2][1]; p_array[9] = p_mtx.basis.rows[2][1];
p_array[10] = p_mtx.basis.elements[2][2]; p_array[10] = p_mtx.basis.rows[2][2];
p_array[11] = p_mtx.origin.z; p_array[11] = p_mtx.origin.z;
} }

View File

@ -570,19 +570,19 @@ _FORCE_INLINE_ static void _fill_std140_variant_ubo_value(ShaderLanguage::DataTy
} }
} else { } else {
Basis v = value; Basis v = value;
gui[0] = v.elements[0][0]; gui[0] = v.rows[0][0];
gui[1] = v.elements[1][0]; gui[1] = v.rows[1][0];
gui[2] = v.elements[2][0]; gui[2] = v.rows[2][0];
gui[3] = 0; // ignored gui[3] = 0; // ignored
gui[4] = v.elements[0][1]; gui[4] = v.rows[0][1];
gui[5] = v.elements[1][1]; gui[5] = v.rows[1][1];
gui[6] = v.elements[2][1]; gui[6] = v.rows[2][1];
gui[7] = 0; // ignored gui[7] = 0; // ignored
gui[8] = v.elements[0][2]; gui[8] = v.rows[0][2];
gui[9] = v.elements[1][2]; gui[9] = v.rows[1][2];
gui[10] = v.elements[2][2]; gui[10] = v.rows[2][2];
gui[11] = 0; // ignored gui[11] = 0; // ignored
} }
} break; } break;
@ -638,19 +638,19 @@ _FORCE_INLINE_ static void _fill_std140_variant_ubo_value(ShaderLanguage::DataTy
} }
} else { } else {
Transform3D v = value; Transform3D v = value;
gui[0] = v.basis.elements[0][0]; gui[0] = v.basis.rows[0][0];
gui[1] = v.basis.elements[1][0]; gui[1] = v.basis.rows[1][0];
gui[2] = v.basis.elements[2][0]; gui[2] = v.basis.rows[2][0];
gui[3] = 0; gui[3] = 0;
gui[4] = v.basis.elements[0][1]; gui[4] = v.basis.rows[0][1];
gui[5] = v.basis.elements[1][1]; gui[5] = v.basis.rows[1][1];
gui[6] = v.basis.elements[2][1]; gui[6] = v.basis.rows[2][1];
gui[7] = 0; gui[7] = 0;
gui[8] = v.basis.elements[0][2]; gui[8] = v.basis.rows[0][2];
gui[9] = v.basis.elements[1][2]; gui[9] = v.basis.rows[1][2];
gui[10] = v.basis.elements[2][2]; gui[10] = v.basis.rows[2][2];
gui[11] = 0; gui[11] = 0;
gui[12] = v.origin.x; gui[12] = v.origin.x;
@ -1733,19 +1733,19 @@ void MaterialStorage::_global_variable_store_in_buffer(int32_t p_index, RS::Glob
case RS::GLOBAL_VAR_TYPE_MAT3: { case RS::GLOBAL_VAR_TYPE_MAT3: {
GlobalVariables::Value *bv = &global_variables.buffer_values[p_index]; GlobalVariables::Value *bv = &global_variables.buffer_values[p_index];
Basis v = p_value; Basis v = p_value;
bv[0].x = v.elements[0][0]; bv[0].x = v.rows[0][0];
bv[0].y = v.elements[1][0]; bv[0].y = v.rows[1][0];
bv[0].z = v.elements[2][0]; bv[0].z = v.rows[2][0];
bv[0].w = 0; bv[0].w = 0;
bv[1].x = v.elements[0][1]; bv[1].x = v.rows[0][1];
bv[1].y = v.elements[1][1]; bv[1].y = v.rows[1][1];
bv[1].z = v.elements[2][1]; bv[1].z = v.rows[2][1];
bv[1].w = 0; bv[1].w = 0;
bv[2].x = v.elements[0][2]; bv[2].x = v.rows[0][2];
bv[2].y = v.elements[1][2]; bv[2].y = v.rows[1][2];
bv[2].z = v.elements[2][2]; bv[2].z = v.rows[2][2];
bv[2].w = 0; bv[2].w = 0;
} break; } break;
@ -1800,19 +1800,19 @@ void MaterialStorage::_global_variable_store_in_buffer(int32_t p_index, RS::Glob
case RS::GLOBAL_VAR_TYPE_TRANSFORM: { case RS::GLOBAL_VAR_TYPE_TRANSFORM: {
GlobalVariables::Value *bv = &global_variables.buffer_values[p_index]; GlobalVariables::Value *bv = &global_variables.buffer_values[p_index];
Transform3D v = p_value; Transform3D v = p_value;
bv[0].x = v.basis.elements[0][0]; bv[0].x = v.basis.rows[0][0];
bv[0].y = v.basis.elements[1][0]; bv[0].y = v.basis.rows[1][0];
bv[0].z = v.basis.elements[2][0]; bv[0].z = v.basis.rows[2][0];
bv[0].w = 0; bv[0].w = 0;
bv[1].x = v.basis.elements[0][1]; bv[1].x = v.basis.rows[0][1];
bv[1].y = v.basis.elements[1][1]; bv[1].y = v.basis.rows[1][1];
bv[1].z = v.basis.elements[2][1]; bv[1].z = v.basis.rows[2][1];
bv[1].w = 0; bv[1].w = 0;
bv[2].x = v.basis.elements[0][2]; bv[2].x = v.basis.rows[0][2];
bv[2].y = v.basis.elements[1][2]; bv[2].y = v.basis.rows[1][2];
bv[2].z = v.basis.elements[2][2]; bv[2].z = v.basis.rows[2][2];
bv[2].w = 0; bv[2].w = 0;
bv[3].x = v.origin.x; bv[3].x = v.origin.x;

View File

@ -609,12 +609,12 @@ AABB MeshStorage::mesh_get_aabb(RID p_mesh, RID p_skeleton) {
Transform3D mtx; Transform3D mtx;
mtx.basis.elements[0].x = dataptr[0]; mtx.basis.rows[0].x = dataptr[0];
mtx.basis.elements[1].x = dataptr[1]; mtx.basis.rows[1].x = dataptr[1];
mtx.origin.x = dataptr[3]; mtx.origin.x = dataptr[3];
mtx.basis.elements[0].y = dataptr[4]; mtx.basis.rows[0].y = dataptr[4];
mtx.basis.elements[1].y = dataptr[5]; mtx.basis.rows[1].y = dataptr[5];
mtx.origin.y = dataptr[7]; mtx.origin.y = dataptr[7];
AABB baabb = mtx.xform(skbones[j]); AABB baabb = mtx.xform(skbones[j]);
@ -636,17 +636,17 @@ AABB MeshStorage::mesh_get_aabb(RID p_mesh, RID p_skeleton) {
Transform3D mtx; Transform3D mtx;
mtx.basis.elements[0][0] = dataptr[0]; mtx.basis.rows[0][0] = dataptr[0];
mtx.basis.elements[0][1] = dataptr[1]; mtx.basis.rows[0][1] = dataptr[1];
mtx.basis.elements[0][2] = dataptr[2]; mtx.basis.rows[0][2] = dataptr[2];
mtx.origin.x = dataptr[3]; mtx.origin.x = dataptr[3];
mtx.basis.elements[1][0] = dataptr[4]; mtx.basis.rows[1][0] = dataptr[4];
mtx.basis.elements[1][1] = dataptr[5]; mtx.basis.rows[1][1] = dataptr[5];
mtx.basis.elements[1][2] = dataptr[6]; mtx.basis.rows[1][2] = dataptr[6];
mtx.origin.y = dataptr[7]; mtx.origin.y = dataptr[7];
mtx.basis.elements[2][0] = dataptr[8]; mtx.basis.rows[2][0] = dataptr[8];
mtx.basis.elements[2][1] = dataptr[9]; mtx.basis.rows[2][1] = dataptr[9];
mtx.basis.elements[2][2] = dataptr[10]; mtx.basis.rows[2][2] = dataptr[10];
mtx.origin.z = dataptr[11]; mtx.origin.z = dataptr[11];
AABB baabb = mtx.xform(skbones[j]); AABB baabb = mtx.xform(skbones[j]);
@ -1331,26 +1331,26 @@ void MeshStorage::_multimesh_re_create_aabb(MultiMesh *multimesh, const float *p
Transform3D t; Transform3D t;
if (multimesh->xform_format == RS::MULTIMESH_TRANSFORM_3D) { if (multimesh->xform_format == RS::MULTIMESH_TRANSFORM_3D) {
t.basis.elements[0][0] = data[0]; t.basis.rows[0][0] = data[0];
t.basis.elements[0][1] = data[1]; t.basis.rows[0][1] = data[1];
t.basis.elements[0][2] = data[2]; t.basis.rows[0][2] = data[2];
t.origin.x = data[3]; t.origin.x = data[3];
t.basis.elements[1][0] = data[4]; t.basis.rows[1][0] = data[4];
t.basis.elements[1][1] = data[5]; t.basis.rows[1][1] = data[5];
t.basis.elements[1][2] = data[6]; t.basis.rows[1][2] = data[6];
t.origin.y = data[7]; t.origin.y = data[7];
t.basis.elements[2][0] = data[8]; t.basis.rows[2][0] = data[8];
t.basis.elements[2][1] = data[9]; t.basis.rows[2][1] = data[9];
t.basis.elements[2][2] = data[10]; t.basis.rows[2][2] = data[10];
t.origin.z = data[11]; t.origin.z = data[11];
} else { } else {
t.basis.elements[0].x = data[0]; t.basis.rows[0].x = data[0];
t.basis.elements[1].x = data[1]; t.basis.rows[1].x = data[1];
t.origin.x = data[3]; t.origin.x = data[3];
t.basis.elements[0].y = data[4]; t.basis.rows[0].y = data[4];
t.basis.elements[1].y = data[5]; t.basis.rows[1].y = data[5];
t.origin.y = data[7]; 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; float *dataptr = w + p_index * multimesh->stride_cache;
dataptr[0] = p_transform.basis.elements[0][0]; dataptr[0] = p_transform.basis.rows[0][0];
dataptr[1] = p_transform.basis.elements[0][1]; dataptr[1] = p_transform.basis.rows[0][1];
dataptr[2] = p_transform.basis.elements[0][2]; dataptr[2] = p_transform.basis.rows[0][2];
dataptr[3] = p_transform.origin.x; dataptr[3] = p_transform.origin.x;
dataptr[4] = p_transform.basis.elements[1][0]; dataptr[4] = p_transform.basis.rows[1][0];
dataptr[5] = p_transform.basis.elements[1][1]; dataptr[5] = p_transform.basis.rows[1][1];
dataptr[6] = p_transform.basis.elements[1][2]; dataptr[6] = p_transform.basis.rows[1][2];
dataptr[7] = p_transform.origin.y; dataptr[7] = p_transform.origin.y;
dataptr[8] = p_transform.basis.elements[2][0]; dataptr[8] = p_transform.basis.rows[2][0];
dataptr[9] = p_transform.basis.elements[2][1]; dataptr[9] = p_transform.basis.rows[2][1];
dataptr[10] = p_transform.basis.elements[2][2]; dataptr[10] = p_transform.basis.rows[2][2];
dataptr[11] = p_transform.origin.z; dataptr[11] = p_transform.origin.z;
} }
@ -1485,17 +1485,17 @@ Transform3D MeshStorage::multimesh_instance_get_transform(RID p_multimesh, int p
const float *dataptr = r + p_index * multimesh->stride_cache; const float *dataptr = r + p_index * multimesh->stride_cache;
t.basis.elements[0][0] = dataptr[0]; t.basis.rows[0][0] = dataptr[0];
t.basis.elements[0][1] = dataptr[1]; t.basis.rows[0][1] = dataptr[1];
t.basis.elements[0][2] = dataptr[2]; t.basis.rows[0][2] = dataptr[2];
t.origin.x = dataptr[3]; t.origin.x = dataptr[3];
t.basis.elements[1][0] = dataptr[4]; t.basis.rows[1][0] = dataptr[4];
t.basis.elements[1][1] = dataptr[5]; t.basis.rows[1][1] = dataptr[5];
t.basis.elements[1][2] = dataptr[6]; t.basis.rows[1][2] = dataptr[6];
t.origin.y = dataptr[7]; t.origin.y = dataptr[7];
t.basis.elements[2][0] = dataptr[8]; t.basis.rows[2][0] = dataptr[8];
t.basis.elements[2][1] = dataptr[9]; t.basis.rows[2][1] = dataptr[9];
t.basis.elements[2][2] = dataptr[10]; t.basis.rows[2][2] = dataptr[10];
t.origin.z = dataptr[11]; t.origin.z = dataptr[11];
} }
@ -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; float *dataptr = skeleton->data.ptrw() + p_bone * 12;
dataptr[0] = p_transform.basis.elements[0][0]; dataptr[0] = p_transform.basis.rows[0][0];
dataptr[1] = p_transform.basis.elements[0][1]; dataptr[1] = p_transform.basis.rows[0][1];
dataptr[2] = p_transform.basis.elements[0][2]; dataptr[2] = p_transform.basis.rows[0][2];
dataptr[3] = p_transform.origin.x; dataptr[3] = p_transform.origin.x;
dataptr[4] = p_transform.basis.elements[1][0]; dataptr[4] = p_transform.basis.rows[1][0];
dataptr[5] = p_transform.basis.elements[1][1]; dataptr[5] = p_transform.basis.rows[1][1];
dataptr[6] = p_transform.basis.elements[1][2]; dataptr[6] = p_transform.basis.rows[1][2];
dataptr[7] = p_transform.origin.y; dataptr[7] = p_transform.origin.y;
dataptr[8] = p_transform.basis.elements[2][0]; dataptr[8] = p_transform.basis.rows[2][0];
dataptr[9] = p_transform.basis.elements[2][1]; dataptr[9] = p_transform.basis.rows[2][1];
dataptr[10] = p_transform.basis.elements[2][2]; dataptr[10] = p_transform.basis.rows[2][2];
dataptr[11] = p_transform.origin.z; dataptr[11] = p_transform.origin.z;
_skeleton_make_dirty(skeleton); _skeleton_make_dirty(skeleton);
@ -1827,17 +1827,17 @@ Transform3D MeshStorage::skeleton_bone_get_transform(RID p_skeleton, int p_bone)
Transform3D t; Transform3D t;
t.basis.elements[0][0] = dataptr[0]; t.basis.rows[0][0] = dataptr[0];
t.basis.elements[0][1] = dataptr[1]; t.basis.rows[0][1] = dataptr[1];
t.basis.elements[0][2] = dataptr[2]; t.basis.rows[0][2] = dataptr[2];
t.origin.x = dataptr[3]; t.origin.x = dataptr[3];
t.basis.elements[1][0] = dataptr[4]; t.basis.rows[1][0] = dataptr[4];
t.basis.elements[1][1] = dataptr[5]; t.basis.rows[1][1] = dataptr[5];
t.basis.elements[1][2] = dataptr[6]; t.basis.rows[1][2] = dataptr[6];
t.origin.y = dataptr[7]; t.origin.y = dataptr[7];
t.basis.elements[2][0] = dataptr[8]; t.basis.rows[2][0] = dataptr[8];
t.basis.elements[2][1] = dataptr[9]; t.basis.rows[2][1] = dataptr[9];
t.basis.elements[2][2] = dataptr[10]; t.basis.rows[2][2] = dataptr[10];
t.origin.z = dataptr[11]; t.origin.z = dataptr[11];
return t; return t;

View File

@ -860,7 +860,7 @@ void RendererSceneCull::instance_set_transform(RID p_instance, const Transform3D
#ifdef DEBUG_ENABLED #ifdef DEBUG_ENABLED
for (int i = 0; i < 4; i++) { 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_inf(v.x));
ERR_FAIL_COND(Math::is_nan(v.x)); ERR_FAIL_COND(Math::is_nan(v.x));
ERR_FAIL_COND(Math::is_inf(v.y)); ERR_FAIL_COND(Math::is_inf(v.y));

View File

@ -131,7 +131,7 @@ void XRServer::center_on_hmd(RotationMode p_rotation_mode, bool p_keep_height) {
// remove our tilt // remove our tilt
if (p_rotation_mode == 1) { if (p_rotation_mode == 1) {
// take the Y out of our Z // 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 // Y is straight up
new_reference_frame.basis.set_axis(1, Vector3(0.0, 1.0, 0.0)); new_reference_frame.basis.set_axis(1, Vector3(0.0, 1.0, 0.0));