1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//! Scene-wide wind state, owned by the render layer for the cloth simulation.
use nalgebra_glm::Vec3;
/// Global wind affecting every cloth in the scene, stored at
/// [`RenderInputs::wind`](crate::wgpu::render_configs::RenderInputs).
///
/// The cloth simulation samples this each frame: the steady component is
/// `direction * strength`, gusts add a sinusoidal surge of up to
/// `gust_strength` at `gust_frequency` cycles per second, and `turbulence`
/// adds spatially varying swirl. Each cloth scales the result by its own
/// `wind_response`.
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct Wind {
/// Direction the wind blows toward. Does not need to be normalized.
pub direction: Vec3,
/// Steady wind speed in m/s.
pub strength: f32,
/// Peak additional speed of gusts in m/s.
pub gust_strength: f32,
/// Gust cycles per second.
pub gust_frequency: f32,
/// Magnitude of spatially varying swirl in m/s.
pub turbulence: f32,
}
impl Default for Wind {
fn default() -> Self {
Self {
direction: Vec3::new(0.42, 0.0, 0.91),
strength: 3.0,
gust_strength: 2.0,
gust_frequency: 0.5,
turbulence: 1.5,
}
}
}