* =============================================================================
*
* Copyright . . . -----, ,----- ,---. .---.
- * 2021-2023 |\ /| | / | | | | /|
+ * 2021-2024 |\ /| | / | | | | /|
* | \ / | +-- / +----- +---' | / |
* | \ / | | / | | \ | / |
* | \/ | | / | | \ | / |
* =============================================================================
*/
-#if 1
-
-#define SR_NETWORKED
-#define SR_USE_LOCALHOST
-
-#ifndef VG_RELEASE
- #define VG_DEVWINDOW
-#endif
+#define SR_ALLOW_REWIND_HUB
/*
* system headers
#include "skaterift.h"
#include "steam.h"
#include "render.h"
-#include "audio.h"
+#include "vg/vg_opt.h"
+#include "vg/vg_loader.h"
#include "world.h"
#include "network.h"
#include "menu.h"
#include "vehicle.h"
-#include "pointcloud.h"
#include "save.h"
#include "player_remote.h"
+#include "particle.h"
+#include "trail.h"
+#include "freecam.h"
+#include "ent_tornado.h"
+#include "ent_miniworld.h"
+#include "ent_skateshop.h"
+#include "ent_npc.h"
+#include "world_map.h"
+#include "gui.h"
+#include "workshop.h"
+#include "audio.h"
+#include "player_render.h"
-/* unity build
- * ----------------- */
+struct skaterift_globals skaterift =
+{
+ .op = k_async_op_clientloading, .time_rate = 1.0f, .demo_mode = 1,
+ .hub_world = "maps/dev_hub",
+};
-#include "world.c"
-#include "player.c"
-#include "vehicle.c"
-#include "entity.c"
-#include "workshop.c"
-#include "addon.c"
-#include "highscores.c"
-#include "save.c"
-#include "respawn.c"
-#include "network.c"
-#include "player_remote.c"
-
-static struct player_avatar localplayer_avatar;
+static int k_tools_mode = 0;
int main( int argc, char *argv[] ){
-#if 0
- u8 buf[ 512 ];
- bitpack_ctx ctx = {
- .buffer = buf,
- .buffer_len = 512,
- .bytes = 0,
- .mode = k_bitpack_compress
- };
-
- v4f q = { 0.388, -0.565, 0.515, 0.515 };
- vg_info( "q: %f %f %f %f\n", q[0], q[1], q[2], q[3] );
-
- /* compress */
- bitpack_qquat( &ctx, q );
-
- vg_info( "compressed bytes: %u\n", ctx.bytes );
-
- /* decompress */
- ctx.bytes = 0;
- ctx.mode = k_bitpack_decompress;
-
- bitpack_qquat( &ctx, q );
- vg_info( "q: %f %f %f %f\n", q[0], q[1], q[2], q[3] );
-
- return 0;
-#endif
-
vg_mem.use_libc_malloc = 0;
vg_set_mem_quota( 160*1024*1024 );
vg_enter( argc, argv, "Voyager Game Engine" );
return 0;
}
-static void vg_launch_opt(void){
+void vg_launch_opt(void)
+{
+ const char *arg;
if( vg_long_opt( "noauth" ) ){
network_client.auth_mode = eServerModeNoAuthentication;
}
-}
-static void vg_preload(void){
- //skaterift_read_savedata();
+ if( (arg = vg_long_opt_arg( "server" )) ){
+ vg_strncpy( arg, network_client.server_adress, 64,
+ k_strncpy_overflow_fatal );
+ }
+
+ if( vg_long_opt( "tools" ) ){
+ k_tools_mode = 1;
+ }
+
+ if( vg_long_opt( "demo" ) ){
+ skaterift.demo_mode = 1;
+ }
+
+ if( (arg = vg_long_opt_arg( "world" )) ){
+ skaterift.hub_world = arg;
+ }
+}
+void vg_preload(void)
+{
vg_info(" Copyright . . . -----, ,----- ,---. .---. \n" );
vg_info(" 2021-2023 |\\ /| | / | | | | /| \n" );
vg_info(" | \\ / | +-- / +----- +---' | / | \n" );
vg_info(" ' ' '--' [] '----- '----- ' ' '---' "
"SOFTWARE\n" );
+ /* please forgive me! */
+ u32 sz; char *drm;
+ if( (drm = vg_file_read_text( vg_mem.scratch, "DRM", &sz )) )
+ if( !strcmp(drm, "blibby!") )
+ skaterift.demo_mode = 0;
+
+ vg_loader_step( remote_players_init, NULL );
+
+ if( k_tools_mode )
+ return;
+
steam_init();
vg_loader_step( NULL, steam_end );
- vg_loader_step( remote_players_init, NULL );
vg_loader_step( network_init, network_end );
}
-static void load_playermodels(void){
- /* FIXME: hack */
- shader_model_character_view_register();
- shader_model_board_view_register();
- shader_model_entity_register();
-}
-
static void async_skaterift_player_start( void *payload, u32 size ){
- localplayer.viewable_world = world_current_instance();
- localplayer_cmd_respawn( 1, (const char *[]){ "start" } );
+ world_switch_instance(0);
}
static void async_call_ready( void *payload, u32 size ){
skaterift.op = k_async_op_none;
}
-static void skaterift_restore_state(void){
+static void skaterift_restore_state(void)
+{
savedata_file sav;
- strcpy( sav.path, str_skaterift_main_save );
- savedata_file_read( &sav );
+ skaterift_read_main_savedata( &sav );
- vg_msg kvsav = {0};
- kvsav.buf = sav.buf;
- kvsav.len = sav.len;
- kvsav.max = sizeof(sav.buf);
+ vg_msg kvsav;
+ vg_msg_init( &kvsav, sav.buf, sizeof(sav.buf) );
+
+ u32 ach;
+ vg_msg_getkvintg( &kvsav, "ach", k_vg_msg_u32, &ach );
+ skaterift.achievements |= ach;
u32 board_reg_id = 0,
player_reg_id = 0;
- vg_msg player = kvsav;
- if( vg_msg_seekframe( &player, "player", 0 ) ){
+ vg_msg_cursor orig = kvsav.cur;
+ if( vg_msg_seekframe( &kvsav, "player" ) ){
addon_alias q;
/* board */
- skaterift_read_addon_alias( &player, "board", k_addon_type_board, &q );
+ skaterift_read_addon_alias( &kvsav, "board", k_addon_type_board, &q );
u32 reg_id = addon_match( &q );
if( reg_id != 0xffffffff )
board_reg_id = reg_id;
-
/* playermodel */
- skaterift_read_addon_alias( &player, "playermodel",
+ skaterift_read_addon_alias( &kvsav, "playermodel",
k_addon_type_player, &q );
reg_id = addon_match( &q );
if( reg_id != 0xffffffff )
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;
+ kvsav.cur = orig;
+}
- /* world */
- skaterift_read_addon_alias( &world, "alias", k_addon_type_world, &q );
- u32 reg_id = addon_match( &q );
- if( reg_id != 0xffffffff ){
- addon_reg *reg = get_addon_from_index( k_addon_type_world, reg_id );
-
- world_static.load_state = k_world_loader_load;
- struct world_load_args args = {
- .purpose = k_world_purpose_client,
- .reg = reg
- };
- skaterift_world_load_thread( &args );
-
- world_set_active_instance( vg_msg_seekkvu32( &world, "index", 0 ) );
- world_static.active_trigger_volume_count = 0;
- localplayer.viewable_world = world_current_instance();
- }
+static addon_reg *skaterift_mount_world_unloadable( const char *path, u32 ext ){
+ addon_reg *reg = addon_mount_local_addon( path, k_addon_type_world, ".mdl" );
+ if( !reg ) vg_fatal_error( "world not found\n" );
+ reg->flags |= (ADDON_REG_HIDDEN | ext);
+ return reg;
+}
- vg_msg_cmd position = vg_msg_seekkv( &world, "position", 0 );
- v3f pos;
- vg_msg_convert_num( &position, k_vg_msg_float|k_vg_msg_32b, 3, pos );
+static void skaterift_load_world_content(void){
+ /* hub world */
+ addon_reg *hub = skaterift_mount_world_unloadable( skaterift.hub_world, 0 );
+ skaterift_mount_world_unloadable( "maps/mp_spawn",
+ ADDON_REG_CITY|ADDON_REG_PREMIUM );
+ skaterift_mount_world_unloadable( "maps/mp_mtzero",
+ ADDON_REG_MTZERO|ADDON_REG_PREMIUM );
+ skaterift_mount_world_unloadable( "maps/dev_tutorial", 0 );
+ skaterift_mount_world_unloadable( "maps/dev_flatworld", 0 );
- if( v3_length2(pos) > 1.0f )
- player__setpos( pos );
- }
+ world_static.load_state = k_world_loader_load;
+
+ struct world_load_args args = {
+ .purpose = k_world_purpose_hub,
+ .reg = hub
+ };
+ skaterift_world_load_thread( &args );
+}
+
+static void skaterift_load_player_content(void){
+ u32 bytes = 1024*1024*10;
+ player_replay.local.data = vg_linear_alloc( vg_mem.rtmemory, bytes );
+ player_replay.local.size = bytes;
+ replay_clear( &player_replay.local );
+
+ particle_alloc( &particles_grind, 300 );
+ particle_alloc( &particles_env, 200 );
+
+ player_load_animation_reference( "models/ch_none.mdl" );
+ player_model_load( &localplayer.fallback_model, "models/ch_none.mdl" );
+ player__bind();
+ player_board_load( &localplayer.fallback_board, "models/board_none.mdl" );
}
-static void vg_load(void){
- vg_console_reg_cmd( "changeworld", skaterift_change_world_command, NULL );
+void vg_load(void)
+{
+ if( k_tools_mode ){
+ vg_async_call( async_call_ready, NULL, 0 );
+ return;
+ }
+
+ vg_audio.always_keep_compressed = 1;
+
+ vg_console_reg_cmd( "load_world", skaterift_load_world_command, NULL );
+ vg_console_reg_cmd( "fc", freecam_cmd, NULL );
+ vg_console_reg_var( "immobile", &localplayer.immobile, k_var_dtype_i32, 0 );
vg_loader_step( render_init, NULL );
vg_loader_step( menu_init, NULL );
- vg_loader_step( pointcloud_init, NULL );
vg_loader_step( world_init, NULL );
vg_loader_step( vehicle_init, NULL );
- vg_loader_step( font3d_init, NULL );
vg_loader_step( gui_init, NULL );
vg_loader_step( player_init, NULL );
vg_loader_step( player_ragdoll_init, NULL );
+ vg_loader_step( npc_init, NULL );
/* content stuff */
vg_loader_step( addon_system_init, NULL );
vg_loader_step( workshop_init, NULL );
vg_loader_step( skateshop_init, NULL );
-
- /* ----------------- */
- vg_loader_step( load_playermodels, NULL );
-
- /* player setup */
- u32 bytes = 1024*1024*10;
- skaterift.replay.data = vg_linear_alloc( vg_mem.rtmemory, bytes );
- skaterift.replay.size = bytes;
- replay_clear( &skaterift.replay );
-
- player_avatar_load( &localplayer_avatar, "models/ch_none.mdl" );
- player__use_avatar( &localplayer_avatar );
-
- /* FIXME FIXME FIXME FIXME FIXME */
- u32 mtx_size = sizeof(m4x3f)*localplayer_avatar.sk.bone_count;
- localplayer.final_mtx = vg_linear_alloc( vg_mem.rtmemory, mtx_size );
- netplayers.final_mtx = vg_linear_alloc( vg_mem.rtmemory,
- mtx_size*NETWORK_MAX_PLAYERS );
-
- player_model_load( &localplayer.fallback_model, "models/ch_none.mdl" );
- player__bind();
+ vg_loader_step( ent_tornado_init, NULL );
+ vg_loader_step( skaterift_load_player_content, NULL );
/* --------------------- */
* -------------------------------------
*/
- /* understate diy. */
- addon_reg *spawn = addon_mount_local_addon( "maps/mp_spawn",
- k_addon_type_world,
- ".mdl" );
- {
- vg_msg msg = {0};
- msg.buf = spawn->metadata;
- msg.max = sizeof(spawn->metadata);
- vg_msg_frame( &msg, "workshop" );
- vg_msg_wkvstr( &msg, "title", "Understate DIY" );
- vg_msg_end_frame( &msg );
- vg_msg_wkvstr( &msg, "location", "USA" );
- spawn->metadata_len = msg.cur;
- }
-
- /* mtzero island */
- addon_reg *mtzero = addon_mount_local_addon( "maps/mp_mtzero",
- k_addon_type_world,
- ".mdl" );
- {
- vg_msg msg = {0};
- msg.buf = mtzero->metadata;
- msg.max = sizeof(mtzero->metadata);
- vg_msg_frame( &msg, "workshop" );
- vg_msg_wkvstr( &msg, "title", "Mt.Zero Island" );
- vg_msg_end_frame( &msg );
- vg_msg_wkvstr( &msg, "location", "Australia" );
- mtzero->metadata_len = msg.cur;
- }
-
/* load home/permanent world manually */
- world_static.load_state = k_world_loader_load;
- struct world_load_args args = {
- .purpose = k_world_purpose_hub,
- .reg = spawn
- };
- skaterift_world_load_thread( &args );
-
+ vg_loader_step( skaterift_load_world_content, NULL );
vg_async_call( async_skaterift_player_start, NULL, 0 );
vg_async_stall();
-
- global_skateshop.selected_world_id=1;
- global_skateshop.pointcloud_world_id=1;
- skateshop_world_preview_loader_thread( mtzero ); /* HACK */
-
vg_console_load_autos();
menu_link();
/* and now */
skaterift_restore_state();
+ update_ach_models();
+
vg_loader_step( NULL, skaterift_autosave_synchronous );
//board_processview_thread(NULL);
vg_line( (v3f){ 0.0f, 0.0f, 0.0f }, (v3f){ 0.0f, 1.0f, 0.0f }, 0xff00ff00 );
vg_line( (v3f){ 0.0f, 0.0f, 0.0f }, (v3f){ 0.0f, 0.0f, 1.0f }, 0xff0000ff );
}
-static void skaterift_change_client_world_preupdate(void);
+void skaterift_change_client_world_preupdate(void);
/*
* UPDATE LOOP
* ---------------------------------------------------------------------------*/
-static void vg_pre_update(void){
- srinput.enabled = 1;
+void vg_pre_update(void)
+{
+ skaterift_preupdate_inputs();
+
+ if( k_tools_mode ) return;
steam_update();
- skaterift_preupdate_inputs();
if( skaterift.op == k_async_op_clientloading ) return;
if( world_static.load_state == k_world_loader_preload )
skaterift_change_client_world_preupdate();
/* time rate */
f32 target = 1;
if( skaterift.activity & (k_skaterift_replay|k_skaterift_menu|
- k_skaterift_respawning) ) {
+ k_skaterift_world_map) )
+ {
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();
+ /* TODO: how can we compress this? */
+ ent_miniworld_preupdate();
world_entity_focus_preupdate();
+ player__pre_update();
skaterift_replay_pre_update();
remote_sfx_pre_update();
+ skateshop_world_preupdate( world_current_instance() );
world_update( world_current_instance(), localplayer.rb.co );
audio_ambient_sprites_update( world_current_instance(), localplayer.rb.co );
- respawn_chooser_pre_update();
+ world_map_pre_update();
}
-static void vg_fixed_update(void){
+void vg_fixed_update(void)
+{
+ if( k_tools_mode ) return;
if( skaterift.op == k_async_op_clientloading ) return;
world_routes_fixedupdate( world_current_instance() );
vehicle_update_fixed();
}
-static void vg_post_update(void){
+void vg_post_update(void)
+{
+ if( k_tools_mode ) return;
if( skaterift.op == k_async_op_clientloading ) return;
player__post_update();
audio_unlock();
vehicle_update_post();
-
- if( vg.time - skaterift.last_autosave > 20.0 ){
- if( skaterift_autosave(1) ){
- skaterift.last_autosave = vg.time;
- }
- }
+ skaterift_autosave_update();
}
/*
* RENDERING
* ---------------------------------------------------------------------------*/
-static void vg_framebuffer_resize( int w, int h ){
+void vg_framebuffer_resize( int w, int h ){
render_fb_resize();
}
f32 glitch_strength = 0.0f;
if( skaterift.activity == k_skaterift_replay ){
glitch_strength = 0.005f;
- if( skaterift.replay_control == k_replay_control_play )
+ if( player_replay.replay_control == k_replay_control_play )
glitch_strength = 0.005f;
else
- glitch_strength += 0.005f*skaterift.track_velocity;
+ glitch_strength += 0.005f*player_replay.track_velocity;
}
shader_blitblur_uGlitchStrength( glitch_strength );
}
static void render_player_transparent(void){
- static camera small_cam; /* DOES NOT NEED TO BE STATIC BUT MINGW
+ static vg_camera small_cam; /* DOES NOT NEED TO BE STATIC BUT MINGW
SAIS OTHERWISE */
m4x3_copy( skaterift.cam.transform, small_cam.transform );
small_cam.nearz = 0.05f;
small_cam.farz = 60.0f;
- camera_update_view( &small_cam );
- camera_update_projection( &small_cam );
- camera_finalize( &small_cam );
+ vg_camera_update_view( &small_cam );
+ vg_camera_update_projection( &small_cam );
+ vg_camera_finalize( &small_cam );
/* Draw player to window buffer and blend background ontop */
player__render( &small_cam );
- render_remote_players_tags( localplayer.viewable_world, &skaterift.cam );
+}
+
+static world_instance *get_view_world(void){
+ world_instance *view_world = world_current_instance();
+ if( localplayer.gate_waiting &&
+ (localplayer.gate_waiting->flags & k_ent_gate_nonlocal) ){
+ view_world = &world_static.instances[world_static.active_instance ^ 0x1];
+ }
+
+ return view_world;
}
static void render_scene(void){
/* Draw world */
glEnable( GL_DEPTH_TEST );
- world_instance *view_world = localplayer.viewable_world;
-
- if( view_world == NULL ){
- glClearColor( 0.25f, 0.25f, 0.0f, 1.0f );
- glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT );
- return;
- }
-
for( u32 i=0; i<vg_list_size(world_static.instances); i++ ){
if( world_static.instances[i].status == k_world_status_loaded ){
world_prerender( &world_static.instances[i] );
}
}
- if( skaterift.activity == k_skaterift_respawning ){
+ if( skaterift.activity == k_skaterift_world_map ){
+ world_instance *world = world_current_instance();
glDrawBuffers( 1, (GLenum[]){ GL_COLOR_ATTACHMENT0 } );
- glClearColor( 0.624f, 0.659f, 0.769f, 0.0f );
+
+ v3f bg;
+ v3_muls( world->ub_lighting.g_daysky_colour,
+ world->ub_lighting.g_day_phase -
+ world->ub_lighting.g_sunset_phase*0.1f, bg );
+
+ v3_muladds( bg, world->ub_lighting.g_sunset_colour,
+ (1.0f-0.5f)*world->ub_lighting.g_sunset_phase, bg );
+
+ v3_muladds( bg, world->ub_lighting.g_nightsky_colour,
+ (1.0f-world->ub_lighting.g_day_phase), bg );
+
+ glClearColor( bg[0], bg[1], bg[2], 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 );
- render_world_routes( view_world, &skaterift.cam, 1 );
+
+ m4x3f identity;
+ m4x3_identity( identity );
+ render_world_override( world, world, identity, &skaterift.cam,
+ world_map.spawn,
+ (v4f){world->tar_min, world->tar_max, 1.0f, 0.0f});
+ render_world_routes( world, world, identity, &skaterift.cam, 0, 1 );
+ return;
+ }
+
+ world_instance *view_world = get_view_world();
+ render_world( view_world, &skaterift.cam, 0, 0, 1, 1 );
+
+ particle_system_update( &particles_grind, vg.time_delta );
+ //particle_system_debug( &particles_grind );
+ particle_system_prerender( &particles_grind );
+ particle_system_render( &particles_grind, &skaterift.cam );
+
+ ent_tornado_pre_update();
+ particle_system_update( &particles_env, vg.time_delta );
+ particle_system_prerender( &particles_env );
+ particle_system_render( &particles_env, &skaterift.cam );
+
+ player_glide_render_effects( &skaterift.cam );
+
+ /*
+ * render transition
+ */
+ if( global_miniworld.transition == 0 )
+ return;
+
+ world_instance *holdout_world = NULL;
+ f32 t = 0.0f;
+
+ if( global_miniworld.transition == 1 ){
+ holdout_world = &world_static.instances[ k_world_purpose_hub ];
+ t = global_miniworld.t;
}
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 );
- render_remote_players( view_world, &skaterift.cam );
+ holdout_world = &world_static.instances[ k_world_purpose_client ];
+ t = 1.0f-global_miniworld.t;
}
-}
-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;
+ if( holdout_world->status != k_world_status_loaded )
+ return;
+
+ t = vg_smoothstepf( t );
+
+ glEnable( GL_STENCIL_TEST );
+ glDisable( GL_DEPTH_TEST );
+ glStencilOp( GL_KEEP, GL_KEEP, GL_REPLACE );
+ glStencilFunc( GL_ALWAYS, 1, 0xFF );
+ glStencilMask( 0xFF );
- int depth = 1;
- if( localplayer.gate_waiting ) depth = 0;
- render_world_gates( view_world, &skaterift.cam, depth );
+ shader_blit_transition_use();
+ shader_blit_transition_uInverseRatio( (v2f){1.0f,1.0f} );
+ shader_blit_transition_uT( -(sqrtf(2)+0.5f) * t );
+
+ render_fsquad();
+ render_world( holdout_world, &global_miniworld.cam, 1, 0, 1, 1 );
}
static void skaterift_composite_maincamera(void){
- camera_lerp( &localplayer.cam, &world_static.focus_cam,
+ vg_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 );
+ if( player_replay.freecam ){
+ freecam_preupdate();
+ v3_copy( player_replay.replay_freecam.pos, skaterift.cam.pos );
+ v3_copy( player_replay.replay_freecam.angles, skaterift.cam.angles );
+ skaterift.cam.fov = player_replay.replay_freecam.fov;
+ }
+ else {
+ if( skaterift.activity == k_skaterift_replay ){
+ replay_get_camera( &player_replay.local, &skaterift.cam );
+ }
}
skaterift.cam.nearz = 0.1f;
skaterift.cam.farz = 2100.0f;
- if( skaterift.activity == k_skaterift_respawning ){
- camera_copy( &respawn_chooser.cam, &skaterift.cam );
+ if( skaterift.activity == k_skaterift_world_map ){
+ vg_camera_copy( &world_map.cam, &skaterift.cam );
skaterift.cam.nearz = 4.0f;
- skaterift.cam.farz = 3100.0f;
+ skaterift.cam.farz = 3100.0f;
}
- camera_update_transform( &skaterift.cam );
+ if( global_miniworld.transition ){
+ f32 dt = vg.time_frame_delta / 2.0f,
+ s = vg_signf( global_miniworld.transition );
+ global_miniworld.t += s * dt;
- 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 );
+ if( (global_miniworld.t > 1.0f) || (global_miniworld.t < 0.0f) ){
+ global_miniworld.t = vg_clampf( global_miniworld.t, 0.0f, 1.0f );
+ global_miniworld.transition = 0;
}
}
-
- camera_update_view( &skaterift.cam );
- camera_update_projection( &skaterift.cam );
- camera_finalize( &skaterift.cam );
+
+ vg_camera_update_transform( &skaterift.cam );
+ vg_camera_update_view( &skaterift.cam );
+ vg_camera_update_projection( &skaterift.cam );
+ vg_camera_finalize( &skaterift.cam );
}
static void render_main_game(void){
if( skaterift.activity == k_skaterift_replay ){
- player__animate_from_replay( &skaterift.replay );
+ player__animate_from_replay( &player_replay.local );
}
else{
player__animate();
- skaterift_record_frame( &skaterift.replay, 0 );
+ skaterift_record_frame( &player_replay.local,
+ localplayer.deferred_frame_record );
+ localplayer.deferred_frame_record = 0;
}
animate_remote_players();
player__pre_render();
skaterift_composite_maincamera();
/* --------------------------------------------------------------------- */
+ if( skaterift.activity != k_skaterift_world_map ){
+ world_instance *world = world_current_instance();
+ render_world_cubemaps( world );
- world_instance *view_world = localplayer.viewable_world;
- if( (view_world != NULL) && (skaterift.activity != k_skaterift_respawning) ){
- render_world_cubemaps( view_world );
-
- ent_gate *gate = view_world->rendering_gate;
- if( gate ){
- if( gate->flags & k_ent_gate_nonlocal ){
- world_instance *dest = &world_static.instances[ gate->target ];
- render_world_cubemaps( dest );
- }
- }
+ ent_gate *nlg = world->rendering_gate;
+ if( nlg && nlg->flags & k_ent_gate_nonlocal )
+ render_world_cubemaps( &world_static.instances[nlg->target] );
}
/* variable res target */
portals */
/* continue with variable rate */
- render_scene_gate_subview();
+ if( !global_miniworld.transition &&
+ (skaterift.activity != k_skaterift_world_map) ){
+ render_fb_bind( gpipeline.fb_main, 1 );
+ render_world_gates( get_view_world(), &skaterift.cam );
+ }
/* composite */
present_view_with_post_processing();
+ skaterift_replay_post_render();
+}
- /* --------------------------------------------------------------------- */
-
- /* capture the current resume frame at the very last point */
- if( button_down( k_srbind_reset ) ){
- if( skaterift.activity == k_skaterift_default ){
- skaterift.activity = k_skaterift_replay;
- skaterift_record_frame( &skaterift.replay, 1 );
- if( skaterift.replay.head ){
- skaterift.replay.cursor = skaterift.replay.head->time;
- skaterift.replay.cursor_frame = skaterift.replay.head;
- }
- skaterift.replay_control = k_replay_control_scrub;
- }
+void vg_render(void)
+{
+ if( k_tools_mode ){
+ glBindFramebuffer( GL_FRAMEBUFFER, 0 );
+ glViewport( 0,0, vg.window_x, vg.window_y );
+ glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
+ glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT );
+ return;
}
-}
-static void vg_render(void){
if( skaterift.op == k_async_op_clientloading ){
- _vg_loader_render();
+ vg_loader_render();
return;
}
gui_draw();
}
-static void vg_gui(void){
+void vg_gui(void)
+{
if( skaterift.op == k_async_op_clientloading ) return;
+ if( k_tools_mode ){
+ ui_rect null;
+ ui_rect screen = { 0, 0, vg.window_x, vg.window_y };
+ ui_rect panel = { 0, 0, 1000, 700 };
+ ui_rect_center( screen, panel );
+ vg_ui.wants_mouse = 1;
+
+ ui_fill( panel, ui_colour( k_ui_bg+1 ) );
+ ui_outline( panel, 1, ui_colour( k_ui_bg+7 ), 0 );
+
+ ui_rect_pad( panel, (ui_px[2]){ 8, 8 } );
+
+ return;
+ }
+
+ if( k_light_editor )
+ imgui_world_light_edit( world_current_instance() );
+
+ vg_ui.tex_bg = gpipeline.fb_main->attachments[0].id;
+ render_fb_inverse_ratio( gpipeline.fb_main, vg_ui.bg_inverse_ratio );
+
menu_update();
if( skaterift.activity == k_skaterift_menu ){
glClear( GL_DEPTH_BUFFER_BIT );
player__im_gui();
world_instance *world = world_current_instance();
+ world_routes_imgui( world );
skaterift_replay_imgui();
workshop_form_gui();
render_view_framebuffer_ui();
remote_player_network_imgui( vg.pv );
-}
-
-
-#else
-#include "skaterift_imgui_dev.c"
+ if( skaterift.activity == k_skaterift_world_map ){
+ 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 );
+ }
+}
-#endif
+#include "addon.c"
+#include "addon_types.c"
+#include "audio.c"
+#include "ent_challenge.c"
+#include "ent_glider.c"
+#include "entity.c"
+#include "ent_miniworld.c"
+#include "ent_objective.c"
+#include "ent_region.c"
+#include "ent_relay.c"
+#include "ent_route.c"
+#include "ent_skateshop.c"
+#include "ent_tornado.c"
+#include "ent_traffic.c"
+#include "freecam.c"
+#include "menu.c"
+#include "network.c"
+#include "particle.c"
+#include "player_basic_info.c"
+#include "player.c"
+#include "player_common.c"
+#include "player_dead.c"
+#include "player_drive.c"
+#include "player_effects.c"
+#include "player_glide.c"
+#include "player_ragdoll.c"
+#include "player_remote.c"
+#include "player_render.c"
+#include "player_replay.c"
+#include "player_skate.c"
+#include "player_walk.c"
+#include "render.c"
+#include "save.c"
+#include "scene.c"
+#include "steam.c"
+#include "trail.c"
+#include "vehicle.c"
+#include "workshop.c"
+#include "world_audio.c"
+#include "world.c"
+#include "world_entity.c"
+#include "world_gate.c"
+#include "world_gen.c"
+#include "world_load.c"
+#include "world_map.c"
+#include "world_physics.c"
+#include "world_render.c"
+#include "world_routes.c"
+#include "world_routes_ui.c"
+#include "world_sfd.c"
+#include "world_volumes.c"
+#include "world_water.c"
+#include "ent_npc.c"