Rename Transform2D "elements" to "columns"

This commit is contained in:
Aaron Franke 2022-04-24 16:59:24 -05:00
parent 81139c94a8
commit b831fb0a54
No known key found for this signature in database
GPG key ID: 40A1750B977E56BF
44 changed files with 410 additions and 407 deletions

View file

@ -291,7 +291,7 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
ERR_FAIL_COND_V((size_t)len < sizeof(double) * 6, ERR_INVALID_DATA);
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 2; j++) {
val.elements[i][j] = decode_double(&buf[(i * 2 + j) * sizeof(double)]);
val.columns[i][j] = decode_double(&buf[(i * 2 + j) * sizeof(double)]);
}
}
@ -302,7 +302,7 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
ERR_FAIL_COND_V((size_t)len < sizeof(float) * 6, ERR_INVALID_DATA);
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 2; j++) {
val.elements[i][j] = decode_float(&buf[(i * 2 + j) * sizeof(float)]);
val.columns[i][j] = decode_float(&buf[(i * 2 + j) * sizeof(float)]);
}
}
@ -1261,7 +1261,7 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
Transform2D val = p_variant;
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 2; j++) {
memcpy(&buf[(i * 2 + j) * sizeof(real_t)], &val.elements[i][j], sizeof(real_t));
memcpy(&buf[(i * 2 + j) * sizeof(real_t)], &val.columns[i][j], sizeof(real_t));
}
}
}

View file

