pub struct RecPlayer { /* private fields */ }Expand description
Incremental player. Owns a private copy of the recording bytes and drives replay one step at a time. (b2RecPlayer)
Implementations§
Source§impl RecPlayer
impl RecPlayer
Sourcepub fn create(data: &[u8]) -> Option<RecPlayer>
pub fn create(data: &[u8]) -> Option<RecPlayer>
Open a recording for incremental playback. The player copies the bytes, so the source buffer can be dropped immediately after this call. Returns None if the recording is malformed. (b2RecPlayer_Create; workerCount is not a parameter of the serial port.)
Sourcepub fn step_frame(&mut self) -> bool
pub fn step_frame(&mut self) -> bool
Advance the replay by one recorded step. Returns true if a step executed, false once the end of the recording is reached. (b2RecPlayer_StepFrame)
Sourcepub fn restart(&mut self)
pub fn restart(&mut self)
Rewind the player to the first step, recreating the replay world from the frame-0 image in place. (b2RecPlayer_Restart)
Sourcepub fn seek_frame(&mut self, target_frame: i32)
pub fn seek_frame(&mut self, target_frame: i32)
Seek to a recorded step. Seeking backward restores the nearest keyframe and re-runs the gap. Clamps to the recording bounds. (b2RecPlayer_SeekFrame)
Sourcepub fn world_mut(&mut self) -> &mut World
pub fn world_mut(&mut self) -> &mut World
Mutable access to the replay world, e.g. for a viewer’s world_draw.
Sourcepub fn info(&self) -> RecPlayerInfo
pub fn info(&self) -> RecPlayerInfo
Static metadata for the recording. (b2RecPlayer_GetInfo)
Sourcepub fn is_at_end(&self) -> bool
pub fn is_at_end(&self) -> bool
True once the end of the recording has been reached. (b2RecPlayer_IsAtEnd)
Sourcepub fn has_diverged(&self) -> bool
pub fn has_diverged(&self) -> bool
True if a recorded state hash or query failed to reproduce. (b2RecPlayer_HasDiverged)
Sourcepub fn diverge_frame(&self) -> i32
pub fn diverge_frame(&self) -> i32
The first step at which replay diverged, or -1. (b2RecPlayer_GetDivergeFrame)
Sourcepub fn set_keyframe_policy(
&mut self,
budget_bytes: usize,
min_interval_frames: i32,
)
pub fn set_keyframe_policy( &mut self, budget_bytes: usize, min_interval_frames: i32, )
Tune the keyframe ring. A zero budget or a non-positive interval keeps that value. Clears the existing ring, so call restart afterward to repopulate it under the new policy. (b2RecPlayer_SetKeyframePolicy)
Sourcepub fn keyframe_budget(&self) -> usize
pub fn keyframe_budget(&self) -> usize
(b2RecPlayer_GetKeyframeBudget)
Sourcepub fn keyframe_min_interval(&self) -> i32
pub fn keyframe_min_interval(&self) -> i32
(b2RecPlayer_GetKeyframeMinInterval)
Sourcepub fn keyframe_interval(&self) -> i32
pub fn keyframe_interval(&self) -> i32
The current keyframe spacing in frames; reflects the effective backward-seek granularity right now. (b2RecPlayer_GetKeyframeInterval)
Sourcepub fn keyframe_bytes(&self) -> usize
pub fn keyframe_bytes(&self) -> usize
The memory currently held by keyframe snapshots, in bytes. (b2RecPlayer_GetKeyframeBytes)
Sourcepub fn draw_frame_queries(&self, draw: &mut dyn DebugDraw, query_index: i32)
pub fn draw_frame_queries(&self, draw: &mut dyn DebugDraw, query_index: i32)
Draw spatial queries recorded during the most recently replayed
frame. Call after world_draw so queries are layered on top of the
world. query_index < 0 draws all of them.
(b2RecPlayer_DrawFrameQueries)
Sourcepub fn frame_query_count(&self) -> i32
pub fn frame_query_count(&self) -> i32
The number of spatial queries recorded for the most recently replayed frame. (b2RecPlayer_GetFrameQueryCount)
Sourcepub fn frame_query(&self, index: i32) -> RecQueryInfo
pub fn frame_query(&self, index: i32) -> RecQueryInfo
A recorded query from the most recently replayed frame by index. (b2RecPlayer_GetFrameQuery)
Sourcepub fn frame_query_hit(&self, query_index: i32, hit_index: i32) -> RecQueryHit
pub fn frame_query_hit(&self, query_index: i32, hit_index: i32) -> RecQueryHit
One result of a recorded query from the most recently replayed frame. (b2RecPlayer_GetFrameQueryHit)
Sourcepub fn body_count(&self) -> i32
pub fn body_count(&self) -> i32
The number of body slots tracked for the outliner. This is the creation-order span and includes holes for destroyed bodies, so it only grows as the replay advances. (b2RecPlayer_GetBodyCount)