perf: harden runtime for weaker hardware

This commit is contained in:
Rijad Zuzo
2026-08-12 10:02:45 +02:00
parent cd29da95e0
commit 34428d836a
47 changed files with 2164 additions and 243 deletions
+7 -3
View File
@@ -11,10 +11,10 @@ func _init(interval: float = 1.0) -> void:
tick_interval = maxf(interval, 0.0001)
func advance(delta: float) -> int:
func advance(delta: float, max_ticks: int = 0) -> int:
accumulator += maxf(delta, 0.0)
var ticks_due := 0
while accumulator >= tick_interval:
while accumulator >= tick_interval and (max_ticks <= 0 or ticks_due < max_ticks):
accumulator -= tick_interval
elapsed_ticks += 1
ticks_due += 1
@@ -27,5 +27,9 @@ func reset() -> void:
func time_of_day() -> float:
var total_seconds := elapsed_ticks * tick_interval + accumulator
# A capped frame can leave several whole ticks in the accumulator. Those ticks
# are backlog, not simulated time yet; only retain the sub-tick fraction for
# smooth presentation until the manager consumes the remaining work.
var fractional_progress := fmod(accumulator, tick_interval)
var total_seconds := elapsed_ticks * tick_interval + fractional_progress
return fmod(total_seconds / maxf(cycle_duration_seconds, 1.0), 1.0)