mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Fixed slow motion effect after lag
This commit is contained in:
parent
985156fca4
commit
ea28f93dc0
@ -77,9 +77,6 @@ impl Clock {
|
|||||||
pub fn dt(&self) -> Duration { self.last_dt }
|
pub fn dt(&self) -> Duration { self.last_dt }
|
||||||
|
|
||||||
pub fn get_stable_dt(&self) -> Duration {
|
pub fn get_stable_dt(&self) -> Duration {
|
||||||
if self.last_dts.len() < NUMBER_OF_DELTAS_COMPARED {
|
|
||||||
self.last_dt
|
|
||||||
} else {
|
|
||||||
let stable_dt = Duration::from_secs_f32(
|
let stable_dt = Duration::from_secs_f32(
|
||||||
self.last_dts
|
self.last_dts
|
||||||
.iter()
|
.iter()
|
||||||
@ -87,10 +84,11 @@ impl Clock {
|
|||||||
.min()
|
.min()
|
||||||
.map_or(self.last_dt.as_secs_f32(), |t| t.into_inner()),
|
.map_or(self.last_dt.as_secs_f32(), |t| t.into_inner()),
|
||||||
);
|
);
|
||||||
if self.last_dt > 2 * stable_dt {
|
if self.last_dts.len() >= NUMBER_OF_DELTAS_COMPARED && self.last_dt > 2 * stable_dt {
|
||||||
tracing::debug!(?self.last_dt, ?self.total_tick_time, "lag spike detected, unusually slow tick");
|
tracing::debug!(?self.last_dt, ?self.total_tick_time, "lag spike detected, unusually slow tick");
|
||||||
}
|
|
||||||
stable_dt
|
stable_dt
|
||||||
|
} else {
|
||||||
|
self.last_dt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user