automatic camera inversing across portals
[carveJwlIkooP6JGAAIwe30JlM.git] / player_device_skate.h
index e23398d78a45e17d0b5df1165e3abf8faff5c069..13f6398a0b549d37f338b2b25ffd0bacb7062320 100644 (file)
@@ -1128,9 +1128,35 @@ VG_STATIC void player_skate_update( player_interface *player,
                                      &s->sphere_front, manifold ),
    len_back = skate_collide_smooth( player, mtx_back,  
                                     &s->sphere_back, &manifold[len_front] ),
-
    interface_len = len_front + len_back;
 
+   /* try to slap both wheels onto the ground when landing to prevent mega 
+    * angular velocities being added */
+   if( (s->state.activity == k_skate_activity_air) && (len_front != len_back) )
+   {
+      v3f trace_from, trace_dir;
+      v3_muls( player->rb.to_world[1], -1.0f, trace_dir );
+
+      if( len_front )
+         v3_copy( mtx_back[3],  trace_from );
+      else
+         v3_copy( mtx_front[3], trace_from );
+
+      ray_hit ray;
+      ray.dist = 0.6f;
+
+      if( ray_world( trace_from, trace_dir, &ray ) )
+      {
+         rb_ct *ct = &manifold[ interface_len ];
+
+         v3_copy( ray.pos, ct->co );
+         v3_copy( ray.normal, ct->n );
+         ct->p = 0.0f;
+
+         interface_len ++;
+      }
+   }
+
    interface_manifold = manifold;
    grind_manifold = manifold + interface_len;
 
@@ -1173,6 +1199,8 @@ VG_STATIC void player_skate_update( player_interface *player,
       m4x3_mulv( gate->transport, s->state.cog,   s->state.cog );
       m3x3_mulv( gate->transport, s->state.cog_v, s->state.cog_v );
       m3x3_mulv( gate->transport, s->state.throw_v, s->state.throw_v );
+      m4x3_mulv( gate->transport, s->state.posl, s->state.posl );
+      m3x3_mulv( gate->transport, s->state.vl, s->state.vl );
 
 #if 0
       mixedcam_transport( &s->state.cam, gate );