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();
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;
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 ){