quite a lot of changes
[carveJwlIkooP6JGAAIwe30JlM.git] / player_common.c
index 169cbf4ba5f7640b0708f7c7966e1a0bba0c5a12..cb83d532598fcf37fd342ea44ba0fe218e9554fa 100644 (file)
@@ -3,7 +3,6 @@
 
 #include "ent_skateshop.h"
 #include "player.h"
-#include "conf.h"
 #include "input.h"
 #include "menu.h"
 #include "vg/vg_perlin.h"
@@ -194,14 +193,23 @@ VG_STATIC void player__cam_iterate( player_instance *player )
    v3_lerp( player->tpv_lpf, pco, 20.0f*vg.time_frame_delta, player->tpv_lpf );
 
    /* now move into world */
+   v3f tpv_pos, tpv_offset, tpv_origin;
 
-   m3x3_mulv( player->basis, camera_follow_dir, camera_follow_dir );
-   v3f tpv_pos, tpv_offset;
+   /* origin */
+   q_mulv( pq, player->tpv_offset_smooth, tpv_origin );
+   v3_add( tpv_origin, player->tpv_lpf, tpv_origin );
 
-   v3_muladds( player->tpv_lpf, camera_follow_dir, 1.8f, tpv_pos );
-   q_mulv( pq, player->tpv_offset_smooth, tpv_offset );
-   v3_add( tpv_offset, tpv_pos, tpv_pos );
-   v3_muladds( tpv_pos, player->cam_velocity_smooth, -0.025f, tpv_pos );
+   /* offset */
+   m3x3_mulv( player->basis, camera_follow_dir, camera_follow_dir );
+   v3_muls( camera_follow_dir, 1.8f, tpv_offset );
+   v3_muladds( tpv_offset, player->cam_velocity_smooth, -0.025f, tpv_offset );
+
+   v3_add( tpv_origin, tpv_offset, tpv_pos );
+   f32 t; v3f n;
+   if( spherecast_world( world_current_instance(), tpv_origin, tpv_pos, 
+                         0.2f, &t, n ) != -1 ){
+      v3_lerp( tpv_origin, tpv_pos, t, tpv_pos );
+   }
 
    /* 
     * Blend cameras 
@@ -297,18 +305,4 @@ VG_STATIC void player_look( player_instance *player, v3f angles )
    angles[1] = vg_clampf( angles[1], -VG_PIf*0.5f, VG_PIf*0.5f );
 }
 
-struct player_board *player_get_player_board( struct player_instance *player )
-{
-   struct player_board *board = NULL;
-
-   if( localplayer.board_view_slot ){
-      struct cache_board *cache_view = localplayer.board_view_slot;
-      if( cache_view->state == k_cache_board_state_loaded ){
-         board = &cache_view->board;
-      }
-   }
-
-   return board;
-}
-
 #endif /* PLAYER_COMMON_C */