Skip to main content

euv_core/game/fluid/scene/
struct.rs

1use super::*;
2
3/// Interior mutable state of `GyroLiquidGameScene` uniting SI PBF physics, double-buffered snapshots, optical rendering, and live sensor binding.
4#[derive(CustomDebug, Data)]
5pub(crate) struct GyroLiquidSceneState {
6    /// Core SI Position-Based Fluids solver.
7    pub(crate) solver: LiquidFluidSolver,
8    /// Double-buffered zero-allocation simulation snapshot store for smooth 240/360/480Hz+ interpolation.
9    pub(crate) snapshots: DoubleBufferedSnapshot<FluidSimSnapshot>,
10    /// Photorealistic optical liquid RGBA8 renderer.
11    pub(crate) renderer: LiquidOpticalRenderer,
12    /// Bounded zero-allocation RGBA8 output frame pool.
13    #[debug(skip)]
14    pub(crate) frame_pool: RenderBufferPool,
15    /// Monotonic submission fence counter for `RenderBufferPool`.
16    #[get(type(copy))]
17    pub(crate) frame_fence: u64,
18    /// Active sensor mode (`Auto`, `LiveHardware`, or `VirtualTilt`).
19    #[get(type(copy))]
20    pub(crate) sensor_mode: FluidSensorMode,
21    /// Optional explicit reactive `Signal<DeviceMotionSample>` bound from `Context` / `use_device_motion()`.
22    #[get(type(copy))]
23    pub(crate) device_motion_signal: Option<Signal<DeviceMotionSample>>,
24    /// Most recently injected explicit `DeviceMotionSample` (for direct programmatic / test sensor injection).
25    #[get(type(copy))]
26    pub(crate) manual_motion_sample: Option<DeviceMotionSample>,
27    /// Whether live hardware motion data drove the previous simulation tick.
28    #[get(type(copy))]
29    pub(crate) sensor_active: bool,
30    /// Last measured viewport rectangle in root logical coordinates for pointer stirring and aspect adaptation.
31    #[get(type(copy))]
32    pub(crate) last_viewport_bounds: Rect,
33    /// Last measured simulation step duration in milliseconds.
34    #[get(type(copy))]
35    pub(crate) last_sim_ms: f32,
36    /// Last measured optical render duration in milliseconds.
37    #[get(type(copy))]
38    pub(crate) last_render_ms: f32,
39    /// Cached read-only live telemetry snapshot.
40    #[get(type(copy))]
41    pub(crate) stats: GyroLiquidStats,
42}
43
44/// Shareable high-fidelity gyroscope liquid water `GameScene` ready for `GameEngineHost`, arbitrary dynamic resize, and edge-to-edge fullscreen.
45///
46/// 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.
47#[derive(Clone, CustomDebug, Getter)]
48pub struct GyroLiquidGameScene {
49    /// Shared interior-mutable liquid scene state.
50    #[debug(skip)]
51    #[get(pub(crate))]
52    pub(crate) inner: Rc<RefCell<GyroLiquidSceneState>>,
53}