Skip to main content

GyroLiquidGameScene

Struct GyroLiquidGameScene 

Source
pub struct GyroLiquidGameScene { /* private fields */ }
Expand description

Shareable high-fidelity gyroscope liquid water GameScene ready for GameEngineHost, arbitrary dynamic resize, and edge-to-edge fullscreen.

Cloning GyroLiquidGameScene shares the same underlying solver/renderer handle so UI controls can tilt, shake, stir, change viscosity/fill, toggle buoyant bodies, and read live GyroLiquidStats seamlessly while GameEngineHost drives fixed-step physics and zero-copy pooled rendering.

Implementations§

Source§

impl GyroLiquidGameScene

Interactive physics controls, sensor bindings, telemetry inspection, and offscreen pooled rendering on GyroLiquidGameScene.

Source

pub fn with_config(config: GyroLiquidConfig) -> Self

Creates a new GyroLiquidGameScene with custom physical config.

§Arguments
  • GyroLiquidConfig - Physical container, fill ratio, viscosity, and solver configuration.
§Returns
  • Self - Shareable liquid water game scene handle.
Source

pub fn bind_device_motion(&self, signal: Signal<DeviceMotionSample>)

Binds a reactive Signal<DeviceMotionSample> (e.g. from use_device_motion()) so live hardware sensor updates drive the liquid seamlessly.

§Arguments
  • &Self - Liquid game scene handle.
  • Signal<DeviceMotionSample> - Reactive device motion signal.
Source

pub fn set_device_motion(&self, sample: Option<DeviceMotionSample>)

Injects an explicit DeviceMotionSample (useful for live custom bridges or deterministic testing) and clears it when passed None.

§Arguments
  • &Self - Liquid game scene handle.
  • Option<DeviceMotionSample> - Hardware or synthetic motion sample.
Source

pub fn set_sensor_mode(&self, mode: FluidSensorMode)

Selects the sensor input mode (Auto, LiveHardware, or VirtualTilt).

§Arguments
  • &Self - Liquid game scene handle.
  • FluidSensorMode - Desired sensor driving mode.
Source

pub fn set_virtual_tilt(&self, roll_rad: f32, pitch_rad: f32)

Sets virtual desktop/simulator tilt angles (roll_rad, pitch_rad).

§Arguments
  • &Self - Liquid game scene handle.
  • f32 - In-plane roll angle in radians (0.0 = upright, +π/2 = clockwise right-down).
  • f32 - Out-of-plane pitch angle in radians (0.0 = upright vertical, +π/2 = face-up flat).
Source

pub fn rotate_container_by(&self, delta_rad: f32)

Rotates the virtual container angle by delta_rad radians (positive clockwise in screen space).

§Arguments
  • &Self - Liquid game scene handle.
  • f32 - Rotation increment in radians.
Source

pub fn apply_shake_impulse(&self, ax: f32, ay: f32)

Injects a physical linear frame shake acceleration impulse (ax, ay) in m/s².

§Arguments
  • &Self - Liquid game scene handle.
  • f32 - Horizontal shake acceleration in m/s².
  • f32 - Vertical shake acceleration in m/s².
Source

pub fn apply_stir_impulse( &self, norm_x: f32, norm_y: f32, vel_x_mps: f32, vel_y_mps: f32, )

Applies a direct pointer/touch stirring wake impulse at normalized vessel coordinates (norm_x, norm_y).

§Arguments
  • &Self - Liquid game scene handle.
  • f32 - Normalized x-coordinate in [0.0, 1.0].
  • f32 - Normalized y-coordinate in [0.0, 1.0].
  • f32 - Stir velocity x-component in m/s.
  • f32 - Stir velocity y-component in m/s.
Source

pub fn set_fill_ratio(&self, fill_ratio: f32)

Updates the liquid fill ratio (0.20..=0.85) and captures a discontinuous snapshot cleanly.

§Arguments
  • &Self - Liquid game scene handle.
  • f32 - Target fill fraction in [0.20, 0.85].
Source

pub fn set_viscosity(&self, viscosity: f32)

Updates the relative liquid viscosity (0.2..=6.0, where 1.0 = 20 °C pure water).

§Arguments
  • &Self - Liquid game scene handle.
  • f32 - Relative viscosity multiplier.
Source

pub fn set_surface_tension(&self, surface_tension: f32)

Updates the relative liquid surface tension (0.0..=3.0, where 1.0 = 0.0728 N/m).

§Arguments
  • &Self - Liquid game scene handle.
  • f32 - Relative surface tension multiplier.
Source

pub fn set_buoyant_bodies_enabled(&self, enabled: bool)

Enables or disables Archimedes buoyant floating objects (orb + ice cube).

