update overlay to have ps controls too
[carveJwlIkooP6JGAAIwe30JlM.git] / player_replay.h
1 #pragma once
2 #include "player_render.h"
3 #include "vg/vg_rigidbody.h"
4
5 typedef struct replay_buffer replay_buffer;
6 typedef struct replay_frame replay_frame;
7 typedef struct replay_keyframe replay_keyframe;
8
9 typedef struct replay_gamestate replay_gamestate;
10 typedef struct replay_sfx replay_sfx;
11
12 struct replay_buffer {
13 void *data;
14 u32 size; /* bytes */
15
16 replay_frame *head, *tail, *cursor_frame,
17 *statehead;
18 f64 cursor;
19 };
20
21 enum replay_framedata{
22 k_replay_framedata_animator,
23 k_replay_framedata_gamestate,
24 k_replay_framedata_internal_gamestate,
25 k_replay_framedata_sfx,
26 k_replay_framedata_glider,
27 k_replay_framedata_rows
28 };
29
30 struct replay_cam
31 {
32 v3f pos, angles;
33 f32 fov;
34 };
35
36 struct replay_frame
37 {
38 struct replay_cam cam;
39 f64 time;
40
41 replay_frame *l, *r;
42
43 enum player_subsystem system;
44 u16 total_size;
45 u16 data_table[k_replay_framedata_rows][2];
46 };
47
48 /* player-defined replay frames */
49 struct replay_keyframe
50 {
51 struct replay_cam cam;
52 f64 time;
53 };
54
55 struct replay_gamestate
56 {
57 rigidbody rb, glider_rb; /* TODO: these don't need to be saved with their
58 full matrices */
59 v3f angles;
60 struct player_cam_controller cam_control;
61 u32 current_run_version;
62 bool drowned;
63 };
64
65 /* we save this per-anim-frame. if there glider is existing in any state */
66 struct replay_glider_data
67 {
68 bool have_glider, glider_orphan;
69 f32 t;
70 v3f co;
71 v4f q;
72 };
73
74 struct replay_sfx {
75 u32 none;
76 };
77
78 struct replay_globals
79 {
80 replay_buffer local;
81 replay_frame *resume_target;
82 f64 resume_begin;
83 f32 resume_transition;
84
85 enum replay_control {
86 k_replay_control_scrub = 0x00,
87 k_replay_control_play = 0x01,
88 k_replay_control_resume= 0x02
89 }
90 replay_control;
91 f32 track_velocity;
92 struct gui_helper *helper_resume, *helper_freecam;
93
94 vg_camera replay_freecam;
95
96 bool use_freecam;
97 bool show_ui;
98 v3f freecam_v, freecam_w;
99
100 i32 editor_mode;
101
102 replay_keyframe keyframes[32];
103 u32 keyframe_count;
104 i32 active_keyframe;
105 }
106 extern player_replay;
107
108 int replay_seek( replay_buffer *replay, f64 t );
109
110 replay_frame *replay_find_recent_stateframe( replay_buffer *replay );
111 void replay_get_camera( replay_buffer *replay, vg_camera *cam );
112 void replay_get_frame_camera( replay_frame *frame, vg_camera *cam );
113 f32 replay_subframe_time( replay_buffer *replay );
114 void replay_clear( replay_buffer *replay );
115 void *
116 replay_frame_data( replay_frame *frame, enum replay_framedata type );
117
118 void skaterift_replay_pre_update(void);
119 void skaterift_replay_imgui(void);
120 void skaterift_replay_debug_info(void);
121 void skaterift_record_frame( replay_buffer *replay,
122 int force_gamestate );
123 void skaterift_replay_post_render(void);
124 void skaterift_replay_init(void);
125 void skaterift_get_replay_cam( vg_camera *cam );