to the workers of the world
authorhgn <hgodden00@gmail.com>
Fri, 31 Mar 2023 02:18:22 +0000 (03:18 +0100)
committerhgn <hgodden00@gmail.com>
Fri, 31 Mar 2023 02:18:22 +0000 (03:18 +0100)
15 files changed:
audio.h
blender_export.py
maps_src/mp_gridmap.mdl
player_common.c
player_dead.c
player_ragdoll.h
player_skate.c
player_skate.h
rigidbody.h
skaterift.c
sound_src/hit0.ogg [new file with mode: 0644]
sound_src/hit1.ogg [new file with mode: 0644]
sound_src/hit2.ogg [new file with mode: 0644]
sound_src/hit3.ogg [new file with mode: 0644]
sound_src/hit4.ogg [new file with mode: 0644]

diff --git a/audio.h b/audio.h
index 3504ed21e441432766fec67b5f02a6eba2153952..b3640bda8a386dc3cdf88bde89468ddbd3bfc073 100644 (file)
--- a/audio.h
+++ b/audio.h
@@ -35,6 +35,15 @@ audio_clip audio_taps[] =
    { .path="sound/tap3.ogg" }
 };
 
    { .path="sound/tap3.ogg" }
 };
 
+audio_clip audio_hits[] =
+{
+   { .path="sound/hit0.ogg" },
+   { .path="sound/hit1.ogg" },
+   { .path="sound/hit2.ogg" },
+   { .path="sound/hit3.ogg" },
+   { .path="sound/hit4.ogg" }
+};
+
 audio_clip audio_splash =
 { .path = "sound/splash.ogg" };
 
 audio_clip audio_splash =
 { .path = "sound/splash.ogg" };
 
@@ -206,6 +215,7 @@ VG_STATIC void audio_init(void)
 
    audio_clip_loadn( audio_board, vg_list_size(audio_board), NULL );
    audio_clip_loadn( audio_taps, vg_list_size(audio_taps), NULL );
 
    audio_clip_loadn( audio_board, vg_list_size(audio_board), NULL );
    audio_clip_loadn( audio_taps, vg_list_size(audio_taps), NULL );
+   audio_clip_loadn( audio_hits, vg_list_size(audio_hits), NULL );
    audio_clip_loadn( audio_ambience, vg_list_size(audio_ambience), NULL );
    audio_clip_loadn( &audio_splash, 1, NULL );
    audio_clip_loadn( &audio_gate_pass, 1, NULL );
    audio_clip_loadn( audio_ambience, vg_list_size(audio_ambience), NULL );
    audio_clip_loadn( &audio_splash, 1, NULL );
    audio_clip_loadn( &audio_gate_pass, 1, NULL );
index 721bba6962b4fd5bc3ecc27d0a984761acde58c1..3b3f5cd9393f28fc995c555944426b0d2bdb3266 100644 (file)
@@ -1741,7 +1741,8 @@ class SR_MATERIAL_PROPERTIES(bpy.types.PropertyGroup):
       ('0','concrete',''),
       ('1','wood',''),
       ('2','grass',''),
       ('0','concrete',''),
       ('1','wood',''),
       ('2','grass',''),
