From: hgn Date: Sat, 15 Apr 2023 04:17:10 +0000 (+0100) Subject: nonlocal stuff again X-Git-Url: https://harrygodden.com/git/?a=commitdiff_plain;h=6b9993651343af73bd48e2213910bbaadb41edaf;hp=e70b6d550d63af95cafd9ffdee1918faf02a6892;p=carveJwlIkooP6JGAAIwe30JlM.git nonlocal stuff again --- diff --git a/blender_export.py b/blender_export.py index eed99af..c863971 100644 --- a/blender_export.py +++ b/blender_export.py @@ -1290,13 +1290,21 @@ def sr_compile( collection ): #} elif ent_type == 'ent_gate': #{ gate = ent_gate() - gate.type = 0 obj_data = obj.SR_data.ent_gate[0] mesh_data = obj.data.SR_data.ent_gate[0] - if obj_data.target:#{ - gate.target = sr_compile.entity_ids[obj_data.target.name] - gate.type = 1 + + if obj_data.tipo == 'default':#{ + if obj_data.target:#{ + gate.target = sr_compile.entity_ids[obj_data.target.name] + gate.type = 1 + #} + #} + elif obj_data.tipo == 'nonlocal':#{ + gate.target = sr_compile_string(obj_data.key) + gate.type = 2 #} + else: gate.type = 0 + gate.dimensions[0] = mesh_data.dimensions[0] gate.dimensions[1] = mesh_data.dimensions[1] gate.dimensions[2] = mesh_data.dimensions[2] @@ -1926,6 +1934,20 @@ class SR_OBJECT_ENT_GATE(bpy.types.PropertyGroup): target: bpy.props.PointerProperty( \ type=bpy.types.Object, name="destination", \ poll=lambda self,obj: sr_filter_ent_type(obj,['ent_gate'])) + + key: bpy.props.StringProperty() + tipo: bpy.props.EnumProperty(items=(('default', 'Default', ""), + ('nonlocal', 'Non-Local', ""),)) + + @staticmethod + def sr_inspector( layout, data ): + #{ + box = layout.box() + box.prop( data[0], 'tipo', text="subtype" ) + + if data[0].tipo == 'default': box.prop( data[0], 'target' ) + elif data[0].tipo == 'nonlocal': box.prop( data[0], 'key' ) + #} #} class SR_MESH_ENT_GATE(bpy.types.PropertyGroup): diff --git a/entity.h b/entity.h index 143ad0d..9bfd04a 100644 --- a/entity.h +++ b/entity.h @@ -69,15 +69,14 @@ struct ent_light{ enum gate_type{ k_gate_type_unlinked = 0, k_gate_type_teleport = 1, - k_gate_type_nonlocal = 2 + k_gate_type_nonlocal_unlinked = 2, + k_gate_type_nonlocel = 3 }; struct ent_gate{ u32 type, target; - /* TODO: World index */ - v3f dimensions, co[2]; diff --git a/maps_src/mp_mtzero.mdl b/maps_src/mp_mtzero.mdl index 4eb90fc..2b5bded 100644 Binary files a/maps_src/mp_mtzero.mdl and b/maps_src/mp_mtzero.mdl differ diff --git a/maps_src/mp_spawn.mdl b/maps_src/mp_spawn.mdl new file mode 100644 index 0000000..0d6f093 Binary files /dev/null and b/maps_src/mp_spawn.mdl differ diff --git a/player.c b/player.c index 48f696a..b804ed1 100644 --- a/player.c +++ b/player.c @@ -352,7 +352,7 @@ void player__pass_gate( player_instance *player, ent_gate *gate ) m4x3_mulv( gate->transport, player->cam.pos, player->cam.pos ); player_save_rewind_frame( player ); - if( gate->type == k_gate_type_nonlocal ) + if( gate->type == k_gate_type_nonlocel ) world_global.active_world = gate->target; world_global.in_volume = 0; diff --git a/player_skate.c b/player_skate.c index f1670c8..e9a4f09 100644 --- a/player_skate.c +++ b/player_skate.c @@ -347,7 +347,7 @@ VG_STATIC int create_jumps_to_hit_target( player_instance *player, VG_STATIC void player__approximate_best_trajectory( player_instance *player ) { - world_instance *world = get_active_world(); + world_instance *world0 = get_active_world(); struct player_skate *s = &player->_skate; float k_trace_delta = k_rb_delta * 10.0f; @@ -392,6 +392,7 @@ void player__approximate_best_trajectory( player_instance *player ) v3_copy( player->rb.co, launch_co ); v3_copy( player->rb.v, launch_v ); v3_copy( launch_co, co0 ); + world_instance *trace_world = world0; float vt = (float)m * (1.0f/30.0f), ang = vg_lerpf( angle_begin, angle_end, vt ) * 0.15f; @@ -431,8 +432,7 @@ void player__approximate_best_trajectory( player_instance *player ) v3f closest={0.0f,0.0f,0.0f}; if( search_for_grind ){ - if( bh_closest_point( world->geo_bh, co1, closest, 1.0f ) != -1 ){ - + if( bh_closest_point(trace_world->geo_bh,co1,closest,1.0f) != -1 ){ float min_dist = 0.75f; min_dist *= min_dist; @@ -491,14 +491,18 @@ void player__approximate_best_trajectory( player_instance *player ) } } - if( world->rendering_gate ){ - ent_gate *gate = world->rendering_gate; + if( trace_world->rendering_gate ){ + ent_gate *gate = trace_world->rendering_gate; if( gate_intersect( gate, co1, co0 ) ){ m4x3_mulv( gate->transport, co0, co0 ); m4x3_mulv( gate->transport, co1, co1 ); m3x3_mulv( gate->transport, launch_v, launch_v); m4x3_mulv( gate->transport, launch_co, launch_co ); m3x3_mul( gate->transport, basis, basis ); + + if( gate->type == k_gate_type_nonlocel ){ + trace_world = &world_global.worlds[ gate->target ]; + } } } @@ -508,15 +512,16 @@ void player__approximate_best_trajectory( player_instance *player ) float scan_radius = k_board_radius; scan_radius *= vg_clampf( t, 0.02f, 1.0f ); - int idx = spherecast_world( world, co0, co1, scan_radius, &t1, n ); + int idx = spherecast_world(trace_world, co0, co1, scan_radius, &t1, n); if( idx != -1 ){ v3f co; v3_lerp( co0, co1, t1, co ); v3_copy( co, inf->log[ inf->log_length ++ ] ); v3_copy( n, inf->n ); - u32 *tri = &world->scene_geo->arrindices[ idx*3 ]; - struct world_surface *surf = world_tri_index_surface(world, tri[0]); + u32 *tri = &trace_world->scene_geo->arrindices[ idx*3 ]; + struct world_surface *surf = + world_tri_index_surface( trace_world, tri[0] ); inf->type = k_prediction_land; @@ -591,7 +596,7 @@ void player__approximate_best_trajectory( player_instance *player ) float t1; v3f n; - int idx = spherecast_world( world, co0,co1, + int idx = spherecast_world( world0, co0,co1, k_board_radius*0.1f, &t1, n); if( idx != -1 ){ goto invalidated_grind; diff --git a/skaterift.c b/skaterift.c index a01f67a..eb69bc7 100644 --- a/skaterift.c +++ b/skaterift.c @@ -166,7 +166,7 @@ VG_STATIC void vg_load(void) /* 'systems' are completely loaded now */ /* load home world */ - world_load( 0, "maps/mp_gridmap.mdl" ); + world_load( 0, "maps/mp_spawn.mdl" ); world_load( 1, "maps/mp_mtzero.mdl" ); #if 0 diff --git a/world.h b/world.h index c7485d1..8093971 100644 --- a/world.h +++ b/world.h @@ -62,6 +62,12 @@ struct world_instance { void *heap; char world_name[ 64 ]; + enum world_status{ + k_world_status_unloaded = 0, + k_world_status_loading = 1, + k_world_status_loaded = 2 + } + status; struct{ boxf depthbounds; diff --git a/world_gate.h b/world_gate.h index a073b26..989e918 100644 --- a/world_gate.h +++ b/world_gate.h @@ -231,7 +231,8 @@ VG_STATIC ent_gate *world_intersect_gates( world_instance *world, { for( u32 i=0; ient_gate); i++ ){ ent_gate *gate = mdl_arritm( &world->ent_gate, i ); - if( gate->type == k_gate_type_unlinked ) + if( gate->type == k_gate_type_unlinked || + gate->type == k_gate_type_nonlocal_unlinked ) continue; if( gate_intersect( gate, pos, last ) ){ diff --git a/world_gen.h b/world_gen.h index 2371fa5..3f57498 100644 --- a/world_gen.h +++ b/world_gen.h @@ -597,6 +597,8 @@ VG_STATIC void world_free( world_instance *world ) glDeleteTextures( world->texture_count, world->textures ); vg_release_thread_sync(); + + world->status = k_world_status_unloaded; } VG_STATIC void world_init_blank( world_instance *world ) @@ -641,8 +643,10 @@ VG_STATIC void world_init_blank( world_instance *world ) v3_copy( (v3f){1.10f, 0.89f, 0.35f}, state->g_sun_colour ); } -VG_STATIC void world_entities_init( world_instance *world ) +VG_STATIC void world_entities_init( u32 world_id ) { + world_instance *world = &world_global.worlds[world_id]; + /* lights */ for( u32 j=0; jent_light); j ++ ){ ent_light *light = mdl_arritm( &world->ent_light, j ); @@ -659,7 +663,55 @@ VG_STATIC void world_entities_init( world_instance *world ) /* gates */ for( u32 j=0; jent_gate); j ++ ){ ent_gate *gate = mdl_arritm( &world->ent_gate, j ); - gate_transform_update( gate ); + + if( gate->type == k_gate_type_teleport ){ + gate_transform_update( gate ); + } + else if( gate->type == k_gate_type_nonlocal_unlinked ){ + const char *key = mdl_pstr( &world->meta, gate->target ); + vg_info( "key: %s\n", key ); + + for( u32 i=0; istatus != k_world_status_loaded ) continue; + vg_info( "Checking world %u for key matches\n", i ); + + for( u32 j=0; jent_gate ); j++ ){ + ent_gate *gate2 = mdl_arritm( &other->ent_gate, j ); + if( gate2->type != k_gate_type_nonlocal_unlinked ) continue; + + const char *key2 = mdl_pstr( &other->meta, gate2->target ); + vg_info( " key2: %s\n", key2 ); + + if( strcmp( key, key2 ) ) continue; + + vg_success( "Non-local matching pair '%s' found. (%u:%u)\n", + key, world_id, i ); + + gate->type = k_gate_type_nonlocel; + gate2->type = k_gate_type_nonlocel; + gate->target = i; + gate2->target = world_id; + + v3_copy( gate->co[0], gate2->co[1] ); + v3_copy( gate2->co[0], gate->co[1] ); + v4_copy( gate->q[0], gate2->q[1] ); + v4_copy( gate2->q[0], gate->q[1] ); + + v4f qflip; + q_axis_angle( qflip, (v3f){0.0f,1.0f,0.0f}, VG_PIf ); + q_mul( gate->q[0], qflip, gate->q[0] ); + q_mul( gate->q[1], qflip, gate->q[1] ); + + gate_transform_update( gate ); + gate_transform_update( gate2 ); + + goto matched; + } + } +matched:; + } } /* water */ @@ -723,6 +775,7 @@ VG_STATIC void world_load( u32 index, const char *path ) { world_instance *world = &world_global.worlds[index]; world_init_blank( world ); + world->status = k_world_status_loading; vg_info( "Loading world: %s\n", path ); @@ -765,7 +818,7 @@ VG_STATIC void world_load( u32 index, const char *path ) world_process_resources( world ); world_routes_ent_init( world ); - world_entities_init( world ); + world_entities_init( index ); world->volume_bh = bh_create( heap, &bh_system_volumes, world, mdl_arrcount( &world->ent_volume ), 1 ); @@ -775,6 +828,8 @@ VG_STATIC void world_load( u32 index, const char *path ) world_post_process( world ); mdl_close( meta ); + + world->status = k_world_status_loaded; } #endif /* WORLD_GEN_H */ diff --git a/world_render.h b/world_render.h index ad0d5c4..4e39036 100644 --- a/world_render.h +++ b/world_render.h @@ -359,16 +359,19 @@ VG_STATIC void render_world_gates( world_instance *world, camera *cam, } if( gate ){ -#if 0 - world_instance *dest_world = &world_global.worlds[ gate->world_index ]; - render_gate( dest_world, gate, cam, layer_depth ); -#else - render_gate( world, gate, cam, layer_depth ); -#endif - /* should really be set in fixed update since its used in the physics * of most systems. too bad! */ world->rendering_gate = gate; + + if( gate->type == k_gate_type_teleport ){ + render_gate( world, gate, cam, layer_depth ); + } + else if( gate->type == k_gate_type_nonlocel ){ + world_instance *dest_world = &world_global.worlds[ gate->target ]; + render_gate( dest_world, gate, cam, layer_depth ); + } + else + world->rendering_gate = NULL; } } @@ -377,7 +380,6 @@ VG_STATIC void world_prerender( world_instance *world ) static double g_time = 0.0; g_time += vg.time_delta * (1.0/(k_day_length*60.0)); - struct ub_world_lighting *state = &world->ub_lighting; state->g_time = g_time; diff --git a/world_routes.h b/world_routes.h index 00dee4e..66a4fa5 100644 --- a/world_routes.h +++ b/world_routes.h @@ -134,10 +134,19 @@ VG_STATIC void world_routes_time_lap( world_instance *world, ent_route *route ) VG_STATIC void world_routes_activate_entry_gate( world_instance *world, ent_gate *rg ) { - ent_gate *dest = mdl_arritm( &world->ent_gate, rg->target ); - world_global.last_use = world_global.time; + /* disable all routes and leave the world */ + if( rg->type == k_gate_type_nonlocel ){ + for( u32 i=0; ient_route); i++ ){ + ent_route *route = mdl_arritm( &world->ent_route, i ); + route->active_checkpoint = 0xffff; + } + return; + } + + ent_gate *dest = mdl_arritm( &world->ent_gate, rg->target ); + for( u32 i=0; ient_route); i++ ){ ent_route *route = mdl_arritm( &world->ent_route, i );