Time and lots of it.
What changed
-
GameClock is now its own component
- Time used to be managed by EnviromentState mixed in with sky-color code. It now is its own component as a singleton entity, so any system can query it without going through the GameState.
- Time is stored as integer ticks
tick, day, tick_of_dayandtime_of_day()is now derived from them. My first version accumulated an f32 fraction, I went a head and wrote a unit test and it failed showing a rollover issue firing one tick late because of float drift. I changed this to count while ticks to get rid of float drift. update_enviromentnow takes&GameClockas read-only It can no longer change the time.
-
Fixed timestep (locked at 60Hz)
update(dt)now feeds an accumulator and runsfixed_updatezero or more times per frame. The clock, physics step and player movement run there.- Frame time is capped at 0.25 seconds to prevent a spiral of death after a long stall.
- Day length is changed to a real 60 seconds at any framerate before it scaled with FPS (60 seconds is only for early development).
-
Mouse look is moved out of the tick
update_player_lookruns once per frame.update_player_movementruns per tick.- This fixes mouse deltas being applied twice at low fps and dropped at high fps.
-
Render interpolation
- New
PreviousTransformcomponent snapshotted at the start of each tick - The renderer blends previous and current position by
alpha = accumulator / FIXED_DT - Rotation is deliberately not interpolated since it updates every frame. Turning does not have any added latency.
- New
-
Up Next
- HashSet for expected chunks in ChunkManager::update() its currently a Vec scan right now
- Arc
to replace the per-chunk deep clone issue I have. - tracing for logging and more fun stuff
- Per-subsystem RNG streams.
This is a boring devlog no new features started mostly just bug fixes and a important Time fix I am not sure why I didn’t initially design the GameClock to be its own thing and had it in the EnviromentState but oh well lessons learned I guess. These next couple devlogs will be a little more technical but I hope you enjoy them and I hope you stay for the journey as the next devlog should have photos added (possibly I coded this site by hand and my posts are in markdown format).