imgui delta time needs to use float math

Our prior math converted to float after int which made our delta time
wrong making hovers and stuff not work.
This commit is contained in:
Mitchell Hashimoto
2026-01-27 09:25:58 -08:00
parent f85653414c
commit bdfb45bca7
2 changed files with 8 additions and 11 deletions

View File

@@ -1205,10 +1205,11 @@ pub const Inspector = struct {
// Determine our delta time
const now = try std.time.Instant.now();
io.DeltaTime = if (self.instant) |prev| delta: {
const since_ns = now.since(prev);
const since_s: f32 = @floatFromInt(since_ns / std.time.ns_per_s);
const since_ns: f64 = @floatFromInt(now.since(prev));
const ns_per_s: f64 = @floatFromInt(std.time.ns_per_s);
const since_s: f32 = @floatCast(since_ns / ns_per_s);
break :delta @max(0.00001, since_s);
} else (1 / 60);
} else (1.0 / 60.0);
self.instant = now;
}
};