my fucking fingers
[carveJwlIkooP6JGAAIwe30JlM.git] / player_common.c
index f058b56569ac2bb9b7aa4c20c7a6e192fb6545b5..5c5dda1fef5554398698b41437e16246688a9fca 100644 (file)
@@ -1,8 +1,10 @@
 #ifndef PLAYER_COMMON_C
 #define PLAYER_COMMON_C
 
+#include "ent_skateshop.h"
 #include "player.h"
 #include "conf.h"
+#include "input.h"
 
 VG_STATIC float
    k_cam_spring            = 20.0f,
@@ -89,17 +91,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;
 
@@ -109,16 +111,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 ),
@@ -139,7 +141,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;
@@ -167,7 +169,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 = 
@@ -193,7 +195,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 */
 
@@ -213,8 +215,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 */
@@ -226,6 +228,8 @@ VG_STATIC void player__cam_iterate( player_instance *player )
                  player->cam_override_strength );
    v3_lerp( player->cam.pos, player->cam_override_pos, 
             player->cam_override_strength, player->cam.pos );
+   player->cam.fov = vg_lerpf( player->cam.fov, player->cam_override_fov, 
+                               player->cam_override_strength );
 
    /* portal transitions */
    player_camera_portal_correction( player );
@@ -233,6 +237,8 @@ VG_STATIC void player__cam_iterate( player_instance *player )
 
 VG_STATIC void player_look( player_instance *player, v3f angles )
 {
+   if( vg_ui.wants_mouse ) return;
+
    angles[2] = 0.0f;
 
    v2f mouse_input;
@@ -241,41 +247,30 @@ VG_STATIC void player_look( player_instance *player, v3f angles )
       mouse_input[1] *= -1.0f;
    v2_muladds( angles, mouse_input, 0.0025f, angles );
 
-   if( vg_input.controller_should_use_trackpad_look ){
-      static v2f last_input;
-      static v2f vel;
-      static v2f vel_smooth;
-
-      v2f input = { player->input_js2h->axis.value,
-                    player->input_js2v->axis.value };
+   v2f jlook;
+   joystick_state( k_srjoystick_look, jlook );
 
-      if( cl_invert_y )
-         input[1] *= -1.0f;
-
-      if( (v2_length2(last_input) > 0.001f) && (v2_length2(input) > 0.001f) ){
-         v2_sub( input, last_input, vel );
-         v2_muls( vel, 1.0f/vg.time_delta, vel );
-      }
-      else{
-         v2_zero( vel );
-      }
+   angles[0] += jlook[0] * vg.time_delta * 4.0f;
+   float input_y = jlook[1] * vg.time_delta * 4.0f;
+   if( cl_invert_y )
+      input_y *= -1.0f;
 
-      v2_lerp( vel_smooth, vel, vg.time_delta*8.0f, vel_smooth );
-      
-      v2_muladds( angles, vel_smooth, vg.time_delta, angles );
-      v2_copy( input, last_input );
-   }
-   else{
-      angles[0] += player->input_js2h->axis.value * vg.time_delta * 4.0f;
+   angles[1] += input_y;
+   angles[1] = vg_clampf( angles[1], -VG_PIf*0.5f, VG_PIf*0.5f );
+}
 
-      float input_y = player->input_js2v->axis.value * vg.time_delta * 4.0f;
-      if( cl_invert_y )
-         input_y *= -1.0f;
+struct player_board *player_get_player_board( struct player_instance *player )
+{
+   struct player_board *board = NULL;
 
-      angles[1] += input_y;
+   if( localplayer.board_view_slot ){
+      struct dynamic_board *vs = localplayer.board_view_slot;
+      if( vs->state == k_dynamic_board_state_loaded ){
+         board = &vs->board;
+      }
    }
 
-   angles[1] = vg_clampf( angles[1], -VG_PIf*0.5f, VG_PIf*0.5f );
+   return board;
 }
 
 #endif /* PLAYER_COMMON_C */