- if( player.on_board )
- player_physics();
- else
- player_walk_physics();
-
- /* Integrate velocity */
- v3f prevco;
- v3_copy( player.rb.co, prevco );
-
- apply_gravity( player.rb.v, ktimestep );
- v3_muladds( player.rb.co, player.rb.v, ktimestep, player.rb.co );
-
- /* Real angular velocity integration */
- v3_lerp( player.rb.w, (v3f){0.0f,0.0f,0.0f}, 0.125f, player.rb.w );
- if( v3_length2( player.rb.w ) > 0.0f )
- {
- v4f rotation;
- v3f axis;
- v3_copy( player.rb.w, axis );
-
- float mag = v3_length( axis );
- v3_divs( axis, mag, axis );
- q_axis_angle( rotation, axis, mag*k_rb_delta );
- q_mul( rotation, player.rb.q, player.rb.q );
- }
-
- /* Faux angular velocity */
- v4f rotate;
-
- static float siY = 0.0f;
- float lerpq = player.in_air? 0.04f: 0.3f;
- siY = vg_lerpf( siY, player.iY, lerpq );
-
- q_axis_angle( rotate, player.rb.up, siY );
- q_mul( rotate, player.rb.q, player.rb.q );
- player.iY = 0.0f;
-
- /*
- * Gate intersection, by tracing a line over the gate planes
- */
- for( int i=0; i<world.routes.gate_count; i++ )
- {
- struct route_gate *rg = &world.routes.gates[i];
- teleport_gate *gate = &rg->gate;
-
- if( gate_intersect( gate, player.rb.co, prevco ) )
- {
- m4x3_mulv( gate->transport, player.rb.co, player.rb.co );
- m3x3_mulv( gate->transport, player.rb.v, player.rb.v );
- m3x3_mulv( gate->transport, player.vl, player.vl );
- m3x3_mulv( gate->transport, player.v_last, player.v_last );
- m3x3_mulv( gate->transport, player.m, player.m );
- m3x3_mulv( gate->transport, player.bob, player.bob );
-
- v4f transport_rotation;
- m3x3_q( gate->transport, transport_rotation );
- q_mul( transport_rotation, player.rb.q, player.rb.q );
-
- world_routes_activate_gate( i );
- player.rb_gate_frame = player.rb;
-
- m3x3_copy( player.vr, player.gate_vr_frame );
- m3x3_copy( player.vr_pstep, player.gate_vr_pstep_frame );
- break;
- }
- }
-
- rb_update_transform( &player.rb );