From: hgn Date: Mon, 20 Nov 2023 14:25:31 +0000 (+0000) Subject: chaos pt 3 X-Git-Url: https://skaterift.com/git/?a=commitdiff_plain;h=00653e446d6b1310fa89d3aace70800f9fef4122;p=carveJwlIkooP6JGAAIwe30JlM.git chaos pt 3 --- diff --git a/blender_export.py b/blender_export.py index 36ca368..4b7cf7f 100644 --- a/blender_export.py +++ b/blender_export.py @@ -528,7 +528,7 @@ class ent_cubemap(Structure):#{ class ent_miniworld(Structure):#{ _fields_ = [("transform",mdl_transform), ("pstr_world",c_uint32), - ("purpose",c_int32), + ("camera",c_uint32), ("proxy",c_uint32)] sr_functions = { 0: 'zone', 1: 'leave' } @@ -1972,6 +1972,7 @@ def sr_compile( collection ): compile_obj_transform( obj, miniworld.transform ) miniworld.pstr_world = sr_compile_string( obj_data.world ) miniworld.proxy = sr_entity_id( obj_data.proxy ) + miniworld.camera = sr_entity_id( obj_data.camera ) sr_ent_push( miniworld ) #} elif ent_type == 'ent_prop':#{ @@ -2624,6 +2625,9 @@ class SR_OBJECT_ENT_MINIWORLD(bpy.types.PropertyGroup): proxy: bpy.props.PointerProperty( \ type=bpy.types.Object, name='proxy', \ poll=lambda self,obj: sr_filter_ent_type(obj,['ent_prop'])) + camera: bpy.props.PointerProperty( \ + type=bpy.types.Object, name="Camera", \ + poll=lambda self,obj: sr_filter_ent_type(obj,['ent_camera'])) #} class SR_UL_ROUTE_NODE_LIST(bpy.types.UIList): diff --git a/ent_miniworld.c b/ent_miniworld.c index 08e7093..802bd8b 100644 --- a/ent_miniworld.c +++ b/ent_miniworld.c @@ -2,6 +2,8 @@ #include "ent_miniworld.h" #include "world_render.h" #include "input.h" +#include "gui.h" +#include "menu.h" static void ent_miniworld_call( world_instance *world, ent_call *call ){ ent_miniworld *miniworld = mdl_arritm( &world->ent_miniworld, @@ -13,6 +15,7 @@ static void ent_miniworld_call( world_instance *world, ent_call *call ){ const char *uid = mdl_pstr( &world->meta, miniworld->pstr_world ); skaterift_load_world_command( 1, (const char *[]){ uid } ); + mdl_transform_m4x3( &miniworld->transform, global_miniworld.mmdl ); global_miniworld.active = miniworld; } else if( call->function == 1 ){ @@ -26,6 +29,28 @@ static void ent_miniworld_call( world_instance *world, ent_call *call ){ } } +static void miniworld_icon( camera *cam, enum gui_icon icon, v3f pos ){ + m4x3f mmdl; + v3_copy( cam->transform[2], mmdl[2] ); + mmdl[2][1] = 0.0f; + v3_normalize( mmdl[2] ); + v3_copy( (v3f){0,1,0}, mmdl[1] ); + v3_cross( mmdl[1], mmdl[2], mmdl[0] ); + m4x3_mulv( global_miniworld.mmdl, pos, mmdl[3] ); + + shader_model_font_uMdl( mmdl ); + shader_model_font_uOffset( (v4f){0,0,0,20} ); + + m4x4f m4mdl; + m4x3_expand( mmdl, m4mdl ); + m4x4_mul( cam->mtx_prev.pv, m4mdl, m4mdl ); + shader_model_font_uPvmPrev( m4mdl ); + + mdl_submesh *sm = gui.icons[ icon ]; + if( sm ) + mdl_draw_submesh( sm ); +} + static void ent_miniworld_render( world_instance *host_world, camera *cam ){ if( host_world != &world_static.instances[k_world_purpose_hub] ) return; @@ -54,44 +79,118 @@ static void ent_miniworld_render( world_instance *host_world, camera *cam ){ if( !rendering ) return; - m4x3f mmdl; - mdl_transform_m4x3( &miniworld->transform, mmdl ); - render_world_override( dest_world, host_world, mmdl, cam ); - render_world_routes( dest_world, host_world, mmdl, cam, 0, 1 ); -} + render_world_override( dest_world, host_world, global_miniworld.mmdl, cam, + global_miniworld.dest_spawn ); + render_world_routes( dest_world, host_world, + global_miniworld.mmdl, cam, 0, 1 ); -static void ent_miniworld_preupdate(void){ - if( world_static.active_instance == k_world_purpose_client ){ - if( button_down(k_srbind_mleft) ){ - global_miniworld.transition = -1; - global_miniworld.t = 1.0f; - - global_miniworld.cam = skaterift.cam; - m4x3_transform_camera( global_miniworld.mmdl, &global_miniworld.cam ); - world_switch_instance(0); + /* icons + * ---------------------*/ + font3d_bind( &gui.font, k_font_shader_default, 0, NULL, cam ); + mesh_bind( &gui.icons_mesh ); + + glActiveTexture( GL_TEXTURE0 ); + glBindTexture( GL_TEXTURE_2D, gui.icons_texture ); + shader_model_font_uTexMain( 0 ); + shader_model_font_uColour( (v4f){1,1,1,1} ); + + for( u32 i=0; ient_challenge); i++ ){ + ent_challenge *challenge = mdl_arritm( &dest_world->ent_challenge, i ); + + enum gui_icon icon = k_gui_icon_exclaim; + if( challenge->status ) + icon = k_gui_icon_tick; + + miniworld_icon( cam, icon, challenge->transform.co ); + } + + for( u32 i=0; ient_skateshop); i++ ){ + ent_skateshop *shop = mdl_arritm( &dest_world->ent_skateshop, i ); + if( shop->type == k_skateshop_type_boardshop ){ + miniworld_icon( cam, k_gui_icon_board, shop->transform.co ); } + else if( shop->type == k_skateshop_type_worldshop ){ + miniworld_icon( cam, k_gui_icon_world, shop->transform.co ); + } + } + + for( u32 i=0; ient_route); i++ ){ + ent_route *route = mdl_arritm( &dest_world->ent_route, i ); + + v4f colour; + v4_copy( route->colour, colour ); + v3_muls( colour, 1.6666f, colour ); + shader_model_font_uColour( colour ); + miniworld_icon( cam, k_gui_icon_rift_run, route->board_transform[3] ); } +} + +static void ent_miniworld_preupdate(void){ + world_instance *hub = world_current_instance(), + *dest = &world_static.instances[k_world_purpose_client]; ent_miniworld *miniworld = global_miniworld.active; - if( !miniworld ) + + if( (localplayer.subsystem != k_player_subsystem_walk) || + (global_miniworld.transition) || + (world_static.active_instance != k_world_purpose_hub) || + (!miniworld) || + (dest->status != k_world_status_loaded) ){ + + if( global_miniworld.mode ){ + global_miniworld.mode = 0; + menu.disable_open = 0; + srinput.state = k_input_state_resume; + } return; + } - world_instance *world = world_current_instance(); + if( button_down( k_srbind_miniworld_resume ) ){ + global_miniworld.mode = 0; + global_miniworld.transition = 1; + global_miniworld.t = 0.0f; + global_miniworld.cam = skaterift.cam; + + if( global_miniworld.dest_spawn ){ + v3_copy( global_miniworld.dest_spawn->transform.co, + dest->player_co ); + } - if( global_miniworld.transition ){ + world_switch_instance(1); + global_miniworld.dest_spawn = NULL; + srinput.state = k_input_state_resume; + menu.disable_open = 0; } else { - int rendering = 1; - if( world_static.instances[k_world_purpose_client].status - == k_world_status_loaded ){ - if( button_down( k_srbind_mright ) ){ - global_miniworld.transition = 1; - global_miniworld.t = 0.0f; - global_miniworld.cam = skaterift.cam; - - mdl_transform_m4x3( &miniworld->transform, global_miniworld.mmdl ); - world_switch_instance(1); + if( global_miniworld.mode == 1 ){ + if( button_down(k_srbind_mback) ){ + global_miniworld.mode = 0; + global_miniworld.dest_spawn = NULL; + menu.disable_open = 0; + srinput.state = k_input_state_resume; + } + else { + m4x3f mmdl_inv; + m4x3_invert_full( global_miniworld.mmdl, mmdl_inv ); + v3f lco; + m4x3_mulv( mmdl_inv, localplayer.rb.co, lco ); + global_miniworld.dest_spawn = world_find_closest_spawn( dest, lco ); + } + } + else { + if( button_down( k_srbind_miniworld_teleport ) ){ + global_miniworld.mode = 1; + menu.disable_open = 1; } } } } + +static void ent_miniworld_goback(void){ + global_miniworld.transition = -1; + global_miniworld.t = 1.0f; + + global_miniworld.cam = skaterift.cam; + m4x3_transform_camera( global_miniworld.mmdl, &global_miniworld.cam ); + world_switch_instance(0); +} diff --git a/ent_miniworld.h b/ent_miniworld.h index 2be6141..73d0c46 100644 --- a/ent_miniworld.h +++ b/ent_miniworld.h @@ -6,14 +6,18 @@ struct { ent_miniworld *active; int transition; + int mode; f32 t; m4x3f mmdl; camera cam; + + ent_spawn *dest_spawn; } static global_miniworld; static void ent_miniworld_call( world_instance *world, ent_call *call ); static void ent_miniworld_render( world_instance *host_world, camera *cam ); +static void ent_miniworld_goback(void); #endif /* ENT_MINIWORLD_H */ diff --git a/entity.h b/entity.h index 7cfce58..612ad61 100644 --- a/entity.h +++ b/entity.h @@ -504,8 +504,7 @@ struct ent_call{ struct ent_miniworld { mdl_transform transform; u32 pstr_world; - - i32 purpose_DELTED; + u32 camera; u32 proxy; }; diff --git a/input.h b/input.h index fc8f7c9..e66bdc6 100644 --- a/input.h +++ b/input.h @@ -34,6 +34,10 @@ enum sr_bind{ k_srbind_home, k_srbind_lobby, k_srbind_chat, + + k_srbind_miniworld_teleport, + k_srbind_miniworld_resume, + k_srbind_max, }; @@ -97,6 +101,10 @@ static vg_input_op *input_button_list[] = { [k_srbind_sit] = INPUT_BASIC( SDLK_z, SDL_CONTROLLER_BUTTON_B ), [k_srbind_lobby] = INPUT_BASIC( SDLK_TAB, SDL_CONTROLLER_BUTTON_DPAD_LEFT ), [k_srbind_chat ] = (vg_input_op[]){ vg_keyboard, SDLK_y, vg_end }, + +[k_srbind_miniworld_resume] = INPUT_BASIC( SDLK_e, SDL_CONTROLLER_BUTTON_A ), +[k_srbind_miniworld_teleport]= INPUT_BASIC( SDLK_r, SDL_CONTROLLER_BUTTON_X ), + [k_srbind_max]=NULL }; diff --git a/maps_src/dev_hub/main.mdl b/maps_src/dev_hub/main.mdl index 44881ec..4798e48 100644 Binary files a/maps_src/dev_hub/main.mdl and b/maps_src/dev_hub/main.mdl differ diff --git a/menu.h b/menu.h index 8da5026..8691f08 100644 --- a/menu.h +++ b/menu.h @@ -11,6 +11,7 @@ #include "workshop.h" #include "respawn.h" #include "gui.h" +#include "ent_miniworld.h" #define MENU_STACK_SIZE 8 @@ -247,7 +248,7 @@ static void menu_trigger_item( ent_menuitem *item ){ else if( MDL_CONST_PSTREQ( &menu.model, q, "reset" ) ){ menu_close(); - respawn_begin_chooser(); + ent_miniworld_goback(); } else if( MDL_CONST_PSTREQ( &menu.model, q, "credits" ) ){ diff --git a/models_src/rs_icons.mdl b/models_src/rs_icons.mdl index 296df3f..5cb9769 100644 Binary files a/models_src/rs_icons.mdl and b/models_src/rs_icons.mdl differ diff --git a/player.c b/player.c index 3084828..860e048 100644 --- a/player.c +++ b/player.c @@ -200,7 +200,6 @@ static void player__im_gui(void){ [k_skaterift_replay] = "replay", [k_skaterift_ent_focus] = "ent_focus", [k_skaterift_default] = "default", - [k_skaterift_respawning]= "respawning", } [skaterift.activity] ); player__debugtext( 1, "time_rate: %.4f", skaterift.time_rate ); diff --git a/player_replay.c b/player_replay.c index 6a59e25..befbf0f 100644 --- a/player_replay.c +++ b/player_replay.c @@ -505,6 +505,9 @@ static void skaterift_replay_update_helpers(void){ } static void skaterift_replay_post_render(void){ + if( world_static.active_instance != k_world_purpose_client ) + return; + /* capture the current resume frame at the very last point */ if( button_down( k_srbind_reset ) ){ if( skaterift.activity == k_skaterift_default ){ diff --git a/respawn.c b/respawn.c index f7be930..0e1dc67 100644 --- a/respawn.c +++ b/respawn.c @@ -1,6 +1,7 @@ #ifndef RESPAWN_C #define RESPAWN_C +#if 0 #include "respawn.h" #include "skaterift.h" #include "world.h" @@ -263,5 +264,6 @@ static void respawn_chooser_shader_uniforms(void){ shader_scene_override_uSpawnPos( uSpawnPos ); } #endif +#endif #endif /* RESPAWN_C */ diff --git a/shaders/scene_override.fs b/shaders/scene_override.fs index f7dff2b..60bf90d 100644 --- a/shaders/scene_override.fs +++ b/shaders/scene_override.fs @@ -31,7 +31,7 @@ void main(){ compute_motion_vectors(); - vec3 vfrag = vec3(0.7); + vec3 vfrag = vec3(0.898,0.811,0.716); vec3 qnorm = aNorm.xyz; qnorm = normalize(floor(aNorm.xyz*4.0)*0.25); diff --git a/shaders/scene_override.h b/shaders/scene_override.h index d0c7ab9..d9f7be0 100644 --- a/shaders/scene_override.h +++ b/shaders/scene_override.h @@ -482,7 +482,7 @@ static struct vg_shader _shader_scene_override = { "\n" " compute_motion_vectors();\n" "\n" -" vec3 vfrag = vec3(0.7);\n" +" vec3 vfrag = vec3(0.898,0.811,0.716);\n" " vec3 qnorm = aNorm.xyz;\n" "\n" " qnorm = normalize(floor(aNorm.xyz*4.0)*0.25);\n" diff --git a/skaterift.c b/skaterift.c index 254c80d..c020532 100644 --- a/skaterift.c +++ b/skaterift.c @@ -324,8 +324,7 @@ static void vg_pre_update(void){ /* time rate */ f32 target = 1; - if( skaterift.activity & (k_skaterift_replay|k_skaterift_menu| - k_skaterift_respawning) ) { + if( skaterift.activity & (k_skaterift_replay|k_skaterift_menu) ){ target = 0; } @@ -341,7 +340,6 @@ static void vg_pre_update(void){ world_update( world_current_instance(), localplayer.rb.co ); audio_ambient_sprites_update( world_current_instance(), localplayer.rb.co ); - respawn_chooser_pre_update(); } static void vg_fixed_update(void){ @@ -545,12 +543,6 @@ static void skaterift_composite_maincamera(void){ } } - if( skaterift.activity == k_skaterift_respawning ){ - camera_copy( &respawn_chooser.cam, &skaterift.cam ); - skaterift.cam.nearz = 4.0f; - skaterift.cam.farz = 3100.0f; - } - camera_update_transform( &skaterift.cam ); camera_update_view( &skaterift.cam ); camera_update_projection( &skaterift.cam ); @@ -652,16 +644,8 @@ static void vg_gui(void){ render_view_framebuffer_ui(); remote_player_network_imgui( vg.pv ); - - if( skaterift.activity == k_skaterift_respawning ){ - remote_players_imgui_world( world_current_instance(), vg.pv, - 2000.0f, 0 ); - remote_players_imgui_lobby(); - } - else { - remote_players_chat_imgui(); /* TODO: conditional */ - remote_players_imgui_world( world_current_instance(), vg.pv, 100.0f, 1 ); - } + remote_players_chat_imgui(); /* TODO: conditional */ + remote_players_imgui_world( world_current_instance(), vg.pv, 100.0f, 1 ); } diff --git a/skaterift.h b/skaterift.h index 6664637..4cfc874 100644 --- a/skaterift.h +++ b/skaterift.h @@ -51,7 +51,7 @@ struct{ k_skaterift_replay = 0x01, k_skaterift_ent_focus = 0x02, k_skaterift_menu = 0x04, - k_skaterift_respawning = 0x08 + k_skaterift_respawning_DELETED = 0x08, } activity; diff --git a/world.c b/world.c index 4f8cda2..22c3c2c 100644 --- a/world.c +++ b/world.c @@ -27,7 +27,7 @@ static void world_init(void) } static void world_switch_instance( u32 index ){ - assert( localplayer.subsystem == k_player_subsystem_walk ); + localplayer.subsystem = k_player_subsystem_walk; if( index >= vg_list_size(world_static.instances) ){ vg_error( "Instance ID out of range (%u)\n", index ); diff --git a/world_entity.c b/world_entity.c index d34ed6e..c5c2fc7 100644 --- a/world_entity.c +++ b/world_entity.c @@ -92,10 +92,9 @@ static void world_entity_focus_render(void){ ent_skateshop *skateshop = mdl_arritm( &world->ent_skateshop, index ); skateshop_render( skateshop ); } - else if( type == k_ent_challenge ){ - } - else if( type == k_ent_route ){ - } + else if( type == k_ent_challenge ){} + else if( type == k_ent_route ){} + else if( type == k_ent_miniworld ){} else { vg_fatal_error( "Programming error\n" ); } diff --git a/world_gate.c b/world_gate.c index bc21e95..accdc06 100644 --- a/world_gate.c +++ b/world_gate.c @@ -65,10 +65,6 @@ static void world_gates_init(void) world_gates.sm_marker[i] = *sm; } - mdl_mesh *icosphere = mdl_find_mesh( &mgate, "rs_icosphere" ); - world_gates.sm_icosphere = - *((mdl_submesh *)mdl_arritm( &mgate.submeshs, icosphere->submesh_start )); - mdl_async_load_glmesh( &mgate, &world_gates.mesh ); mdl_close( &mgate ); } diff --git a/world_gate.h b/world_gate.h index a8decac..2201f76 100644 --- a/world_gate.h +++ b/world_gate.h @@ -11,7 +11,7 @@ struct world_gates{ glmesh mesh; - mdl_submesh sm_surface, sm_marker[4], sm_icosphere; + mdl_submesh sm_surface, sm_marker[4]; camera cam; v3f userportal_co; diff --git a/world_render.c b/world_render.c index b63d8a7..8d7e546 100644 --- a/world_render.c +++ b/world_render.c @@ -798,11 +798,7 @@ static void world_prerender( world_instance *world ){ state->g_debug_indices = k_debug_light_indices; state->g_light_preview = k_light_preview; state->g_debug_complexity = k_debug_light_complexity; - - if( skaterift.activity == k_skaterift_respawning ) - state->g_time_of_day = 0.1f; - else - state->g_time_of_day = vg_fractf( world->time ); + state->g_time_of_day = vg_fractf( world->time ); state->g_day_phase = cosf( state->g_time_of_day * VG_PIf * 2.0f ); state->g_sunset_phase= cosf( state->g_time_of_day * VG_PIf * 4.0f + VG_PIf ); @@ -963,7 +959,8 @@ static void render_world_override_pass( world_instance *world, static void render_world_override( world_instance *world, world_instance *lighting_source, m4x3f mmdl, - camera *cam ){ + camera *cam, + ent_spawn *dest_spawn ){ struct world_pass pass = { .cam = cam, .fn_bind_textures = bindpoint_override, @@ -974,9 +971,6 @@ static void render_world_override( world_instance *world, }; shader_scene_override_use(); -#if 0 - respawn_chooser_shader_uniforms(); -#endif shader_scene_override_uTexGarbage(0); shader_scene_override_uTexMain(1); shader_scene_override_uPv( pass.cam->mtx.pv ); @@ -1003,13 +997,10 @@ static void render_world_override( world_instance *world, v3_copy( world->player_co, uPlayerPos ); - m4x3f mmdl_inv; - m4x3_invert_full( mmdl, mmdl_inv ); - v3f localized; - m4x3_mulv( mmdl_inv, localplayer.rb.co, localized ); - ent_spawn *spawn = world_find_closest_spawn( world, localized ); - if( spawn ) - v3_copy( spawn->transform.co, uSpawnPos ); + if( dest_spawn && (v3_dist2(dest_spawn->transform.co,uPlayerPos) > 0.1f) ) + v3_copy( dest_spawn->transform.co, uSpawnPos ); + else + v3_add( uPlayerPos, (v3f){0,-1,0}, uSpawnPos ); uPlayerPos[3] = v3_dist(uPlayerPos,uSpawnPos); uSpawnPos[3] = 1.0f/uPlayerPos[3]; diff --git a/world_render.h b/world_render.h index 3837068..b02116e 100644 --- a/world_render.h +++ b/world_render.h @@ -83,7 +83,8 @@ static void bind_terrain_noise(void); static void render_world_override( world_instance *world, world_instance *lighting_source, m4x3f mmdl, - camera *cam ); + camera *cam, + ent_spawn *dest_spawn ); #define WORLD_BIND_LIGHT_BUFFERS_UB0_TEX234( WORLD, SHADER ) \ world_link_lighting_ub( WORLD, _shader_##SHADER.id ); \ diff --git a/world_routes.c b/world_routes.c index d710e5e..5f6d283 100644 --- a/world_routes.c +++ b/world_routes.c @@ -612,8 +612,7 @@ static void world_routes_update( world_instance *world ){ for( u32 i=0; ient_route); i++ ){ ent_route *route = mdl_arritm( &world->ent_route, i ); - int target = (route->active_checkpoint == 0xffff? 0: 1) || - skaterift.activity == k_skaterift_respawning; + int target = route->active_checkpoint == 0xffff? 0: 1; route->factive = vg_lerpf( route->factive, target, 0.6f*vg.time_frame_delta ); }