X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=player.h;h=bd7304dc614550c8978345c08cce9fb893a363ae;hb=9c85e110fa8b965195438d96625ff9753af362a6;hp=34ed46944337270ec1f571bac991ee02a9d37222;hpb=cb16ccb05a796178c879ea8d5091663d215a5217;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/player.h b/player.h index 34ed469..bd7304d 100644 --- a/player.h +++ b/player.h @@ -21,9 +21,6 @@ static struct gplayer float iY; /* Yaw inertia */ int in_air, is_dead, on_board; - /* Input */ - v2f joy_l; - v2f board_xy; float grab; float pitch; @@ -53,6 +50,11 @@ player = .on_board = 1 }; +static float *player_cam_pos(void) +{ + return player.camera_pos; +} + static void player_transform_update(void) { q_normalize( player.rot ); @@ -64,15 +66,49 @@ static void player_transform_update(void) static int reset_player( int argc, char const *argv[] ) { - v3_copy( world.tutorial, player.co ); - if( argc == 1 ) + struct respawn_point *rp = NULL, *r; + + if( argc > 1 ) + { + for( int i=0; iname, argv[0] ) ) + { + rp = r; + break; + } + } + + if( !rp ) + vg_warn( "No spawn named '%s'\n", argv[0] ); + } + + if( !rp ) + { + float min_dist = INFINITY; + for( int i=0; ico, player.co ); + + if( d < min_dist ) + { + min_dist = d; + rp = r; + } + } + } + + if( !rp ) { - if( !strcmp( argv[0], "tutorial" )) - v3_copy( world.tutorial, player.co ); + vg_error( "No spawn found\n" ); + return 0; } - v3_copy( (v3f){ 0.0f, 0.0f, -0.2f }, player.v ); - q_identity( player.rot ); + v4_copy( r->q, player.rot ); + v3_copy( r->co, player.co ); + player.vswitch = 1.0f; player.slip_last = 0.0f; player.is_dead = 0; @@ -83,11 +119,15 @@ static int reset_player( int argc, char const *argv[] ) player.mdl.shoes[1] = 1; player_transform_update(); - return 0; + m3x3_mulv( player.to_world, (v3f){ 0.0f, 0.0f, -0.2f }, player.v ); + return 1; } static void player_mouseview(void) { + if( gui_want_mouse() ) + return; + static v2f mouse_last, view_vel = { 0.0f, 0.0f }; @@ -369,8 +409,8 @@ static void player_physics_ground(void) { vel[2] = stable_force( vel[2], vg_signf( vel[2] ) * fwd_resistance ); - /* This used to be -7.0 */ - vel[0] = stable_force( vel[0], vg_signf( vel[0] ) * -10.0f *substep ); + /* This used to be -7.0, then -10.0 */ + vel[0] = stable_force( vel[0], vg_signf( vel[0] ) * -8.5f *substep ); } static double start_push = 0.0; @@ -398,7 +438,7 @@ static void player_physics_ground(void) player.iY -= 3.6f * ktimestep; float steer = vg_get_axis( "horizontal" ); - player.iY -= vg_signf(steer)*powf(steer,2.0f) * 1.5f * ktimestep; + player.iY -= vg_signf(steer)*powf(steer,2.0f) * 2.5f * ktimestep; /* Too much lean and it starts to look like a snowboard here */ v2_lerp( player.board_xy, (v2f){ slip*0.25f, 0.0f }, @@ -530,9 +570,6 @@ static void player_do_motion(void) float horizontal = vg_get_axis("horizontal"), vertical = vg_get_axis("vertical"); - player.joy_l[0] = vg_signf(horizontal) * powf( horizontal, 2.0f ); - player.joy_l[1] = vg_signf(vertical) * powf( vertical, 2.0f ); - if( player.in_air ) player_physics_air(); @@ -590,12 +627,12 @@ static void player_do_motion(void) player.angles[0] = atan2f( player.vl[0], -player.vl[2] ); player.angles[1] = atan2f( -player.vl[1], sqrtf(player.vl[0]*player.vl[0]+ - player.vl[2]*player.vl[2]) ) * 0.3f; + player.vl[2]*player.vl[2]) ) * 0.7f; } static int player_walkgrid_tri_walkable( u32 tri[3] ) { - return tri[0] < world.sm_road.vertex_count; + return tri[0] < world.sm_surface.vertex_count; } #define WALKGRID_SIZE 16 @@ -1605,6 +1642,9 @@ static void player_animate(void) character_pose_reset( &player.mdl ); + /* TODO */ + fstand = 1.0f; + float amt_air = ffly*ffly, amt_ground = 1.0f-amt_air, amt_std = (1.0f-fslide) * amt_ground, @@ -1627,9 +1667,11 @@ static void player_animate(void) character_final_pose( &player.mdl, (v3f){0.0f,0.0f,0.0f}, &pose_fly, amt_air ); +#if 0 static float fupper = 0.0f; fupper = vg_lerpf( fupper, -vg_get_axis("horizontal")*0.2f, 0.1f ); character_yaw_upper( &player.mdl, fupper ); +#endif /* Camera position */ v3_lerp( player.smooth_localcam, player.mdl.cam_pos, 0.08f, @@ -1652,8 +1694,11 @@ static void player_animate(void) v3f localv; m3x3_mulv( player.to_local, player.v, localv ); + +#if 0 v3_muladds( arm_l->end, localv, -0.01f, arm_l->end ); v3_muladds( arm_r->end, localv, -0.01f, arm_r->end ); +#endif /* New board transformation */ v4f board_rotation; v3f board_location; @@ -1737,8 +1782,9 @@ static void player_animate(void) /* Head rotation */ static float rhead = 0.0f; + static const float klook_max = 0.8f; rhead = vg_lerpf( rhead, - vg_clampf(atan2f( localv[2], -localv[0] ),-1.0f,1.0f), 0.04f ); + vg_clampf( atan2f(localv[2],-localv[0]),-klook_max,klook_max), 0.04f ); player.mdl.rhead = rhead; } @@ -2134,10 +2180,12 @@ static void player_update(void) player_do_motion(); player_animate(); - v3f offs = { -0.35f, 0.0f, 0.0f }; - m3x3_mulv( player.to_world, offs, offs ); + v3f offs = { -0.29f, 0.08f, 0.0f }; + m3x3_mulv( player.to_world, offs, offs ); m4x3_mulv( player.to_world, player.mdl.ik_body.end, player.camera_pos ); - v3_add( offs, player.camera_pos, player.camera_pos ); + //m4x3_mulv( player.mdl.matrices[k_chpart_head], offs, player.camera_pos ); + // v3_copy( player.mdl.matrices[k_chpart_head][3], player.camera_pos ); + v3_add( offs, player.camera_pos, player.camera_pos ); } else { @@ -2151,7 +2199,7 @@ static void player_update(void) /* Update camera matrices */ m4x3_identity( player.camera ); m4x3_rotate_y( player.camera, -player.angles[0] ); - m4x3_rotate_x( player.camera, -0.33f -player.angles[1] ); + m4x3_rotate_x( player.camera, -0.30f -player.angles[1] ); v3_copy( player.camera_pos, player.camera[3] ); m4x3_invert_affine( player.camera, player.camera_inverse ); }