X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;ds=sidebyside;f=audio.h;h=51445b665b6edfc70e49a8d247e326bf90be157a;hb=8c376ed2e4021a18b0a6c6e800109d67ad09d198;hp=d1fd1cc6277196453fcb3c8fad653457f127dc85;hpb=f99902f513b0ad606437bf32de47405dd4ea5f98;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/audio.h b/audio.h index d1fd1cc..51445b6 100644 --- a/audio.h +++ b/audio.h @@ -170,52 +170,6 @@ enum audio_sprite_type k_audio_sprite_type_water }; -/* - * 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 chance = { (vg_randf()-0.5f) * 30.0f, - 8.0f, - (vg_randf()-0.5f) * 30.0f }; - - v3f pos; - v3_add( chance, origin, pos ); - - ray_hit contact; - contact.dist = vg_minf( 16.0f, pos[1] ); - - world_instance *world = get_active_world(); - - if( ray_world( world, pos, (v3f){0.0f,-1.0f,0.0f}, &contact ) ){ - struct world_surface *mat = ray_hit_surface( world, &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; - } - } - - output[0] = pos[0]; - output[1] = 0.0f; - output[2] = pos[2]; - - float dist = fabsf(output[1] - origin[1]); - - if( world->water.enabled && dist<=40.0f ) - return k_audio_sprite_type_water; - else - return k_audio_sprite_type_none; -} - VG_STATIC void audio_ambient_sprite_play( v3f co, audio_clip *clip ) { audio_lock(); @@ -235,7 +189,7 @@ VG_STATIC void audio_ambient_sprite_play( v3f co, audio_clip *clip ) VG_STATIC void audio_ambient_sprites_update( world_instance *world, v3f co ) { static float accum = 0.0f; - accum += vg.frame_delta; + accum += vg.time_delta; if( accum > 0.1f ) accum -= 0.1f; @@ -243,7 +197,7 @@ VG_STATIC void audio_ambient_sprites_update( world_instance *world, v3f co ) v3f sprite_pos; enum audio_sprite_type sprite_type = - audio_sample_sprite_random( co, sprite_pos ); + world_audio_sample_sprite_random( co, sprite_pos ); if( sprite_type != k_audio_sprite_type_none ){ if( sprite_type == k_audio_sprite_type_grass ){