atmosphere: change variable types from f32 to f64

This commit is contained in:
yuni 2024-11-27 23:00:22 +01:00
parent 7559786bae
commit 707275e5ef
4 changed files with 12 additions and 12 deletions

View file

@ -1159,8 +1159,8 @@ fn handle_atmosphere(
let pressure = nature::jupiter_altitude_to_pressure(distance);
if player.is_some() {
settings.atmo_pressure = Some(pressure as f32);
settings.atmo_altitude = Some(height as f32);
settings.atmo_pressure = Some(pressure);
settings.atmo_altitude = Some(height);
reset_player_gauges = false;
}

View file

@ -878,10 +878,10 @@ fn update_speedometer(
// Atmospheric conditions
let mut atmo = String::new();
if let Some(val) = settings.atmo_altitude {
atmo += format!("Altitude: {}m\n", nature::readable_si(val as f64)).as_str();
atmo += format!("alt: {}m\n", nature::readable_si(val)).as_str();
}
if let Some(val) = settings.atmo_pressure {
atmo += format!("Pressure: {}bar\n", nature::readable_si(val as f64)).as_str();
atmo += format!("p: {}bar\n", nature::readable_si(val as f64)).as_str();
}
speed_text.sections[0].value = atmo;

View file

@ -157,17 +157,17 @@ pub fn readable_speed(speed: f64) -> String {
pub fn readable_si(value: f64) -> String {
if value > 1e10 {
return format!("{:.3} G", value / 1e9);
return format!("{:.1} G", value / 1e9);
} else if value > 1e7 {
return format!("{:.3} M", value / 1e6);
return format!("{:.1} M", value / 1e6);
} else if value > 1e4 {
return format!("{:.3} k", value / 1e3);
return format!("{:.1} k", value / 1e3);
} else if value < 1e-2 {
return format!("{:.3} m", value * 1e3);
return format!("{:.1} m", value * 1e3);
} else if value < 1e-5 {
return format!("{:.3} µ", value * 1e3);
return format!("{:.1} µ", value * 1e3);
}
return format!("{:.3} ", value);
return format!("{:.1} ", value);
}
pub fn lorentz_factor(speed: f64) -> f64 {

View file

@ -52,8 +52,8 @@ pub struct Settings {
pub fov_highspeed: f32,
pub zoom_fov: f32,
pub zoom_sensitivity_factor: f32,
pub atmo_pressure: Option<f32>,
pub atmo_altitude: Option<f32>,
pub atmo_pressure: Option<f64>,
pub atmo_altitude: Option<f64>,
pub font_size_hud: f32,
pub font_size_fps: f32,
pub font_size_conversations: f32,