+ struct player_cam_controller *cc = &player->cam_control;
+
+ if( player->subsystem == k_player_subsystem_walk ){
+ v3_copy( (v3f){-0.1f,1.8f,0.0f}, cc->fpv_viewpoint );
+ v3_copy( (v3f){0.0f,0.0f,0.0f}, cc->fpv_offset );
+ v3_copy( (v3f){0.0f,1.4f,0.0f}, cc->tpv_offset );
+ }
+ else{
+ v3_copy( (v3f){-0.15f,1.75f,0.0f}, cc->fpv_viewpoint );
+ v3_copy( (v3f){0.0f,0.0f,0.0f}, cc->fpv_offset );
+
+ f32 h = vg_lerpf( 0.4f, 1.4f, k_cam_height );
+ v3_copy( (v3f){0.0f,h,0.0f}, cc->tpv_offset );
+ v3_add( cc->tpv_offset_extra, cc->tpv_offset, cc->tpv_offset );
+ }
+
+ player->cam_velocity_constant = 0.25f;
+ player->cam_velocity_coefficient = 0.7f;
+
+ /* lerping */
+
+ player->cam_velocity_influence_smooth = vg_lerpf(
+ player->cam_velocity_influence_smooth,
+ player->cam_velocity_influence,
+ vg.time_frame_delta * 8.0f );
+
+ player->cam_velocity_coefficient_smooth = vg_lerpf(
+ player->cam_velocity_coefficient_smooth,
+ player->cam_velocity_coefficient,
+ vg.time_frame_delta * 8.0f );
+
+ player->cam_velocity_constant_smooth = vg_lerpf(
+ player->cam_velocity_constant_smooth,
+ player->cam_velocity_constant,
+ vg.time_frame_delta * 8.0f );
+
+ enum camera_mode target_mode = cc->camera_mode;
+
+ if( player->subsystem == k_player_subsystem_dead )
+ target_mode = k_cam_thirdperson;
+
+ cc->camera_type_blend =
+ vg_lerpf( cc->camera_type_blend,
+ (target_mode == k_cam_firstperson)? 1.0f: 0.0f,
+ 5.0f * vg.time_frame_delta );
+
+ v3_lerp( cc->fpv_viewpoint_smooth, cc->fpv_viewpoint,
+ vg.time_frame_delta * 8.0f, cc->fpv_viewpoint_smooth );
+
+ v3_lerp( cc->fpv_offset_smooth, cc->fpv_offset,
+ vg.time_frame_delta * 8.0f, cc->fpv_offset_smooth );
+
+ v3_lerp( cc->tpv_offset_smooth, cc->tpv_offset,
+ vg.time_frame_delta * 8.0f, cc->tpv_offset_smooth );
+
+ /* fov -- simple blend */
+ float fov_skate = vg_lerpf( 97.0f, 135.0f, k_fov ),
+ fov_walk = vg_lerpf( 90.0f, 110.0f, k_fov );
+
+ player->cam.fov = vg_lerpf( fov_walk, fov_skate, cc->camera_type_blend );
+
+ /*
+ * first person camera
+ */
+
+ /* position */
+ v3f fpv_pos, fpv_offset;
+ m4x3_mulv( av->sk.final_mtx[ av->id_head-1 ],
+ cc->fpv_viewpoint_smooth, fpv_pos );
+ m3x3_mulv( player->rb.to_world, cc->fpv_offset_smooth, fpv_offset );
+ v3_add( fpv_offset, fpv_pos, fpv_pos );
+
+ /* angles */
+ v3f velocity_angles;
+ v3_lerp( cc->cam_velocity_smooth, player->rb.v, 4.0f*vg.time_frame_delta,
+ cc->cam_velocity_smooth );
+
+ v3f velocity_local;
+ m3x3_mulv( player->invbasis, cc->cam_velocity_smooth, velocity_local );
+ player_vector_angles( velocity_angles, velocity_local,
+ player->cam_velocity_coefficient_smooth,
+ player->cam_velocity_constant_smooth );
+
+ float inf_fpv = player->cam_velocity_influence_smooth * cc->camera_type_blend,
+ inf_tpv = player->cam_velocity_influence_smooth *
+ (1.0f-cc->camera_type_blend);