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