summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorHugo Locurcio <hugo.locurcio@hugo.pro>2021-08-11 02:35:16 +0200
committerHugo Locurcio <hugo.locurcio@hugo.pro>2021-08-11 02:37:02 +0200
commit937c1a716c87e48ba0d1c097747e0438dc076f67 (patch)
tree956f3f725bab532a92f0c96a97fd93291d4eca08 /main
parent18bd0fee5a8aa360177cbe14a16d6be69f088d8f (diff)
Rename `iterations_per_second` to `physics_ticks_per_second`
This makes it clearer that this property is only about physics FPS, not rendering FPS. The `physics_fps` project setting was also renamed to `physics_ticks_per_second` for consistency.
Diffstat (limited to 'main')
-rw-r--r--main/main.cpp12
-rw-r--r--main/main_timer_sync.cpp16
-rw-r--r--main/main_timer_sync.h6
3 files changed, 17 insertions, 17 deletions
diff --git a/main/main.cpp b/main/main.cpp
index d91cc5c9bf..f899894642 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -1340,9 +1340,9 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
{
window_vsync_mode = DisplayServer::VSyncMode(int(GLOBAL_DEF("display/window/vsync/vsync_mode", DisplayServer::VSyncMode::VSYNC_ENABLED)));
}
- Engine::get_singleton()->set_iterations_per_second(GLOBAL_DEF_BASIC("physics/common/physics_fps", 60));
- ProjectSettings::get_singleton()->set_custom_property_info("physics/common/physics_fps",
- PropertyInfo(Variant::INT, "physics/common/physics_fps",
+ Engine::get_singleton()->set_physics_ticks_per_second(GLOBAL_DEF_BASIC("physics/common/physics_ticks_per_second", 60));
+ ProjectSettings::get_singleton()->set_custom_property_info("physics/common/physics_ticks_per_second",
+ PropertyInfo(Variant::INT, "physics/common/physics_ticks_per_second",
PROPERTY_HINT_RANGE, "1,1000,1"));
Engine::get_singleton()->set_physics_jitter_fix(GLOBAL_DEF("physics/common/physics_jitter_fix", 0.5));
Engine::get_singleton()->set_target_fps(GLOBAL_DEF("debug/settings/fps/force_fps", 0));
@@ -2463,12 +2463,12 @@ bool Main::iteration() {
uint64_t ticks_elapsed = ticks - last_ticks;
- int physics_fps = Engine::get_singleton()->get_iterations_per_second();
- float physics_step = 1.0 / physics_fps;
+ int physics_ticks_per_second = Engine::get_singleton()->get_physics_ticks_per_second();
+ float physics_step = 1.0 / physics_ticks_per_second;
float time_scale = Engine::get_singleton()->get_time_scale();
- MainFrameTime advance = main_timer_sync.advance(physics_step, physics_fps);
+ MainFrameTime advance = main_timer_sync.advance(physics_step, physics_ticks_per_second);
double process_step = advance.process_step;
double scaled_step = process_step * time_scale;
diff --git a/main/main_timer_sync.cpp b/main/main_timer_sync.cpp
index 94e62bea97..0d172be65e 100644
--- a/main/main_timer_sync.cpp
+++ b/main/main_timer_sync.cpp
@@ -73,14 +73,14 @@ int MainTimerSync::get_average_physics_steps(double &p_min, double &p_max) {
}
// advance physics clock by p_process_step, return appropriate number of steps to simulate
-MainFrameTime MainTimerSync::advance_core(double p_physics_step, int p_physics_fps, double p_process_step) {
+MainFrameTime MainTimerSync::advance_core(double p_physics_step, int p_physics_ticks_per_second, double p_process_step) {
MainFrameTime ret;
ret.process_step = p_process_step;
// simple determination of number of physics iteration
time_accum += ret.process_step;
- ret.physics_steps = floor(time_accum * p_physics_fps);
+ ret.physics_steps = floor(time_accum * p_physics_ticks_per_second);
int min_typical_steps = typical_physics_steps[0];
int max_typical_steps = min_typical_steps + 1;
@@ -107,7 +107,7 @@ MainFrameTime MainTimerSync::advance_core(double p_physics_step, int p_physics_f
// try to keep it consistent with previous iterations
if (ret.physics_steps < min_typical_steps) {
- const int max_possible_steps = floor((time_accum)*p_physics_fps + get_physics_jitter_fix());
+ const int max_possible_steps = floor((time_accum)*p_physics_ticks_per_second + get_physics_jitter_fix());
if (max_possible_steps < min_typical_steps) {
ret.physics_steps = max_possible_steps;
update_typical = true;
@@ -115,7 +115,7 @@ MainFrameTime MainTimerSync::advance_core(double p_physics_step, int p_physics_f
ret.physics_steps = min_typical_steps;
}
} else if (ret.physics_steps > max_typical_steps) {
- const int min_possible_steps = floor((time_accum)*p_physics_fps - get_physics_jitter_fix());
+ const int min_possible_steps = floor((time_accum)*p_physics_ticks_per_second - get_physics_jitter_fix());
if (min_possible_steps > max_typical_steps) {
ret.physics_steps = min_possible_steps;
update_typical = true;
@@ -146,7 +146,7 @@ MainFrameTime MainTimerSync::advance_core(double p_physics_step, int p_physics_f
}
// calls advance_core, keeps track of deficit it adds to animaption_step, make sure the deficit sum stays close to zero
-MainFrameTime MainTimerSync::advance_checked(double p_physics_step, int p_physics_fps, double p_process_step) {
+MainFrameTime MainTimerSync::advance_checked(double p_physics_step, int p_physics_ticks_per_second, double p_process_step) {
if (fixed_fps != -1) {
p_process_step = 1.0 / fixed_fps;
}
@@ -154,7 +154,7 @@ MainFrameTime MainTimerSync::advance_checked(double p_physics_step, int p_physic
// compensate for last deficit
p_process_step += time_deficit;
- MainFrameTime ret = advance_core(p_physics_step, p_physics_fps, p_process_step);
+ MainFrameTime ret = advance_core(p_physics_step, p_physics_ticks_per_second, p_process_step);
// we will do some clamping on ret.process_step and need to sync those changes to time_accum,
// that's easiest if we just remember their fixed difference now
@@ -220,8 +220,8 @@ void MainTimerSync::set_fixed_fps(int p_fixed_fps) {
}
// advance one physics frame, return timesteps to take
-MainFrameTime MainTimerSync::advance(double p_physics_step, int p_physics_fps) {
+MainFrameTime MainTimerSync::advance(double p_physics_step, int p_physics_ticks_per_second) {
double cpu_process_step = get_cpu_process_step();
- return advance_checked(p_physics_step, p_physics_fps, cpu_process_step);
+ return advance_checked(p_physics_step, p_physics_ticks_per_second, cpu_process_step);
}
diff --git a/main/main_timer_sync.h b/main/main_timer_sync.h
index abdec18f6d..d0ebcb8f96 100644
--- a/main/main_timer_sync.h
+++ b/main/main_timer_sync.h
@@ -77,10 +77,10 @@ protected:
int get_average_physics_steps(double &p_min, double &p_max);
// advance physics clock by p_process_step, return appropriate number of steps to simulate
- MainFrameTime advance_core(double p_physics_step, int p_physics_fps, double p_process_step);
+ MainFrameTime advance_core(double p_physics_step, int p_physics_ticks_per_second, double p_process_step);
// calls advance_core, keeps track of deficit it adds to animaption_step, make sure the deficit sum stays close to zero
- MainFrameTime advance_checked(double p_physics_step, int p_physics_fps, double p_process_step);
+ MainFrameTime advance_checked(double p_physics_step, int p_physics_ticks_per_second, double p_process_step);
// determine wall clock step since last iteration
double get_cpu_process_step();
@@ -96,7 +96,7 @@ public:
void set_fixed_fps(int p_fixed_fps);
// advance one frame, return timesteps to take
- MainFrameTime advance(double p_physics_step, int p_physics_fps);
+ MainFrameTime advance(double p_physics_step, int p_physics_ticks_per_second);
};
#endif // MAIN_TIMER_SYNC_H