-      ('3','tiles','')
+      ('3','tiles',''),
+      ('4','metal','')
       ])
    
    collision: bpy.props.BoolProperty( \
       ])
    
    collision: bpy.props.BoolProperty( \
index 5ad866944e229a4c0d9482ee000a025130064774..2f44b2153fcbaeeb307db0492f562e060a2bc498 100644 (file)
Binary files a/maps_src/mp_gridmap.mdl and b/maps_src/mp_gridmap.mdl differ
index bf049012878a1427e58b125480d5dc14cd51b549..a7c42035af4c62c0734a0df048dda5d07be1493f 100644 (file)
@@ -69,7 +69,7 @@ VG_STATIC void player__cam_iterate( player_instance *player )
       v3_copy( (v3f){0.0f,1.4f,0.0f}, player->tpv_offset );
    }
    else{
       v3_copy( (v3f){0.0f,1.4f,0.0f}, player->tpv_offset );
    }
    else{
-      v3_copy( (v3f){-0.15f,1.7f,0.0f}, player->fpv_viewpoint );
+      v3_copy( (v3f){-0.15f,1.75f,0.0f}, player->fpv_viewpoint );
 #if 0
       v3_copy( (v3f){-0.35f,0.0f,0.0f}, player->fpv_offset );
 #endif
 #if 0
       v3_copy( (v3f){-0.35f,0.0f,0.0f}, player->fpv_offset );
 #endif
index f040adb47c55309f74b83615e2e100b78acccbc6..da23487d2546d4b5dcd086a8dc20870f1ff189e0 100644 (file)
@@ -14,8 +14,7 @@ VG_STATIC void player__dead_animate     ( player_instance *player,
    v3_zero( anim->root_co );
    q_identity( anim->root_q );
    
    v3_zero( anim->root_co );
    q_identity( anim->root_q );
    
-   for( int i=0; i<vg_list_size( anim->pose ); i ++ )
-   {
+   for( int i=0; i<vg_list_size( anim->pose ); i ++ ){
       v3_zero( anim->pose[i].co );
       v3_fill( anim->pose[i].s, 1.0f );
       q_identity( anim->pose[i].q );
       v3_zero( anim->pose[i].co );
       v3_fill( anim->pose[i].s, 1.0f );
       q_identity( anim->pose[i].q );
index 3fd552471001449920d1fe49d589f5add73352d9..497aedd09b87b349b5e29113864033074fd6620e 100644 (file)
@@ -7,6 +7,7 @@
 #include "rigidbody.h"
 #include "player_model.h"
 #include "world.h"
 #include "rigidbody.h"
 #include "player_model.h"
 #include "world.h"
+#include "audio.h"
 
 struct player_ragdoll
 {
 
 struct player_ragdoll
 {
@@ -219,6 +220,22 @@ VG_STATIC void copy_ragdoll_pose_to_avatar( struct player_ragdoll *rd,
                   av->sk.final_mtx[part->bone_id] );
    }
 
                   av->sk.final_mtx[part->bone_id] );
    }
 
+   for( u32 i=1; i<av->sk.bone_count; i++ ){
+      struct skeleton_bone *sb = &av->sk.bones[i];
+
+      if( sb->parent && !sb->collider ){
+         v3f delta;
+         v3_sub( av->sk.bones[i].co, av->sk.bones[sb->parent].co, delta );
+
+         m4x3f posemtx;
+         m3x3_identity( posemtx );
+         v3_copy( delta, posemtx[3] );
+
+         /* final matrix */
+         m4x3_mul( av->sk.final_mtx[sb->parent], posemtx, av->sk.final_mtx[i] );
+      }
+   }
+
    skeleton_apply_inverses( &av->sk );
 }
 
    skeleton_apply_inverses( &av->sk );
 }
 
@@ -273,6 +290,9 @@ VG_STATIC void player_ragdoll_iter( struct player_ragdoll *rd )
    }
 
    rb_solver_reset();
    }
 
    rb_solver_reset();
