X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=player_common.c;h=21d52aa76871c6f978d10f3bda4334ae614e5671;hb=8c376ed2e4021a18b0a6c6e800109d67ad09d198;hp=4cb1a0bd77c5650187b7c884a365404fa1b5f15b;hpb=16f58e6b8d79762919000b9ae8266ad55a01a870;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/player_common.c b/player_common.c index 4cb1a0b..21d52aa 100644 --- a/player_common.c +++ b/player_common.c @@ -4,6 +4,10 @@ #include "player.h" #include "conf.h" +VG_STATIC float + k_cam_spring = 20.0f, + k_cam_damp = 6.7f; + VG_STATIC void player_vector_angles( v3f angles, v3f v, float C, float k ) { float yaw = atan2f( v[0], -v[2] ), @@ -85,17 +89,17 @@ VG_STATIC void player__cam_iterate( player_instance *player ) player->cam_velocity_influence_smooth = vg_lerpf( player->cam_velocity_influence_smooth, player->cam_velocity_influence, - vg.frame_delta * 8.0f ); + vg.time_frame_delta * 8.0f ); player->cam_velocity_coefficient_smooth = vg_lerpf( player->cam_velocity_coefficient_smooth, player->cam_velocity_coefficient, - vg.frame_delta * 8.0f ); + vg.time_frame_delta * 8.0f ); player->cam_velocity_constant_smooth = vg_lerpf( player->cam_velocity_constant_smooth, player->cam_velocity_constant, - vg.frame_delta * 8.0f ); + vg.time_frame_delta * 8.0f ); enum camera_mode target_mode = player->camera_mode; @@ -105,16 +109,16 @@ VG_STATIC void player__cam_iterate( player_instance *player ) player->camera_type_blend = vg_lerpf( player->camera_type_blend, (target_mode == k_cam_firstperson)? 1.0f: 0.0f, - 5.0f * vg.frame_delta ); + 5.0f * vg.time_frame_delta ); v3_lerp( player->fpv_viewpoint_smooth, player->fpv_viewpoint, - vg.frame_delta * 8.0f, player->fpv_viewpoint_smooth ); + vg.time_frame_delta * 8.0f, player->fpv_viewpoint_smooth ); v3_lerp( player->fpv_offset_smooth, player->fpv_offset, - vg.frame_delta * 8.0f, player->fpv_offset_smooth ); + vg.time_frame_delta * 8.0f, player->fpv_offset_smooth ); v3_lerp( player->tpv_offset_smooth, player->tpv_offset, - vg.frame_delta * 8.0f, player->tpv_offset_smooth ); + vg.time_frame_delta * 8.0f, player->tpv_offset_smooth ); /* fov -- simple blend */ float fov_skate = vg_lerpf( 97.0f, 135.0f, cl_fov ), @@ -135,7 +139,7 @@ VG_STATIC void player__cam_iterate( player_instance *player ) /* angles */ v3f velocity_angles; - v3_lerp( player->cam_velocity_smooth, player->rb.v, 4.0f*vg.frame_delta, + v3_lerp( player->cam_velocity_smooth, player->rb.v, 4.0f*vg.time_frame_delta, player->cam_velocity_smooth ); v3f velocity_local; @@ -163,7 +167,7 @@ VG_STATIC void player__cam_iterate( player_instance *player ) * it is done in the local basis then transformed back */ v3f future; - v3_muls( player->rb.v, 0.4f*vg.frame_delta, future ); + v3_muls( player->rb.v, 0.4f*vg.time_frame_delta, future ); m3x3_mulv( player->invbasis, future, future ); v3f camera_follow_dir = @@ -189,7 +193,7 @@ VG_STATIC void player__cam_iterate( player_instance *player ) v3f pco; v4f pq; rb_extrapolate( &player->rb, pco, pq ); - v3_lerp( player->tpv_lpf, pco, 20.0f*vg.frame_delta, player->tpv_lpf ); + v3_lerp( player->tpv_lpf, pco, 20.0f*vg.time_frame_delta, player->tpv_lpf ); /* now move into world */ @@ -209,8 +213,8 @@ VG_STATIC void player__cam_iterate( player_instance *player ) float Fd = -player->cam_land_punch_v * k_cam_damp, Fs = -player->cam_land_punch * k_cam_spring; - player->cam_land_punch += player->cam_land_punch_v * vg.frame_delta; - player->cam_land_punch_v += ( Fd + Fs ) * vg.frame_delta; + player->cam_land_punch += player->cam_land_punch_v * vg.time_frame_delta; + player->cam_land_punch_v += ( Fd + Fs ) * vg.time_frame_delta; player->cam.angles[1] += player->cam_land_punch; /* override camera */