X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=player_skate.c;h=1ad7231609e2f0dcc2b5abd1a2a94d9e03ce63b8;hb=e311bbe2fa903a7e2a922f202f389b799193195d;hp=63315a80d6830889219717348ff47c5641d9ef96;hpb=6e96ba64e805ea8a39ca46171e28426c6bc86ab6;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/player_skate.c b/player_skate.c index 63315a8..1ad7231 100644 --- a/player_skate.c +++ b/player_skate.c @@ -225,7 +225,7 @@ too_many_samples: v3_copy( sj->normal3, n1 ); v3_cross( n0, n1, dir ); - if( v3_length2( dir ) <= 0.001f ) + if( v3_length2( dir ) <= 0.000001f ) continue; v3_normalize( dir ); @@ -1540,7 +1540,6 @@ static void skate_grind_decay( struct grind_info *inf, float strength ){ static void skate_grind_truck_apply( float sign, struct grind_info *inf, float strength ){ struct player_skate_state *state = &player_skate.state; - /* REFACTOR */ v3f ra = { 0.0f, -k_board_radius, sign * k_board_length }; v3f raw, wsp; @@ -2390,7 +2389,7 @@ begin_collision:; } /* yes, we are currently rebuilding mass matrices every frame. too bad! */ - v3f extent = { k_board_width, 0.1f, k_board_length }; + v3f extent = { k_board_width*10.0f, 0.1f, k_board_length }; float ex2 = k_board_interia*extent[0]*extent[0], ey2 = k_board_interia*extent[1]*extent[1], ez2 = k_board_interia*extent[2]*extent[2]; @@ -2570,6 +2569,27 @@ begin_collision:; } else if( stick_frames == 0 ){ /* TODO: EXIT SOUNDS */ } + + if( (state->activity_prev < k_skate_activity_grind_any) && + (state->activity >= k_skate_activity_grind_any) ){ + state->velocity_limit = v3_length( localplayer.rb.v )*1.0f; + state->grind_y_start = localplayer.rb.co[1]; + } + + if( state->activity >= k_skate_activity_grind_any ){ + f32 dy = localplayer.rb.co[1] - state->grind_y_start; + if( dy < 0.0f ){ + state->velocity_limit += -dy*0.2f; + } + state->grind_y_start = localplayer.rb.co[1]; + + + f32 speed_end = v3_length( localplayer.rb.v ); + if( speed_end > state->velocity_limit ){ + v3_muls( localplayer.rb.v, state->velocity_limit/speed_end, + localplayer.rb.v ); + } + } } static void player__skate_im_gui(void){ @@ -2716,6 +2736,7 @@ static void player__skate_animate(void){ animator->grind_balance = vg_lerpf( animator->grind_balance, grind_frame, 5.0f*vg.time_delta ); + animator->activity = state->activity; /* pushing */ animator->push_time = vg.time - state->start_push; @@ -2872,6 +2893,7 @@ static void player__skate_animate(void){ } else q_identity( animator->qfixuptotal ); rb_extrapolate( &localplayer.rb, animator->root_co, animator->root_q ); + v3_copy( localplayer.rb.v, animator->root_v ); } static void player__skate_pose( void *_animator, player_pose *pose ){ @@ -3097,6 +3119,63 @@ static void player__skate_pose( void *_animator, player_pose *pose ){ } } +static void player__skate_effects( void *_animator, m4x3f *final_mtx, + struct player_board *board, + struct player_effects_data *effect_data ){ + + struct skeleton *sk = &localplayer.skeleton; + struct player_skate_animator *animator = _animator; + + if( animator->grind > 0.5f ){ + v3f vp0, vp1, vpc; + if( board ){ + v3_copy((v3f){0.0f,0.02f, board->truck_positions[0][2]}, vp1 ); + v3_copy((v3f){0.0f,0.02f, board->truck_positions[1][2]}, vp0 ); + } + else{ + v3_zero( vp0 ); + v3_zero( vp1 ); + } + + v3f *board_mtx = final_mtx[ localplayer.id_board ]; + m4x3_mulv( board_mtx, vp0, vp0 ); + m4x3_mulv( board_mtx, vp1, vp1 ); + v3_add( vp0, vp1, vpc ); + v3_muls( vpc, 0.5f, vpc ); + + int back = 0, front = 0, mid = 0; + + if( animator->activity == k_skate_activity_grind_5050 ){ + back = 1; + front = 1; + } + else if( animator->activity == k_skate_activity_grind_back50 ){ + back = 1; + } + else if( animator->activity == k_skate_activity_grind_front50 ){ + front = 1; + } + else if( animator->activity == k_skate_activity_grind_boardslide ){ + mid = 1; + } + + if( back ){ + effect_spark_apply( &effect_data->spark, vp0, + animator->root_v, vg.time_delta ); + } + + if( front ){ + effect_spark_apply( &effect_data->spark, vp1, + animator->root_v, vg.time_delta ); + } + + if( mid ){ + effect_spark_apply( &effect_data->spark, vpc, + animator->root_v, vg.time_delta ); + } + } +} + static void player__skate_post_animate(void){ struct player_skate_state *state = &player_skate.state; localplayer.cam_velocity_influence = 1.0f; @@ -3205,6 +3284,8 @@ static void player__skate_animator_exchange( bitpack_ctx *ctx, void *data ){ bitpack_qf32( ctx, 16, 0.0f, 120.0f, &animator->push_time ); bitpack_qf32( ctx, 16, 0.0f, 120.0f, &animator->jump_time ); + bitpack_qv3f( ctx, 16, -100.0f, 100.0f, animator->root_v ); + bitpack_bytes( ctx, 1, &animator->activity ); } static void player__skate_sfx_oneshot( u8 id, v3f pos, f32 volume ){