residue
[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 float reverse,
28 slip;
29
30 int manual_direction;
31
32 /* tricks */
33 v3f flip_axis;
34 float flip_time,
35 flip_rate;
36
37 v3f trick_vel, /* measured in units of TAU/s */
38 trick_euler; /* measured in units of TAU */
39 float trick_time;
40 float gravity_bias;
41
42 v3f up_dir;
43 v3f head_position;
44
45 v3f throw_v;
46 v3f cog_v, cog;
47
48 float grabbing;
49 v2f grab_mouse_delta;
50
51 int charging_jump, jump_dir;
52 float jump_charge,
53 slap;
54
55 double jump_time;
56 double start_push,
57 cur_push;
58
59 v3f prev_pos;
60
61 /* initial launch conditions */
62 double air_start;
63 v3f air_init_v,
64 air_init_co;
65
66 v4f smoothed_rotation;
67 }
68 state,
69 state_gate_storage;
70
71 /* animation /audio */
72 struct skeleton_anim *anim_stand, *anim_highg, *anim_slide,
73 *anim_air, *anim_grind, *anim_grind_jump,
74 *anim_push, *anim_push_reverse,
75 *anim_ollie, *anim_ollie_reverse,
76 *anim_grabs, *anim_stop;
77 v3f
78 board_trick_residualv,
79 board_trick_residuald;
80
81 float blend_slide,
82 blend_z,
83 blend_x,
84 blend_fly,
85 blend_grind,
86 blend_grind_balance,
87 blend_stand,
88 blend_push,
89 blend_jump,
90 blend_airdir,
91 blend_weight,
92 subslap;
93
94 /* vectors representing the direction of the axels in localspace */
95 v3f truckv0[2];
96 v2f wobble;
97
98 audio_channel *aud_main, *aud_slide, *aud_air;
99 enum mdl_surface_prop surface, audio_surface;
100
101 int wheel_contacts[2];
102 float sample_change_cooldown;
103
104 enum {
105 k_skate_sample_concrete,
106 k_skate_sample_wood,
107 k_skate_sample_concrete_scrape_metal,
108 k_skate_sample_concrete_scrape_wood,
109 k_skate_sample_metal_scrape_generic
110 }
111 main_sample_type;
112
113 player_pose holdout;
114
115 /*
116 * Physics
117 * ----------------------------------------------------
118 */
119
120 float substep,
121 substep_delta;
122
123 struct jump_info{
124 v3f log[50];
125 v3f n;
126 v3f apex;
127 v3f v;
128
129 float gravity;
130
131 int log_length;
132 float score,
133 land_dist;
134
135 enum prediction_type{
136 k_prediction_none,
137 k_prediction_unset,
138 k_prediction_land,
139 k_prediction_grind
140 }
141 type;
142
143 u32 colour;
144 }
145 possible_jumps[36];
146 u32 possible_jump_count;
147
148 float land_dist;
149 v3f land_normal;
150
151 v3f surface_picture,
152 weight_distribution,
153 grind_vec,
154 grind_dir;
155
156 u32 grind_cooldown,
157 surface_cooldown;
158
159 float grind_strength;
160
161 struct grind_limit{
162 v3f ra, n;
163 float p;
164 }
165 limits[3];
166 u32 limit_count;
167 };
168
169 VG_STATIC float
170 k_friction_lat = 12.0f,
171 k_friction_resistance = 0.01f,
172
173 k_max_push_speed = 16.0f,
174 k_push_accel = 10.0f,
175 k_push_cycle_rate = 8.0f,
176
177 k_steer_ground = 2.5f,
178 k_steer_air = 3.6f,
179
180 k_jump_charge_speed = (1.0f/0.4f),
181 k_jump_force = 5.0f,
182
183 k_cog_spring = 0.2f,
184 k_cog_damp = 0.02f,
185 k_cog_mass_ratio = 0.9f,
186
187 k_mmthrow_scale = 6.0f,
188 k_mmcollect_lat = 2.0f,
189 k_mmcollect_vert = 0.0f,
190 k_mmdecay = 12.0f,
191 k_spring_angular = 1.0f,
192
193 k_spring_force = 300.0f,
194 k_spring_dampener = 5.0f,
195
196 k_grind_spring = 50.0f,
197 k_grind_aligment = 10.0f,
198 k_grind_dampener = 5.0f,
199
200 k_surface_spring = 100.0f,
201 k_surface_dampener = 40.0f,
202 k_manul_spring = 200.0f,
203 k_manul_dampener = 30.0f,
204 k_board_interia = 8.0f,
205
206 k_grind_decayxy = 30.0f,
207 k_grind_axel_min_vel = 1.0f,
208 k_grind_axel_max_angle = 0.95f, /* cosine(|a|) */
209 k_grind_axel_max_vangle = 0.4f,
210 k_grind_max_friction = 3.0f,
211 k_grind_max_edge_angle = 0.97f,
212
213 k_board_length = 0.45f,
214 k_board_width = 0.13f,
215 k_board_end_radius = 0.1f,
216 k_board_radius = 0.14f, /* 0.07 */
217
218 k_grind_balance = -40.0f;
219
220 VG_STATIC void player__skate_register(void)
221 {
222 VG_VAR_F32( k_grind_dampener, flags=VG_VAR_CHEAT );
223 VG_VAR_F32( k_grind_spring, flags=VG_VAR_CHEAT );
224 VG_VAR_F32( k_grind_aligment, flags=VG_VAR_CHEAT );
225 VG_VAR_F32( k_surface_spring, flags=VG_VAR_CHEAT );
226 VG_VAR_F32( k_surface_dampener, flags=VG_VAR_CHEAT );
227 VG_VAR_F32( k_board_interia, flags=VG_VAR_CHEAT );
228 VG_VAR_F32( k_grind_decayxy, flags=VG_VAR_CHEAT );
229 VG_VAR_F32( k_grind_axel_min_vel, flags=VG_VAR_CHEAT );
230 VG_VAR_F32( k_grind_axel_max_angle, flags=VG_VAR_CHEAT );
231 VG_VAR_F32( k_grind_max_friction, flags=VG_VAR_CHEAT );
232 VG_VAR_F32( k_grind_balance, flags=VG_VAR_CHEAT );
233 VG_VAR_F32( k_friction_lat, flags=VG_VAR_CHEAT );
234
235 VG_VAR_F32( k_cog_spring, flags=VG_VAR_CHEAT );
236 VG_VAR_F32( k_cog_damp, flags=VG_VAR_CHEAT );
237 VG_VAR_F32( k_cog_mass_ratio, flags=VG_VAR_CHEAT );
238
239 VG_VAR_F32( k_spring_force, flags=VG_VAR_CHEAT );
240 VG_VAR_F32( k_spring_dampener, flags=VG_VAR_CHEAT );
241 VG_VAR_F32( k_spring_angular, flags=VG_VAR_CHEAT );
242
243 VG_VAR_F32( k_mmthrow_scale, flags=VG_VAR_CHEAT );
244 VG_VAR_F32( k_mmcollect_lat, flags=VG_VAR_CHEAT );
245 VG_VAR_F32( k_mmcollect_vert, flags=VG_VAR_CHEAT );
246 VG_VAR_F32( k_mmdecay, flags=VG_VAR_CHEAT );
247 }
248
249 VG_STATIC void player__skate_bind ( player_instance *player );
250 VG_STATIC void player__skate_pre_update ( player_instance *player );
251 VG_STATIC void player__skate_update ( player_instance *player );
252 VG_STATIC void player__skate_post_update ( player_instance *player );
253 VG_STATIC void player__skate_im_gui ( player_instance *player );
254 VG_STATIC void player__skate_animate ( player_instance *player,
255 player_animation *anim );
256 VG_STATIC void player__skate_post_animate ( player_instance *player );
257 VG_STATIC void player__skate_reset ( player_instance *player,
258 ent_spawn *rp );
259 VG_STATIC void player__skate_restore( player_instance *player );
260
261 VG_STATIC void player__skate_clear_mechanics( player_instance *player );
262 VG_STATIC void player__skate_reset_animator( player_instance *player );
263 VG_STATIC void player__approximate_best_trajectory( player_instance *player );
264 #endif /* PLAYER_SKATE_H */