+   
+   float contact_velocities[256];
+
    for( int i=0; i<rd->part_count; i ++ ){
       if( rb_global_has_space() ){
          rb_ct *buf = rb_global_buffer();
    for( int i=0; i<rd->part_count; i ++ ){
       if( rb_global_has_space() ){
          rb_ct *buf = rb_global_buffer();
@@ -346,6 +366,18 @@ VG_STATIC void player_ragdoll_iter( struct player_ragdoll *rd )
    /*
     * PRESOLVE
     */
    /*
     * PRESOLVE
     */
+   for( u32 i=0; i<rb_contact_count; i++ ){
+      rb_ct *ct = &rb_contact_buffer[i];
+
+      v3f rv, ra, rb;
+      v3_sub( ct->co, ct->rba->co, ra );
+      v3_sub( ct->co, ct->rbb->co, rb );
+      rb_rcv( ct->rba, ct->rbb, ra, rb, rv );
+      float     vn = v3_dot( rv, ct->n );
+
+      contact_velocities[i] = vn;
+   }
+
    rb_presolve_contacts( rb_contact_buffer, rb_contact_count );
    rb_presolve_swingtwist_constraints( rd->cone_constraints,
                                        rd->cone_constraints_count );
    rb_presolve_contacts( rb_contact_buffer, rb_contact_count );
    rb_presolve_swingtwist_constraints( rd->cone_constraints,
                                        rd->cone_constraints_count );
@@ -391,6 +423,38 @@ VG_STATIC void player_ragdoll_iter( struct player_ragdoll *rd )
                                        rd->position_constraints_count, 0.5f );
    }
 
                                        rd->position_constraints_count, 0.5f );
    }
 
+   rb_ct *stress = NULL;
+   float max_stress = 1.0f;
+
+   for( u32 i=0; i<rb_contact_count; i++ ){
+      rb_ct *ct = &rb_contact_buffer[i];
+
+      v3f rv, ra, rb;
+      v3_sub( ct->co, ct->rba->co, ra );
+      v3_sub( ct->co, ct->rbb->co, rb );
+      rb_rcv( ct->rba, ct->rbb, ra, rb, rv );
+      float     vn = v3_dot( rv, ct->n );
+
+      float s = fabsf(vn - contact_velocities[i]);
+      if( s > max_stress ){
+         stress = ct;
+         max_stress = s;
+      }
+   }
+
+   static u32 temp_filter = 0;
+
+   if( temp_filter ){
+      temp_filter --;
+      return;
+   }
+
+   if( stress ){
+      temp_filter = 20;
+      audio_lock();
+      audio_oneshot_3d( &audio_hits[rand()%5], stress->co, 20.0f, 1.0f );
+      audio_unlock();
+   }
 }
 
 #endif /* PLAYER_RAGDOLL_H */
 }
 
 #endif /* PLAYER_RAGDOLL_H */
index 8535540b52807c2a6ce9419d91ebff5d3bc6aa4a..af41d53b99cbd6cf90a594f2e088a760445ad27f 100644 (file)
@@ -522,6 +522,7 @@ void player__approximate_best_trajectory( player_instance *player )
                if( (fabsf(v3_dot( ve, grind.dir ))>=k_grind_axel_min_vel) &&
                    (a >= a_min) )
                {
                if( (fabsf(v3_dot( ve, grind.dir ))>=k_grind_axel_min_vel) &&
                    (a >= a_min) )
                {
+                  vg_success( "ding\n" );
                   grind_located = 1;
                   grind_located_gravity = inf->gravity;
                }
                   grind_located = 1;
                   grind_located_gravity = inf->gravity;
                }
@@ -2555,7 +2556,7 @@ begin_collision:;
       rb_ct *ct = &manifold[i];
       struct world_surface *surf = world_contact_surface( world, ct );
 
       rb_ct *ct = &manifold[i];
       struct world_surface *surf = world_contact_surface( world, ct );
 
-      if( surf->info.surface_prop != k_surface_prop_concrete )
+      if( surf->info.surface_prop > s->surface )
          s->surface = surf->info.surface_prop;
    }
 
          s->surface = surf->info.surface_prop;
    }
 
@@ -2598,23 +2599,36 @@ begin_collision:;
    /* FIXME: Rate limit */
    static int stick_frames = 0;
 
    /* FIXME: Rate limit */
    static int stick_frames = 0;
 
-   if( s->state.activity == k_skate_activity_ground )
+   if( s->state.activity >= k_skate_activity_ground )
       stick_frames ++;
    else
       stick_frames = 0;
 
       stick_frames ++;
    else
       stick_frames = 0;
 
