From d9e9eb8d048bbec5941fa684a5e56d5edc5954d0 Mon Sep 17 00:00:00 2001 From: Marcel Admiraal Date: Tue, 22 Dec 2020 09:50:29 +0000 Subject: Rename MainLoop methods to match Node methods --- core/config/engine.h | 10 +++--- core/core_bind.cpp | 6 ++-- core/core_bind.h | 2 +- core/debugger/engine_debugger.cpp | 6 ++-- core/debugger/engine_debugger.h | 6 ++-- core/debugger/remote_debugger.cpp | 2 +- core/input/input.cpp | 10 +++--- core/input/input.h | 2 +- core/os/main_loop.cpp | 24 ++++++------- core/os/main_loop.h | 12 +++---- doc/classes/Engine.xml | 6 ++-- main/main.cpp | 47 +++++++++++++------------ main/main_timer_sync.cpp | 72 +++++++++++++++++++-------------------- main/main_timer_sync.h | 18 +++++----- platform/android/os_android.cpp | 4 +-- platform/iphone/os_iphone.mm | 4 +-- platform/linuxbsd/os_linuxbsd.cpp | 4 +-- platform/osx/os_osx.mm | 4 +-- platform/windows/os_windows.cpp | 4 +-- scene/3d/velocity_tracker_3d.cpp | 6 ++-- scene/main/node.cpp | 42 +++++++++++------------ scene/main/node.h | 8 ++--- scene/main/scene_tree.cpp | 30 +++++++--------- scene/main/scene_tree.h | 12 +++---- tests/test_gui.cpp | 4 +-- tests/test_physics_2d.cpp | 6 ++-- tests/test_physics_3d.cpp | 12 +++---- 27 files changed, 179 insertions(+), 184 deletions(-) diff --git a/core/config/engine.h b/core/config/engine.h index 0d9aa02f28..c0fd64fcc4 100644 --- a/core/config/engine.h +++ b/core/config/engine.h @@ -50,7 +50,7 @@ private: uint64_t frames_drawn = 0; uint32_t _frame_delay = 0; uint64_t _frame_ticks = 0; - float _frame_step = 0; + float _process_step = 0; int ips = 60; float physics_jitter_fix = 0.5; @@ -62,7 +62,7 @@ private: bool abort_on_gpu_errors = false; bool use_validation_layers = false; - uint64_t _idle_frames = 0; + uint64_t _process_frames = 0; bool _in_physics = false; List singletons; @@ -89,10 +89,10 @@ public: uint64_t get_frames_drawn(); uint64_t get_physics_frames() const { return _physics_frames; } - uint64_t get_idle_frames() const { return _idle_frames; } + uint64_t get_process_frames() const { return _process_frames; } bool is_in_physics_frame() const { return _in_physics; } - uint64_t get_idle_frame_ticks() const { return _frame_ticks; } - float get_idle_frame_step() const { return _frame_step; } + uint64_t get_frame_ticks() const { return _frame_ticks; } + float get_process_step() const { return _process_step; } float get_physics_interpolation_fraction() const { return _physics_interpolation_fraction; } void set_time_scale(float p_scale); diff --git a/core/core_bind.cpp b/core/core_bind.cpp index 259d899d39..d769bd28b6 100644 --- a/core/core_bind.cpp +++ b/core/core_bind.cpp @@ -2278,8 +2278,8 @@ uint64_t _Engine::get_physics_frames() const { return Engine::get_singleton()->get_physics_frames(); } -uint64_t _Engine::get_idle_frames() const { - return Engine::get_singleton()->get_idle_frames(); +uint64_t _Engine::get_process_frames() const { + return Engine::get_singleton()->get_process_frames(); } void _Engine::set_time_scale(float p_scale) { @@ -2358,7 +2358,7 @@ void _Engine::_bind_methods() { ClassDB::bind_method(D_METHOD("get_frames_drawn"), &_Engine::get_frames_drawn); ClassDB::bind_method(D_METHOD("get_frames_per_second"), &_Engine::get_frames_per_second); ClassDB::bind_method(D_METHOD("get_physics_frames"), &_Engine::get_physics_frames); - ClassDB::bind_method(D_METHOD("get_idle_frames"), &_Engine::get_idle_frames); + ClassDB::bind_method(D_METHOD("get_process_frames"), &_Engine::get_process_frames); ClassDB::bind_method(D_METHOD("get_main_loop"), &_Engine::get_main_loop); diff --git a/core/core_bind.h b/core/core_bind.h index f3a77a4fa6..08634339ae 100644 --- a/core/core_bind.h +++ b/core/core_bind.h @@ -635,7 +635,7 @@ public: float get_frames_per_second() const; uint64_t get_physics_frames() const; - uint64_t get_idle_frames() const; + uint64_t get_process_frames() const; int get_frames_drawn(); diff --git a/core/debugger/engine_debugger.cpp b/core/debugger/engine_debugger.cpp index 4bf31aa55f..121161f4be 100644 --- a/core/debugger/engine_debugger.cpp +++ b/core/debugger/engine_debugger.cpp @@ -117,9 +117,9 @@ void EngineDebugger::line_poll() { poll_every++; } -void EngineDebugger::iteration(uint64_t p_frame_ticks, uint64_t p_idle_ticks, uint64_t p_physics_ticks, float p_physics_frame_time) { +void EngineDebugger::iteration(uint64_t p_frame_ticks, uint64_t p_process_ticks, uint64_t p_physics_ticks, float p_physics_frame_time) { frame_time = USEC_TO_SEC(p_frame_ticks); - idle_time = USEC_TO_SEC(p_idle_ticks); + process_time = USEC_TO_SEC(p_process_ticks); physics_time = USEC_TO_SEC(p_physics_ticks); physics_frame_time = p_physics_frame_time; // Notify tick to running profilers @@ -128,7 +128,7 @@ void EngineDebugger::iteration(uint64_t p_frame_ticks, uint64_t p_idle_ticks, ui if (!p.active || !p.tick) { continue; } - p.tick(p.data, frame_time, idle_time, physics_time, physics_frame_time); + p.tick(p.data, frame_time, process_time, physics_time, physics_frame_time); } singleton->poll_events(true); } diff --git a/core/debugger/engine_debugger.h b/core/debugger/engine_debugger.h index 10f04bf97a..96fb494484 100644 --- a/core/debugger/engine_debugger.h +++ b/core/debugger/engine_debugger.h @@ -44,7 +44,7 @@ class ScriptDebugger; class EngineDebugger { public: typedef void (*ProfilingToggle)(void *p_user, bool p_enable, const Array &p_opts); - typedef void (*ProfilingTick)(void *p_user, float p_frame_time, float p_idle_time, float p_physics_time, float p_physics_frame_time); + typedef void (*ProfilingTick)(void *p_user, float p_frame_time, float p_process_time, float p_physics_time, float p_physics_frame_time); typedef void (*ProfilingAdd)(void *p_user, const Array &p_arr); typedef Error (*CaptureFunc)(void *p_user, const String &p_msg, const Array &p_args, bool &r_captured); @@ -86,7 +86,7 @@ public: private: float frame_time = 0.0; - float idle_time = 0.0; + float process_time = 0.0; float physics_time = 0.0; float physics_frame_time = 0.0; @@ -120,7 +120,7 @@ public: static void register_uri_handler(const String &p_protocol, CreatePeerFunc p_func); - void iteration(uint64_t p_frame_ticks, uint64_t p_idle_ticks, uint64_t p_physics_ticks, float p_physics_frame_time); + void iteration(uint64_t p_frame_ticks, uint64_t p_process_ticks, uint64_t p_physics_ticks, float p_physics_frame_time); void profiler_enable(const StringName &p_name, bool p_enabled, const Array &p_opts = Array()); Error capture_parse(const StringName &p_name, const String &p_msg, const Array &p_args, bool &r_captured); diff --git a/core/debugger/remote_debugger.cpp b/core/debugger/remote_debugger.cpp index ff89517497..53c754e513 100644 --- a/core/debugger/remote_debugger.cpp +++ b/core/debugger/remote_debugger.cpp @@ -317,7 +317,7 @@ struct RemoteDebugger::ServersProfiler { void _send_frame_data(bool p_final) { DebuggerMarshalls::ServersProfilerFrame frame; - frame.frame_number = Engine::get_singleton()->get_idle_frames(); + frame.frame_number = Engine::get_singleton()->get_process_frames(); frame.frame_time = frame_time; frame.idle_time = idle_time; frame.physics_time = physics_time; diff --git a/core/input/input.cpp b/core/input/input.cpp index 153656e44a..9209908704 100644 --- a/core/input/input.cpp +++ b/core/input/input.cpp @@ -247,7 +247,7 @@ bool Input::is_action_just_pressed(const StringName &p_action) const { if (Engine::get_singleton()->is_in_physics_frame()) { return E->get().pressed && E->get().physics_frame == Engine::get_singleton()->get_physics_frames(); } else { - return E->get().pressed && E->get().idle_frame == Engine::get_singleton()->get_idle_frames(); + return E->get().pressed && E->get().process_frame == Engine::get_singleton()->get_process_frames(); } } @@ -260,7 +260,7 @@ bool Input::is_action_just_released(const StringName &p_action) const { if (Engine::get_singleton()->is_in_physics_frame()) { return !E->get().pressed && E->get().physics_frame == Engine::get_singleton()->get_physics_frames(); } else { - return !E->get().pressed && E->get().idle_frame == Engine::get_singleton()->get_idle_frames(); + return !E->get().pressed && E->get().process_frame == Engine::get_singleton()->get_process_frames(); } } @@ -588,7 +588,7 @@ void Input::_parse_input_event_impl(const Ref &p_event, bool p_is_em if (!p_event->is_echo() && is_action_pressed(E->key()) != p_event->is_action_pressed(E->key())) { Action action; action.physics_frame = Engine::get_singleton()->get_physics_frames(); - action.idle_frame = Engine::get_singleton()->get_idle_frames(); + action.process_frame = Engine::get_singleton()->get_process_frames(); action.pressed = p_event->is_action_pressed(E->key()); action.strength = 0.0f; action.raw_strength = 0.0f; @@ -714,7 +714,7 @@ void Input::action_press(const StringName &p_action, float p_strength) { Action action; action.physics_frame = Engine::get_singleton()->get_physics_frames(); - action.idle_frame = Engine::get_singleton()->get_idle_frames(); + action.process_frame = Engine::get_singleton()->get_process_frames(); action.pressed = true; action.strength = p_strength; @@ -725,7 +725,7 @@ void Input::action_release(const StringName &p_action) { Action action; action.physics_frame = Engine::get_singleton()->get_physics_frames(); - action.idle_frame = Engine::get_singleton()->get_idle_frames(); + action.process_frame = Engine::get_singleton()->get_process_frames(); action.pressed = false; action.strength = 0.f; diff --git a/core/input/input.h b/core/input/input.h index 1b2df49ac0..39dc0bceff 100644 --- a/core/input/input.h +++ b/core/input/input.h @@ -114,7 +114,7 @@ private: struct Action { uint64_t physics_frame; - uint64_t idle_frame; + uint64_t process_frame; bool pressed; float strength; float raw_strength; diff --git a/core/os/main_loop.cpp b/core/os/main_loop.cpp index 9252ba0840..0247b6a1d8 100644 --- a/core/os/main_loop.cpp +++ b/core/os/main_loop.cpp @@ -34,8 +34,8 @@ void MainLoop::_bind_methods() { BIND_VMETHOD(MethodInfo("_initialize")); - BIND_VMETHOD(MethodInfo(Variant::BOOL, "_iteration", PropertyInfo(Variant::FLOAT, "delta"))); - BIND_VMETHOD(MethodInfo(Variant::BOOL, "_idle", PropertyInfo(Variant::FLOAT, "delta"))); + BIND_VMETHOD(MethodInfo(Variant::BOOL, "_physics_process", PropertyInfo(Variant::FLOAT, "delta"))); + BIND_VMETHOD(MethodInfo(Variant::BOOL, "_process", PropertyInfo(Variant::FLOAT, "delta"))); BIND_VMETHOD(MethodInfo("_finalize")); BIND_CONSTANT(NOTIFICATION_OS_MEMORY_WARNING); @@ -52,13 +52,13 @@ void MainLoop::_bind_methods() { ADD_SIGNAL(MethodInfo("on_request_permissions_result", PropertyInfo(Variant::STRING, "permission"), PropertyInfo(Variant::BOOL, "granted"))); }; -void MainLoop::set_init_script(const Ref