static float
k_walkspeed = 2.0f,
k_board_radius = 0.3f,
- k_board_length = 0.55f,
+ k_board_length = 0.45f,
k_board_allowance = 0.04f,
- k_friction_lat = 8.68f,
- k_friction_resistance = 0.02f,
+ k_friction_lat = 8.8f,
+ k_friction_resistance = 0.01f,
k_max_push_speed = 16.0f,
k_push_accel = 5.0f,
k_push_cycle_rate = 8.0f,
k_steer_ground = 2.5f,
k_steer_air = 3.6f,
k_steer_air_lerp = 0.3f,
+ k_pump_force = 000.0f,
k_downforce = 5.0f;
static int freecam = 0;
static struct gplayer
{
/* Physics */
- rigidbody rb, collide_front, collide_back;
+ rigidbody rb, collide_front, collide_back, rb_gate_frame;
v3f a, v_last, m, bob, vl;
player.in_air = 1;
float pstep = ktimestep*10.0f;
-
- float best_velocity_mod = 0.0f,
- best_velocity_delta = -9999.9f;
-
+ float best_velocity_delta = -9999.9f;
float k_bias = 0.96f;
v3f axis;
if( (land_delta < 0.0f) && (land_delta > best_velocity_delta) )
{
best_velocity_delta = land_delta;
- best_velocity_mod = vmod;
v3_copy( contact.pos, player.land_target );
for( int i=0; i<5; i++ )
{
vel[2] = stable_force( vel[2], vg_signf( vel[2] ) * fwd_resistance );
- vel[0] = stable_force( vel[0], vg_signf( vel[0] ) * -8.78f *substep );
+ vel[0] = stable_force( vel[0],
+ vg_signf( vel[0] ) * -k_friction_lat*substep );
}
static double start_push = 0.0;
new_vel -= vg_minf(current, k_max_push_speed);
vel[2] -= new_vel * player.reverse;
}
+
+ /* Pumping */
+ static float previous = 0.0f;
+ float delta = previous - player.grab,
+ pump = delta * k_pump_force*ktimestep;
+ previous = player.grab;
+
+ v3f p1;
+ v3_muladds( player.rb.co, player.rb.up, pump, p1 );
+ vg_line( player.rb.co, p1, 0xff0000ff );
+
+ vel[1] += pump;
+
m3x3_mulv( player.rb.to_world, vel, player.rb.v );
m3x3_copy( player.rb.to_world, player.collide_front.to_world );
m3x3_copy( player.rb.to_world, player.collide_back.to_world );
- m4x3_mulv( player.rb.to_world, (v3f){0.0f,0.0f,-k_board_length}, rbf->co );
+
+ player.air_blend = vg_lerpf( player.air_blend, player.in_air, 0.1f );
+ float h = player.air_blend*0.2f;
+
+ m4x3_mulv( player.rb.to_world, (v3f){0.0f,h,-k_board_length}, rbf->co );
v3_copy( rbf->co, rbf->to_world[3] );
- m4x3_mulv( player.rb.to_world, (v3f){0.0f,0.0f, k_board_length}, rbb->co );
+ m4x3_mulv( player.rb.to_world, (v3f){0.0f,h, k_board_length}, rbb->co );
v3_copy( rbb->co, rbb->to_world[3] );
m4x3_invert_affine( rbf->to_world, rbf->to_local );
len += rb_sphere_vs_scene( rbf, &world.rb_geo, manifold+len );
len += rb_sphere_vs_scene( rbb, &world.rb_geo, manifold+len );
-#if 0
- for( int i=0; i<len; i++ )
- {
- u32 *ptri = &world.geo.indices[ geo[i]*3 ];
-
- for( int j=0; j<3; j++ )
- v3_copy( world.geo.verts[ptri[j]].co, tri[j] );
-
- vg_line(tri[0],tri[1],0xff00ff00 );
- vg_line(tri[1],tri[2],0xff00ff00 );
- vg_line(tri[2],tri[0],0xff00ff00 );
-
- v3f temp;
- v3_copy( player.rb.co, temp );
-
- for( int j=0; j<2; j++ )
- {
- if(manifold_count >= vg_list_size(manifold))
- {
- vg_error("Manifold overflow!\n");
- break;
- }
-
- rb_ct *ct = &manifold[manifold_count];
- v3_copy( poles[j], player.rb.co );
-
- manifold_count += rb_sphere_vs_triangle( &player.rb, tri, ct );
- }
-
- v3_copy( temp, player.rb.co );
- }
-#endif
-
rb_presolve_contacts( manifold, len );
v3f surface_avg = {0.0f, 0.0f, 0.0f};
else
{
for( int i=0; i<len; i++ )
+ {
v3_add( manifold[i].n, surface_avg, surface_avg );
+#if 0
+ if( manifold[i].element_id <= world.sm_geo_std_oob.vertex_count )
+ {
+ player.is_dead = 1;
+ character_ragdoll_copypose( &player.mdl, player.rb.v );
+ return;
+ }
+#endif
+ }
+
v3_normalize( surface_avg );
if( v3_dot( player.rb.v, surface_avg ) > 0.5f )
}
}
+ float grabt = vg_get_axis( "grabr" )*0.5f+0.5f;
+ player.grab = vg_lerpf( player.grab, grabt, 0.14f );
+
if( !player.in_air )
{
v3f axis;
float angle = v3_dot( player.rb.up, surface_avg );
v3_cross( player.rb.up, surface_avg, axis );
- float cz = v3_dot( player.rb.forward, axis );
- v3_muls( player.rb.forward, cz, axis );
+ //float cz = v3_dot( player.rb.forward, axis );
+ //v3_muls( player.rb.forward, cz, axis );
if( angle < 0.999f )
{
/*
* Gate intersection, by tracing a line over the gate planes
*/
- for( int i=0; i<world.gate_count; i++ )
+ for( int i=0; i<world.routes.gate_count; i++ )
{
- teleport_gate *gate = &world.gates[i];
+ struct route_gate *rg = &world.routes.gates[i];
+ teleport_gate *gate = &rg->gate;
if( gate_intersect( gate, player.rb.co, prevco ) )
{
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;
break;
}
}
pa[0] = wg->region[0][0] + (float)wg->cell_id[0] *k_gridscale;
pa[1] = (wg->region[0][1] + wg->region[1][1]) * 0.5f + k_gridscale;
pa[2] = wg->region[0][2] + (float)wg->cell_id[1] *k_gridscale;
+#if 0
pb[0] = pa[0];
pb[1] = pa[1];
pb[2] = pa[2] + k_gridscale;
pd[0] = pa[0] + k_gridscale;
pd[1] = pa[1];
pd[2] = pa[2];
-#if 0
/* if you want to draw the current cell */
vg_line( pa, pb, 0xff00ffff );
vg_line( pb, pc, 0xff00ffff );
/* Head */
float lslip = fabsf(player.slip);
-
- float grabt = vg_get_axis( "grabr" )*0.5f+0.5f;
- player.grab = vg_lerpf( player.grab, grabt, 0.04f );
float kheight = 2.0f,
kleg = 0.6f;
v3f offset;
+ v3_zero( offset );
m3x3_mulv( player.rb.to_local, player.bob, offset );
static float speed_wobble = 0.0f, speed_wobble_2 = 0.0f;
offset[0] = vg_clampf( offset[0], -0.8f, 0.8f );
offset[1] = vg_clampf( offset[1], -0.5f, 0.0f );
+ /*
+ * Player rotation
+ */
+#if 0
+ float angle = v3_dot( player.rb.up, (v3f){0.0f,1.0f,0.0f} );
+ v3f axis;
+ v3_cross( player.rb.up, (v3f){0.0f,1.0f,0.0f}, axis );
+
+ v4f correction;
+ if( angle < 0.99f && 0 )
+ {
+ m3x3_mulv( player.rb.to_local, axis, axis );
+ q_axis_angle( correction, axis, acosf(angle) );
+ }
+ else
+ {
+ q_identity( correction );
+ }
/*
* Animation blending
* ===========================================
*/
+#endif
static float fslide = 0.0f;
static float fdirz = 0.0f;
character_final_pose( &player.mdl, offset,
&pose_slide1, amt_slide*(1.0f-fdirx) );
- character_final_pose( &player.mdl, (v3f){0.0f,0.0f,0.0f},
+ character_final_pose( &player.mdl, (v4f){0.0f,0.0f,0.0f,1.0f},
&pose_fly, amt_air );
/*
rb_update_transform( &player.rb );
m3x3_mulv( player.rb.to_world, (v3f){ 0.0f, 0.0f, -1.2f }, player.rb.v );
+
+ player.rb_gate_frame = player.rb;
return 1;
}
player.land_target_colours[i], 0.25f);
if( vg_get_axis("grabl")>0.0f)
- reset_player(0,NULL);
+ {
+ player.rb = player.rb_gate_frame;
+ player.is_dead = 0;
+ player.in_air = 1;
+ m3x3_identity( player.vr );
+
+ player.mdl.shoes[0] = 1;
+ player.mdl.shoes[1] = 1;
+ }
if( vg_get_button_down( "switchmode" ) )
{