}
static int push_thresh_last = 0;
- float push = player.input_push->axis.value;
+ float push = player.input_push->button.value;
int push_thresh = push>0.15f? 1: 0;
if( push_thresh && !push_thresh_last )
v3f forward_dir = { sinf(player.angles[0]),0.0f,-cosf(player.angles[0]) };
v3f right_dir = { -forward_dir[2], 0.0f, forward_dir[0] };
+ v2f walk = { player.input_walkh->axis.value,
+ player.input_walkv->axis.value };
+
+ if( v2_length2(walk) > 0.001f )
+ v2_normalize_clamp( walk );
+
if( phys->in_air )
{
player_walk_update_collision();
rb_debug( rbf, 0xff0000ff );
rb_debug( rbb, 0xff0000ff );
+ /* allow player to accelerate a bit */
+ v3f walk_3d;
+ v3_muls( forward_dir, walk[1], walk_3d );
+ v3_muladds( walk_3d, right_dir, walk[0], walk_3d );
+
+ float current_vel = fabsf(v3_dot( walk_3d, phys->rb.v )),
+ new_vel = current_vel + VG_TIMESTEP_FIXED*k_air_accelerate,
+ clamped_new = vg_clampf( new_vel, 0.0f, k_walkspeed ),
+ vel_diff = vg_maxf( 0.0f, clamped_new - current_vel );
+
+ v3_muladds( phys->rb.v, right_dir, walk[0] * vel_diff, phys->rb.v );
+ v3_muladds( phys->rb.v, forward_dir, walk[1] * vel_diff, phys->rb.v );
+
+
len = 0;
len += rb_sphere_scene( rbf, &world.rb_geo, manifold+len );
len += rb_sphere_scene( rbb, &world.rb_geo, manifold+len );
}
else
{
- /* translate player */
- v2f walk = { player.input_walkh->axis.value,
- player.input_walkv->axis.value };
-
- if( v2_length2(walk) > 0.001f )
- v2_normalize( walk );
+ player.walk = v2_length( walk );
+
+ if( player.input_walk->button.value )
+ v2_muls( walk, 0.5f, walk );
- v2_muls( walk, vg_maxf( player.input_push->axis.value, 0.5f ) *
- k_walkspeed * VG_TIMESTEP_FIXED, walk );
+ v2_muls( walk, k_walkspeed * VG_TIMESTEP_FIXED, walk );
v3f walk_apply;
v3_zero( walk_apply );
len += rb_sphere_scene( rbf, &world.rb_geo, manifold+len );
len += rb_sphere_scene( rbb, &world.rb_geo, manifold+len );
+ /*
+ * Preprocess collision points, and create a surface picture.
+ * we want contacts that are within our 'capsule's internal line to be
+ * clamped so that they face the line and do not oppose, to stop the
+ * player hanging up on stuff
+ */
+ for( int i=0; i<len; i++ )
+ {
+ v3f dfront, dback;
+ v3_sub( manifold[i].co, rbf->co, dfront );
+ v3_sub( manifold[i].co, rbb->co, dback );
+
+ if( (v3_dot( dfront, phys->rb.forward ) < -0.02f) &&
+ (v3_dot( dback, phys->rb.forward ) > 0.02f))
+ {
+ float p = v3_dot( manifold[i].n, phys->rb.forward );
+ v3_muladds( manifold[i].n, phys->rb.forward, -p, manifold[i].n );
+ v3_normalize( manifold[i].n );
+ }
+ }
+
rb_presolve_contacts( manifold, len );
v3f surface_avg = {0.0f, 0.0f, 0.0f};
m3x3_mulv( camera_mtx, sidedir, sidedir );
static v3f move_vel = { 0.0f, 0.0f, 0.0f };
+
+ /* TODO */
+#if 0
if( vg_get_button( "forward" ) )
v3_muladds( move_vel, lookdir, VG_TIMESTEP_FIXED * movespeed, move_vel );
if( vg_get_button( "back" ) )
v3_muladds( move_vel, sidedir, VG_TIMESTEP_FIXED *-movespeed, move_vel );
if( vg_get_button( "right" ) )
v3_muladds( move_vel, sidedir, VG_TIMESTEP_FIXED * movespeed, move_vel );
+#endif
v3_muls( move_vel, 0.7f, move_vel );
v3_add( move_vel, player.camera_pos, player.camera_pos );