From 482e07af7e5c8b85463f950036dc7b14cb8cd3b4 Mon Sep 17 00:00:00 2001 From: letheed Date: Fri, 10 Nov 2017 11:07:52 +0100 Subject: Unify degree members and properties --- scene/2d/node_2d.cpp | 26 +++++++++++++------------- scene/2d/node_2d.h | 8 ++++---- scene/2d/polygon_2d.cpp | 10 +++++----- scene/2d/polygon_2d.h | 6 +++--- 4 files changed, 25 insertions(+), 25 deletions(-) (limited to 'scene/2d') diff --git a/scene/2d/node_2d.cpp b/scene/2d/node_2d.cpp index b6111e9765..c562a4652d 100644 --- a/scene/2d/node_2d.cpp +++ b/scene/2d/node_2d.cpp @@ -65,7 +65,7 @@ void Node2D::edit_set_state(const Variant &p_state) { _scale = state[2]; _update_transform(); _change_notify("rotation"); - _change_notify("rotation_deg"); + _change_notify("rotation_degrees"); _change_notify("scale"); _change_notify("position"); } @@ -106,7 +106,7 @@ void Node2D::edit_rotate(float p_rot) { angle += p_rot; _update_transform(); _change_notify("rotation"); - _change_notify("rotation_deg"); + _change_notify("rotation_degrees"); } void Node2D::_update_xform_values() { @@ -147,10 +147,10 @@ void Node2D::set_rotation(float p_radians) { angle = p_radians; _update_transform(); _change_notify("rotation"); - _change_notify("rotation_deg"); + _change_notify("rotation_degrees"); } -void Node2D::set_rotation_in_degrees(float p_degrees) { +void Node2D::set_rotation_degrees(float p_degrees) { set_rotation(Math::deg2rad(p_degrees)); } @@ -182,7 +182,7 @@ float Node2D::get_rotation() const { return angle; } -float Node2D::get_rotation_in_degrees() const { +float Node2D::get_rotation_degrees() const { return Math::rad2deg(get_rotation()); } @@ -287,12 +287,12 @@ void Node2D::set_global_rotation(float p_radians) { } } -float Node2D::get_global_rotation_in_degrees() const { +float Node2D::get_global_rotation_degrees() const { return Math::rad2deg(get_global_rotation()); } -void Node2D::set_global_rotation_in_degrees(float p_degrees) { +void Node2D::set_global_rotation_degrees(float p_degrees) { set_global_rotation(Math::deg2rad(p_degrees)); } @@ -400,12 +400,12 @@ void Node2D::_bind_methods() { 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_in_degrees", "degrees"), &Node2D::set_rotation_in_degrees); + ClassDB::bind_method(D_METHOD("set_rotation_degrees", "degrees"), &Node2D::set_rotation_degrees); 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_rotation"), &Node2D::get_rotation); - ClassDB::bind_method(D_METHOD("get_rotation_in_degrees"), &Node2D::get_rotation_in_degrees); + ClassDB::bind_method(D_METHOD("get_rotation_degrees"), &Node2D::get_rotation_degrees); ClassDB::bind_method(D_METHOD("get_scale"), &Node2D::get_scale); ClassDB::bind_method(D_METHOD("rotate", "radians"), &Node2D::rotate); @@ -419,8 +419,8 @@ void Node2D::_bind_methods() { 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("get_global_rotation"), &Node2D::get_global_rotation); - ClassDB::bind_method(D_METHOD("set_global_rotation_in_degrees", "degrees"), &Node2D::set_global_rotation_in_degrees); - ClassDB::bind_method(D_METHOD("get_global_rotation_in_degrees"), &Node2D::get_global_rotation_in_degrees); + ClassDB::bind_method(D_METHOD("set_global_rotation_degrees", "degrees"), &Node2D::set_global_rotation_degrees); + ClassDB::bind_method(D_METHOD("get_global_rotation_degrees"), &Node2D::get_global_rotation_degrees); ClassDB::bind_method(D_METHOD("set_global_scale", "scale"), &Node2D::set_global_scale); ClassDB::bind_method(D_METHOD("get_global_scale"), &Node2D::get_global_scale); @@ -446,13 +446,13 @@ void Node2D::_bind_methods() { ADD_GROUP("Transform", ""); ADD_PROPERTYNZ(PropertyInfo(Variant::VECTOR2, "position"), "set_position", "get_position"); ADD_PROPERTYNZ(PropertyInfo(Variant::REAL, "rotation", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_rotation", "get_rotation"); - ADD_PROPERTYNZ(PropertyInfo(Variant::REAL, "rotation_deg", PROPERTY_HINT_RANGE, "-1440,1440,0.1", PROPERTY_USAGE_EDITOR), "set_rotation_in_degrees", "get_rotation_in_degrees"); + ADD_PROPERTYNZ(PropertyInfo(Variant::REAL, "rotation_degrees", PROPERTY_HINT_RANGE, "-1440,1440,0.1", PROPERTY_USAGE_EDITOR), "set_rotation_degrees", "get_rotation_degrees"); ADD_PROPERTYNO(PropertyInfo(Variant::VECTOR2, "scale"), "set_scale", "get_scale"); ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM2D, "transform", PROPERTY_HINT_NONE, "", 0), "set_transform", "get_transform"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "global_position", PROPERTY_HINT_NONE, "", 0), "set_global_position", "get_global_position"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "global_rotation", PROPERTY_HINT_NONE, "", 0), "set_global_rotation", "get_global_rotation"); - ADD_PROPERTY(PropertyInfo(Variant::REAL, "global_rotation_deg", PROPERTY_HINT_NONE, "", 0), "set_global_rotation_in_degrees", "get_global_rotation_in_degrees"); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "global_rotation_degrees", PROPERTY_HINT_NONE, "", 0), "set_global_rotation_degrees", "get_global_rotation_degrees"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "global_scale", PROPERTY_HINT_NONE, "", 0), "set_global_scale", "get_global_scale"); ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM2D, "global_transform", PROPERTY_HINT_NONE, "", 0), "set_global_transform", "get_global_transform"); diff --git a/scene/2d/node_2d.h b/scene/2d/node_2d.h index 8890c829f8..eca1e96c82 100644 --- a/scene/2d/node_2d.h +++ b/scene/2d/node_2d.h @@ -66,7 +66,7 @@ public: void set_position(const Point2 &p_pos); void set_rotation(float p_radians); - void set_rotation_in_degrees(float p_degrees); + void set_rotation_degrees(float p_degrees); void set_scale(const Size2 &p_scale); void rotate(float p_radians); @@ -78,12 +78,12 @@ public: Point2 get_position() const; float get_rotation() const; - float get_rotation_in_degrees() const; + float get_rotation_degrees() const; Size2 get_scale() const; Point2 get_global_position() const; float get_global_rotation() const; - float get_global_rotation_in_degrees() const; + float get_global_rotation_degrees() const; Size2 get_global_scale() const; virtual Rect2 get_item_rect() const; @@ -91,7 +91,7 @@ public: void set_global_transform(const Transform2D &p_transform); void set_global_position(const Point2 &p_pos); void set_global_rotation(float p_radians); - void set_global_rotation_in_degrees(float p_degrees); + void set_global_rotation_degrees(float p_degrees); void set_global_scale(const Size2 &p_scale); void set_z(int p_z); diff --git a/scene/2d/polygon_2d.cpp b/scene/2d/polygon_2d.cpp index 197c74352e..b5b5445684 100644 --- a/scene/2d/polygon_2d.cpp +++ b/scene/2d/polygon_2d.cpp @@ -264,11 +264,11 @@ float Polygon2D::get_texture_rotation() const { return tex_rot; } -void Polygon2D::_set_texture_rotationd(float p_rot) { +void Polygon2D::set_texture_rotation_degrees(float p_rot) { set_texture_rotation(Math::deg2rad(p_rot)); } -float Polygon2D::_get_texture_rotationd() const { +float Polygon2D::get_texture_rotation_degrees() const { return Math::rad2deg(get_texture_rotation()); } @@ -348,8 +348,8 @@ void Polygon2D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_texture_rotation", "texture_rotation"), &Polygon2D::set_texture_rotation); ClassDB::bind_method(D_METHOD("get_texture_rotation"), &Polygon2D::get_texture_rotation); - ClassDB::bind_method(D_METHOD("_set_texture_rotationd", "texture_rotation"), &Polygon2D::_set_texture_rotationd); - ClassDB::bind_method(D_METHOD("_get_texture_rotationd"), &Polygon2D::_get_texture_rotationd); + ClassDB::bind_method(D_METHOD("set_texture_rotation_degrees", "texture_rotation"), &Polygon2D::set_texture_rotation_degrees); + ClassDB::bind_method(D_METHOD("get_texture_rotation_degrees"), &Polygon2D::get_texture_rotation_degrees); ClassDB::bind_method(D_METHOD("set_texture_scale", "texture_scale"), &Polygon2D::set_texture_scale); ClassDB::bind_method(D_METHOD("get_texture_scale"), &Polygon2D::get_texture_scale); @@ -377,7 +377,7 @@ void Polygon2D::_bind_methods() { ADD_GROUP("Texture", "texture_"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "texture_offset"), "set_texture_offset", "get_texture_offset"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "texture_scale"), "set_texture_scale", "get_texture_scale"); - ADD_PROPERTY(PropertyInfo(Variant::REAL, "texture_rotation", PROPERTY_HINT_RANGE, "-1440,1440,0.1"), "_set_texture_rotationd", "_get_texture_rotationd"); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "texture_rotation", PROPERTY_HINT_RANGE, "-1440,1440,0.1"), "set_texture_rotation_degrees", "get_texture_rotation_degrees"); ADD_GROUP("Invert", "invert_"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "invert_enable"), "set_invert", "get_invert"); diff --git a/scene/2d/polygon_2d.h b/scene/2d/polygon_2d.h index 20c3324a50..0c2c049c18 100644 --- a/scene/2d/polygon_2d.h +++ b/scene/2d/polygon_2d.h @@ -53,9 +53,6 @@ class Polygon2D : public Node2D { mutable bool rect_cache_dirty; mutable Rect2 item_rect; - void _set_texture_rotationd(float p_rot); - float _get_texture_rotationd() const; - protected: void _notification(int p_what); static void _bind_methods(); @@ -82,6 +79,9 @@ public: void set_texture_rotation(float p_rot); float get_texture_rotation() const; + void set_texture_rotation_degrees(float p_rot); + float get_texture_rotation_degrees() const; + void set_texture_scale(const Size2 &p_scale); Size2 get_texture_scale() const; -- cgit v1.2.3