mirror of
https://github.com/godotengine/godot.git
synced 2025-12-08 06:09:55 +00:00
Rename Basis get_axis to get_column, remove redundant methods
This commit is contained in:
parent
d5d86cb26e
commit
fa7a7795f0
50 changed files with 285 additions and 305 deletions
|
|
@ -73,9 +73,9 @@ void Basis::invert() {
|
|||
void Basis::orthonormalize() {
|
||||
// Gram-Schmidt Process
|
||||
|
||||
Vector3 x = get_axis(0);
|
||||
Vector3 y = get_axis(1);
|
||||
Vector3 z = get_axis(2);
|
||||
Vector3 x = get_column(0);
|
||||
Vector3 y = get_column(1);
|
||||
Vector3 z = get_column(2);
|
||||
|
||||
x.normalize();
|
||||
y = (y - x * (x.dot(y)));
|
||||
|
|
@ -83,9 +83,9 @@ void Basis::orthonormalize() {
|
|||
z = (z - x * (x.dot(z)) - y * (y.dot(z)));
|
||||
z.normalize();
|
||||
|
||||
set_axis(0, x);
|
||||
set_axis(1, y);
|
||||
set_axis(2, z);
|
||||
set_column(0, x);
|
||||
set_column(1, y);
|
||||
set_column(2, z);
|
||||
}
|
||||
|
||||
Basis Basis::orthonormalized() const {
|
||||
|
|
@ -260,7 +260,7 @@ Basis Basis::scaled_orthogonal(const Vector3 &p_scale) const {
|
|||
Basis b;
|
||||
for (int i = 0; i < 3; i++) {
|
||||
for (int j = 0; j < 3; j++) {
|
||||
dots[j] += s[i] * abs(m.get_axis(i).normalized().dot(b.get_axis(j)));
|
||||
dots[j] += s[i] * abs(m.get_column(i).normalized().dot(b.get_column(j)));
|
||||
}
|
||||
}
|
||||
m.scale_local(Vector3(1, 1, 1) + dots);
|
||||
|
|
@ -708,9 +708,9 @@ bool Basis::operator!=(const Basis &p_matrix) const {
|
|||
}
|
||||
|
||||
Basis::operator String() const {
|
||||
return "[X: " + get_axis(0).operator String() +
|
||||
", Y: " + get_axis(1).operator String() +
|
||||
", Z: " + get_axis(2).operator String() + "]";
|
||||
return "[X: " + get_column(0).operator String() +
|
||||
", Y: " + get_column(1).operator String() +
|
||||
", Z: " + get_column(2).operator String() + "]";
|
||||
}
|
||||
|
||||
Quaternion Basis::get_quaternion() const {
|
||||
|
|
@ -1107,6 +1107,6 @@ Basis Basis::looking_at(const Vector3 &p_target, const Vector3 &p_up) {
|
|||
Vector3 v_y = v_z.cross(v_x);
|
||||
|
||||
Basis basis;
|
||||
basis.set(v_x, v_y, v_z);
|
||||
basis.set_columns(v_x, v_y, v_z);
|
||||
return basis;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,17 +58,6 @@ struct _NO_DISCARD_ Basis {
|
|||
|
||||
void from_z(const Vector3 &p_z);
|
||||
|
||||
_FORCE_INLINE_ Vector3 get_axis(int p_axis) const {
|
||||
// get actual basis axis column (we store transposed as rows for performance)
|
||||
return Vector3(rows[0][p_axis], rows[1][p_axis], rows[2][p_axis]);
|
||||
}
|
||||
_FORCE_INLINE_ void set_axis(int p_axis, const Vector3 &p_value) {
|
||||
// get actual basis axis column (we store transposed as rows for performance)
|
||||
rows[0][p_axis] = p_value.x;
|
||||
rows[1][p_axis] = p_value.y;
|
||||
rows[2][p_axis] = p_value.z;
|
||||
}
|
||||
|
||||
void rotate(const Vector3 &p_axis, real_t p_phi);
|
||||
Basis rotated(const Vector3 &p_axis, real_t p_phi) const;
|
||||
|
||||
|
|
@ -186,28 +175,28 @@ struct _NO_DISCARD_ Basis {
|
|||
rows[2][1] = zy;
|
||||
rows[2][2] = zz;
|
||||
}
|
||||
_FORCE_INLINE_ void set(const Vector3 &p_x, const Vector3 &p_y, const Vector3 &p_z) {
|
||||
set_axis(0, p_x);
|
||||
set_axis(1, p_y);
|
||||
set_axis(2, p_z);
|
||||
}
|
||||
_FORCE_INLINE_ Vector3 get_column(int i) const {
|
||||
return Vector3(rows[0][i], rows[1][i], rows[2][i]);
|
||||
_FORCE_INLINE_ void set_columns(const Vector3 &p_x, const Vector3 &p_y, const Vector3 &p_z) {
|
||||
set_column(0, p_x);
|
||||
set_column(1, p_y);
|
||||
set_column(2, p_z);
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ Vector3 get_row(int i) const {
|
||||
return Vector3(rows[i][0], rows[i][1], rows[i][2]);
|
||||
_FORCE_INLINE_ Vector3 get_column(int p_index) const {
|
||||
// Get actual basis axis column (we store transposed as rows for performance).
|
||||
return Vector3(rows[0][p_index], rows[1][p_index], rows[2][p_index]);
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ void set_column(int p_index, const Vector3 &p_value) {
|
||||
// Set actual basis axis column (we store transposed as rows for performance).
|
||||
rows[0][p_index] = p_value.x;
|
||||
rows[1][p_index] = p_value.y;
|
||||
rows[2][p_index] = p_value.z;
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ Vector3 get_main_diagonal() const {
|
||||
return Vector3(rows[0][0], rows[1][1], rows[2][2]);
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ void set_row(int i, const Vector3 &p_row) {
|
||||
rows[i][0] = p_row.x;
|
||||
rows[i][1] = p_row.y;
|
||||
rows[i][2] = p_row.z;
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ void set_zero() {
|
||||
rows[0].zero();
|
||||
rows[1].zero();
|
||||
|
|
|
|||
|
|
@ -58,15 +58,6 @@ struct _NO_DISCARD_ Transform2D {
|
|||
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 columns[p_axis];
|
||||
}
|
||||
_FORCE_INLINE_ void set_axis(int p_axis, const Vector2 &p_vec) {
|
||||
ERR_FAIL_INDEX(p_axis, 3);
|
||||
columns[p_axis] = p_vec;
|
||||
}
|
||||
|
||||
void invert();
|
||||
Transform2D inverse() const;
|
||||
|
||||
|
|
|
|||
|
|
@ -194,9 +194,9 @@ Transform3D Transform3D::operator*(const real_t p_val) const {
|
|||
}
|
||||
|
||||
Transform3D::operator String() const {
|
||||
return "[X: " + basis.get_axis(0).operator String() +
|
||||
", Y: " + basis.get_axis(1).operator String() +
|
||||
", Z: " + basis.get_axis(2).operator String() +
|
||||
return "[X: " + basis.get_column(0).operator String() +
|
||||
", Y: " + basis.get_column(1).operator String() +
|
||||
", Z: " + basis.get_column(2).operator String() +
|
||||
", O: " + origin.operator String() + "]";
|
||||
}
|
||||
|
||||
|
|
@ -207,9 +207,9 @@ Transform3D::Transform3D(const Basis &p_basis, const Vector3 &p_origin) :
|
|||
|
||||
Transform3D::Transform3D(const Vector3 &p_x, const Vector3 &p_y, const Vector3 &p_z, const Vector3 &p_origin) :
|
||||
origin(p_origin) {
|
||||
basis.set_axis(0, p_x);
|
||||
basis.set_axis(1, p_y);
|
||||
basis.set_axis(2, p_z);
|
||||
basis.set_column(0, p_x);
|
||||
basis.set_column(1, p_y);
|
||||
basis.set_column(2, p_z);
|
||||
}
|
||||
|
||||
Transform3D::Transform3D(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, real_t ox, real_t oy, real_t oz) {
|
||||
|
|
|
|||
|
|
@ -790,7 +790,7 @@ 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, .columns, 3)
|
||||
INDEXED_SETGET_STRUCT_BULTIN_FUNC(Basis, Vector3, set_axis, get_axis, 3)
|
||||
INDEXED_SETGET_STRUCT_BULTIN_FUNC(Basis, Vector3, set_column, get_column, 3)
|
||||
|
||||
INDEXED_SETGET_STRUCT_TYPED_NUMERIC(PackedByteArray, int64_t, uint8_t)
|
||||
INDEXED_SETGET_STRUCT_TYPED_NUMERIC(PackedInt32Array, int64_t, int32_t)
|
||||
|
|
|
|||
|
|
@ -308,9 +308,9 @@ SETGET_NUMBER_STRUCT(Quaternion, double, y)
|
|||
SETGET_NUMBER_STRUCT(Quaternion, double, z)
|
||||
SETGET_NUMBER_STRUCT(Quaternion, double, w)
|
||||
|
||||
SETGET_STRUCT_FUNC_INDEX(Basis, Vector3, x, set_axis, get_axis, 0)
|
||||
SETGET_STRUCT_FUNC_INDEX(Basis, Vector3, y, set_axis, get_axis, 1)
|
||||
SETGET_STRUCT_FUNC_INDEX(Basis, Vector3, z, set_axis, get_axis, 2)
|
||||
SETGET_STRUCT_FUNC_INDEX(Basis, Vector3, x, set_column, get_column, 0)
|
||||
SETGET_STRUCT_FUNC_INDEX(Basis, Vector3, y, set_column, get_column, 1)
|
||||
SETGET_STRUCT_FUNC_INDEX(Basis, Vector3, z, set_column, get_column, 2)
|
||||
|
||||
SETGET_STRUCT(Transform3D, Basis, basis)
|
||||
SETGET_STRUCT(Transform3D, Vector3, origin)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue