X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=player_skate.c;h=7da738ef6419013c0bff9dc460d94abc9bb62d47;hb=cd953da74e652bc1a4d598448f68f35df152175e;hp=fcaffd9e9466b550b1977e44e09c3776bef10e2a;hpb=35b57a341eb37d863ec69e4f011a88b7bfba5c01;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/player_skate.c b/player_skate.c index fcaffd9..7da738e 100644 --- a/player_skate.c +++ b/player_skate.c @@ -2855,25 +2855,19 @@ VG_STATIC void player__skate_animate( player_instance *player ){ /* counter-rotation */ if( v3_length2( s->state.up_dir ) > 0.001f ){ - if( v4_length(s->state.smoothed_rotation) <= 0.1f || - v4_length(s->state.smoothed_rotation) >= 1.1f ){ - vg_warn( "FIX THIS! CARROT\n" ); /* this never happens anymore? */ - v4_copy( player->rb.q, s->state.smoothed_rotation ); - } v4_lerp( s->state.smoothed_rotation, player->rb.q, 2.0f*vg.time_frame_delta, s->state.smoothed_rotation ); q_normalize( s->state.smoothed_rotation ); - v3f yaw_ref = {1.0f,0.0f,0.0f}, - yaw_smooth = {1.0f,0.0f,0.0f}; - q_mulv( player->rb.q, yaw_ref, yaw_ref ); + v3f yaw_smooth = {1.0f,0.0f,0.0f}; q_mulv( s->state.smoothed_rotation, yaw_smooth, yaw_smooth ); m3x3_mulv( player->rb.to_local, yaw_smooth, yaw_smooth ); - m3x3_mulv( player->rb.to_local, yaw_ref, yaw_ref ); + yaw_smooth[1] = 0.0f; + v3_normalize( yaw_smooth ); - f32 yaw_counter_rotate = v3_dot(yaw_ref,yaw_smooth); - yaw_counter_rotate = vg_clampf(yaw_counter_rotate,-0.7f,0.7f); + f32 yaw_counter_rotate = yaw_smooth[0]; + yaw_counter_rotate = vg_maxf( 0.7f, yaw_counter_rotate ); yaw_counter_rotate = acosf( yaw_counter_rotate ); yaw_counter_rotate *= 1.0f-animator->fly; @@ -2882,7 +2876,6 @@ VG_STATIC void player__skate_animate( player_instance *player ){ v3_normalize( ndir ); v3f up = { 0.0f, 1.0f, 0.0f }; - float a = v3_dot( ndir, up ); a = acosf( vg_clampf( a, -1.0f, 1.0f ) ); @@ -2890,9 +2883,11 @@ VG_STATIC void player__skate_animate( player_instance *player ){ v4f qcounteryaw, qfixup; v3_cross( up, ndir, axis ); - q_axis_angle( qfixup, axis, a ); + q_axis_angle( qfixup, axis, a*2.0f ); + + v3_cross( (v3f){1.0f,0.0f,0.0f}, yaw_smooth, axis ); + q_axis_angle( qcounteryaw, axis, yaw_counter_rotate ); - q_axis_angle( qcounteryaw, (v3f){0.0f,1.0f,0.0f}, yaw_counter_rotate ); q_mul( qcounteryaw, qfixup, animator->qfixuptotal ); q_normalize( animator->qfixuptotal ); @@ -2900,11 +2895,10 @@ VG_STATIC void player__skate_animate( player_instance *player ){ m3x3_mulv( player->rb.to_world, up, p1 ); m3x3_mulv( player->rb.to_world, ndir, p2 ); - vg_line_arrow( player->rb.co, p1, 0.25f, VG__PINK ); - vg_line_arrow( player->rb.co, p2, 0.25f, VG__PINK ); + vg_line_arrow( player->rb.co, p1, 0.5f, VG__PINK ); + vg_line_arrow( player->rb.co, p2, 0.5f, VG__PINK ); } else q_identity( animator->qfixuptotal ); - q_identity( animator->qfixuptotal ); rb_extrapolate( &player->rb, animator->root_co, animator->root_q ); } @@ -3064,14 +3058,19 @@ VG_STATIC void player__skate_pose( player_instance *player, player_pose *pose ){ if( animator->trick_type == k_trick_type_kickflip ){ kf_foot_l->co[0] += animator->trick_foot * 0.2f; + kf_foot_l->co[1] -= animator->trick_foot * 0.18f; } else if( animator->trick_type == k_trick_type_shuvit ){ kf_foot_l->co[0] += animator->trick_foot * 0.1f; kf_foot_r->co[0] -= animator->trick_foot * 0.15f; + kf_foot_l->co[1] -= animator->trick_foot * 0.18f; + kf_foot_r->co[1] -= animator->trick_foot * 0.18f; } else if( animator->trick_type == k_trick_type_treflip ){ kf_foot_l->co[0] += animator->trick_foot * 0.2f; kf_foot_r->co[0] -= animator->trick_foot * 0.15f; + kf_foot_l->co[1] -= animator->trick_foot * 0.18f; + kf_foot_r->co[1] -= animator->trick_foot * 0.18f; } /* @@ -3092,6 +3091,7 @@ VG_STATIC void player__skate_pose( player_instance *player, player_pose *pose ){ q_normalize( kf_wheels[i]->q ); } +#if 0 { mdl_keyframe *kf_head = &pose->keyframes[av->id_head-1], @@ -3122,6 +3122,7 @@ VG_STATIC void player__skate_pose( player_instance *player, player_pose *pose ){ q_mul( qrot, kf_head->q, kf_head->q ); q_normalize( kf_head->q ); } +#endif } VG_STATIC void player__skate_post_animate( player_instance *player )