i hope your hapy
[carveJwlIkooP6JGAAIwe30JlM.git] / player_walk.c
index fbae15d4e1dc12b1c18bb21094d0dcdf645c89b6..6b7788c1405a9be7854e8af56382b8d47c24c12f 100644 (file)
@@ -432,15 +432,13 @@ VG_STATIC void player__walk_update( player_instance *player )
    v3_muls( right_dir,  walk[0], movedir );
    v3_muladds( movedir, forward_dir, walk[1], movedir );
 
-   if( w->state.activity == k_walk_activity_ground )
-   {
+   if( w->state.activity == k_walk_activity_ground ){
       v3_normalize( surface_avg );
 
       v3f tx, ty;
       rb_tangent_basis( surface_avg, tx, ty );
 
-      if( v2_length2(walk) > 0.001f )
-      {
+      if( v2_length2(walk) > 0.001f ){
          /* clip movement to the surface */
          float d = v3_dot(surface_avg,movedir);
          v3_muladds( movedir, surface_avg, -d, movedir );
@@ -450,30 +448,25 @@ VG_STATIC void player__walk_update( player_instance *player )
       nominal_speed = k_walkspeed;
 
       /* jump */
-      if( player->input_jump->button.value )
-      {
+      if( player->input_jump->button.value ){
          v3_muladds( player->rb.v, player->basis[1], 5.0f, player->rb.v );
          w->state.activity = k_walk_activity_air;
          accel_speed = k_walk_air_accel;
          nominal_speed = k_airspeed;
       }
-      else
-      {
+      else{
          player_friction( player->rb.v );
 
-         struct world_material *surface_mat = 
-                                       world_contact_material( world, manifold);
-         w->surface = surface_mat->info.surface_prop;
+         struct world_surface *surf = world_contact_surface( world, manifold );
+         w->surface = surf->info.surface_prop;
       }
    }
-   else
-   {
+   else{
       accel_speed = k_walk_air_accel;
       nominal_speed = k_airspeed;
    }
 
-   if( v2_length2(walk) > 0.001f )
-   {
+   if( v2_length2(walk) > 0.001f ){
       player_accelerate( player->rb.v, movedir, nominal_speed, accel_speed );
       v3_normalize( movedir );
    }
@@ -481,10 +474,8 @@ VG_STATIC void player__walk_update( player_instance *player )
    /*
     * Resolve velocity constraints
     */
-   for( int j=0; j<5; j++ )
-   {
-      for( int i=0; i<len; i++ )
-      {
+   for( int j=0; j<5; j++ ){
+      for( int i=0; i<len; i++ ){
          struct contact *ct = &manifold[i];
          
          /*normal */
@@ -580,10 +571,9 @@ VG_STATIC void player__walk_update( player_instance *player )
       }
    }
 
-   struct gate_hit hit;
-   if( world_intersect_gates(world, player->rb.co, w->state.prev_pos, &hit) )
-   {
-      teleport_gate *gate = hit.gate;
+   ent_gate *gate = 
+      world_intersect_gates( world, player->rb.co, w->state.prev_pos );
+   if( gate ){
       m4x3_mulv( gate->transport, player->rb.co, player->rb.co );
       m3x3_mulv( gate->transport, player->rb.v,  player->rb.v );
 
@@ -594,7 +584,7 @@ VG_STATIC void player__walk_update( player_instance *player )
       rb_update_transform( &player->rb );
 
       w->state_gate_storage = w->state;
-      player__pass_gate( player, &hit );
+      player__pass_gate( player, gate );
    }
 }