launch option to load world
[carveJwlIkooP6JGAAIwe30JlM.git] / world_audio.c
index 510a13401726753e9ab669558bdcbd62d0a15bb2..0ecb6eb5d0c03443ff8ceeccc3cf778c0690d9c3 100644 (file)
@@ -6,14 +6,14 @@
 
 /* finds any active playing in world and fades them out, we can only do this 
  * while unloading */
-VG_STATIC void world_fadeout_audio( world_instance *world )
+static void world_fadeout_audio( world_instance *world )
 {
    if( world->status != k_world_status_unloading ){
       vg_fatal_error( "World status must be set to 'unloading', to fadeout"
                       " audio.\n" );
    }
 
-   u8 world_id = (world - world_static.worlds) + 1;
+   u8 world_id = (world - world_static.instances) + 1;
 
    audio_lock();
    for( u32 i=0; i<AUDIO_CHANNELS; i++ ){
@@ -29,12 +29,11 @@ VG_STATIC void world_fadeout_audio( world_instance *world )
 /*
  * Trace out a random point, near the player to try and determine water areas
  */
-VG_STATIC 
-enum audio_sprite_type world_audio_sample_sprite_random(v3f origin, v3f output)
-{
-   v3f chance = { (vg_randf64()-0.5f) * 30.0f, 
-                  8.0f,
-                  (vg_randf64()-0.5f) * 30.0f };
+static 
+enum audio_sprite_type world_audio_sample_sprite_random(v3f origin, v3f output){
+   v3f chance = { (vg_randf64(&vg.rand)-0.5f) * 30.0f, 
+                  8,
+                  (vg_randf64(&vg.rand)-0.5f) * 30.0f };
    
    v3f pos;
    v3_add( chance, origin, pos );
@@ -44,7 +43,8 @@ enum audio_sprite_type world_audio_sample_sprite_random(v3f origin, v3f output)
 
    world_instance *world = world_current_instance();
    
-   if( ray_world( world, pos, (v3f){0.0f,-1.0f,0.0f}, &contact ) ){
+   if( ray_world( world, pos, (v3f){0.0f,-1.0f,0.0f}, &contact, 
+            k_material_flag_ghosts ) ){
       struct world_surface *mat = ray_hit_surface( world, &contact );
 
       if( mat->info.surface_prop == k_surface_prop_grass){
@@ -68,7 +68,7 @@ enum audio_sprite_type world_audio_sample_sprite_random(v3f origin, v3f output)
       return k_audio_sprite_type_none;
 }
 
-VG_STATIC void world_audio_sample_distances( v3f co, int *index, float *value )
+static void world_audio_sample_distances( v3f co, int *index, float *value )
 {
    float inr3 = 0.57735027,
          inr2 = 0.70710678118;
@@ -104,7 +104,8 @@ VG_STATIC void world_audio_sample_distances( v3f co, int *index, float *value )
    float dist = 200.0f;
 
    for( int i=0; i<10; i++ ){
-      if( ray_world( world_current_instance(), rc, rd, &ray ) ){
+      if( ray_world( world_current_instance(), rc, rd, &ray, 
+                     k_material_flag_ghosts ) ){
          dist = (float)i*5.0f + ray.dist;
          break;
       }