framebuffer formalitites
[carveJwlIkooP6JGAAIwe30JlM.git] / player_physics.h
index 80a07b2d450f54cd2d5e03c85e534d702ad8c0ad..f395953932e19003e93cac528d76c538cb99531e 100644 (file)
@@ -973,33 +973,60 @@ VG_STATIC void player_do_motion(void)
       int len = player_update_collision_manifold( manifold );
       int grind_col = player_update_grind_collision( &manifold[len] );
 
+      static int _grind_col_pre = 0;
+
       if( grind_col )
       {
          phys->grind = 1;
          v3f up = { 0.0f, 1.0f, 0.0f };
          float angle = v3_dot( phys->rb.up, up );
-         v3f axis; 
-         v3_cross( phys->rb.up, up, axis );
 
          if( fabsf(angle) < 0.99f )
          {
+            v3f axis; 
+            v3_cross( phys->rb.up, up, axis );
+
             v4f correction;
             q_axis_angle( correction, axis, 
                   VG_TIMESTEP_FIXED * 10.0f * acosf(angle) );
             q_mul( correction, phys->rb.q, phys->rb.q );
          }
 
-         float const DOWNFORCE = -k_downforce*2.0f*VG_TIMESTEP_FIXED;
-         v3_muladds( phys->rb.v, phys->rb.up, DOWNFORCE, phys->rb.v );
+         float const DOWNFORCE = -k_downforce*1.2f*VG_TIMESTEP_FIXED;
+         v3_muladds( phys->rb.v, manifold[len].n, DOWNFORCE, phys->rb.v );
          m3x3_identity( phys->vr );
          m3x3_identity( phys->vr_pstep );
+
+         if( !_grind_col_pre )
+         {
+            audio_lock();
+            audio_player_set_flags( &audio_player_extra, 
+                                    AUDIO_FLAG_SPACIAL_3D );
+            audio_player_set_position( &audio_player_extra, phys->rb.co );
+            audio_player_set_vol( &audio_player_extra, 20.0f );
+            audio_player_playclip( &audio_player_extra, &audio_board[5] );
+            audio_unlock();
+         }
       }
       else
       {
          phys->grind = 0;
          player_adhere_ground( manifold, len );
+
+         if( _grind_col_pre )
+         {
+            audio_lock();
+            audio_player_set_flags( &audio_player_extra, 
+                                    AUDIO_FLAG_SPACIAL_3D );
+            audio_player_set_position( &audio_player_extra, phys->rb.co );
+            audio_player_set_vol( &audio_player_extra, 20.0f );
+            audio_player_playclip( &audio_player_extra, &audio_board[6] );
+            audio_unlock();
+         }
       }
 
+      _grind_col_pre = grind_col;
+
       rb_presolve_contacts( manifold, len+ VG_MAX(0,grind_col) );
       player_collision_response( manifold, len+ VG_MAX(0,grind_col) );
 
@@ -1104,8 +1131,8 @@ VG_STATIC void player_freecam(void)
    v3f lookdir = { 0.0f, 0.0f, -1.0f },
        sidedir = { 1.0f, 0.0f,  0.0f };
    
-   m3x3_mulv( camera_mtx, lookdir, lookdir );
-   m3x3_mulv( camera_mtx, sidedir, sidedir );
+   m3x3_mulv( main_camera.transform, lookdir, lookdir );
+   m3x3_mulv( main_camera.transform, sidedir, sidedir );
    
    static v3f move_vel = { 0.0f, 0.0f, 0.0f };
 
@@ -1167,6 +1194,13 @@ VG_STATIC int reset_player( int argc, char const *argv[] )
    if( !rp )
    {
       vg_error( "No spawn found\n" );
+      vg_info( "Player position: %f %f %f\n", player.phys.rb.co[0],
+                                              player.phys.rb.co[1],
+                                              player.phys.rb.co[2] );
+      vg_info( "Player velocity: %f %f %f\n", player.phys.rb.v[0],
+                                              player.phys.rb.v[1],
+                                              player.phys.rb.v[2] );
+
       if( !world.spawn_count )
          return 0;