+
+
+ static float random_accum = 0.0f;
+ random_accum += vg.time_delta;
+
+ u32 random_ticks = 0;
+
+ while( random_accum > 0.1f ){
+ random_accum -= 0.1f;
+ random_ticks ++;
+ }
+
+ float radius = 25.0f;
+ boxf volume_proximity;
+ v3_add( pos, (v3f){ radius, radius, radius }, volume_proximity[1] );
+ v3_sub( pos, (v3f){ radius, radius, radius }, volume_proximity[0] );
+
+ bh_iter it;
+ bh_iter_init( 0, &it );
+ int idx;
+
+ int in_volume = 0;
+
+ while( bh_next( world->volume_bh, &it, volume_proximity, &idx ) ){
+ ent_volume *volume = mdl_arritm( &world->ent_volume, idx );
+
+ boxf cube = {{-1.0f,-1.0f,-1.0f},{1.0f,1.0f,1.0f}};
+
+ if( volume->type == k_volume_subtype_trigger ){
+ v3f local;
+ m4x3_mulv( volume->to_local, pos, local );
+
+ if( (fabsf(local[0]) <= 1.0f) &&
+ (fabsf(local[1]) <= 1.0f) &&
+ (fabsf(local[2]) <= 1.0f) )
+ {
+ in_volume = 1;
+ vg_line_boxf_transformed( volume->to_world, cube, 0xff00ff00 );
+
+ if( !world_global.in_volume ){
+ ent_call basecall;
+ basecall.ent.index = idx;
+ basecall.ent.type = k_ent_volume;
+ basecall.function = k_ent_function_trigger;
+ basecall.data = NULL;
+
+ entity_call( world, &basecall );
+ }
+ }
+ else
+ vg_line_boxf_transformed( volume->to_world, cube, 0xff0000ff );
+ }
+ else if( volume->type == k_volume_subtype_particle ){
+ vg_line_boxf_transformed( volume->to_world, cube, 0xff00c0ff );
+
+ for( int j=0; j<random_ticks; j++ ){
+ ent_call basecall;
+ basecall.ent.index = idx;
+ basecall.ent.type = k_ent_volume;
+ basecall.function = k_ent_function_trigger;
+ basecall.data = NULL;
+
+ entity_call( world, &basecall );
+ }
+ }
+ }
+ world_global.in_volume = in_volume;
+
+#if 0
+ if( k_debug_light_indices )
+ {
+ for( int i=0; i<world->light_count; i++ ){
+ struct world_light *light = &world->lights[i];
+ struct classtype_world_light *inf = light->inf;
+
+ u32 colour = 0xff000000;
+ u8 r = inf->colour[0] * 255.0f,
+ g = inf->colour[1] * 255.0f,
+ b = inf->colour[2] * 255.0f;
+
+ colour |= r;
+ colour |= g << 8;
+ colour |= b << 16;
+
+ vg_line_pt3( light->node->co, 0.25f, colour );
+ }
+ }
+
+#endif
+
+#if 0
+
+ /* process soundscape transactions */
+ audio_lock();
+ for( int i=0; i<world->soundscape_count; i++ )
+ {
+ struct soundscape *s = &world->soundscapes[i];
+ s->usage_count = 0;
+
+ for( int j=0; j<s->max_instances; j++ )
+ {
+ if( s->channels[j] )
+ {
+ if( audio_channel_finished(s->channels[j]) )
+ s->channels[j] = audio_relinquish_channel( s->channels[j] );
+ else
+ s->usage_count ++;
+ }
+ }
+ }
+ audio_unlock();
+#endif
+}
+
+/*
+ * -----------------------------------------------------------------------------
+ * API implementation
+ * -----------------------------------------------------------------------------
+ */
+
+VG_STATIC void ray_world_get_tri( world_instance *world,
+ ray_hit *hit, v3f tri[3] )
+{
+ for( int i=0; i<3; i++ )
+ v3_copy( world->scene_geo->arrvertices[ hit->tri[i] ].co, tri[i] );