pub struct LiquidFluidSolver { /* private fields */ }Expand description
Real-time SI Position-Based Fluids (PBF) 2D liquid engine with non-inertial rotating-device dynamics, Archimedes buoyancy, and zero steady-state heap allocations.
Implementations§
Source§impl LiquidFluidSolver
SI Position-Based Fluids simulation, non-inertial frame kinematics, Archimedes buoyancy, and snapshot capture for LiquidFluidSolver.
impl LiquidFluidSolver
SI Position-Based Fluids simulation, non-inertial frame kinematics, Archimedes buoyancy, and snapshot capture for LiquidFluidSolver.
Sourcepub fn with_config(config: GyroLiquidConfig) -> Self
pub fn with_config(config: GyroLiquidConfig) -> Self
Sourcepub fn reset_water(&mut self)
pub fn reset_water(&mut self)
Resets the liquid particles, buoyant objects, and bubbles to a calm hydrostatic pool matching the active fill ratio.
§Arguments
&Self- Mutable liquid solver.
Sourcepub fn reset_buoyant_bodies(&mut self)
pub fn reset_buoyant_bodies(&mut self)
Initializes the default floating orb (450 kg/m³) and ice cube (917 kg/m³) near the free surface.
§Arguments
&Self- Mutable liquid solver.
Sourcepub fn adapt_vessel_aspect(&mut self, aspect_w_over_h: f32)
pub fn adapt_vessel_aspect(&mut self, aspect_w_over_h: f32)
Adapts physical vessel aspect ratio to match a resized or fullscreen viewport while preserving total physical water area and live wave motion.
§Arguments
&Self- Mutable liquid solver.f32- Target viewportwidth / heightaspect ratio.
Sourcepub fn set_fill_ratio(&mut self, fill_ratio: f32)
pub fn set_fill_ratio(&mut self, fill_ratio: f32)
Updates the liquid fill ratio (0.20..=0.85) and rebuilds the resting fluid volume.
§Arguments
&Self- Mutable liquid solver.f32- Desired liquid area fill fraction.
Sourcepub fn set_viscosity(&mut self, viscosity_scale: f32)
pub fn set_viscosity(&mut self, viscosity_scale: f32)
Updates the relative viscosity multiplier (0.2..=6.0, where 1.0 = 20 °C pure water).
§Arguments
&Self- Mutable liquid solver.f32- Relative viscosity scale factor.
Sourcepub fn set_surface_tension(&mut self, surface_tension_scale: f32)
pub fn set_surface_tension(&mut self, surface_tension_scale: f32)
Updates the relative surface tension multiplier (0.0..=3.0, where 1.0 = 0.0728 N/m).
§Arguments
&Self- Mutable liquid solver.f32- Relative surface tension scale factor.
Sourcepub fn set_buoyant_bodies_enabled(&mut self, enabled: bool)
pub fn set_buoyant_bodies_enabled(&mut self, enabled: bool)
Enables or disables Archimedes buoyant floating bodies (orb & ice cube).
§Arguments
&Self- Mutable liquid solver.bool- Whether floating buoyant objects are active.
Sourcepub fn set_virtual_tilt(&mut self, roll_rad: f32, pitch_rad: f32)
pub fn set_virtual_tilt(&mut self, roll_rad: f32, pitch_rad: f32)
Sets desktop/simulator virtual device tilt angles (roll_rad, pitch_rad).
§Arguments
&Self- Mutable liquid solver.f32- In-plane roll angle in radians (0= upright,+π/2= clockwise right-down).f32- Out-of-plane pitch angle in radians (0= vertical,+π/2= flat face-up).
Sourcepub fn rotate_container_by(&mut self, delta_rad: f32)
pub fn rotate_container_by(&mut self, delta_rad: f32)
Rotates the virtual container angle smoothly by delta_rad (positive clockwise in screen space).
§Arguments
&Self- Mutable liquid solver.f32- Angular rotation increment in radians.
Sourcepub fn apply_shake_impulse(&mut self, ax: f32, ay: f32)
pub fn apply_shake_impulse(&mut self, ax: f32, ay: f32)
Injects a physical linear frame shake acceleration impulse (ax, ay) in m/s² (decays smoothly).
§Arguments
&Self- Mutable liquid solver.f32- Horizontal shake acceleration inm/s².f32- Vertical shake acceleration inm/s².
Sourcepub fn apply_stir_impulse(
&mut self,
norm_x: f32,
norm_y: f32,
vel_x_mps: f32,
vel_y_mps: f32,
)
pub fn apply_stir_impulse( &mut self, norm_x: f32, norm_y: f32, vel_x_mps: f32, vel_y_mps: f32, )
Applies a direct pointer/touch viscous wake stirring impulse inside normalized tank coordinates [0, 1] × [0, 1].
§Arguments
&Self- Mutable liquid solver.f32- Normalized horizontal coordinate in[0.0, 1.0].f32- Normalized vertical coordinate in[0.0, 1.0].f32- Stirring velocity x-component inm/s.f32- Stirring velocity y-component inm/s.
Sourcepub fn apply_device_motion(&mut self, sample: DeviceMotionSample, dt: f32)
pub fn apply_device_motion(&mut self, sample: DeviceMotionSample, dt: f32)
Feeds a sanitized 6-DOF DeviceMotionSample directly into the non-inertial solver frame.
§Arguments
&Self- Mutable liquid solver.DeviceMotionSample- Screen-aligned hardware or synthetic sensor sample.f32- Timestep in seconds used to estimate Euler angular accelerationα = dΩ/dt.
Sourcepub fn sync_virtual_motion(&mut self, dt: f32)
pub fn sync_virtual_motion(&mut self, dt: f32)
Updates gravity, angular velocity Ω, and Euler acceleration α from desktop virtual tilt angles.
§Arguments
&Self- Mutable liquid solver.f32- Timestep in seconds.
Sourcepub fn step(&mut self, dt: f32)
pub fn step(&mut self, dt: f32)
Advances the entire physical liquid simulation by dt seconds with zero steady-state heap allocations.
§Arguments
&Self- Mutable liquid solver.f32- Fixed simulation timestep in seconds.
Sourcepub fn capture_snapshot_into(&self, dst: &mut FluidSimSnapshot)
pub fn capture_snapshot_into(&self, dst: &mut FluidSimSnapshot)
Captures current particle, buoyant body, and bubble states directly into pre-allocated dst with zero heap allocations.
§Arguments
&Self- Liquid solver reference.&mut FluidSimSnapshot- Pre-allocated destination snapshot.