update vg
authorhgn <hgodden00@gmail.com>
Sun, 16 Apr 2023 06:37:56 +0000 (07:37 +0100)
committerhgn <hgodden00@gmail.com>
Sun, 16 Apr 2023 06:37:56 +0000 (07:37 +0100)
13 files changed:
audio.h
maps_src/mp_mtzero.mdl
menu.h
player.c
player_common.c
player_dead.c
player_skate.c
player_walk.c
render.h
rigidbody.h
skaterift.c
world_render.h
world_routes.h

diff --git a/audio.h b/audio.h
index 5eb499a0c44ce2eebfeca0f7a3daba7b0736bf3c..51445b665b6edfc70e49a8d247e326bf90be157a 100644 (file)
--- a/audio.h
+++ b/audio.h
@@ -189,7 +189,7 @@ VG_STATIC void audio_ambient_sprite_play( v3f co, audio_clip *clip )
 VG_STATIC void audio_ambient_sprites_update( world_instance *world, v3f co )
 {
    static float accum = 0.0f;
-   accum += vg.frame_delta;
+   accum += vg.time_delta;
 
    if( accum > 0.1f )
       accum -= 0.1f;
index 2b5bded00faae755df5dad593f8b9ce18bf79d31..9eb41d7e29c9581fa5545ebe62d11248bccf4364 100644 (file)
Binary files a/maps_src/mp_mtzero.mdl and b/maps_src/mp_mtzero.mdl differ
diff --git a/menu.h b/menu.h
index b69345659642f2bdf9c589fd1e37d7e64c8c5f77..1e2b8e7d422f607d432eb0873868c4710f39c722 100644 (file)
--- a/menu.h
+++ b/menu.h
@@ -604,7 +604,7 @@ VG_STATIC void menu_slider( float *value, int set_value,
    if( set_value ){
       float h = input_menu_h.axis.value;
       if( fabsf(h) > 0.04f )
-         *value += h * vg.frame_delta;
+         *value += h * vg.time_frame_delta;
       *value = vg_clampf( *value, 0.0f, 1.0f );
    }
 
@@ -729,7 +729,7 @@ VG_STATIC void menu_update(void)
       m3x3_mul( player->basis, menu_mdl_mtx, menu_mdl_mtx );
 
       menu_smooth_fov = vg_lerpf( menu_smooth_fov, menu_fov_target, 
-                                  vg.frame_delta * 8.2f );
+                                  vg.time_frame_delta * 8.2f );
    }
 
    /* Extra */
@@ -740,7 +740,7 @@ VG_STATIC void menu_update(void)
 
       float y = atan2f( delta[0], delta[2] ),
             p = -sinf(delta[1]),
-            dt = vg.frame_delta;
+            dt = vg.time_frame_delta;
 
       menu_extra_angles[0] = vg_lerpf( menu_extra_angles[0], y, dt );
       menu_extra_angles[1] = vg_lerpf( menu_extra_angles[1], p, dt );
@@ -750,7 +750,7 @@ VG_STATIC void menu_update(void)
       menu_camera_angles[0] = fmodf( menu_camera_angles[0], VG_TAUf );
    }
 
-   float dt = vg.frame_delta * 6.0f;
+   float dt = vg.time_frame_delta * 6.0f;
    menu_opacity = vg_lerpf( menu_opacity, cl_menu&&!cl_menu_go_away, dt );
 
    if( menu_opacity <= 0.01f ){
@@ -761,7 +761,7 @@ VG_STATIC void menu_update(void)
    vg.time_rate = 1.0-(double)menu_opacity;
 
    if( cl_menu ){
-      menu_input_cooldown -= vg.frame_delta;
+      menu_input_cooldown -= vg.time_frame_delta;
    }
 }
 
@@ -807,8 +807,8 @@ VG_STATIC void menu_render_fg( camera *cam )
             tsize1 = i==game_menu.loc? 0.07f: 0.0f,
             tsize  = tsize0+tsize1;
 
