diff options
Diffstat (limited to 'scene/main')
-rw-r--r-- | scene/main/canvas_layer.cpp | 14 | ||||
-rw-r--r-- | scene/main/canvas_layer.h | 3 | ||||
-rw-r--r-- | scene/main/node.cpp | 48 | ||||
-rw-r--r-- | scene/main/node.h | 6 | ||||
-rw-r--r-- | scene/main/timer.cpp | 2 | ||||
-rw-r--r-- | scene/main/viewport.cpp | 13 | ||||
-rw-r--r-- | scene/main/viewport.h | 5 |
7 files changed, 68 insertions, 23 deletions
diff --git a/scene/main/canvas_layer.cpp b/scene/main/canvas_layer.cpp index f699e68715..4540e42b4c 100644 --- a/scene/main/canvas_layer.cpp +++ b/scene/main/canvas_layer.cpp @@ -103,14 +103,6 @@ real_t CanvasLayer::get_rotation() const { return rot; } -void CanvasLayer::set_rotation_degrees(real_t p_degrees) { - set_rotation(Math::deg2rad(p_degrees)); -} - -real_t CanvasLayer::get_rotation_degrees() const { - return Math::rad2deg(get_rotation()); -} - void CanvasLayer::set_scale(const Vector2 &p_scale) { if (locrotscale_dirty) { _update_locrotscale(); @@ -277,9 +269,6 @@ void CanvasLayer::_bind_methods() { ClassDB::bind_method(D_METHOD("set_rotation", "radians"), &CanvasLayer::set_rotation); ClassDB::bind_method(D_METHOD("get_rotation"), &CanvasLayer::get_rotation); - ClassDB::bind_method(D_METHOD("set_rotation_degrees", "degrees"), &CanvasLayer::set_rotation_degrees); - ClassDB::bind_method(D_METHOD("get_rotation_degrees"), &CanvasLayer::get_rotation_degrees); - ClassDB::bind_method(D_METHOD("set_scale", "scale"), &CanvasLayer::set_scale); ClassDB::bind_method(D_METHOD("get_scale"), &CanvasLayer::get_scale); @@ -298,8 +287,7 @@ void CanvasLayer::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::INT, "layer", PROPERTY_HINT_RANGE, "-128,128,1"), "set_layer", "get_layer"); ADD_GROUP("Transform", ""); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "offset"), "set_offset", "get_offset"); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "rotation_degrees", PROPERTY_HINT_RANGE, "-1080,1080,0.1,or_lesser,or_greater", PROPERTY_USAGE_EDITOR), "set_rotation_degrees", "get_rotation_degrees"); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "rotation", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_rotation", "get_rotation"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "rotation", PROPERTY_HINT_RANGE, "-1080,1080,0.1,or_lesser,or_greater,radians"), "set_rotation", "get_rotation"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "scale"), "set_scale", "get_scale"); ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM2D, "transform"), "set_transform", "get_transform"); ADD_GROUP("", ""); diff --git a/scene/main/canvas_layer.h b/scene/main/canvas_layer.h index 899039340a..5de1ebf18d 100644 --- a/scene/main/canvas_layer.h +++ b/scene/main/canvas_layer.h @@ -79,9 +79,6 @@ public: void set_rotation(real_t p_radians); real_t get_rotation() const; - void set_rotation_degrees(real_t p_degrees); - real_t get_rotation_degrees() const; - void set_scale(const Size2 &p_scale); Size2 get_scale() const; diff --git a/scene/main/node.cpp b/scene/main/node.cpp index 9479b1339d..ac092d9862 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -403,6 +403,7 @@ void Node::set_process_mode(ProcessMode p_mode) { } bool prev_can_process = can_process(); + bool prev_enabled = _is_enabled(); data.process_mode = p_mode; @@ -417,6 +418,7 @@ void Node::set_process_mode(ProcessMode p_mode) { } bool next_can_process = can_process(); + bool next_enabled = _is_enabled(); int pause_notification = 0; @@ -426,7 +428,16 @@ void Node::set_process_mode(ProcessMode p_mode) { pause_notification = NOTIFICATION_UNPAUSED; } - _propagate_process_owner(data.process_owner, pause_notification); + int enabled_notification = 0; + + if (prev_enabled && !next_enabled) { + enabled_notification = NOTIFICATION_DISABLED; + } else if (!prev_enabled && next_enabled) { + enabled_notification = NOTIFICATION_ENABLED; + } + + _propagate_process_owner(data.process_owner, pause_notification, enabled_notification); + #ifdef TOOLS_ENABLED // This is required for the editor to update the visibility of disabled nodes // It's very expensive during runtime to change, so editor-only @@ -455,17 +466,21 @@ Node::ProcessMode Node::get_process_mode() const { return data.process_mode; } -void Node::_propagate_process_owner(Node *p_owner, int p_notification) { +void Node::_propagate_process_owner(Node *p_owner, int p_pause_notification, int p_enabled_notification) { data.process_owner = p_owner; - if (p_notification != 0) { - notification(p_notification); + if (p_pause_notification != 0) { + notification(p_pause_notification); + } + + if (p_enabled_notification != 0) { + notification(p_enabled_notification); } for (int i = 0; i < data.children.size(); i++) { Node *c = data.children[i]; if (c->data.process_mode == PROCESS_MODE_INHERIT) { - c->_propagate_process_owner(p_owner, p_notification); + c->_propagate_process_owner(p_owner, p_pause_notification, p_enabled_notification); } } } @@ -669,6 +684,27 @@ bool Node::_can_process(bool p_paused) const { } } +bool Node::_is_enabled() const { + ProcessMode process_mode; + + if (data.process_mode == PROCESS_MODE_INHERIT) { + if (!data.process_owner) { + process_mode = PROCESS_MODE_PAUSABLE; + } else { + process_mode = data.process_owner->data.process_mode; + } + } else { + process_mode = data.process_mode; + } + + return (process_mode != PROCESS_MODE_DISABLED); +} + +bool Node::is_enabled() const { + ERR_FAIL_COND_V(!is_inside_tree(), false); + return _is_enabled(); +} + float Node::get_physics_process_delta_time() const { if (data.tree) { return data.tree->get_physics_process_time(); @@ -2628,6 +2664,8 @@ void Node::_bind_methods() { BIND_CONSTANT(NOTIFICATION_INTERNAL_PROCESS); BIND_CONSTANT(NOTIFICATION_INTERNAL_PHYSICS_PROCESS); BIND_CONSTANT(NOTIFICATION_POST_ENTER_TREE); + BIND_CONSTANT(NOTIFICATION_DISABLED); + BIND_CONSTANT(NOTIFICATION_ENABLED); BIND_CONSTANT(NOTIFICATION_EDITOR_PRE_SAVE); BIND_CONSTANT(NOTIFICATION_EDITOR_POST_SAVE); diff --git a/scene/main/node.h b/scene/main/node.h index f685eac86a..fc5af43829 100644 --- a/scene/main/node.h +++ b/scene/main/node.h @@ -166,7 +166,7 @@ private: void _propagate_after_exit_tree(); void _propagate_validate_owner(); void _print_stray_nodes(); - void _propagate_process_owner(Node *p_owner, int p_notification); + void _propagate_process_owner(Node *p_owner, int p_pause_notification, int p_enabled_notification); Array _get_node_and_resource(const NodePath &p_path); void _duplicate_signals(const Node *p_original, Node *p_copy) const; @@ -184,6 +184,7 @@ private: void _propagate_pause_notification(bool p_enable); _FORCE_INLINE_ bool _can_process(bool p_paused) const; + _FORCE_INLINE_ bool _is_enabled() const; protected: void _block() { data.blocked++; } @@ -227,6 +228,8 @@ public: NOTIFICATION_INTERNAL_PROCESS = 25, NOTIFICATION_INTERNAL_PHYSICS_PROCESS = 26, NOTIFICATION_POST_ENTER_TREE = 27, + NOTIFICATION_DISABLED = 28, + NOTIFICATION_ENABLED = 29, //keep these linked to node NOTIFICATION_WM_MOUSE_ENTER = 1002, @@ -385,6 +388,7 @@ public: ProcessMode get_process_mode() const; bool can_process() const; bool can_process_notification(int p_what) const; + bool is_enabled() const; void request_ready(); diff --git a/scene/main/timer.cpp b/scene/main/timer.cpp index ea9f51aa5d..f52237251c 100644 --- a/scene/main/timer.cpp +++ b/scene/main/timer.cpp @@ -207,7 +207,7 @@ void Timer::_bind_methods() { ADD_SIGNAL(MethodInfo("timeout")); ADD_PROPERTY(PropertyInfo(Variant::INT, "process_callback", PROPERTY_HINT_ENUM, "Physics,Idle"), "set_timer_process_callback", "get_timer_process_callback"); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "wait_time", PROPERTY_HINT_EXP_RANGE, "0.001,4096,0.001,or_greater"), "set_wait_time", "get_wait_time"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "wait_time", PROPERTY_HINT_RANGE, "0.001,4096,0.001,or_greater,exp"), "set_wait_time", "get_wait_time"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "one_shot"), "set_one_shot", "is_one_shot"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "autostart"), "set_autostart", "has_autostart"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "paused", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_paused", "is_paused"); diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index cc56d6a49e..319e589036 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -929,6 +929,15 @@ bool Viewport::is_audio_listener_2d() const { return audio_listener_2d; } +void Viewport::set_disable_3d(bool p_disable) { + disable_3d = p_disable; + RenderingServer::get_singleton()->viewport_set_disable_3d(viewport, disable_3d); +} + +bool Viewport::is_3d_disabled() const { + return disable_3d; +} + void Viewport::enable_canvas_transform_override(bool p_enable) { if (override_canvas_transform == p_enable) { return; @@ -3516,6 +3525,9 @@ void Viewport::_bind_methods() { ClassDB::bind_method(D_METHOD("set_as_audio_listener_2d", "enable"), &Viewport::set_as_audio_listener_2d); ClassDB::bind_method(D_METHOD("is_audio_listener_2d"), &Viewport::is_audio_listener_2d); + ClassDB::bind_method(D_METHOD("set_disable_3d", "disable"), &Viewport::set_disable_3d); + ClassDB::bind_method(D_METHOD("is_3d_disabled"), &Viewport::is_3d_disabled); + ClassDB::bind_method(D_METHOD("get_mouse_position"), &Viewport::get_mouse_position); ClassDB::bind_method(D_METHOD("warp_mouse", "to_position"), &Viewport::warp_mouse); @@ -3582,6 +3594,7 @@ void Viewport::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::BOOL, "snap_2d_transforms_to_pixel"), "set_snap_2d_transforms_to_pixel", "is_snap_2d_transforms_to_pixel_enabled"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "snap_2d_vertices_to_pixel"), "set_snap_2d_vertices_to_pixel", "is_snap_2d_vertices_to_pixel_enabled"); ADD_GROUP("Rendering", ""); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "disable_3d"), "set_disable_3d", "is_3d_disabled"); ADD_PROPERTY(PropertyInfo(Variant::INT, "msaa", PROPERTY_HINT_ENUM, "Disabled (Fastest),2x (Fast),4x (Average),8x (Slow),16x (Slower)"), "set_msaa", "get_msaa"); ADD_PROPERTY(PropertyInfo(Variant::INT, "screen_space_aa", PROPERTY_HINT_ENUM, "Disabled (Fastest),FXAA (Fast)"), "set_screen_space_aa", "get_screen_space_aa"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_debanding"), "set_use_debanding", "is_using_debanding"); diff --git a/scene/main/viewport.h b/scene/main/viewport.h index d905e44a82..29491a1178 100644 --- a/scene/main/viewport.h +++ b/scene/main/viewport.h @@ -288,6 +288,8 @@ private: void _update_listener(); void _update_listener_2d(); + bool disable_3d = false; + void _propagate_enter_world(Node *p_node); void _propagate_exit_world(Node *p_node); void _propagate_viewport_notification(Node *p_node, int p_what); @@ -503,6 +505,9 @@ public: void set_as_audio_listener_2d(bool p_enable); bool is_audio_listener_2d() const; + void set_disable_3d(bool p_disable); + bool is_3d_disabled() const; + void update_canvas_items(); Rect2 get_visible_rect() const; |