diff options
-rw-r--r-- | core/core_constants.cpp | 7 | ||||
-rw-r--r-- | core/math/basis.cpp | 24 | ||||
-rw-r--r-- | core/math/basis.h | 23 | ||||
-rw-r--r-- | core/math/math_defs.h | 9 | ||||
-rw-r--r-- | core/math/quaternion.cpp | 4 | ||||
-rw-r--r-- | core/variant/binder_common.h | 2 | ||||
-rw-r--r-- | core/variant/variant_call.cpp | 18 | ||||
-rw-r--r-- | core/variant/variant_internal.h | 6 | ||||
-rw-r--r-- | doc/classes/@GlobalScope.xml | 18 | ||||
-rw-r--r-- | doc/classes/Basis.xml | 20 | ||||
-rw-r--r-- | modules/mono/glue/GodotSharp/GodotSharp/Core/Basis.cs | 43 | ||||
-rw-r--r-- | scene/3d/node_3d.cpp | 2 | ||||
-rw-r--r-- | scene/3d/node_3d.h | 2 | ||||
-rw-r--r-- | scene/3d/remote_transform_3d.cpp | 4 | ||||
-rw-r--r-- | servers/physics_3d/joints/godot_generic_6dof_joint_3d.cpp | 2 | ||||
-rw-r--r-- | tests/core/math/test_basis.h | 48 |
16 files changed, 105 insertions, 127 deletions
diff --git a/core/core_constants.cpp b/core/core_constants.cpp index c784d87c87..0e8532a327 100644 --- a/core/core_constants.cpp +++ b/core/core_constants.cpp @@ -167,6 +167,13 @@ void register_global_constants() { BIND_CORE_ENUM_CONSTANT(INLINE_ALIGNMENT_IMAGE_MASK); BIND_CORE_ENUM_CONSTANT(INLINE_ALIGNMENT_TEXT_MASK); + BIND_CORE_ENUM_CLASS_CONSTANT(EulerOrder, EULER_ORDER, XYZ); + BIND_CORE_ENUM_CLASS_CONSTANT(EulerOrder, EULER_ORDER, XZY); + BIND_CORE_ENUM_CLASS_CONSTANT(EulerOrder, EULER_ORDER, YXZ); + BIND_CORE_ENUM_CLASS_CONSTANT(EulerOrder, EULER_ORDER, YZX); + BIND_CORE_ENUM_CLASS_CONSTANT(EulerOrder, EULER_ORDER, ZXY); + BIND_CORE_ENUM_CLASS_CONSTANT(EulerOrder, EULER_ORDER, ZYX); + BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, NONE); BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, SPECIAL); BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, ESCAPE); diff --git a/core/math/basis.cpp b/core/math/basis.cpp index 5f0d7ba96f..41ec6d8ce3 100644 --- a/core/math/basis.cpp +++ b/core/math/basis.cpp @@ -453,7 +453,7 @@ void Basis::get_rotation_axis_angle_local(Vector3 &p_axis, real_t &p_angle) cons Vector3 Basis::get_euler(EulerOrder p_order) const { switch (p_order) { - case EULER_ORDER_XYZ: { + case EulerOrder::XYZ: { // Euler angles in XYZ convention. // See https://en.wikipedia.org/wiki/Euler_angles#Rotation_matrix // @@ -488,7 +488,7 @@ Vector3 Basis::get_euler(EulerOrder p_order) const { } return euler; } break; - case EULER_ORDER_XZY: { + case EulerOrder::XZY: { // Euler angles in XZY convention. // See https://en.wikipedia.org/wiki/Euler_angles#Rotation_matrix // @@ -517,7 +517,7 @@ Vector3 Basis::get_euler(EulerOrder p_order) const { } return euler; } break; - case EULER_ORDER_YXZ: { + case EulerOrder::YXZ: { // Euler angles in YXZ convention. // See https://en.wikipedia.org/wiki/Euler_angles#Rotation_matrix // @@ -555,7 +555,7 @@ Vector3 Basis::get_euler(EulerOrder p_order) const { return euler; } break; - case EULER_ORDER_YZX: { + case EulerOrder::YZX: { // Euler angles in YZX convention. // See https://en.wikipedia.org/wiki/Euler_angles#Rotation_matrix // @@ -584,7 +584,7 @@ Vector3 Basis::get_euler(EulerOrder p_order) const { } return euler; } break; - case EULER_ORDER_ZXY: { + case EulerOrder::ZXY: { // Euler angles in ZXY convention. // See https://en.wikipedia.org/wiki/Euler_angles#Rotation_matrix // @@ -612,7 +612,7 @@ Vector3 Basis::get_euler(EulerOrder p_order) const { } return euler; } break; - case EULER_ORDER_ZYX: { + case EulerOrder::ZYX: { // Euler angles in ZYX convention. // See https://en.wikipedia.org/wiki/Euler_angles#Rotation_matrix // @@ -663,22 +663,22 @@ void Basis::set_euler(const Vector3 &p_euler, EulerOrder p_order) { Basis zmat(c, -s, 0, s, c, 0, 0, 0, 1); switch (p_order) { - case EULER_ORDER_XYZ: { + case EulerOrder::XYZ: { *this = xmat * (ymat * zmat); } break; - case EULER_ORDER_XZY: { + case EulerOrder::XZY: { *this = xmat * zmat * ymat; } break; - case EULER_ORDER_YXZ: { + case EulerOrder::YXZ: { *this = ymat * xmat * zmat; } break; - case EULER_ORDER_YZX: { + case EulerOrder::YZX: { *this = ymat * zmat * xmat; } break; - case EULER_ORDER_ZXY: { + case EulerOrder::ZXY: { *this = zmat * xmat * ymat; } break; - case EULER_ORDER_ZYX: { + case EulerOrder::ZYX: { *this = zmat * ymat * xmat; } break; default: { diff --git a/core/math/basis.h b/core/math/basis.h index 69bef5a7be..a1d9fccef1 100644 --- a/core/math/basis.h +++ b/core/math/basis.h @@ -56,15 +56,6 @@ struct _NO_DISCARD_ Basis { _FORCE_INLINE_ real_t determinant() const; - enum EulerOrder { - EULER_ORDER_XYZ, - EULER_ORDER_XZY, - EULER_ORDER_YXZ, - EULER_ORDER_YZX, - EULER_ORDER_ZXY, - EULER_ORDER_ZYX - }; - void from_z(const Vector3 &p_z); void rotate(const Vector3 &p_axis, real_t p_angle); @@ -73,13 +64,13 @@ struct _NO_DISCARD_ Basis { void rotate_local(const Vector3 &p_axis, real_t p_angle); Basis rotated_local(const Vector3 &p_axis, real_t p_angle) const; - void rotate(const Vector3 &p_euler, EulerOrder p_order = EULER_ORDER_YXZ); - Basis rotated(const Vector3 &p_euler, EulerOrder p_order = EULER_ORDER_YXZ) const; + void rotate(const Vector3 &p_euler, EulerOrder p_order = EulerOrder::YXZ); + Basis rotated(const Vector3 &p_euler, EulerOrder p_order = EulerOrder::YXZ) const; void rotate(const Quaternion &p_quaternion); Basis rotated(const Quaternion &p_quaternion) const; - Vector3 get_euler_normalized(EulerOrder p_order = EULER_ORDER_YXZ) const; + Vector3 get_euler_normalized(EulerOrder p_order = EulerOrder::YXZ) const; void get_rotation_axis_angle(Vector3 &p_axis, real_t &p_angle) const; void get_rotation_axis_angle_local(Vector3 &p_axis, real_t &p_angle) const; Quaternion get_rotation_quaternion() const; @@ -88,9 +79,9 @@ struct _NO_DISCARD_ Basis { Vector3 rotref_posscale_decomposition(Basis &rotref) const; - Vector3 get_euler(EulerOrder p_order = EULER_ORDER_YXZ) const; - void set_euler(const Vector3 &p_euler, EulerOrder p_order = EULER_ORDER_YXZ); - static Basis from_euler(const Vector3 &p_euler, EulerOrder p_order = EULER_ORDER_YXZ) { + Vector3 get_euler(EulerOrder p_order = EulerOrder::YXZ) const; + void set_euler(const Vector3 &p_euler, EulerOrder p_order = EulerOrder::YXZ); + static Basis from_euler(const Vector3 &p_euler, EulerOrder p_order = EulerOrder::YXZ) { Basis b; b.set_euler(p_euler, p_order); return b; @@ -119,7 +110,7 @@ struct _NO_DISCARD_ Basis { Vector3 get_scale_local() const; void set_axis_angle_scale(const Vector3 &p_axis, real_t p_angle, const Vector3 &p_scale); - void set_euler_scale(const Vector3 &p_euler, const Vector3 &p_scale, EulerOrder p_order = EULER_ORDER_YXZ); + void set_euler_scale(const Vector3 &p_euler, const Vector3 &p_scale, EulerOrder p_order = EulerOrder::YXZ); void set_quaternion_scale(const Quaternion &p_quaternion, const Vector3 &p_scale); // transposed dot products diff --git a/core/math/math_defs.h b/core/math/math_defs.h index b8b82f2ff4..759667e2d5 100644 --- a/core/math/math_defs.h +++ b/core/math/math_defs.h @@ -116,6 +116,15 @@ enum Corner { CORNER_BOTTOM_LEFT }; +enum class EulerOrder { + XYZ, + XZY, + YXZ, + YZX, + ZXY, + ZYX +}; + /** * The "Real" type is an abstract type used for real numbers, such as 1.5, * in contrast to integer numbers. Precision can be controlled with the diff --git a/core/math/quaternion.cpp b/core/math/quaternion.cpp index 79a4e62b56..42b61f6dfe 100644 --- a/core/math/quaternion.cpp +++ b/core/math/quaternion.cpp @@ -44,7 +44,7 @@ real_t Quaternion::angle_to(const Quaternion &p_to) const { // This implementation uses XYZ convention (Z is the first rotation). Vector3 Quaternion::get_euler_xyz() const { Basis m(*this); - return m.get_euler(Basis::EULER_ORDER_XYZ); + return m.get_euler(EulerOrder::XYZ); } // get_euler_yxz returns a vector containing the Euler angles in the format @@ -56,7 +56,7 @@ Vector3 Quaternion::get_euler_yxz() const { ERR_FAIL_COND_V_MSG(!is_normalized(), Vector3(0, 0, 0), "The quaternion must be normalized."); #endif Basis m(*this); - return m.get_euler(Basis::EULER_ORDER_YXZ); + return m.get_euler(EulerOrder::YXZ); } void Quaternion::operator*=(const Quaternion &p_q) { diff --git a/core/variant/binder_common.h b/core/variant/binder_common.h index f0c3b1ce38..696b27f9f2 100644 --- a/core/variant/binder_common.h +++ b/core/variant/binder_common.h @@ -138,7 +138,7 @@ VARIANT_ENUM_CAST(Vector3::Axis); VARIANT_ENUM_CAST(Vector3i::Axis); VARIANT_ENUM_CAST(Vector4::Axis); VARIANT_ENUM_CAST(Vector4i::Axis); -VARIANT_ENUM_CAST(Basis::EulerOrder); +VARIANT_ENUM_CAST(EulerOrder); VARIANT_ENUM_CAST(Projection::Planes); VARIANT_ENUM_CAST(Error); diff --git a/core/variant/variant_call.cpp b/core/variant/variant_call.cpp index 087ce09215..f32233d808 100644 --- a/core/variant/variant_call.cpp +++ b/core/variant/variant_call.cpp @@ -1927,7 +1927,7 @@ static void _register_variant_builtin_methods() { bind_methodv(Basis, rotated, static_cast<Basis (Basis::*)(const Vector3 &, real_t) const>(&Basis::rotated), sarray("axis", "angle"), varray()); bind_method(Basis, scaled, sarray("scale"), varray()); bind_method(Basis, get_scale, sarray(), varray()); - bind_method(Basis, get_euler, sarray("order"), varray((int64_t)Basis::EULER_ORDER_YXZ)); + bind_method(Basis, get_euler, sarray("order"), varray((int64_t)EulerOrder::YXZ)); bind_method(Basis, tdotx, sarray("with"), varray()); bind_method(Basis, tdoty, sarray("with"), varray()); bind_method(Basis, tdotz, sarray("with"), varray()); @@ -1937,7 +1937,7 @@ static void _register_variant_builtin_methods() { bind_method(Basis, get_rotation_quaternion, sarray(), varray()); bind_static_method(Basis, looking_at, sarray("target", "up"), varray(Vector3(0, 1, 0))); bind_static_method(Basis, from_scale, sarray("scale"), varray()); - bind_static_method(Basis, from_euler, sarray("euler", "order"), varray((int64_t)Basis::EULER_ORDER_YXZ)); + bind_static_method(Basis, from_euler, sarray("euler", "order"), varray((int64_t)EulerOrder::YXZ)); /* AABB */ @@ -2434,20 +2434,6 @@ static void _register_variant_builtin_methods() { _VariantCall::add_variant_constant(Variant::VECTOR2I, "UP", Vector2i(0, -1)); _VariantCall::add_variant_constant(Variant::VECTOR2I, "DOWN", Vector2i(0, 1)); - _VariantCall::add_constant(Variant::BASIS, "EULER_ORDER_XYZ", Basis::EULER_ORDER_XYZ); - _VariantCall::add_constant(Variant::BASIS, "EULER_ORDER_XZY", Basis::EULER_ORDER_XZY); - _VariantCall::add_constant(Variant::BASIS, "EULER_ORDER_YXZ", Basis::EULER_ORDER_YXZ); - _VariantCall::add_constant(Variant::BASIS, "EULER_ORDER_YZX", Basis::EULER_ORDER_YZX); - _VariantCall::add_constant(Variant::BASIS, "EULER_ORDER_ZXY", Basis::EULER_ORDER_ZXY); - _VariantCall::add_constant(Variant::BASIS, "EULER_ORDER_ZYX", Basis::EULER_ORDER_ZYX); - - _VariantCall::add_enum_constant(Variant::BASIS, "EulerOrder", "EULER_ORDER_XYZ", Basis::EULER_ORDER_XYZ); - _VariantCall::add_enum_constant(Variant::BASIS, "EulerOrder", "EULER_ORDER_XZY", Basis::EULER_ORDER_XZY); - _VariantCall::add_enum_constant(Variant::BASIS, "EulerOrder", "EULER_ORDER_YXZ", Basis::EULER_ORDER_YXZ); - _VariantCall::add_enum_constant(Variant::BASIS, "EulerOrder", "EULER_ORDER_YZX", Basis::EULER_ORDER_YZX); - _VariantCall::add_enum_constant(Variant::BASIS, "EulerOrder", "EULER_ORDER_ZXY", Basis::EULER_ORDER_ZXY); - _VariantCall::add_enum_constant(Variant::BASIS, "EulerOrder", "EULER_ORDER_ZYX", Basis::EULER_ORDER_ZYX); - _VariantCall::add_variant_constant(Variant::TRANSFORM2D, "IDENTITY", Transform2D()); _VariantCall::add_variant_constant(Variant::TRANSFORM2D, "FLIP_X", Transform2D(-1, 0, 0, 1, 0, 0)); _VariantCall::add_variant_constant(Variant::TRANSFORM2D, "FLIP_Y", Transform2D(1, 0, 0, -1, 0, 0)); diff --git a/core/variant/variant_internal.h b/core/variant/variant_internal.h index 636710c934..94e7296a99 100644 --- a/core/variant/variant_internal.h +++ b/core/variant/variant_internal.h @@ -824,9 +824,9 @@ VARIANT_ACCESSOR_NUMBER(Vector4i::Axis) VARIANT_ACCESSOR_NUMBER(Projection::Planes) template <> -struct VariantInternalAccessor<Basis::EulerOrder> { - static _FORCE_INLINE_ Basis::EulerOrder get(const Variant *v) { return Basis::EulerOrder(*VariantInternal::get_int(v)); } - static _FORCE_INLINE_ void set(Variant *v, Basis::EulerOrder p_value) { *VariantInternal::get_int(v) = (int64_t)p_value; } +struct VariantInternalAccessor<EulerOrder> { + static _FORCE_INLINE_ EulerOrder get(const Variant *v) { return EulerOrder(*VariantInternal::get_int(v)); } + static _FORCE_INLINE_ void set(Variant *v, EulerOrder p_value) { *VariantInternal::get_int(v) = (int64_t)p_value; } }; template <> diff --git a/doc/classes/@GlobalScope.xml b/doc/classes/@GlobalScope.xml index ae39f7ce28..ed404ea504 100644 --- a/doc/classes/@GlobalScope.xml +++ b/doc/classes/@GlobalScope.xml @@ -1466,6 +1466,24 @@ <constant name="INLINE_ALIGNMENT_TEXT_MASK" value="12" enum="InlineAlignment"> A bit mask for [code]INLINE_ALIGNMENT_TO_*[/code] alignment constants. </constant> + <constant name="EULER_ORDER_XYZ" value="0" enum="EulerOrder"> + Specifies that Euler angles should be in XYZ order. When composing, the order is X, Y, Z. When decomposing, the order is reversed, first Z, then Y, and X last. + </constant> + <constant name="EULER_ORDER_XZY" value="1" enum="EulerOrder"> + Specifies that Euler angles should be in XZY order. When composing, the order is X, Z, Y. When decomposing, the order is reversed, first Y, then Z, and X last. + </constant> + <constant name="EULER_ORDER_YXZ" value="2" enum="EulerOrder"> + Specifies that Euler angles should be in YXZ order. When composing, the order is Y, X, Z. When decomposing, the order is reversed, first Z, then X, and Y last. + </constant> + <constant name="EULER_ORDER_YZX" value="3" enum="EulerOrder"> + Specifies that Euler angles should be in YZX order. When composing, the order is Y, Z, X. When decomposing, the order is reversed, first X, then Z, and Y last. + </constant> + <constant name="EULER_ORDER_ZXY" value="4" enum="EulerOrder"> + Specifies that Euler angles should be in ZXY order. When composing, the order is Z, X, Y. When decomposing, the order is reversed, first Y, then X, and Z last. + </constant> + <constant name="EULER_ORDER_ZYX" value="5" enum="EulerOrder"> + Specifies that Euler angles should be in ZYX order. When composing, the order is Z, Y, X. When decomposing, the order is reversed, first X, then Y, and Z last. + </constant> <constant name="KEY_NONE" value="0" enum="Key"> Enum value which doesn't correspond to any key. This is used to initialize [enum Key] properties with a generic state. </constant> diff --git a/doc/classes/Basis.xml b/doc/classes/Basis.xml index 652d6d2407..acc2fd34dd 100644 --- a/doc/classes/Basis.xml +++ b/doc/classes/Basis.xml @@ -70,7 +70,7 @@ <param index="0" name="euler" type="Vector3" /> <param index="1" name="order" type="int" default="2" /> <description> - Constructs a pure rotation Basis matrix from Euler angles in the specified Euler rotation order. By default, use YXZ order (most common). + Constructs a pure rotation Basis matrix from Euler angles in the specified Euler rotation order. By default, use YXZ order (most common). See the [enum EulerOrder] enum for possible values. </description> </method> <method name="from_scale" qualifiers="static"> @@ -197,24 +197,6 @@ </member> </members> <constants> - <constant name="EULER_ORDER_XYZ" value="0"> - Euler angle composing/decomposing order where X component is first, then Y, then Z. - </constant> - <constant name="EULER_ORDER_XZY" value="1"> - Euler angle composing/decomposing order where X component is first, then Z, then Y. - </constant> - <constant name="EULER_ORDER_YXZ" value="2"> - Euler angle composing/decomposing order where Y component is first, then X, then Z. - </constant> - <constant name="EULER_ORDER_YZX" value="3"> - Euler angle composing/decomposing order where Y component is first, then Z, then X. - </constant> - <constant name="EULER_ORDER_ZXY" value="4"> - Euler angle composing/decomposing order where Z component is first, then X, then Y. - </constant> - <constant name="EULER_ORDER_ZYX" value="5"> - Euler angle composing/decomposing order where Z component is first, then Y, then X. - </constant> <constant name="IDENTITY" value="Basis(1, 0, 0, 0, 1, 0, 0, 0, 1)"> The identity basis, with no rotation or scaling applied. This is identical to calling [code]Basis()[/code] without any parameters. This constant can be used to make your code clearer, and for consistency with C#. diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Basis.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Basis.cs index 9c3bc51c44..bb1d6e1661 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Basis.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Basis.cs @@ -4,21 +4,6 @@ using System.Runtime.InteropServices; namespace Godot { /// <summary> - /// Specifies which order Euler angle rotations should be in. - /// When composing, the order is the same as the letters. When decomposing, - /// the order is reversed (ex: YXZ decomposes Z first, then X, and Y last). - /// </summary> - public enum EulerOrder - { - XYZ, - XZY, - YXZ, - YZX, - ZXY, - ZYX - }; - - /// <summary> /// 3×3 matrix used for 3D rotation and scale. /// Almost always used as an orthogonal basis for a Transform. /// @@ -270,11 +255,11 @@ namespace Godot /// </summary> /// <param name="order">The Euler order to use. By default, use YXZ order (most common).</param> /// <returns>A <see cref="Vector3"/> representing the basis rotation in Euler angles.</returns> - public Vector3 GetEuler(EulerOrder order = EulerOrder.YXZ) + public Vector3 GetEuler(EulerOrder order = EulerOrder.Yxz) { switch (order) { - case EulerOrder.XYZ: + case EulerOrder.Xyz: { // Euler angles in XYZ convention. // See https://en.wikipedia.org/wiki/Euler_angles#Rotation_matrix @@ -318,7 +303,7 @@ namespace Godot } return euler; } - case EulerOrder.XZY: + case EulerOrder.Xzy: { // Euler angles in XZY convention. // See https://en.wikipedia.org/wiki/Euler_angles#Rotation_matrix @@ -353,7 +338,7 @@ namespace Godot } return euler; } - case EulerOrder.YXZ: + case EulerOrder.Yxz: { // Euler angles in YXZ convention. // See https://en.wikipedia.org/wiki/Euler_angles#Rotation_matrix @@ -398,7 +383,7 @@ namespace Godot return euler; } - case EulerOrder.YZX: + case EulerOrder.Yzx: { // Euler angles in YZX convention. // See https://en.wikipedia.org/wiki/Euler_angles#Rotation_matrix @@ -433,7 +418,7 @@ namespace Godot } return euler; } - case EulerOrder.ZXY: + case EulerOrder.Zxy: { // Euler angles in ZXY convention. // See https://en.wikipedia.org/wiki/Euler_angles#Rotation_matrix @@ -468,7 +453,7 @@ namespace Godot } return euler; } - case EulerOrder.ZYX: + case EulerOrder.Zyx: { // Euler angles in ZYX convention. // See https://en.wikipedia.org/wiki/Euler_angles#Rotation_matrix @@ -998,7 +983,7 @@ namespace Godot /// </summary> /// <param name="euler">The Euler angles to use.</param> /// <param name="order">The order to compose the Euler angles.</param> - public static Basis FromEuler(Vector3 euler, EulerOrder order = EulerOrder.YXZ) + public static Basis FromEuler(Vector3 euler, EulerOrder order = EulerOrder.Yxz) { real_t c, s; @@ -1016,17 +1001,17 @@ namespace Godot switch (order) { - case EulerOrder.XYZ: + case EulerOrder.Xyz: return xmat * ymat * zmat; - case EulerOrder.XZY: + case EulerOrder.Xzy: return xmat * zmat * ymat; - case EulerOrder.YXZ: + case EulerOrder.Yxz: return ymat * xmat * zmat; - case EulerOrder.YZX: + case EulerOrder.Yzx: return ymat * zmat * xmat; - case EulerOrder.ZXY: + case EulerOrder.Zxy: return zmat * xmat * ymat; - case EulerOrder.ZYX: + case EulerOrder.Zyx: return zmat * ymat * xmat; default: throw new ArgumentOutOfRangeException(nameof(order)); diff --git a/scene/3d/node_3d.cpp b/scene/3d/node_3d.cpp index 1743fa1838..e2d68c36ff 100644 --- a/scene/3d/node_3d.cpp +++ b/scene/3d/node_3d.cpp @@ -393,7 +393,7 @@ Node3D::RotationEditMode Node3D::get_rotation_edit_mode() const { } void Node3D::set_rotation_order(RotationOrder p_order) { - Basis::EulerOrder order = Basis::EulerOrder(p_order); + EulerOrder order = EulerOrder(p_order); if (data.euler_rotation_order == order) { return; diff --git a/scene/3d/node_3d.h b/scene/3d/node_3d.h index 457f634c34..f6868209bb 100644 --- a/scene/3d/node_3d.h +++ b/scene/3d/node_3d.h @@ -100,7 +100,7 @@ private: struct Data { mutable Transform3D global_transform; mutable Transform3D local_transform; - mutable Basis::EulerOrder euler_rotation_order = Basis::EULER_ORDER_YXZ; + mutable EulerOrder euler_rotation_order = EulerOrder::YXZ; mutable Vector3 euler_rotation; mutable Vector3 scale = Vector3(1, 1, 1); mutable RotationEditMode rotation_edit_mode = ROTATION_EDIT_MODE_EULER; diff --git a/scene/3d/remote_transform_3d.cpp b/scene/3d/remote_transform_3d.cpp index ff05e88241..817ffbfec8 100644 --- a/scene/3d/remote_transform_3d.cpp +++ b/scene/3d/remote_transform_3d.cpp @@ -68,7 +68,7 @@ void RemoteTransform3D::_update_remote() { Transform3D our_trans = get_global_transform(); if (update_remote_rotation) { - n->set_rotation(our_trans.basis.get_euler_normalized(Basis::EulerOrder(n->get_rotation_order()))); + n->set_rotation(our_trans.basis.get_euler_normalized(EulerOrder(n->get_rotation_order()))); } if (update_remote_scale) { @@ -90,7 +90,7 @@ void RemoteTransform3D::_update_remote() { Transform3D our_trans = get_transform(); if (update_remote_rotation) { - n->set_rotation(our_trans.basis.get_euler_normalized(Basis::EulerOrder(n->get_rotation_order()))); + n->set_rotation(our_trans.basis.get_euler_normalized(EulerOrder(n->get_rotation_order()))); } if (update_remote_scale) { diff --git a/servers/physics_3d/joints/godot_generic_6dof_joint_3d.cpp b/servers/physics_3d/joints/godot_generic_6dof_joint_3d.cpp index e0fa940104..dfe2bfa4d3 100644 --- a/servers/physics_3d/joints/godot_generic_6dof_joint_3d.cpp +++ b/servers/physics_3d/joints/godot_generic_6dof_joint_3d.cpp @@ -232,7 +232,7 @@ GodotGeneric6DOFJoint3D::GodotGeneric6DOFJoint3D(GodotBody3D *rbA, GodotBody3D * void GodotGeneric6DOFJoint3D::calculateAngleInfo() { Basis relative_frame = m_calculatedTransformB.basis.inverse() * m_calculatedTransformA.basis; - m_calculatedAxisAngleDiff = relative_frame.get_euler(Basis::EULER_ORDER_XYZ); + m_calculatedAxisAngleDiff = relative_frame.get_euler(EulerOrder::XYZ); // in euler angle mode we do not actually constrain the angular velocity // along the axes axis[0] and axis[2] (although we do use axis[1]) : diff --git a/tests/core/math/test_basis.h b/tests/core/math/test_basis.h index f52b715cd7..a4099ebf7d 100644 --- a/tests/core/math/test_basis.h +++ b/tests/core/math/test_basis.h @@ -46,26 +46,26 @@ Vector3 rad2deg(const Vector3 &p_rotation) { return p_rotation / Math_PI * 180.0; } -String get_rot_order_name(Basis::EulerOrder ro) { +String get_rot_order_name(EulerOrder ro) { switch (ro) { - case Basis::EULER_ORDER_XYZ: + case EulerOrder::XYZ: return "XYZ"; - case Basis::EULER_ORDER_XZY: + case EulerOrder::XZY: return "XZY"; - case Basis::EULER_ORDER_YZX: + case EulerOrder::YZX: return "YZX"; - case Basis::EULER_ORDER_YXZ: + case EulerOrder::YXZ: return "YXZ"; - case Basis::EULER_ORDER_ZXY: + case EulerOrder::ZXY: return "ZXY"; - case Basis::EULER_ORDER_ZYX: + case EulerOrder::ZYX: return "ZYX"; default: return "[Not supported]"; } } -void test_rotation(Vector3 deg_original_euler, Basis::EulerOrder rot_order) { +void test_rotation(Vector3 deg_original_euler, EulerOrder rot_order) { // This test: // 1. Converts the rotation vector from deg to rad. // 2. Converts euler to basis. @@ -98,8 +98,8 @@ void test_rotation(Vector3 deg_original_euler, Basis::EulerOrder rot_order) { CHECK_MESSAGE((res.get_column(2) - Vector3(0.0, 0.0, 1.0)).length() <= 0.1, vformat("Fail due to Z %s\n", String(res.get_column(2))).utf8().ptr()); // Double check `to_rotation` decomposing with XYZ rotation order. - const Vector3 euler_xyz_from_rotation = to_rotation.get_euler(Basis::EULER_ORDER_XYZ); - Basis rotation_from_xyz_computed_euler = Basis::from_euler(euler_xyz_from_rotation, Basis::EULER_ORDER_XYZ); + const Vector3 euler_xyz_from_rotation = to_rotation.get_euler(EulerOrder::XYZ); + Basis rotation_from_xyz_computed_euler = Basis::from_euler(euler_xyz_from_rotation, EulerOrder::XYZ); res = to_rotation.inverse() * rotation_from_xyz_computed_euler; @@ -113,13 +113,13 @@ void test_rotation(Vector3 deg_original_euler, Basis::EulerOrder rot_order) { } TEST_CASE("[Basis] Euler conversions") { - Vector<Basis::EulerOrder> euler_order_to_test; - euler_order_to_test.push_back(Basis::EULER_ORDER_XYZ); - euler_order_to_test.push_back(Basis::EULER_ORDER_XZY); - euler_order_to_test.push_back(Basis::EULER_ORDER_YZX); - euler_order_to_test.push_back(Basis::EULER_ORDER_YXZ); - euler_order_to_test.push_back(Basis::EULER_ORDER_ZXY); - euler_order_to_test.push_back(Basis::EULER_ORDER_ZYX); + Vector<EulerOrder> euler_order_to_test; + euler_order_to_test.push_back(EulerOrder::XYZ); + euler_order_to_test.push_back(EulerOrder::XZY); + euler_order_to_test.push_back(EulerOrder::YZX); + euler_order_to_test.push_back(EulerOrder::YXZ); + euler_order_to_test.push_back(EulerOrder::ZXY); + euler_order_to_test.push_back(EulerOrder::ZYX); Vector<Vector3> vectors_to_test; @@ -185,13 +185,13 @@ TEST_CASE("[Basis] Euler conversions") { } TEST_CASE("[Stress][Basis] Euler conversions") { - Vector<Basis::EulerOrder> euler_order_to_test; - euler_order_to_test.push_back(Basis::EULER_ORDER_XYZ); - euler_order_to_test.push_back(Basis::EULER_ORDER_XZY); - euler_order_to_test.push_back(Basis::EULER_ORDER_YZX); - euler_order_to_test.push_back(Basis::EULER_ORDER_YXZ); - euler_order_to_test.push_back(Basis::EULER_ORDER_ZXY); - euler_order_to_test.push_back(Basis::EULER_ORDER_ZYX); + Vector<EulerOrder> euler_order_to_test; + euler_order_to_test.push_back(EulerOrder::XYZ); + euler_order_to_test.push_back(EulerOrder::XZY); + euler_order_to_test.push_back(EulerOrder::YZX); + euler_order_to_test.push_back(EulerOrder::YXZ); + euler_order_to_test.push_back(EulerOrder::ZXY); + euler_order_to_test.push_back(EulerOrder::ZYX); Vector<Vector3> vectors_to_test; // Add 1000 random vectors with weirds numbers. |