X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=world_logic_bricks.h;h=d6e9d11557fa08cf2a40ad50de2b05c4a32bfde1;hb=620beae94b362ae4d4c42e5ba3329a6211d67a8f;hp=c4d5358db05980376588053230928b822d1df647;hpb=000297f007a08b25f458656bfb8dfe4345f2ec32;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/world_logic_bricks.h b/world_logic_bricks.h index c4d5358..d6e9d11 100644 --- a/world_logic_bricks.h +++ b/world_logic_bricks.h @@ -5,6 +5,8 @@ #include "world.h" +#if 0 + typedef struct logic_packet logic_packet; struct logic_packet { @@ -37,7 +39,7 @@ VG_STATIC void logic_bricks_debug_connection( world_instance *world, vg_line( from->co, to->co, clamped ); } -VG_STATIC void logic_bricks_debug( world_instance *world ) +VG_STATIC void logic_bricks_debug( world_instance *world, v3f pos ) { v3f white = {1.0f,1.0f,1.0f}, red = {1.0f,0.2f,0.1f}, @@ -50,6 +52,9 @@ VG_STATIC void logic_bricks_debug( world_instance *world ) struct logic_brick_ref *ref = &world->logic_bricks[i]; mdl_node *node = ref->node; + if( v3_dist2( node->co, pos ) > 50.0f*50.0f ) + continue; + void *entdata = mdl_get_entdata( world->meta, node ); if( ref->node->classtype == k_classtype_logic_wire ) @@ -173,7 +178,9 @@ VG_STATIC void logic_chances_call( world_instance *world, { mdl_node *pnext = mdl_node_from_id( world->meta, inf->targets[red] ); - if( pnext->classtype == k_classtype_logic_wire ) + if( (pnext->classtype == k_classtype_logic_wire) || + (pnext->classtype == k_classtype_logic_chances) || + (pnext->classtype == k_classtype_signal_splitter) ) { packet->location = pnext->sub_uid; } @@ -492,68 +499,10 @@ VG_STATIC void logic_bricks_world_gen_allocate( world_instance *world ) } } +#endif -/* - * BVH implementation - * ---------------------------------------------------------------------------- - */ - -VG_STATIC void trigger_bh_expand_bound( void *user, boxf bound, u32 item_index ) -{ - world_instance *world = user; - struct trigger_zone *trigger = &world->triggers[ item_index ]; - - m4x3_expand_aabb_point( trigger->transform, bound, (v3f){ 1.0f, 1.0f, 1.0f} ); - m4x3_expand_aabb_point( trigger->transform, bound, (v3f){ 1.0f, 1.0f,-1.0f} ); - m4x3_expand_aabb_point( trigger->transform, bound, (v3f){ 1.0f,-1.0f, 1.0f} ); - m4x3_expand_aabb_point( trigger->transform, bound, (v3f){ 1.0f,-1.0f,-1.0f} ); - m4x3_expand_aabb_point( trigger->transform, bound, (v3f){-1.0f, 1.0f, 1.0f} ); - m4x3_expand_aabb_point( trigger->transform, bound, (v3f){-1.0f, 1.0f,-1.0f} ); - m4x3_expand_aabb_point( trigger->transform, bound, (v3f){-1.0f,-1.0f, 1.0f} ); - m4x3_expand_aabb_point( trigger->transform, bound, (v3f){-1.0f,-1.0f,-1.0f} ); -} - -VG_STATIC float trigger_bh_centroid( void *user, u32 item_index, int axis ) -{ - world_instance *world = user; - struct trigger_zone *trigger = &world->triggers[ item_index ]; - - return trigger->transform[3][axis]; -} - -VG_STATIC void trigger_bh_swap( void *user, u32 ia, u32 ib ) -{ - world_instance *world = user; - struct trigger_zone *a = &world->triggers[ ia ], - *b = &world->triggers[ ib ], - temp; - - temp = *a; - *a = *b; - *b = temp; -} - -VG_STATIC void trigger_bh_debug( void *user, u32 item_index ) -{ - world_instance *world = user; - struct trigger_zone *zone = &world->triggers[ item_index ]; - - vg_line_boxf_transformed( zone->transform, (boxf){{-1.0f,-1.0f,-1.0f}, - { 1.0f, 1.0f, 1.0f}}, - 0xff00ff00 ); -} - -VG_STATIC bh_system bh_system_triggers = -{ - .expand_bound = trigger_bh_expand_bound, - .item_centroid = trigger_bh_centroid, - .item_closest = NULL, - .item_swap = trigger_bh_swap, - .item_debug = trigger_bh_debug, - .cast_ray = NULL -}; #endif /* WORLD_LOGIC_BRICKS_H */