-      btn->falpha = vg_lerpf( btn->falpha, talpha, vg.frame_delta * 14.0f );
-      btn->fsize  = vg_lerpf( btn->fsize,  tsize,  vg.frame_delta * 7.0f  );
+      btn->falpha = vg_lerpf( btn->falpha, talpha, vg.time_frame_delta * 14.0f);
+      btn->fsize  = vg_lerpf( btn->fsize,  tsize,  vg.time_frame_delta * 7.0f );
 
       /* Colour */
       v4f vselected = {0.95f*1.3f,0.45f*1.3f,0.095f*1.3f, 1.0f},
index b804ed14b23e71aadd9ac65d449d4332e5abaf47..19c44929cd61f01ea336592f8ab36d2d6e266438 100644 (file)
--- a/player.c
+++ b/player.c
@@ -273,7 +273,7 @@ void player__post_update( player_instance *player )
       _player_post_update[ player->subsystem ]( player );
 
    if((player->subsystem != k_player_subsystem_dead) && !player->gate_waiting){
-      player->rewind_accum += vg.frame_delta;
+      player->rewind_accum += vg.time_frame_delta;
 
       if( player->rewind_accum > 0.25f ){
          player->rewind_accum -= 0.25f;
@@ -377,7 +377,7 @@ VG_STATIC void player__pre_render( player_instance *player )
       if( player->holdout_time > 0.0f ){
          skeleton_lerp_pose( sk, res.pose, player->holdout_pose, 
                                            player->holdout_time, res.pose );
-         player->holdout_time -= vg.frame_delta * 2.0f;
+         player->holdout_time -= vg.time_frame_delta * 2.0f;
       }
 
       skeleton_apply_pose( sk, res.pose, k_anim_apply_defer_ik );
index f058b56569ac2bb9b7aa4c20c7a6e192fb6545b5..21d52aa76871c6f978d10f3bda4334ae614e5671 100644 (file)
@@ -89,17 +89,17 @@ VG_STATIC void player__cam_iterate( player_instance *player )
    player->cam_velocity_influence_smooth = vg_lerpf(
          player->cam_velocity_influence_smooth, 
          player->cam_velocity_influence,
-         vg.frame_delta * 8.0f );
+         vg.time_frame_delta * 8.0f );
 
    player->cam_velocity_coefficient_smooth = vg_lerpf(
          player->cam_velocity_coefficient_smooth,
          player->cam_velocity_coefficient,
-         vg.frame_delta * 8.0f );
+         vg.time_frame_delta * 8.0f );
 
    player->cam_velocity_constant_smooth = vg_lerpf(
          player->cam_velocity_constant_smooth,
          player->cam_velocity_constant,
-         vg.frame_delta * 8.0f );
+         vg.time_frame_delta * 8.0f );
 
    enum camera_mode target_mode = player->camera_mode;
 
@@ -109,16 +109,16 @@ VG_STATIC void player__cam_iterate( player_instance *player )
    player->camera_type_blend = 
       vg_lerpf( player->camera_type_blend, 
                 (target_mode == k_cam_firstperson)? 1.0f: 0.0f,
-                5.0f * vg.frame_delta );
+                5.0f * vg.time_frame_delta );
 
    v3_lerp( player->fpv_viewpoint_smooth, player->fpv_viewpoint,
-         vg.frame_delta * 8.0f, player->fpv_viewpoint_smooth );
+         vg.time_frame_delta * 8.0f, player->fpv_viewpoint_smooth );
 
    v3_lerp( player->fpv_offset_smooth, player->fpv_offset,
-         vg.frame_delta * 8.0f, player->fpv_offset_smooth );
+         vg.time_frame_delta * 8.0f, player->fpv_offset_smooth );
 
    v3_lerp( player->tpv_offset_smooth, player->tpv_offset,
-         vg.frame_delta * 8.0f, player->tpv_offset_smooth );
+         vg.time_frame_delta * 8.0f, player->tpv_offset_smooth );
 
    /* fov -- simple blend */
    float fov_skate = vg_lerpf( 97.0f, 135.0f, cl_fov ),
