#}
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]
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):
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];
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;
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;
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;
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;
}
}
- 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 ];
+ }
}
}
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;
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;
/* '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
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;
{
for( u32 i=0; i<mdl_arrcount(&world->ent_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 ) ){
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 )
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; j<mdl_arrcount(&world->ent_light); j ++ ){
ent_light *light = mdl_arritm( &world->ent_light, j );
/* gates */
for( u32 j=0; j<mdl_arrcount(&world->ent_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; i<vg_list_size(world_global.worlds); i++ ){
+ world_instance *other = &world_global.worlds[i];
+ if( other == world ) continue;
+ if( other->status != k_world_status_loaded ) continue;
+ vg_info( "Checking world %u for key matches\n", i );
+
+ for( u32 j=0; j<mdl_arrcount( &other->ent_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 */
{
world_instance *world = &world_global.worlds[index];
world_init_blank( world );
+ world->status = k_world_status_loading;
vg_info( "Loading world: %s\n", 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 );
world_post_process( world );
mdl_close( meta );
+
+ world->status = k_world_status_loaded;
}
#endif /* WORLD_GEN_H */
}
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;
}
}
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;
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; i<mdl_arrcount(&world->ent_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; i<mdl_arrcount(&world->ent_route); i++ ){
ent_route *route = mdl_arritm( &world->ent_route, i );