set tick sim time right before publishing
This commit is contained in:
parent
f0a25248c3
commit
79cc9e15e5
@ -504,7 +504,6 @@ INTERNAL void game_update(struct game_cmd_array game_cmds)
|
||||
* ========================== */
|
||||
|
||||
++G.tick.tick_id;
|
||||
G.tick.simtime_ns = sys_time_ns();
|
||||
|
||||
G.tick.dt_ns = NS_FROM_SECONDS(max_f64(0.0, (1.0 / GAME_FPS) * G.tick.timescale));
|
||||
G.tick.time_ns += G.tick.dt_ns;
|
||||
@ -1327,6 +1326,7 @@ INTERNAL void game_update(struct game_cmd_array game_cmds)
|
||||
* ========================== */
|
||||
|
||||
/* Publish tick */
|
||||
G.tick.publishtime_ns = sys_time_ns();
|
||||
publish_game_tick();
|
||||
__profframe("Game");
|
||||
|
||||
|
||||
14
src/user.c
14
src/user.c
@ -291,13 +291,13 @@ INTERNAL struct interp_ticks pull_ticks(i64 blend_time_ns)
|
||||
from_tick = oldest_tick;
|
||||
to_tick = newest_tick;
|
||||
for (struct blend_tick *bt = G.head_blend_tick; bt; bt = bt->next) {
|
||||
i64 bt_time_ns = bt->world.simtime_ns;
|
||||
i64 bt_time_ns = bt->world.publishtime_ns;
|
||||
|
||||
if (bt_time_ns < blend_time_ns && bt_time_ns > from_tick->simtime_ns) {
|
||||
if (bt_time_ns < blend_time_ns && bt_time_ns > from_tick->publishtime_ns) {
|
||||
from_tick = &bt->world;
|
||||
}
|
||||
|
||||
if (bt_time_ns > blend_time_ns && bt_time_ns < to_tick->simtime_ns) {
|
||||
if (bt_time_ns > blend_time_ns && bt_time_ns < to_tick->publishtime_ns) {
|
||||
to_tick = &bt->world;
|
||||
}
|
||||
}
|
||||
@ -309,8 +309,8 @@ INTERNAL struct interp_ticks pull_ticks(i64 blend_time_ns)
|
||||
u64 bts_to_free_count = 0;
|
||||
|
||||
for (struct blend_tick *bt = G.head_blend_tick; bt; bt = bt->next) {
|
||||
i64 bt_time_ns = bt->world.simtime_ns;
|
||||
if (bt_time_ns < from_tick->simtime_ns) {
|
||||
i64 bt_time_ns = bt->world.publishtime_ns;
|
||||
if (bt_time_ns < from_tick->publishtime_ns) {
|
||||
*arena_push(scratch.arena, struct blend_tick *) = bt;
|
||||
++bts_to_free_count;
|
||||
}
|
||||
@ -518,8 +518,8 @@ INTERNAL void user_update(void)
|
||||
|
||||
f32 tick_blend = 0;
|
||||
{
|
||||
i64 t0_time_ns = t0->simtime_ns;
|
||||
i64 t1_time_ns = t1->simtime_ns;
|
||||
i64 t0_time_ns = t0->publishtime_ns;
|
||||
i64 t1_time_ns = t1->publishtime_ns;
|
||||
if (t1_time_ns > t0_time_ns) {
|
||||
f64 t0_t1_elapsed = SECONDS_FROM_NS(t1_time_ns - t0_time_ns);
|
||||
f64 t0_blend_elapsed = SECONDS_FROM_NS(blend_time_ns - t0_time_ns);
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
struct world {
|
||||
u64 continuity_gen; /* Starts at 1 */
|
||||
u64 tick_id; /* Starts at 1 */
|
||||
i64 simtime_ns; /* When was this tick simulated in program time */
|
||||
i64 publishtime_ns; /* When was this tick simulated in program time */
|
||||
|
||||
/* World time */
|
||||
f64 timescale;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user