f
[carveJwlIkooP6JGAAIwe30JlM.git] / player.h
index 9540d9ea5201f27a5a0757904ae72ad26fffb553..a378f72a7e76368c012ab3a156a9b7a28c95be3d 100644 (file)
--- a/player.h
+++ b/player.h
@@ -439,35 +439,26 @@ static void player_physics(void)
       vg_line(tri[1],tri[2],0xff00ff00 );
       vg_line(tri[2],tri[0],0xff00ff00 );
 
-      v3f co, norm;
-      float p;
+      v3f temp;
+      v3_copy( player.rb.co, temp );
 
       for( int j=0; j<2; j++ )
       {
-         if( sphere_vs_triangle( poles[j], k_board_radius, tri,co,norm,&p) )
+         if(manifold_count >= vg_list_size(manifold))
          {
-            if(manifold_count >= vg_list_size(manifold))
-            {
-               vg_error("Manifold overflow!\n");
-               break;
-            }
-
-            v3f p1;
-            v3_muladds( poles[j], norm, p, p1 );
-            vg_line( poles[j], p1, 0xffffffff );
-
-            struct contact *ct = &manifold[manifold_count ++];
-            v3_sub( co, player.rb.co, ct->delta );
-            v3_copy( co, ct->co );
-            v3_copy( norm, ct->n );
+            vg_error("Manifold overflow!\n");
+            break;
+         }
 
-            ct->bias = -0.2f*k_rb_rate*vg_minf(0.0f,-p+k_board_allowance);
-            ct->norm_impulse = 0.0f;
+         rb_ct *ct = &manifold[manifold_count];
+         v3_copy( poles[j], player.rb.co );
 
-            v3_add( norm, surface_avg, surface_avg );
-         }
+         manifold_count += rb_sphere_vs_triangle( &player.rb, tri, ct );
       }
+
+      v3_copy( temp, player.rb.co );
    }
+   rb_presolve_contacts( manifold, manifold_count );
 
    if( !manifold_count )
    {
@@ -491,8 +482,9 @@ static void player_physics(void)
       {
          struct contact *ct = &manifold[i];
          
-         v3f dv;
-         v3_cross( player.rb.w, ct->delta, dv );
+         v3f dv, delta;
+         v3_sub( ct->co, player.rb.co, delta ); 
+         v3_cross( player.rb.w, delta, dv );
          v3_add( player.rb.v, dv, dv );
 
          float vn = -v3_dot( dv, ct->n );
@@ -503,7 +495,6 @@ static void player_physics(void)
          vn = ct->norm_impulse - temp;
 
          v3f impulse;
-
          v3_muls( ct->n, vn, impulse );
 
          if( fabsf(v3_dot( impulse, player.rb.forward )) > 10.0f ||
@@ -515,7 +506,7 @@ static void player_physics(void)
          }
 
          v3_add( impulse, player.rb.v, player.rb.v );
-         v3_cross( ct->delta, impulse, impulse );
+         v3_cross( delta, impulse, impulse );
 
          /*
           * W Impulses are limited to the Y and X axises, we don't really want