Restore 'rotation_degrees' properties.
By popular demand, restoring the helper properties to rotate objects in degrees. Affected are local and global rotations for: * Node2D * Node3D * Control
This commit is contained in:
parent
0bb94df247
commit
80b578b060
|
@ -1050,6 +1050,9 @@
|
||||||
<member name="rotation" type="float" setter="set_rotation" getter="get_rotation" default="0.0">
|
<member name="rotation" type="float" setter="set_rotation" getter="get_rotation" default="0.0">
|
||||||
The node's rotation around its pivot, in radians. See [member pivot_offset] to change the pivot's position.
|
The node's rotation around its pivot, in radians. See [member pivot_offset] to change the pivot's position.
|
||||||
</member>
|
</member>
|
||||||
|
<member name="rotation_degrees" type="float" setter="set_rotation_degrees" getter="get_rotation_degrees">
|
||||||
|
Helper property to access [member rotation] in degrees instead of radians.
|
||||||
|
</member>
|
||||||
<member name="scale" type="Vector2" setter="set_scale" getter="get_scale" default="Vector2(1, 1)">
|
<member name="scale" type="Vector2" setter="set_scale" getter="get_scale" default="Vector2(1, 1)">
|
||||||
The node's scale, relative to its [member size]. Change this property to scale the node around its [member pivot_offset]. The Control's [member tooltip_text] will also scale according to this value.
|
The node's scale, relative to its [member size]. Change this property to scale the node around its [member pivot_offset]. The Control's [member tooltip_text] will also scale according to this value.
|
||||||
[b]Note:[/b] This property is mainly intended to be used for animation purposes. Text inside the Control will look pixelated or blurry when the Control is scaled. To support multiple resolutions in your project, use an appropriate viewport stretch mode as described in the [url=$DOCS_URL/tutorials/rendering/multiple_resolutions.html]documentation[/url] instead of scaling Controls individually.
|
[b]Note:[/b] This property is mainly intended to be used for animation purposes. Text inside the Control will look pixelated or blurry when the Control is scaled. To support multiple resolutions in your project, use an appropriate viewport stretch mode as described in the [url=$DOCS_URL/tutorials/rendering/multiple_resolutions.html]documentation[/url] instead of scaling Controls individually.
|
||||||
|
|
|
@ -99,6 +99,9 @@
|
||||||
<member name="global_rotation" type="float" setter="set_global_rotation" getter="get_global_rotation">
|
<member name="global_rotation" type="float" setter="set_global_rotation" getter="get_global_rotation">
|
||||||
Global rotation in radians.
|
Global rotation in radians.
|
||||||
</member>
|
</member>
|
||||||
|
<member name="global_rotation_degrees" type="float" setter="set_global_rotation_degrees" getter="get_global_rotation_degrees">
|
||||||
|
Helper property to access [member global_rotation] in degrees instead of radians.
|
||||||
|
</member>
|
||||||
<member name="global_scale" type="Vector2" setter="set_global_scale" getter="get_global_scale">
|
<member name="global_scale" type="Vector2" setter="set_global_scale" getter="get_global_scale">
|
||||||
Global scale.
|
Global scale.
|
||||||
</member>
|
</member>
|
||||||
|
@ -114,6 +117,9 @@
|
||||||
<member name="rotation" type="float" setter="set_rotation" getter="get_rotation" default="0.0">
|
<member name="rotation" type="float" setter="set_rotation" getter="get_rotation" default="0.0">
|
||||||
Rotation in radians, relative to the node's parent.
|
Rotation in radians, relative to the node's parent.
|
||||||
</member>
|
</member>
|
||||||
|
<member name="rotation_degrees" type="float" setter="set_rotation_degrees" getter="get_rotation_degrees">
|
||||||
|
Helper property to access [member rotation] in degrees instead of radians.
|
||||||
|
</member>
|
||||||
<member name="scale" type="Vector2" setter="set_scale" getter="get_scale" default="Vector2(1, 1)">
|
<member name="scale" type="Vector2" setter="set_scale" getter="get_scale" default="Vector2(1, 1)">
|
||||||
The node's scale. Unscaled value: [code](1, 1)[/code].
|
The node's scale. Unscaled value: [code](1, 1)[/code].
|
||||||
[b]Note:[/b] Negative X scales in 2D are not decomposable from the transformation matrix. Due to the way scale is represented with transformation matrices in Godot, negative scales on the X axis will be changed to negative scales on the Y axis and a rotation of 180 degrees when decomposed.
|
[b]Note:[/b] Negative X scales in 2D are not decomposable from the transformation matrix. Due to the way scale is represented with transformation matrices in Godot, negative scales on the X axis will be changed to negative scales on the Y axis and a rotation of 180 degrees when decomposed.
|
||||||
|
|
|
@ -274,6 +274,9 @@
|
||||||
Rotation part of the global transformation in radians, specified in terms of YXZ-Euler angles in the format (X angle, Y angle, Z angle).
|
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.
|
[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.
|
||||||
</member>
|
</member>
|
||||||
|
<member name="global_rotation_degrees" type="Vector3" setter="set_global_rotation_degrees" getter="get_global_rotation_degrees">
|
||||||
|
Helper property to access [member global_rotation] in degrees instead of radians.
|
||||||
|
</member>
|
||||||
<member name="global_transform" type="Transform3D" setter="set_global_transform" getter="get_global_transform">
|
<member name="global_transform" type="Transform3D" setter="set_global_transform" getter="get_global_transform">
|
||||||
World3D space (global) [Transform3D] of this node.
|
World3D space (global) [Transform3D] of this node.
|
||||||
</member>
|
</member>
|
||||||
|
@ -287,6 +290,9 @@
|
||||||
Rotation part of the local transformation in radians, specified in terms of Euler angles. The angles construct a rotaton in the order specified by the [member rotation_order] property.
|
Rotation part of the local transformation in radians, specified in terms of Euler angles. The angles construct a rotaton in the order specified by the [member rotation_order] property.
|
||||||
[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.
|
[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.
|
||||||
</member>
|
</member>
|
||||||
|
<member name="rotation_degrees" type="Vector3" setter="set_rotation_degrees" getter="get_rotation_degrees">
|
||||||
|
Helper property to access [member rotation] in degrees instead of radians.
|
||||||
|
</member>
|
||||||
<member name="rotation_edit_mode" type="int" setter="set_rotation_edit_mode" getter="get_rotation_edit_mode" enum="Node3D.RotationEditMode" default="0">
|
<member name="rotation_edit_mode" type="int" setter="set_rotation_edit_mode" getter="get_rotation_edit_mode" enum="Node3D.RotationEditMode" default="0">
|
||||||
Specify how rotation (and scale) will be presented in the editor.
|
Specify how rotation (and scale) will be presented in the editor.
|
||||||
</member>
|
</member>
|
||||||
|
|
|
@ -149,6 +149,10 @@ void Node2D::set_rotation(real_t p_radians) {
|
||||||
_update_transform();
|
_update_transform();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Node2D::set_rotation_degrees(real_t p_degrees) {
|
||||||
|
set_rotation(Math::deg_to_rad(p_degrees));
|
||||||
|
}
|
||||||
|
|
||||||
void Node2D::set_skew(real_t p_radians) {
|
void Node2D::set_skew(real_t p_radians) {
|
||||||
if (_xform_dirty) {
|
if (_xform_dirty) {
|
||||||
const_cast<Node2D *>(this)->_update_xform_values();
|
const_cast<Node2D *>(this)->_update_xform_values();
|
||||||
|
@ -187,6 +191,10 @@ real_t Node2D::get_rotation() const {
|
||||||
return rotation;
|
return rotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
real_t Node2D::get_rotation_degrees() const {
|
||||||
|
return Math::rad_to_deg(get_rotation());
|
||||||
|
}
|
||||||
|
|
||||||
real_t Node2D::get_skew() const {
|
real_t Node2D::get_skew() const {
|
||||||
if (_xform_dirty) {
|
if (_xform_dirty) {
|
||||||
const_cast<Node2D *>(this)->_update_xform_values();
|
const_cast<Node2D *>(this)->_update_xform_values();
|
||||||
|
@ -259,6 +267,10 @@ real_t Node2D::get_global_rotation() const {
|
||||||
return get_global_transform().get_rotation();
|
return get_global_transform().get_rotation();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
real_t Node2D::get_global_rotation_degrees() const {
|
||||||
|
return Math::rad_to_deg(get_global_rotation());
|
||||||
|
}
|
||||||
|
|
||||||
real_t Node2D::get_global_skew() const {
|
real_t Node2D::get_global_skew() const {
|
||||||
return get_global_transform().get_skew();
|
return get_global_transform().get_skew();
|
||||||
}
|
}
|
||||||
|
@ -276,6 +288,10 @@ void Node2D::set_global_rotation(const real_t p_radians) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Node2D::set_global_rotation_degrees(const real_t p_degrees) {
|
||||||
|
set_global_rotation(Math::deg_to_rad(p_degrees));
|
||||||
|
}
|
||||||
|
|
||||||
void Node2D::set_global_skew(const real_t p_radians) {
|
void Node2D::set_global_skew(const real_t p_radians) {
|
||||||
CanvasItem *parent = get_parent_item();
|
CanvasItem *parent = get_parent_item();
|
||||||
if (parent) {
|
if (parent) {
|
||||||
|
@ -372,11 +388,13 @@ void Node2D::_notification(int p_notification) {
|
||||||
void Node2D::_bind_methods() {
|
void Node2D::_bind_methods() {
|
||||||
ClassDB::bind_method(D_METHOD("set_position", "position"), &Node2D::set_position);
|
ClassDB::bind_method(D_METHOD("set_position", "position"), &Node2D::set_position);
|
||||||
ClassDB::bind_method(D_METHOD("set_rotation", "radians"), &Node2D::set_rotation);
|
ClassDB::bind_method(D_METHOD("set_rotation", "radians"), &Node2D::set_rotation);
|
||||||
|
ClassDB::bind_method(D_METHOD("set_rotation_degrees", "degrees"), &Node2D::set_rotation_degrees);
|
||||||
ClassDB::bind_method(D_METHOD("set_skew", "radians"), &Node2D::set_skew);
|
ClassDB::bind_method(D_METHOD("set_skew", "radians"), &Node2D::set_skew);
|
||||||
ClassDB::bind_method(D_METHOD("set_scale", "scale"), &Node2D::set_scale);
|
ClassDB::bind_method(D_METHOD("set_scale", "scale"), &Node2D::set_scale);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("get_position"), &Node2D::get_position);
|
ClassDB::bind_method(D_METHOD("get_position"), &Node2D::get_position);
|
||||||
ClassDB::bind_method(D_METHOD("get_rotation"), &Node2D::get_rotation);
|
ClassDB::bind_method(D_METHOD("get_rotation"), &Node2D::get_rotation);
|
||||||
|
ClassDB::bind_method(D_METHOD("get_rotation_degrees"), &Node2D::get_rotation_degrees);
|
||||||
ClassDB::bind_method(D_METHOD("get_skew"), &Node2D::get_skew);
|
ClassDB::bind_method(D_METHOD("get_skew"), &Node2D::get_skew);
|
||||||
ClassDB::bind_method(D_METHOD("get_scale"), &Node2D::get_scale);
|
ClassDB::bind_method(D_METHOD("get_scale"), &Node2D::get_scale);
|
||||||
|
|
||||||
|
@ -390,7 +408,9 @@ void Node2D::_bind_methods() {
|
||||||
ClassDB::bind_method(D_METHOD("set_global_position", "position"), &Node2D::set_global_position);
|
ClassDB::bind_method(D_METHOD("set_global_position", "position"), &Node2D::set_global_position);
|
||||||
ClassDB::bind_method(D_METHOD("get_global_position"), &Node2D::get_global_position);
|
ClassDB::bind_method(D_METHOD("get_global_position"), &Node2D::get_global_position);
|
||||||
ClassDB::bind_method(D_METHOD("set_global_rotation", "radians"), &Node2D::set_global_rotation);
|
ClassDB::bind_method(D_METHOD("set_global_rotation", "radians"), &Node2D::set_global_rotation);
|
||||||
|
ClassDB::bind_method(D_METHOD("set_global_rotation_degrees", "degrees"), &Node2D::set_global_rotation_degrees);
|
||||||
ClassDB::bind_method(D_METHOD("get_global_rotation"), &Node2D::get_global_rotation);
|
ClassDB::bind_method(D_METHOD("get_global_rotation"), &Node2D::get_global_rotation);
|
||||||
|
ClassDB::bind_method(D_METHOD("get_global_rotation_degrees"), &Node2D::get_global_rotation_degrees);
|
||||||
ClassDB::bind_method(D_METHOD("set_global_skew", "radians"), &Node2D::set_global_skew);
|
ClassDB::bind_method(D_METHOD("set_global_skew", "radians"), &Node2D::set_global_skew);
|
||||||
ClassDB::bind_method(D_METHOD("get_global_skew"), &Node2D::get_global_skew);
|
ClassDB::bind_method(D_METHOD("get_global_skew"), &Node2D::get_global_skew);
|
||||||
ClassDB::bind_method(D_METHOD("set_global_scale", "scale"), &Node2D::set_global_scale);
|
ClassDB::bind_method(D_METHOD("set_global_scale", "scale"), &Node2D::set_global_scale);
|
||||||
|
@ -410,12 +430,14 @@ void Node2D::_bind_methods() {
|
||||||
ADD_GROUP("Transform", "");
|
ADD_GROUP("Transform", "");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "position", PROPERTY_HINT_RANGE, "-99999,99999,0.001,or_less,or_greater,hide_slider,suffix:px"), "set_position", "get_position");
|
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "position", PROPERTY_HINT_RANGE, "-99999,99999,0.001,or_less,or_greater,hide_slider,suffix:px"), "set_position", "get_position");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "rotation", PROPERTY_HINT_RANGE, "-360,360,0.1,or_less,or_greater,radians"), "set_rotation", "get_rotation");
|
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "rotation", PROPERTY_HINT_RANGE, "-360,360,0.1,or_less,or_greater,radians"), "set_rotation", "get_rotation");
|
||||||
|
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "rotation_degrees", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_rotation_degrees", "get_rotation_degrees");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "scale", PROPERTY_HINT_LINK), "set_scale", "get_scale");
|
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "scale", PROPERTY_HINT_LINK), "set_scale", "get_scale");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "skew", PROPERTY_HINT_RANGE, "-89.9,89.9,0.1,radians"), "set_skew", "get_skew");
|
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "skew", PROPERTY_HINT_RANGE, "-89.9,89.9,0.1,radians"), "set_skew", "get_skew");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM2D, "transform", PROPERTY_HINT_NONE, "suffix:px", PROPERTY_USAGE_NONE), "set_transform", "get_transform");
|
ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM2D, "transform", PROPERTY_HINT_NONE, "suffix:px", PROPERTY_USAGE_NONE), "set_transform", "get_transform");
|
||||||
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "global_position", PROPERTY_HINT_NONE, "suffix:px", PROPERTY_USAGE_NONE), "set_global_position", "get_global_position");
|
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "global_position", PROPERTY_HINT_NONE, "suffix:px", PROPERTY_USAGE_NONE), "set_global_position", "get_global_position");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "global_rotation", PROPERTY_HINT_NONE, "radians", PROPERTY_USAGE_NONE), "set_global_rotation", "get_global_rotation");
|
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "global_rotation", PROPERTY_HINT_NONE, "radians", PROPERTY_USAGE_NONE), "set_global_rotation", "get_global_rotation");
|
||||||
|
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "global_rotation_degrees", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_global_rotation_degrees", "get_global_rotation_degrees");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "global_scale", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_global_scale", "get_global_scale");
|
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "global_scale", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_global_scale", "get_global_scale");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "global_skew", PROPERTY_HINT_NONE, "radians", PROPERTY_USAGE_NONE), "set_global_skew", "get_global_skew");
|
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "global_skew", PROPERTY_HINT_NONE, "radians", PROPERTY_USAGE_NONE), "set_global_skew", "get_global_skew");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM2D, "global_transform", PROPERTY_HINT_NONE, "suffix:px", PROPERTY_USAGE_NONE), "set_global_transform", "get_global_transform");
|
ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM2D, "global_transform", PROPERTY_HINT_NONE, "suffix:px", PROPERTY_USAGE_NONE), "set_global_transform", "get_global_transform");
|
||||||
|
|
|
@ -73,6 +73,7 @@ public:
|
||||||
|
|
||||||
void set_position(const Point2 &p_pos);
|
void set_position(const Point2 &p_pos);
|
||||||
void set_rotation(real_t p_radians);
|
void set_rotation(real_t p_radians);
|
||||||
|
void set_rotation_degrees(real_t p_degrees);
|
||||||
void set_skew(real_t p_radians);
|
void set_skew(real_t p_radians);
|
||||||
void set_scale(const Size2 &p_scale);
|
void set_scale(const Size2 &p_scale);
|
||||||
|
|
||||||
|
@ -85,11 +86,13 @@ public:
|
||||||
|
|
||||||
Point2 get_position() const;
|
Point2 get_position() const;
|
||||||
real_t get_rotation() const;
|
real_t get_rotation() const;
|
||||||
|
real_t get_rotation_degrees() const;
|
||||||
real_t get_skew() const;
|
real_t get_skew() const;
|
||||||
Size2 get_scale() const;
|
Size2 get_scale() const;
|
||||||
|
|
||||||
Point2 get_global_position() const;
|
Point2 get_global_position() const;
|
||||||
real_t get_global_rotation() const;
|
real_t get_global_rotation() const;
|
||||||
|
real_t get_global_rotation_degrees() const;
|
||||||
real_t get_global_skew() const;
|
real_t get_global_skew() const;
|
||||||
Size2 get_global_scale() const;
|
Size2 get_global_scale() const;
|
||||||
|
|
||||||
|
@ -97,6 +100,7 @@ public:
|
||||||
void set_global_transform(const Transform2D &p_transform);
|
void set_global_transform(const Transform2D &p_transform);
|
||||||
void set_global_position(const Point2 &p_pos);
|
void set_global_position(const Point2 &p_pos);
|
||||||
void set_global_rotation(const real_t p_radians);
|
void set_global_rotation(const real_t p_radians);
|
||||||
|
void set_global_rotation_degrees(const real_t p_degrees);
|
||||||
void set_global_skew(const real_t p_radians);
|
void set_global_skew(const real_t p_radians);
|
||||||
void set_global_scale(const Size2 &p_scale);
|
void set_global_scale(const Size2 &p_scale);
|
||||||
|
|
||||||
|
|
|
@ -251,12 +251,22 @@ Vector3 Node3D::get_global_rotation() const {
|
||||||
return get_global_transform().get_basis().get_euler();
|
return get_global_transform().get_basis().get_euler();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Vector3 Node3D::get_global_rotation_degrees() const {
|
||||||
|
Vector3 radians = get_global_rotation();
|
||||||
|
return Vector3(Math::rad_to_deg(radians.x), Math::rad_to_deg(radians.y), Math::rad_to_deg(radians.z));
|
||||||
|
}
|
||||||
|
|
||||||
void Node3D::set_global_rotation(const Vector3 &p_euler_rad) {
|
void Node3D::set_global_rotation(const Vector3 &p_euler_rad) {
|
||||||
Transform3D transform = get_global_transform();
|
Transform3D transform = get_global_transform();
|
||||||
transform.basis = Basis::from_euler(p_euler_rad);
|
transform.basis = Basis::from_euler(p_euler_rad);
|
||||||
set_global_transform(transform);
|
set_global_transform(transform);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Node3D::set_global_rotation_degrees(const Vector3 &p_euler_degrees) {
|
||||||
|
Vector3 radians(Math::deg_to_rad(p_euler_degrees.x), Math::deg_to_rad(p_euler_degrees.y), Math::deg_to_rad(p_euler_degrees.z));
|
||||||
|
set_global_rotation(radians);
|
||||||
|
}
|
||||||
|
|
||||||
void Node3D::set_transform(const Transform3D &p_transform) {
|
void Node3D::set_transform(const Transform3D &p_transform) {
|
||||||
data.local_transform = p_transform;
|
data.local_transform = p_transform;
|
||||||
data.dirty = DIRTY_EULER_ROTATION_AND_SCALE; // Make rot/scale dirty.
|
data.dirty = DIRTY_EULER_ROTATION_AND_SCALE; // Make rot/scale dirty.
|
||||||
|
@ -440,6 +450,11 @@ void Node3D::set_rotation(const Vector3 &p_euler_rad) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Node3D::set_rotation_degrees(const Vector3 &p_euler_degrees) {
|
||||||
|
Vector3 radians(Math::deg_to_rad(p_euler_degrees.x), Math::deg_to_rad(p_euler_degrees.y), Math::deg_to_rad(p_euler_degrees.z));
|
||||||
|
set_rotation(radians);
|
||||||
|
}
|
||||||
|
|
||||||
void Node3D::set_scale(const Vector3 &p_scale) {
|
void Node3D::set_scale(const Vector3 &p_scale) {
|
||||||
if (data.dirty & DIRTY_EULER_ROTATION_AND_SCALE) {
|
if (data.dirty & DIRTY_EULER_ROTATION_AND_SCALE) {
|
||||||
// Update rotation only if rotation and scale are dirty, as scale will be overridden.
|
// Update rotation only if rotation and scale are dirty, as scale will be overridden.
|
||||||
|
@ -467,6 +482,11 @@ Vector3 Node3D::get_rotation() const {
|
||||||
return data.euler_rotation;
|
return data.euler_rotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Vector3 Node3D::get_rotation_degrees() const {
|
||||||
|
Vector3 radians = get_rotation();
|
||||||
|
return Vector3(Math::rad_to_deg(radians.x), Math::rad_to_deg(radians.y), Math::rad_to_deg(radians.z));
|
||||||
|
}
|
||||||
|
|
||||||
Vector3 Node3D::get_scale() const {
|
Vector3 Node3D::get_scale() const {
|
||||||
if (data.dirty & DIRTY_EULER_ROTATION_AND_SCALE) {
|
if (data.dirty & DIRTY_EULER_ROTATION_AND_SCALE) {
|
||||||
_update_rotation_and_scale();
|
_update_rotation_and_scale();
|
||||||
|
@ -958,8 +978,10 @@ void Node3D::_bind_methods() {
|
||||||
ClassDB::bind_method(D_METHOD("get_transform"), &Node3D::get_transform);
|
ClassDB::bind_method(D_METHOD("get_transform"), &Node3D::get_transform);
|
||||||
ClassDB::bind_method(D_METHOD("set_position", "position"), &Node3D::set_position);
|
ClassDB::bind_method(D_METHOD("set_position", "position"), &Node3D::set_position);
|
||||||
ClassDB::bind_method(D_METHOD("get_position"), &Node3D::get_position);
|
ClassDB::bind_method(D_METHOD("get_position"), &Node3D::get_position);
|
||||||
ClassDB::bind_method(D_METHOD("set_rotation", "euler"), &Node3D::set_rotation);
|
ClassDB::bind_method(D_METHOD("set_rotation", "euler_radians"), &Node3D::set_rotation);
|
||||||
ClassDB::bind_method(D_METHOD("get_rotation"), &Node3D::get_rotation);
|
ClassDB::bind_method(D_METHOD("get_rotation"), &Node3D::get_rotation);
|
||||||
|
ClassDB::bind_method(D_METHOD("set_rotation_degrees", "euler_degrees"), &Node3D::set_rotation_degrees);
|
||||||
|
ClassDB::bind_method(D_METHOD("get_rotation_degrees"), &Node3D::get_rotation_degrees);
|
||||||
ClassDB::bind_method(D_METHOD("set_rotation_order", "order"), &Node3D::set_rotation_order);
|
ClassDB::bind_method(D_METHOD("set_rotation_order", "order"), &Node3D::set_rotation_order);
|
||||||
ClassDB::bind_method(D_METHOD("get_rotation_order"), &Node3D::get_rotation_order);
|
ClassDB::bind_method(D_METHOD("get_rotation_order"), &Node3D::get_rotation_order);
|
||||||
ClassDB::bind_method(D_METHOD("set_rotation_edit_mode", "edit_mode"), &Node3D::set_rotation_edit_mode);
|
ClassDB::bind_method(D_METHOD("set_rotation_edit_mode", "edit_mode"), &Node3D::set_rotation_edit_mode);
|
||||||
|
@ -975,8 +997,10 @@ void Node3D::_bind_methods() {
|
||||||
ClassDB::bind_method(D_METHOD("get_global_transform"), &Node3D::get_global_transform);
|
ClassDB::bind_method(D_METHOD("get_global_transform"), &Node3D::get_global_transform);
|
||||||
ClassDB::bind_method(D_METHOD("set_global_position", "position"), &Node3D::set_global_position);
|
ClassDB::bind_method(D_METHOD("set_global_position", "position"), &Node3D::set_global_position);
|
||||||
ClassDB::bind_method(D_METHOD("get_global_position"), &Node3D::get_global_position);
|
ClassDB::bind_method(D_METHOD("get_global_position"), &Node3D::get_global_position);
|
||||||
ClassDB::bind_method(D_METHOD("set_global_rotation", "radians"), &Node3D::set_global_rotation);
|
ClassDB::bind_method(D_METHOD("set_global_rotation", "euler_radians"), &Node3D::set_global_rotation);
|
||||||
ClassDB::bind_method(D_METHOD("get_global_rotation"), &Node3D::get_global_rotation);
|
ClassDB::bind_method(D_METHOD("get_global_rotation"), &Node3D::get_global_rotation);
|
||||||
|
ClassDB::bind_method(D_METHOD("set_global_rotation_degrees", "euler_degrees"), &Node3D::set_global_rotation_degrees);
|
||||||
|
ClassDB::bind_method(D_METHOD("get_global_rotation_degrees"), &Node3D::get_global_rotation_degrees);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("get_parent_node_3d"), &Node3D::get_parent_node_3d);
|
ClassDB::bind_method(D_METHOD("get_parent_node_3d"), &Node3D::get_parent_node_3d);
|
||||||
ClassDB::bind_method(D_METHOD("set_ignore_transform_notification", "enabled"), &Node3D::set_ignore_transform_notification);
|
ClassDB::bind_method(D_METHOD("set_ignore_transform_notification", "enabled"), &Node3D::set_ignore_transform_notification);
|
||||||
|
@ -1045,6 +1069,7 @@ void Node3D::_bind_methods() {
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM3D, "global_transform", PROPERTY_HINT_NONE, "suffix:m", PROPERTY_USAGE_NONE), "set_global_transform", "get_global_transform");
|
ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM3D, "global_transform", PROPERTY_HINT_NONE, "suffix:m", PROPERTY_USAGE_NONE), "set_global_transform", "get_global_transform");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "position", PROPERTY_HINT_RANGE, "-99999,99999,0.001,or_greater,or_less,hide_slider,suffix:m", PROPERTY_USAGE_EDITOR), "set_position", "get_position");
|
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "position", PROPERTY_HINT_RANGE, "-99999,99999,0.001,or_greater,or_less,hide_slider,suffix:m", PROPERTY_USAGE_EDITOR), "set_position", "get_position");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "rotation", PROPERTY_HINT_RANGE, "-360,360,0.1,or_less,or_greater,radians", PROPERTY_USAGE_EDITOR), "set_rotation", "get_rotation");
|
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "rotation", PROPERTY_HINT_RANGE, "-360,360,0.1,or_less,or_greater,radians", PROPERTY_USAGE_EDITOR), "set_rotation", "get_rotation");
|
||||||
|
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "rotation_degrees", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_rotation_degrees", "get_rotation_degrees");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::QUATERNION, "quaternion", PROPERTY_HINT_HIDE_QUATERNION_EDIT, "", PROPERTY_USAGE_EDITOR), "set_quaternion", "get_quaternion");
|
ADD_PROPERTY(PropertyInfo(Variant::QUATERNION, "quaternion", PROPERTY_HINT_HIDE_QUATERNION_EDIT, "", PROPERTY_USAGE_EDITOR), "set_quaternion", "get_quaternion");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::BASIS, "basis", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "set_basis", "get_basis");
|
ADD_PROPERTY(PropertyInfo(Variant::BASIS, "basis", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "set_basis", "get_basis");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "scale", PROPERTY_HINT_LINK, "", PROPERTY_USAGE_EDITOR), "set_scale", "get_scale");
|
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "scale", PROPERTY_HINT_LINK, "", PROPERTY_USAGE_EDITOR), "set_scale", "get_scale");
|
||||||
|
@ -1054,6 +1079,7 @@ void Node3D::_bind_methods() {
|
||||||
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "global_position", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_global_position", "get_global_position");
|
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "global_position", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_global_position", "get_global_position");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "global_rotation", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_global_rotation", "get_global_rotation");
|
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "global_rotation", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_global_rotation", "get_global_rotation");
|
||||||
|
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "global_rotation_degrees", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_global_rotation_degrees", "get_global_rotation_degrees");
|
||||||
ADD_GROUP("Visibility", "");
|
ADD_GROUP("Visibility", "");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "visible"), "set_visible", "is_visible");
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "visible"), "set_visible", "is_visible");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "visibility_parent", PROPERTY_HINT_NODE_PATH_VALID_TYPES, "GeometryInstance3D"), "set_visibility_parent", "get_visibility_parent");
|
ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "visibility_parent", PROPERTY_HINT_NODE_PATH_VALID_TYPES, "GeometryInstance3D"), "set_visibility_parent", "get_visibility_parent");
|
||||||
|
|
|
@ -172,19 +172,23 @@ public:
|
||||||
|
|
||||||
void set_rotation_order(EulerOrder p_order);
|
void set_rotation_order(EulerOrder p_order);
|
||||||
void set_rotation(const Vector3 &p_euler_rad);
|
void set_rotation(const Vector3 &p_euler_rad);
|
||||||
|
void set_rotation_degrees(const Vector3 &p_euler_degrees);
|
||||||
void set_scale(const Vector3 &p_scale);
|
void set_scale(const Vector3 &p_scale);
|
||||||
|
|
||||||
void set_global_position(const Vector3 &p_position);
|
void set_global_position(const Vector3 &p_position);
|
||||||
void set_global_rotation(const Vector3 &p_euler_rad);
|
void set_global_rotation(const Vector3 &p_euler_rad);
|
||||||
|
void set_global_rotation_degrees(const Vector3 &p_euler_degrees);
|
||||||
|
|
||||||
Vector3 get_position() const;
|
Vector3 get_position() const;
|
||||||
|
|
||||||
EulerOrder get_rotation_order() const;
|
EulerOrder get_rotation_order() const;
|
||||||
Vector3 get_rotation() const;
|
Vector3 get_rotation() const;
|
||||||
|
Vector3 get_rotation_degrees() const;
|
||||||
Vector3 get_scale() const;
|
Vector3 get_scale() const;
|
||||||
|
|
||||||
Vector3 get_global_position() const;
|
Vector3 get_global_position() const;
|
||||||
Vector3 get_global_rotation() const;
|
Vector3 get_global_rotation() const;
|
||||||
|
Vector3 get_global_rotation_degrees() const;
|
||||||
|
|
||||||
void set_transform(const Transform3D &p_transform);
|
void set_transform(const Transform3D &p_transform);
|
||||||
void set_basis(const Basis &p_basis);
|
void set_basis(const Basis &p_basis);
|
||||||
|
|
|
@ -1475,10 +1475,18 @@ void Control::set_rotation(real_t p_radians) {
|
||||||
_notify_transform();
|
_notify_transform();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Control::set_rotation_degrees(real_t p_degrees) {
|
||||||
|
set_rotation(Math::deg_to_rad(p_degrees));
|
||||||
|
}
|
||||||
|
|
||||||
real_t Control::get_rotation() const {
|
real_t Control::get_rotation() const {
|
||||||
return data.rotation;
|
return data.rotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
real_t Control::get_rotation_degrees() const {
|
||||||
|
return Math::rad_to_deg(get_rotation());
|
||||||
|
}
|
||||||
|
|
||||||
void Control::set_pivot_offset(const Vector2 &p_pivot) {
|
void Control::set_pivot_offset(const Vector2 &p_pivot) {
|
||||||
if (data.pivot_offset == p_pivot) {
|
if (data.pivot_offset == p_pivot) {
|
||||||
return;
|
return;
|
||||||
|
@ -3042,6 +3050,7 @@ void Control::_bind_methods() {
|
||||||
ClassDB::bind_method(D_METHOD("set_global_position", "position", "keep_offsets"), &Control::set_global_position, DEFVAL(false));
|
ClassDB::bind_method(D_METHOD("set_global_position", "position", "keep_offsets"), &Control::set_global_position, DEFVAL(false));
|
||||||
ClassDB::bind_method(D_METHOD("_set_global_position", "position"), &Control::_set_global_position);
|
ClassDB::bind_method(D_METHOD("_set_global_position", "position"), &Control::_set_global_position);
|
||||||
ClassDB::bind_method(D_METHOD("set_rotation", "radians"), &Control::set_rotation);
|
ClassDB::bind_method(D_METHOD("set_rotation", "radians"), &Control::set_rotation);
|
||||||
|
ClassDB::bind_method(D_METHOD("set_rotation_degrees", "degrees"), &Control::set_rotation_degrees);
|
||||||
ClassDB::bind_method(D_METHOD("set_scale", "scale"), &Control::set_scale);
|
ClassDB::bind_method(D_METHOD("set_scale", "scale"), &Control::set_scale);
|
||||||
ClassDB::bind_method(D_METHOD("set_pivot_offset", "pivot_offset"), &Control::set_pivot_offset);
|
ClassDB::bind_method(D_METHOD("set_pivot_offset", "pivot_offset"), &Control::set_pivot_offset);
|
||||||
ClassDB::bind_method(D_METHOD("get_begin"), &Control::get_begin);
|
ClassDB::bind_method(D_METHOD("get_begin"), &Control::get_begin);
|
||||||
|
@ -3049,6 +3058,7 @@ void Control::_bind_methods() {
|
||||||
ClassDB::bind_method(D_METHOD("get_position"), &Control::get_position);
|
ClassDB::bind_method(D_METHOD("get_position"), &Control::get_position);
|
||||||
ClassDB::bind_method(D_METHOD("get_size"), &Control::get_size);
|
ClassDB::bind_method(D_METHOD("get_size"), &Control::get_size);
|
||||||
ClassDB::bind_method(D_METHOD("get_rotation"), &Control::get_rotation);
|
ClassDB::bind_method(D_METHOD("get_rotation"), &Control::get_rotation);
|
||||||
|
ClassDB::bind_method(D_METHOD("get_rotation_degrees"), &Control::get_rotation_degrees);
|
||||||
ClassDB::bind_method(D_METHOD("get_scale"), &Control::get_scale);
|
ClassDB::bind_method(D_METHOD("get_scale"), &Control::get_scale);
|
||||||
ClassDB::bind_method(D_METHOD("get_pivot_offset"), &Control::get_pivot_offset);
|
ClassDB::bind_method(D_METHOD("get_pivot_offset"), &Control::get_pivot_offset);
|
||||||
ClassDB::bind_method(D_METHOD("get_custom_minimum_size"), &Control::get_custom_minimum_size);
|
ClassDB::bind_method(D_METHOD("get_custom_minimum_size"), &Control::get_custom_minimum_size);
|
||||||
|
@ -3217,6 +3227,7 @@ void Control::_bind_methods() {
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "position", PROPERTY_HINT_NONE, "suffix:px", PROPERTY_USAGE_EDITOR), "_set_position", "get_position");
|
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "position", PROPERTY_HINT_NONE, "suffix:px", PROPERTY_USAGE_EDITOR), "_set_position", "get_position");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "global_position", PROPERTY_HINT_NONE, "suffix:px", PROPERTY_USAGE_NONE), "_set_global_position", "get_global_position");
|
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "global_position", PROPERTY_HINT_NONE, "suffix:px", PROPERTY_USAGE_NONE), "_set_global_position", "get_global_position");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "rotation", PROPERTY_HINT_RANGE, "-360,360,0.1,or_less,or_greater,radians"), "set_rotation", "get_rotation");
|
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "rotation", PROPERTY_HINT_RANGE, "-360,360,0.1,or_less,or_greater,radians"), "set_rotation", "get_rotation");
|
||||||
|
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "rotation_degrees", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_rotation_degrees", "get_rotation_degrees");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "scale"), "set_scale", "get_scale");
|
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "scale"), "set_scale", "get_scale");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "pivot_offset", PROPERTY_HINT_NONE, "suffix:px"), "set_pivot_offset", "get_pivot_offset");
|
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "pivot_offset", PROPERTY_HINT_NONE, "suffix:px"), "set_pivot_offset", "get_pivot_offset");
|
||||||
|
|
||||||
|
|
|
@ -451,7 +451,9 @@ public:
|
||||||
void set_scale(const Vector2 &p_scale);
|
void set_scale(const Vector2 &p_scale);
|
||||||
Vector2 get_scale() const;
|
Vector2 get_scale() const;
|
||||||
void set_rotation(real_t p_radians);
|
void set_rotation(real_t p_radians);
|
||||||
|
void set_rotation_degrees(real_t p_degrees);
|
||||||
real_t get_rotation() const;
|
real_t get_rotation() const;
|
||||||
|
real_t get_rotation_degrees() const;
|
||||||
void set_pivot_offset(const Vector2 &p_pivot);
|
void set_pivot_offset(const Vector2 &p_pivot);
|
||||||
Vector2 get_pivot_offset() const;
|
Vector2 get_pivot_offset() const;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue