Skip to main content

LiquidFluidSolver

Struct LiquidFluidSolver 

Source
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.

Source

pub fn with_config(config: GyroLiquidConfig) -> Self

Creates a pre-allocated LiquidFluidSolver with config and initializes calm resting water.

§Arguments
  • GyroLiquidConfig - Physical container, fill ratio, viscosity, and solver configuration.
§Returns
  • Self - Initialized liquid solver.
Source

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.
Source

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.
Source

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 viewport width / height aspect ratio.
Source

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.
Source

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.
Source

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.
Source

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.
Source

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).
Source

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.
Source

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 in m/s².
  • f32 - Vertical shake acceleration in m/s².
Source

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 in m/s.
  • f32 - Stirring velocity y-component in m/s.
Source

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.
Source

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.
Source

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.
Source

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.
Source

pub fn center_of_mass(&self) -> (f32, f32)

Computes the liquid center of mass (cx, cy) in SI meters inside the vessel.

§Arguments
  • &Self - Liquid solver reference.
§Returns
  • (f32, f32) - Center of mass coordinates (x_m, y_m).
Source

pub fn has_invalid_or_escaped_state(&self) -> bool

Returns true if any active particle, buoyant body, or bubble has non-finite coordinates or escaped vessel bounds.

§Arguments
  • &Self - Liquid solver reference.
§Returns
  • bool - true when NaN/Inf or out-of-bounds escape is detected.
Source§

impl LiquidFluidSolver

Source

pub fn get_config(&self) -> GyroLiquidConfig

Source

pub fn get_mut_config(&mut self) -> &mut GyroLiquidConfig

Source

pub fn set_config(&mut self, val: GyroLiquidConfig) -> &mut Self

Source

pub fn get_particle_count(&self) -> usize

Source

pub fn get_mut_particle_count(&mut self) -> &mut usize

Source

pub fn set_particle_count(&mut self, val: usize) -> &mut Self

Source

pub fn get_rest_spacing_m(&self) -> f32

Source

pub fn get_mut_rest_spacing_m(&mut self) -> &mut f32

Source

pub fn set_rest_spacing_m(&mut self, val: f32) -> &mut Self

Source

pub fn get_particle_area_m2(&self) -> f32

Source

pub fn get_mut_particle_area_m2(&mut self) -> &mut f32

Source

pub fn set_particle_area_m2(&mut self, val: f32) -> &mut Self

Source

pub fn get_particle_mass_kgpm(&self) -> f32

Source

pub fn get_mut_particle_mass_kgpm(&mut self) -> &mut f32

Source

pub fn set_particle_mass_kgpm(&mut self, val: f32) -> &mut Self

Source

pub fn get_kernel_radius_m(&self) -> f32

Source

pub fn get_mut_kernel_radius_m(&mut self) -> &mut f32

Source

pub fn set_kernel_radius_m(&mut self, val: f32) -> &mut Self

Source

pub fn get_poly6_coeff(&self) -> f32

Source

pub fn get_mut_poly6_coeff(&mut self) -> &mut f32

Source

pub fn set_poly6_coeff(&mut self, val: f32) -> &mut Self

Source

pub fn get_spiky_grad_coeff(&self) -> f32

Source

pub fn get_mut_spiky_grad_coeff(&mut self) -> &mut f32

Source

pub fn set_spiky_grad_coeff(&mut self, val: f32) -> &mut Self

Source

pub fn get_w_dq(&self) -> f32

Source

pub fn get_mut_w_dq(&mut self) -> &mut f32

Source

pub fn set_w_dq(&mut self, val: f32) -> &mut Self

Source

pub fn get_gravity_x(&self) -> f32

Source

pub fn get_mut_gravity_x(&mut self) -> &mut f32

Source

pub fn set_gravity_x(&mut self, val: f32) -> &mut Self

Source

pub fn get_gravity_y(&self) -> f32

Source

pub fn get_mut_gravity_y(&mut self) -> &mut f32

Source

pub fn set_gravity_y(&mut self, val: f32) -> &mut Self

Source

pub fn get_gravity_z(&self) -> f32

Source

pub fn get_mut_gravity_z(&mut self) -> &mut f32

Source

pub fn set_gravity_z(&mut self, val: f32) -> &mut Self

Source

pub fn get_linear_accel_x(&self) -> f32

Source

pub fn get_mut_linear_accel_x(&mut self) -> &mut f32

Source

pub fn set_linear_accel_x(&mut self, val: f32) -> &mut Self

Source

pub fn get_linear_accel_y(&self) -> f32

Source

pub fn get_mut_linear_accel_y(&mut self) -> &mut f32

Source

pub fn set_linear_accel_y(&mut self, val: f32) -> &mut Self

Source

pub fn get_shake_accel_x(&self) -> f32

Source

pub fn get_mut_shake_accel_x(&mut self) -> &mut f32

Source

pub fn set_shake_accel_x(&mut self, val: f32) -> &mut Self

Source

pub fn get_shake_accel_y(&self) -> f32

Source

pub fn get_mut_shake_accel_y(&mut self) -> &mut f32

Source

pub fn set_shake_accel_y(&mut self, val: f32) -> &mut Self

Source

pub fn get_angular_vel_cw(&self) -> f32

Source

pub fn get_mut_angular_vel_cw(&mut self) -> &mut f32

Source

pub fn set_angular_vel_cw(&mut self, val: f32) -> &mut Self

Source

pub fn get_prev_angular_vel_cw(&self) -> f32

Source

pub fn get_mut_prev_angular_vel_cw(&mut self) -> &mut f32

Source

pub fn set_prev_angular_vel_cw(&mut self, val: f32) -> &mut Self

Source

pub fn get_angular_accel_cw(&self) -> f32

Source

pub fn get_mut_angular_accel_cw(&mut self) -> &mut f32

Source

pub fn set_angular_accel_cw(&mut self, val: f32) -> &mut Self

Source

pub fn get_virtual_roll_rad(&self) -> f32

Source

pub fn get_mut_virtual_roll_rad(&mut self) -> &mut f32

Source

pub fn set_virtual_roll_rad(&mut self, val: f32) -> &mut Self

Source

pub fn get_virtual_pitch_rad(&self) -> f32

Source

pub fn get_mut_virtual_pitch_rad(&mut self) -> &mut f32

Source

pub fn set_virtual_pitch_rad(&mut self, val: f32) -> &mut Self

Source

pub fn get_prev_virtual_roll_rad(&self) -> f32

Source

pub fn get_mut_prev_virtual_roll_rad(&mut self) -> &mut f32

Source

pub fn set_prev_virtual_roll_rad(&mut self, val: f32) -> &mut Self

Source

pub fn get_active_roll_rad(&self) -> f32

Source

pub fn get_mut_active_roll_rad(&mut self) -> &mut f32

Source

pub fn set_active_roll_rad(&mut self, val: f32) -> &mut Self

Source

pub fn get_sim_time_secs(&self) -> f32

Source

pub fn get_mut_sim_time_secs(&mut self) -> &mut f32

Source

pub fn set_sim_time_secs(&mut self, val: f32) -> &mut Self

Source

pub fn get_rng_state(&self) -> u64

Source

pub fn get_mut_rng_state(&mut self) -> &mut u64

Source

pub fn set_rng_state(&mut self, val: u64) -> &mut Self

Source

pub fn get_kinetic_energy_mj(&self) -> f32

Source

pub fn get_mut_kinetic_energy_mj(&mut self) -> &mut f32

Source

pub fn set_kinetic_energy_mj(&mut self, val: f32) -> &mut Self

Source

pub fn get_peak_wave_height_m(&self) -> f32

Source

pub fn get_mut_peak_wave_height_m(&mut self) -> &mut f32

Source

pub fn set_peak_wave_height_m(&mut self, val: f32) -> &mut Self

Source

pub fn get_grid_w(&self) -> usize

Source

pub fn get_mut_grid_w(&mut self) -> &mut usize

Source

pub fn set_grid_w(&mut self, val: usize) -> &mut Self

Source

pub fn get_grid_h(&self) -> usize

Source

pub fn get_mut_grid_h(&mut self) -> &mut usize

Source

pub fn set_grid_h(&mut self, val: usize) -> &mut Self

Source

pub fn get_pos_x(&self) -> &Vec<f32>

Source

pub fn get_mut_pos_x(&mut self) -> &mut Vec<f32>

Source

pub fn set_pos_x(&mut self, val: Vec<f32>) -> &mut Self

Source

pub fn get_pos_y(&self) -> &Vec<f32>

Source

pub fn get_mut_pos_y(&mut self) -> &mut Vec<f32>

Source

pub fn set_pos_y(&mut self, val: Vec<f32>) -> &mut Self

Source

pub fn get_pred_x(&self) -> &Vec<f32>

Source

pub fn get_mut_pred_x(&mut self) -> &mut Vec<f32>

Source

pub fn set_pred_x(&mut self, val: Vec<f32>) -> &mut Self

Source

pub fn get_pred_y(&self) -> &Vec<f32>

Source

pub fn get_mut_pred_y(&mut self) -> &mut Vec<f32>

Source

pub fn set_pred_y(&mut self, val: Vec<f32>) -> &mut Self

Source

pub fn get_vel_x(&self) -> &Vec<f32>

Source

pub fn get_mut_vel_x(&mut self) -> &mut Vec<f32>

Source

pub fn set_vel_x(&mut self, val: Vec<f32>) -> &mut Self

Source

pub fn get_vel_y(&self) -> &Vec<f32>

Source

pub fn get_mut_vel_y(&mut self) -> &mut Vec<f32>

Source

pub fn set_vel_y(&mut self, val: Vec<f32>) -> &mut Self

Source

pub fn get_lambda(&self) -> &Vec<f32>

Source

pub fn get_mut_lambda(&mut self) -> &mut Vec<f32>

Source

pub fn set_lambda(&mut self, val: Vec<f32>) -> &mut Self

Source

pub fn get_density(&self) -> &Vec<f32>

Source

pub fn get_mut_density(&mut self) -> &mut Vec<f32>

Source

pub fn set_density(&mut self, val: Vec<f32>) -> &mut Self

Source

pub fn get_vorticity(&self) -> &Vec<f32>

Source

pub fn get_mut_vorticity(&mut self) -> &mut Vec<f32>

Source

pub fn set_vorticity(&mut self, val: Vec<f32>) -> &mut Self

Source

pub fn get_corr_x(&self) -> &Vec<f32>

Source

pub fn get_mut_corr_x(&mut self) -> &mut Vec<f32>

Source

pub fn set_corr_x(&mut self, val: Vec<f32>) -> &mut Self

Source

pub fn get_corr_y(&self) -> &Vec<f32>

Source

pub fn get_mut_corr_y(&mut self) -> &mut Vec<f32>

Source

pub fn set_corr_y(&mut self, val: Vec<f32>) -> &mut Self

Source

pub fn get_dvx_scratch(&self) -> &Vec<f32>

Source

pub fn get_mut_dvx_scratch(&mut self) -> &mut Vec<f32>

Source

pub fn set_dvx_scratch(&mut self, val: Vec<f32>) -> &mut Self

Source

pub fn get_dvy_scratch(&self) -> &Vec<f32>

Source

pub fn get_mut_dvy_scratch(&mut self) -> &mut Vec<f32>

Source

pub fn set_dvy_scratch(&mut self, val: Vec<f32>) -> &mut Self

Source

pub fn get_cell_counts(&self) -> &Vec<u32>

Source

pub fn get_mut_cell_counts(&mut self) -> &mut Vec<u32>

Source

pub fn set_cell_counts(&mut self, val: Vec<u32>) -> &mut Self

Source

pub fn get_cell_starts(&self) -> &Vec<u32>

Source

pub fn get_mut_cell_starts(&mut self) -> &mut Vec<u32>

Source

pub fn set_cell_starts(&mut self, val: Vec<u32>) -> &mut Self

Source

pub fn get_cell_cursors(&self) -> &Vec<u32>

Source

pub fn get_mut_cell_cursors(&mut self) -> &mut Vec<u32>

Source

pub fn set_cell_cursors(&mut self, val: Vec<u32>) -> &mut Self

Source

pub fn get_particle_cells(&self) -> &Vec<u32>

Source

pub fn get_mut_particle_cells(&mut self) -> &mut Vec<u32>

Source

pub fn set_particle_cells(&mut self, val: Vec<u32>) -> &mut Self

Source

pub fn get_sorted_indices(&self) -> &Vec<u32>

Source

pub fn get_mut_sorted_indices(&mut self) -> &mut Vec<u32>

Source

pub fn set_sorted_indices(&mut self, val: Vec<u32>) -> &mut Self

Source

pub fn get_neighbor_indices(&self) -> &Vec<u16>

Source

pub fn get_mut_neighbor_indices(&mut self) -> &mut Vec<u16>

Source

pub fn set_neighbor_indices(&mut self, val: Vec<u16>) -> &mut Self

Source

pub fn get_neighbor_counts(&self) -> &Vec<u8> ⓘ

Source

pub fn get_mut_neighbor_counts(&mut self) -> &mut Vec<u8> ⓘ

Source

pub fn set_neighbor_counts(&mut self, val: Vec<u8>) -> &mut Self

Source

pub fn get_buoyant_bodies(&self) -> &Vec<BuoyantBody>

Source

pub fn get_mut_buoyant_bodies(&mut self) -> &mut Vec<BuoyantBody>

Source

pub fn set_buoyant_bodies(&mut self, val: Vec<BuoyantBody>) -> &mut Self

Source

pub fn get_buoyant_body_count(&self) -> usize

Source

pub fn get_mut_buoyant_body_count(&mut self) -> &mut usize

Source

pub fn set_buoyant_body_count(&mut self, val: usize) -> &mut Self

Source

pub fn get_bubbles(&self) -> &Vec<FluidBubble>

Source

pub fn get_mut_bubbles(&mut self) -> &mut Vec<FluidBubble>

Source

pub fn set_bubbles(&mut self, val: Vec<FluidBubble>) -> &mut Self

Source

pub fn get_bubble_count(&self) -> usize

Source

pub fn get_mut_bubble_count(&mut self) -> &mut usize

Source

pub fn set_bubble_count(&mut self, val: usize) -> &mut Self

Trait Implementations§

Source§

impl Clone for LiquidFluidSolver

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for LiquidFluidSolver

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for LiquidFluidSolver

Default handheld SI Position-Based Fluids solver.

Source§

fn default() -> Self

Creates a LiquidFluidSolver initialized with GyroLiquidConfig::default().

§Returns
  • Self - Pre-allocated SI liquid solver ready for zero-alloc stepping.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.