some niceer ui stuff
[carveJwlIkooP6JGAAIwe30JlM.git] / world_entity.c
index d431bedc20f88dfd0cb1043bf16143bbc21841d5..7e285d44a54731ea3cd73e93885ff10ed6d70d74 100644 (file)
@@ -26,7 +26,7 @@ VG_STATIC void world_gen_entities_init(void){
    for( u32 j=0; j<mdl_arrcount(&world->ent_gate); j ++ ){
       ent_gate *gate = mdl_arritm( &world->ent_gate, j );
 
-      if( gate->type == k_gate_type_teleport ){
+      if( !(gate->flags & k_ent_gate_nonlocal) ) {
          gate_transform_update( gate );
       }
    }
@@ -415,4 +415,29 @@ VG_STATIC void entity_bh_debug( void *user, u32 item_index ){
    }
 }
 
+VG_STATIC void entity_bh_closest( void *user, u32 item_index, v3f point,
+                                  v3f closest ){
+   world_instance *world = user;
+
+   u32 id    = world->entity_list[ item_index ],
+       type  = mdl_entity_id_type( id ),
+       index = mdl_entity_id_id( id );
+
+   if( type == k_ent_gate ){
+      ent_gate *gate = mdl_arritm( &world->ent_gate, index );
+      v3_copy( gate->to_world[3], closest );
+   }
+   else if( type == k_ent_challenge ){
+      ent_challenge *challenge = mdl_arritm( &world->ent_challenge, index );
+      v3_copy( challenge->transform.co, closest );
+   }
+   else if( type == k_ent_volume ){
+      ent_volume *volume = mdl_arritm( &world->ent_volume, index );
+      v3_copy( volume->to_world[3], closest );
+   }
+   else{
+      vg_fatal_error( "Programming error\n" );
+   }
+}
+
 #endif /* WORLD_ENTITY_C */