seperate gamestate and animator memory (BREAKS: SMOOTHED UPPER YAW)
[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 v2f steer, grab;
116
117 f32 jump_charge;
118
119 /* linear anims */
120 f32 push_time, jump_time;
121 u8 jump_dir;
122 u8 trick_type;
123 }
124 animator;
125
126 /* animation /audio
127 * --------------------------------------------------------------*/
128 struct skeleton_anim *anim_stand, *anim_highg, *anim_slide,
129 *anim_air, *anim_grind, *anim_grind_jump,
130 *anim_push, *anim_push_reverse,
131 *anim_ollie, *anim_ollie_reverse,
132 *anim_grabs, *anim_stop;
133
134 /* vectors representing the direction of the axels in localspace */
135 v3f truckv0[2];
136
137 audio_channel *aud_main, *aud_slide, *aud_air;
138 enum mdl_surface_prop surface, audio_surface;
139
140 int wheel_contacts[2];
141 float sample_change_cooldown;
142
143 enum {
144 k_skate_sample_concrete,
145 k_skate_sample_wood,
146 k_skate_sample_concrete_scrape_metal,
147 k_skate_sample_concrete_scrape_wood,
148 k_skate_sample_metal_scrape_generic
149 }
150 main_sample_type;
151
152 /*
153 * Physics
154 * ----------------------------------------------------
155 */
156
157 float substep, substep_delta;
158
159 struct jump_info{
160 v3f log[50];
161 v3f n;
162 v3f apex;
163 v3f v;
164
165 float gravity;
166
167 int log_length;
168 float score,
169 land_dist;
170
171 enum prediction_type{
172 k_prediction_none,
173 k_prediction_unset,
174 k_prediction_land,
175 k_prediction_grind
176 }
177 type;
178
179 u32 colour;
180 }
181 possible_jumps[36];
182 u32 possible_jump_count;
183
184 v3f surface_picture,
185 weight_distribution,
186 grind_vec,
187 grind_dir;
188
189 float grind_strength;
190 struct grind_limit{
191 v3f ra, n;
192 float p;
193 }
194 limits[3];
195 u32 limit_count;
196 };
197
198 struct player_skate_animator_q {
199 v3f root_co;
200 v4f root_q;
201
202 i8 offset[3];
203 i8 local_cog[3];
204 i8 slide,
205 z,
206 x,
207 fly,
208 grind,
209 grind_balance,
210 stand,
211 push,
212 jump,
213 airdir,
214 weight,
215 trick_foot,
216 slap,
217 subslap,
218 reverse,
219 delayed_slip_dir,
220 grabbing;
221
222 i8 wobble[2];
223 i8 foot_offset[2];
224
225 i16 qfixuptotal[4];
226 i16 qflip;
227
228 i16 board_euler[3];
229 i8 steer[2], grab[2];
230
231 u8 jump_charge;
232
233 /* linear anims */
234 i8 push_time, jump_time;
235 u8 jump_dir;
236 u8 trick_type;
237 }
238 animator;
239
240 VG_STATIC float
241 k_friction_lat = 12.0f,
242 k_friction_resistance = 0.01f,
243
244 k_max_push_speed = 16.0f,
245 k_push_accel = 10.0f,
246 k_push_cycle_rate = 8.0f,
247
248 k_steer_ground = 2.5f,
249 k_steer_air = 3.6f,
250
251 k_jump_charge_speed = (1.0f/0.4f),
252 k_jump_force = 5.0f,
253
254 k_cog_spring = 0.2f,
255 k_cog_damp = 0.02f,
256 k_cog_mass_ratio = 0.9f,
257
258 k_mmthrow_steer = 1.0f,
259 k_mmthrow_scale = 6.0f,
260 k_mmcollect_lat = 2.0f,
261 k_mmcollect_vert = 0.0f,
262 k_mmdecay = 12.0f,
263 k_spring_angular = 1.0f,
264
265 k_spring_force = 300.0f,
266 k_spring_dampener = 5.0f,
267
268 k_grind_spring = 50.0f,
269 k_grind_aligment = 10.0f,
270 k_grind_dampener = 5.0f,
271
272 k_surface_spring = 100.0f,
273 k_surface_dampener = 40.0f,
274 k_manul_spring = 200.0f,
275 k_manul_dampener = 30.0f,
276 k_board_interia = 8.0f,
277
278 k_grind_decayxy = 30.0f,
279 k_grind_axel_min_vel = 1.0f,
280 k_grind_axel_max_angle = 0.95f, /* cosine(|a|) */
281 k_grind_axel_max_vangle = 0.4f,
282 k_grind_max_friction = 3.0f,
283 k_grind_max_edge_angle = 0.97f,
284
285 k_board_length = 0.45f,
286 k_board_width = 0.13f,
287 k_board_end_radius = 0.1f,
288 k_board_radius = 0.14f, /* 0.07 */
289
290 k_grind_balance = -40.0f;
291
292 VG_STATIC void player__skate_register(void)
293 {
294 VG_VAR_F32( k_grind_dampener, flags=VG_VAR_CHEAT );
295 VG_VAR_F32( k_grind_spring, flags=VG_VAR_CHEAT );
296 VG_VAR_F32( k_grind_aligment, flags=VG_VAR_CHEAT );
297 VG_VAR_F32( k_surface_spring, flags=VG_VAR_CHEAT );
298 VG_VAR_F32( k_surface_dampener, flags=VG_VAR_CHEAT );
299 VG_VAR_F32( k_board_interia, flags=VG_VAR_CHEAT );
300 VG_VAR_F32( k_grind_decayxy, flags=VG_VAR_CHEAT );
301 VG_VAR_F32( k_grind_axel_min_vel, flags=VG_VAR_CHEAT );
302 VG_VAR_F32( k_grind_axel_max_angle, flags=VG_VAR_CHEAT );
303 VG_VAR_F32( k_grind_max_friction, flags=VG_VAR_CHEAT );
304 VG_VAR_F32( k_grind_balance, flags=VG_VAR_CHEAT );
305 VG_VAR_F32( k_friction_lat, flags=VG_VAR_CHEAT );
306
307 VG_VAR_F32( k_cog_spring, flags=VG_VAR_CHEAT );
308 VG_VAR_F32( k_cog_damp, flags=VG_VAR_CHEAT );
309 VG_VAR_F32( k_cog_mass_ratio, flags=VG_VAR_CHEAT );
310
311 VG_VAR_F32( k_spring_force, flags=VG_VAR_CHEAT );
312 VG_VAR_F32( k_spring_dampener, flags=VG_VAR_CHEAT );
313 VG_VAR_F32( k_spring_angular, flags=VG_VAR_CHEAT );
314
315 VG_VAR_F32( k_mmthrow_scale, flags=VG_VAR_CHEAT );
316 VG_VAR_F32( k_mmcollect_lat, flags=VG_VAR_CHEAT );
317 VG_VAR_F32( k_mmcollect_vert, flags=VG_VAR_CHEAT );
318 VG_VAR_F32( k_mmdecay, flags=VG_VAR_CHEAT );
319 VG_VAR_F32( k_mmthrow_steer, flags=VG_VAR_CHEAT );
320 }
321
322 VG_STATIC void player__skate_bind ( player_instance *player );
323 VG_STATIC void player__skate_pre_update ( player_instance *player );
324 VG_STATIC void player__skate_update ( player_instance *player );
325 VG_STATIC void player__skate_post_update ( player_instance *player );
326 VG_STATIC void player__skate_im_gui ( player_instance *player );
327 VG_STATIC void player__skate_animate ( player_instance *player );
328 VG_STATIC void player__skate_pose ( player_instance *player );
329 VG_STATIC void player__skate_post_animate ( player_instance *player );
330 VG_STATIC void player__skate_reset ( player_instance *player,
331 ent_spawn *rp );
332
333 VG_STATIC void player__skate_clear_mechanics( player_instance *player );
334 VG_STATIC void player__skate_reset_animator( player_instance *player );
335 VG_STATIC void player__approximate_best_trajectory( player_instance *player );
336
337 #endif /* PLAYER_SKATE_H */