add player guide
[carveJwlIkooP6JGAAIwe30JlM.git] / player_walk.c
index 6a20b17f32855eb9bcd1924eb822ef431318fdcf..b37095da28ded733db41f629dfad1a3d2a61cf45 100644 (file)
@@ -88,7 +88,7 @@ VG_STATIC void player_walk_drop_in_to_skate( player_instance *player )
    v3_muladds( player->rb.co, player->rb.to_world[1], 1.0f, s->state.cog );
    v3_copy( init_velocity, s->state.cog_v );
    v3_copy( init_velocity, player->rb.v );
-   v3_copy( init_velocity, player->cam_velocity_smooth );
+   v3_copy( init_velocity, player->cam_control.cam_velocity_smooth );
    v3_copy( (v3f){1.0f,0.0f,0.0f}, s->state.trick_euler );
 }
 
@@ -147,7 +147,7 @@ VG_STATIC int player_walk_scan_for_drop_in( player_instance *player )
       if( ray_world( world, pos, ray_dir, ray ) )
       {
          vg_line( pos, ray->pos, VG__RED );
-         vg_line_pt3( ray->pos, 0.025f, VG__BLACK );
+         vg_line_point( ray->pos, 0.025f, VG__BLACK );
          
          sample_count ++;
       }
@@ -225,7 +225,7 @@ VG_STATIC int player_walk_scan_for_drop_in( player_instance *player )
          if( ray_world( world, va, v0, &ray ) )
          {
             vg_line( va, vb, VG__RED );
-            vg_line_pt3( ray.pos, 0.1f, VG__RED );
+            vg_line_point( ray.pos, 0.1f, VG__RED );
             vg_error( "invalidated\n" );
             return 0;
          }
@@ -234,7 +234,7 @@ VG_STATIC int player_walk_scan_for_drop_in( player_instance *player )
          if( ray_world( world, vb, v0, &ray ) )
          {
             vg_line( va, vb, VG__RED );
-            vg_line_pt3( ray.pos, 0.1f, VG__RED );
+            vg_line_point( ray.pos, 0.1f, VG__RED );
             vg_error( "invalidated\n" );
             return 0;
          }
@@ -284,8 +284,11 @@ VG_STATIC void player__walk_pre_update( player_instance *player )
          player->subsystem = k_player_subsystem_drive;
       }
       else{
-         if( !player_get_player_board(player) )
-            return;
+         struct player_board *board = 
+            addon_cache_item_if_loaded( k_addon_type_board,
+                                        player->board_view_slot );
+
+         if( !board ) return;
 
          if( w->state.activity == k_walk_activity_ground ){
             if( player_walk_scan_for_drop_in( player ) ){
@@ -389,7 +392,7 @@ VG_STATIC void player__walk_update( player_instance *player )
    m3x3_copy( player->rb.to_world, mtx );
    v3_add( player->rb.co, player->basis[1], mtx[3] );
 
-   debug_capsule( mtx, w->collider.radius, w->collider.height, VG__WHITE );
+   vg_line_capsule( mtx, w->collider.radius, w->collider.height, VG__WHITE );
 
    rb_ct manifold[64];
    int len;
@@ -454,7 +457,7 @@ VG_STATIC void player__walk_update( player_instance *player )
       v3_normalize( surface_avg );
 
       v3f tx, ty;
-      rb_tangent_basis( surface_avg, tx, ty );
+      v3_tangent_basis( surface_avg, tx, ty );
 
       if( v2_length2(steer) > 0.001f ){
          /* clip movement to the surface */
@@ -556,7 +559,7 @@ VG_STATIC void player__walk_update( player_instance *player )
 
    v3_muladds( player->rb.co, player->rb.v, k_rb_delta, player->rb.co );
    v3_add( player->rb.co, player->basis[1], mtx[3] );
-   debug_capsule( mtx, w->collider.radius, w->collider.height, VG__GREEN );
+   vg_line_capsule( mtx, w->collider.radius, w->collider.height, VG__GREEN );
 
    /* 
     * CCD routine 
@@ -585,7 +588,7 @@ VG_STATIC void player__walk_update( player_instance *player )
          rb_update_transform( &player->rb );
 
          v3_add( player->rb.co, player->basis[1], mtx[3] );
-         debug_capsule( mtx, w->collider.radius, w->collider.height, VG__RED );
+         vg_line_capsule( mtx, w->collider.radius, w->collider.height, VG__RED );
       }
    }
 
@@ -623,7 +626,7 @@ VG_STATIC void player__walk_post_update( player_instance *player )
 
    float substep = vg.time_fixed_extrapolate;
    v3_muladds( mtx[3], player->rb.v, k_rb_delta*substep, mtx[3] );
-   debug_capsule( mtx, w->collider.radius, w->collider.height, VG__YELOW );
+   vg_line_capsule( mtx, w->collider.radius, w->collider.height, VG__YELOW );
 
 
    /* Calculate header */
@@ -639,7 +642,7 @@ VG_STATIC void player__walk_post_update( player_instance *player )
       q_normalize( player->rb.q );
    }
 
-   vg_line_pt3( w->state.drop_in_target, 0.1f, VG__GREEN );
+   vg_line_point( w->state.drop_in_target, 0.1f, VG__GREEN );
    v3f p1;
    v3_muladds( w->state.drop_in_target, w->state.drop_in_normal, 0.3f, p1 );
    vg_line( w->state.drop_in_target, p1, VG__GREEN );
@@ -647,7 +650,7 @@ VG_STATIC void player__walk_post_update( player_instance *player )
    vg_line( w->state.drop_in_target, p1, VG__GREEN );
 
    vg_line( w->state.drop_in_target, w->state.drop_in_foot_anchor, VG__WHITE );
-   vg_line_pt3( w->state.drop_in_foot_anchor, 0.08f, VG__PINK );
+   vg_line_point( w->state.drop_in_foot_anchor, 0.08f, VG__PINK );
 
 
    float a = player_get_heading_yaw( player );
@@ -748,7 +751,12 @@ VG_STATIC void player__walk_animate( player_instance *player,
    skeleton_lerp_pose( sk, apose, bpose, w->blend_fly, apose );
 
    /* Create transform */
-   rb_extrapolate( &player->rb, dest->root_co, dest->root_q );
+   if( !player->immobile )
+      rb_extrapolate( &player->rb, dest->root_co, dest->root_q );
+   else{
+      v3_copy( player->rb.co, dest->root_co );
+      v4_copy( player->rb.q,  dest->root_q );
+   }
 
    float walk_yaw = player_get_heading_yaw( player );