@ -266,12 +266,12 @@ Error ResourceLoaderBinary::parse_variant(Variant &r_v) {
} break;
case VARIANT_TRANSFORM2D: {
Transform2D v;
v.elements[0].x = f->get_real();
v.elements[0].y = f->get_real();
v.elements[1].x = f->get_real();
v.elements[1].y = f->get_real();
v.elements[2].x = f->get_real();
v.elements[2].y = f->get_real();
v.columns[0].x = f->get_real();
v.columns[0].y = f->get_real();
v.columns[1].x = f->get_real();
v.columns[1].y = f->get_real();
v.columns[2].x = f->get_real();
v.columns[2].y = f->get_real();
r_v = v;
} break;
@ -1473,12 +1473,12 @@ void ResourceFormatSaverBinaryInstance::write_variant(Ref<FileAccess> f, const V
case Variant::TRANSFORM2D: {
f->store_32(VARIANT_TRANSFORM2D);
Transform2D val = p_property;
f->store_real(val.elements[0].x);
f->store_real(val.elements[0].y);
f->store_real(val.elements[1].x);
f->store_real(val.elements[1].y);
f->store_real(val.elements[2].x);
f->store_real(val.elements[2].y);
f->store_real(val.columns[0].x);
f->store_real(val.columns[0].y);
f->store_real(val.columns[1].x);
f->store_real(val.columns[1].y);
f->store_real(val.columns[2].x);
f->store_real(val.columns[2].y);
} break;
case Variant::BASIS: {

View file

@ -115,12 +115,12 @@ Variant fieldwise_assign(const Variant &p_target, const Variant &p_source, const
case Variant::TRANSFORM2D: {
SETUP_TYPE(Transform2D)
/**/ TRY_TRANSFER_FIELD("xx", elements[0][0])
else TRY_TRANSFER_FIELD("xy", elements[0][1])
else TRY_TRANSFER_FIELD("yx", elements[1][0])
else TRY_TRANSFER_FIELD("yy", elements[1][1])
else TRY_TRANSFER_FIELD("ox", elements[2][0])
else TRY_TRANSFER_FIELD("oy", elements[2][1])
/**/ TRY_TRANSFER_FIELD("xx", columns[0][0])
else TRY_TRANSFER_FIELD("xy", columns[0][1])
else TRY_TRANSFER_FIELD("yx", columns[1][0])
else TRY_TRANSFER_FIELD("yy", columns[1][1])
else TRY_TRANSFER_FIELD("ox", columns[2][0])
else TRY_TRANSFER_FIELD("oy", columns[2][1])
return target;
}

View file

@ -201,33 +201,33 @@ next4:
Vector2(position.x + size.x, position.y + size.y),
};
real_t maxa = p_xform.elements[0].dot(xf_points2[0]);
real_t maxa = p_xform.columns[0].dot(xf_points2[0]);
real_t mina = maxa;
real_t dp = p_xform.elements[0].dot(xf_points2[1]);
real_t dp = p_xform.columns[0].dot(xf_points2[1]);
maxa = MAX(dp, maxa);
mina = MIN(dp, mina);
dp = p_xform.elements[0].dot(xf_points2[2]);
dp = p_xform.columns[0].dot(xf_points2[2]);
maxa = MAX(dp, maxa);
mina = MIN(dp, mina);
dp = p_xform.elements[0].dot(xf_points2[3]);
dp = p_xform.columns[0].dot(xf_points2[3]);
maxa = MAX(dp, maxa);
mina = MIN(dp, mina);
real_t maxb = p_xform.elements[0].dot(xf_points[0]);
real_t maxb = p_xform.columns[0].dot(xf_points[0]);
real_t minb = maxb;
dp = p_xform.elements[0].dot(xf_points[1]);
dp = p_xform.columns[0].dot(xf_points[1]);
maxb = MAX(dp, maxb);
minb = MIN(dp, minb);
dp = p_xform.elements[0].dot(xf_points[2]);
dp = p_xform.columns[0].dot(xf_points[2]);
maxb = MAX(dp, maxb);
minb = MIN(dp, minb);
dp = p_xform.elements[0].dot(xf_points[3]);
dp = p_xform.columns[0].dot(xf_points[3]);
maxb = MAX(dp, maxb);
minb = MIN(dp, minb);
@ -238,33 +238,33 @@ next4:
return false;
}
maxa = p_xform.elements[1].dot(xf_points2[0]);
maxa = p_xform.columns[1].dot(xf_points2[0]);
mina = maxa;
dp = p_xform.elements[1].dot(xf_points2[1]);
dp = p_xform.columns[1].dot(xf_points2[1]);
maxa = MAX(dp, maxa);
mina = MIN(dp, mina);
dp = p_xform.elements[1].dot(xf_points2[2]);
dp = p_xform.columns[1].dot(xf_points2[2]);
maxa = MAX(dp, maxa);
mina = MIN(dp, mina);
dp = p_xform.elements[1].dot(xf_points2[3]);
dp = p_xform.columns[1].dot(xf_points2[3]);
maxa = MAX(dp, maxa);
mina = MIN(dp, mina);
maxb = p_xform.elements[1].dot(xf_points[0]);
maxb = p_xform.columns[1].dot(xf_points[0]);
minb = maxb;
dp = p_xform.elements[1].dot(xf_points[1]);
dp = p_xform.columns[1].dot(xf_points[1]);
maxb = MAX(dp, maxb);
minb = MIN(dp, minb);
dp = p_xform.elements[1].dot(xf_points[2]);
dp = p_xform.columns[1].dot(xf_points[2]);
maxb = MAX(dp, maxb);
minb = MIN(dp, minb);
dp = p_xform.elements[1].dot(xf_points[3]);
dp = p_xform.columns[1].dot(xf_points[3]);
maxb = MAX(dp, maxb);
minb = MIN(dp, minb);

View file

@ -35,8 +35,8 @@
void Transform2D::invert() {
// FIXME: this function assumes the basis is a rotation matrix, with no scaling.
// Transform2D::affine_inverse can handle matrices with scaling, so GDScript should eventually use that.
SWAP(elements[0][1], elements[1][0]);
elements[2] = basis_xform(-elements[2]);
SWAP(columns[0][1], columns[1][0]);
columns[2] = basis_xform(-columns[2]);
}
Transform2D Transform2D::inverse() const {
@ -52,11 +52,11 @@ void Transform2D::affine_invert() {
#endif
real_t idet = 1.0f / det;
SWAP(elements[0][0], elements[1][1]);
elements[0] *= Vector2(idet, -idet);
elements[1] *= Vector2(-idet, idet);
SWAP(columns[0][0], columns[1][1]);
columns[0] *= Vector2(idet, -idet);
columns[1] *= Vector2(-idet, idet);
elements[2] = basis_xform(-elements[2]);
columns[2] = basis_xform(-columns[2]);
}
Transform2D Transform2D::affine_inverse() const {
@ -71,69 +71,69 @@ void Transform2D::rotate(const real_t p_phi) {
real_t Transform2D::get_skew() const {
real_t det = basis_determinant();
return Math::acos(elements[0].normalized().dot(SIGN(det) * elements[1].normalized())) - (real_t)Math_PI * 0.5f;
return Math::acos(columns[0].normalized().dot(SIGN(det) * columns[1].normalized())) - (real_t)Math_PI * 0.5f;
}
void Transform2D::set_skew(const real_t p_angle) {
real_t det = basis_determinant();
elements[1] = SIGN(det) * elements[0].rotated(((real_t)Math_PI * 0.5f + p_angle)).normalized() * elements[1].length();
columns[1] = SIGN(det) * columns[0].rotated(((real_t)Math_PI * 0.5f + p_angle)).normalized() * columns[1].length();
}
real_t Transform2D::get_rotation() const {
return Math::atan2(elements[0].y, elements[0].x);
return Math::atan2(columns[0].y, columns[0].x);
}
void Transform2D::set_rotation(const real_t p_rot) {
Size2 scale = get_scale();
real_t cr = Math::cos(p_rot);
real_t sr = Math::sin(p_rot);
elements[0][0] = cr;
elements[0][1] = sr;
elements[1][0] = -sr;
elements[1][1] = cr;
columns[0][0] = cr;
columns[0][1] = sr;
columns[1][0] = -sr;
columns[1][1] = cr;
set_scale(scale);
}
Transform2D::Transform2D(const real_t p_rot, const Vector2 &p_pos) {
real_t cr = Math::cos(p_rot);
real_t sr = Math::sin(p_rot);
elements[0][0] = cr;
elements[0][1] = sr;
elements[1][0] = -sr;
elements[1][1] = cr;
elements[2] = p_pos;
columns[0][0] = cr;
columns[0][1] = sr;
columns[1][0] = -sr;
columns[1][1] = cr;
columns[2] = p_pos;
}
Transform2D::Transform2D(const real_t p_rot, const Size2 &p_scale, const real_t p_skew, const Vector2 &p_pos) {
elements[0][0] = Math::cos(p_rot) * p_scale.x;
elements[1][1] = Math::cos(p_rot + p_skew) * p_scale.y;
elements[1][0] = -Math::sin(p_rot + p_skew) * p_scale.y;
elements[0][1] = Math::sin(p_rot) * p_scale.x;
elements[2] = p_pos;
columns[0][0] = Math::cos(p_rot) * p_scale.x;
columns[1][1] = Math::cos(p_rot + p_skew) * p_scale.y;
columns[1][0] = -Math::sin(p_rot + p_skew) * p_scale.y;
columns[0][1] = Math::sin(p_rot) * p_scale.x;
columns[2] = p_pos;
}
Size2 Transform2D::get_scale() const {
real_t det_sign = SIGN(basis_determinant());
return Size2(elements[0].length(), det_sign * elements[1].length());
return Size2(columns[0].length(), det_sign * columns[1].length());
}
void Transform2D::set_scale(const Size2 &p_scale) {
elements[0].normalize();
elements[1].normalize();
elements[0] *= p_scale.x;
elements[1] *= p_scale.y;
columns[0].normalize();
columns[1].normalize();
columns[0] *= p_scale.x;
columns[1] *= p_scale.y;
}
void Transform2D::scale(const Size2 &p_scale) {
scale_basis(p_scale);
elements[2] *= p_scale;
columns[2] *= p_scale;
}
void Transform2D::scale_basis(const Size2 &p_scale) {
elements[0][0] *= p_scale.x;
elements[0][1] *= p_scale.y;
elements[1][0] *= p_scale.x;
elements[1][1] *= p_scale.y;
columns[0][0] *= p_scale.x;
columns[0][1] *= p_scale.y;
columns[1][0] *= p_scale.x;
columns[1][1] *= p_scale.y;
}
void Transform2D::translate(const real_t p_tx, const real_t p_ty) {
@ -141,21 +141,21 @@ void Transform2D::translate(const real_t p_tx, const real_t p_ty) {
}
void Transform2D::translate(const Vector2 &p_translation) {
elements[2] += basis_xform(p_translation);
columns[2] += basis_xform(p_translation);
}
void Transform2D::orthonormalize() {
// Gram-Schmidt Process
Vector2 x = elements[0];
Vector2 y = elements[1];
Vector2 x = columns[0];
Vector2 y = columns[1];
x.normalize();
y = (y - x * (x.dot(y)));
y.normalize();
elements[0] = x;
elements[1] = y;
columns[0] = x;
columns[1] = y;
}
Transform2D Transform2D::orthonormalized() const {
@ -165,7 +165,7 @@ Transform2D Transform2D::orthonormalized() const {
}
bool Transform2D::is_equal_approx(const Transform2D &p_transform) const {
return elements[0].is_equal_approx(p_transform.elements[0]) && elements[1].is_equal_approx(p_transform.elements[1]) && elements[2].is_equal_approx(p_transform.elements[2]);
return columns[0].is_equal_approx(p_transform.columns[0]) && columns[1].is_equal_approx(p_transform.columns[1]) && columns[2].is_equal_approx(p_transform.columns[2]);
}
Transform2D Transform2D::looking_at(const Vector2 &p_target) const {
@ -177,7 +177,7 @@ Transform2D Transform2D::looking_at(const Vector2 &p_target) const {
bool Transform2D::operator==(const Transform2D &p_transform) const {
for (int i = 0; i < 3; i++) {
if (elements[i] != p_transform.elements[i]) {
if (columns[i] != p_transform.columns[i]) {
return false;
}
}
@ -187,7 +187,7 @@ bool Transform2D::operator==(const Transform2D &p_transform) const {
bool Transform2D::operator!=(const Transform2D &p_transform) const {
for (int i = 0; i < 3; i++) {
if (elements[i] != p_transform.elements[i]) {
if (columns[i] != p_transform.columns[i]) {
return true;
}
}
@ -196,19 +196,19 @@ bool Transform2D::operator!=(const Transform2D &p_transform) const {
}
void Transform2D::operator*=(const Transform2D &p_transform) {
elements[2] = xform(p_transform.elements[2]);
columns[2] = xform(p_transform.columns[2]);
real_t x0, x1, y0, y1;
x0 = tdotx(p_transform.elements[0]);
x1 = tdoty(p_transform.elements[0]);
y0 = tdotx(p_transform.elements[1]);
y1 = tdoty(p_transform.elements[1]);
x0 = tdotx(p_transform.columns[0]);
x1 = tdoty(p_transform.columns[0]);
y0 = tdotx(p_transform.columns[1]);
y1 = tdoty(p_transform.columns[1]);
elements[0][0] = x0;
elements[0][1] = x1;
elements[1][0] = y0;
elements[1][1] = y1;
columns[0][0] = x0;
columns[0][1] = x1;
columns[1][0] = y0;
columns[1][1] = y1;
}
Transform2D Transform2D::operator*(const Transform2D &p_transform) const {
@ -231,7 +231,7 @@ Transform2D Transform2D::basis_scaled(const Size2 &p_scale) const {
Transform2D Transform2D::untranslated() const {
Transform2D copy = *this;
copy.elements[2] = Vector2();
copy.columns[2] = Vector2();
return copy;
}
@ -248,7 +248,7 @@ Transform2D Transform2D::rotated(const real_t p_phi) const {
}
real_t Transform2D::basis_determinant() const {
return elements[0].x * elements[1].y - elements[0].y * elements[1].x;
return columns[0].x * columns[1].y - columns[0].y * columns[1].x;
}
Transform2D Transform2D::interpolate_with(const Transform2D &p_transform, const real_t p_c) const {
@ -287,9 +287,9 @@ Transform2D Transform2D::interpolate_with(const Transform2D &p_transform, const
}
void Transform2D::operator*=(const real_t p_val) {
elements[0] *= p_val;
elements[1] *= p_val;
elements[2] *= p_val;
columns[0] *= p_val;
columns[1] *= p_val;
columns[2] *= p_val;
}
Transform2D Transform2D::operator*(const real_t p_val) const {
@ -299,7 +299,7 @@ Transform2D Transform2D::operator*(const real_t p_val) const {
}
Transform2D::operator String() const {
return "[X: " + elements[0].operator String() +
", Y: " + elements[1].operator String() +
", O: " + elements[2].operator String() + "]";
return "[X: " + columns[0].operator String() +
", Y: " + columns[1].operator String() +
", O: " + columns[2].operator String() + "]";
}

View file

@ -39,32 +39,32 @@
class String;
struct _NO_DISCARD_ Transform2D {
// Warning #1: basis of Transform2D is stored differently from Basis. In terms of elements array, the basis matrix looks like "on paper":
// M = (elements[0][0] elements[1][0])
// (elements[0][1] elements[1][1])
// This is such that the columns, which can be interpreted as basis vectors of the coordinate system "painted" on the object, can be accessed as elements[i].
// Note that this is the opposite of the indices in mathematical texts, meaning: $M_{12}$ in a math book corresponds to elements[1][0] here.
// Warning #1: basis of Transform2D is stored differently from Basis. In terms of columns array, the basis matrix looks like "on paper":
// M = (columns[0][0] columns[1][0])
// (columns[0][1] columns[1][1])
// This is such that the columns, which can be interpreted as basis vectors of the coordinate system "painted" on the object, can be accessed as columns[i].
// Note that this is the opposite of the indices in mathematical texts, meaning: $M_{12}$ in a math book corresponds to columns[1][0] here.
// This requires additional care when working with explicit indices.
// See https://en.wikipedia.org/wiki/Row-_and_column-major_order for further reading.
// Warning #2: 2D be aware that unlike 3D code, 2D code uses a left-handed coordinate system: Y-axis points down,
// and angle is measure from +X to +Y in a clockwise-fashion.
Vector2 elements[3];
Vector2 columns[3];
_FORCE_INLINE_ real_t tdotx(const Vector2 &v) const { return elements[0][0] * v.x + elements[1][0] * v.y; }
_FORCE_INLINE_ real_t tdoty(const Vector2 &v) const { return elements[0][1] * v.x + elements[1][1] * v.y; }
_FORCE_INLINE_ real_t tdotx(const Vector2 &v) const { return columns[0][0] * v.x + columns[1][0] * v.y; }
_FORCE_INLINE_ real_t tdoty(const Vector2 &v) const { return columns[0][1] * v.x + columns[1][1] * v.y; }
const Vector2 &operator[](int p_idx) const { return elements[p_idx]; }
Vector2 &operator[](int p_idx) { return elements[p_idx]; }
const Vector2 &operator[](int p_idx) const { return columns[p_idx]; }
Vector2 &operator[](int p_idx) { return columns[p_idx]; }
_FORCE_INLINE_ Vector2 get_axis(int p_axis) const {
ERR_FAIL_INDEX_V(p_axis, 3, Vector2());
return elements[p_axis];
return columns[p_axis];
}
_FORCE_INLINE_ void set_axis(int p_axis, const Vector2 &p_vec) {
ERR_FAIL_INDEX(p_axis, 3);
elements[p_axis] = p_vec;
columns[p_axis] = p_vec;
}
void invert();
@ -91,8 +91,8 @@ struct _NO_DISCARD_ Transform2D {
Size2 get_scale() const;
void set_scale(const Size2 &p_scale);
_FORCE_INLINE_ const Vector2 &get_origin() const { return elements[2]; }
_FORCE_INLINE_ void set_origin(const Vector2 &p_origin) { elements[2] = p_origin; }
_FORCE_INLINE_ const Vector2 &get_origin() const { return columns[2]; }
_FORCE_INLINE_ void set_origin(const Vector2 &p_origin) { columns[2] = p_origin; }
Transform2D scaled(const Size2 &p_scale) const;
Transform2D basis_scaled(const Size2 &p_scale) const;
@ -129,18 +129,18 @@ struct _NO_DISCARD_ Transform2D {
operator String() const;
Transform2D(const real_t xx, const real_t xy, const real_t yx, const real_t yy, const real_t ox, const real_t oy) {
elements[0][0] = xx;
elements[0][1] = xy;
elements[1][0] = yx;
elements[1][1] = yy;
elements[2][0] = ox;
elements[2][1] = oy;
columns[0][0] = xx;
columns[0][1] = xy;
columns[1][0] = yx;
columns[1][1] = yy;
columns[2][0] = ox;
columns[2][1] = oy;
}
Transform2D(const Vector2 &p_x, const Vector2 &p_y, const Vector2 &p_origin) {
elements[0] = p_x;
elements[1] = p_y;
elements[2] = p_origin;
columns[0] = p_x;
columns[1] = p_y;
columns[2] = p_origin;
}
Transform2D(const real_t p_rot, const Vector2 &p_pos);
@ -148,8 +148,8 @@ struct _NO_DISCARD_ Transform2D {
Transform2D(const real_t p_rot, const Size2 &p_scale, const real_t p_skew, const Vector2 &p_pos);
Transform2D() {
elements[0][0] = 1.0;
elements[1][1] = 1.0;
columns[0][0] = 1.0;
columns[1][1] = 1.0;
}
};
@ -161,28 +161,28 @@ Vector2 Transform2D::basis_xform(const Vector2 &p_vec) const {
Vector2 Transform2D::basis_xform_inv(const Vector2 &p_vec) const {
return Vector2(
elements[0].dot(p_vec),
elements[1].dot(p_vec));
columns[0].dot(p_vec),
columns[1].dot(p_vec));
}
Vector2 Transform2D::xform(const Vector2 &p_vec) const {
return Vector2(
tdotx(p_vec),
tdoty(p_vec)) +
elements[2];
columns[2];
}
Vector2 Transform2D::xform_inv(const Vector2 &p_vec) const {
Vector2 v = p_vec - elements[2];
Vector2 v = p_vec - columns[2];
return Vector2(
elements[0].dot(v),
elements[1].dot(v));
columns[0].dot(v),
columns[1].dot(v));
}
Rect2 Transform2D::xform(const Rect2 &p_rect) const {
Vector2 x = elements[0] * p_rect.size.x;
Vector2 y = elements[1] * p_rect.size.y;
Vector2 x = columns[0] * p_rect.size.x;
Vector2 y = columns[1] * p_rect.size.y;
Vector2 pos = xform(p_rect.position);
Rect2 new_rect;
@ -194,17 +194,17 @@ Rect2 Transform2D::xform(const Rect2 &p_rect) const {
}
void Transform2D::set_rotation_and_scale(const real_t p_rot, const Size2 &p_scale) {
elements[0][0] = Math::cos(p_rot) * p_scale.x;
elements[1][1] = Math::cos(p_rot) * p_scale.y;
elements[1][0] = -Math::sin(p_rot) * p_scale.y;
elements[0][1] = Math::sin(p_rot) * p_scale.x;
columns[0][0] = Math::cos(p_rot) * p_scale.x;
columns[1][1] = Math::cos(p_rot) * p_scale.y;
columns[1][0] = -Math::sin(p_rot) * p_scale.y;
columns[0][1] = Math::sin(p_rot) * p_scale.x;
}
void Transform2D::set_rotation_scale_and_skew(const real_t p_rot, const Size2 &p_scale, const real_t p_skew) {
elements[0][0] = Math::cos(p_rot) * p_scale.x;
elements[1][1] = Math::cos(p_rot + p_skew) * p_scale.y;
elements[1][0] = -Math::sin(p_rot + p_skew) * p_scale.y;
elements[0][1] = Math::sin(p_rot) * p_scale.x;
columns[0][0] = Math::cos(p_rot) * p_scale.x;
columns[1][1] = Math::cos(p_rot + p_skew) * p_scale.y;
columns[1][0] = -Math::sin(p_rot + p_skew) * p_scale.y;
columns[0][1] = Math::sin(p_rot) * p_scale.x;
}
Rect2 Transform2D::xform_inv(const Rect2 &p_rect) const {

View file

@ -1908,12 +1908,12 @@ Variant::operator Transform3D() const {
} else if (type == TRANSFORM2D) {
const Transform2D &t = *_data._transform2d;
Transform3D m;
m.basis.elements[0][0] = t.elements[0][0];
m.basis.elements[1][0] = t.elements[0][1];
m.basis.elements[0][1] = t.elements[1][0];
m.basis.elements[1][1] = t.elements[1][1];
m.origin[0] = t.elements[2][0];
m.origin[1] = t.elements[2][1];
m.basis.elements[0][0] = t.columns[0][0];
m.basis.elements[1][0] = t.columns[0][1];
m.basis.elements[0][1] = t.columns[1][0];
m.basis.elements[1][1] = t.columns[1][1];
m.origin[0] = t.columns[2][0];
m.origin[1] = t.columns[2][1];
return m;
} else {
return Transform3D();
@ -1926,12 +1926,12 @@ Variant::operator Transform2D() const {
} else if (type == TRANSFORM3D) {
const Transform3D &t = *_data._transform3d;
Transform2D m;
m.elements[0][0] = t.basis.elements[0][0];
m.elements[0][1] = t.basis.elements[1][0];
m.elements[1][0] = t.basis.elements[0][1];
m.elements[1][1] = t.basis.elements[1][1];
m.elements[2][0] = t.origin[0];
m.elements[2][1] = t.origin[1];
m.columns[0][0] = t.basis.elements[0][0];
m.columns[0][1] = t.basis.elements[1][0];
m.columns[1][0] = t.basis.elements[0][1];
m.columns[1][1] = t.basis.elements[1][1];
m.columns[2][0] = t.origin[0];
m.columns[2][1] = t.origin[1];
return m;
} else {
return Transform2D();
@ -2790,7 +2790,7 @@ uint32_t Variant::recursive_hash(int recursion_count) const {
uint32_t hash = 5831;
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 2; j++) {
hash = hash_djb2_one_float(_data._transform2d->elements[i][j], hash);
hash = hash_djb2_one_float(_data._transform2d->columns[i][j], hash);
}
}
@ -3112,7 +3112,7 @@ bool Variant::hash_compare(const Variant &p_variant, int recursion_count) const
Transform2D *r = p_variant._data._transform2d;
for (int i = 0; i < 3; i++) {
if (!(hash_compare_vector2(l->elements[i], r->elements[i]))) {
if (!(hash_compare_vector2(l->columns[i], r->columns[i]))) {
return false;
}
}

View file

@ -1555,7 +1555,7 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
if (i != 0 || j != 0) {
s += ", ";
}
s += rtos_fix(m3.elements[i][j]);
s += rtos_fix(m3.columns[i][j]);
}
}

View file

@ -789,7 +789,7 @@ INDEXED_SETGET_STRUCT_BULTIN_NUMERIC(Vector3i, int64_t, int32_t, 3)
INDEXED_SETGET_STRUCT_BULTIN_NUMERIC(Quaternion, double, real_t, 4)
INDEXED_SETGET_STRUCT_BULTIN_NUMERIC(Color, double, float, 4)
INDEXED_SETGET_STRUCT_BULTIN_ACCESSOR(Transform2D, Vector2, .elements, 3)
INDEXED_SETGET_STRUCT_BULTIN_ACCESSOR(Transform2D, Vector2, .columns, 3)
INDEXED_SETGET_STRUCT_BULTIN_FUNC(Basis, Vector3, set_axis, get_axis, 3)
INDEXED_SETGET_STRUCT_TYPED_NUMERIC(PackedByteArray, int64_t, uint8_t)

View file

@ -293,9 +293,9 @@ SETGET_STRUCT(AABB, Vector3, position)
SETGET_STRUCT(AABB, Vector3, size)
SETGET_STRUCT_FUNC(AABB, Vector3, end, set_end, get_end)
SETGET_STRUCT_CUSTOM(Transform2D, Vector2, x, elements[0])
SETGET_STRUCT_CUSTOM(Transform2D, Vector2, y, elements[1])
SETGET_STRUCT_CUSTOM(Transform2D, Vector2, origin, elements[2])
SETGET_STRUCT_CUSTOM(Transform2D, Vector2, x, columns[0])
SETGET_STRUCT_CUSTOM(Transform2D, Vector2, y, columns[1])
SETGET_STRUCT_CUSTOM(Transform2D, Vector2, origin, columns[2])
SETGET_NUMBER_STRUCT_CUSTOM(Plane, double, x, normal.x)
SETGET_NUMBER_STRUCT_CUSTOM(Plane, double, y, normal.y)

View file

@ -57,43 +57,43 @@
//};
void RasterizerCanvasGLES3::_update_transform_2d_to_mat4(const Transform2D &p_transform, float *p_mat4) {
p_mat4[0] = p_transform.elements[0][0];
p_mat4[1] = p_transform.elements[0][1];
p_mat4[0] = p_transform.columns[0][0];
p_mat4[1] = p_transform.columns[0][1];
p_mat4[2] = 0;
p_mat4[3] = 0;
p_mat4[4] = p_transform.elements[1][0];
p_mat4[5] = p_transform.elements[1][1];
p_mat4[4] = p_transform.columns[1][0];
p_mat4[5] = p_transform.columns[1][1];
p_mat4[6] = 0;
p_mat4[7] = 0;
p_mat4[8] = 0;
p_mat4[9] = 0;
p_mat4[10] = 1;
p_mat4[11] = 0;
p_mat4[12] = p_transform.elements[2][0];
p_mat4[13] = p_transform.elements[2][1];
p_mat4[12] = p_transform.columns[2][0];
p_mat4[13] = p_transform.columns[2][1];
p_mat4[14] = 0;
p_mat4[15] = 1;
}
void RasterizerCanvasGLES3::_update_transform_2d_to_mat2x4(const Transform2D &p_transform, float *p_mat2x4) {
p_mat2x4[0] = p_transform.elements[0][0];
p_mat2x4[1] = p_transform.elements[1][0];
p_mat2x4[0] = p_transform.columns[0][0];
p_mat2x4[1] = p_transform.columns[1][0];
p_mat2x4[2] = 0;
p_mat2x4[3] = p_transform.elements[2][0];
p_mat2x4[3] = p_transform.columns[2][0];
p_mat2x4[4] = p_transform.elements[0][1];
p_mat2x4[5] = p_transform.elements[1][1];
p_mat2x4[4] = p_transform.columns[0][1];
p_mat2x4[5] = p_transform.columns[1][1];
p_mat2x4[6] = 0;
p_mat2x4[7] = p_transform.elements[2][1];
p_mat2x4[7] = p_transform.columns[2][1];
}
void RasterizerCanvasGLES3::_update_transform_2d_to_mat2x3(const Transform2D &p_transform, float *p_mat2x3) {
p_mat2x3[0] = p_transform.elements[0][0];
p_mat2x3[1] = p_transform.elements[0][1];
p_mat2x3[2] = p_transform.elements[1][0];
p_mat2x3[3] = p_transform.elements[1][1];
p_mat2x3[4] = p_transform.elements[2][0];
p_mat2x3[5] = p_transform.elements[2][1];
p_mat2x3[0] = p_transform.columns[0][0];
p_mat2x3[1] = p_transform.columns[0][1];
p_mat2x3[2] = p_transform.columns[1][0];
p_mat2x3[3] = p_transform.columns[1][1];
p_mat2x3[4] = p_transform.columns[2][0];
p_mat2x3[5] = p_transform.columns[2][1];
}
void RasterizerCanvasGLES3::_update_transform_to_mat4(const Transform3D &p_transform, float *p_mat4) {
@ -142,9 +142,9 @@ void RasterizerCanvasGLES3::canvas_render_items(RID p_to_render_target, Item *p_
_update_transform_2d_to_mat4(p_canvas_transform, state_buffer.canvas_transform);
Transform2D normal_transform = p_canvas_transform;
normal_transform.elements[0].normalize();
normal_transform.elements[1].normalize();
normal_transform.elements[2] = Vector2();
normal_transform.columns[0].normalize();
normal_transform.columns[1].normalize();
normal_transform.columns[2] = Vector2();
_update_transform_2d_to_mat4(normal_transform, state_buffer.canvas_normal_transform);
state_buffer.canvas_modulate[0] = p_modulate.r;

View file

@ -2,6 +2,9 @@
Import("env")
env.Depends("#drivers/gles3/shaders/copy.glsl.gen.h", "#core/math/basis.h")
env.Depends("#drivers/gles3/shaders/copy.glsl.gen.h", "#core/math/transform_2d.h")
if "GLES3_GLSL" in env["BUILDERS"]:
env.GLES3_GLSL("canvas.glsl")
env.GLES3_GLSL("copy.glsl")

View file

@ -524,13 +524,13 @@ _FORCE_INLINE_ static void _fill_std140_variant_ubo_value(ShaderLanguage::DataTy
Transform2D v = value;
//in std140 members of mat2 are treated as vec4s
gui[0] = v.elements[0][0];
gui[1] = v.elements[0][1];
gui[0] = v.columns[0][0];
gui[1] = v.columns[0][1];
gui[2] = 0; // ignored
gui[3] = 0; // ignored
gui[4] = v.elements[1][0];
gui[5] = v.elements[1][1];
gui[4] = v.columns[1][0];
gui[5] = v.columns[1][1];
gui[6] = 0; // ignored
gui[7] = 0; // ignored
}
@ -1922,18 +1922,18 @@ void MaterialStorage::_global_variable_store_in_buffer(int32_t p_index, RS::Glob
case RS::GLOBAL_VAR_TYPE_TRANSFORM_2D: {
GlobalVariables::Value *bv = &global_variables.buffer_values[p_index];
Transform2D v = p_value;
bv[0].x = v.elements[0][0];
bv[0].y = v.elements[0][1];
bv[0].x = v.columns[0][0];
bv[0].y = v.columns[0][1];
bv[0].z = 0;
bv[0].w = 0;
bv[1].x = v.elements[1][0];
bv[1].y = v.elements[1][1];
bv[1].x = v.columns[1][0];
bv[1].y = v.columns[1][1];
bv[1].z = 0;
bv[1].w = 0;
bv[2].x = v.elements[2][0];
bv[2].y = v.elements[2][1];
bv[2].x = v.columns[2][0];
bv[2].y = v.columns[2][1];
bv[2].z = 1;
bv[2].w = 0;

View file

@ -1051,14 +1051,14 @@ void MeshStorage::multimesh_instance_set_transform_2d(RID p_multimesh, int p_ind
float *dataptr = w + p_index * multimesh->stride_cache;
dataptr[0] = p_transform.elements[0][0];
dataptr[1] = p_transform.elements[1][0];
dataptr[0] = p_transform.columns[0][0];
dataptr[1] = p_transform.columns[1][0];
dataptr[2] = 0;
dataptr[3] = p_transform.elements[2][0];
dataptr[4] = p_transform.elements[0][1];
dataptr[5] = p_transform.elements[1][1];
dataptr[3] = p_transform.columns[2][0];
dataptr[4] = p_transform.columns[0][1];
dataptr[5] = p_transform.columns[1][1];
dataptr[6] = 0;
dataptr[7] = p_transform.elements[2][1];
dataptr[7] = p_transform.columns[2][1];
}
_multimesh_mark_dirty(multimesh, p_index, true);
@ -1169,12 +1169,12 @@ Transform2D MeshStorage::multimesh_instance_get_transform_2d(RID p_multimesh, in
const float *dataptr = r + p_index * multimesh->stride_cache;
t.elements[0][0] = dataptr[0];
t.elements[1][0] = dataptr[1];
t.elements[2][0] = dataptr[3];
t.elements[0][1] = dataptr[4];
t.elements[1][1] = dataptr[5];
t.elements[2][1] = dataptr[7];
t.columns[0][0] = dataptr[0];
t.columns[1][0] = dataptr[1];
t.columns[2][0] = dataptr[3];
t.columns[0][1] = dataptr[4];
t.columns[1][1] = dataptr[5];
t.columns[2][1] = dataptr[7];
}
return t;

View file

@ -268,12 +268,12 @@ int DebugAdapterProtocol::parse_variant(const Variant &p_var) {
x.type = type_vec2;
y.type = type_vec2;
origin.type = type_vec2;
x.value = transform.elements[0];
y.value = transform.elements[1];
origin.value = transform.elements[2];
x.variablesReference = parse_variant(transform.elements[0]);
y.variablesReference = parse_variant(transform.elements[1]);
origin.variablesReference = parse_variant(transform.elements[2]);
x.value = transform.columns[0];
y.value = transform.columns[1];
origin.value = transform.columns[2];
x.variablesReference = parse_variant(transform.columns[0]);
y.variablesReference = parse_variant(transform.columns[1]);
origin.variablesReference = parse_variant(transform.columns[2]);
Array arr;
arr.push_back(x.to_json());

View file

@ -812,7 +812,7 @@ void ScriptEditorDebugger::_notification(int p_what) {
Transform2D transform;
transform.scale_basis(Size2(zoom, zoom));
transform.elements[2] = -offset * zoom;
transform.columns[2] = -offset * zoom;
Array msg;
msg.push_back(transform);

View file

@ -521,9 +521,9 @@ void AnimationNodeStateMachineEditor::_connection_draw(const Vector2 &p_from, co
Ref<Texture2D> icon = icons[p_mode + (p_auto_advance ? 3 : 0)];
Transform2D xf;
xf.elements[0] = (p_to - p_from).normalized();
xf.elements[1] = xf.elements[0].orthogonal();
xf.elements[2] = (p_from + p_to) * 0.5 - xf.elements[1] * icon->get_height() * 0.5 - xf.elements[0] * icon->get_height() * 0.5;
xf.columns[0] = (p_to - p_from).normalized();
xf.columns[1] = xf.columns[0].orthogonal();
xf.columns[2] = (p_from + p_to) * 0.5 - xf.columns[1] * icon->get_height() * 0.5 - xf.columns[0] * icon->get_height() * 0.5;
state_machine_draw->draw_set_transform_matrix(xf);
state_machine_draw->draw_texture(icon, Vector2(), icon_color);

View file

@ -3675,7 +3675,7 @@ void CanvasItemEditor::_draw_viewport() {
// Update the transform
transform = Transform2D();
transform.scale_basis(Size2(zoom, zoom));
transform.elements[2] = -view_offset * zoom;
transform.columns[2] = -view_offset * zoom;
EditorNode::get_singleton()->get_scene_root()->set_global_canvas_transform(transform);
// hide/show buttons depending on the selection

View file

@ -455,7 +455,7 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) {
}
Transform2D mtx;
mtx.elements[2] = -uv_draw_ofs;
mtx.columns[2] = -uv_draw_ofs;
mtx.scale_basis(Vector2(uv_draw_zoom, uv_draw_zoom));
Ref<InputEventMouseButton> mb = p_input;
@ -970,7 +970,7 @@ void Polygon2DEditor::_uv_draw() {
String warning;
Transform2D mtx;
mtx.elements[2] = -uv_draw_ofs;
mtx.columns[2] = -uv_draw_ofs;
mtx.scale_basis(Vector2(uv_draw_zoom, uv_draw_zoom));
RS::get_singleton()->canvas_item_add_set_transform(uv_edit_draw->get_canvas_item(), mtx);

View file

@ -78,7 +78,7 @@ void TextureRegionEditor::_region_draw() {
}
Transform2D mtx;
mtx.elements[2] = -draw_ofs * draw_zoom;
mtx.columns[2] = -draw_ofs * draw_zoom;
mtx.scale_basis(Vector2(draw_zoom, draw_zoom));
RS::get_singleton()->canvas_item_add_set_transform(edit_draw->get_canvas_item(), mtx);
@ -267,7 +267,7 @@ void TextureRegionEditor::_region_input(const Ref<InputEvent> &p_input) {
}
Transform2D mtx;
mtx.elements[2] = -draw_ofs * draw_zoom;
mtx.columns[2] = -draw_ofs * draw_zoom;
mtx.scale_basis(Vector2(draw_zoom, draw_zoom));
const real_t handle_radius = 8 * EDSCALE;

View file

@ -768,7 +768,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
Transform2D basis = v;
for (int i = 0; i < 6; i++) {
value_editor[i]->set_text(String::num(basis.elements[i / 2][i % 2]));
value_editor[i]->set_text(String::num(basis.columns[i / 2][i % 2]));
}
} break;
@ -1568,7 +1568,7 @@ void CustomPropertyEditor::_modified(String p_string) {
case Variant::TRANSFORM2D: {
Transform2D m;
for (int i = 0; i < 6; i++) {
m.elements[i / 2][i % 2] = _parse_real_expression(value_editor[i]->get_text());
m.columns[i / 2][i % 2] = _parse_real_expression(value_editor[i]->get_text());
}
v = m;

View file

@ -410,20 +410,20 @@ def build_gles3_header(filename, include, class_suffix, output_attribs):
const Transform2D &tr = p_transform;
GLfloat matrix[16]={ /* build a 16x16 matrix */
(GLfloat)tr.elements[0][0],
(GLfloat)tr.elements[0][1],
(GLfloat)tr.columns[0][0],
(GLfloat)tr.columns[0][1],
(GLfloat)0,
(GLfloat)0,
(GLfloat)tr.elements[1][0],
(GLfloat)tr.elements[1][1],
(GLfloat)tr.columns[1][0],
(GLfloat)tr.columns[1][1],
(GLfloat)0,
(GLfloat)0,
(GLfloat)0,
(GLfloat)0,
(GLfloat)1,
(GLfloat)0,
(GLfloat)tr.elements[2][0],
(GLfloat)tr.elements[2][1],
(GLfloat)tr.columns[2][0],
(GLfloat)tr.columns[2][1],
(GLfloat)0,
(GLfloat)1
};

View file

@ -3202,7 +3202,7 @@ bool BindingsGenerator::_arg_default_value_from_variant(const Variant &p_val, Ar
if (transform == Transform2D()) {
r_iarg.default_argument = "Transform2D.Identity";
} else {
r_iarg.default_argument = "new Transform2D(new Vector2" + transform.elements[0].operator String() + ", new Vector2" + transform.elements[1].operator String() + ", new Vector2" + transform.elements[2].operator String() + ")";
r_iarg.default_argument = "new Transform2D(new Vector2" + transform.columns[0].operator String() + ", new Vector2" + transform.columns[1].operator String() + ", new Vector2" + transform.columns[2].operator String() + ")";
}
r_iarg.def_param_mode = ArgumentInterface::NULLABLE_VAL;
} break;

View file

@ -367,9 +367,9 @@ struct M_Transform2D {
static _FORCE_INLINE_ M_Transform2D convert_from(const Transform2D &p_from) {
M_Transform2D ret = {
M_Vector2::convert_from(p_from.elements[0]),
M_Vector2::convert_from(p_from.elements[1]),
M_Vector2::convert_from(p_from.elements[2])
M_Vector2::convert_from(p_from.columns[0]),
M_Vector2::convert_from(p_from.columns[1]),
M_Vector2::convert_from(p_from.columns[2])
};
return ret;
}

View file

@ -1329,7 +1329,7 @@ _FORCE_INLINE_ bool TextServerAdvanced::_ensure_cache_for_size(FontDataAdvanced
fd->underline_position = (-FT_MulFix(fd->face->underline_position, fd->face->size->metrics.y_scale) / 64.0) / fd->oversampling * fd->scale;
fd->underline_thickness = (FT_MulFix(fd->face->underline_thickness, fd->face->size->metrics.y_scale) / 64.0) / fd->oversampling * fd->scale;
hb_font_set_synthetic_slant(fd->hb_handle, p_font_data->transform.elements[0][1]);
hb_font_set_synthetic_slant(fd->hb_handle, p_font_data->transform.columns[0][1]);
if (!p_font_data->face_init) {
// Get style flags and name.

View file

@ -969,13 +969,13 @@ void CPUParticles2D::_particles_process(double p_delta) {
if (particle_flags[PARTICLE_FLAG_ALIGN_Y_TO_VELOCITY]) {
if (p.velocity.length() > 0.0) {
p.transform.elements[1] = p.velocity.normalized();
p.transform.elements[0] = p.transform.elements[1].orthogonal();
p.transform.columns[1] = p.velocity.normalized();
p.transform.columns[0] = p.transform.columns[1].orthogonal();
}
} else {
p.transform.elements[0] = Vector2(Math::cos(p.rotation), -Math::sin(p.rotation));
p.transform.elements[1] = Vector2(Math::sin(p.rotation), Math::cos(p.rotation));
p.transform.columns[0] = Vector2(Math::cos(p.rotation), -Math::sin(p.rotation));
p.transform.columns[1] = Vector2(Math::sin(p.rotation), Math::cos(p.rotation));
}
//scale by scale
@ -986,8 +986,8 @@ void CPUParticles2D::_particles_process(double p_delta) {
if (base_scale.y < 0.00001) {
base_scale.y = 0.00001;
}
p.transform.elements[0] *= base_scale.x;
p.transform.elements[1] *= base_scale.y;
p.transform.columns[0] *= base_scale.x;
p.transform.columns[1] *= base_scale.y;
p.transform[2] += p.velocity * local_delta;
}
@ -1029,14 +1029,14 @@ void CPUParticles2D::_update_particle_data_buffer() {
}
if (r[idx].active) {
ptr[0] = t.elements[0][0];
ptr[1] = t.elements[1][0];
ptr[0] = t.columns[0][0];
ptr[1] = t.columns[1][0];
ptr[2] = 0;
ptr[3] = t.elements[2][0];
ptr[4] = t.elements[0][1];
ptr[5] = t.elements[1][1];
ptr[3] = t.columns[2][0];
ptr[4] = t.columns[0][1];
ptr[5] = t.columns[1][1];
ptr[6] = 0;
ptr[7] = t.elements[2][1];
ptr[7] = t.columns[2][1];
} else {
memset(ptr, 0, sizeof(float) * 8);
@ -1137,14 +1137,14 @@ void CPUParticles2D::_notification(int p_what) {
Transform2D t = inv_emission_transform * r[i].transform;
if (r[i].active) {
ptr[0] = t.elements[0][0];
ptr[1] = t.elements[1][0];
ptr[0] = t.columns[0][0];
ptr[1] = t.columns[1][0];
ptr[2] = 0;
ptr[3] = t.elements[2][0];
ptr[4] = t.elements[0][1];
ptr[5] = t.elements[1][1];
ptr[3] = t.columns[2][0];
ptr[4] = t.columns[0][1];
ptr[5] = t.columns[1][1];
ptr[6] = 0;
ptr[7] = t.elements[2][1];
ptr[7] = t.columns[2][1];
} else {
memset(ptr, 0, sizeof(float) * 8);

View file

@ -111,7 +111,7 @@ void Node2D::_edit_set_rect(const Rect2 &p_edit_rect) {
#endif
void Node2D::_update_xform_values() {
position = transform.elements[2];
position = transform.columns[2];
rotation = transform.get_rotation();
scale = transform.get_scale();
skew = transform.get_skew();
@ -120,7 +120,7 @@ void Node2D::_update_xform_values() {
void Node2D::_update_transform() {
transform.set_rotation_scale_and_skew(rotation, scale, skew);
transform.elements[2] = position;
transform.columns[2] = position;
RenderingServer::get_singleton()->canvas_item_set_transform(get_canvas_item(), transform);

View file

@ -123,7 +123,7 @@ bool PhysicsBody2D::move_and_collide(const PhysicsServer2D::MotionParameters &p_
if (!p_test_only) {
Transform2D gt = p_parameters.from;
gt.elements[2] += r_result.travel;
gt.columns[2] += r_result.travel;
set_global_transform(gt);
}
@ -928,7 +928,7 @@ TypedArray<String> RigidDynamicBody2D::get_configuration_warnings() const {
TypedArray<String> warnings = CollisionObject2D::get_configuration_warnings();
if (ABS(t.elements[0].length() - 1.0) > 0.05 || ABS(t.elements[1].length() - 1.0) > 0.05) {
if (ABS(t.columns[0].length() - 1.0) > 0.05 || ABS(t.columns[1].length() - 1.0) > 0.05) {
warnings.push_back(RTR("Size changes to RigidDynamicBody2D will be overridden by the physics engine when running.\nChange the size in children collision shapes instead."));
}
@ -1110,7 +1110,7 @@ bool CharacterBody2D::move_and_slide() {
Vector2 current_platform_velocity = platform_velocity;
Transform2D gt = get_global_transform();
previous_position = gt.elements[2];
previous_position = gt.columns[2];
if ((on_floor || on_wall) && platform_rid.is_valid()) {
bool excluded = false;
@ -1123,7 +1123,7 @@ bool CharacterBody2D::move_and_slide() {
//this approach makes sure there is less delay between the actual body velocity and the one we saved
PhysicsDirectBodyState2D *bs = PhysicsServer2D::get_singleton()->body_get_direct_state(platform_rid);
if (bs) {
Vector2 local_position = gt.elements[2] - bs->get_transform().elements[2];
Vector2 local_position = gt.columns[2] - bs->get_transform().columns[2];
current_platform_velocity = bs->get_velocity_at_local_position(local_position);
} else {
// Body is removed or destroyed, invalidate floor.
@ -1204,7 +1204,7 @@ void CharacterBody2D::_move_and_slide_grounded(double p_delta, bool p_was_on_flo
for (int iteration = 0; iteration < max_slides; ++iteration) {
PhysicsServer2D::MotionParameters parameters(get_global_transform(), motion, margin);
Vector2 prev_position = parameters.from.elements[2];
Vector2 prev_position = parameters.from.columns[2];
PhysicsServer2D::MotionResult result;
bool collided = move_and_collide(parameters, result, false, !sliding_enabled);
@ -1231,7 +1231,7 @@ void CharacterBody2D::_move_and_slide_grounded(double p_delta, bool p_was_on_flo
if (on_floor && floor_stop_on_slope && (velocity.normalized() + up_direction).length() < 0.01) {
Transform2D gt = get_global_transform();
if (result.travel.length() <= margin + CMP_EPSILON) {
gt.elements[2] -= result.travel;
gt.columns[2] -= result.travel;
}
set_global_transform(gt);
velocity = Vector2();
@ -1253,7 +1253,7 @@ void CharacterBody2D::_move_and_slide_grounded(double p_delta, bool p_was_on_flo
if (result.travel.length() <= margin + CMP_EPSILON) {
// Cancels the motion.
Transform2D gt = get_global_transform();
gt.elements[2] -= result.travel;
gt.columns[2] -= result.travel;
set_global_transform(gt);
}
// Determines if you are on the ground.
@ -1312,7 +1312,7 @@ void CharacterBody2D::_move_and_slide_grounded(double p_delta, bool p_was_on_flo
can_apply_constant_speed = false;
sliding_enabled = true;
Transform2D gt = get_global_transform();
gt.elements[2] = prev_position;
gt.columns[2] = prev_position;
set_global_transform(gt);
Vector2 motion_slide_norm = motion.slide(prev_floor_normal).normalized();
@ -1424,7 +1424,7 @@ void CharacterBody2D::_snap_on_floor(bool was_on_floor, bool vel_dir_facing_up)
}
}
parameters.from.elements[2] += result.travel;
parameters.from.columns[2] += result.travel;
set_global_transform(parameters.from);
}
}
@ -1520,7 +1520,7 @@ const Vector2 &CharacterBody2D::get_last_motion() const {
}
Vector2 CharacterBody2D::get_position_delta() const {
return get_global_transform().elements[2] - previous_position;
return get_global_transform().columns[2] - previous_position;
}
const Vector2 &CharacterBody2D::get_real_velocity() const {

View file

@ -451,12 +451,12 @@ Variant Tween::interpolate_variant(Variant p_initial_val, Variant p_delta_val, f
Transform2D d = p_delta_val;
Transform2D r;
APPLY_EQUATION(elements[0][0]);
APPLY_EQUATION(elements[0][1]);
APPLY_EQUATION(elements[1][0]);
APPLY_EQUATION(elements[1][1]);
APPLY_EQUATION(elements[2][0]);
APPLY_EQUATION(elements[2][1]);
APPLY_EQUATION(columns[0][0]);
APPLY_EQUATION(columns[0][1]);
APPLY_EQUATION(columns[1][0]);
APPLY_EQUATION(columns[1][1]);
APPLY_EQUATION(columns[2][0]);
APPLY_EQUATION(columns[2][1]);
return r;
}
@ -565,12 +565,12 @@ Variant Tween::calculate_delta_value(Variant p_intial_val, Variant p_final_val)
case Variant::TRANSFORM2D: {
Transform2D i = p_intial_val;
Transform2D f = p_final_val;
return Transform2D(f.elements[0][0] - i.elements[0][0],
f.elements[0][1] - i.elements[0][1],
f.elements[1][0] - i.elements[1][0],
f.elements[1][1] - i.elements[1][1],
f.elements[2][0] - i.elements[2][0],
f.elements[2][1] - i.elements[2][1]);
return Transform2D(f.columns[0][0] - i.columns[0][0],
f.columns[0][1] - i.columns[0][1],
f.columns[1][0] - i.columns[1][0],
f.columns[1][1] - i.columns[1][1],
f.columns[2][0] - i.columns[2][0],
f.columns[2][1] - i.columns[2][1]);
}
case Variant::AABB: {

View file

@ -96,7 +96,7 @@ void CanvasLayer::_update_xform() {
}
void CanvasLayer::_update_locrotscale() {
ofs = transform.elements[2];
ofs = transform.columns[2];
rot = transform.get_rotation();
scale = transform.get_scale();
locrotscale_dirty = false;

View file

@ -1104,7 +1104,7 @@ Transform2D Viewport::_get_input_pre_xform() const {
Transform2D pre_xf;
if (to_screen_rect.size.x != 0 && to_screen_rect.size.y != 0) {
pre_xf.elements[2] = -to_screen_rect.position;
pre_xf.columns[2] = -to_screen_rect.position;
pre_xf.scale(Vector2(size) / to_screen_rect.size);
}

View file

@ -101,9 +101,9 @@ void MultiMesh::_set_transform_2d_array(const Vector<Vector2> &p_array) {
for (int i = 0; i < len / 3; i++) {
Transform2D t;
t.elements[0] = r[i * 3 + 0];
t.elements[1] = r[i * 3 + 1];
t.elements[2] = r[i * 3 + 2];
t.columns[0] = r[i * 3 + 0];
t.columns[1] = r[i * 3 + 1];
t.columns[2] = r[i * 3 + 2];
set_instance_transform_2d(i, t);
}
@ -125,9 +125,9 @@ Vector<Vector2> MultiMesh::_get_transform_2d_array() const {
for (int i = 0; i < instance_count; i++) {
Transform2D t = get_instance_transform_2d(i);
w[i * 3 + 0] = t.elements[0];
w[i * 3 + 1] = t.elements[1];
w[i * 3 + 2] = t.elements[2];
w[i * 3 + 0] = t.columns[0];
w[i * 3 + 1] = t.columns[1];
w[i * 3 + 2] = t.columns[2];
}
return xforms;

View file

@ -1717,8 +1717,8 @@ void MeshTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_mo
Transform2D xform;
xform.set_origin(p_pos);
if (p_transpose) {
SWAP(xform.elements[0][1], xform.elements[1][0]);
SWAP(xform.elements[0][0], xform.elements[1][1]);
SWAP(xform.columns[0][1], xform.columns[1][0]);
SWAP(xform.columns[0][0], xform.columns[1][1]);
}
RenderingServer::get_singleton()->canvas_item_add_mesh(p_canvas_item, mesh->get_rid(), xform, p_modulate, base_texture->get_rid());
}
@ -1739,8 +1739,8 @@ void MeshTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile,
xform.set_scale(p_rect.size / size);
if (p_transpose) {
SWAP(xform.elements[0][1], xform.elements[1][0]);
SWAP(xform.elements[0][0], xform.elements[1][1]);
SWAP(xform.columns[0][1], xform.columns[1][0]);
SWAP(xform.columns[0][0], xform.columns[1][1]);
}
RenderingServer::get_singleton()->canvas_item_add_mesh(p_canvas_item, mesh->get_rid(), xform, p_modulate, base_texture->get_rid());
}
@ -1761,8 +1761,8 @@ void MeshTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const
xform.set_scale(p_rect.size / size);
if (p_transpose) {
SWAP(xform.elements[0][1], xform.elements[1][0]);
SWAP(xform.elements[0][0], xform.elements[1][1]);
SWAP(xform.columns[0][1], xform.columns[1][0]);
SWAP(xform.columns[0][0], xform.columns[1][1]);
}
RenderingServer::get_singleton()->canvas_item_add_mesh(p_canvas_item, mesh->get_rid(), xform, p_modulate, base_texture->get_rid());
}

View file

@ -260,7 +260,7 @@ bool GodotBodyPair2D::setup(real_t p_step) {
Transform2D xform_A = xform_Au * A->get_shape_transform(shape_A);
Transform2D xform_Bu = B->get_transform();
xform_Bu.elements[2] -= offset_A;
xform_Bu.columns[2] -= offset_A;
Transform2D xform_B = xform_Bu * B->get_shape_transform(shape_B);
GodotShape2D *shape_A_ptr = A->get_shape(shape_A);
@ -351,7 +351,7 @@ bool GodotBodyPair2D::pre_solve(real_t p_step) {
Transform2D xform_A = xform_Au * A->get_shape_transform(shape_A);
Transform2D xform_Bu = B->get_transform();
xform_Bu.elements[2] -= offset_A;
xform_Bu.columns[2] -= offset_A;
Transform2D xform_B = xform_Bu * B->get_shape_transform(shape_B);
if (A->get_continuous_collision_detection_mode() == PhysicsServer2D::CCD_MODE_CAST_RAY && collide_A) {

View file

@ -185,13 +185,13 @@ bool GodotCollisionSolver2D::solve_concave(const GodotShape2D *p_shape_A, const
cinfo.aabb_tests = 0;
Transform2D rel_transform = p_transform_A;
rel_transform.elements[2] -= p_transform_B.get_origin();
rel_transform.columns[2] -= p_transform_B.get_origin();
//quickly compute a local Rect2
Rect2 local_aabb;
for (int i = 0; i < 2; i++) {
Vector2 axis(p_transform_B.elements[i]);
Vector2 axis(p_transform_B.columns[i]);
real_t axis_scale = 1.0 / axis.length();
axis *= axis_scale;

View file

@ -477,11 +477,11 @@ static void _collision_segment_rectangle(const GodotShape2D *p_a, const Transfor
return;
}
if (!separator.test_axis(p_transform_b.elements[0].normalized())) {
if (!separator.test_axis(p_transform_b.columns[0].normalized())) {
return;
}
if (!separator.test_axis(p_transform_b.elements[1].normalized())) {
if (!separator.test_axis(p_transform_b.columns[1].normalized())) {
return;
}
@ -548,22 +548,22 @@ static void _collision_segment_capsule(const GodotShape2D *p_a, const Transform2
return;
}
if (!separator.test_axis(p_transform_b.elements[0].normalized())) {
if (!separator.test_axis(p_transform_b.columns[0].normalized())) {
return;
}
real_t capsule_dir = capsule_B->get_height() * 0.5 - capsule_B->get_radius();
if (TEST_POINT(p_transform_a.xform(segment_A->get_a()), (p_transform_b.get_origin() + p_transform_b.elements[1] * capsule_dir))) {
if (TEST_POINT(p_transform_a.xform(segment_A->get_a()), (p_transform_b.get_origin() + p_transform_b.columns[1] * capsule_dir))) {
return;
}
if (TEST_POINT(p_transform_a.xform(segment_A->get_a()), (p_transform_b.get_origin() - p_transform_b.elements[1] * capsule_dir))) {
if (TEST_POINT(p_transform_a.xform(segment_A->get_a()), (p_transform_b.get_origin() - p_transform_b.columns[1] * capsule_dir))) {
return;
}
if (TEST_POINT(p_transform_a.xform(segment_A->get_b()), (p_transform_b.get_origin() + p_transform_b.elements[1] * capsule_dir))) {
if (TEST_POINT(p_transform_a.xform(segment_A->get_b()), (p_transform_b.get_origin() + p_transform_b.columns[1] * capsule_dir))) {
return;
}
if (TEST_POINT(p_transform_a.xform(segment_A->get_b()), (p_transform_b.get_origin() - p_transform_b.elements[1] * capsule_dir))) {
if (TEST_POINT(p_transform_a.xform(segment_A->get_b()), (p_transform_b.get_origin() - p_transform_b.columns[1] * capsule_dir))) {
return;
}
@ -646,8 +646,8 @@ static void _collision_circle_rectangle(const GodotShape2D *p_a, const Transform
return;
}
const Vector2 &sphere = p_transform_a.elements[2];
const Vector2 *axis = &p_transform_b.elements[0];
const Vector2 &sphere = p_transform_a.columns[2];
const Vector2 *axis = &p_transform_b.columns[0];
//const Vector2& half_extents = rectangle_B->get_half_extents();
if (!separator.test_axis(axis[0].normalized())) {
@ -705,17 +705,17 @@ static void _collision_circle_capsule(const GodotShape2D *p_a, const Transform2D
}
//capsule axis
if (!separator.test_axis(p_transform_b.elements[0].normalized())) {
if (!separator.test_axis(p_transform_b.columns[0].normalized())) {
return;
}
real_t capsule_dir = capsule_B->get_height() * 0.5 - capsule_B->get_radius();
//capsule endpoints
if (TEST_POINT(p_transform_a.get_origin(), (p_transform_b.get_origin() + p_transform_b.elements[1] * capsule_dir))) {
if (TEST_POINT(p_transform_a.get_origin(), (p_transform_b.get_origin() + p_transform_b.columns[1] * capsule_dir))) {
return;
}
if (TEST_POINT(p_transform_a.get_origin(), (p_transform_b.get_origin() - p_transform_b.elements[1] * capsule_dir))) {
if (TEST_POINT(p_transform_a.get_origin(), (p_transform_b.get_origin() - p_transform_b.columns[1] * capsule_dir))) {
return;
}
@ -769,20 +769,20 @@ static void _collision_rectangle_rectangle(const GodotShape2D *p_a, const Transf
}
//box faces A
if (!separator.test_axis(p_transform_a.elements[0].normalized())) {
if (!separator.test_axis(p_transform_a.columns[0].normalized())) {
return;
}
if (!separator.test_axis(p_transform_a.elements[1].normalized())) {
if (!separator.test_axis(p_transform_a.columns[1].normalized())) {
return;
}
//box faces B
if (!separator.test_axis(p_transform_b.elements[0].normalized())) {
if (!separator.test_axis(p_transform_b.columns[0].normalized())) {
return;
}
if (!separator.test_axis(p_transform_b.elements[1].normalized())) {
if (!separator.test_axis(p_transform_b.columns[1].normalized())) {
return;
}
@ -796,10 +796,10 @@ static void _collision_rectangle_rectangle(const GodotShape2D *p_a, const Transf
if (castA || castB) {
Transform2D aofs = p_transform_a;
aofs.elements[2] += p_motion_a;
aofs.columns[2] += p_motion_a;
Transform2D bofs = p_transform_b;
bofs.elements[2] += p_motion_b;
bofs.columns[2] += p_motion_b;
Transform2D aofsinv = aofs.affine_inverse();
Transform2D bofsinv = bofs.affine_inverse();
@ -843,16 +843,16 @@ static void _collision_rectangle_capsule(const GodotShape2D *p_a, const Transfor
}
//box faces
if (!separator.test_axis(p_transform_a.elements[0].normalized())) {
if (!separator.test_axis(p_transform_a.columns[0].normalized())) {
return;
}
if (!separator.test_axis(p_transform_a.elements[1].normalized())) {
if (!separator.test_axis(p_transform_a.columns[1].normalized())) {
return;
}
//capsule axis
if (!separator.test_axis(p_transform_b.elements[0].normalized())) {
if (!separator.test_axis(p_transform_b.columns[0].normalized())) {
return;
}
@ -864,7 +864,7 @@ static void _collision_rectangle_capsule(const GodotShape2D *p_a, const Transfor
for (int i = 0; i < 2; i++) {
{
Vector2 capsule_endpoint = p_transform_b.get_origin() + p_transform_b.elements[1] * capsule_dir;
Vector2 capsule_endpoint = p_transform_b.get_origin() + p_transform_b.columns[1] * capsule_dir;
if (!separator.test_axis(rectangle_A->get_circle_axis(p_transform_a, boxinv, capsule_endpoint))) {
return;
@ -872,7 +872,7 @@ static void _collision_rectangle_capsule(const GodotShape2D *p_a, const Transfor
}
if (castA) {
Vector2 capsule_endpoint = p_transform_b.get_origin() + p_transform_b.elements[1] * capsule_dir;
Vector2 capsule_endpoint = p_transform_b.get_origin() + p_transform_b.columns[1] * capsule_dir;
capsule_endpoint -= p_motion_a;
if (!separator.test_axis(rectangle_A->get_circle_axis(p_transform_a, boxinv, capsule_endpoint))) {
@ -881,7 +881,7 @@ static void _collision_rectangle_capsule(const GodotShape2D *p_a, const Transfor
}
if (castB) {
Vector2 capsule_endpoint = p_transform_b.get_origin() + p_transform_b.elements[1] * capsule_dir;
Vector2 capsule_endpoint = p_transform_b.get_origin() + p_transform_b.columns[1] * capsule_dir;
capsule_endpoint += p_motion_b;
if (!separator.test_axis(rectangle_A->get_circle_axis(p_transform_a, boxinv, capsule_endpoint))) {
@ -890,7 +890,7 @@ static void _collision_rectangle_capsule(const GodotShape2D *p_a, const Transfor
}
if (castA && castB) {
Vector2 capsule_endpoint = p_transform_b.get_origin() + p_transform_b.elements[1] * capsule_dir;
Vector2 capsule_endpoint = p_transform_b.get_origin() + p_transform_b.columns[1] * capsule_dir;
capsule_endpoint -= p_motion_a;
capsule_endpoint += p_motion_b;
@ -921,11 +921,11 @@ static void _collision_rectangle_convex_polygon(const GodotShape2D *p_a, const T
}
//box faces
if (!separator.test_axis(p_transform_a.elements[0].normalized())) {
if (!separator.test_axis(p_transform_a.columns[0].normalized())) {
return;
}
if (!separator.test_axis(p_transform_a.elements[1].normalized())) {
if (!separator.test_axis(p_transform_a.columns[1].normalized())) {
return;
}
@ -984,11 +984,11 @@ static void _collision_capsule_capsule(const GodotShape2D *p_a, const Transform2
//capsule axis
if (!separator.test_axis(p_transform_b.elements[0].normalized())) {
if (!separator.test_axis(p_transform_b.columns[0].normalized())) {
return;
}
if (!separator.test_axis(p_transform_a.elements[0].normalized())) {
if (!separator.test_axis(p_transform_a.columns[0].normalized())) {
return;
}
@ -996,11 +996,11 @@ static void _collision_capsule_capsule(const GodotShape2D *p_a, const Transform2
real_t capsule_dir_A = capsule_A->get_height() * 0.5 - capsule_A->get_radius();
for (int i = 0; i < 2; i++) {
Vector2 capsule_endpoint_A = p_transform_a.get_origin() + p_transform_a.elements[1] * capsule_dir_A;
Vector2 capsule_endpoint_A = p_transform_a.get_origin() + p_transform_a.columns[1] * capsule_dir_A;
real_t capsule_dir_B = capsule_B->get_height() * 0.5 - capsule_B->get_radius();
for (int j = 0; j < 2; j++) {
Vector2 capsule_endpoint_B = p_transform_b.get_origin() + p_transform_b.elements[1] * capsule_dir_B;
Vector2 capsule_endpoint_B = p_transform_b.get_origin() + p_transform_b.columns[1] * capsule_dir_B;
if (TEST_POINT(capsule_endpoint_A, capsule_endpoint_B)) {
return;
@ -1032,7 +1032,7 @@ static void _collision_capsule_convex_polygon(const GodotShape2D *p_a, const Tra
//capsule axis
if (!separator.test_axis(p_transform_a.elements[0].normalized())) {
if (!separator.test_axis(p_transform_a.columns[0].normalized())) {
return;
}
@ -1042,7 +1042,7 @@ static void _collision_capsule_convex_polygon(const GodotShape2D *p_a, const Tra
real_t capsule_dir = capsule_A->get_height() * 0.5 - capsule_A->get_radius();
for (int j = 0; j < 2; j++) {
Vector2 capsule_endpoint_A = p_transform_a.get_origin() + p_transform_a.elements[1] * capsule_dir;
Vector2 capsule_endpoint_A = p_transform_a.get_origin() + p_transform_a.columns[1] * capsule_dir;
if (TEST_POINT(capsule_endpoint_A, cpoint)) {
return;

View file

@ -134,7 +134,7 @@ public:
real_t mina, maxa; \
real_t minb, maxb; \
Transform2D ofsb = p_transform; \
ofsb.elements[2] += p_cast; \
ofsb.columns[2] += p_cast; \
project_range(p_normal, p_transform, mina, maxa); \
project_range(p_normal, ofsb, minb, maxb); \
r_min = MIN(mina, minb); \

View file

@ -710,7 +710,7 @@ bool GodotSpace2D::test_body_motion(GodotBody2D *p_body, const PhysicsServer2D::
break;
}
body_transform.elements[2] += recover_motion;
body_transform.columns[2] += recover_motion;
body_aabb.position += recover_motion;
recover_attempts--;
@ -881,7 +881,7 @@ bool GodotSpace2D::test_body_motion(GodotBody2D *p_body, const PhysicsServer2D::
//it collided, let's get the rest info in unsafe advance
Transform2D ugt = body_transform;
ugt.elements[2] += p_parameters.motion * unsafe;
ugt.columns[2] += p_parameters.motion * unsafe;
_RestCallbackData2D rcd;

View file

@ -84,7 +84,7 @@ void _collect_ysort_children(RendererCanvasCull::Item *p_canvas_item, Transform2
if (r_items) {
r_items[r_index] = child_items[i];
child_items[i]->ysort_xform = p_transform;
child_items[i]->ysort_pos = p_transform.xform(child_items[i]->xform.elements[2]);
child_items[i]->ysort_pos = p_transform.xform(child_items[i]->xform.columns[2]);
child_items[i]->material_owner = child_items[i]->use_parent_material ? p_material_owner : nullptr;
child_items[i]->ysort_index = r_index;
}
@ -236,7 +236,7 @@ void RendererCanvasCull::_cull_canvas_item(Item *p_canvas_item, const Transform2
Transform2D xform = ci->xform;
if (snapping_2d_transforms_to_pixel) {
xform.elements[2] = xform.elements[2].floor();
xform.columns[2] = xform.columns[2].floor();
}
xform = p_transform * xform;

View file

@ -41,43 +41,43 @@
#include "servers/rendering/rendering_server_default.h"
void RendererCanvasRenderRD::_update_transform_2d_to_mat4(const Transform2D &p_transform, float *p_mat4) {
p_mat4[0] = p_transform.elements[0][0];
p_mat4[1] = p_transform.elements[0][1];
p_mat4[0] = p_transform.columns[0][0];
p_mat4[1] = p_transform.columns[0][1];
p_mat4[2] = 0;
p_mat4[3] = 0;
p_mat4[4] = p_transform.elements[1][0];
p_mat4[5] = p_transform.elements[1][1];
p_mat4[4] = p_transform.columns[1][0];
p_mat4[5] = p_transform.columns[1][1];
p_mat4[6] = 0;
p_mat4[7] = 0;
p_mat4[8] = 0;
p_mat4[9] = 0;
p_mat4[10] = 1;
p_mat4[11] = 0;
p_mat4[12] = p_transform.elements[2][0];
p_mat4[13] = p_transform.elements[2][1];
p_mat4[12] = p_transform.columns[2][0];
p_mat4[13] = p_transform.columns[2][1];
p_mat4[14] = 0;
p_mat4[15] = 1;
}
void RendererCanvasRenderRD::_update_transform_2d_to_mat2x4(const Transform2D &p_transform, float *p_mat2x4) {
p_mat2x4[0] = p_transform.elements[0][0];
p_mat2x4[1] = p_transform.elements[1][0];
p_mat2x4[0] = p_transform.columns[0][0];
p_mat2x4[1] = p_transform.columns[1][0];
p_mat2x4[2] = 0;
p_mat2x4[3] = p_transform.elements[2][0];
p_mat2x4[3] = p_transform.columns[2][0];
p_mat2x4[4] = p_transform.elements[0][1];
p_mat2x4[5] = p_transform.elements[1][1];
p_mat2x4[4] = p_transform.columns[0][1];
p_mat2x4[5] = p_transform.columns[1][1];
p_mat2x4[6] = 0;
p_mat2x4[7] = p_transform.elements[2][1];
p_mat2x4[7] = p_transform.columns[2][1];
}
void RendererCanvasRenderRD::_update_transform_2d_to_mat2x3(const Transform2D &p_transform, float *p_mat2x3) {
p_mat2x3[0] = p_transform.elements[0][0];
p_mat2x3[1] = p_transform.elements[0][1];
p_mat2x3[2] = p_transform.elements[1][0];
p_mat2x3[3] = p_transform.elements[1][1];
p_mat2x3[4] = p_transform.elements[2][0];
p_mat2x3[5] = p_transform.elements[2][1];
p_mat2x3[0] = p_transform.columns[0][0];
p_mat2x3[1] = p_transform.columns[0][1];
p_mat2x3[2] = p_transform.columns[1][0];
p_mat2x3[3] = p_transform.columns[1][1];
p_mat2x3[4] = p_transform.columns[2][0];
p_mat2x3[5] = p_transform.columns[2][1];
}
void RendererCanvasRenderRD::_update_transform_to_mat4(const Transform3D &p_transform, float *p_mat4) {
@ -1175,7 +1175,7 @@ void RendererCanvasRenderRD::canvas_render_items(RID p_to_render_target, Item *p
ERR_CONTINUE(!clight);
}
Vector2 canvas_light_dir = l->xform_cache.elements[1].normalized();
Vector2 canvas_light_dir = l->xform_cache.columns[1].normalized();
state.light_uniforms[index].position[0] = -canvas_light_dir.x;
state.light_uniforms[index].position[1] = -canvas_light_dir.y;
@ -1246,7 +1246,7 @@ void RendererCanvasRenderRD::canvas_render_items(RID p_to_render_target, Item *p
_update_transform_2d_to_mat2x4(to_light_xform, state.light_uniforms[index].matrix);
_update_transform_2d_to_mat2x4(l->xform_cache.affine_inverse(), state.light_uniforms[index].shadow_matrix);
state.light_uniforms[index].height = l->height * (p_canvas_transform.elements[0].length() + p_canvas_transform.elements[1].length()) * 0.5; //approximate height conversion to the canvas size, since all calculations are done in canvas coords to avoid precision loss
state.light_uniforms[index].height = l->height * (p_canvas_transform.columns[0].length() + p_canvas_transform.columns[1].length()) * 0.5; //approximate height conversion to the canvas size, since all calculations are done in canvas coords to avoid precision loss
for (int i = 0; i < 4; i++) {
state.light_uniforms[index].shadow_color[i] = uint8_t(CLAMP(int32_t(l->shadow_color[i] * 255.0), 0, 255));
state.light_uniforms[index].color[i] = l->color[i];
@ -1310,9 +1310,9 @@ void RendererCanvasRenderRD::canvas_render_items(RID p_to_render_target, Item *p
_update_transform_2d_to_mat4(p_canvas_transform, state_buffer.canvas_transform);
Transform2D normal_transform = p_canvas_transform;
normal_transform.elements[0].normalize();
normal_transform.elements[1].normalize();
normal_transform.elements[2] = Vector2();
normal_transform.columns[0].normalize();
normal_transform.columns[1].normalize();
normal_transform.columns[2] = Vector2();
_update_transform_2d_to_mat4(normal_transform, state_buffer.canvas_normal_transform);
state_buffer.canvas_modulate[0] = p_modulate.r;
@ -1645,7 +1645,7 @@ void RendererCanvasRenderRD::light_update_directional_shadow(RID p_rid, int p_sh
_update_shadow_atlas();
Vector2 light_dir = p_light_xform.elements[1].normalized();
Vector2 light_dir = p_light_xform.columns[1].normalized();
Vector2 center = p_clip_rect.get_center();
@ -1713,8 +1713,8 @@ void RendererCanvasRenderRD::light_update_directional_shadow(RID p_rid, int p_sh
RD::get_singleton()->draw_list_end();
Transform2D to_shadow;
to_shadow.elements[0].x = 1.0 / -(half_size * 2.0);
to_shadow.elements[2].x = 0.5;
to_shadow.columns[0].x = 1.0 / -(half_size * 2.0);
to_shadow.columns[2].x = 0.5;
cl->shadow.directional_xform = to_shadow * to_light_xform;
}
@ -1726,14 +1726,14 @@ void RendererCanvasRenderRD::render_sdf(RID p_render_target, LightOccluderInstan
Rect2i rect = texture_storage->render_target_get_sdf_rect(p_render_target);
Transform2D to_sdf;
to_sdf.elements[0] *= rect.size.width;
to_sdf.elements[1] *= rect.size.height;
to_sdf.elements[2] = rect.position;
to_sdf.columns[0] *= rect.size.width;
to_sdf.columns[1] *= rect.size.height;
to_sdf.columns[2] = rect.position;
Transform2D to_clip;
to_clip.elements[0] *= 2.0;
to_clip.elements[1] *= 2.0;
to_clip.elements[2] = -Vector2(1.0, 1.0);
to_clip.columns[0] *= 2.0;
to_clip.columns[1] *= 2.0;
to_clip.columns[2] = -Vector2(1.0, 1.0);
to_clip = to_clip * to_sdf.affine_inverse();

View file

@ -520,13 +520,13 @@ _FORCE_INLINE_ static void _fill_std140_variant_ubo_value(ShaderLanguage::DataTy
Transform2D v = value;
//in std140 members of mat2 are treated as vec4s
gui[0] = v.elements[0][0];
gui[1] = v.elements[0][1];
gui[0] = v.columns[0][0];
gui[1] = v.columns[0][1];
gui[2] = 0; // ignored
gui[3] = 0; // ignored
gui[4] = v.elements[1][0];
gui[5] = v.elements[1][1];
gui[4] = v.columns[1][0];
gui[5] = v.columns[1][1];
gui[6] = 0; // ignored
gui[7] = 0; // ignored
}
@ -1781,18 +1781,18 @@ void MaterialStorage::_global_variable_store_in_buffer(int32_t p_index, RS::Glob
case RS::GLOBAL_VAR_TYPE_TRANSFORM_2D: {
GlobalVariables::Value *bv = &global_variables.buffer_values[p_index];
Transform2D v = p_value;
bv[0].x = v.elements[0][0];
bv[0].y = v.elements[0][1];
bv[0].x = v.columns[0][0];
bv[0].y = v.columns[0][1];
bv[0].z = 0;
bv[0].w = 0;
bv[1].x = v.elements[1][0];
bv[1].y = v.elements[1][1];
bv[1].x = v.columns[1][0];
bv[1].y = v.columns[1][1];
bv[1].z = 0;
bv[1].w = 0;
bv[2].x = v.elements[2][0];
bv[2].y = v.elements[2][1];
bv[2].x = v.columns[2][0];
bv[2].y = v.columns[2][1];
bv[2].z = 1;
bv[2].w = 0;

View file

@ -1407,14 +1407,14 @@ void MeshStorage::multimesh_instance_set_transform_2d(RID p_multimesh, int p_ind
float *dataptr = w + p_index * multimesh->stride_cache;
dataptr[0] = p_transform.elements[0][0];
dataptr[1] = p_transform.elements[1][0];
dataptr[0] = p_transform.columns[0][0];
dataptr[1] = p_transform.columns[1][0];
dataptr[2] = 0;
dataptr[3] = p_transform.elements[2][0];
dataptr[4] = p_transform.elements[0][1];
dataptr[5] = p_transform.elements[1][1];
dataptr[3] = p_transform.columns[2][0];
dataptr[4] = p_transform.columns[0][1];
dataptr[5] = p_transform.columns[1][1];
dataptr[6] = 0;
dataptr[7] = p_transform.elements[2][1];
dataptr[7] = p_transform.columns[2][1];
}
_multimesh_mark_dirty(multimesh, p_index, true);
@ -1516,12 +1516,12 @@ Transform2D MeshStorage::multimesh_instance_get_transform_2d(RID p_multimesh, in
const float *dataptr = r + p_index * multimesh->stride_cache;
t.elements[0][0] = dataptr[0];
t.elements[1][0] = dataptr[1];
t.elements[2][0] = dataptr[3];
t.elements[0][1] = dataptr[4];
t.elements[1][1] = dataptr[5];
t.elements[2][1] = dataptr[7];
t.columns[0][0] = dataptr[0];
t.columns[1][0] = dataptr[1];
t.columns[2][0] = dataptr[3];
t.columns[0][1] = dataptr[4];
t.columns[1][1] = dataptr[5];
t.columns[2][1] = dataptr[7];
}
return t;
@ -1852,14 +1852,14 @@ void MeshStorage::skeleton_bone_set_transform_2d(RID p_skeleton, int p_bone, con
float *dataptr = skeleton->data.ptrw() + p_bone * 8;
dataptr[0] = p_transform.elements[0][0];
dataptr[1] = p_transform.elements[1][0];
dataptr[0] = p_transform.columns[0][0];
dataptr[1] = p_transform.columns[1][0];
dataptr[2] = 0;
dataptr[3] = p_transform.elements[2][0];
dataptr[4] = p_transform.elements[0][1];
dataptr[5] = p_transform.elements[1][1];
dataptr[3] = p_transform.columns[2][0];
dataptr[4] = p_transform.columns[0][1];
dataptr[5] = p_transform.columns[1][1];
dataptr[6] = 0;
dataptr[7] = p_transform.elements[2][1];
dataptr[7] = p_transform.columns[2][1];
_skeleton_make_dirty(skeleton);
}
@ -1874,12 +1874,12 @@ Transform2D MeshStorage::skeleton_bone_get_transform_2d(RID p_skeleton, int p_bo
const float *dataptr = skeleton->data.ptr() + p_bone * 8;
Transform2D t;
t.elements[0][0] = dataptr[0];
t.elements[1][0] = dataptr[1];
t.elements[2][0] = dataptr[3];
t.elements[0][1] = dataptr[4];
t.elements[1][1] = dataptr[5];
t.elements[2][1] = dataptr[7];
t.columns[0][0] = dataptr[0];
t.columns[1][0] = dataptr[1];
t.columns[2][0] = dataptr[3];
t.columns[0][1] = dataptr[4];
t.columns[1][1] = dataptr[5];
t.columns[2][1] = dataptr[7];
return t;
}

View file

@ -800,25 +800,25 @@ void ParticlesStorage::_particles_process(Particles *p_particles, double p_delta
Transform2D xform = p_particles->sdf_collision_transform; //will use dotproduct manually so invert beforehand
Transform2D revert = xform.affine_inverse();
frame_params.collider_count = 1;
frame_params.colliders[0].transform[0] = xform.elements[0][0];
frame_params.colliders[0].transform[1] = xform.elements[0][1];
frame_params.colliders[0].transform[0] = xform.columns[0][0];
frame_params.colliders[0].transform[1] = xform.columns[0][1];
frame_params.colliders[0].transform[2] = 0;
frame_params.colliders[0].transform[3] = xform.elements[2][0];
frame_params.colliders[0].transform[3] = xform.columns[2][0];
frame_params.colliders[0].transform[4] = xform.elements[1][0];
frame_params.colliders[0].transform[5] = xform.elements[1][1];
frame_params.colliders[0].transform[4] = xform.columns[1][0];
frame_params.colliders[0].transform[5] = xform.columns[1][1];
frame_params.colliders[0].transform[6] = 0;
frame_params.colliders[0].transform[7] = xform.elements[2][1];
frame_params.colliders[0].transform[7] = xform.columns[2][1];
frame_params.colliders[0].transform[8] = revert.elements[0][0];
frame_params.colliders[0].transform[9] = revert.elements[0][1];
frame_params.colliders[0].transform[8] = revert.columns[0][0];
frame_params.colliders[0].transform[9] = revert.columns[0][1];
frame_params.colliders[0].transform[10] = 0;
frame_params.colliders[0].transform[11] = revert.elements[2][0];
frame_params.colliders[0].transform[11] = revert.columns[2][0];
frame_params.colliders[0].transform[12] = revert.elements[1][0];
frame_params.colliders[0].transform[13] = revert.elements[1][1];
frame_params.colliders[0].transform[12] = revert.columns[1][0];
frame_params.colliders[0].transform[13] = revert.columns[1][1];
frame_params.colliders[0].transform[14] = 0;
frame_params.colliders[0].transform[15] = revert.elements[2][1];
frame_params.colliders[0].transform[15] = revert.columns[2][1];
frame_params.colliders[0].extents[0] = p_particles->sdf_collision_to_screen.size.x;
frame_params.colliders[0].extents[1] = p_particles->sdf_collision_to_screen.size.y;

View file

@ -43,7 +43,7 @@ static Transform2D _canvas_get_transform(RendererViewport::Viewport *p_viewport,
if (p_viewport->canvas_map.has(p_canvas->parent)) {
Transform2D c_xform = p_viewport->canvas_map[p_canvas->parent].transform;
if (p_viewport->snap_2d_transforms_to_pixel) {
c_xform.elements[2] = c_xform.elements[2].floor();
c_xform.columns[2] = c_xform.columns[2].floor();
}
xf = xf * c_xform;
scale = p_canvas->parent_scale;
@ -52,7 +52,7 @@ static Transform2D _canvas_get_transform(RendererViewport::Viewport *p_viewport,
Transform2D c_xform = p_canvas_data->transform;
if (p_viewport->snap_2d_transforms_to_pixel) {
c_xform.elements[2] = c_xform.elements[2].floor();
c_xform.columns[2] = c_xform.columns[2].floor();
}
xf = xf * c_xform;
@ -305,7 +305,7 @@ void RendererViewport::_draw_viewport(Viewport *p_viewport) {
// cl->texture_cache = nullptr;
Transform2D scale;
scale.scale(cl->rect_cache.size);
scale.elements[2] = cl->rect_cache.position;
scale.columns[2] = cl->rect_cache.position;
cl->light_shader_xform = cl->xform * scale;
//cl->light_shader_pos = cl->xform_cache[2];
if (cl->use_shadow) {
@ -332,7 +332,7 @@ void RendererViewport::_draw_viewport(Viewport *p_viewport) {
cl->filter_next_ptr = directional_lights;
directional_lights = cl;
cl->xform_cache = xf * cl->xform;
cl->xform_cache.elements[2] = Vector2(); //translation is pointless
cl->xform_cache.columns[2] = Vector2(); //translation is pointless
if (cl->use_shadow) {
cl->shadows_next_ptr = directional_lights_with_shadow;
directional_lights_with_shadow = cl;
@ -390,7 +390,7 @@ void RendererViewport::_draw_viewport(Viewport *p_viewport) {
//update shadows if any
RendererCanvasRender::Light *light = directional_lights_with_shadow;
while (light) {
Vector2 light_dir = -light->xform_cache.elements[1].normalized(); // Y is light direction
Vector2 light_dir = -light->xform_cache.columns[1].normalized(); // Y is light direction
float cull_distance = light->directional_distance;
Vector2 light_dir_sign;