review save method
[carveJwlIkooP6JGAAIwe30JlM.git] / player_skate.h
1 #ifndef PLAYER_SKATE_H
2 #define PLAYER_SKATE_H
3
4 #include "player_api.h"
5
6 #define SKATE_CCD
7
8 typedef struct jump_info jump_info;
9
10 struct player_skate{
11 struct player_skate_state{
12 enum skate_activity{
13 k_skate_activity_air,
14 k_skate_activity_air_to_grind,
15 k_skate_activity_ground,
16 k_skate_activity_undefined,
17 k_skate_activity_grind_any,
18 k_skate_activity_grind_boardslide,
19 k_skate_activity_grind_metallic,
20 k_skate_activity_grind_back50,
21 k_skate_activity_grind_front50,
22 k_skate_activity_grind_5050
23 }
24 activity,
25 activity_prev;
26
27 u32 grind_cooldown,
28 surface_cooldown;
29
30 f32 reverse, slip, delayed_slip_dir;
31 int manual_direction;
32
33 /* tricks */
34 v3f flip_axis;
35 float flip_time,
36 flip_rate;
37
38 v3f trick_vel, /* measured in units of TAU/s */
39 trick_euler; /* measured in units of TAU */
40 v3f trick_residualv, /* spring */
41 trick_residuald;
42
43 float trick_time;
44 enum trick_type{
45 k_trick_type_none,
46 k_trick_type_kickflip,
47 k_trick_type_shuvit,
48 k_trick_type_treflip
49 }
50 trick_type;
51 float gravity_bias;
52
53 v3f up_dir;
54 v3f head_position;
55
56 v3f throw_v;
57 v3f cog_v, cog;
58
59 float grabbing;
60 v2f grab_mouse_delta;
61
62 int charging_jump, jump_dir;
63 float jump_charge,
64 slap;
65
66 double jump_time;
67 double start_push,
68 cur_push;
69
70 v3f prev_pos;
71
72 /* initial launch conditions */
73 double air_start;
74 v3f air_init_v,
75 air_init_co;
76
77 float land_dist;
78 v3f land_normal;
79 v4f smoothed_rotation;
80 }
81 state;
82
83 struct player_skate_animator {
84 v3f root_co;
85 v4f root_q;
86
87 v3f offset,
88 local_cog;
89
90 f32 slide,
91 z,
92 x,
93 fly,
94 grind,
95 grind_balance,
96 stand,
97 push,
98 jump,
99 airdir,
100 weight,
101 trick_foot,
102 slap,
103 subslap,
104 reverse,
105 delayed_slip_dir,
106 grabbing;
107
108 v2f wobble;
109 f32 foot_offset[2];
110
111 v4f qfixuptotal;
112 v4f qflip;
113
114 v3f board_euler;
115 f32 board_lean;
116 v2f steer, grab;
117
118 f32 jump_charge;
119
120 /* linear anims */
121 f32 push_time, jump_time;
122 u8 jump_dir;
123 u8 trick_type;
124 }
125 animator;
126
127 /* animation /audio
128 * --------------------------------------------------------------*/
129 struct skeleton_anim *anim_stand, *anim_highg, *anim_slide,
130 *anim_air, *anim_grind, *anim_grind_jump,
131 *anim_push, *anim_push_reverse,
132 *anim_ollie, *anim_ollie_reverse,
133 *anim_grabs, *anim_stop;
134
135 /* vectors representing the direction of the axels in localspace */
136 v3f truckv0[2];
137
138 audio_channel *aud_main, *aud_slide, *aud_air;
139 enum mdl_surface_prop surface, audio_surface;
140
141 int wheel_contacts[2];
142 float sample_change_cooldown;
143
144 enum {
145 k_skate_sample_concrete,
146 k_skate_sample_wood,
147 k_skate_sample_concrete_scrape_metal,
148 k_skate_sample_concrete_scrape_wood,
149 k_skate_sample_metal_scrape_generic
150 }
151 main_sample_type;
152
153 /*
154 * Physics
155 * ----------------------------------------------------
156 */
157
158 float substep, substep_delta;
159
160 struct jump_info{
161 v3f log[50];
162 v3f n;
163 v3f apex;
164 v3f v;
165
166 float gravity;
167
168 int log_length;
169 float score,
170 land_dist;
171
172 enum prediction_type{
173 k_prediction_none,
174 k_prediction_unset,
175 k_prediction_land,
176 k_prediction_grind
177 }
178 type;
179
180 u32 colour;
181 }
182 possible_jumps[36];
183 u32 possible_jump_count;
184
185 v3f surface_picture,
186 weight_distribution,
187 grind_vec,
188 grind_dir;
189
190 float grind_strength;
191 struct grind_limit{
192 v3f ra, n;
193 float p;
194 }
195 limits[3];
196 u32 limit_count;
197 };
198
199 struct player_skate_animator_q {
200 v3f root_co;
201 v4f root_q;
202
203 i8 offset[3];
204 i8 local_cog[3];
205 i8 slide,
206 z,
207 x,
208 fly,
209 grind,
210 grind_balance,
211 stand,
212 push,
213 jump,
214 airdir,
215 weight,
216 trick_foot,
217 slap,
218 subslap,
219 reverse,
220 delayed_slip_dir,
221 grabbing;
222
223 i8 wobble[2];
224 i8 foot_offset[2];
225
226 i16 qfixuptotal[4];
227 i16 qflip;
228
229 i16 board_euler[3];
230 i8 steer[2], grab[2];
231
232 u8 jump_charge;
233
234 /* linear anims */
235 i8 push_time, jump_time;
236 u8 jump_dir;
237 u8 trick_type;
238 }
239 animator;
240
241 VG_STATIC float
242 k_friction_lat = 12.0f,
243 k_friction_resistance = 0.01f,
244
245 k_max_push_speed = 16.0f,
246 k_push_accel = 10.0f,
247 k_push_cycle_rate = 8.0f,
248
249 k_steer_ground = 2.5f,
250 k_steer_air = 3.6f,
251
252 k_jump_charge_speed = (1.0f/0.4f),
253 k_jump_force = 5.0f,
254
255 k_cog_spring = 0.2f,
256 k_cog_damp = 0.02f,
257 k_cog_mass_ratio = 0.9f,
258
259 k_mmthrow_steer = 1.0f,
260 k_mmthrow_scale = 6.0f,
261 k_mmcollect_lat = 2.0f,
262 k_mmcollect_vert = 0.0f,
263 k_mmdecay = 12.0f,
264 k_spring_angular = 1.0f,
265
266 k_spring_force = 300.0f,
267 k_spring_dampener = 5.0f,
268
269 k_grind_spring = 50.0f,
270 k_grind_aligment = 10.0f,
271 k_grind_dampener = 5.0f,
272
273 k_surface_spring = 100.0f,
274 k_surface_dampener = 40.0f,
275 k_manul_spring = 200.0f,
276 k_manul_dampener = 30.0f,
277 k_board_interia = 8.0f,
278
279 k_grind_decayxy = 30.0f,
280 k_grind_axel_min_vel = 1.0f,
281 k_grind_axel_max_angle = 0.95f, /* cosine(|a|) */
282 k_grind_axel_max_vangle = 0.4f,
283 k_grind_max_friction = 3.0f,
284 k_grind_max_edge_angle = 0.97f,
285
286 k_board_length = 0.45f,
287 k_board_width = 0.13f,
288 k_board_end_radius = 0.1f,
289 k_board_radius = 0.14f, /* 0.07 */
290
291 k_grind_balance = -40.0f;
292
293 VG_STATIC void player__skate_register(void)
294 {
295 VG_VAR_F32( k_grind_dampener, flags=VG_VAR_CHEAT );
296 VG_VAR_F32( k_grind_spring, flags=VG_VAR_CHEAT );
297 VG_VAR_F32( k_grind_aligment, flags=VG_VAR_CHEAT );
298 VG_VAR_F32( k_surface_spring, flags=VG_VAR_CHEAT );
299 VG_VAR_F32( k_surface_dampener, flags=VG_VAR_CHEAT );
300 VG_VAR_F32( k_board_interia, flags=VG_VAR_CHEAT );
301 VG_VAR_F32( k_grind_decayxy, flags=VG_VAR_CHEAT );
302 VG_VAR_F32( k_grind_axel_min_vel, flags=VG_VAR_CHEAT );
303 VG_VAR_F32( k_grind_axel_max_angle, flags=VG_VAR_CHEAT );
304 VG_VAR_F32( k_grind_max_friction, flags=VG_VAR_CHEAT );
305 VG_VAR_F32( k_grind_balance, flags=VG_VAR_CHEAT );
306 VG_VAR_F32( k_friction_lat, flags=VG_VAR_CHEAT );
307
308 VG_VAR_F32( k_cog_spring, flags=VG_VAR_CHEAT );
309 VG_VAR_F32( k_cog_damp, flags=VG_VAR_CHEAT );
310 VG_VAR_F32( k_cog_mass_ratio, flags=VG_VAR_CHEAT );
311
312 VG_VAR_F32( k_spring_force, flags=VG_VAR_CHEAT );
313 VG_VAR_F32( k_spring_dampener, flags=VG_VAR_CHEAT );
314 VG_VAR_F32( k_spring_angular, flags=VG_VAR_CHEAT );
315
316 VG_VAR_F32( k_mmthrow_scale, flags=VG_VAR_CHEAT );
317 VG_VAR_F32( k_mmcollect_lat, flags=VG_VAR_CHEAT );
318 VG_VAR_F32( k_mmcollect_vert, flags=VG_VAR_CHEAT );
319 VG_VAR_F32( k_mmdecay, flags=VG_VAR_CHEAT );
320 VG_VAR_F32( k_mmthrow_steer, flags=VG_VAR_CHEAT );
321 }
322
323 VG_STATIC void player__skate_bind ( player_instance *player );
324 VG_STATIC void player__skate_pre_update ( player_instance *player );
325 VG_STATIC void player__skate_update ( player_instance *player );
326 VG_STATIC void player__skate_post_update ( player_instance *player );
327 VG_STATIC void player__skate_im_gui ( player_instance *player );
328 VG_STATIC void player__skate_animate ( player_instance *player );
329 VG_STATIC void player__skate_pose( player_instance *player, player_pose *pose );
330 VG_STATIC void player__skate_post_animate ( player_instance *player );
331 VG_STATIC void player__skate_reset ( player_instance *player,
332 ent_spawn *rp );
333
334 VG_STATIC void player__skate_clear_mechanics( player_instance *player );
335 VG_STATIC void player__skate_reset_animator( player_instance *player );
336 VG_STATIC void player__approximate_best_trajectory( player_instance *player );
337
338 #endif /* PLAYER_SKATE_H */