jakobhellermann / bevy-inspector-egui

Inspector plugin for the bevy game engine
Apache License 2.0
1.15k stars 169 forks source link

Prevent `Duration` loss of precision #64

Closed ariofrio closed 2 years ago

ariofrio commented 2 years ago

Currently any Duration that's in an Inspectable struct (like a Component or Resource) gets rounded off to the closest f32 seconds representation every frame. This breaks logic that adds small Duration values with large ones. For example, in my game I have an age field in a resource that can increase to very large amounts (years) when fast-forwarding but then need to increase by small amounts (milliseconds) when going in slow-motion. Without this fix, the age field never increases because bevy-inspector-egui rounds it off.

I'm not sure if f64 is able to capture enough precision to prevent the specific corner case I ran into in my game, but either way it seems that any lossy or imprecise conversion should only set the value when changed manually by the user.

jakobhellermann commented 2 years ago

This just needs a cargo fmt and then it is good to merge

ariofrio commented 2 years ago

Done!