oh yeah mr crabs
[carveJwlIkooP6JGAAIwe30JlM.git] / player_physics.h
index 4a2add1b906fdd76f069c337aebdee1629157e48..6c170c6d9ae16f54272096c44c69b448c340c03c 100644 (file)
@@ -465,7 +465,9 @@ static void player_physics(void)
          player_start_air();
       }
       else
+      {
          phys->in_air = 0;
+      }
    }
 
    for( int j=0; j<5; j++ )
@@ -521,6 +523,7 @@ static void player_physics(void)
 
    if( !phys->in_air )
    {
+#if 0
       v3f axis;
       float angle = v3_dot( phys->rb.up, surface_avg );
       v3_cross( phys->rb.up, surface_avg, axis );
@@ -534,6 +537,34 @@ static void player_physics(void)
          q_axis_angle( correction, axis, acosf(angle)*18.0f*VG_TIMESTEP_FIXED );
          q_mul( correction, phys->rb.q, phys->rb.q );
       }
+#else
+      
+      /* 20/10/22: make this only go axisways instead, may effect velocities. */
+
+      v3f projected, axis;
+
+      float d = v3_dot( phys->rb.forward, surface_avg );
+      v3_muladds( surface_avg, phys->rb.forward, -d, projected );
+      v3_normalize( projected );
+
+      float angle = v3_dot( phys->rb.up, projected );
+      v3_cross( phys->rb.up, projected, axis );
+
+      v3f p0, p1;
+      v3_add( phys->rb.co, projected, p0 );
+      v3_add( phys->rb.co, phys->rb.up, p1 );
+      vg_line( phys->rb.co, p0, 0xff00ff00 );
+      vg_line( phys->rb.co, p1, 0xff000fff );
+
+      if( fabsf(angle) < 0.999f )
+      {
+         v4f correction;
+         q_axis_angle( correction, axis, acosf(angle)*4.0f*VG_TIMESTEP_FIXED );
+         q_mul( correction, phys->rb.q, phys->rb.q );
+      }
+
+
+#endif
 
       float const DOWNFORCE = -k_downforce*VG_TIMESTEP_FIXED;
       v3_muladds( phys->rb.v, phys->rb.up, DOWNFORCE, phys->rb.v );
@@ -566,7 +597,7 @@ static void player_physics(void)
          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_jumps[rand()%4] );
+         audio_player_playclip( &audio_player_extra, &audio_jumps[rand()%2] );
          audio_unlock();
       }
    }
@@ -684,6 +715,7 @@ static void player_do_motion(void)
          }
          
          player.rewind_length = 0;
+         player.rewind_total_length = 0.0f;
          player.rewind_incrementer = 10000;
          player_save_frame();