§Arguments
  • &Self - Liquid game scene handle.
  • bool - Whether floating buoyant objects are active.
Source

pub fn reset_water(&self)

Resets the water, buoyant objects, bubbles, and virtual tilt to a calm upright resting pool.

§Arguments
  • &Self - Liquid game scene handle.
Source

pub fn stats(&self) -> GyroLiquidStats

Returns the latest read-only GyroLiquidStats telemetry snapshot.

§Arguments
  • &Self - Liquid game scene handle.
§Returns
  • GyroLiquidStats - Current live telemetry struct.
Source

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

Returns the liquid center of mass (x_m, y_m) in SI meters inside the physical vessel.

§Arguments
  • &Self - Liquid game scene handle.
§Returns
  • (f32, f32) - Center of mass in meters.
Source

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

Copies the currently active buoyant bodies for inspection or HUD overlays.

§Arguments
  • &Self - Liquid game scene handle.
§Returns
  • Vec<BuoyantBody> - Active buoyant rigid body states.
Source

pub fn has_invalid_or_escaped_state(&self) -> bool

Returns true if any active particle or buoyant body has NaN/Inf state or escaped container bounds.

§Arguments
  • &Self - Liquid game scene handle.
§Returns
  • bool - Whether solver state is invalid or escaped.
Source

pub fn render_to_pooled_frame( &self, viewport_w: u32, viewport_h: u32, alpha: f32, ) -> Option<PooledFrameLease>

Renders the interpolated liquid scene directly into the internal RenderBufferPool for offscreen inspection or custom blitting.

§Arguments
  • &Self - Liquid game scene handle.
  • u32 - Target viewport width in logical pixels.
  • u32 - Target viewport height in logical pixels.
  • f32 - Interpolation alpha in [0.0, 1.0].
§Returns
  • Option<PooledFrameLease> - Rendered zero-copy RGBA8 frame lease.

Trait Implementations§

Source§

impl Clone for GyroLiquidGameScene

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 GyroLiquidGameScene

Source§

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

Formats the struct fields as a debug struct, skipping excluded fields.

§Arguments
  • &mut ::std::fmt::Formatter<'_> - The formatter to write the representation into.
§Returns
  • ::std::fmt::Result - Success or failure of the formatting operation.
Source§

impl Default for GyroLiquidGameScene

Default handheld gyroscope liquid water game scene.

Source§

fn default() -> Self

Creates a GyroLiquidGameScene configured with GyroLiquidConfig::default().

§Returns
  • Self - Shareable liquid water game scene handle.
Source§

impl GameScene for GyroLiquidGameScene

GameScene integration driving fixed-step SI liquid physics, sensor ingestion, pointer stirring, and zero-copy pooled optical rendering inside GameEngineHost.

Source§

fn fixed_update(&mut self, dt: f32, input: &InputState)

Advances SI PBF liquid physics by one fixed timestep dt using live hardware sensors (or virtual tilt) plus pointer stirring and keyboard controls.

§Arguments
  • &Self - Mutable liquid scene handle.
  • f32 - Fixed simulation timestep in seconds.
  • &InputState - Real-time polled pointer and keyboard input state.
Source§

fn render(&mut self, alpha: f32, ctx: &mut GameRenderContext<'_>)

Renders the photorealistic optical water into the bounded RenderBufferPool and blits it zero-copy into ctx, adapting cleanly to arbitrary resize and fullscreen bounds.

§Arguments
  • &Self - Mutable liquid scene handle.
  • f32 - Render interpolation alpha in [0.0, 1.0].
  • &mut GameRenderContext<'_> - Active viewport draw surface.
Source§

fn update(&mut self, _dt: f32, _input: &InputState)

Advances variable-rate camera, animation, or visual interpolation state. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for GyroLiquidGameScene

§

impl !Send for GyroLiquidGameScene

§

impl !Sync for GyroLiquidGameScene

§

impl !UnwindSafe for GyroLiquidGameScene

§

impl Forget for GyroLiquidGameScene

§

impl Freeze for GyroLiquidGameScene
where *const RcInner<RefCell<GyroLiquidSceneState>> is !null: Freeze, PhantomData<RcInner<RefCell<GyroLiquidSceneState>>>: Freeze,

§

impl Move for GyroLiquidGameScene

§

impl Unpin for GyroLiquidGameScene
where Rc<RefCell<GyroLiquidSceneState>>: Unpin,

§

impl UnsafeUnpin for GyroLiquidGameScene
where *const RcInner<RefCell<GyroLiquidSceneState>> is !null: UnsafeUnpin, PhantomData<RcInner<RefCell<GyroLiquidSceneState>>>: UnsafeUnpin,

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.