Merge pull request #18118 from akien-mga/nodes-internal-process

Use internal physics processing for Nodes' internal logic
This commit is contained in:
Rémi Verschelde 2018-04-12 10:06:28 +02:00 committed by GitHub
commit cdf22e61ab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 36 additions and 36 deletions

View file

@ -101,7 +101,7 @@ void RayCast2D::set_enabled(bool p_enabled) {
enabled = p_enabled; enabled = p_enabled;
if (is_inside_tree() && !Engine::get_singleton()->is_editor_hint()) if (is_inside_tree() && !Engine::get_singleton()->is_editor_hint())
set_physics_process(p_enabled); set_physics_process_internal(p_enabled);
if (!p_enabled) if (!p_enabled)
collided = false; collided = false;
} }
@ -141,9 +141,9 @@ void RayCast2D::_notification(int p_what) {
case NOTIFICATION_ENTER_TREE: { case NOTIFICATION_ENTER_TREE: {
if (enabled && !Engine::get_singleton()->is_editor_hint()) if (enabled && !Engine::get_singleton()->is_editor_hint())
set_physics_process(true); set_physics_process_internal(true);
else else
set_physics_process(false); set_physics_process_internal(false);
if (Object::cast_to<CollisionObject2D>(get_parent())) { if (Object::cast_to<CollisionObject2D>(get_parent())) {
if (exclude_parent_body) if (exclude_parent_body)
@ -155,7 +155,7 @@ void RayCast2D::_notification(int p_what) {
case NOTIFICATION_EXIT_TREE: { case NOTIFICATION_EXIT_TREE: {
if (enabled) if (enabled)
set_physics_process(false); set_physics_process_internal(false);
} break; } break;
@ -183,7 +183,7 @@ void RayCast2D::_notification(int p_what) {
} break; } break;
case NOTIFICATION_PHYSICS_PROCESS: { case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: {
if (!enabled) if (!enabled)
break; break;

View file

@ -103,7 +103,7 @@ void RayCast::set_enabled(bool p_enabled) {
enabled = p_enabled; enabled = p_enabled;
if (is_inside_tree() && !Engine::get_singleton()->is_editor_hint()) if (is_inside_tree() && !Engine::get_singleton()->is_editor_hint())
set_physics_process(p_enabled); set_physics_process_internal(p_enabled);
if (!p_enabled) if (!p_enabled)
collided = false; collided = false;
@ -150,12 +150,12 @@ void RayCast::_notification(int p_what) {
case NOTIFICATION_ENTER_TREE: { case NOTIFICATION_ENTER_TREE: {
if (enabled && !Engine::get_singleton()->is_editor_hint()) { if (enabled && !Engine::get_singleton()->is_editor_hint()) {
set_physics_process(true); set_physics_process_internal(true);
if (get_tree()->is_debugging_collisions_hint()) if (get_tree()->is_debugging_collisions_hint())
_update_debug_shape(); _update_debug_shape();
} else } else
set_physics_process(false); set_physics_process_internal(false);
if (Object::cast_to<CollisionObject>(get_parent())) { if (Object::cast_to<CollisionObject>(get_parent())) {
if (exclude_parent_body) if (exclude_parent_body)
@ -168,14 +168,14 @@ void RayCast::_notification(int p_what) {
case NOTIFICATION_EXIT_TREE: { case NOTIFICATION_EXIT_TREE: {
if (enabled) { if (enabled) {
set_physics_process(false); set_physics_process_internal(false);
} }
if (debug_shape) if (debug_shape)
_clear_debug_shape(); _clear_debug_shape();
} break; } break;
case NOTIFICATION_PHYSICS_PROCESS: { case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: {
if (!enabled) if (!enabled)
break; break;

View file

@ -182,8 +182,8 @@ void AnimationPlayer::_notification(int p_what) {
if (!processing) { if (!processing) {
//make sure that a previous process state was not saved //make sure that a previous process state was not saved
//only process if "processing" is set //only process if "processing" is set
set_physics_process(false); set_physics_process_internal(false);
set_process(false); set_process_internal(false);
} }
//_set_process(false); //_set_process(false);
clear_caches(); clear_caches();

View file

@ -114,7 +114,7 @@ void ScrollBar::_gui_input(Ref<InputEvent> p_event) {
if (smooth_scroll_enabled) { if (smooth_scroll_enabled) {
scrolling = true; scrolling = true;
set_physics_process(true); set_physics_process_internal(true);
} else { } else {
set_value(target_scroll); set_value(target_scroll);
} }
@ -138,7 +138,7 @@ void ScrollBar::_gui_input(Ref<InputEvent> p_event) {
if (smooth_scroll_enabled) { if (smooth_scroll_enabled) {
scrolling = true; scrolling = true;
set_physics_process(true); set_physics_process_internal(true);
} else { } else {
set_value(target_scroll); set_value(target_scroll);
} }
@ -322,7 +322,7 @@ void ScrollBar::_notification(int p_what) {
drag_slave = NULL; drag_slave = NULL;
} }
if (p_what == NOTIFICATION_PHYSICS_PROCESS) { if (p_what == NOTIFICATION_INTERNAL_PHYSICS_PROCESS) {
if (scrolling) { if (scrolling) {
if (get_value() != target_scroll) { if (get_value() != target_scroll) {
@ -337,7 +337,7 @@ void ScrollBar::_notification(int p_what) {
} }
} else { } else {
scrolling = false; scrolling = false;
set_physics_process(false); set_physics_process_internal(false);
} }
} else if (drag_slave_touching) { } else if (drag_slave_touching) {
@ -397,7 +397,7 @@ void ScrollBar::_notification(int p_what) {
} }
if (turnoff) { if (turnoff) {
set_physics_process(false); set_physics_process_internal(false);
drag_slave_touching = false; drag_slave_touching = false;
drag_slave_touching_deaccel = false; drag_slave_touching_deaccel = false;
} }
@ -566,7 +566,7 @@ void ScrollBar::_drag_slave_input(const Ref<InputEvent> &p_input) {
if (mb->is_pressed()) { if (mb->is_pressed()) {
if (drag_slave_touching) { if (drag_slave_touching) {
set_physics_process(false); set_physics_process_internal(false);
drag_slave_touching_deaccel = false; drag_slave_touching_deaccel = false;
drag_slave_touching = false; drag_slave_touching = false;
drag_slave_speed = Vector2(); drag_slave_speed = Vector2();
@ -586,7 +586,7 @@ void ScrollBar::_drag_slave_input(const Ref<InputEvent> &p_input) {
drag_slave_touching_deaccel = false; drag_slave_touching_deaccel = false;
time_since_motion = 0; time_since_motion = 0;
if (drag_slave_touching) { if (drag_slave_touching) {
set_physics_process(true); set_physics_process_internal(true);
time_since_motion = 0; time_since_motion = 0;
} }
} }
@ -598,7 +598,7 @@ void ScrollBar::_drag_slave_input(const Ref<InputEvent> &p_input) {
if (drag_slave_speed == Vector2()) { if (drag_slave_speed == Vector2()) {
drag_slave_touching_deaccel = false; drag_slave_touching_deaccel = false;
drag_slave_touching = false; drag_slave_touching = false;
set_physics_process(false); set_physics_process_internal(false);
} else { } else {
drag_slave_touching_deaccel = true; drag_slave_touching_deaccel = true;

View file

@ -68,7 +68,7 @@ Size2 ScrollContainer::get_minimum_size() const {
}; };
void ScrollContainer::_cancel_drag() { void ScrollContainer::_cancel_drag() {
set_physics_process(false); set_physics_process_internal(false);
drag_touching_deaccel = false; drag_touching_deaccel = false;
drag_touching = false; drag_touching = false;
drag_speed = Vector2(); drag_speed = Vector2();
@ -141,7 +141,7 @@ void ScrollContainer::_gui_input(const Ref<InputEvent> &p_gui_input) {
beyond_deadzone = false; beyond_deadzone = false;
time_since_motion = 0; time_since_motion = 0;
if (drag_touching) { if (drag_touching) {
set_physics_process(true); set_physics_process_internal(true);
time_since_motion = 0; time_since_motion = 0;
} }
} }
@ -278,7 +278,7 @@ void ScrollContainer::_notification(int p_what) {
update_scrollbars(); update_scrollbars();
} }
if (p_what == NOTIFICATION_PHYSICS_PROCESS) { if (p_what == NOTIFICATION_INTERNAL_PHYSICS_PROCESS) {
if (drag_touching) { if (drag_touching) {

View file

@ -539,7 +539,7 @@ void TextEdit::_notification(int p_what) {
draw_caret = false; draw_caret = false;
update(); update();
} break; } break;
case NOTIFICATION_PHYSICS_PROCESS: { case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: {
if (scrolling && v_scroll->get_value() != target_v_scroll) { if (scrolling && v_scroll->get_value() != target_v_scroll) {
double target_y = target_v_scroll - v_scroll->get_value(); double target_y = target_v_scroll - v_scroll->get_value();
double dist = sqrt(target_y * target_y); double dist = sqrt(target_y * target_y);
@ -548,13 +548,13 @@ void TextEdit::_notification(int p_what) {
if (Math::abs(vel) >= dist) { if (Math::abs(vel) >= dist) {
v_scroll->set_value(target_v_scroll); v_scroll->set_value(target_v_scroll);
scrolling = false; scrolling = false;
set_physics_process(false); set_physics_process_internal(false);
} else { } else {
v_scroll->set_value(v_scroll->get_value() + vel); v_scroll->set_value(v_scroll->get_value() + vel);
} }
} else { } else {
scrolling = false; scrolling = false;
set_physics_process(false); set_physics_process_internal(false);
} }
} break; } break;
case NOTIFICATION_DRAW: { case NOTIFICATION_DRAW: {
@ -3027,7 +3027,7 @@ void TextEdit::_scroll_up(real_t p_delta) {
v_scroll->set_value(target_v_scroll); v_scroll->set_value(target_v_scroll);
} else { } else {
scrolling = true; scrolling = true;
set_physics_process(true); set_physics_process_internal(true);
} }
} else { } else {
v_scroll->set_value(target_v_scroll); v_scroll->set_value(target_v_scroll);
@ -3060,7 +3060,7 @@ void TextEdit::_scroll_down(real_t p_delta) {
v_scroll->set_value(target_v_scroll); v_scroll->set_value(target_v_scroll);
} else { } else {
scrolling = true; scrolling = true;
set_physics_process(true); set_physics_process_internal(true);
} }
} else { } else {
v_scroll->set_value(target_v_scroll); v_scroll->set_value(target_v_scroll);

View file

@ -2545,7 +2545,7 @@ void Tree::_gui_input(Ref<InputEvent> p_event) {
if (drag_speed == 0) { if (drag_speed == 0) {
drag_touching_deaccel = false; drag_touching_deaccel = false;
drag_touching = false; drag_touching = false;
set_physics_process(false); set_physics_process_internal(false);
} else { } else {
drag_touching_deaccel = true; drag_touching_deaccel = true;
@ -2611,7 +2611,7 @@ void Tree::_gui_input(Ref<InputEvent> p_event) {
break; break;
if (drag_touching) { if (drag_touching) {
set_physics_process(false); set_physics_process_internal(false);
drag_touching_deaccel = false; drag_touching_deaccel = false;
drag_touching = false; drag_touching = false;
drag_speed = 0; drag_speed = 0;
@ -2626,7 +2626,7 @@ void Tree::_gui_input(Ref<InputEvent> p_event) {
drag_touching = OS::get_singleton()->has_touchscreen_ui_hint(); drag_touching = OS::get_singleton()->has_touchscreen_ui_hint();
drag_touching_deaccel = false; drag_touching_deaccel = false;
if (drag_touching) { if (drag_touching) {
set_physics_process(true); set_physics_process_internal(true);
} }
if (b->get_button_index() == BUTTON_LEFT) { if (b->get_button_index() == BUTTON_LEFT) {
@ -2829,7 +2829,7 @@ void Tree::_notification(int p_what) {
drop_mode_flags = 0; drop_mode_flags = 0;
scrolling = false; scrolling = false;
set_physics_process(false); set_physics_process_internal(false);
update(); update();
} }
if (p_what == NOTIFICATION_DRAG_BEGIN) { if (p_what == NOTIFICATION_DRAG_BEGIN) {
@ -2837,10 +2837,10 @@ void Tree::_notification(int p_what) {
single_select_defer = NULL; single_select_defer = NULL;
if (cache.scroll_speed > 0 && get_rect().has_point(get_viewport()->get_mouse_position() - get_global_position())) { if (cache.scroll_speed > 0 && get_rect().has_point(get_viewport()->get_mouse_position() - get_global_position())) {
scrolling = true; scrolling = true;
set_physics_process(true); set_physics_process_internal(true);
} }
} }
if (p_what == NOTIFICATION_PHYSICS_PROCESS) { if (p_what == NOTIFICATION_INTERNAL_PHYSICS_PROCESS) {
if (drag_touching) { if (drag_touching) {
@ -2853,7 +2853,7 @@ void Tree::_notification(int p_what) {
if (pos < 0) { if (pos < 0) {
pos = 0; pos = 0;
turnoff = true; turnoff = true;
set_physics_process(false); set_physics_process_internal(false);
drag_touching = false; drag_touching = false;
drag_touching_deaccel = false; drag_touching_deaccel = false;
} }
@ -2873,7 +2873,7 @@ void Tree::_notification(int p_what) {
drag_speed = sgn * val; drag_speed = sgn * val;
if (turnoff) { if (turnoff) {
set_physics_process(false); set_physics_process_internal(false);
drag_touching = false; drag_touching = false;
drag_touching_deaccel = false; drag_touching_deaccel = false;
} }