X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=player_replay.h;h=42d9bf71d768f731964e6195615647acf6e4ecfc;hb=refs%2Fheads%2Frigidbody;hp=2c18d4c68a17797ca5425f9ae8e42948baeb81fe;hpb=9eb3de757a997becb8406417a4bf613f4cb04900;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/player_replay.h b/player_replay.h index 2c18d4c..42d9bf7 100644 --- a/player_replay.h +++ b/player_replay.h @@ -5,8 +5,6 @@ #include "player.h" #include "player_render.h" -static i32 k_replay_test = 0; - typedef struct replay_buffer replay_buffer; typedef struct replay_frame replay_frame; typedef struct replay_gamestate replay_gamestate; @@ -16,55 +14,65 @@ struct replay_buffer { void *data; u32 size; /* bytes */ - enum replay_control { - k_replay_control_scrub, - k_replay_control_play, - } - control; - replay_frame *head, *tail, *cursor_frame, *statehead; f64 cursor; }; -struct replay_frame { - player_animation anim; - struct board_pose board_pose; +enum replay_framedata{ + k_replay_framedata_animator, + k_replay_framedata_gamestate, + k_replay_framedata_internal_gamestate, + k_replay_framedata_sfx, + k_replay_framedata_glider, + k_replay_framedata_rows +}; +struct replay_frame { v3f cam_pos, cam_angles; f32 cam_fov; f64 time; replay_frame *l, *r; - u16 gamestate_count, sfx_count; + enum player_subsystem system; + u16 total_size; + u16 data_table[k_replay_framedata_rows][2]; }; struct replay_gamestate { - enum player_subsystem system; - rigidbody rb; + rigidbody rb, glider_rb; /* TODO: these don't need to be saved with their + full matrices */ v3f angles; - struct player_cam_controller cam_control; +}; - union { - struct player_skate_state skate; - struct player_walk_state walk; - }; +/* we save this per-anim-frame. if there glider is existing in any state */ +struct replay_glider_data { + bool have_glider, glider_orphan; + f32 t; + v3f co; + v4f q; }; struct replay_sfx { u32 none; }; -VG_STATIC void replay_debug_info( player_instance *player ); -VG_STATIC replay_frame *replay_newframe( replay_buffer *replay, - u16 gamestate_count, u16 sfx_count ); -VG_STATIC void replay_imgui( player_instance *player ); -VG_STATIC void replay_seek( replay_buffer *replay, f64 t ); - -replay_gamestate *replay_frame_gamestate( replay_frame *frame, u16 index ); -replay_sfx *replay_frame_sfx( replay_frame *frame, u16 index ); -VG_STATIC replay_frame *replay_find_recent_stateframe( replay_buffer *replay ); +static int replay_seek( replay_buffer *replay, f64 t ); + +static replay_frame *replay_find_recent_stateframe( replay_buffer *replay ); +static void replay_get_camera( replay_buffer *replay, camera *cam ); +static void replay_get_frame_camera( replay_frame *frame, camera *cam ); +static f32 replay_subframe_time( replay_buffer *replay ); +static void replay_clear( replay_buffer *replay ); +static void * +replay_frame_data( replay_frame *frame, enum replay_framedata type ); + +static void skaterift_replay_pre_update(void); +static void skaterift_replay_imgui(void); +static void skaterift_replay_debug_info(void); +static void skaterift_record_frame( replay_buffer *replay, + int force_gamestate ); #endif /* PLAYER_REPLAY_H */