From: hgn Date: Sat, 27 May 2023 05:22:58 +0000 (+0100) Subject: fix long standing grind bug X-Git-Url: https://harrygodden.com/git/?a=commitdiff_plain;h=d43d7f62ff83799b6d99221d881179814cb239a6;p=carveJwlIkooP6JGAAIwe30JlM.git fix long standing grind bug --- diff --git a/models_src/ch_jordan.mdl b/models_src/ch_jordan.mdl index 5d12a1a..67eea24 100644 Binary files a/models_src/ch_jordan.mdl and b/models_src/ch_jordan.mdl differ diff --git a/models_src/ch_new.mdl b/models_src/ch_new.mdl index 4e6b96f..aa3472f 100644 Binary files a/models_src/ch_new.mdl and b/models_src/ch_new.mdl differ diff --git a/models_src/ch_outlaw.mdl b/models_src/ch_outlaw.mdl index 04ac794..8bc115e 100644 Binary files a/models_src/ch_outlaw.mdl and b/models_src/ch_outlaw.mdl differ diff --git a/player_skate.c b/player_skate.c index f2a1cd0..87c8cba 100644 --- a/player_skate.c +++ b/player_skate.c @@ -103,8 +103,7 @@ VG_STATIC int skate_grind_scansq( player_instance *player, v3_add( pos, (v3f){ r, r, r }, box[1] ); v3_sub( pos, (v3f){ r, r, r }, box[0] ); - struct grind_sample - { + struct grind_sample{ v2f co; v2f normal; v3f normal3, @@ -234,10 +233,8 @@ too_many_samples: float yi = v3_dot( player->basis[1], si->normal3 ), yj = v3_dot( player->basis[1], sj->normal3 ); - if( yi > yj ) - v3_add( si->normal3, average_normal, average_normal ); - else - v3_add( sj->normal3, average_normal, average_normal ); + if( yi > yj ) v3_add( si->normal3, average_normal, average_normal ); + else v3_add( sj->normal3, average_normal, average_normal ); passed_samples ++; } @@ -1666,6 +1663,10 @@ VG_STATIC void skate_5050_apply( player_instance *player, v3_muladds( inf_back->co, inf_avg.dir, 0.5f, inf_avg.co ); v3_normalize( inf_avg.dir ); + /* dont ask */ + v3_muls( inf_avg.dir, vg_signf(v3_dot(inf_avg.dir,player->rb.v)), + inf_avg.dir ); + v3f axis_front, axis_back, axis; v3_cross( inf_front->dir, inf_front->n, axis_front ); v3_cross( inf_back->dir, inf_back->n, axis_back ); @@ -1694,6 +1695,8 @@ VG_STATIC void skate_5050_apply( player_instance *player, k_grind_spring, k_grind_dampener, k_rb_delta ); + vg_line_arrow( player->rb.co, up, 1.0f, VG__GREEN ); + vg_line_arrow( player->rb.co, target_up, 1.0f, VG__GREEN ); v3f fwd_nplane, dir_nplane; v3_muladds( player->rb.to_world[2], inf_avg.n, @@ -1710,6 +1713,8 @@ VG_STATIC void skate_5050_apply( player_instance *player, 1000.0f, k_grind_dampener, k_rb_delta ); + vg_line_arrow( player->rb.co, fwd_nplane, 0.8f, VG__RED ); + vg_line_arrow( player->rb.co, dir_nplane, 0.8f, VG__RED ); v3f pos_front = { 0.0f, -k_board_radius, -1.0f * k_board_length }, pos_back = { 0.0f, -k_board_radius, 1.0f * k_board_length }, diff --git a/rigidbody.h b/rigidbody.h index b3bd442..b1dc834 100644 --- a/rigidbody.h +++ b/rigidbody.h @@ -2229,7 +2229,7 @@ VG_STATIC void rb_effect_spring_target_vector( rigidbody *rba, v3f ra, v3f rt, float timestep ) { float d = v3_dot( rt, ra ); - float a = vg_signf( d ) * acosf( vg_clampf( d, -1.0f, 1.0f ) ); + float a = acosf( vg_clampf( d, -1.0f, 1.0f ) ); v3f axis; v3_cross( rt, ra, axis );