@@ -139,7 +139,7 @@ VG_STATIC void player__cam_iterate( player_instance *player )
 
    /* angles */
    v3f velocity_angles;
-   v3_lerp( player->cam_velocity_smooth, player->rb.v, 4.0f*vg.frame_delta, 
+   v3_lerp( player->cam_velocity_smooth, player->rb.v, 4.0f*vg.time_frame_delta, 
             player->cam_velocity_smooth );
 
    v3f velocity_local;
@@ -167,7 +167,7 @@ VG_STATIC void player__cam_iterate( player_instance *player )
     * it is done in the local basis then transformed back */
 
    v3f future;
-   v3_muls( player->rb.v, 0.4f*vg.frame_delta, future );
+   v3_muls( player->rb.v, 0.4f*vg.time_frame_delta, future );
    m3x3_mulv( player->invbasis, future, future );
 
    v3f camera_follow_dir = 
@@ -193,7 +193,7 @@ VG_STATIC void player__cam_iterate( player_instance *player )
    v3f pco;
    v4f pq;
    rb_extrapolate( &player->rb, pco, pq );
-   v3_lerp( player->tpv_lpf, pco, 20.0f*vg.frame_delta, player->tpv_lpf );
+   v3_lerp( player->tpv_lpf, pco, 20.0f*vg.time_frame_delta, player->tpv_lpf );
 
    /* now move into world */
 
@@ -213,8 +213,8 @@ VG_STATIC void player__cam_iterate( player_instance *player )
 
    float Fd = -player->cam_land_punch_v * k_cam_damp,
          Fs = -player->cam_land_punch   * k_cam_spring;
-   player->cam_land_punch   += player->cam_land_punch_v * vg.frame_delta;
-   player->cam_land_punch_v += ( Fd + Fs ) * vg.frame_delta;
+   player->cam_land_punch   += player->cam_land_punch_v * vg.time_frame_delta;
+   player->cam_land_punch_v += ( Fd + Fs ) * vg.time_frame_delta;
    player->cam.angles[1] += player->cam_land_punch;
 
    /* override camera */
index e06c20abad85670825a3af264246352852abdd9c..b7e6bce8539f82676fb51bf9f0fe2e46e77c3a2a 100644 (file)
@@ -31,9 +31,9 @@ VG_STATIC void player__dead_post_animate( player_instance *player )
 
    struct ragdoll_part *part = &player->ragdoll.parts[ av->id_hip-1 ];
 
-   v3_lerp( d->co_lpf, part->obj.rb.co, vg.frame_delta*4.0f, d->co_lpf );
-   v3_lerp( d->v_lpf,  part->obj.rb.v,  vg.frame_delta*4.0f, d->v_lpf );
-   v3_lerp( d->w_lpf,  part->obj.rb.w,  vg.frame_delta*4.0f, d->w_lpf );
+   v3_lerp( d->co_lpf, part->obj.rb.co, vg.time_frame_delta*4.0f, d->co_lpf );
+   v3_lerp( d->v_lpf,  part->obj.rb.v,  vg.time_frame_delta*4.0f, d->v_lpf );
+   v3_lerp( d->w_lpf,  part->obj.rb.w,  vg.time_frame_delta*4.0f, d->w_lpf );
    
    v3_copy( d->co_lpf, player->rb.co );
    v3_copy( d->v_lpf, player->rb.v );
index e9a4f09f4b01cbaca4857b4b0e95c897f82218c4..c300b3f579a67c95a1b95663d00d5b89b461726d 100644 (file)
@@ -1192,7 +1192,7 @@ VG_STATIC void player__skate_post_update( player_instance *player )
    }
 
    static float menu_gate = 1.0f;
