}
float occlusion = 1.0f - (d * (1.0f/(sample_dist*(float)sample_count))),
- rate = ktimestep * k_audio_occlusion_rate,
+ rate = VG_TIMESTEP_FIXED * k_audio_occlusion_rate,
target = powf( occlusion, 6.0f );
audio_occlusion_current = vg_lerpf( audio_occlusion_current, target, rate );
}
run_command game
run_command server
;;
- distribution)
+ disb)
mkdir -p ./dist
run_command release
run_command tools
run_command content
run_command textures
run_command server
+ ;;
+ distribution)
titleit "Compressing distributions"
logit "Linux"
tar -chzvf dist/skaterift_linux__$TIMESTAMP.tar.gz bin/linux/
#ifndef COMMON_H
#define COMMON_H
+#define VG_TIMESTEP_FIXED (1.0/60.0)
#define VG_3D
#define VG_FRAMEBUFFER_RESIZE 1
#include "vg/vg.h"
-static float ktimestep = 1.0f/60.0f;
-
typedef struct ray_hit ray_hit;
struct ray_hit
{
.persistent = 1
});
-vg_info(" Copyright . . . -----, ,----- ,---. .---. " );
-vg_info(" 2021-2022 |\\ /| | / | | | | /| " );
-vg_info(" | \\ / | +-- / +----- +---' | / | " );
-vg_info(" | \\ / | | / | | \\ | / | " );
-vg_info(" | \\/ | | / | | \\ | / | " );
+vg_info(" Copyright . . . -----, ,----- ,---. .---. \n" );
+vg_info(" 2021-2022 |\\ /| | / | | | | /| \n" );
+vg_info(" | \\ / | +-- / +----- +---' | / | \n" );
+vg_info(" | \\ / | | / | | \\ | / | \n" );
+vg_info(" | \\/ | | / | | \\ | / | \n" );
vg_info(" ' ' '--' [] '----- '----- ' ' '---' "
- "SOFTWARE" );
+ "SOFTWARE\n" );
highscores_init( 2000, 50 );
vg_loader_highwater( NULL, highscores_save_at_exit, NULL );
{
draw_origin_axis();
network_update();
- player_update();
+ player_update_pre();
world_update( player.phys.rb.co );
}
}
+static void vg_update_fixed( int loaded )
+{
+ if( loaded )
+ {
+ player_update_fixed();
+ }
+}
+
+static void vg_update_post( int loaded )
+{
+ if( loaded )
+ {
+ player_update_post();
+ }
+}
+
static void vg_framebuffer_resize( int w, int h )
{
render_fb_resize();
static void render_main_game(void)
{
- /* TODO Breakup this & Gen */
-#if 0
- float speed = freecam? 0.0f: v3_length( player.phys.rb.v );
- v3f shake = { vg_randf()-0.5f, vg_randf()-0.5f, vg_randf()-0.5f };
- v3_muls( shake, speed*0.01f, shake );
-#endif
-
m4x4f world_4x4;
m4x3_expand( player.camera_inverse, world_4x4 );
gpipeline.fov = freecam? 60.0f: 125.0f; /* 120 */
- m4x4_projection( vg_pv, gpipeline.fov,
- (float)vg_window_x / (float)vg_window_y,
+ m4x4_projection( vg.pv, gpipeline.fov,
+ (float)vg.window_x / (float)vg.window_y,
0.02f, 2100.0f );
- m4x4_mul( vg_pv, world_4x4, vg_pv );
-
+ m4x4_mul( vg.pv, world_4x4, vg.pv );
glEnable( GL_DEPTH_TEST );
/*
int draw_solid = player.is_dead | freecam;
- render_world( vg_pv, player.camera );
+ render_world( vg.pv, player.camera );
if( draw_solid )
draw_player();
render_water_texture( player.camera );
glBindFramebuffer( GL_FRAMEBUFFER, 0 );
- render_water_surface( vg_pv, player.camera );
+ render_water_surface( vg.pv, player.camera );
- render_world_gates( vg_pv, player.phys.rb.co, player.camera );
+ render_world_gates( vg.pv, player.phys.rb.co, player.camera );
/* Copy the RGB of what we have into the background buffer */
glBindFramebuffer( GL_READ_FRAMEBUFFER, 0 );
glBindFramebuffer( GL_DRAW_FRAMEBUFFER, gpipeline.fb_background );
- glBlitFramebuffer( 0,0, vg_window_x, vg_window_y,
- 0,0, vg_window_x, vg_window_y,
+ glBlitFramebuffer( 0,0, vg.window_x, vg.window_y,
+ 0,0, vg.window_x, vg.window_y,
GL_COLOR_BUFFER_BIT,
GL_LINEAR );
if( !draw_solid )
{
- m4x4_projection( vg_pv, gpipeline.fov,
- (float)vg_window_x / (float)vg_window_y,
+ m4x4_projection( vg.pv, gpipeline.fov,
+ (float)vg.window_x / (float)vg.window_y,
0.01f, 600.0f );
- m4x4_mul( vg_pv, world_4x4, vg_pv );
+ m4x4_mul( vg.pv, world_4x4, vg.pv );
draw_player();
}
void vg_render(void)
{
glBindFramebuffer( GL_FRAMEBUFFER, 0 );
- glViewport( 0,0, vg_window_x, vg_window_y );
+ glViewport( 0,0, vg.window_x, vg.window_y );
glDisable( GL_DEPTH_TEST );
glClearColor( 0.11f, 0.35f, 0.37f, 1.0f );
/* Other shite */
glDisable(GL_BLEND);
glDisable( GL_DEPTH_TEST );
- vg_lines_drawall( (float *)vg_pv );
- glViewport( 0,0, vg_window_x, vg_window_y );
+ vg_lines_drawall( (float *)vg.pv );
+ glViewport( 0,0, vg.window_x, vg.window_y );
}
void vg_ui(void)
static double last_update = 0.0;
poll_connection();
- if( vg_time > (last_update + 60.0) )
+ if( vg.time > (last_update + 60.0) )
{
- last_update = vg_time;
+ last_update = vg.time;
if( steam_app_ticket_length )
{
}
}
- if( vg_time > (last_update + 10.0) &&
+ if( vg.time > (last_update + 10.0) &&
(cremote_state == k_ESteamNetworkingConnectionState_Connected ))
{
vg_warn( "Connected to server but no return... disconnecting\n" );
float vswitch, slip, slip_last,
reverse;
- float grab, jump;
+ float grab, jump, pushing, push_time;
+ double start_push;
int in_air, on_board, jump_charge, jump_dir;
m3x3f vr,vr_pstep;
phys,
phys_gate_frame;
- float pushing, push_time;
int is_dead;
v3f land_target;
vg_loader_highwater( player_model_init, player_model_free, NULL );
}
-static void player_update(void) /* 2 */
+/* Deal with input etc */
+static void player_update_pre(void)
{
struct player_phys *phys = &player.phys;
- for( int i=0; i<player.land_log_count; i++ )
- vg_line_cross( player.land_target_log[i],
- player.land_target_colours[i], 0.25f);
-
if( vg_get_axis("grabl")>0.0f)
{
player.is_dead = 0;
{
phys->on_board ^= 0x1;
}
+}
+
+static void player_update_fixed(void) /* 2 */
+{
+ struct player_phys *phys = &player.phys;
-#if 0
- if( (glfwGetKey( vg_window, GLFW_KEY_O ) ))
+ if( player.is_dead )
{
- player_ragdoll_copy_model( phys->rb.v );
- player.is_dead = 1;
+ player_ragdoll_iter();
}
-#endif
+ else
+ {
+ player_do_motion();
+ }
+
+ player_audio(); /* FUTURE: can probably move this to post()
+ BUT, it uses deltas from fixed step physics,
+ AND this *might* be what we want for realtime
+ audio, anyway. */
+}
+
+static void player_update_post(void)
+{
+ for( int i=0; i<player.land_log_count; i++ )
+ vg_line_cross( player.land_target_log[i],
+ player.land_target_colours[i], 0.25f);
if( player.is_dead )
{
- player_ragdoll_iter();
player_debug_ragdoll();
if( !freecam )
}
else
{
- player_do_motion();
player_animate();
if( !freecam )
player_freecam();
player_camera_update();
- player_audio();
}
static void draw_player(void) /* 3 */
vg_tex2d_bind( &tex_characters, 0 );
shader_viewchar_uTexMain( 0 );
shader_viewchar_uCamera( player.camera[3] );
- shader_viewchar_uPv( vg_pv );
+ shader_viewchar_uPv( vg.pv );
shader_link_standard_ub( _shader_viewchar.id, 2 );
glUniformMatrix4x3fv( _uniform_viewchar_uTransforms,
player.mdl.sk.bone_count,
skeleton_lerp_pose( sk, apose, bpose, l, apose );
- float idle_walk = vg_minf( l * 10.0f, 1.0f);
+ float idle_walk = vg_minf(l * 10.0f, 1.0f);
- skeleton_sample_anim( sk, player.mdl.anim_idle, vg_time*0.1f, bpose );
+ skeleton_sample_anim( sk, player.mdl.anim_idle, vg.time*0.1f, bpose );
skeleton_lerp_pose( sk, apose, bpose, 1.0f-idle_walk, apose );
skeleton_apply_pose( &player.mdl.sk, apose, k_anim_apply_defer_ik );
float kickspeed = vg_clampf(v3_length(phys->rb.v)*(1.0f/40.0f), 0.0f, 1.0f);
float kicks = (vg_randf()-0.5f)*2.0f*kickspeed;
float sign = vg_signf( kicks );
- speed_wobble = vg_lerpf( speed_wobble, kicks*kicks*sign, 0.1f );
- speed_wobble_2 = vg_lerpf( speed_wobble_2, speed_wobble, 0.04f );
+ speed_wobble = vg_lerpf( speed_wobble, kicks*kicks*sign, 6.0f*vg.time_delta);
+ speed_wobble_2 = vg_lerpf( speed_wobble_2, speed_wobble, 2.4f*vg.time_delta);
offset[0] *= 0.26f;
offset[0] += speed_wobble_2*3.0f;
/* sliding */
{
float desired = vg_clampf( lslip, 0.0f, 1.0f );
- player.fslide = vg_lerpf( player.fslide, desired, 0.04f );
+ player.fslide = vg_lerpf( player.fslide, desired, 2.4f*vg.time_delta);
}
/* movement information */
dirx = phys->slip < 0.0f? 0.0f: 1.0f,
fly = phys->in_air? 1.0f: 0.0f;
- player.fdirz = vg_lerpf( player.fdirz, dirz, 0.04f );
- player.fdirx = vg_lerpf( player.fdirx, dirx, 0.01f );
- player.ffly = vg_lerpf( player.ffly, fly, 0.04f );
+ player.fdirz = vg_lerpf( player.fdirz, dirz, 2.4f*vg.time_delta );
+ player.fdirx = vg_lerpf( player.fdirx, dirx, 0.6f*vg.time_delta );
+ player.ffly = vg_lerpf( player.ffly, fly, 2.4f*vg.time_delta );
}
struct skeleton *sk = &player.mdl.sk;
{
/* when the player is moving fast he will crouch down a little bit */
float stand = 1.0f - vg_clampf( speed * 0.03f, 0.0f, 1.0f );
- player.fstand = vg_lerpf( player.fstand, stand, 0.1f );
+ player.fstand = vg_lerpf( player.fstand, stand, 6.0f*vg.time_delta );
/* stand/crouch */
float dir_frame = player.fdirz * (15.0f/30.0f),
skeleton_lerp_pose( sk, apose, bpose, player.fslide, apose );
/* pushing */
- player.fpush = vg_lerpf( player.fpush, player.pushing, 0.1f );
+ player.fpush = vg_lerpf( player.fpush,
+ player.phys.pushing,
+ 6.0f*vg.time_delta );
- float pt = player.push_time;
+ float pt = player.phys.push_time;
if( phys->reverse > 0.0f )
skeleton_sample_anim( sk, player.mdl.anim_push, pt, bpose );
else
/* trick setup */
float jump_start_frame = 14.0f/30.0f;
- player.fjump = vg_lerpf( player.fjump, phys->jump, 0.14f );
+ player.fjump = vg_lerpf( player.fjump, phys->jump, 8.4f*vg.time_delta );
float setup_frame = phys->jump * jump_start_frame,
setup_blend = vg_minf( player.fjump, 1.0f );
- float jump_frame = (vg_time - player.jump_time) + jump_start_frame;
+ float jump_frame = (vg.time - player.jump_time) + jump_start_frame;
if( jump_frame >= jump_start_frame && jump_frame <= (40.0f/30.0f) )
setup_frame = jump_frame;
mdl_keyframe air_pose[32];
{
float target = -vg_get_axis("horizontal");
- player.fairdir = vg_lerpf( player.fairdir, target, 0.04f );
+ player.fairdir = vg_lerpf( player.fairdir, target, 2.4f*vg.time_delta );
float air_frame = (player.fairdir*0.5f+0.5f) * (15.0f/30.0f);
static v3f lerp_cam = {0.0f,0.0f,0.0f};
v3f cam_pos;
- player.fonboard = vg_lerpf(player.fonboard, phys->on_board, ktimestep*1.0f);
+ player.fonboard = vg_lerpf( player.fonboard, phys->on_board, vg.time_delta );
if( phys->on_board )
{
}
else
{
- float speed = ktimestep * k_look_speed;
+ float speed = vg.time_delta * k_look_speed;
player.angles[0] += vg_get_axis( "horizontal" ) * speed;
player.angles[1] += vg_get_axis( "vertical" ) * speed;
audio_lock();
- double revert_delta = vg_time - last_revert;
+ double revert_delta = vg.time - last_revert;
if( phys->on_board && (!_air && l2) && (fabsf(phys->slip) > 0.5f) &&
(revert_delta > 0.7) )
{
audio_player_set_vol( &audio_player_extra, 2.0f );
audio_player_playclip( &audio_player_extra, &audio_lands[rand()%5] );
- last_revert = vg_time;
+ last_revert = vg.time;
}
static float air = 0.0f;
- air = vg_lerpf(air, phys->in_air? 1.0f: 0.0f, 5.0f*ktimestep);
+ air = vg_lerpf(air, phys->in_air? 1.0f: 0.0f, 5.0f*VG_TIMESTEP_FIXED );
/* Spacial info */
v3f ears = { 1.0f,0.0f,0.0f };
phys->in_air = 1;
- float pstep = ktimestep*10.0f;
+ float pstep = VG_TIMESTEP_FIXED * 10.0f;
float best_velocity_delta = -9999.9f;
float k_bias = 0.96f;
phys->slip = slip;
phys->reverse = -vg_signf(vel[2]);
- float substep = ktimestep * 0.2f;
+ float substep = VG_TIMESTEP_FIXED * 0.2f;
float fwd_resistance = (vg_get_button( "break" )? 5.0f: 0.02f) * -substep;
for( int i=0; i<5; i++ )
vg_signf( vel[0] ) * -k_friction_lat*substep );
}
- static double start_push = 0.0;
- if( vg_get_button_down( "push" ) )
- start_push = vg_time;
-
if( vg_get_button( "jump" ) )
{
- phys->jump += ktimestep * k_jump_charge_speed;
+ phys->jump += VG_TIMESTEP_FIXED * k_jump_charge_speed;
if( !phys->jump_charge )
phys->jump_dir = phys->reverse > 0.0f? 1: 0;
phys->jump_charge = 1;
}
+ static int push_button_last = 0;
+ int push_button = vg_get_button( "push" );
+ push_button_last = push_button;
+
+ if( push_button && !push_button_last )
+ player.phys.start_push = vg.time;
+
if( !vg_get_button("break") && vg_get_button( "push" ) )
{
- player.pushing = 1.0f;
- player.push_time = vg_time-start_push;
+ player.phys.pushing = 1.0f;
+ player.phys.push_time = vg.time - player.phys.start_push;
- float cycle_time = player.push_time*k_push_cycle_rate,
- amt = k_push_accel * (sinf(cycle_time)*0.5f+0.5f)*ktimestep,
+ float cycle_time = player.phys.push_time*k_push_cycle_rate,
+ amt = k_push_accel * (sinf(cycle_time)*0.5f+0.5f)*VG_TIMESTEP_FIXED,
current = v3_length( vel ),
new_vel = vg_minf( current + amt, k_max_push_speed );
/* Pumping */
static float previous = 0.0f;
float delta = previous - phys->grab,
- pump = delta * k_pump_force*ktimestep;
+ pump = delta * k_pump_force * VG_TIMESTEP_FIXED;
previous = phys->grab;
v3f p1;
m3x3_mulv( phys->rb.to_world, vel, phys->rb.v );
- float steer = vg_get_axis( "horizontal" );
- phys->iY -= vg_signf(steer)*powf(steer,2.0f) * k_steer_ground * ktimestep;
+ float steer = vg_get_axis( "horizontal" ),
+ steer_scaled = vg_signf(steer) * powf(steer,2.0f) * k_steer_ground;
+
+ phys->iY -= steer_scaled * VG_TIMESTEP_FIXED;
}
/*
/*
* Prediction
*/
- float pstep = ktimestep*10.0f;
+ float pstep = VG_TIMESTEP_FIXED * 10.0f;
v3f pco, pco1, pv;
v3_copy( phys->rb.co, pco );
time_to_impact += pstep;
}
- phys->iY -= vg_get_axis( "horizontal" ) * k_steer_air * ktimestep;
+ phys->iY -= vg_get_axis( "horizontal" ) * k_steer_air * VG_TIMESTEP_FIXED;
{
float iX = vg_get_axis( "vertical" ) *
- phys->reverse * k_steer_air * limiter * ktimestep;
+ phys->reverse * k_steer_air * limiter * VG_TIMESTEP_FIXED;
static float siX = 0.0f;
siX = vg_lerpf( siX, iX, k_steer_air_lerp );
{
float move_norm = move * (1.0f/(1.0f-move_dead)),
speed = vg_lerpf( 0.1f*k_runspeed, k_runspeed, move_norm ),
- amt = k_walk_accel * ktimestep,
+ amt = k_walk_accel * VG_TIMESTEP_FIXED,
zvel = v3_dot( phys->rb.v, forward_dir ),
new_vel = vg_minf( zvel + amt, speed ),
diff = new_vel - vg_minf( zvel, speed );
/* TODO move */
float walk_norm = 30.0f/(float)player.mdl.anim_walk->length,
- run_norm = 30.0f/(float)player.mdl.anim_run->length ;
+ run_norm = 30.0f/(float)player.mdl.anim_run->length,
+ walk_adv = vg_lerpf( walk_norm,run_norm,move_norm );
- player.walk_timer += ktimestep * vg_lerpf( walk_norm,run_norm,move_norm );
+ player.walk_timer += walk_adv * VG_TIMESTEP_FIXED;
}
else
{
player.walk_timer = 0.0f;
}
- phys->rb.v[0] *= 1.0f - (ktimestep*k_walk_friction);
- phys->rb.v[2] *= 1.0f - (ktimestep*k_walk_friction);
+ phys->rb.v[0] *= 1.0f - (VG_TIMESTEP_FIXED * k_walk_friction);
+ phys->rb.v[2] *= 1.0f - (VG_TIMESTEP_FIXED * k_walk_friction);
}
/*
float grabt = vg_get_axis( "grabr" )*0.5f+0.5f;
phys->grab = vg_lerpf( phys->grab, grabt, 0.14f );
- player.pushing = 0.0f;
+ player.phys.pushing = 0.0f;
if( !phys->in_air )
{
q_mul( correction, phys->rb.q, phys->rb.q );
}
- v3_muladds( phys->rb.v, phys->rb.up,
- -k_downforce*ktimestep, phys->rb.v );
+ float const DOWNFORCE = -k_downforce*VG_TIMESTEP_FIXED;
+ v3_muladds( phys->rb.v, phys->rb.up, DOWNFORCE, phys->rb.v );
player_physics_control();
v3_muladds( phys->rb.v, jumpdir, force, phys->rb.v );
phys->jump = 0.0f;
- player.jump_time = vg_time;
+ player.jump_time = vg.time;
/* TODO: Move to audio file */
audio_lock();
if( !phys->jump_charge )
{
- phys->jump -= k_jump_charge_speed * ktimestep;
+ phys->jump -= k_jump_charge_speed * VG_TIMESTEP_FIXED;
}
+
phys->jump_charge = 0;
phys->jump = vg_clampf( phys->jump, 0.0f, 1.0f );
}
v3f prevco;
v3_copy( phys->rb.co, prevco );
- apply_gravity( phys->rb.v, ktimestep );
- v3_muladds( phys->rb.co, phys->rb.v, ktimestep, phys->rb.co );
+ apply_gravity( phys->rb.v, VG_TIMESTEP_FIXED );
+ v3_muladds( phys->rb.co, phys->rb.v, VG_TIMESTEP_FIXED, phys->rb.co );
/* Real angular velocity integration */
v3_lerp( phys->rb.w, (v3f){0.0f,0.0f,0.0f}, 0.125f, phys->rb.w );
view_vel = { 0.0f, 0.0f };
if( vg_get_button_down( "primary" ) )
- v2_copy( vg_mouse, mouse_last );
+ v2_copy( vg.mouse, mouse_last );
else if( vg_get_button( "primary" ) )
{
v2f delta;
- v2_sub( vg_mouse, mouse_last, delta );
- v2_copy( vg_mouse, mouse_last );
+ v2_sub( vg.mouse, mouse_last, delta );
+ v2_copy( vg.mouse, mouse_last );
- v2_muladds( view_vel, delta, 0.001f, view_vel );
+ v2_muladds( view_vel, delta, 0.06f*vg.time_delta, view_vel );
}
- v2_muladds( view_vel,
- (v2f){ vg_get_axis("h1"), vg_get_axis("v1") },
- 0.05f, view_vel );
- v2_muls( view_vel, 0.93f, view_vel );
+ v2_muladds( view_vel, (v2f){ vg_get_axis("h1"), vg_get_axis("v1") },
+ 3.0f * vg.time_delta, view_vel );
+
+ v2_muls( view_vel, 1.0f-4.2f*vg.time_delta, view_vel );
v2_add( view_vel, player.angles, player.angles );
player.angles[1] = vg_clampf( player.angles[1], -VG_PIf*0.5f, VG_PIf*0.5f );
}
static v3f move_vel = { 0.0f, 0.0f, 0.0f };
if( vg_get_button( "forward" ) )
- v3_muladds( move_vel, lookdir, ktimestep * movespeed, move_vel );
+ v3_muladds( move_vel, lookdir, VG_TIMESTEP_FIXED * movespeed, move_vel );
if( vg_get_button( "back" ) )
- v3_muladds( move_vel, lookdir, ktimestep *-movespeed, move_vel );
+ v3_muladds( move_vel, lookdir, VG_TIMESTEP_FIXED *-movespeed, move_vel );
if( vg_get_button( "left" ) )
- v3_muladds( move_vel, sidedir, ktimestep *-movespeed, move_vel );
+ v3_muladds( move_vel, sidedir, VG_TIMESTEP_FIXED *-movespeed, move_vel );
if( vg_get_button( "right" ) )
- v3_muladds( move_vel, sidedir, ktimestep * movespeed, move_vel );
+ v3_muladds( move_vel, sidedir, VG_TIMESTEP_FIXED * movespeed, move_vel );
v3_muls( move_vel, 0.7f, move_vel );
v3_add( move_vel, player.camera_pos, player.camera_pos );
{
m4x4_projection( mat,
gpipeline.fov,
- (float)vg_window_x / (float)vg_window_y,
+ (float)vg.window_x / (float)vg.window_y,
nearz, farz );
}
if( !fb )
{
glBindFramebuffer( GL_FRAMEBUFFER, 0 );
- glViewport( 0, 0, vg_window_x, vg_window_y );
+ glViewport( 0, 0, vg.window_x, vg.window_y );
}
else
{
glBindFramebuffer( GL_FRAMEBUFFER, fb->fb );
- glViewport( 0, 0, vg_window_x / fb->div, vg_window_y / fb->div );
+ glViewport( 0, 0, vg.window_x / fb->div, vg.window_y / fb->div );
}
}
static void fb_init( struct framebuffer *fb )
{
- i32 ix = vg_window_x / fb->div,
- iy = vg_window_y / fb->div;
+ i32 ix = vg.window_x / fb->div,
+ iy = vg.window_y / fb->div;
glGenFramebuffers( 1, &fb->fb );
glBindFramebuffer( GL_FRAMEBUFFER, fb->fb );
if( !fb->allocated )
return;
- i32 ix = vg_window_x / fb->div,
- iy = vg_window_y / fb->div;
+ i32 ix = vg.window_x / fb->div,
+ iy = vg.window_y / fb->div;
glBindTexture( GL_TEXTURE_2D, fb->colour );
glTexImage2D( GL_TEXTURE_2D, 0, fb->format, ix, iy, 0,
if( gpipeline.ready )
{
glBindTexture( GL_TEXTURE_2D, gpipeline.rgb_background );
- glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, vg_window_x, vg_window_y, 0,
+ glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, vg.window_x, vg.window_y, 0,
GL_RGB, GL_UNSIGNED_BYTE, NULL );
}
}
glGenTextures( 1, &gpipeline.rgb_background );
glBindTexture( GL_TEXTURE_2D, gpipeline.rgb_background );
- glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, vg_window_x, vg_window_y,
+ glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, vg.window_x, vg.window_y,
0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
float depth = v3_dot( plane, ra->co ) - plane[3],
lambda = vg_clampf( -depth, 0.0f, 1.0f ) * amt;
- v3_muladds( ra->v, plane, lambda * ktimestep, ra->v );
+ v3_muladds( ra->v, plane, lambda * VG_TIMESTEP_FIXED, ra->v );
if( depth < 0.0f )
- v3_muls( ra->v, 1.0f-(drag*ktimestep), ra->v );
+ v3_muls( ra->v, 1.0f-(drag*VG_TIMESTEP_FIXED), ra->v );
}
/*
#include "common.h"
#include "model.h"
#include "rigidbody.h"
+#include "world.h"
typedef struct traffic_node traffic_node;
typedef struct traffic_driver traffic_driver;
v3_muladds( next->co, next->h, -1.0f, h1 );
eval_bezier_time( p0,p1,h0,h1, driver->t, pc );
- eval_bezier_time( p0,p1,h0,h1, driver->t + ktimestep, pn );
+ eval_bezier_time( p0,p1,h0,h1, driver->t + vg.time_delta, pn );
- float mod = ktimestep / v3_dist( pc, pn );
+ float mod = vg.time_delta / v3_dist( pc, pn );
v3f dir,side,up;
v3_sub( pn, pc, dir );
v3_normalize(dir);
* Jesus take the wheel
*/
float steer_penalty = 1.0f-v3_dot( dir, driver->transform[0] );
- steer_penalty /= ktimestep;
+ steer_penalty /= vg.time_delta;
steer_penalty *= 30.0f;
float target_speed = vg_maxf( 16.0f * (1.0f-steer_penalty), 0.1f ),
accel = target_speed - driver->speed;
- driver->speed = stable_force( driver->speed, accel*ktimestep*2.0f );
- driver->t += driver->speed*mod*ktimestep;
+ driver->speed = stable_force( driver->speed, accel*vg.time_delta*2.0f );
+ driver->t += driver->speed*mod*vg.time_delta;
/*
* Update transform
static void world_update( v3f pos )
{
world_routes_update();
+#if 0
world_routes_debug();
+#endif
int closest = 0;
float min_dist = INFINITY;
glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT );
#else
shader_gatelq_use();
- shader_gatelq_uPv( vg_pv );
+ shader_gatelq_uPv( vg.pv );
shader_gatelq_uMdl( gate_xform );
shader_gatelq_uCam( viewpos );
- shader_gatelq_uTime( vg_time*0.25f );
+ shader_gatelq_uTime( vg.time*0.25f );
shader_gatelq_uInvRes( (v2f){
- 1.0f / (float)vg_window_x,
- 1.0f / (float)vg_window_y });
+ 1.0f / (float)vg.window_x,
+ 1.0f / (float)vg.window_y });
glEnable( GL_STENCIL_TEST );
glStencilOp( GL_KEEP, GL_KEEP, GL_REPLACE );
shader_sky_uMdl(identity_matrix);
shader_sky_uPv(full);
shader_sky_uTexGarbage(0);
- shader_sky_uTime( vg_time );
+ shader_sky_uTime( vg.time );
vg_tex2d_bind( &tex_terrain_noise, 0 );
static void world_routes_interact(void)
{
- world.routes.last_interaction = vg_time;
+ world.routes.last_interaction = vg.time;
}
static void debug_sbpath( struct route_node *rna, struct route_node *rnb,
shader_routeui_use();
glBindVertexArray( pr->ui.vao );
- float fade_amt = vg_time - pr->ui.fade_timer_start;
+ float fade_amt = vg.time - pr->ui.fade_timer_start;
fade_amt = vg_clampf( fade_amt / 1.0f, 0.0f, 1.0f );
float fade_block_size = 0.0f,
v4_copy( colour, fade_colour );
fade_colour[3] *= 1.0f-fade_amt;
- float timer_delta = (vg_time - world.routes.last_interaction) * (1.0/60.0),
+ float timer_delta = (vg.time - world.routes.last_interaction) * (1.0/60.0),
timer_scale = 1.0f - vg_minf( timer_delta, 1.0f );
/*
pr->ui.fade_start = pr->ui.segment_start;
pr->ui.fade_count = 0;
- pr->ui.fade_timer_start = vg_time;
+ pr->ui.fade_timer_start = vg.time;
int orig_seg_count = pr->ui.segment_count;
pr->ui.fade_count ++;
}
- r->routes[route].latest_pass = vg_time;
+ r->routes[route].latest_pass = vg.time;
}
/*
r->active_gate = id;
rg->timing.version = r->current_run_version;
- rg->timing.time = vg_time;
+ rg->timing.time = vg.time;
for( u32 i=0; i<r->route_count; i++ )
{
struct route *route = &r->routes[i];
{
route->ui.fade_start = route->ui.segment_start;
route->ui.fade_count = route->ui.segment_count;
- route->ui.fade_timer_start = vg_time;
+ route->ui.fade_timer_start = vg.time;
world_routes_ui_clear(i);
vg_success( "CLEARING -> %u %u \n", route->ui.fade_start,
r->current_run_version ++;
rc->timing.version = r->current_run_version;
- rc->timing.time = vg_time;
+ rc->timing.time = vg.time;
r->current_run_version ++;
}
struct route *route = &r->routes[i];
if( route->active )
- world_routes_ui_notch( i, vg_time - route->latest_pass );
+ world_routes_ui_notch( i, vg.time - route->latest_pass );
}
}
for( int i=0; i<r->route_count; i++ )
{
struct route *route = &r->routes[i];
- route->factive = vg_lerpf( route->factive, route->active, 0.01f );
+ route->factive = vg_lerpf( route->factive, route->active,
+ 0.6f*vg.time_delta );
if( route->active )
{
- world_routes_ui_updatetime( i, vg_time - route->latest_pass );
+ world_routes_ui_updatetime( i, vg.time - route->latest_pass );
}
}
}
float *target = &display->buffer[i],
*cur = target+display->w*display->h;
- float const rate = ktimestep*15.2313131414f;
+ float const rate = vg.time_delta * 15.2313131414f;
float d1 = *target-*cur;
if( fabsf(d1) > rate )
m4x4f projection;
m4x4_projection( projection,
gpipeline.fov,
- (float)vg_window_x / (float)vg_window_y,
+ (float)vg.window_x / (float)vg.window_y,
0.1f, 900.0f );
plane_clip_projection( projection, clippa );
m4x4_mul( projection, view, projection );
m4x4_projection( projection,
gpipeline.fov,
- (float)vg_window_x / (float)vg_window_y,
+ (float)vg.window_x / (float)vg.window_y,
0.1f, 900.0f );
plane_clip_projection( projection, clippb );
m4x4_mul( projection, view, projection );
render_world_depth( projection, camera );
- glViewport( 0, 0, vg_window_x, vg_window_y );
+ glViewport( 0, 0, vg.window_x, vg.window_y );
}
static void render_water_surface( m4x4f pv, m4x3f camera )
vg_tex2d_bind( &tex_water_surf, 1 );
shader_water_uTexDudv( 1 );
shader_water_uInvRes( (v2f){
- 1.0f / (float)vg_window_x,
- 1.0f / (float)vg_window_y });
+ 1.0f / (float)vg.window_x,
+ 1.0f / (float)vg.window_y });
shader_link_standard_ub( _shader_water.id, 2 );
fb_bindtex( &wrender.fbdepth, 3 );
shader_water_uTexBack( 3 );
- shader_water_uTime( vg_time );
+ shader_water_uTime( vg.time );
shader_water_uCamera( camera[3] );
shader_water_uSurfaceY( wrender.height );