+   if( stick_frames >  5 ) stick_frames =  5;
 
    if( stick_frames == 4 ){
       audio_lock();
 
    if( stick_frames == 4 ){
       audio_lock();
-      if( (fabsf(s->state.slip) > 0.75f) ){
-         audio_oneshot_3d( &audio_lands[rand()%2+3], player->rb.co, 
-                           40.0f, 1.0f );
+
+      if( s->state.activity == k_skate_activity_ground ){
+         if( (fabsf(s->state.slip) > 0.75f) ){
+            audio_oneshot_3d( &audio_lands[rand()%2+3], player->rb.co, 
+                              40.0f, 1.0f );
+         }
+         else{
+            audio_oneshot_3d( &audio_lands[rand()%3], player->rb.co, 
+                              40.0f, 1.0f );
+         }
+      }
+      else if( s->surface == k_surface_prop_metal ){
+         audio_oneshot_3d( &audio_board[3], player->rb.co, 40.0f, 1.0f );
       }
       else{
       }
       else{
-         audio_oneshot_3d( &audio_lands[rand()%3], player->rb.co, 
-                           40.0f, 1.0f );
+         audio_oneshot_3d( &audio_board[8], player->rb.co, 40.0f, 1.0f );
       }
       }
+
       audio_unlock();
       audio_unlock();
+   } else if( stick_frames == 0 ){
+      
    }
 }
 
    }
 }
 
@@ -2639,6 +2653,7 @@ VG_STATIC void player__skate_im_gui( player_instance *player )
       "undefined (INVALID)",
       "grind_any (INVALID)",
       "grind_boardslide",
       "undefined (INVALID)",
       "grind_any (INVALID)",
       "grind_boardslide",
+      "grind_metallic (INVALID)",
       "grind_back50",
       "grind_front50",
       "grind_5050"
       "grind_back50",
       "grind_front50",
       "grind_5050"
@@ -3144,6 +3159,8 @@ VG_STATIC void player__skate_clear_mechanics( player_instance *player )
    v3_zero( s->state.trick_vel );
    v3_zero( s->state.trick_euler );
    v3_zero( s->state.cog_v );
    v3_zero( s->state.trick_vel );
    v3_zero( s->state.trick_euler );
    v3_zero( s->state.cog_v );
+   s->grind_cooldown = 0;
+   s->surface_cooldown = 0;
    v3_muladds( player->rb.co, player->rb.to_world[1], 1.0f, s->state.cog );
 }
 
    v3_muladds( player->rb.co, player->rb.to_world[1], 1.0f, s->state.cog );
 }
 
index 0f99fdbb8d3a87a0c9053e6560fbf90d441fa3c7..2b7c60e820893dd0bb9007ababc7286e43c24a8d 100644 (file)
@@ -19,6 +19,7 @@ struct player_skate
          k_skate_activity_undefined,
          k_skate_activity_grind_any,
          k_skate_activity_grind_boardslide,
          k_skate_activity_undefined,
          k_skate_activity_grind_any,
          k_skate_activity_grind_boardslide,
+         k_skate_activity_grind_metallic,
          k_skate_activity_grind_back50,
          k_skate_activity_grind_front50,
          k_skate_activity_grind_5050
          k_skate_activity_grind_back50,
          k_skate_activity_grind_front50,
          k_skate_activity_grind_5050
