animation and transition adjustments
[carveJwlIkooP6JGAAIwe30JlM.git] / player_skate.c
index 708125c632f51679b30121536923f9205c174270..191c708ad1a160340e3040846a34bcbafc21c0b8 100644 (file)
@@ -25,7 +25,7 @@ static void player__skate_bind(void){
       { &player_skate.anim_ollie,        "ollie" },
       { &player_skate.anim_ollie_reverse,"ollie_reverse" },
       { &player_skate.anim_grabs,        "grabs" },
-      { &player_skate.anim_handplant,    "handplant" }
+      { &player_skate.anim_handplant,    "handplant" },
    };
 
    for( u32 i=0; i<vg_list_size(bindings); i++ )
@@ -1150,8 +1150,10 @@ static void player__skate_pre_update(void){
       state->handplant_t += vg.time_delta;
       mdl_keyframe hpose[32];
 
+      struct skeleton_anim *anim = player_skate.anim_handplant;
+
       int end = !skeleton_sample_anim_clamped( 
-               &localplayer.skeleton, player_skate.anim_handplant,
+               &localplayer.skeleton, anim,
                state->handplant_t, hpose );
 
       if( state->reverse < 0.0f )
@@ -1185,6 +1187,7 @@ static void player__skate_pre_update(void){
 
       m3x3_mulv( transfer, state->air_init_v, localplayer.rb.v );
       m3x3_mulv( transfer, state->store_cog_v, state->cog_v );
+
       m4x3_mulv( transfer, state->store_cog, state->cog );
       v3_muladds( state->cog, localplayer.rb.to_world[1], 
                   -state->handplant_t*0.5f, state->cog );
@@ -1201,7 +1204,7 @@ static void player__skate_pre_update(void){
       else return;
    }
 
-   if( button_down( k_srbind_use ) ){
+   if( button_down(k_srbind_use) && (v3_length2(state->trick_vel) < 0.01f) ){
       localplayer.subsystem = k_player_subsystem_walk;
 
       v3f angles;
@@ -1213,10 +1216,13 @@ static void player__skate_pre_update(void){
       v3_add( newpos, (v3f){0.0f,-1.0f,0.0f}, newpos );
       v3_sub( localplayer.rb.co, newpos, offset );
       v3_copy( newpos, localplayer.rb.co );
+      v3_muladds( localplayer.rb.co, localplayer.rb.to_world[1], -0.1f,
+                  localplayer.rb.co );
 
       player__begin_holdout( offset );
       player__skate_kill_audio();
-      player__walk_transition();
+      player__walk_transition( state->activity <= k_skate_activity_air_to_grind?
+                               0: 1, state->trick_euler[0] );
       return;
    }
 
@@ -3206,10 +3212,12 @@ static void player__skate_pose( void *_animator, player_pose *pose ){
    }
 #endif
 
+
    if( animator->activity == k_skate_activity_handplant ){
+      struct skeleton_anim *anim = player_skate.anim_handplant;
+
       mdl_keyframe hpose[32];
-      skeleton_sample_anim_clamped( sk, player_skate.anim_handplant, 
-                                    animator->handplant_t, hpose );
+      skeleton_sample_anim_clamped( sk, anim, animator->handplant_t, hpose );
       if( animator->reverse < 0.0f )
          player_mirror_pose( hpose, hpose );
 
@@ -3235,8 +3243,10 @@ static void player__skate_pose( void *_animator, player_pose *pose ){
       v3_copy( world_view[3], pose->root_co );
 
       f32 t        = animator->handplant_t,
-          frames   = player_skate.anim_handplant->length-1,
-          length   = frames / player_skate.anim_handplant->rate,
+          frames   = anim->length-1,
+          length   = animator->activity == k_skate_activity_handplant?
+                        frames / anim->rate:
+                        999999,
           end_dist = vg_minf( t, length - t )/k_anim_transition,
           blend    = vg_smoothstepf( vg_minf(1,end_dist) );
 
@@ -3244,9 +3254,6 @@ static void player__skate_pose( void *_animator, player_pose *pose ){
    }
 
 
-
-
-
    /* trick rotation */
    v4f qtrick, qyaw, qpitch, qroll;
    q_axis_angle( qyaw,   (v3f){0.0f,1.0f,0.0f}, animator->board_euler[0] );