option between water plane / water trigger
[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 };
63
64 /* we save this per-anim-frame. if there glider is existing in any state */
65 struct replay_glider_data
66 {
67 bool have_glider, glider_orphan;
68 f32 t;
69 v3f co;
70 v4f q;
71 };
72
73 struct replay_sfx {
74 u32 none;
75 };
76
77 struct replay_globals
78 {
79 replay_buffer local;
80 replay_frame *resume_target;
81 f64 resume_begin;
82 f32 resume_transition;
83
84 enum replay_control {
85 k_replay_control_scrub = 0x00,
86 k_replay_control_play = 0x01,
87 k_replay_control_resume= 0x02
88 }
89 replay_control;
90 f32 track_velocity;
91 struct gui_helper *helper_resume, *helper_freecam;
92
93 vg_camera replay_freecam;
94
95 bool use_freecam;
96 bool show_ui;
97 v3f freecam_v, freecam_w;
98
99 i32 editor_mode;
100
101 replay_keyframe keyframes[32];
102 u32 keyframe_count;
103 i32 active_keyframe;
104 }
105 extern player_replay;
106
107 int replay_seek( replay_buffer *replay, f64 t );
108
109 replay_frame *replay_find_recent_stateframe( replay_buffer *replay );
110 void replay_get_camera( replay_buffer *replay, vg_camera *cam );
111 void replay_get_frame_camera( replay_frame *frame, vg_camera *cam );
112 f32 replay_subframe_time( replay_buffer *replay );
113 void replay_clear( replay_buffer *replay );
114 void *
115 replay_frame_data( replay_frame *frame, enum replay_framedata type );
116
117 void skaterift_replay_pre_update(void);
118 void skaterift_replay_imgui(void);
119 void skaterift_replay_debug_info(void);
120 void skaterift_record_frame( replay_buffer *replay,
121 int force_gamestate );
122 void skaterift_replay_post_render(void);
123 void skaterift_replay_init(void);
124 void skaterift_get_replay_cam( vg_camera *cam );