more tweaks
authorhgn <hgodden00@gmail.com>
Tue, 11 Apr 2023 23:14:07 +0000 (00:14 +0100)
committerhgn <hgodden00@gmail.com>
Tue, 11 Apr 2023 23:14:07 +0000 (00:14 +0100)
13 files changed:
audio.h
player_skate.c
skaterift.c
sound_src/grass0.ogg
sound_src/grass1.ogg
sound_src/grass2.ogg
sound_src/grass3.ogg
sound_src/wave0.ogg
sound_src/wave1.ogg
sound_src/wave2.ogg
sound_src/wave3.ogg
sound_src/wave4.ogg
sound_src/wave5.ogg

diff --git a/audio.h b/audio.h
index d52f410defd3cebef94613ba19c348e3612d85b6..097093350608dd972b38e31e7178cd814b4a9f83 100644 (file)
--- 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; i<sample_count; i++ )
-   {
-      v3f dir;
-      vg_rand_dir( dir );
-
-      ray_hit contact;
-      contact.dist = 15.0f;
-      
-      if( ray_world( world, origin, dir, &contact ) )
-      {
-         d += contact.dist;
-
-#if 0
-         vg_line( origin, contact.pos, 0xff0000ff );
-         vg_line_pt3( contact.pos, 0.1f, 0xff0000ff );
-
-         if( lv )
-            vg_line( contact.pos, last, 0xffffffff );
-#endif
-
-         v3_copy( contact.pos, last );
-         lv = 1;
-      }
-      else
-      {
-         v3f p1;
-         v3_muladds( origin, dir, sample_dist, p1 );
-
-#if 0
-         vg_line( origin, p1, 0xffcccccc );
-#endif
-
-         d += sample_dist;
-         lv = 0;
-      }
-
-   }
-
-   float occlusion = 1.0f - (d * (1.0f/(sample_dist*(float)sample_count))),
-         rate = VG_TIMESTEP_FIXED * k_audio_occlusion_rate,
-         target = powf( vg_maxf(occlusion,0.0f), 6.0f );
-   audio_occlusion_current = vg_lerpf( audio_occlusion_current, target, rate );
-}
-
 enum audio_sprite_type 
 {
    k_audio_sprite_type_none,
@@ -418,27 +228,53 @@ VG_STATIC enum audio_sprite_type audio_sample_sprite_random( v3f origin,
    output[0] = pos[0];
    output[1] = 0.0f;
    output[2] = pos[2];
+
+   float dist = fabsf(output[1] - origin[1]);
    
-   if( world->water.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 */
index a802a1cd496a2e1e78570ab424e94ce017f36d09..d67d055669bd03cf9baba373b8f155ba5826600c 100644 (file)
@@ -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 ) );
index 1d8e564359ef810e34532e131a876b568f417454..c036a50188582ff0805abe0ea6ba52c4587d5505 100644 (file)
@@ -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<vg_list_size(vg_input.controller_axises); i++ )
-      {
-         snprintf( buf, 40, "%.2f", vg_input.controller_axises[i] );
-         ui_text( (ui_px [2]){ 0, (i+3)*20 }, buf, 1, k_text_align_left );
-      }
-   }
-   else
-   {
-      ui_text( (ui_px [2]){ 0, 60 }, 
-            "Gamepad not ready", 1, k_text_align_left );
-   }
-#endif
 }
index 3e6cc1c62082c35f87e258ce0d84f9d649aff1b7..a6f0d83c0a96567d72cb177fa40b3269eea574e1 100644 (file)
Binary files a/sound_src/grass0.ogg and b/sound_src/grass0.ogg differ
index 6a89776a826bde8361016cdaef2d50667de3130c..7768c65e14a86d2c52c1d2cf59186aeeaf704167 100644 (file)
Binary files a/sound_src/grass1.ogg and b/sound_src/grass1.ogg differ
index 16382d0fa91e9d9719ce0a551714e0d9adbf94ce..a05ea590086375968292b87a5010963d0cd2f743 100644 (file)
Binary files a/sound_src/grass2.ogg and b/sound_src/grass2.ogg differ
index 000cd38ddae87cabf2ceb19d8d7c897aefcf2cb0..038fe8a3213ed20beee0ebead3e9209b69a81ae7 100644 (file)
Binary files a/sound_src/grass3.ogg and b/sound_src/grass3.ogg differ
index 54b6c941b7dfd8e831a16b7b58b3b864881da0f8..d4531821d8c49eb9f9d8f7e88ef86edf2723c55f 100644 (file)
Binary files a/sound_src/wave0.ogg and b/sound_src/wave0.ogg differ
index 19af0b3043b565732f489c1169406ef367e51c7d..8a95a5f509a48ad92f4ee3889727df416541730b 100644 (file)
Binary files a/sound_src/wave1.ogg and b/sound_src/wave1.ogg differ
index dc59237e501e6a936f437fe4324d2ab67809e22c..fdd0d327e1c78c4bb4fdb4abde5279158df3cbcd 100644 (file)
Binary files a/sound_src/wave2.ogg and b/sound_src/wave2.ogg differ
index 06809f23eb76cf11ffc45169ecd20c6b86bb81a4..7e8e31c5afc020ba5205540be474d94e06f0c2af 100644 (file)
Binary files a/sound_src/wave3.ogg and b/sound_src/wave3.ogg differ
index 1b147503306618d18a5f72f88622c2e57ef1f029..ad5ebf95030b33fea02d4478175251a03bd55396 100644 (file)
Binary files a/sound_src/wave4.ogg and b/sound_src/wave4.ogg differ
index 7bb6d42adbf9fbd1652fc0f1aad7edbfdb040019..41040ff19ef385e346a6d6c4e4a39df9b957d901 100644 (file)
Binary files a/sound_src/wave5.ogg and b/sound_src/wave5.ogg differ