even more collision filtering
[carveJwlIkooP6JGAAIwe30JlM.git] / audio.h
diff --git a/audio.h b/audio.h
index 34ebb3a4ad3a7866468654fcc932a898d4337d76..43adf052e289077ef860e1ef8ba82f1452b3d1b8 100644 (file)
--- a/audio.h
+++ b/audio.h
@@ -9,10 +9,10 @@
 
 #include "world.h"
 
-static float audio_occlusion_current = 0.0f,
+VG_STATIC float audio_occlusion_current = 0.0f,
              k_audio_occlusion_rate  = 1.0f;
 
-static int   k_audio_debug_soundscape = 0;
+VG_STATIC int   k_audio_debug_soundscape = 0;
 
 audio_clip audio_board[] =
 {
@@ -37,6 +37,24 @@ audio_clip audio_footsteps[] = {
  {.path = "sound/step_concrete3.ogg" }
 };
 
+audio_clip audio_footsteps_grass[] = {
+ {.path = "sound/step_bush0.ogg" },
+ {.path = "sound/step_bush1.ogg" },
+ {.path = "sound/step_bush2.ogg" },
+ {.path = "sound/step_bush3.ogg" },
+ {.path = "sound/step_bush4.ogg" },
+ {.path = "sound/step_bush5.ogg" }
+};
+
+audio_clip audio_footsteps_wood[] = {
+ {.path = "sound/step_wood0.ogg" },
+ {.path = "sound/step_wood1.ogg" },
+ {.path = "sound/step_wood2.ogg" },
+ {.path = "sound/step_wood3.ogg" },
+ {.path = "sound/step_wood4.ogg" },
+ {.path = "sound/step_wood5.ogg" }
+};
+
 audio_clip audio_lands[] = {
    { .path = "sound/land0.ogg" },
    { .path = "sound/land1.ogg" },
@@ -141,7 +159,7 @@ audio_player audio_player_gate =
    .name = "Gate"
 };
 
-static void audio_init(void)
+VG_STATIC void audio_init(void)
 {
    audio_player_init( &audio_player0 );
    audio_player_init( &audio_player1 );
@@ -156,19 +174,23 @@ static void audio_init(void)
    audio_player_init( &audio_player_extra );
    audio_player_init( &audio_rewind_player );
 
-   audio_clip_loadn( audio_board, vg_list_size(audio_board) );
-   audio_clip_loadn( audio_ambience, vg_list_size(audio_ambience) );
-   audio_clip_loadn( &audio_splash, 1 );
-   audio_clip_loadn( &audio_gate_pass, 1 );
-   audio_clip_loadn( &audio_gate_lap, 1 );
-   audio_clip_loadn( &audio_gate_ambient, 1 );
-   audio_clip_loadn( audio_jumps, vg_list_size(audio_jumps) );
-   audio_clip_loadn( audio_lands, vg_list_size(audio_lands) );
-   audio_clip_loadn( audio_water, vg_list_size(audio_water) );
-   audio_clip_loadn( audio_grass, vg_list_size(audio_grass) );
-   audio_clip_loadn( audio_footsteps, vg_list_size(audio_footsteps) );
-   audio_clip_loadn( audio_rewind, vg_list_size(audio_rewind) );
-   audio_clip_loadn( audio_ui, vg_list_size(audio_ui) );
+   audio_clip_loadn( audio_board, vg_list_size(audio_board), 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_gate_lap, 1, NULL );
+   audio_clip_loadn( &audio_gate_ambient, 1, NULL );
+   audio_clip_loadn( audio_jumps, vg_list_size(audio_jumps), NULL );
+   audio_clip_loadn( audio_lands, vg_list_size(audio_lands), NULL );
+   audio_clip_loadn( audio_water, vg_list_size(audio_water), NULL );
+   audio_clip_loadn( audio_grass, vg_list_size(audio_grass), NULL );
+   audio_clip_loadn( audio_footsteps, vg_list_size(audio_footsteps), NULL );
+   audio_clip_loadn( audio_footsteps_grass, 
+                     vg_list_size(audio_footsteps_grass), NULL );
+   audio_clip_loadn( audio_footsteps_wood, 
+                     vg_list_size(audio_footsteps_wood), NULL );
+   audio_clip_loadn( audio_rewind, vg_list_size(audio_rewind), NULL );
+   audio_clip_loadn( audio_ui, vg_list_size(audio_ui), NULL );
 
    audio_lock();
    u32 flags = AUDIO_FLAG_LOOP|AUDIO_FLAG_SPACIAL_3D;
@@ -215,13 +237,13 @@ static void audio_init(void)
    });
 }
 
-static void audio_free(void*_)
+VG_STATIC void audio_free(void*_)
 {
    /* TODO! */
    vg_warn( "UNIMPLEMENTED: audio_free()\n" );
 }
 
-static void audio_sample_occlusion( v3f origin )
+VG_STATIC void audio_sample_occlusion( v3f origin )
 {
    float d = 0.0f,
          sample_dist = 880.0f;
@@ -244,11 +266,14 @@ static void audio_sample_occlusion( v3f origin )
       {
          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;
       }
@@ -256,7 +281,10 @@ static void audio_sample_occlusion( v3f origin )
       {
          v3f p1;
          v3_muladds( origin, dir, sample_dist, p1 );
+
+#if 0
          vg_line( origin, p1, 0xffcccccc );
+#endif
 
          d += sample_dist;
          lv = 0;
@@ -280,8 +308,8 @@ enum audio_sprite_type
 /*
  * Trace out a random point, near the player to try and determine water areas
  */
-static enum audio_sprite_type audio_sample_sprite_random( v3f origin, 
-                                                          v3f output )
+VG_STATIC enum audio_sprite_type audio_sample_sprite_random( v3f origin, 
+                                                             v3f output )
 {
    v3f chance = { (vg_randf()-0.5f) * 30.0f, 
                   8.0f,
@@ -296,25 +324,34 @@ static enum audio_sprite_type audio_sample_sprite_random( v3f origin,
    
    if( ray_world( pos, (v3f){0.0f,-1.0f,0.0f}, &contact ) )
    {
-      if( ray_hit_is_ramp( &contact ) )
+      struct world_material *mat = ray_hit_material( &contact );
+
+      if( mat->info.surface_prop == k_surface_prop_grass) 
       {
+         v3_copy( contact.pos, output );
+         return k_audio_sprite_type_grass;
+      }
+      else
+      {
+#if 0
          vg_line( pos, contact.pos, 0xff0000ff );
          vg_line_pt3( contact.pos, 0.3f, 0xff0000ff );
+#endif
          return k_audio_sprite_type_none;
       }
-
-      v3_copy( contact.pos, output );
-      return k_audio_sprite_type_grass;
    }
 
    output[0] = pos[0];
    output[1] = 0.0f;
    output[2] = pos[2];
-
-   return k_audio_sprite_type_water;
+   
+   if( world.water.enabled )
+      return k_audio_sprite_type_water;
+   else
+      return k_audio_sprite_type_none;
 }
 
-static void audio_debug_soundscapes(void)
+VG_STATIC void audio_debug_soundscapes(void)
 {
    if( !k_audio_debug_soundscape ) return;