mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
refactor rain_dir to rain_vel
This commit is contained in:
parent
7752696387
commit
9f26afb4a5
@ -5,8 +5,6 @@ use vek::{Lerp, Vec2, Vec3};
|
|||||||
|
|
||||||
use crate::{grid::Grid, terrain::TerrainChunkSize, vol::RectVolSize};
|
use crate::{grid::Grid, terrain::TerrainChunkSize, vol::RectVolSize};
|
||||||
|
|
||||||
pub const FALL_RATE: f32 = 20.0;
|
|
||||||
|
|
||||||
/// Weather::default is Clear, 0 degrees C and no wind
|
/// Weather::default is Clear, 0 degrees C and no wind
|
||||||
#[derive(Debug, Clone, Copy, Serialize, Deserialize, Default)]
|
#[derive(Debug, Clone, Copy, Serialize, Deserialize, Default)]
|
||||||
pub struct Weather {
|
pub struct Weather {
|
||||||
@ -42,9 +40,10 @@ impl Weather {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the rain direction for this weather
|
// Get the rain velocity for this weather
|
||||||
pub fn rain_dir(&self) -> Vec3<f32> {
|
pub fn rain_vel(&self) -> Vec3<f32> {
|
||||||
(-Vec3::unit_z() + self.wind / (2.0 * FALL_RATE)).normalized()
|
const FALL_RATE: f32 = 20.0;
|
||||||
|
Vec3::new(self.wind.x, self.wind.y, -FALL_RATE)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1005,14 +1005,14 @@ impl Scene {
|
|||||||
.max_weather_near(focus_off.xy() + cam_pos.xy());
|
.max_weather_near(focus_off.xy() + cam_pos.xy());
|
||||||
if weather.rain > 0.0 {
|
if weather.rain > 0.0 {
|
||||||
let weather = client.state().weather_at(focus_off.xy() + cam_pos.xy());
|
let weather = client.state().weather_at(focus_off.xy() + cam_pos.xy());
|
||||||
let rain_dir = weather.rain_dir();
|
let rain_vel = weather.rain_vel();
|
||||||
let rain_view_mat = math::Mat4::look_at_rh(look_at, look_at + rain_dir, up);
|
let rain_view_mat = math::Mat4::look_at_rh(look_at, look_at + rain_vel, up);
|
||||||
let rain_vel = rain_dir * common::weather::FALL_RATE - player_vel;
|
let relative_rain_vel = rain_vel - player_vel;
|
||||||
self.integrated_rain_vel += rain_vel.magnitude() * dt;
|
self.integrated_rain_vel += relative_rain_vel.magnitude() * dt;
|
||||||
let rel_rain_dir_mat = Mat4::rotation_from_to_3d(-Vec3::unit_z(), rain_vel);
|
let rel_rain_dir_mat = Mat4::rotation_from_to_3d(-Vec3::unit_z(), relative_rain_vel);
|
||||||
|
|
||||||
let (shadow_mat, texture_mat) =
|
let (shadow_mat, texture_mat) =
|
||||||
directed_mats(rain_view_mat, rain_dir.into(), &visible_occlusion_volume);
|
directed_mats(rain_view_mat, rain_vel.into(), &visible_occlusion_volume);
|
||||||
|
|
||||||
let rain_occlusion_locals = RainOcclusionLocals::new(
|
let rain_occlusion_locals = RainOcclusionLocals::new(
|
||||||
shadow_mat,
|
shadow_mat,
|
||||||
|
@ -1415,7 +1415,7 @@ impl<V: RectRasterableVol> Terrain<V> {
|
|||||||
max: visible_bounding_box.max.as_::<f64>(),
|
max: visible_bounding_box.max.as_::<f64>(),
|
||||||
};
|
};
|
||||||
let weather = scene_data.state.weather_at(focus_pos.xy());
|
let weather = scene_data.state.weather_at(focus_pos.xy());
|
||||||
let ray_direction = math::Vec3::<f32>::from(weather.rain_dir());
|
let ray_direction = math::Vec3::<f32>::from(weather.rain_vel().normalized());
|
||||||
|
|
||||||
// NOTE: We use proj_mat_treeculler here because
|
// NOTE: We use proj_mat_treeculler here because
|
||||||
// calc_focused_light_volume_points makes the assumption that the
|
// calc_focused_light_volume_points makes the assumption that the
|
||||||
|
Loading…
Reference in New Issue
Block a user