X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;ds=sidebyside;f=player_walk.c;h=6d020523d0cc1bb57451dc6dc3fb992b080bb291;hb=d3d41f80ec992fe4e40b8531721b7874b8a7c400;hp=00ee7fb4807cf27d197331f941c4018ce4278c57;hpb=56f320d8ce6e8997370ec8e02fe50ca2d07b67f0;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/player_walk.c b/player_walk.c index 00ee7fb..6d02052 100644 --- a/player_walk.c +++ b/player_walk.c @@ -432,15 +432,13 @@ VG_STATIC void player__walk_update( player_instance *player ) v3_muls( right_dir, walk[0], movedir ); v3_muladds( movedir, forward_dir, walk[1], movedir ); - if( w->state.activity == k_walk_activity_ground ) - { + if( w->state.activity == k_walk_activity_ground ){ v3_normalize( surface_avg ); v3f tx, ty; rb_tangent_basis( surface_avg, tx, ty ); - if( v2_length2(walk) > 0.001f ) - { + if( v2_length2(walk) > 0.001f ){ /* clip movement to the surface */ float d = v3_dot(surface_avg,movedir); v3_muladds( movedir, surface_avg, -d, movedir ); @@ -450,30 +448,25 @@ VG_STATIC void player__walk_update( player_instance *player ) nominal_speed = k_walkspeed; /* jump */ - if( player->input_jump->button.value ) - { + if( player->input_jump->button.value ){ v3_muladds( player->rb.v, player->basis[1], 5.0f, player->rb.v ); w->state.activity = k_walk_activity_air; accel_speed = k_walk_air_accel; nominal_speed = k_airspeed; } - else - { + else{ player_friction( player->rb.v ); - struct world_material *surface_mat = - world_contact_material( world, manifold); - w->surface = surface_mat->info.surface_prop; + struct world_surface *surf = world_contact_surface( world, manifold ); + w->surface = surf->info.surface_prop; } } - else - { + else{ accel_speed = k_walk_air_accel; nominal_speed = k_airspeed; } - if( v2_length2(walk) > 0.001f ) - { + if( v2_length2(walk) > 0.001f ){ player_accelerate( player->rb.v, movedir, nominal_speed, accel_speed ); v3_normalize( movedir ); } @@ -481,10 +474,8 @@ VG_STATIC void player__walk_update( player_instance *player ) /* * Resolve velocity constraints */ - for( int j=0; j<5; j++ ) - { - for( int i=0; irb.co, w->state.prev_pos)) ) - { + ent_gate *gate = + world_intersect_gates( world, player->rb.co, w->state.prev_pos ); + if( gate ){ m4x3_mulv( gate->transport, player->rb.co, player->rb.co ); m3x3_mulv( gate->transport, player->rb.v, player->rb.v ); @@ -707,8 +698,7 @@ VG_STATIC void player__walk_animate( player_instance *player, float walk_yaw = player_get_heading_yaw( player ); - if( w->state.outro_anim ) - { + if( w->state.outro_anim ){ struct player_avatar *av = player->playeravatar; float outro_length = (float)w->state.outro_anim->length / w->state.outro_anim->rate, @@ -720,8 +710,7 @@ VG_STATIC void player__walk_animate( player_instance *player, outro_time, bpose ); skeleton_lerp_pose( sk, apose, bpose, outro_t * 10.0f, dest->pose ); - if( w->state.outro_type == k_walk_outro_drop_in ) - { + if( w->state.outro_type == k_walk_outro_drop_in ){ float inv_rate = 1.0f / w->state.outro_anim->rate, anim_frames = w->state.outro_anim->length * inv_rate, step_frames = 12.0f * inv_rate, @@ -753,8 +742,7 @@ VG_STATIC void player__walk_animate( player_instance *player, /* the drop in bit */ - if( step_t >= 1.0f ) - { + if( step_t >= 1.0f ){ v4f final_q; player_walk_drop_in_overhang_transform( player, dop_t, player->rb.co, final_q ); @@ -769,8 +757,7 @@ VG_STATIC void player__walk_animate( player_instance *player, } return; } - else - { + else{ v3_muladds( dest->root_co, player->rb.to_world[1], -0.1f * outro_t, dest->root_co ); @@ -778,8 +765,7 @@ VG_STATIC void player__walk_animate( player_instance *player, player->holdout_time = 1.0f; } } - else - { + else{ skeleton_copy_pose( sk, apose, dest->pose ); }