adjust walkout anim length & masked anim blending
[carveJwlIkooP6JGAAIwe30JlM.git] / player_walk.c
index eacdeeb2f4634ced916fd6528df10f0c0cba80c5..449b99e3a03bff9e0b63466123bcc2c5be4506c5 100644 (file)
@@ -932,7 +932,7 @@ enum walk_transition_type {
 static void player_walk_pose_transition( 
       struct player_walk_animator *animator, struct skeleton_anim *anim,
       enum walk_transition_type type,
-      mdl_keyframe apose[32], player_pose *pose ){
+      mdl_keyframe apose[32], f32 *mask, player_pose *pose ){
 
    mdl_keyframe bpose[32];
 
@@ -961,7 +961,12 @@ static void player_walk_pose_transition(
    q_mul( kf_board->q, qyaw, kf_board->q );
    q_normalize( kf_board->q );
 
-   skeleton_lerp_pose( sk, apose, bpose, blend, pose->keyframes );
+   if( mask ){
+      for( i32 i=0; i<sk->bone_count-1; i ++ )
+         keyframe_lerp( apose+i, bpose+i, blend*mask[i], pose->keyframes+i );
+   }
+   else
+      skeleton_lerp_pose( sk, apose, bpose, blend, pose->keyframes );
 }
 
 static void player__walk_pose( void *_animator, player_pose *pose ){
@@ -1018,19 +1023,42 @@ static void player__walk_pose( void *_animator, player_pose *pose ){
    }
    else if( animator->activity == k_walk_activity_odrop_in ){
       player_walk_pose_transition( 
-            animator, w->anim_drop_in, k_walk_transition_out, apose, pose );
+            animator, w->anim_drop_in, k_walk_transition_out, apose, 
+            NULL, pose );
    }
    else if( animator->activity == k_walk_activity_oair ){
       player_walk_pose_transition(
-            animator, w->anim_jump_to_air, k_walk_transition_out, apose, pose );
+            animator, w->anim_jump_to_air, k_walk_transition_out, apose, 
+            NULL, pose );
    }
    else if( animator->activity == k_walk_activity_oregular ){
       player_walk_pose_transition( 
-            animator, w->anim_intro, k_walk_transition_out, apose, pose );
+            animator, w->anim_intro, k_walk_transition_out, apose, 
+            NULL, pose );
    }
    else if( animator->activity == k_walk_activity_ipopoff ){
-      player_walk_pose_transition( 
-            animator, w->anim_popoff, k_walk_transition_in, apose, pose );
+
+      if( animator->run > 0.2f ){
+         f32 t = 1.0f-vg_minf( animator->run-0.2f, 1.0f ),
+             mask[ 32 ];
+
+         for( u32 i=0; i<32; i ++ ) 
+            mask[i] = 1.0f;
+
+         mask[ localplayer.id_ik_foot_l-1 ] = t;
+         mask[ localplayer.id_ik_foot_r-1 ] = t;
+         mask[ localplayer.id_ik_knee_l-1 ] = t;
+         mask[ localplayer.id_ik_knee_r-1 ] = t;
+         mask[ localplayer.id_hip-1 ] = t;
+         player_walk_pose_transition( 
+               animator, w->anim_popoff, k_walk_transition_in, apose,
+               mask, pose );
+      }
+      else{
+         player_walk_pose_transition( 
+               animator, w->anim_popoff, k_walk_transition_in, apose,
+               NULL, pose );
+      }
    }
    else {
       skeleton_copy_pose( sk, apose, pose->keyframes );