From 69fe6336f16ec2c889532d36ff7b87fd8a4800f2 Mon Sep 17 00:00:00 2001 From: Zhehang Ding Date: Tue, 30 Aug 2022 21:28:36 -0700 Subject: [PATCH] Basis constructor: row vectors -> column vectors --- core/math/basis.h | 6 ++---- core/math/vector3.cpp | 10 +++++----- editor/plugins/skeleton_3d_editor_plugin.cpp | 4 +++- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/core/math/basis.h b/core/math/basis.h index 2853947ba74..cc2924f5ff5 100644 --- a/core/math/basis.h +++ b/core/math/basis.h @@ -238,10 +238,8 @@ struct _NO_DISCARD_ Basis { Basis(const Vector3 &p_axis, real_t p_angle, const Vector3 &p_scale) { set_axis_angle_scale(p_axis, p_angle, p_scale); } static Basis from_scale(const Vector3 &p_scale); - _FORCE_INLINE_ Basis(const Vector3 &row0, const Vector3 &row1, const Vector3 &row2) { - rows[0] = row0; - rows[1] = row1; - rows[2] = row2; + _FORCE_INLINE_ Basis(const Vector3 &p_x_axis, const Vector3 &p_y_axis, const Vector3 &p_z_axis) { + set_columns(p_x_axis, p_y_axis, p_z_axis); } _FORCE_INLINE_ Basis() {} diff --git a/core/math/vector3.cpp b/core/math/vector3.cpp index fdbbb8cb5ca..f8eefa4f186 100644 --- a/core/math/vector3.cpp +++ b/core/math/vector3.cpp @@ -134,11 +134,11 @@ Vector3 Vector3::octahedron_tangent_decode(const Vector2 &p_oct, float *sign) { } Basis Vector3::outer(const Vector3 &p_with) const { - Vector3 row0(x * p_with.x, x * p_with.y, x * p_with.z); - Vector3 row1(y * p_with.x, y * p_with.y, y * p_with.z); - Vector3 row2(z * p_with.x, z * p_with.y, z * p_with.z); - - return Basis(row0, row1, row2); + Basis basis; + basis.rows[0] = Vector3(x * p_with.x, x * p_with.y, x * p_with.z); + basis.rows[1] = Vector3(y * p_with.x, y * p_with.y, y * p_with.z); + basis.rows[2] = Vector3(z * p_with.x, z * p_with.y, z * p_with.z); + return basis; } bool Vector3::is_equal_approx(const Vector3 &p_v) const { diff --git a/editor/plugins/skeleton_3d_editor_plugin.cpp b/editor/plugins/skeleton_3d_editor_plugin.cpp index 026d9574070..b85e44e106b 100644 --- a/editor/plugins/skeleton_3d_editor_plugin.cpp +++ b/editor/plugins/skeleton_3d_editor_plugin.cpp @@ -426,7 +426,9 @@ PhysicalBone3D *Skeleton3DEditor::create_physical_bone(int bone_id, int bone_chi bone_shape->set_name("CollisionShape3D"); Transform3D capsule_transform; - capsule_transform.basis = Basis(Vector3(1, 0, 0), Vector3(0, 0, 1), Vector3(0, -1, 0)); + capsule_transform.basis.rows[0] = Vector3(1, 0, 0); + capsule_transform.basis.rows[1] = Vector3(0, 0, 1); + capsule_transform.basis.rows[2] = Vector3(0, -1, 0); bone_shape->set_transform(capsule_transform); /// Get an up vector not collinear with child rest origin