Box3D
Safe HaskellNone
LanguageGHC2021

Box3D.RecPlayer

Synopsis

Documentation

create Source #

Arguments

:: Ptr ()

data: pointer to recording bytes

-> Int

size: byte count of the recording

-> Int

workerCount: worker count for the replay world; pass 1 to match a serial recording. Replaying at a different count re-partitions the constraint graph, so the StateHash check becomes a cross-thread determinism test. Adjustable later with b3RecPlayer_SetWorkerCount.

-> IO (Ptr RecPlayer) 

Create a player over a recording. Owns a private copy of the bytes.

Returns: a new player, or NULL on bad header or deserialization failure

Binds b3RecPlayer_Create.

destroy :: Ptr RecPlayer -> IO () Source #

Destroy the player and free all memory. Restores the previous global length scale.

Binds b3RecPlayer_Destroy.

stepFrame :: Ptr RecPlayer -> IO Bool Source #

Advance one frame: dispatch ops until the next Step completes.

Returns: true when a frame was stepped, false at end-of-recording

Binds b3RecPlayer_StepFrame.

restart :: Ptr RecPlayer -> IO () Source #

Rewind to frame 0 (in-place restore so the world id stays stable).

Binds b3RecPlayer_Restart.

seekFrame Source #

Arguments

:: Ptr RecPlayer 
-> Int
targetFrame
-> IO () 

Seek to a specific frame. Forward seek steps op-by-op; backward seek restores the nearest keyframe then re-steps the remaining gap.

Binds b3RecPlayer_SeekFrame.

getWorldId :: Ptr RecPlayer -> IO WorldId Source #

Returns: the world currently driven by this player

Binds b3RecPlayer_GetWorldId.

getFrame :: Ptr RecPlayer -> IO Int Source #

Returns: the last fully-stepped frame index (0 before any step)

Binds b3RecPlayer_GetFrame.

getFrameCount :: Ptr RecPlayer -> IO Int Source #

Returns: total number of recorded frames

Binds b3RecPlayer_GetFrameCount.

isAtEnd :: Ptr RecPlayer -> IO Bool Source #

Returns: true when the op stream is exhausted

Binds b3RecPlayer_IsAtEnd.

hasDiverged :: Ptr RecPlayer -> IO Bool Source #

Returns: true when any StateHash mismatch has been detected

Binds b3RecPlayer_HasDiverged.

getInfo Source #

Arguments

:: Ptr RecPlayer 
-> Ptr RecPlayerInfo

Result buffer.

-> IO () 

Returns: a summary of the recording read at open: frame count, recorded tuning, and bounds

Binds b3RecPlayer_GetInfo.

getDivergeFrame :: Ptr RecPlayer -> IO Int Source #

Returns: the first frame at which replay diverged, or -1 if it has not diverged

Binds b3RecPlayer_GetDivergeFrame.

setWorkerCount Source #

Arguments

:: Ptr RecPlayer 
-> Int
count
-> IO () 

Set the worker count of the replay world. Clamped to \[1, B3_MAX_WORKERS\]. Applied to the live world at once and reused whenever the player rebuilds its world on Restart or a backward seek. Replaying at a different count than recorded re-partitions the constraint graph, so the StateHash check becomes a cross-thread determinism test.

Binds b3RecPlayer_SetWorkerCount.

setKeyframePolicy Source #

Arguments

:: Ptr RecPlayer

player: the recording player

-> CSize

budgetBytes: memory cap for the kept snapshots; the spacing widens to stay under it

-> Int

minIntervalFrames: finest spacing between keyframes, in frames A zero budget or a non-positive interval keeps that value. Clears the existing ring, so call b3RecPlayer_Restart afterward to repopulate it under the new policy.

-> IO () 

Tune the keyframe ring used to speed up backward seeking. A keyframe is a periodic snapshot the player restores from instead of replaying from the start, trading memory for seek speed.

Binds b3RecPlayer_SetKeyframePolicy.

getKeyframeBudget :: Ptr RecPlayer -> IO CSize Source #

Returns: the keyframe memory budget in bytes

Binds b3RecPlayer_GetKeyframeBudget.

getKeyframeMinInterval :: Ptr RecPlayer -> IO Int Source #

Returns: the finest keyframe spacing in frames

Binds b3RecPlayer_GetKeyframeMinInterval.

getKeyframeInterval :: Ptr RecPlayer -> IO Int Source #

Returns: the current keyframe spacing in frames; starts at the min interval and doubles as the ring evicts to stay under budget, so it reflects the effective backward-seek granularity now

Binds b3RecPlayer_GetKeyframeInterval.

getKeyframeBytes :: Ptr RecPlayer -> IO CSize Source #

Returns: the memory currently held by keyframe snapshots, in bytes

Binds b3RecPlayer_GetKeyframeBytes.

getBodyCount :: Ptr RecPlayer -> IO Int Source #

Returns: the number of bodies tracked in creation order (including holes for destroyed bodies)

Binds b3RecPlayer_GetBodyCount.

getBodyId Source #

Arguments

:: Ptr RecPlayer 
-> Int
index
-> IO BodyId 

Resolve a creation ordinal to the live body id at the current frame.

Returns: the body id, or a null id if that ordinal is out of range or its body is destroyed

Binds b3RecPlayer_GetBodyId.

setDebugShapeCallbacks Source #

Arguments

:: Ptr RecPlayer

player: the player to configure

-> FunPtr CreateDebugShapeCallback

createDebugShape: called when a replayed shape is added; returns a user draw handle

-> FunPtr DestroyDebugShapeCallback

destroyDebugShape: called when a replayed shape is removed; may be NULL

-> Ptr ()

context: user context passed to both callbacks

-> IO () 

Wire host debug-shape callbacks into the player's replay world so a renderer can build per-shape draw resources (the 3D sample needs this or the replay world draws nothing). Rebuilds the current world under the new callbacks and rewinds to frame 0, so call it once right after b3RecPlayer_Create and re-read the world id afterward. The callbacks persist across Restart and backward seeks, which recreate the world internally.

Binds b3RecPlayer_SetDebugShapeCallbacks.

drawFrameQueries Source #

Arguments

:: Ptr RecPlayer

player: a valid player handle

-> Ptr DebugDraw

draw: debug draw callbacks

-> Int

queryIndex: index of the frame query to draw, or -1 to draw all of them

-> Int

selectedIndex: index of the query to emphasize (reserved color plus a label), or -1 for none

-> IO () 

Draw the spatial queries recorded during the most recently replayed frame, layered on top of the world. Call after b3World_Draw. NULL draw function pointers are skipped.

Binds b3RecPlayer_DrawFrameQueries.

getFrameQueryCount :: Ptr RecPlayer -> IO Int Source #

Returns: the number of spatial queries recorded for the most recently replayed frame

Binds b3RecPlayer_GetFrameQueryCount.

getFrameQuery Source #

Arguments

:: Ptr RecPlayer 
-> Int
index
-> Ptr RecQueryInfo

Result buffer.

-> IO () 

Get a recorded query from the most recently replayed frame by index.

Binds b3RecPlayer_GetFrameQuery.

getFrameQueryHit Source #

Arguments

:: Ptr RecPlayer 
-> Int
queryIndex
-> Int
hitIndex
-> Ptr RecQueryHit

Result buffer.

-> IO () 

Get one result of a recorded query from the most recently replayed frame.

Binds b3RecPlayer_GetFrameQueryHit.