From: hgn Date: Wed, 8 Nov 2023 07:35:31 +0000 (+0000) Subject: smooth out walk animator drop ins / sitting X-Git-Url: https://harrygodden.com/git/?a=commitdiff_plain;h=54f371130e8cf89999ed9b076b906a7072df8d40;p=carveJwlIkooP6JGAAIwe30JlM.git smooth out walk animator drop ins / sitting --- diff --git a/player_walk.c b/player_walk.c index 7d09f15..193e79a 100644 --- a/player_walk.c +++ b/player_walk.c @@ -10,7 +10,7 @@ static void player_walk_drop_in_vector( v3f vec ){ v3_cross( localplayer.basis[1], player_walk.state.drop_in_normal, axis ); v3_cross( axis, player_walk.state.drop_in_normal, init_dir ); v3_normalize( init_dir ); - v3_muls( init_dir, 7.0f, vec ); + v3_muls( init_dir, 4.25f, vec ); } static float player_xyspeed2(void){ @@ -246,6 +246,40 @@ static void player__walk_pre_update(void){ if( !localplayer.immobile ) player_look( localplayer.angles, skaterift.time_rate ); + v2f steer; + joystick_state( k_srjoystick_steer, steer ); + + if( w->state.activity == k_walk_activity_sit ){ + if( w->state.sit_t < 1.0f ) + w->state.sit_t = vg_minf( 1.0f, w->state.sit_t + vg.time_delta ); + + if( button_down(k_srbind_sit) || (v2_length2(steer)>0.2f) || + button_down(k_srbind_jump) ){ + w->state.activity = k_walk_activity_sit_up; + } + return; + } + else if( w->state.activity == k_walk_activity_sit_up ){ + if( w->state.sit_t > 0.0f ) + w->state.sit_t = vg_maxf( 0.0f, w->state.sit_t - vg.time_delta ); + else + w->state.activity = k_walk_activity_ground; + + if( button_down(k_srbind_sit) ) + w->state.activity = k_walk_activity_sit; + + return; + } + else if( w->state.activity == k_walk_activity_ground ){ + if( button_down(k_srbind_sit) ){ + v3_zero( localplayer.rb.v ); + w->state.activity = k_walk_activity_sit; + return; + } + } + + w->state.sit_t = 0.0f; + if( w->state.outro_type ){ struct skeleton_anim *anim = player_walk_outro_anim(w->state.outro_type); @@ -391,27 +425,10 @@ static void player__walk_update(void){ v2f steer; joystick_state( k_srjoystick_steer, steer ); - if( w->state.activity == k_walk_activity_sit ){ - if( w->state.sit_t < 1.0f ) - w->state.sit_t += vg.time_delta; - else { - w->state.sit_t = 1.0f; - - if( button_down(k_srbind_sit) || (v2_length2(steer)>0.2f) || - button_down(k_srbind_jump) ){ - w->state.activity = k_walk_activity_sit_up; - } - } + if( (w->state.activity == k_walk_activity_sit) || + (w->state.activity == k_walk_activity_sit_up) ){ return; } - else if( w->state.activity == k_walk_activity_sit_up ){ - if( w->state.sit_t > 0.0f ){ - w->state.sit_t -= vg.time_delta; - return; - } - } - else - w->state.sit_t = 0.0f; v3_copy( localplayer.rb.co, w->state.prev_pos ); v3_zero( localplayer.rb.w ); @@ -497,11 +514,6 @@ static void player__walk_update(void){ if( w->state.activity == k_walk_activity_ground ){ v3_normalize( surface_avg ); - if( button_down(k_srbind_sit) ){ - w->state.activity = k_walk_activity_sit; - return; - } - v3f tx, ty; v3_tangent_basis( surface_avg, tx, ty ); @@ -779,12 +791,13 @@ static void player__walk_animate(void){ animator->walk_timer = w->state.walk_timer; - if( !localplayer.immobile ) - rb_extrapolate( &localplayer.rb, animator->root_co, animator->root_q ); - else{ + if( localplayer.immobile || (w->state.outro_type == k_walk_outro_drop_in) ){ v3_copy( localplayer.rb.co, animator->root_co ); v4_copy( localplayer.rb.q, animator->root_q ); } + else{ + rb_extrapolate( &localplayer.rb, animator->root_co, animator->root_q ); + } f32 walk_yaw = player_get_heading_yaw(); @@ -829,6 +842,15 @@ static void player__walk_animate(void){ v3_lerp( w->state.drop_in_start, w->state.drop_in_target, step_t, localplayer.rb.co ); + v3_copy( localplayer.rb.co, animator->root_co ); + + /* for the camera purposes only */ + v3f init_velocity; + player_walk_drop_in_vector( init_velocity ); + v3_muls( init_velocity, dop_t, localplayer.rb.v ); + v3_copy( localplayer.rb.v, + localplayer.cam_control.cam_velocity_smooth ); + q_axis_angle( animator->root_q, (v3f){0.0f,1.0f,0.0f}, walk_yaw + VG_PIf ); @@ -836,15 +858,22 @@ static void player__walk_animate(void){ /* the drop in bit */ if( step_t >= 1.0f ){ + v3f final_co; v4f final_q; - player_walk_drop_in_overhang_transform( dop_t, localplayer.rb.co, - final_q ); + player_walk_drop_in_overhang_transform( dop_t, final_co, final_q ); + q_mul( final_q, animator->root_q, animator->root_q ); + v3_copy( final_co, animator->root_co ); + v4_copy( animator->root_q, localplayer.rb.q ); + rb_update_transform( &localplayer.rb ); + v3_muladds( animator->root_co, localplayer.rb.to_world[1], -0.1f*dop_t, animator->root_co ); + v3_copy( animator->root_co, localplayer.rb.co ); } + return; } else{