X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=player_skate.c;fp=player_skate.c;h=6d9aa924a1cbfc00dcb51bcb2828882c94675884;hb=4c3dc94e7221f599491e7d111cac3d51d8d83b17;hp=779ba7596f5f5126ae102443bdd416d02b4c406c;hpb=9e807cf476f75ff098d940450c0ba39cfb5be7b3;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/player_skate.c b/player_skate.c index 779ba75..6d9aa92 100644 --- a/player_skate.c +++ b/player_skate.c @@ -8,6 +8,8 @@ #include "ent_skateshop.h" #include "addon.h" +#include "ent_tornado.c" + static void player__skate_bind(void){ struct skeleton *sk = &localplayer.skeleton; rb_update_transform( &localplayer.rb ); @@ -403,18 +405,29 @@ static void player__approximate_best_trajectory(void){ inf->gravity = gravity; v3_copy( launch_v, inf->v ); + /* initial conditions */ + v3f v; + v3_copy( launch_v, v ); + v3_copy( launch_co, co1 ); + for( int i=1; i<=50; i++ ){ - float t = (float)i * k_trace_delta; + f32 t = (f32)i * k_trace_delta; - v3_muls( launch_v, t, co1 ); - co1[1] += -0.5f * gravity * t*t; - v3_add( launch_co, co1, co1 ); + /* integrate forces */ + v3f a; + ent_tornado_forces( co1, v, a ); + a[1] -= gravity; - float launch_vy = launch_v[1]; + /* position */ + v3_muladds( co1, v, k_trace_delta, co1 ); + v3_muladds( co1, a, 0.5f*k_trace_delta*k_trace_delta, co1 ); + + /* velocity */ + v3_muladds( v, a, k_trace_delta, v ); int search_for_grind = 1; if( grind_located ) search_for_grind = 0; - if( launch_vy - gravity*t > 0.0f ) search_for_grind = 0; + if( v[1] > 0.0f ) search_for_grind = 0; /* REFACTOR */ @@ -448,13 +461,9 @@ static void player__approximate_best_trajectory(void){ } if( search_for_grind ){ - v3f ve; - v3_copy( launch_v, ve ); - ve[1] += -gravity * t; - - if( skate_grind_scansq( closest, ve, 0.5f, &grind ) ){ + if( skate_grind_scansq( closest, v, 0.5f, &grind ) ){ /* check alignment */ - v2f v0 = { ve[0], ve[2] }, + v2f v0 = { v[0], v[2] }, v1 = { grind.dir[0], grind.dir[2] }; v2_normalize( v0 ); @@ -467,7 +476,7 @@ static void player__approximate_best_trajectory(void){ a_min = cosf( VG_PIf * 0.05f ); /* check speed */ - if( (fabsf(v3_dot( ve, grind.dir ))>=k_grind_axel_min_vel) && + if( (fabsf(v3_dot( v, grind.dir ))>=k_grind_axel_min_vel) && (a >= a_min) && (fabsf(grind.dir[1]) < 0.70710678118654752f)) { @@ -509,12 +518,7 @@ static void player__approximate_best_trajectory(void){ world_tri_index_surface( trace_world, tri[0] ); inf->type = k_prediction_land; - - v3f ve; - v3_copy( launch_v, ve ); - ve[1] += -gravity * t; - - inf->score = -v3_dot( ve, inf->n ); + inf->score = -v3_dot( v, inf->n ); inf->land_dist = t + k_trace_delta * t1; /* Bias prediction towords ramps */ @@ -901,10 +905,20 @@ static void skate_apply_friction_model(void){ f32 lat = k_friction_lat; if( fabsf(axis_state(k_sraxis_skid)) > 0.1f ){ - lat = k_friction_lat * 2.0f; + if( (player_skate.surface == k_surface_prop_snow) || + (player_skate.surface == k_surface_prop_sand) ){ + lat *= 8.0f; + } + else + lat *= 1.5f; } - vel[0] += vg_cfrictf( vel[0], k_friction_lat * k_rb_delta ); + if( player_skate.surface == k_surface_prop_snow ) + lat *= 0.5f; + else if( player_skate.surface == k_surface_prop_sand ) + lat *= 0.6f; + + vel[0] += vg_cfrictf( vel[0], lat * k_rb_delta ); vel[2] += vg_cfrictf( vel[2], k_friction_resistance * k_rb_delta ); /* Pushing additive force */ @@ -1206,6 +1220,12 @@ static void player__skate_pre_update(void){ if( button_down(k_srbind_use) && (v3_length2(state->trick_vel) < 0.01f) ){ localplayer.subsystem = k_player_subsystem_walk; + if( state->activity <= k_skate_activity_air_to_grind ){ + localplayer.subsystem = k_player_subsystem_glide; + player__begin_holdout( (v3f){0,0,0} ); + return; + } + v3f angles; v3_copy( localplayer.cam.angles, localplayer.angles ); localplayer.angles[2] = 0.0f; @@ -1221,6 +1241,7 @@ static void player__skate_pre_update(void){ player__begin_holdout( offset ); player__walk_transition( state->activity <= k_skate_activity_air_to_grind? 0: 1, state->trick_euler[0] ); + return; } @@ -2352,6 +2373,11 @@ grinding:; skate_apply_trick_model(); skate_apply_pump_model(); + ent_tornado_debug(); + v3f a; + ent_tornado_forces( localplayer.rb.co, localplayer.rb.v, a ); + v3_muladds( localplayer.rb.v, a, k_rb_delta, localplayer.rb.v ); + begin_collision:; /* @@ -3407,27 +3433,37 @@ 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 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 ); + 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 ); + if( animator->surface == k_surface_prop_sand ){ + if( (animator->slide>0.4f) && (v3_length2(animator->root_v)>4.0f*4.0f) ){ + v3f v, co; + v3_muls( animator->root_v, 0.5f, v ); + v3_lerp( vp0, vp1, vg_randf64(&vg.rand), co ); + + effect_data->sand.colour = 0xff8ec4e6; + effect_spark_apply( &effect_data->sand, co, v, vg.time_delta * 8.0 ); + } + } + + if( animator->grind > 0.5f ){ int back = 0, front = 0, mid = 0; if( animator->activity == k_skate_activity_grind_5050 ){