X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=player_physics.h;h=b93ac0394b32aa8211cc0f7490b2134fa5cbd5c7;hb=88b191de24adac2a2f9aa57d001dcf17e12f788e;hp=bc1434c66f801f8e37881ee4ab68c91634a4079f;hpb=06e35432f5cf2b4e9ad2f537393511867f64d29a;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/player_physics.h b/player_physics.h index bc1434c..b93ac03 100644 --- a/player_physics.h +++ b/player_physics.h @@ -521,6 +521,7 @@ static void player_physics(void) if( !phys->in_air ) { +#if 0 v3f axis; float angle = v3_dot( phys->rb.up, surface_avg ); v3_cross( phys->rb.up, surface_avg, axis ); @@ -534,6 +535,34 @@ static void player_physics(void) q_axis_angle( correction, axis, acosf(angle)*18.0f*VG_TIMESTEP_FIXED ); q_mul( correction, phys->rb.q, phys->rb.q ); } +#else + + /* 20/10/22: make this only go axisways instead, may effect velocities. */ + + v3f projected, axis; + + float d = v3_dot( phys->rb.forward, surface_avg ); + v3_muladds( surface_avg, phys->rb.forward, -d, projected ); + v3_normalize( projected ); + + float angle = v3_dot( phys->rb.up, projected ); + v3_cross( phys->rb.up, projected, axis ); + + v3f p0, p1; + v3_add( phys->rb.co, projected, p0 ); + v3_add( phys->rb.co, phys->rb.up, p1 ); + vg_line( phys->rb.co, p0, 0xff00ff00 ); + vg_line( phys->rb.co, p1, 0xff000fff ); + + if( fabsf(angle) < 0.999f ) + { + v4f correction; + q_axis_angle( correction, axis, acosf(angle)*4.0f*VG_TIMESTEP_FIXED ); + q_mul( correction, phys->rb.q, phys->rb.q ); + } + + +#endif float const DOWNFORCE = -k_downforce*VG_TIMESTEP_FIXED; v3_muladds( phys->rb.v, phys->rb.up, DOWNFORCE, phys->rb.v ); @@ -683,6 +712,8 @@ static void player_do_motion(void) player.angles[0] = atan2f( fwd_dir[2], fwd_dir[0] ); } + player.rewind_length = 0; + player.rewind_incrementer = 10000; player_save_frame(); audio_lock();