even more collision filtering
[carveJwlIkooP6JGAAIwe30JlM.git] / audio.h
diff --git a/audio.h b/audio.h
index 26c1a35ca3b69152c2a0b2f99c556e63567c7247..43adf052e289077ef860e1ef8ba82f1452b3d1b8 100644 (file)
--- a/audio.h
+++ b/audio.h
@@ -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" },
@@ -167,6 +185,10 @@ VG_STATIC void audio_init(void)
    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 );
 
@@ -244,11 +266,14 @@ VG_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 @@ VG_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;
@@ -281,7 +309,7 @@ enum audio_sprite_type
  * Trace out a random point, near the player to try and determine water areas
  */
 VG_STATIC enum audio_sprite_type audio_sample_sprite_random( v3f origin, 
-                                                          v3f output )
+                                                             v3f output )
 {
    v3f chance = { (vg_randf()-0.5f) * 30.0f, 
                   8.0f,
@@ -296,22 +324,31 @@ VG_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;
 }
 
 VG_STATIC void audio_debug_soundscapes(void)