From ab9ed3245db4804ab0049da472b7a5bb0118a9a7 Mon Sep 17 00:00:00 2001 From: Aaron Franke Date: Wed, 20 Sep 2023 14:25:45 -0500 Subject: [PATCH] [3.x] Add "position" as an alias for "translation" in Spatial --- doc/classes/Spatial.xml | 6 ++++++ scene/3d/spatial.cpp | 2 ++ 2 files changed, 8 insertions(+) diff --git a/doc/classes/Spatial.xml b/doc/classes/Spatial.xml index 4580c61277c..144e7e9cd9e 100644 --- a/doc/classes/Spatial.xml +++ b/doc/classes/Spatial.xml @@ -253,6 +253,9 @@ The [SpatialGizmo] for this node. Used for example in [EditorSpatialGizmo] as custom visualization and editing handles in Editor. + + Global position of this node. This is a forward-compatible alias for [member global_translation]. + Rotation part of the global transformation in radians, specified in terms of YXZ-Euler angles in the format (X angle, Y angle, Z angle). [b]Note:[/b] In the mathematical sense, rotation is a matrix and not a vector. The three Euler angles, which are the three independent parameters of the Euler-angle parametrization of the rotation matrix, are stored in a [Vector3] data structure not because the rotation is a vector, but only because [Vector3] exists as a convenient data-structure to store 3 floating-point numbers. Therefore, applying affine operations on the rotation "vector" is not meaningful. @@ -263,6 +266,9 @@ Global position of this node. This is equivalent to [code]global_transform.origin[/code]. + + Local position of this node. This is a forward-compatible alias for [member translation]. + Rotation part of the local transformation in radians, specified in terms of YXZ-Euler angles in the format (X angle, Y angle, Z angle). [b]Note:[/b] In the mathematical sense, rotation is a matrix and not a vector. The three Euler angles, which are the three independent parameters of the Euler-angle parametrization of the rotation matrix, are stored in a [Vector3] data structure not because the rotation is a vector, but only because [Vector3] exists as a convenient data-structure to store 3 floating-point numbers. Therefore, applying affine operations on the rotation "vector" is not meaningful. diff --git a/scene/3d/spatial.cpp b/scene/3d/spatial.cpp index 6e59be4d377..3e7c6a93f23 100644 --- a/scene/3d/spatial.cpp +++ b/scene/3d/spatial.cpp @@ -936,11 +936,13 @@ void Spatial::_bind_methods() { BIND_CONSTANT(NOTIFICATION_EXIT_GAMEPLAY); ADD_GROUP("Transform", ""); + ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "position", PROPERTY_HINT_NONE, "", 0), "set_translation", "get_translation"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "translation", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "set_translation", "get_translation"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "rotation_degrees", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "set_rotation_degrees", "get_rotation_degrees"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "rotation", PROPERTY_HINT_NONE, "", 0), "set_rotation", "get_rotation"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "scale", PROPERTY_HINT_LINK, "", PROPERTY_USAGE_EDITOR), "set_scale", "get_scale"); ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM, "global_transform", PROPERTY_HINT_NONE, "", 0), "set_global_transform", "get_global_transform"); + ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "global_position", PROPERTY_HINT_NONE, "", 0), "set_global_translation", "get_global_translation"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "global_translation", PROPERTY_HINT_NONE, "", 0), "set_global_translation", "get_global_translation"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "global_rotation", PROPERTY_HINT_NONE, "", 0), "set_global_rotation", "get_global_rotation");