Add display precision to diagnostics #6033
Labels
A-Diagnostics
Logging, crash handling, error reporting and performance analysis
C-Usability
A targeted quality-of-life change that makes Bevy easier to use
D-Trivial
Nice and easy! A great choice to get started with Bevy
What problem does this solve or what need does it fill?
Diagnostics have no concept of display precision, so values for all diagnostics are displayed using a hard-coded static precision of
6
in theLogDiagnosticsPlugin
:bevy/crates/bevy_diagnostic/src/log_diagnostics_plugin.rs
Lines 65 to 75 in 2b80a3f
What solution would you like?
A new field could be added to
bevy_diagnostic::Diagnostic
,pub precision: usize
:bevy/crates/bevy_diagnostic/src/diagnostic.rs
Lines 34 to 42 in 2b80a3f
What alternative(s) have you considered?
Instead of handling value formatting manually in plugins with
format!
,Diagnostic
could alternatively provide a formatting function to format values. A new field could be added tobevy_diagnostic::Diagnostic
,pub formatter: Arc<dyn (Fn(f64) -> String) + Send + Sync>
.This approach would give maximum flexibility, but it does incur the (possibly minimal) runtime performance cost of dynamic dispatch.
Additional context
This is relevant for a plugin I'm working on to dynamically visualize diagnostics.
https://github.com/sagan-software/bevy_diagnostic_visualizer
The text was updated successfully, but these errors were encountered: