X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=world.c;h=5cc7841641acfe46e91e686079431440694bade0;hb=96f8ce1f47009e5f763b05566db3f6cca07cdc76;hp=209de3e5d17e3275e8b1e5155bafc1f0e14944b0;hpb=342fcbf6fda017bdd38d56ce0fa7c9e59e589f3b;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/world.c b/world.c index 209de3e..5cc7841 100644 --- a/world.c +++ b/world.c @@ -179,6 +179,34 @@ VG_STATIC void world_update( world_instance *world, v3f pos ) } sfd_update(); + /* volumes + * ------------------------------------------------------------------------- + */ + + /* filter and check the existing ones + * TODO: on change world, clear volumes list */ + u32 j=0; + for( u32 i=0; ient_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; @@ -198,14 +226,19 @@ VG_STATIC void world_update( world_instance *world, v3f pos ) 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 + vg_list_size(world_static.active_trigger_volumes) ) continue; + v3f local; m4x3_mulv( volume->to_local, pos, local ); @@ -213,20 +246,17 @@ VG_STATIC void world_update( world_instance *world, v3f pos ) (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 ); @@ -239,8 +269,8 @@ VG_STATIC void world_update( world_instance *world, v3f pos ) entity_call( world, &basecall ); } } +next_volume:; } - world_static.in_volume = in_volume; #if 0 if( k_debug_light_indices ) @@ -261,7 +291,6 @@ VG_STATIC void world_update( world_instance *world, v3f pos ) vg_line_pt3( light->node->co, 0.25f, colour ); } } - #endif }