pub struct WaveHeightfield2D { /* private fields */ }Expand description
Interactive 2D shallow-water damped wave heightfield with absorbing sponge boundaries and solid obstacle reflections.
Implementations§
Source§impl WaveHeightfield2D
Interactive 2D shallow-water wave simulation, wake injection, obstacle masking, and sampling API.
impl WaveHeightfield2D
Interactive 2D shallow-water wave simulation, wake injection, obstacle masking, and sampling API.
Sourcepub fn from_config(config: WaveHeightfieldConfig) -> Self
pub fn from_config(config: WaveHeightfieldConfig) -> Self
Sourcepub fn reset(&mut self)
pub fn reset(&mut self)
Resets wave heights, velocities, foam, and simulation time to calm rest while preserving obstacles.
Sourcepub fn step(&mut self, dt_secs: f32)
pub fn step(&mut self, dt_secs: f32)
Advances the shallow-water wave heightfield by dt_secs using CFL-clamped damped Verlet integration with zero heap allocations.
§Arguments
f32- Elapsed frame time in seconds.
Sourcepub fn inject_splash(
&mut self,
world_x: f32,
world_z: f32,
radius_m: f32,
amplitude_m: f32,
)
pub fn inject_splash( &mut self, world_x: f32, world_z: f32, radius_m: f32, amplitude_m: f32, )
Injects a circular splash disturbance at (world_x, world_z) with radius radius_m and peak amplitude amplitude_m.
§Arguments
f32- World X splash center coordinate.f32- World Z splash center coordinate.f32- Splash footprint radius in meters.f32- Displacement amplitude in meters (negative pushes water down to radiate a ring).
Sourcepub fn inject_boat_wake(
&mut self,
world_x: f32,
world_z: f32,
velocity_xz: Vec2,
hull_radius_m: f32,
wake_strength: f32,
)
pub fn inject_boat_wake( &mut self, world_x: f32, world_z: f32, velocity_xz: Vec2, hull_radius_m: f32, wake_strength: f32, )
Injects an expanding Kelvin boat wake along a moving vessel’s horizontal velocity vector.
§Arguments
f32- World X hull center coordinate.f32- World Z hull center coordinate.Vec2- Horizontal vessel velocity(vx, vz)in meters per second.f32- Characteristic hull beam radius in meters.f32- Dimensionless wake intensity multiplier.
Sourcepub fn inject_raindrop(&mut self, world_x: f32, world_z: f32, intensity: f32)
pub fn inject_raindrop(&mut self, world_x: f32, world_z: f32, intensity: f32)
Injects a localized raindrop ripple impulse at (world_x, world_z).
§Arguments
f32- World X impact coordinate.f32- World Z impact coordinate.f32- Dimensionless raindrop intensity in[0.0, 2.0].
Sourcepub fn set_obstacle_rect(
&mut self,
min_x: f32,
min_z: f32,
max_x: f32,
max_z: f32,
solid: bool,
)
pub fn set_obstacle_rect( &mut self, min_x: f32, min_z: f32, max_x: f32, max_z: f32, solid: bool, )
Marks or clears a world-space axis-aligned rectangular solid obstacle mask.
§Arguments
f32- Minimum world X coordinate.f32- Minimum world Z coordinate.f32- Maximum world X coordinate.f32- Maximum world Z coordinate.bool-trueto mark cells as reflective solid obstacles,falseto restore fluid.
Sourcepub fn set_obstacle_circle(
&mut self,
center_x: f32,
center_z: f32,
radius_m: f32,
solid: bool,
)
pub fn set_obstacle_circle( &mut self, center_x: f32, center_z: f32, radius_m: f32, solid: bool, )
Marks or clears a world-space circular solid obstacle mask (e.g., pier piling or rock).
§Arguments
f32- Center world X coordinate.f32- Center world Z coordinate.f32- Circle radius in meters.bool-trueto mark cells as reflective solid obstacles,falseto restore fluid.
Sourcepub fn clear_obstacles(&mut self)
pub fn clear_obstacles(&mut self)
Clears all solid obstacle masks back to fluid.
Sourcepub fn is_obstacle_cell(&self, col: usize, row: usize) -> bool
pub fn is_obstacle_cell(&self, col: usize, row: usize) -> bool
Sourcepub fn sample_displacement(&self, world_x: f32, world_z: f32) -> f32
pub fn sample_displacement(&self, world_x: f32, world_z: f32) -> f32
Sourcepub fn sample_height(&self, world_x: f32, world_z: f32) -> f32
pub fn sample_height(&self, world_x: f32, world_z: f32) -> f32
Sourcepub fn sample_foam(&self, world_x: f32, world_z: f32) -> f32
pub fn sample_foam(&self, world_x: f32, world_z: f32) -> f32
Sourcepub fn total_wave_energy(&self) -> f32
pub fn total_wave_energy(&self) -> f32
Computes total discrete shallow-water Hamiltonian wave energy (kinetic + potential) across all fluid cells.
§Returns
f32- Non-negative discrete mechanical wave energy.
Sourcepub fn max_abs_height(&self) -> f32
pub fn max_abs_height(&self) -> f32
Returns the maximum absolute displacement amplitude across the entire heightfield.
§Returns
f32- Maximum|h|in meters.
Sourcepub fn build_mesh(&self, name: &str, material: PbrMaterial) -> Mesh3D
pub fn build_mesh(&self, name: &str, material: PbrMaterial) -> Mesh3D
Builds an indexed Mesh3D representing the current wave surface with analytical normals and vertex foam colors.
§Arguments
&str- Asset mesh name (falls back toWAKE_DEFAULT_MESH_NAMEwhen empty).PbrMaterial- Water surface PBR material.
§Returns
Mesh3D- Renderable triangle mesh for the heightfield surface.
Source§impl WaveHeightfield2D
Implements impl #impl_generics #name #ty_generics #where_clause.
impl WaveHeightfield2D
Implements impl #impl_generics #name #ty_generics #where_clause.
pub fn get_config(&self) -> WaveHeightfieldConfig
pub fn get_mut_config(&mut self) -> &mut WaveHeightfieldConfig
pub fn set_config(&mut self, val: WaveHeightfieldConfig) -> &mut Self
pub fn get_heights_curr(&self) -> &Vec<f32>
pub fn get_mut_heights_curr(&mut self) -> &mut Vec<f32>
pub fn set_heights_curr(&mut self, val: Vec<f32>) -> &mut Self
pub fn get_heights_prev(&self) -> &Vec<f32>
pub fn get_mut_heights_prev(&mut self) -> &mut Vec<f32>
pub fn set_heights_prev(&mut self, val: Vec<f32>) -> &mut Self
pub fn get_heights_next(&self) -> &Vec<f32>
pub fn get_mut_heights_next(&mut self) -> &mut Vec<f32>
pub fn set_heights_next(&mut self, val: Vec<f32>) -> &mut Self
pub fn get_obstacle_mask(&self) -> &Vec<u8> ⓘ
pub fn get_mut_obstacle_mask(&mut self) -> &mut Vec<u8> ⓘ
pub fn set_obstacle_mask(&mut self, val: Vec<u8>) -> &mut Self
pub fn get_foam(&self) -> &Vec<f32>
pub fn get_mut_foam(&mut self) -> &mut Vec<f32>
pub fn set_foam(&mut self, val: Vec<f32>) -> &mut Self
pub fn get_cell_damping(&self) -> &Vec<f32>
pub fn get_mut_cell_damping(&mut self) -> &mut Vec<f32>
pub fn set_cell_damping(&mut self, val: Vec<f32>) -> &mut Self
pub fn get_last_dt_sub(&self) -> f32
pub fn get_mut_last_dt_sub(&mut self) -> &mut f32
pub fn set_last_dt_sub(&mut self, val: f32) -> &mut Self
pub fn get_sim_time_secs(&self) -> f32
pub fn get_mut_sim_time_secs(&mut self) -> &mut f32
pub fn set_sim_time_secs(&mut self, val: f32) -> &mut Self
Trait Implementations§
Source§impl Clone for WaveHeightfield2D
impl Clone for WaveHeightfield2D
Source§impl Debug for WaveHeightfield2D
impl Debug for WaveHeightfield2D
Source§impl Default for WaveHeightfield2D
Default calm WaveHeightfield2D solver.
impl Default for WaveHeightfield2D
Default calm WaveHeightfield2D solver.