index dfacf36c63a3f02ee1b52e543651410988039b2d..0fcb894d089bd0204dc839df1f6cff263c06a7a2 100644 (file)
@@ -2208,8 +2208,7 @@ VG_STATIC void rb_depenetrate( rb_ct *manifold, int len, v3f dt )
  */
 VG_STATIC void rb_presolve_contacts( rb_ct *buffer, int len )
 {
  */
 VG_STATIC void rb_presolve_contacts( rb_ct *buffer, int len )
 {
-   for( int i=0; i<len; i++ )
-   {
+   for( int i=0; i<len; i++ ){
       rb_ct *ct = &buffer[i];
       rb_prepare_contact( ct, k_rb_delta );
 
       rb_ct *ct = &buffer[i];
       rb_prepare_contact( ct, k_rb_delta );
 
@@ -2229,8 +2228,7 @@ VG_STATIC void rb_presolve_contacts( rb_ct *buffer, int len )
       ct->normal_mass += v3_dot( rbCn, rbCnI );
       ct->normal_mass  = 1.0f/ct->normal_mass;
 
       ct->normal_mass += v3_dot( rbCn, rbCnI );
       ct->normal_mass  = 1.0f/ct->normal_mass;
 
-      for( int j=0; j<2; j++ )
-      {
+      for( int j=0; j<2; j++ ){
          v3f raCtI, rbCtI;
          v3_cross( ct->t[j], ra, raCt );
          v3_cross( ct->t[j], rb, rbCt );
          v3f raCtI, rbCtI;
          v3_cross( ct->t[j], ra, raCt );
          v3_cross( ct->t[j], rb, rbCt );
@@ -2282,8 +2280,7 @@ VG_STATIC void rb_linear_impulse( rigidbody *rb, v3f delta, v3f impulse )
  */
 VG_STATIC void rb_solve_contacts( rb_ct *buf, int len )
 {
  */
 VG_STATIC void rb_solve_contacts( rb_ct *buf, int len )
 {
-   for( int i=0; i<len; i++ )
-   {
+   for( int i=0; i<len; i++ ){
       struct contact *ct = &buf[i];
 
       v3f rv, ra, rb;
       struct contact *ct = &buf[i];
 
       v3f rv, ra, rb;
@@ -2292,8 +2289,7 @@ VG_STATIC void rb_solve_contacts( rb_ct *buf, int len )
       rb_rcv( ct->rba, ct->rbb, ra, rb, rv );
       
       /* Friction */
       rb_rcv( ct->rba, ct->rbb, ra, rb, rv );
       
       /* Friction */
-      for( int j=0; j<2; j++ )
-      {
+      for( int j=0; j<2; j++ ){
          float     f = k_friction * ct->norm_impulse,
                   vt = v3_dot( rv, ct->t[j] ),
               lambda = ct->tangent_mass[j] * -vt;
          float     f = k_friction * ct->norm_impulse,
                   vt = v3_dot( rv, ct->t[j] ),
               lambda = ct->tangent_mass[j] * -vt;
index e50c1e5bb2263147aab50a7490775b210d42e5d9..4b7323776dd406550ccc28e13caed317fb4da0f0 100644 (file)
@@ -22,7 +22,7 @@
 
 
 #include "player.h"
 
 
 #include "player.h"
-VG_STATIC player_instance localplayer;
+static player_instance localplayer;
 VG_STATIC struct player_avatar localplayer_avatar;
 VG_STATIC glmesh localplayer_meshes[3];
 vg_tex2d localplayer_texture = { .path = "textures/ch_gradient.qoi" };
 VG_STATIC struct player_avatar localplayer_avatar;
 VG_STATIC glmesh localplayer_meshes[3];
 vg_tex2d localplayer_texture = { .path = "textures/ch_gradient.qoi" };
diff --git a/sound_src/hit0.ogg b/sound_src/hit0.ogg
new file mode 100644 (file)
index 0000000..6627558
Binary files /dev/null and b/sound_src/hit0.ogg differ
diff --git a/sound_src/hit1.ogg b/sound_src/hit1.ogg
new file mode 100644 (file)
index 0000000..d019f69
Binary files /dev/null and b/sound_src/hit1.ogg differ
diff --git a/sound_src/hit2.ogg b/sound_src/hit2.ogg
new file mode 100644 (file)
index 0000000..c9593cc
Binary files /dev/null and b/sound_src/hit2.ogg differ
diff --git a/sound_src/hit3.ogg b/sound_src/hit3.ogg
new file mode 100644 (file)
index 0000000..ce49ae1
Binary files /dev/null and b/sound_src/hit3.ogg differ
diff --git a/sound_src/hit4.ogg b/sound_src/hit4.ogg
new file mode 100644 (file)
index 0000000..b793d19
Binary files /dev/null and b/sound_src/hit4.ogg differ