-   menu_gate = vg_lerpf( menu_gate, 1-cl_menu, vg.frame_delta*4.0f );
+   menu_gate = vg_lerpf( menu_gate, 1-cl_menu, vg.time_frame_delta*4.0f );
 
    float
          vol_main    = sqrtf( (1.0f-air)*attn*(1.0f-slide) * 0.4f ) * menu_gate,
@@ -1230,7 +1230,7 @@ VG_STATIC void player__skate_post_update( player_instance *player )
                           vg_lerpf( 250.0f, 80.0f, attn ) );
 
    if( s->sample_change_cooldown > 0.0f ){
-      s->sample_change_cooldown -= vg.frame_delta;
+      s->sample_change_cooldown -= vg.time_frame_delta;
    }
    else{
       int sample_type = k_skate_sample_concrete;
@@ -2740,11 +2740,10 @@ VG_STATIC void player__skate_animate( player_instance *player,
                                (vg.time - s->state.cur_push) < 0.125,
                                6.0f*vg.time_delta );
 
-      float pt = push_time + vg.accumulator;
       if( s->state.reverse > 0.0f )
-         skeleton_sample_anim( sk, s->anim_push, pt, bpose );
+         skeleton_sample_anim( sk, s->anim_push, push_time, bpose );
       else
-         skeleton_sample_anim( sk, s->anim_push_reverse, pt, bpose );
+         skeleton_sample_anim( sk, s->anim_push_reverse, push_time, bpose );
 
       skeleton_lerp_pose( sk, apose, bpose, s->blend_push, apose );
 
@@ -2862,7 +2861,8 @@ VG_STATIC void player__skate_animate( player_instance *player,
             vg_warn( "FIX THIS! CARROT\n" );
             v4_copy( player->rb.q, s->state.smoothed_rotation );
          }
-         v4_lerp( s->state.smoothed_rotation, player->rb.q, 2.0f*vg.frame_delta,
+         v4_lerp( s->state.smoothed_rotation, player->rb.q, 
+                  2.0f*vg.time_frame_delta,
                   s->state.smoothed_rotation );
          q_normalize( s->state.smoothed_rotation );
 
@@ -3031,7 +3031,7 @@ VG_STATIC void player__skate_animate( player_instance *player,
    rb_extrapolate( &player->rb, dest->root_co, dest->root_q );
    v3_muladds( dest->root_co, player->rb.to_world[1], -0.1f, dest->root_co );
 
-   float substep = vg_clampf( vg.accumulator / VG_TIMESTEP_FIXED, 0.0f, 1.0f );
+   float substep = vg.time_fixed_extrapolate;
 
    v4f qflip;
    if( (s->state.activity <= k_skate_activity_air_to_grind) &&
index 7f857fed8d1cc7c82224a8d792e905c0762f8408..7d160a7a09d0d801cb19f15bc230cb5f9b37c8f1 100644 (file)
@@ -599,7 +599,7 @@ VG_STATIC void player__walk_post_update( player_instance *player )
    m3x3_copy( player->rb.to_world, mtx );
    v3_add( player->rb.co, player->basis[1], mtx[3] );
 
-   float substep = vg_clampf( vg.accumulator / k_rb_delta, 0.0f, 1.0f );
+   float substep = vg.time_fixed_extrapolate;
    v3_muladds( mtx[3], player->rb.v, k_rb_delta*substep, mtx[3] );
    debug_capsule( mtx, w->collider.radius, w->collider.height, VG__YELOW );
 
index b920983d7970b18b24b83faa25a4854ee988eac1..a4005ddbcec76028b77fd873c6b9b8dca479a7b1 100644 (file)
--- a/render.h
+++ b/render.h
@@ -58,8 +58,9 @@ struct framebuffer{
       
       enum framebuffer_attachment_type{
          k_framebuffer_attachment_type_none,
-         k_framebuffer_attachment_type_colour,
-         k_framebuffer_attachment_type_renderbuffer
+         k_framebuffer_attachment_type_texture,
+         k_framebuffer_attachment_type_renderbuffer,
+         k_framebuffer_attachment_type_texture_depth
       }
       purpose;
 
@@ -95,7 +96,7 @@ framebuffers[] =
       .attachments = 
       {
          {
-            "colour", k_framebuffer_attachment_type_colour,
+            "colour", k_framebuffer_attachment_type_texture,
 
             .internalformat = GL_RGB,
             .format         = GL_RGB,
@@ -103,7 +104,7 @@ framebuffers[] =
             .attachment     = GL_COLOR_ATTACHMENT0
          },
          {
-            "motion", k_framebuffer_attachment_type_colour,
+            "motion", k_framebuffer_attachment_type_texture,
 
             .quality        = k_framebuffer_quality_high_only,
             .internalformat = GL_RG16F,
@@ -117,7 +118,7 @@ framebuffers[] =
 
             .internalformat = GL_DEPTH24_STENCIL8,
 #else
-            "depth_stencil", k_framebuffer_attachment_type_colour,
+            "depth_stencil", k_framebuffer_attachment_type_texture_depth,
             .internalformat = GL_DEPTH24_STENCIL8,
             .format         = GL_DEPTH_STENCIL,
             .type           = GL_UNSIGNED_INT_24_8,
@@ -136,7 +137,7 @@ framebuffers[] =
       .attachments = 
       {
          {
-            "colour", k_framebuffer_attachment_type_colour,
+            "colour", k_framebuffer_attachment_type_texture,
             .internalformat = GL_RGB,
             .format         = GL_RGB,
             .type           = GL_UNSIGNED_BYTE,
@@ -161,7 +162,7 @@ framebuffers[] =
       .attachments = 
       {
          {
-            "colour", k_framebuffer_attachment_type_colour,
+            "colour", k_framebuffer_attachment_type_texture,
             .internalformat = GL_RED,
             .format         = GL_RED,
             .type           = GL_UNSIGNED_BYTE,
@@ -240,8 +241,10 @@ VG_STATIC void render_fb_bind_texture( framebuffer *fb,
 {
    struct framebuffer_attachment *at = &fb->attachments[attachment];
 
-   if( at->purpose != k_framebuffer_attachment_type_colour ){
-      vg_fatal_exit_loop( "illegal operation: bind non-colour framebuffer"
+   if( (at->purpose != k_framebuffer_attachment_type_texture) &&
+       (at->purpose != k_framebuffer_attachment_type_texture_depth) )
+   {
+      vg_fatal_exit_loop( "illegal operation: bind non-texture framebuffer"
                           " attachment to texture slot" );
    }
 
@@ -388,7 +391,9 @@ VG_STATIC void render_fb_allocate_texture( struct framebuffer *fb,
       glBindRenderbuffer( GL_RENDERBUFFER, a->id );
       glRenderbufferStorage( GL_RENDERBUFFER, a->internalformat, rx, ry );
    }
-   else if( a->purpose == k_framebuffer_attachment_type_colour ){
+   else if( a->purpose == k_framebuffer_attachment_type_texture ||
+            a->purpose == k_framebuffer_attachment_type_texture_depth )
+   {
       glBindTexture( GL_TEXTURE_2D, a->id );
       glTexImage2D( GL_TEXTURE_2D, 0, a->internalformat, rx, ry,
                                    0, a->format, a->type, NULL );
@@ -429,7 +434,9 @@ VG_STATIC void render_fb_allocate( struct framebuffer *fb )
                                     GL_DEPTH_STENCIL_ATTACHMENT,
                                     GL_RENDERBUFFER, attachment->id );
       }
-      else if( attachment->purpose == k_framebuffer_attachment_type_colour ){
+      else if( attachment->purpose == k_framebuffer_attachment_type_texture || 
+         attachment->purpose == k_framebuffer_attachment_type_texture_depth )
+      {
          glGenTextures( 1, &attachment->id );
          render_fb_allocate_texture( fb, attachment );
          glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
@@ -440,7 +447,8 @@ VG_STATIC void render_fb_allocate( struct framebuffer *fb )
          glFramebufferTexture2D( GL_FRAMEBUFFER, attachment->attachment,
                                  GL_TEXTURE_2D,  attachment->id, 0 );
 
-         colour_attachments[ colour_count ++ ] = attachment->attachment;
+         if( attachment->purpose == k_framebuffer_attachment_type_texture )
+            colour_attachments[ colour_count ++ ] = attachment->attachment;
       }
    }
 
index 5796c7aed341b577afad3bc607e40a7b046bcabf..3d2f4107ca962f433e4f85d46493c2911fc5e816 100644 (file)
@@ -375,8 +375,7 @@ VG_STATIC void rb_update_transform( rigidbody *rb )
  */
 VG_STATIC void rb_extrapolate( rigidbody *rb, v3f co, v4f q )
 {
-   float substep = vg_clampf( vg.accumulator / k_rb_delta, 0.0f, 1.0f );
-
+   float substep = vg.time_fixed_extrapolate;
    v3_muladds( rb->co, rb->v, k_rb_delta*substep, co );
 
    if( v3_length2( rb->w ) > 0.0f ){
index eb69bc7c18a1af50a71d3a9001044a3dcc9b8c3f..c3dec8c87d9a749cbb6a0b68173794abb8fd9694 100644 (file)
@@ -12,7 +12,7 @@
  */
 
 #define SR_NETWORKED
-#define VG_DEVWINDOW
+//#define VG_DEVWINDOW
 #include "common.h"
 #include "conf.h"
 #include "steam.h"
@@ -166,8 +166,11 @@ VG_STATIC void vg_load(void)
    /* 'systems' are completely loaded now */
 
    /* load home world */
+#if 0
    world_load( 0, "maps/mp_spawn.mdl" );
-   world_load( 1, "maps/mp_mtzero.mdl" );
+#endif
+
+   world_load( 0, "maps/mp_mtzero.mdl" );
 
 #if 0
    world_load( &world_global.worlds[1], "maps/mp_gridmap.mdl" );
@@ -307,7 +310,8 @@ VG_STATIC void present_view_with_post_processing(void)
       shader_blitblur_use();
       shader_blitblur_uTexMain( 0 );
       shader_blitblur_uTexMotion( 1 );
-      shader_blitblur_uBlurStrength(cl_blur_strength / (vg.frame_delta*60.0f));
+      shader_blitblur_uBlurStrength( cl_blur_strength / 
+                                     (vg.time_frame_delta*60.0) );
       shader_blitblur_uInverseRatio( inverse );
 
       v2f menu_blurring;
index 4e390368e9f4f51a65283e0534b5e54ef349129a..b1972ba546cf7cafd4774294559c7a39eaabbfc2 100644 (file)
@@ -49,7 +49,7 @@ VG_STATIC void world_render_init(void)
          fb->resolution_div = 0;
 
          fb->attachments[0].display_name     = NULL;
-         fb->attachments[0].purpose = k_framebuffer_attachment_type_colour;
+         fb->attachments[0].purpose = k_framebuffer_attachment_type_texture;
          fb->attachments[0].internalformat   = GL_RG16F;
          fb->attachments[0].format           = GL_RG;
          fb->attachments[0].type             = GL_FLOAT;
index 66a4fa5c022bfd0154fc91a7f0f3086251b7cd18..f5add0bb6ba162d336509e66935debc6b2dd288d 100644 (file)
@@ -103,7 +103,7 @@ VG_STATIC void world_routes_time_lap( world_instance *world, ent_route *route )
       }
 
       last_version = rg->timing_version;
-      vg_info( "%u %f\n", rg, rg->timing_version, rg->timing_time );
+      vg_info( "%u %f\n", rg->timing_version, rg->timing_time );
    }
 
    if( world_global.current_run_version == last_version+1 ){