mirror of
https://github.com/exoticorn/microw8.git
synced 2026-01-20 11:16:42 +01:00
update frame pacing calculation in native runtime
This commit is contained in:
@@ -181,10 +181,12 @@ impl super::Runtime for MicroW8 {
|
|||||||
if let Some(mut instance) = self.instance.take() {
|
if let Some(mut instance) = self.instance.take() {
|
||||||
let time = (now - instance.start_time).as_millis() as i32;
|
let time = (now - instance.start_time).as_millis() as i32;
|
||||||
let next_frame = {
|
let next_frame = {
|
||||||
let offset = ((time as u32 as i64 * 6) % 100 - 50) / 6;
|
let frame = (time as u32 as u64 * 6 / 100) as u32;
|
||||||
let max = now + Duration::from_millis(17);
|
let cur_offset = (time as u32).wrapping_sub((frame as u64 * 100 / 6) as u32);
|
||||||
let next_center = now + Duration::from_millis((16 - offset) as u64);
|
let next_time =
|
||||||
next_center.min(max)
|
((frame as u64 + 1) * 100 / 6 + cur_offset.max(1).min(4) as u64) as u32;
|
||||||
|
let offset = next_time.wrapping_sub(time as u32);
|
||||||
|
now + Duration::from_millis(offset as u64)
|
||||||
};
|
};
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user