fix long standing grind bug
authorhgn <hgodden00@gmail.com>
Sat, 27 May 2023 05:22:58 +0000 (06:22 +0100)
committerhgn <hgodden00@gmail.com>
Sat, 27 May 2023 05:22:58 +0000 (06:22 +0100)
models_src/ch_jordan.mdl
models_src/ch_new.mdl
models_src/ch_outlaw.mdl
player_skate.c
rigidbody.h

index 5d12a1a38d589bca0661fdbc6c646e7f12cdef10..67eea2457079bdc120101b816d582f63c0b17b16 100644 (file)
Binary files a/models_src/ch_jordan.mdl and b/models_src/ch_jordan.mdl differ
index 4e6b96ff663ec4c01f347ab380f7746f3b9f8de8..aa3472fa657eb4e3a4abce327e8acfc192940e09 100644 (file)
Binary files a/models_src/ch_new.mdl and b/models_src/ch_new.mdl differ
index 04ac7945aed6b38d3ecb0256b30338b302fec05c..8bc115e872834960edc1b64f34b5997ff738880e 100644 (file)
Binary files a/models_src/ch_outlaw.mdl and b/models_src/ch_outlaw.mdl differ
index f2a1cd0feffda829eed9ed87d7cee6c8a899f7ed..87c8cba7483e9ea22e07e042b967e34189eb4309 100644 (file)
@@ -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 },
index b3bd4425cb6d493e5a89c7465325891b133eaac5..b1dc834a76ab710d046ec99f729de9da1703d955 100644 (file)
@@ -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 );