From: hgn Date: Fri, 31 Mar 2023 02:18:22 +0000 (+0100) Subject: to the workers of the world X-Git-Url: https://harrygodden.com/git/?a=commitdiff_plain;h=620beae94b362ae4d4c42e5ba3329a6211d67a8f;hp=59c926ee69a041fbe9450b302e11072d39abb432;p=carveJwlIkooP6JGAAIwe30JlM.git to the workers of the world --- diff --git a/audio.h b/audio.h index 3504ed2..b3640bd 100644 --- a/audio.h +++ b/audio.h @@ -35,6 +35,15 @@ audio_clip audio_taps[] = { .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" }; @@ -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_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 ); diff --git a/blender_export.py b/blender_export.py index 721bba6..3b3f5cd 100644 --- a/blender_export.py +++ b/blender_export.py @@ -1741,7 +1741,8 @@ class SR_MATERIAL_PROPERTIES(bpy.types.PropertyGroup): ('0','concrete',''), ('1','wood',''), ('2','grass',''), - ('3','tiles','') + ('3','tiles',''), + ('4','metal','') ]) collision: bpy.props.BoolProperty( \ diff --git a/maps_src/mp_gridmap.mdl b/maps_src/mp_gridmap.mdl index 5ad8669..2f44b21 100644 Binary files a/maps_src/mp_gridmap.mdl and b/maps_src/mp_gridmap.mdl differ diff --git a/player_common.c b/player_common.c index bf04901..a7c4203 100644 --- a/player_common.c +++ b/player_common.c @@ -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.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 diff --git a/player_dead.c b/player_dead.c index f040adb..da23487 100644 --- a/player_dead.c +++ b/player_dead.c @@ -14,8 +14,7 @@ VG_STATIC void player__dead_animate ( player_instance *player, v3_zero( anim->root_co ); q_identity( anim->root_q ); - for( int i=0; ipose ); i ++ ) - { + for( int i=0; ipose ); i ++ ){ v3_zero( anim->pose[i].co ); v3_fill( anim->pose[i].s, 1.0f ); q_identity( anim->pose[i].q ); diff --git a/player_ragdoll.h b/player_ragdoll.h index 3fd5524..497aedd 100644 --- a/player_ragdoll.h +++ b/player_ragdoll.h @@ -7,6 +7,7 @@ #include "rigidbody.h" #include "player_model.h" #include "world.h" +#include "audio.h" 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] ); } + for( u32 i=1; isk.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 ); } @@ -273,6 +290,9 @@ VG_STATIC void player_ragdoll_iter( struct player_ragdoll *rd ) } rb_solver_reset(); + + float contact_velocities[256]; + for( int i=0; ipart_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 */ + for( u32 i=0; ico, 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 ); @@ -391,6 +423,38 @@ VG_STATIC void player_ragdoll_iter( struct player_ragdoll *rd ) rd->position_constraints_count, 0.5f ); } + rb_ct *stress = NULL; + float max_stress = 1.0f; + + for( u32 i=0; ico, 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 */ diff --git a/player_skate.c b/player_skate.c index 8535540..af41d53 100644 --- a/player_skate.c +++ b/player_skate.c @@ -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) ) { + vg_success( "ding\n" ); 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 ); - if( surf->info.surface_prop != k_surface_prop_concrete ) + if( surf->info.surface_prop > s->surface ) s->surface = surf->info.surface_prop; } @@ -2598,23 +2599,36 @@ begin_collision:; /* 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; + if( stick_frames > 5 ) stick_frames = 5; 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{ - 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(); + } 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", + "grind_metallic (INVALID)", "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 ); + s->grind_cooldown = 0; + s->surface_cooldown = 0; v3_muladds( player->rb.co, player->rb.to_world[1], 1.0f, s->state.cog ); } diff --git a/player_skate.h b/player_skate.h index 0f99fdb..2b7c60e 100644 --- a/player_skate.h +++ b/player_skate.h @@ -19,6 +19,7 @@ struct player_skate 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 diff --git a/rigidbody.h b/rigidbody.h index dfacf36..0fcb894 100644 --- a/rigidbody.h +++ b/rigidbody.h @@ -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 ) { - for( int i=0; inormal_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 ); @@ -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 ) { - for( int i=0; irba, 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; diff --git a/skaterift.c b/skaterift.c index e50c1e5..4b73237 100644 --- a/skaterift.c +++ b/skaterift.c @@ -22,7 +22,7 @@ #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" }; diff --git a/sound_src/hit0.ogg b/sound_src/hit0.ogg new file mode 100644 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 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 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 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 index 0000000..b793d19 Binary files /dev/null and b/sound_src/hit4.ogg differ