1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-04 12:00:25 +00:00

Implement adjusting the maximum number of physics steps per rendered frame

When using high physics FPS (which is a requirement to minimize input
lag and improve precision in simulation racing games), a higher value
prevents the game from slowing down at low rendering FPS.

This can be done via an Engine property for run-time changes,
or a project setting for initial changes.
This commit is contained in:
Hugo Locurcio
2022-09-15 18:57:34 +02:00
parent ca25c6e0a3
commit 66f7c48e39
7 changed files with 43 additions and 3 deletions

View File

@@ -48,6 +48,15 @@ int Engine::get_physics_ticks_per_second() const {
return ips;
}
void Engine::set_max_physics_steps_per_frame(int p_max_physics_steps) {
ERR_FAIL_COND_MSG(p_max_physics_steps <= 0, "Maximum number of physics steps per frame must be greater than 0.");
max_physics_steps_per_frame = p_max_physics_steps;
}
int Engine::get_max_physics_steps_per_frame() const {
return max_physics_steps_per_frame;
}
void Engine::set_physics_jitter_fix(double p_threshold) {
if (p_threshold < 0) {
p_threshold = 0;