From: hgn Date: Tue, 11 Apr 2023 23:14:07 +0000 (+0100) Subject: more tweaks X-Git-Url: https://harrygodden.com/git/?a=commitdiff_plain;h=cca3ca3a92572c77f34a99ffa2f3d9a69d029000;hp=249fe329869e43961d4e1d4e44f08c6225e195c7;p=carveJwlIkooP6JGAAIwe30JlM.git more tweaks --- diff --git a/audio.h b/audio.h index d52f410..0970933 100644 --- a/audio.h +++ b/audio.h @@ -120,18 +120,6 @@ audio_clip audio_gate_ambient = { .path = "sound/gate_ambient.ogg" }; -#if 0 -audio_player ambient_player = -{ - .name = "Ambience" -}; - -audio_player audio_rewind_player = -{ - .name = "Rewind" -}; -#endif - audio_clip audio_rewind[] = { { .path = "sound/rewind_start.ogg" }, { .path = "sound/rewind_end_1.5.ogg" }, @@ -145,69 +133,8 @@ audio_clip audio_ui[] = { { .path = "sound/ui_ding.ogg" }, }; -#if 0 -audio_player ambient_sprites[4] = -{ - { .name = "Ambient Sprites 0" }, - { .name = "Ambient Sprites 1" }, - { .name = "Ambient Sprites 2" }, - { .name = "Ambient Sprites 3" }, -}; - -audio_player audio_player0 = -{ - .name = "Player0", -}; - -audio_player audio_player1 = -{ - .name = "Player1", -}; - -audio_player audio_player2 = -{ - .name = "Player2", -}; - -audio_player audio_player3 = -{ - .name = "Player3", -}; - -audio_player audio_player4 = -{ - .name = "Player4", -}; - -audio_player audio_player_extra = -{ - .name = "PlayerInst" -}; - -audio_player audio_player_gate = -{ - .name = "Gate" -}; -#endif - VG_STATIC void audio_init(void) { -#if 0 - audio_player_init( &audio_player0 ); - audio_player_init( &audio_player1 ); - audio_player_init( &audio_player2 ); - audio_player_init( &audio_player3 ); - audio_player_init( &audio_player4 ); - audio_player_init( &audio_player_gate ); - audio_player_init( &ambient_player ); - audio_player_init( &ambient_sprites[0] ); - audio_player_init( &ambient_sprites[1] ); - audio_player_init( &ambient_sprites[2] ); - audio_player_init( &ambient_sprites[3] ); - audio_player_init( &audio_player_extra ); - audio_player_init( &audio_rewind_player ); -#endif - 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 ); @@ -229,39 +156,6 @@ VG_STATIC void audio_init(void) audio_clip_loadn( audio_rewind, vg_list_size(audio_rewind), NULL ); audio_clip_loadn( audio_ui, vg_list_size(audio_ui), NULL ); -#if 0 - audio_lock(); - u32 flags = AUDIO_FLAG_LOOP|AUDIO_FLAG_SPACIAL_3D; - - audio_player_set_flags( &audio_player0, flags ); - audio_player_set_flags( &audio_player1, flags ); - audio_player_set_flags( &audio_player2, flags ); - audio_player_set_flags( &audio_player4, flags ); - audio_player_set_flags( &audio_player_gate, flags ); - audio_player_set_flags( &audio_player3, AUDIO_FLAG_LOOP ); - audio_player_set_flags( &ambient_player, AUDIO_FLAG_LOOP ); - audio_player_set_flags( &ambient_sprites[0], AUDIO_FLAG_SPACIAL_3D ); - audio_player_set_flags( &ambient_sprites[1], AUDIO_FLAG_SPACIAL_3D ); - audio_player_set_flags( &ambient_sprites[2], AUDIO_FLAG_SPACIAL_3D ); - audio_player_set_flags( &ambient_sprites[3], AUDIO_FLAG_SPACIAL_3D ); - - audio_player_set_vol( &ambient_player, 1.0f ); - audio_player_set_vol( &audio_player_gate, 0.0f ); - audio_player_set_vol( &audio_player_extra, 1.0f ); - audio_player_set_vol( &audio_rewind_player, 0.2f ); - audio_player_set_flags( &audio_rewind_player, 0x00 ); - - audio_player_playclip( &audio_player0, &audio_board[0] ); - audio_player_playclip( &audio_player1, &audio_board[1] ); - audio_player_playclip( &audio_player2, &audio_board[2] ); - audio_player_playclip( &audio_player3, &audio_board[3] ); - audio_player_playclip( &audio_player4, &audio_board[4] ); - audio_player_playclip( &ambient_player, &audio_ambience[0] ); - audio_player_playclip( &audio_player_gate, &audio_gate_ambient ); - - audio_unlock(); -#endif - vg_var_push( (struct vg_var){ .name = "aud_debug_soundscape", .data = &k_audio_debug_soundscape, @@ -284,96 +178,12 @@ VG_STATIC void audio_init(void) audio_unlock(); } -VG_STATIC void audio_update(void) -{ -#if 0 - static u32 flapflop = 0x00; - static audio_channel *channel = NULL; - - u32 next = floorf( vg.time / 0.1f ); - - if( flapflop != next ) - { - flapflop = next; - - audio_lock(); - channel = audio_channel_crossfade( channel, - &audio_music[ next & 0x1 ], 0.05f, - AUDIO_FLAG_LOOP|AUDIO_FLAG_SPACIAL_3D - ); - channel = audio_channel_set_spacial( channel, - (v3f){ -22.3f, 60.1f, -52.7f }, - 50.0f ); - - audio_channel_sidechain_lfo( channel, 0, 1.0f ); - audio_unlock(); - } -#endif -} - VG_STATIC void audio_free(void) { /* TODO! */ vg_warn( "UNIMPLEMENTED: audio_free()\n" ); } -VG_STATIC void audio_sample_occlusion( v3f origin ) -{ - float d = 0.0f, - sample_dist = 880.0f; - - int sample_count = 8; - - int lv = 0; - v3f last; - v3_zero(last); - - world_instance *world = get_active_world(); - - for( int i=0; iwater.enabled ) + if( world->water.enabled && dist<=40.0f ) return k_audio_sprite_type_water; else return k_audio_sprite_type_none; } -VG_STATIC void audio_debug_soundscapes(void) +VG_STATIC void audio_ambient_sprite_play( v3f co, audio_clip *clip ) { - if( !k_audio_debug_soundscape ) return; + audio_lock(); + u32 channel_id = 31342352; + audio_channel *ch = audio_get_group_idle_channel( channel_id, 4 ); + + if( ch ){ + audio_channel_init( ch, clip, AUDIO_FLAG_SPACIAL_3D ); + audio_channel_group( ch, channel_id ); + audio_channel_set_spacial( ch, co, 80.0f ); + audio_channel_edit_volume( ch, 1.0f, 1 ); + ch = audio_relinquish_channel( ch ); + } + audio_unlock(); +} - char buf[64]; - snprintf( buf, 31, "occlusion: %.5f", audio_occlusion_current ); +VG_STATIC void audio_ambient_sprites_update( world_instance *world, v3f co ) +{ + static float accum = 0.0f; + accum += vg.frame_delta; - vg_uictx.cursor[0] = 450; - vg_uictx.cursor[1] = 10; - vg_uictx.cursor[2] = audio_occlusion_current * 200.0f; - vg_uictx.cursor[3] = 20; + if( accum > 0.1f ) + accum -= 0.1f; + else return; - ui_fill_rect( vg_uictx.cursor, 0x55cccccc ); - ui_text( vg_uictx.cursor, buf, 1, 0 ); + v3f sprite_pos; + enum audio_sprite_type sprite_type = + audio_sample_sprite_random( co, sprite_pos ); + + if( sprite_type != k_audio_sprite_type_none ){ + if( sprite_type == k_audio_sprite_type_grass ){ + audio_ambient_sprite_play( sprite_pos, &audio_grass[rand()%4] ); + } + else if( sprite_type == k_audio_sprite_type_water ){ + if( world->water.enabled ) + audio_ambient_sprite_play( sprite_pos, &audio_water[rand()%6] ); + } + } } #endif /* AUDIO_H */ diff --git a/player_skate.c b/player_skate.c index a802a1c..d67d055 100644 --- a/player_skate.c +++ b/player_skate.c @@ -3031,7 +3031,7 @@ VG_STATIC void player__skate_animate( player_instance *player, if( (s->state.activity <= k_skate_activity_air_to_grind) && (fabsf(s->state.flip_rate) > 0.01f) ) { - float t = s->state.flip_time; + float t = s->state.flip_time+s->state.flip_rate*substep*k_rb_delta; sign = vg_signf( t ); t = 1.0f - vg_minf( 1.0f, fabsf( t * 1.1f ) ); diff --git a/skaterift.c b/skaterift.c index 1d8e564..c036a50 100644 --- a/skaterift.c +++ b/skaterift.c @@ -12,6 +12,7 @@ */ #define SR_NETWORKED +#define VG_DEVWINDOW #include "common.h" #include "conf.h" #include "steam.h" @@ -21,7 +22,6 @@ #include "font.h" - #include "player.h" static player_instance localplayer; VG_STATIC struct player_avatar localplayer_avatar; @@ -246,8 +246,8 @@ VG_STATIC void vg_load(void) /* 'systems' are completely loaded now */ /* load home world */ - //world_load( &world_global.worlds[0], "maps/mp_gridmap.mdl" ); - world_load( &world_global.worlds[0], "maps/mp_mtzero.mdl" ); + world_load( &world_global.worlds[0], "maps/mp_gridmap.mdl" ); + //world_load( &world_global.worlds[0], "maps/mp_mtzero.mdl" ); #if 0 world_load( &world_global.worlds[1], "maps/mp_gridmap.mdl" ); @@ -286,8 +286,7 @@ VG_STATIC void vg_update(void) player__pre_update( &localplayer ); world_update( get_active_world(), localplayer.rb.co ); - - audio_update(); + audio_ambient_sprites_update( get_active_world(), localplayer.rb.co ); } } @@ -605,42 +604,5 @@ VG_STATIC void vg_ui(void) world_instance *world = get_active_world(); menu_crap_ui(); - audio_debug_soundscapes(); render_view_framebuffer_ui(); - -#if 0 - player_physics_gui(); -#endif -} - -VG_STATIC void run_debug_info(void) -{ -#if 0 - char buf[40]; - - snprintf( buf, 40, "%.2fm/s", v3_length( player.rb.v ) ); - ui_text( (ui_px [2]){ 0, 0 }, buf, 1, k_text_align_left ); - - snprintf( buf, 40, "%.2f %.2f %.2f m/s", - player.phys.a[0], player.phys.a[1], player.phys.a[2] ); - ui_text( (ui_px [2]){ 0, 20 }, buf, 1, k_text_align_left ); - - snprintf( buf, 40, "pos %.2f %.2f %.2f", - player.phys.rb.co[0], player.phys.rb.co[1], player.phys.rb.co[2] ); - ui_text( (ui_px [2]){ 0, 40 }, buf, 1, k_text_align_left ); - - if( vg_input.controller_handle ) - { - for( int i=0; i