Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename MainLoop methods to match Node methods #44593

Merged
merged 1 commit into from
Dec 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions core/config/engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class Engine {
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;
Expand All @@ -62,7 +62,7 @@ class Engine {
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<Singleton> singletons;
Expand All @@ -89,10 +89,10 @@ class Engine {
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);
Expand Down
6 changes: 3 additions & 3 deletions core/core_bind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion core/core_bind.h
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ class _Engine : public Object {

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();

Expand Down
6 changes: 3 additions & 3 deletions core/debugger/engine_debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
}
Expand Down
6 changes: 3 additions & 3 deletions core/debugger/engine_debugger.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -86,7 +86,7 @@ class EngineDebugger {

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;

Expand Down Expand Up @@ -120,7 +120,7 @@ class EngineDebugger {

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);

Expand Down
2 changes: 1 addition & 1 deletion core/debugger/remote_debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 5 additions & 5 deletions core/input/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

Expand All @@ -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();
}
}

Expand Down Expand Up @@ -588,7 +588,7 @@ void Input::_parse_input_event_impl(const Ref<InputEvent> &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;
Expand Down Expand Up @@ -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;

Expand All @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion core/input/input.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class Input : public Object {

struct Action {
uint64_t physics_frame;
uint64_t idle_frame;
uint64_t process_frame;
bool pressed;
float strength;
float raw_strength;
Expand Down
24 changes: 12 additions & 12 deletions core/os/main_loop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -52,37 +52,37 @@ 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<Script> &p_init_script) {
init_script = p_init_script;
void MainLoop::set_initialize_script(const Ref<Script> &p_initialize_script) {
initialize_script = p_initialize_script;
}

void MainLoop::init() {
if (init_script.is_valid()) {
set_script(init_script);
void MainLoop::initialize() {
if (initialize_script.is_valid()) {
set_script(initialize_script);
}

if (get_script_instance()) {
get_script_instance()->call("_initialize");
}
}

bool MainLoop::iteration(float p_time) {
bool MainLoop::physics_process(float p_time) {
if (get_script_instance()) {
return get_script_instance()->call("_iteration", p_time);
return get_script_instance()->call("_physics_process", p_time);
}

return false;
}

bool MainLoop::idle(float p_time) {
bool MainLoop::process(float p_time) {
if (get_script_instance()) {
return get_script_instance()->call("_idle", p_time);
return get_script_instance()->call("_process", p_time);
}

return false;
}

void MainLoop::finish() {
void MainLoop::finalize() {
if (get_script_instance()) {
get_script_instance()->call("_finalize");
set_script(Variant()); //clear script
Expand Down
12 changes: 6 additions & 6 deletions core/os/main_loop.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class MainLoop : public Object {
GDCLASS(MainLoop, Object);
OBJ_CATEGORY("Main Loop");

Ref<Script> init_script;
Ref<Script> initialize_script;

protected:
static void _bind_methods();
Expand All @@ -59,12 +59,12 @@ class MainLoop : public Object {
NOTIFICATION_TEXT_SERVER_CHANGED = 2018,
};

virtual void init();
virtual bool iteration(float p_time);
virtual bool idle(float p_time);
virtual void finish();
virtual void initialize();
virtual bool physics_process(float p_time);
virtual bool process(float p_time);
virtual void finalize();

void set_init_script(const Ref<Script> &p_init_script);
void set_initialize_script(const Ref<Script> &p_initialize_script);

MainLoop() {}
virtual ~MainLoop() {}
Expand Down
6 changes: 3 additions & 3 deletions doc/classes/Engine.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<return type="int">
</return>
<description>
Returns the total number of frames drawn. If the render loop is disabled with [code]--disable-render-loop[/code] via command line, this returns [code]0[/code]. See also [method get_idle_frames].
Returns the total number of frames drawn. If the render loop is disabled with [code]--disable-render-loop[/code] via command line, this returns [code]0[/code]. See also [method get_process_frames].
</description>
</method>
<method name="get_frames_per_second" qualifiers="const">
Expand All @@ -51,11 +51,11 @@
Returns the frames per second of the running game.
</description>
</method>
<method name="get_idle_frames" qualifiers="const">
<method name="get_process_frames" qualifiers="const">
<return type="int">
</return>
<description>
Returns the total number of frames passed since engine initialization which is advanced on each [b]idle frame[/b], regardless of whether the render loop is enabled. See also [method get_frames_drawn].
Returns the total number of frames passed since engine initialization which is advanced on each [b]process frame[/b], regardless of whether the render loop is enabled. See also [method get_frames_drawn].
</description>
</method>
<method name="get_license_info" qualifiers="const">
Expand Down
Loading