always use players weather, and fix weather fr this time

This commit is contained in:
Isse 2024-01-23 23:18:14 +01:00
parent 8f15dedc3b
commit 497cb13e50
4 changed files with 8 additions and 5 deletions

View File

@ -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 {

View File

@ -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);

View File

@ -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);

View File

@ -1580,7 +1580,7 @@ impl<V: RectRasterableVol> Terrain<V> {
min: visible_bounding_box.min.as_::<f64>(),
max: visible_bounding_box.max.as_::<f64>(),
};
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::<f32>::from(weather.rain_vel().normalized());
// NOTE: We use proj_mat_treeculler here because