pub struct SimulationSnapshot {
pub version: u32,
pub time: f64,
pub gravity: [f64; 3],
pub bodies: Vec<SimBodyState>,
pub contacts: Vec<PyContactResult>,
pub sleeping_count: usize,
pub description: Option<String>,
pub metadata: HashMap<String, String>,
}Expand description
A complete snapshot of simulation state at a particular moment.
Fields§
§version: u32Snapshot format version (currently 1).
time: f64Simulation time when the snapshot was taken.
gravity: [f64; 3]Gravity vector [gx, gy, gz] at snapshot time.
bodies: Vec<SimBodyState>State of every live body at snapshot time.
contacts: Vec<PyContactResult>Contacts active at snapshot time (informational).
sleeping_count: usizeNumber of sleeping bodies at snapshot time.
description: Option<String>Optional human-readable description.
metadata: HashMap<String, String>Arbitrary key-value metadata.
Implementations§
Source§impl SimulationSnapshot
impl SimulationSnapshot
Sourcepub const FORMAT_VERSION: u32 = 1
pub const FORMAT_VERSION: u32 = 1
Current snapshot format version.
Sourcepub fn body_count(&self) -> usize
pub fn body_count(&self) -> usize
Number of active bodies in this snapshot.
Sourcepub fn sleeping_count(&self) -> usize
pub fn sleeping_count(&self) -> usize
Number of sleeping bodies in this snapshot.
Sourcepub fn find_body(&self, handle: u32) -> Option<&SimBodyState>
pub fn find_body(&self, handle: u32) -> Option<&SimBodyState>
Find a body by its handle.
Sourcepub fn find_by_tag(&self, tag: &str) -> Option<&SimBodyState>
pub fn find_by_tag(&self, tag: &str) -> Option<&SimBodyState>
Find a body by its tag.
Sourcepub fn total_kinetic_energy_proxy(&self) -> f64
pub fn total_kinetic_energy_proxy(&self) -> f64
Total kinetic-energy proxy across all non-sleeping bodies.
Sourcepub fn to_pretty_json(&self) -> String
pub fn to_pretty_json(&self) -> String
Return the snapshot as a pretty-printed JSON string.
Sourcepub fn with_metadata(
self,
key: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn with_metadata( self, key: impl Into<String>, value: impl Into<String>, ) -> Self
Add a metadata key-value pair.
Sourcepub fn with_description(self, desc: impl Into<String>) -> Self
pub fn with_description(self, desc: impl Into<String>) -> Self
Set a human-readable description.
Sourcepub fn to_msgpack(&self) -> Vec<u8> ⓘ
pub fn to_msgpack(&self) -> Vec<u8> ⓘ
Serialize to MessagePack bytes.
Sourcepub fn from_msgpack(data: &[u8]) -> Result<Self, Error>
pub fn from_msgpack(data: &[u8]) -> Result<Self, Error>
Deserialize from MessagePack bytes.
Sourcepub fn static_body_count(&self) -> usize
pub fn static_body_count(&self) -> usize
Count of static bodies.
Sourcepub fn dynamic_body_count(&self) -> usize
pub fn dynamic_body_count(&self) -> usize
Count of dynamic (non-static) bodies.
Sourcepub fn find_by_tag_prefix(&self, prefix: &str) -> Vec<&SimBodyState>
pub fn find_by_tag_prefix(&self, prefix: &str) -> Vec<&SimBodyState>
Filter bodies by tag prefix.
Source§impl SimulationSnapshot
impl SimulationSnapshot
Sourcepub fn diff(
&self,
other: &SimulationSnapshot,
position_threshold: f64,
) -> SnapshotDiff
pub fn diff( &self, other: &SimulationSnapshot, position_threshold: f64, ) -> SnapshotDiff
Compute the diff between self (snapshot A) and other (snapshot B).
A body is considered “moved” if its position changed by more than
position_threshold.
Trait Implementations§
Source§impl Clone for SimulationSnapshot
impl Clone for SimulationSnapshot
Source§fn clone(&self) -> SimulationSnapshot
fn clone(&self) -> SimulationSnapshot
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SimulationSnapshot
impl Debug for SimulationSnapshot
Source§impl<'de> Deserialize<'de> for SimulationSnapshot
impl<'de> Deserialize<'de> for SimulationSnapshot
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for SimulationSnapshot
impl RefUnwindSafe for SimulationSnapshot
impl Send for SimulationSnapshot
impl Sync for SimulationSnapshot
impl Unpin for SimulationSnapshot
impl UnsafeUnpin for SimulationSnapshot
impl UnwindSafe for SimulationSnapshot
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.