X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=skaterift.c;h=099ff993383b230424dd34abed69fd6009b8b5b5;hb=2f44245bafbb83a2172e544a7a2965ae837186ed;hp=e639d05eb0deade48ee1cab867f830fe6d903967;hpb=188685bc8454ff40b733d9e9df8da45e3c2e2c39;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/skaterift.c b/skaterift.c index e639d05..099ff99 100644 --- a/skaterift.c +++ b/skaterift.c @@ -11,7 +11,7 @@ * ============================================================================= */ -#if 1 +#if 0 #define SR_NETWORKED @@ -50,6 +50,7 @@ #include "addon.c" #include "highscores.c" #include "save.c" +#include "respawn.c" static struct player_avatar localplayer_avatar; @@ -104,6 +105,9 @@ static void skaterift_restore_state(void){ kvsav.len = sav.len; kvsav.max = sizeof(sav.buf); + u32 board_reg_id = 0, + player_reg_id = 0; + vg_msg player = kvsav; if( vg_msg_seekframe( &player, "player", 0 ) ){ addon_alias q; @@ -111,21 +115,23 @@ static void skaterift_restore_state(void){ /* board */ skaterift_read_addon_alias( &player, "board", k_addon_type_board, &q ); u32 reg_id = addon_match( &q ); - if( reg_id != 0xffffffff ){ - localplayer.board_view_slot = - addon_cache_create_viewer( k_addon_type_board, reg_id ); - } + if( reg_id != 0xffffffff ) + board_reg_id = reg_id; + /* playermodel */ skaterift_read_addon_alias( &player, "playermodel", k_addon_type_player, &q ); reg_id = addon_match( &q ); - - if( reg_id == 0xffffffff ) reg_id = 0; - localplayer.playermodel_view_slot = - addon_cache_create_viewer( k_addon_type_player, reg_id ); + if( reg_id != 0xffffffff ) + player_reg_id = reg_id; } + localplayer.board_view_slot = + addon_cache_create_viewer( k_addon_type_board, board_reg_id ); + localplayer.playermodel_view_slot = + addon_cache_create_viewer( k_addon_type_player, player_reg_id ); + vg_msg world = kvsav; if( vg_msg_seekframe( &world, "world", 0 ) ){ addon_alias q; @@ -143,7 +149,7 @@ static void skaterift_restore_state(void){ }; skaterift_world_load_thread( &args ); - world_static.active_instance = vg_msg_seekkvu32( &world, "index", 0 ); + world_set_active_instance( vg_msg_seekkvu32( &world, "index", 0 ) ); world_static.active_trigger_volume_count = 0; localplayer.viewable_world = world_current_instance(); } @@ -292,18 +298,21 @@ VG_STATIC void vg_pre_update(void){ /* time rate */ f32 target = 1; - if( skaterift.activity & (k_skaterift_replay|k_skaterift_menu) ) + if( skaterift.activity & (k_skaterift_replay|k_skaterift_menu| + k_skaterift_respawning) ) { target = 0; + } vg_slewf( &skaterift.time_rate, target, vg.time_frame_delta * (1.0f/0.3f) ); vg.time_rate = vg_smoothstepf( skaterift.time_rate ); player__pre_update( &localplayer ); - global_skateshop_preupdate(); + world_entity_focus_preupdate(); skaterift_replay_pre_update(); world_update( world_current_instance(), localplayer.rb.co ); audio_ambient_sprites_update( world_current_instance(), localplayer.rb.co ); + respawn_chooser_pre_update(); } VG_STATIC void vg_fixed_update(void){ @@ -451,17 +460,28 @@ VG_STATIC void render_scene(void){ } } - render_world( view_world, &skaterift.cam, 0 ); - - render_water_texture( view_world, &skaterift.cam, 0 ); - render_fb_bind( gpipeline.fb_main, 1 ); - render_water_surface( view_world, &skaterift.cam ); + if( skaterift.activity == k_skaterift_respawning ){ + glDrawBuffers( 1, (GLenum[]){ GL_COLOR_ATTACHMENT0 } ); + glClearColor( 0.624f, 0.659f, 0.769f, 0.0f ); + glClear( GL_COLOR_BUFFER_BIT ); + glDrawBuffers( 2, (GLenum[]){ GL_COLOR_ATTACHMENT0, + GL_COLOR_ATTACHMENT1 } ); + view_world = &world_static.instances[respawn_chooser.world_id]; + render_world_override( view_world ); + } + else{ + render_world( view_world, &skaterift.cam, 0 ); + render_water_texture( view_world, &skaterift.cam, 0 ); + render_fb_bind( gpipeline.fb_main, 1 ); + render_water_surface( view_world, &skaterift.cam ); + } } VG_STATIC void render_scene_gate_subview(void){ render_fb_bind( gpipeline.fb_main, 1 ); world_instance *view_world = localplayer.viewable_world; if( !view_world ) return; /* ??? */ + if( skaterift.activity == k_skaterift_respawning ) return; int depth = 1; if( localplayer.gate_waiting ) depth = 0; @@ -469,8 +489,8 @@ VG_STATIC void render_scene_gate_subview(void){ } VG_STATIC void skaterift_composite_maincamera(void){ - camera_lerp( &localplayer.cam, &global_skateshop.cam, - vg_smoothstepf(global_skateshop.factive), &skaterift.cam ); + camera_lerp( &localplayer.cam, &world_static.focus_cam, + vg_smoothstepf(world_static.focus_strength), &skaterift.cam ); if( skaterift.activity == k_skaterift_replay ){ skaterift_get_replay_camera( &skaterift.cam ); @@ -479,15 +499,23 @@ VG_STATIC void skaterift_composite_maincamera(void){ skaterift.cam.nearz = 0.1f; skaterift.cam.farz = 2100.0f; + 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 ); - if( localplayer.gate_waiting ){ - m3x3_mul( localplayer.basis_gate, skaterift.cam.transform, - skaterift.cam.transform ); - } - else{ - m3x3_mul( localplayer.basis, skaterift.cam.transform, - skaterift.cam.transform ); + if( skaterift.activity != k_skaterift_respawning ){ + if( localplayer.gate_waiting ){ + m3x3_mul( localplayer.basis_gate, skaterift.cam.transform, + skaterift.cam.transform ); + } + else{ + m3x3_mul( localplayer.basis, skaterift.cam.transform, + skaterift.cam.transform ); + } } camera_update_view( &skaterift.cam );