From 497cb13e50e84589a9dc16ba3611ab14c178594c Mon Sep 17 00:00:00 2001 From: Isse Date: Tue, 23 Jan 2024 23:18:14 +0100 Subject: [PATCH] always use players weather, and fix weather fr this time --- server/src/weather/tick.rs | 7 +++++-- voxygen/src/scene/figure/mod.rs | 2 +- voxygen/src/scene/mod.rs | 2 +- voxygen/src/scene/terrain.rs | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/server/src/weather/tick.rs b/server/src/weather/tick.rs index a6738c496b..a070d77e9a 100644 --- a/server/src/weather/tick.rs +++ b/server/src/weather/tick.rs @@ -83,7 +83,7 @@ impl<'a> System<'a> for Sys { positions, ): Self::SystemData, ) { - if let Some(weather_job) = match &mut *weather_job { + let to_update = match &mut *weather_job { Some(weather_job) => (program_time.0 - weather_job.last_update.0 >= WEATHER_DT as f64) .then_some(weather_job), None => { @@ -104,7 +104,9 @@ impl<'a> System<'a> for Sys { None }, - } { + }; + + if let Some(weather_job) = to_update { if matches!(weather_job.state, WeatherJobState::Working(_)) && let Ok((new_grid, new_lightning_cells, sim)) = weather_job.weather_rx.try_recv() { *grid = new_grid; @@ -123,6 +125,7 @@ impl<'a> System<'a> for Sys { } if matches!(weather_job.state, WeatherJobState::Idle(_)) { + weather_job.last_update = *program_time; let old_state = mem::replace(&mut weather_job.state, WeatherJobState::None); let WeatherJobState::Idle(mut sim) = old_state else { diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index 5060cf6bcc..26a2094eff 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -780,7 +780,7 @@ impl FigureMgr { // Are shadows enabled at all? let can_shadow_sun = renderer.pipeline_modes().shadow.is_map() && is_daylight; - let weather = scene_data.state.weather_at(cam_pos.xy()); + let weather = scene_data.client.weather_at_player(); let cam_pos = math::Vec3::from(cam_pos); diff --git a/voxygen/src/scene/mod.rs b/voxygen/src/scene/mod.rs index 167913f647..a813459769 100644 --- a/voxygen/src/scene/mod.rs +++ b/voxygen/src/scene/mod.rs @@ -1198,7 +1198,7 @@ impl Scene { .max_weather_near(focus_off.xy() + cam_pos.xy()); self.wind_vel = weather.wind_vel(); if weather.rain > RAIN_THRESHOLD { - let weather = client.state().weather_at(focus_off.xy() + cam_pos.xy()); + let weather = client.weather_at_player(); let rain_vel = weather.rain_vel(); let rain_view_mat = math::Mat4::look_at_rh(look_at, look_at + rain_vel, up); diff --git a/voxygen/src/scene/terrain.rs b/voxygen/src/scene/terrain.rs index 52f595eac0..1a09c74752 100644 --- a/voxygen/src/scene/terrain.rs +++ b/voxygen/src/scene/terrain.rs @@ -1580,7 +1580,7 @@ impl Terrain { min: visible_bounding_box.min.as_::(), max: visible_bounding_box.max.as_::(), }; - let weather = scene_data.state.weather_at(focus_off.xy() + cam_pos.xy()); + let weather = scene_data.client.weather_at_player(); let ray_direction = math::Vec3::::from(weather.rain_vel().normalized()); // NOTE: We use proj_mat_treeculler here because