From 38f88e3cc77bdbfe0568762e9b309d2114ad8619 Mon Sep 17 00:00:00 2001 From: jacob Date: Thu, 15 May 2025 08:09:34 -0500 Subject: [PATCH] fix accidental extra frame of input latency --- src/user.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/user.c b/src/user.c index f6e23640..9fbc6ddb 100644 --- a/src/user.c +++ b/src/user.c @@ -2316,6 +2316,8 @@ INTERNAL SYS_THREAD_ENTRY_POINT_FUNC_DEF(user_local_sim_thread_entry_point, arg) if (is_master) { /* Step master */ + u64 prev_tick = local_client->last_tick; + u64 next_tick = prev_tick + 1; struct sim_step_ctx ctx = ZI; ctx.is_master = is_master; ctx.sim_dt_ns = step_dt_ns; @@ -2323,9 +2325,9 @@ INTERNAL SYS_THREAD_ENTRY_POINT_FUNC_DEF(user_local_sim_thread_entry_point, arg) ctx.user_input_client = user_input_client; ctx.master_client = master_client; ctx.publish_client = publish_client; - struct sim_snapshot *prev_world = sim_snapshot_from_tick(local_client, local_client->last_tick); - ctx.world = sim_snapshot_alloc(local_client, prev_world, local_client->last_tick + 1); - generate_user_input_cmds(user_input_client, local_client->last_tick + 1); + struct sim_snapshot *prev_world = sim_snapshot_from_tick(local_client, prev_tick); + ctx.world = sim_snapshot_alloc(local_client, prev_world, next_tick); + generate_user_input_cmds(user_input_client, next_tick); sim_step(&ctx); } else if (master_client->valid) { /* Step client */