}
sfd_update();
+ /* volumes
+ * -------------------------------------------------------------------------
+ */
+
+ /* filter and check the existing ones
+ * TODO: on change world, clear volumes list */
+ u32 j=0;
+ for( u32 i=0; i<world_static.active_trigger_volume_count; i++ ){
+ i32 idx = world_static.active_trigger_volumes[i];
+ ent_volume *volume = mdl_arritm( &world->ent_volume, idx );
+
+ 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) )
+ {
+ world_static.active_trigger_volumes[ j ++ ] = idx;
+ boxf cube = {{-1.0f,-1.0f,-1.0f},{1.0f,1.0f,1.0f}};
+ vg_line_boxf_transformed( volume->to_world, cube, 0xff00ccff );
+ /* triggr on stay ..... */
+ }
+ else{
+ /* trigger on exit...... */
+ }
+ }
+ world_static.active_trigger_volume_count = j;
+
static float random_accum = 0.0f;
random_accum += vg.time_delta;
bh_iter_init_box( 0, &it, volume_proximity );
i32 idx;
- int in_volume = 0;
-
while( bh_next( world->volume_bh, &it, &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 ){
+ for( u32 i=0; i<world_static.active_trigger_volume_count; i++ )
+ if( world_static.active_trigger_volumes[i] == idx )
+ goto next_volume;
+
+ if( world_static.active_trigger_volume_count >
+ vg_list_size(world_static.active_trigger_volumes) ) continue;
+
v3f local;
m4x3_mulv( volume->to_local, pos, local );
(fabsf(local[1]) <= 1.0f) &&
(fabsf(local[2]) <= 1.0f) )
{
- in_volume = 1;
- vg_line_boxf_transformed( volume->to_world, cube, 0xff00ff00 );
-
- if( !world_static.in_volume ){
- ent_call basecall;
- basecall.function = k_ent_function_trigger;
- basecall.id = mdl_entity_id( k_ent_volume, idx );
- basecall.data = NULL;
+ ent_call basecall;
+ basecall.function = k_ent_function_trigger;
+ basecall.id = mdl_entity_id( k_ent_volume, idx );
+ basecall.data = NULL;
- entity_call( world, &basecall );
- }
+ entity_call( world, &basecall );
+ world_static.active_trigger_volumes[
+ world_static.active_trigger_volume_count ++ ] = idx;
}
else
- vg_line_boxf_transformed( volume->to_world, cube, 0xff0000ff );
+ vg_line_boxf_transformed( volume->to_world, cube, 0xffcccccc );
}
else if( volume->type == k_volume_subtype_particle ){
vg_line_boxf_transformed( volume->to_world, cube, 0xff00c0ff );
entity_call( world, &basecall );
}
}
+next_volume:;
}
- world_static.in_volume = in_volume;
#if 0
if( k_debug_light_indices )
vg_line_pt3( light->node->co, 0.25f, colour );
}
}
-
#endif
}