controls overlay
[carveJwlIkooP6JGAAIwe30JlM.git] / player_skate.h
index 0f99fdbb8d3a87a0c9053e6560fbf90d441fa3c7..abbc7c51c82a2e81b06aac344c23b3cd5120453f 100644 (file)
@@ -1,24 +1,21 @@
-#ifndef PLAYER_SKATE_H
-#define PLAYER_SKATE_H
-
+#pragma once
+#include "vg/vg_audio.h"
+#include "player.h"
 #include "player_api.h"
 
-#define SKATE_CCD
-
 typedef struct jump_info jump_info;
 
-struct player_skate
-{
-   struct
-   {
-      enum skate_activity
-      {
+struct player_skate{
+   struct player_skate_state{
+      enum skate_activity{
          k_skate_activity_air,
          k_skate_activity_air_to_grind,
          k_skate_activity_ground,
+         k_skate_activity_handplant,
          k_skate_activity_undefined,
          k_skate_activity_grind_any,
          k_skate_activity_grind_boardslide,
+         k_skate_activity_grind_metallic,
          k_skate_activity_grind_back50,
          k_skate_activity_grind_front50,
          k_skate_activity_grind_5050
@@ -26,13 +23,10 @@ struct player_skate
       activity,
       activity_prev;
 
-      float /* steery,
-            steerx,
-            steery_s,
-            steerx_s, */
-            reverse,
-            slip;
+      u32 grind_cooldown,
+          surface_cooldown;
 
+      f32 reverse, slip, delayed_slip_dir;
       int manual_direction;
 
       /* tricks */
@@ -42,9 +36,21 @@ struct player_skate
 
       v3f   trick_vel,     /* measured in units of TAU/s */
             trick_euler;   /* measured in units of TAU */
+      v3f trick_residualv, /* spring */
+          trick_residuald;
+
       float trick_time;
+      enum  trick_type{
+         k_trick_type_none,
+         k_trick_type_kickflip,
+         k_trick_type_shuvit,
+         k_trick_type_treflip,
+      }
+      trick_type;
       float gravity_bias;
 
+      f32 trick_input_collect;
+
       v3f up_dir;
       v3f head_position;
 
@@ -69,38 +75,79 @@ struct player_skate
       v3f    air_init_v,
              air_init_co;
 
+      float land_dist;
+      v3f land_normal;
       v4f smoothed_rotation;
+
+      f32 velocity_limit, grind_y_start, skid;
+      f32 handplant_t;
+
+      v3f store_cog_v, store_cog, store_co;
+      v4f store_smoothed, store_q;
+   }
+   state;
+
+   struct player_skate_animator {
+      v3f root_co;
+      v4f root_q;
+      v3f root_v;
+
+      v3f offset,
+          local_cog;
+
+      f32 slide,
+          skid,
+          z,
+          x,
+          fly,
+          grind,
+          grind_balance,
+          stand,
+          push,
+          jump,
+          airdir,
+          weight,
+          trick_foot,
+          slap,
+          subslap,
+          reverse,
+          delayed_slip_dir,
+          grabbing;
+
+      v2f wobble;
+      f32 foot_offset[2];
+
+      v4f qfixuptotal;
+      v4f qflip;
+
+      v3f board_euler;
+      f32 board_lean;
+      v2f steer, grab;
+
+      f32 jump_charge;
+
+      /* linear anims. TODO: we can union a bunch of variables here depending
+       * on activity. */
+      f32 push_time, jump_time, handplant_t;
+      u8 jump_dir;
+      u8 trick_type; /* todo: should encode grind type */
+      u8 activity, surface;
    }
-   state,
-   state_gate_storage;
+   animator;
 
+   f32 collect_feedback;
 
-   /* animation /audio */
+   /* animation /audio
+    * --------------------------------------------------------------*/
    struct skeleton_anim *anim_stand, *anim_highg, *anim_slide,
                         *anim_air, *anim_grind, *anim_grind_jump,
                         *anim_push,  *anim_push_reverse,
                         *anim_ollie, *anim_ollie_reverse,
-                        *anim_grabs, *anim_stop;
-   v3f 
-       board_trick_residualv,
-       board_trick_residuald;
-
-   float blend_slide,
-         blend_z,
-         blend_x,
-         blend_fly,
-         blend_grind,
-         blend_grind_balance,
-         blend_stand,
-         blend_push,
-         blend_jump,
-         blend_airdir,
-         blend_weight,
-         subslap;
+                        *anim_grabs, *anim_stop,
+                        *anim_handplant;
 
    /* vectors representing the direction of the axels in localspace */
    v3f truckv0[2];
-   v2f wobble;
 
    audio_channel *aud_main, *aud_slide, *aud_air;
    enum mdl_surface_prop surface, audio_surface;
@@ -122,11 +169,9 @@ struct player_skate
     * ----------------------------------------------------
     */
 
-   float substep,
-         substep_delta;
+   float substep, substep_delta;
 
-   struct jump_info
-   {
+   struct jump_info{
       v3f   log[50];
       v3f   n;
       v3f   apex;
@@ -138,8 +183,7 @@ struct player_skate
       float score,
             land_dist;
 
-      enum prediction_type
-      {
+      enum prediction_type{
          k_prediction_none,
          k_prediction_unset,
          k_prediction_land,
@@ -152,40 +196,130 @@ struct player_skate
    possible_jumps[36];
    u32 possible_jump_count;
 
-   float land_dist;
-   v3f land_normal;
-
    v3f surface_picture,
        weight_distribution,
        grind_vec,
        grind_dir;
 
-   u32 grind_cooldown,
-       surface_cooldown;
-
    float grind_strength;
-
-   struct grind_limit
-   {
+   struct grind_limit{
       v3f ra, n;
       float p;
    }
    limits[3];
    u32 limit_count;
+}
+extern player_skate;
+extern struct player_subsystem_interface player_subsystem_skate;
+
+enum player_skate_soundeffect {
+   k_player_skate_soundeffect_jump,
+   k_player_skate_soundeffect_tap,
+   k_player_skate_soundeffect_land_good,
+   k_player_skate_soundeffect_land_bad,
+   k_player_skate_soundeffect_grind_metal,
+   k_player_skate_soundeffect_grind_wood,
 };
 
-VG_STATIC void player__skate_bind         ( player_instance *player );
-VG_STATIC void player__skate_pre_update   ( player_instance *player );
-VG_STATIC void player__skate_update       ( player_instance *player );
-VG_STATIC void player__skate_post_update  ( player_instance *player );
-VG_STATIC void player__skate_im_gui       ( player_instance *player );
-VG_STATIC void player__skate_animate      ( player_instance *player,
-                                            player_animation *anim );
-VG_STATIC void player__skate_post_animate ( player_instance *player );
-VG_STATIC void player__skate_reset        ( player_instance *player,
-                                            ent_spawn *rp );
-
-VG_STATIC void player__skate_clear_mechanics( player_instance *player );
-VG_STATIC void player__skate_reset_animator( player_instance *player );
-VG_STATIC void player__approximate_best_trajectory( player_instance *player );
-#endif /* PLAYER_SKATE_H */
+static float 
+   k_friction_lat          = 12.0f,
+   k_friction_resistance   = 0.01f,
+
+   k_max_push_speed        = 16.0f,
+   k_push_accel            = 10.0f,
+   k_push_cycle_rate       = 8.0f,
+
+   k_steer_ground          = 2.5f,
+   k_steer_air             = 3.6f,
+
+   k_jump_charge_speed     = (1.0f/0.4f),
+   k_jump_force            = 5.0f,
+
+   k_cog_spring            = 0.2f,
+   k_cog_damp              = 0.02f,
+   k_cog_mass_ratio        = 0.9f,
+
+   k_mmthrow_steer         = 1.0f,
+   k_mmthrow_scale         = 6.0f,
+   k_mmcollect_lat         = 2.0f,
+   k_mmcollect_vert        = 0.0f,
+   k_mmdecay               = 12.0f,
+   k_spring_angular        = 1.0f,
+
+   k_spring_force          = 300.0f,
+   k_spring_dampener       = 5.0f,
+
+   k_grind_spring          = 50.0f,
+   k_grind_aligment        = 10.0f,
+   k_grind_dampener        = 5.0f,
+
+   k_surface_spring        = 100.0f,
+   k_surface_dampener      = 40.0f,
+   k_manul_spring          = 200.0f,
+   k_manul_dampener        = 30.0f,
+   k_board_interia         = 8.0f,
+
+   k_grind_decayxy         = 30.0f,
+   k_grind_axel_min_vel    = 1.0f,
+   k_grind_axel_max_angle  = 0.95f, /* cosine(|a|) */
+   k_grind_axel_max_vangle = 0.4f,
+   k_grind_max_friction    = 3.0f,
+   k_grind_max_edge_angle  = 0.97f,
+
+   k_board_length          = 0.45f,
+   k_board_width           = 0.13f,
+   k_board_end_radius      = 0.1f,
+   k_board_radius          = 0.14f,    /* 0.07 */
+   
+   k_grind_balance         = -40.0f,
+   k_anim_transition       = 0.12f;
+
+static void player__skate_register(void){
+   VG_VAR_F32( k_grind_dampener,       flags=VG_VAR_CHEAT );
+   VG_VAR_F32( k_grind_spring,         flags=VG_VAR_CHEAT );
+   VG_VAR_F32( k_grind_aligment,       flags=VG_VAR_CHEAT );
+   VG_VAR_F32( k_surface_spring,       flags=VG_VAR_CHEAT );
+   VG_VAR_F32( k_surface_dampener,     flags=VG_VAR_CHEAT );
+   VG_VAR_F32( k_board_interia,        flags=VG_VAR_CHEAT );
+   VG_VAR_F32( k_grind_decayxy,        flags=VG_VAR_CHEAT );
+   VG_VAR_F32( k_grind_axel_min_vel,   flags=VG_VAR_CHEAT );
+   VG_VAR_F32( k_grind_axel_max_angle, flags=VG_VAR_CHEAT );
+   VG_VAR_F32( k_grind_max_friction,   flags=VG_VAR_CHEAT );
+   VG_VAR_F32( k_grind_balance,        flags=VG_VAR_CHEAT );
+   VG_VAR_F32( k_friction_lat,         flags=VG_VAR_CHEAT );
+
+   VG_VAR_F32( k_cog_spring,           flags=VG_VAR_CHEAT );
+   VG_VAR_F32( k_cog_damp,             flags=VG_VAR_CHEAT );
+   VG_VAR_F32( k_cog_mass_ratio,       flags=VG_VAR_CHEAT );
+
+   VG_VAR_F32( k_spring_force,         flags=VG_VAR_CHEAT );
+   VG_VAR_F32( k_spring_dampener,      flags=VG_VAR_CHEAT );
+   VG_VAR_F32( k_spring_angular,       flags=VG_VAR_CHEAT );
+
+   VG_VAR_F32( k_mmthrow_scale,        flags=VG_VAR_CHEAT );
+   VG_VAR_F32( k_mmcollect_lat,        flags=VG_VAR_CHEAT );
+   VG_VAR_F32( k_mmcollect_vert,       flags=VG_VAR_CHEAT );
+   VG_VAR_F32( k_mmdecay,              flags=VG_VAR_CHEAT );
+   VG_VAR_F32( k_mmthrow_steer,        flags=VG_VAR_CHEAT );
+   VG_VAR_F32( k_anim_transition,      flags=VG_VAR_CHEAT );
+}
+
+void player__skate_bind         (void);
+void player__skate_pre_update   (void);
+void player__skate_update       (void);
+void player__skate_post_update  (void);
+void player__skate_im_gui       (void);
+void player__skate_animate      (void);
+void player__skate_pose         (void *animator, player_pose *pose);
+void player__skate_effects( void *_animator, m4x3f *final_mtx,
+                            struct player_board *board,
+                            struct player_effects_data *effect_data );
+void player__skate_post_animate (void);
+void player__skate_animator_exchange( bitpack_ctx *ctx, void *data );
+void player__skate_sfx_oneshot  ( u8 id, v3f pos, f32 volume );
+
+void player__skate_clear_mechanics(void);
+void player__skate_reset_animator(void);
+void player__approximate_best_trajectory(void);
+void player__skate_comp_audio( void *animator );
+void player__skate_kill_audio(void);