dusting
authorhgn <hgodden00@gmail.com>
Thu, 13 Apr 2023 04:51:16 +0000 (05:51 +0100)
committerhgn <hgodden00@gmail.com>
Thu, 13 Apr 2023 04:51:16 +0000 (05:51 +0100)
39 files changed:
audio.h
bvh.h
common.h
conf.h
player.c
player.h
player_animation.h [deleted file]
player_common.c
player_ragdoll.h
player_skate.h
player_walk.h
render.h
rigidbody.h
shaders/common_scene.glsl
shaders/common_world.glsl
shaders/model_character_view.h
shaders/model_sky.h
shaders/scene_depth.h
shaders/scene_position.h
shaders/scene_route.fs
shaders/scene_route.h
shaders/scene_scoretext.h
shaders/scene_standard.fs
shaders/scene_standard.h
shaders/scene_standard_alphatest.fs
shaders/scene_standard_alphatest.h
shaders/scene_terrain.fs
shaders/scene_terrain.h
shaders/scene_vertex_blend.fs
shaders/scene_vertex_blend.h
shaders/scene_water.h
shaders/scene_water_fast.h
skaterift.c
steam.h
vehicle.h
world.h
world_render.h
world_routes.h
world_sfd.h

diff --git a/audio.h b/audio.h
index 097093350608dd972b38e31e7178cd814b4a9f83..d1fd1cc6277196453fcb3c8fad653457f127dc85 100644 (file)
--- a/audio.h
+++ b/audio.h
@@ -9,11 +9,6 @@
 
 #include "world.h"
 
-VG_STATIC float audio_occlusion_current = 0.0f,
-             k_audio_occlusion_rate  = 1.0f;
-
-VG_STATIC int k_audio_debug_soundscape = 0;
-
 audio_clip audio_board[] =
 {
    { .path="sound/skate_hpf.ogg" },
@@ -156,22 +151,6 @@ VG_STATIC void audio_init(void)
    audio_clip_loadn( audio_rewind, vg_list_size(audio_rewind), NULL );
    audio_clip_loadn( audio_ui, vg_list_size(audio_ui), NULL );
 
-   vg_var_push( (struct vg_var){
-      .name = "aud_debug_soundscape",
-      .data = &k_audio_debug_soundscape,
-      .data_type = k_var_dtype_i32,
-      .opt_i32 = { .min=0, .max=1, .clamp=0 },
-      .persistent = 1
-   });
-
-   vg_var_push( (struct vg_var){
-      .name = "aud_occlusion_rate",
-      .data = &k_audio_occlusion_rate,
-      .data_type = k_var_dtype_f32,
-      .opt_f32 = { .clamp = 0 },
-      .persistent = 1
-   });
-
    audio_lock();
    audio_set_lfo_wave( 0, k_lfo_polynomial_bipolar, 80.0f );
    audio_set_lfo_frequency( 0, 20.0f );
diff --git a/bvh.h b/bvh.h
index b054741facdcfbac6d80ee5f6d36dfaac24a5e09..ddc81ca7c1ad5793d45d72ca579aeccab7e85657 100644 (file)
--- a/bvh.h
+++ b/bvh.h
@@ -26,6 +26,13 @@ typedef struct bh_node bh_node;
 typedef struct bh_tree bh_tree;
 typedef struct bh_system bh_system;
 
+typedef struct ray_hit ray_hit;
+struct ray_hit{
+   float dist;
+   u32 *tri;
+   v3f pos, normal;
+};
+
 struct bh_tree
 {
    u32 node_count;
index 9eda6f67ae0e59dfcf76c8fd39b0f26d46d7d8ae..4c04de762df02ce97de46eb4739527b3ab827e73 100644 (file)
--- a/common.h
+++ b/common.h
 #include "vg/vg.h"
 #include "submodules/anyascii/impl/c/anyascii.c"
 
-#define RESET_MAX_TIME 45.0
-VG_STATIC v3f TEMP_BOARD_0, TEMP_BOARD_1;
 
-enum menu_controller_type
-{
+enum menu_controller_type{
    k_menu_controller_type_keyboard,
    k_menu_controller_type_xbox,
    k_menu_controller_type_playstation,
@@ -28,156 +25,4 @@ enum menu_controller_type
 
 VG_STATIC enum menu_controller_type menu_display_controller;
 
-typedef struct ray_hit ray_hit;
-struct ray_hit
-{
-   float dist;
-   u32 *tri;
-   v3f pos, normal;
-};
-
-VG_STATIC float 
-   k_friction_lat          = 12.0f,
-   k_friction_resistance   = 0.01f,
-
-   k_max_push_speed        = 16.0f,
-   k_push_accel            = 10.0f,
-   k_push_cycle_rate       = 8.0f,
-
-   k_steer_ground          = 2.5f,
-   k_steer_air             = 3.6f,
-
-   k_jump_charge_speed     = (1.0f/0.4f),
-   k_jump_force            = 5.0f,
-
-   k_pitch_limit           = 1.5f,
-   k_look_speed            = 2.0f,
-
-   k_cog_spring            = 0.2f,
-   k_cog_damp              = 0.02f,
-   k_cog_mass_ratio        = 0.9f,
-
-   k_mmthrow_scale         = 6.0f,
-   k_mmcollect_lat         = 2.0f,
-   k_mmcollect_vert        = 0.0f,
-   k_mmdecay               = 12.0f,
-   k_spring_angular        = 1.0f,
-
-   k_spring_force          = 300.0f,
-   k_spring_dampener       = 5.0f,
-
-   k_grind_spring          = 50.0f,
-   k_grind_aligment        = 10.0f,
-   k_grind_dampener        = 5.0f,
-
-   k_surface_spring        = 100.0f,
-   k_surface_dampener      = 40.0f,
-   k_manul_spring          = 200.0f,
-   k_manul_dampener        = 30.0f,
-   k_board_interia         = 8.0f,
-
-   k_grind_decayxy         = 30.0f,
-   k_grind_axel_min_vel    = 1.0f,
-   k_grind_axel_max_angle  = 0.95f, /* cosine(|a|) */
-   k_grind_axel_max_vangle = 0.4f,
-   k_grind_max_friction    = 3.0f,
-   k_grind_max_edge_angle  = 0.97f,
-
-   k_board_length          = 0.45f,
-   k_board_width           = 0.13f,
-   k_board_end_radius      = 0.1f,
-   k_board_radius          = 0.14f,    /* 0.07 */
-   
-   k_grind_balance         = -40.0f;
-
-VG_STATIC float
-   k_walkspeed             = 10.0f,
-   k_airspeed              = 1.2f,
-   k_stopspeed             = 4.0f,
-   k_walk_accel            = 10.0f,
-   k_walk_air_accel        = 7.0f,
-   k_walk_friction         = 10.0f,
-   k_walk_step_height      = 0.2f;
-
-VG_STATIC float
-   k_cam_punch             = -0.1f,
-   k_cam_spring            = 20.0f,
-   k_cam_damp              = 6.7f;
-
-VG_STATIC float
-   k_day_length            = 30.0f; /* minutes */
-
-VG_STATIC float k_ragdoll_floatyiness = 20.0f,
-                k_ragdoll_floatydrag  = 1.0f,
-                k_ragdoll_limit_scale = 1.0f;
-
-VG_STATIC int   k_ragdoll_div = 1,
-                ragdoll_frame = 0,
-                k_ragdoll_debug_collider = 1,
-                k_ragdoll_debug_constraints = 0;
-
-VG_STATIC int   k_debug_light_indices = 0,
-                k_debug_light_complexity = 0,
-                k_light_preview = 0;
-
-VG_STATIC int freecam = 0;
-VG_STATIC int walk_grid_iterations = 1;
-VG_STATIC float fc_speed = 10.0f;
-VG_STATIC int cl_thirdperson = 0;
-
-VG_STATIC void common_var_temp(void)
-{
-   VG_VAR_F32( k_day_length );
-
-   VG_VAR_F32( k_cam_punch );
-   VG_VAR_F32( k_cam_damp );
-   VG_VAR_F32( k_cam_spring );
-
-   VG_VAR_F32( k_grind_dampener );
-   VG_VAR_F32( k_grind_spring );
-   VG_VAR_F32( k_grind_aligment );
-   VG_VAR_F32( k_surface_spring );
-   VG_VAR_F32( k_surface_dampener );
-   VG_VAR_F32( k_board_interia );
-   VG_VAR_F32( k_grind_decayxy );
-   VG_VAR_F32( k_grind_axel_min_vel );
-   VG_VAR_F32( k_grind_axel_max_angle );
-   VG_VAR_F32( k_grind_max_friction );
-   VG_VAR_F32( k_grind_balance );
-
-   VG_VAR_F32( k_walkspeed );
-   VG_VAR_F32( k_stopspeed );
-   VG_VAR_F32( k_airspeed );
-   VG_VAR_F32( k_walk_friction );
-   VG_VAR_F32( k_walk_air_accel );
-   VG_VAR_F32( k_walk_accel );
-
-   VG_VAR_I32( freecam );
-   VG_VAR_I32( cl_thirdperson );
-   VG_VAR_F32_PERSISTENT( fc_speed );
-
-   VG_VAR_F32( k_ragdoll_limit_scale );
-   VG_VAR_I32( k_ragdoll_div );
-   VG_VAR_I32( k_ragdoll_debug_collider );
-   VG_VAR_I32( k_ragdoll_debug_constraints );
-   VG_VAR_I32( k_debug_light_indices );
-   VG_VAR_I32( k_debug_light_complexity );
-   VG_VAR_I32( k_light_preview );
-
-   VG_VAR_F32( k_friction_lat );
-
-   VG_VAR_F32( k_cog_spring );
-   VG_VAR_F32( k_cog_damp );
-   VG_VAR_F32( k_cog_mass_ratio );
-
-   VG_VAR_F32( k_spring_force );
-   VG_VAR_F32( k_spring_dampener );
-   VG_VAR_F32( k_spring_angular );
-
-   VG_VAR_F32( k_mmthrow_scale );
-   VG_VAR_F32( k_mmcollect_lat );
-   VG_VAR_F32( k_mmcollect_vert );
-   VG_VAR_F32( k_mmdecay );
-}
-
 #endif /* COMMON_H */
diff --git a/conf.h b/conf.h
index 33cc44e5690c1465c0c8d65ce487a74e1f4e9bae..387ed212a58196b42fd8fb40f57648194fa16e78 100644 (file)
--- a/conf.h
+++ b/conf.h
@@ -12,45 +12,11 @@ VG_STATIC int   cl_blur             = 1,
 
 VG_STATIC void g_conf_init(void)
 {
-   vg_var_push( (struct vg_var){
-      .name = "cl_fov",
-      .data = &cl_fov,
-      .data_type = k_var_dtype_f32,
-      .opt_f32 = { .clamp = 0 },
-      .persistent = 1
-   });
-
-   vg_var_push( (struct vg_var){
-      .name = "cl_invert_y",
-      .data = &cl_invert_y,
-      .data_type = k_var_dtype_i32,
-      .opt_i32 = { .min=0, .max=1, .clamp=1 },
-      .persistent = 1
-   });
-
-   vg_var_push( (struct vg_var){
-      .name = "cl_blur_strength",
-      .data = &cl_blur_strength,
-      .data_type = k_var_dtype_f32,
-      .opt_f32 = { .clamp = 0 },
-      .persistent = 1
-   });
-
-   vg_var_push( (struct vg_var){
-      .name = "cl_blur",
-      .data = &cl_blur,
-      .data_type = k_var_dtype_i32,
-      .opt_i32 = { .min=0, .max=1, .clamp=1 },
-      .persistent = 1
-   });
-
-   vg_var_push( (struct vg_var){
-      .name = "cl_playermdl_id",
-      .data = &cl_playermdl_id,
-      .data_type = k_var_dtype_i32,
-      .opt_i32 = { .min=0, .max=2, .clamp=1 },
-      .persistent = 1
-   });
+   VG_VAR_F32( cl_fov, flags=VG_VAR_PERSISTENT );
+   VG_VAR_I32( cl_invert_y, flags=VG_VAR_PERSISTENT );
+   VG_VAR_I32( cl_blur, flags=VG_VAR_PERSISTENT );
+   VG_VAR_F32( cl_blur_strength, flags=VG_VAR_PERSISTENT );
+   VG_VAR_I32( cl_playermdl_id, flags=VG_VAR_PERSISTENT );
 }
 
 #endif /* CONF_H */
index 28adfd0df4095cd9f1c6eb383a05c69ccb46f9d1..a73122c57c5351cf5afa929b6b3ff995490fe3be 100644 (file)
--- a/player.c
+++ b/player.c
@@ -134,9 +134,10 @@ void player__use_texture( player_instance *player, vg_tex2d *tex )
 PLAYER_API
 void player__bind( player_instance *player )
 {
-   player__skate_bind( player );
-   player__walk_bind( player );
-   player__drive_bind( player );
+   for( u32 i=0; i<vg_list_size(_player_bind); i++ ){
+      if( _player_bind[i] )
+         _player_bind[i]( player );
+   }
 }
 
 /*
@@ -366,8 +367,9 @@ VG_STATIC void player__pre_render( player_instance *player )
    v3f vp0 = {0.0f,0.1f, 0.55f},
        vp1 = {0.0f,0.1f,-0.55f};
 
-   m4x3_mulv( av->sk.final_mtx[ av->id_board ], vp0, TEMP_BOARD_0 );
-   m4x3_mulv( av->sk.final_mtx[ av->id_board ], vp1, TEMP_BOARD_1 );
+   struct ub_world_lighting *ubo = &get_active_world()->ub_lighting;
+   m4x3_mulv( av->sk.final_mtx[ av->id_board ], vp0, ubo->g_board_0 );
+   m4x3_mulv( av->sk.final_mtx[ av->id_board ], vp1, ubo->g_board_1 );
 
    if( player->rewinding ){
       if( player->rewind_time <= 0.0f ){
index 3e23d1713b963e6fae24355209db4568c5210816..38e01ad2865bf73d72b12e64e43c433b007ef3e8 100644 (file)
--- a/player.h
+++ b/player.h
@@ -10,6 +10,7 @@
 #include "player_drive.h"
 
 #define PLAYER_REWIND_FRAMES 60*4
+#define RESET_MAX_TIME 45.0
 
 struct player_instance
 {
@@ -136,6 +137,15 @@ struct player_instance
  * ---------------------------------------------------------
  */
 
+VG_STATIC
+void (*_player_system_register[])(void) =
+{
+   player__walk_register,
+   player__skate_register,
+   NULL,
+   NULL
+};
+
 VG_STATIC
 void (*_player_bind[])( player_instance *player ) =
 {
@@ -217,6 +227,14 @@ void( *_player_restore[] )( player_instance *player ) =
    NULL
 };
 
+VG_STATIC void player_init(void)
+{
+   for( u32 i=0; i<vg_list_size(_player_system_register); i++ ){
+      if( _player_system_register[i] )
+         _player_system_register[i]();
+   }
+}
+
 /* implementation */
 
 #include "player.c"
diff --git a/player_animation.h b/player_animation.h
deleted file mode 100644 (file)
index 0660acf..0000000
+++ /dev/null
@@ -1,415 +0,0 @@
-/*
- * Copyright (C) 2021-2022 Mt.ZERO Software, Harry Godden - All Rights Reserved
- */
-
-#ifndef PLAYER_ANIMATION_H
-#define PLAYER_ANIMATION_H
-
-#include "player.h"
-#include "player_physics_walk.h"
-
-VG_STATIC void player_animate_offboard(void)
-{
-   player_walk_animate( &player_walky, &player.mdl.sk, NULL );
-}
-
-VG_STATIC void player_animate(void)
-{
-#if 0
-   struct player_phys *phys = &player.phys;
-   rb_extrapolate_transform( &player.phys.rb, player.visual_transform );
-   v3_muladds( player.visual_transform[3], phys->rb.up, -0.2f, 
-               player.visual_transform[3] );
-
-   v4f qfake_rot;
-   m3x3f fake_rot;
-   float substep = vg_clampf( vg.accumulator / VG_TIMESTEP_FIXED, 0.0f, 1.0f );
-   q_axis_angle( qfake_rot, phys->rb.up, phys->siY*substep );
-   q_m3x3( qfake_rot, fake_rot );
-   m3x3_mul( fake_rot, player.visual_transform, player.visual_transform );
-
-   m4x3_invert_affine( player.visual_transform, player.inv_visual_transform );
-
-   if( phys->controller == k_player_controller_walk )
-   {
-      player_animate_offboard();
-      return;
-   }
-
-   /* Camera position */
-   v3_muladds( phys->m, phys->a, VG_TIMESTEP_FIXED, phys->m );
-   v3_lerp( phys->m, (v3f){0.0f,0.0f,0.0f}, 0.1f, phys->m );
-
-   phys->m[0] = vg_clampf( phys->m[0], -2.0f, 2.0f );
-   phys->m[1] = vg_clampf( phys->m[1], -2.0f, 2.0f );
-   phys->m[2] = vg_clampf( phys->m[2], -2.0f, 2.0f );
-   v3_lerp( phys->bob, phys->m, 0.2f, phys->bob );
-
-   /* Head */
-   float lslip = fabsf(phys->slip);
-
-   float kheight = 2.0f,
-         kleg = 0.6f;
-
-   v3f offset;
-   v3_zero( offset );
-   m3x3_mulv( player.inv_visual_transform, phys->bob, offset );
-
-   static float speed_wobble = 0.0f, speed_wobble_2 = 0.0f;
-   
-   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, 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;
-
-   offset[1] *= -0.3f;
-   offset[2] *= 0.01f;
-
-   offset[0]=vg_clampf(offset[0],-0.8f,0.8f)*(1.0f-fabsf(player.fslide)*0.9f);
-   offset[1]=vg_clampf(offset[1],-0.5f,0.0f);
-
-   /* 
-    * Animation blending
-    * ===========================================
-    */
-
-   /* scalar blending information */
-   float speed = v3_length( phys->rb.v );
-   
-   /* sliding */
-   {
-      float desired = vg_clampf( lslip, 0.0f, 1.0f );
-      player.fslide = vg_lerpf( player.fslide, desired, 2.4f*vg.time_delta);
-   }
-   
-   /* movement information */
-   {
-      int iair = (player_skate.activity == k_skate_activity_air) ||
-                 (player_skate.activity == k_skate_activity_grind );
-
-      float dirz = phys->reverse > 0.0f? 0.0f: 1.0f,
-            dirx = phys->slip < 0.0f?    0.0f: 1.0f,
-            fly  = iair?                 1.0f: 0.0f;
-
-      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;
-
-   mdl_keyframe apose[32], bpose[32];
-   mdl_keyframe ground_pose[32];
-   {
-      /* 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, 6.0f*vg.time_delta );
-
-      /* stand/crouch */
-      float dir_frame   = player.fdirz * (15.0f/30.0f),
-            stand_blend = offset[1]*-2.0f;
-
-      v3f local_cog;
-      m4x3_mulv( player.phys.rb.to_local, player.phys.cog, local_cog );
-
-      stand_blend = vg_clampf( 1.0f-local_cog[1], 0, 1 );
-
-      skeleton_sample_anim( sk, player.mdl.anim_stand, dir_frame, apose );
-      skeleton_sample_anim( sk, player.mdl.anim_highg, dir_frame, bpose );
-      skeleton_lerp_pose( sk, apose, bpose, stand_blend, apose );
-
-      /* sliding */
-      float slide_frame = player.fdirx * (15.0f/30.0f);
-      skeleton_sample_anim( sk, player.mdl.anim_slide, slide_frame, bpose );
-      skeleton_lerp_pose( sk, apose, bpose, player.fslide, apose );
-
-      /* pushing */
-      double push_time = vg.time - player.phys.start_push;
-
-      player.fpush = vg_lerpf( player.fpush, 
-                               (vg.time - player.phys.cur_push) < 0.125,
-                               6.0f*vg.time_delta );
-
-      float pt = push_time + vg.accumulator;
-      if( phys->reverse > 0.0f )
-         skeleton_sample_anim( sk, player.mdl.anim_push, pt, bpose );
-      else
-         skeleton_sample_anim( sk, player.mdl.anim_push_reverse, pt, bpose );
-
-      skeleton_lerp_pose( sk, apose, bpose, player.fpush, apose );
-
-      /* trick setup */
-      float jump_start_frame = 14.0f/30.0f;
-
-      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;
-      if( jump_frame >= jump_start_frame && jump_frame <= (40.0f/30.0f) )
-         setup_frame = jump_frame;
-
-      struct skeleton_anim *jump_anim = phys->jump_dir?
-                                        player.mdl.anim_ollie:
-                                        player.mdl.anim_ollie_reverse;
-
-      skeleton_sample_anim_clamped( sk, jump_anim, setup_frame, bpose );
-      skeleton_lerp_pose( sk, apose, bpose, setup_blend, ground_pose );
-   }
-   
-   mdl_keyframe air_pose[32];
-   {
-      float target = -player.input_js1h->axis.value;
-      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);
-      
-      skeleton_sample_anim( sk, player.mdl.anim_air, air_frame, apose );
-
-      static v2f grab_choice;
-
-      v2f grab_input = { player.input_js2h->axis.value,
-                         player.input_js2v->axis.value };
-      v2_add( player.phys.grab_mouse_delta, grab_input, grab_input );
-      if( v2_length2( grab_input ) <= 0.001f )
-         grab_input[0] = -1.0f;
-      else
-         v2_normalize_clamp( grab_input );
-      v2_lerp( grab_choice, grab_input, 2.4f*vg.time_delta, grab_choice );
-
-      float ang = atan2f( grab_choice[0], grab_choice[1] ),
-            ang_unit = (ang+VG_PIf) * (1.0f/VG_TAUf),
-            grab_frame = ang_unit * (15.0f/30.0f);
-
-      skeleton_sample_anim( sk, player.mdl.anim_grabs, grab_frame, bpose );
-      skeleton_lerp_pose( sk, apose, bpose, phys->grab, air_pose );
-   }
-
-   skeleton_lerp_pose( sk, ground_pose, air_pose, player.ffly, apose );
-
-   float add_grab_mod = 1.0f - player.ffly;//*phys->grab;
-
-   /* additive effects */
-   {
-      u32 apply_to[] = { player.mdl.id_hip, 
-                         player.mdl.id_ik_hand_l,
-                         player.mdl.id_ik_hand_r,
-                         player.mdl.id_ik_elbow_l,
-                         player.mdl.id_ik_elbow_r };
-
-      for( int i=0; i<vg_list_size(apply_to); i ++ )
-      {
-         apose[apply_to[i]-1].co[0] += offset[0]*add_grab_mod;
-         apose[apply_to[i]-1].co[2] += offset[2]*add_grab_mod;
-      }
-
-      v3f bo;
-      v3_muls( player.board_offset, add_grab_mod, bo );
-
-      v3_add( bo, apose[ player.mdl.id_board-1 ].co,
-                                   apose[ player.mdl.id_board-1 ].co );
-      v3_add( bo, apose[ player.mdl.id_ik_foot_l-1 ].co,
-                                   apose[ player.mdl.id_ik_foot_l-1 ].co );
-      v3_add( bo, apose[ player.mdl.id_ik_foot_r-1 ].co,
-                                   apose[ player.mdl.id_ik_foot_r-1 ].co );
-
-      m3x3f c;
-      q_m3x3( player.board_rotation, c );
-
-      v3f d;
-      v3_sub( apose[ player.mdl.id_ik_foot_l-1 ].co, bo, d );
-      m3x3_mulv( c, d, d );
-      v3_add( bo, d, apose[ player.mdl.id_ik_foot_l-1 ].co );
-      
-      v3_sub( apose[ player.mdl.id_ik_foot_r-1 ].co, bo, d );
-      m3x3_mulv( c, d, d );
-      v3_add( bo, d, apose[ player.mdl.id_ik_foot_r-1 ].co );
-
-      q_mul(  player.board_rotation, apose[ player.mdl.id_board-1 ].q ,
-             apose[ player.mdl.id_board-1 ].q );
-      q_normalize( apose[ player.mdl.id_board-1 ].q );
-   }
-   
-   skeleton_apply_pose( &player.mdl.sk, apose, k_anim_apply_defer_ik );
-   skeleton_apply_ik_pass( &player.mdl.sk );
-   skeleton_apply_pose( &player.mdl.sk, apose, k_anim_apply_deffered_only );
-
-   v3_copy( player.mdl.sk.final_mtx[player.mdl.id_head-1][3], 
-               player.mdl.cam_pos );
-   skeleton_apply_inverses( &player.mdl.sk );
-
-   skeleton_apply_transform( &player.mdl.sk, player.visual_transform );
-   skeleton_debug( &player.mdl.sk );
-#endif
-}
-
-VG_STATIC void player_animate_death_cam(void)
-{
-   v3f delta;
-   v3f head_pos;
-   v3_copy( player.mdl.ragdoll[0].rb.co, head_pos );
-
-   v3_sub( head_pos, player.camera_pos, delta );
-   v3_normalize( delta );
-
-   v3f follow_pos;
-   v3_muladds( head_pos, delta, -2.5f, follow_pos );
-   v3_lerp( player.camera_pos, follow_pos, 0.1f, player.camera_pos );
-
-   /* 
-    * Make sure the camera stays above the ground
-    */
-   v3f min_height = {0.0f,1.0f,0.0f};
-
-   v3f sample;
-   v3_add( player.camera_pos, min_height, sample );
-   ray_hit hit;
-   hit.dist = min_height[1]*2.0f;
-
-   if( ray_world( sample, (v3f){0.0f,-1.0f,0.0f}, &hit ))
-      v3_add( hit.pos, min_height, player.camera_pos );
-
-   if( world.water.enabled )
-   {
-      player.camera_pos[1] = 
-         vg_maxf( world.water.height + 2.0f, player.camera_pos[1] );
-   }
-
-   player.angles[0] = atan2f( delta[0], -delta[2] ); 
-   player.angles[1] = -asinf( delta[1] );
-}
-
-VG_STATIC void player_animate_follow_cam( v3f target, float dist, float speed )
-{
-   v3f delta;
-
-   v3_sub( target, player.camera_pos, delta );
-   v3_normalize( delta );
-
-   v3f follow_pos;
-   v3_muladds( target, delta, -dist, follow_pos );
-   v3_lerp( player.camera_pos, follow_pos,
-             speed * vg.time_delta, player.camera_pos );
-
-   /* 
-    * Make sure the camera stays above the ground
-    */
-   v3f min_height = {0.0f,1.0f,0.0f};
-
-   v3f sample;
-   v3_add( player.camera_pos, min_height, sample );
-   ray_hit hit;
-   hit.dist = min_height[1]*2.0f;
-
-   if( ray_world( sample, (v3f){0.0f,-1.0f,0.0f}, &hit ))
-      v3_add( hit.pos, min_height, player.camera_pos );
-
-#if 0
-   if( world.water.enabled )
-   {
-      player.camera_pos[1] = 
-         vg_maxf( world.water.height + 2.0f, player.camera_pos[1] );
-   }
-#endif
-
-   player.angles[0] = atan2f( delta[0], -delta[2] ); 
-   player.angles[1] = -asinf( delta[1] );
-}
-
-VG_STATIC void player_animate_camera_thirdperson(void)
-{
-   static v3f lerp_cam = { 0.0f, 0.0f, 0.0f };
-   v3f target;
-   
-   v3_muladds( player.rb.co, player.rb.up, 1.2f, target );
-
-   player_animate_follow_cam( target, 1.5f, 20.0f );
-}
-
-VG_STATIC void player_animate_camera(void)
-{
-   static v3f lerp_cam = {0.0f,0.0f,0.0f};
-   v3f cam_pos;
-
-   int _on_board = player.controller == k_player_controller_skate;
-   player.fonboard = vg_lerpf( player.fonboard, _on_board, vg.time_delta );
-
-   if( _on_board )
-   {
-#if 0
-      v3f offs = { -0.4f, 0.15f, 0.0f };
-      v3_lerp( lerp_cam, player.mdl.cam_pos, 0.8f, lerp_cam );
-      v3_add( lerp_cam, offs, cam_pos );
-
-      /* Look angles */
-      v3_lerp( phys->vl, phys->rb.v, 0.05f, phys->vl );
-
-      int _grind = player_skate.activity == k_skate_activity_grind;
-
-      player.fgrind = vg_lerpf( player.fgrind, _grind, vg.time_delta );
-
-      float yaw = atan2f(  phys->vl[0], -phys->vl[2] ),
-          pitch = atan2f
-                  ( 
-                      -phys->vl[1], 
-                      sqrtf
-                      (
-                        phys->vl[0]*phys->vl[0] + phys->vl[2]*phys->vl[2]
-                      )
-                  ) 
-                  * 0.7f + vg_lerpf( 0.30f, 0.90f, player.fgrind );
-
-      player.angles[0] = yaw;
-      player.angles[1] = vg_lerpf( player.angles[1], pitch, player.fonboard );
-
-      /* Camera shake */
-      static v2f shake_damp = {0.0f,0.0f};
-      v2f shake = { vg_randf()-0.5f, vg_randf()-0.5f };
-      v2_muls( shake, v3_length(phys->rb.v)*0.3f 
-                           * (1.0f+fabsf(phys->slip)), shake);
-
-      v2_lerp( shake_damp, shake, 0.01f, shake_damp );
-      shake_damp[0] *= 0.2f;
-
-      v2_muladds( player.angles, shake_damp, 0.1f, player.angles );
-      m4x3_mulv( player.visual_transform, cam_pos, player.camera_pos );
-#endif
-   }
-   else
-   {
-#if 0
-      float speed = vg.time_delta * k_look_speed;
-      player.angles[0] += vg_get_axis( "lookh" ) * speed;
-      player.angles[1] += vg_get_axis( "lookv" ) * speed;
-      
-      player.angles[1] = vg_clampf( player.angles[1], 
-                                       -k_pitch_limit, k_pitch_limit );
-#endif
-      
-      float s =  sinf(player.angles[0]) * 0.2f,
-            c = -cosf(player.angles[0]) * 0.2f;
-      v3f forward_dir = { s,0.15f,c };
-
-      
-      m4x3f mtx;
-      v4f rot;
-      q_axis_angle( rot, (v3f){0.0f,1.0f,0.0f}, 
-                              -player.angles[0] -VG_PIf*0.5f );
-      q_m3x3( rot, mtx );
-      v3_copy( player.visual_transform[3], mtx[3] );
-
-      m4x3_mulv( mtx, player.mdl.cam_pos, cam_pos );
-      v3_add( cam_pos, forward_dir, player.camera_pos );
-
-#if 0
-      v3_lerp( phys->vl, phys->rb.v, 18.0f*vg.time_delta, phys->vl );
-#endif
-   }
-}
-
-#endif /* PLAYER_ANIMATION_H */
index 4cb1a0bd77c5650187b7c884a365404fa1b5f15b..f058b56569ac2bb9b7aa4c20c7a6e192fb6545b5 100644 (file)
@@ -4,6 +4,10 @@
 #include "player.h"
 #include "conf.h"
 
+VG_STATIC float
+   k_cam_spring            = 20.0f,
+   k_cam_damp              = 6.7f;
+
 VG_STATIC void player_vector_angles( v3f angles, v3f v, float C, float k )
 {
    float yaw = atan2f( v[0], -v[2] ),
index 101d8f9c5850f488a5d7fe06162dfd7dca5b97db..d6607ae89331a9ef7ec2883e37099f7665043f73 100644 (file)
@@ -36,6 +36,23 @@ struct player_ragdoll{
    int shoes[2];
 };
 
+VG_STATIC float k_ragdoll_floatyiness = 20.0f,
+                k_ragdoll_floatydrag  = 1.0f,
+                k_ragdoll_limit_scale = 1.0f;
+
+VG_STATIC int   k_ragdoll_div = 1,
+                ragdoll_frame = 0,
+                k_ragdoll_debug_collider = 1,
+                k_ragdoll_debug_constraints = 0;
+
+VG_STATIC void player_ragdoll_init(void)
+{
+   VG_VAR_F32( k_ragdoll_limit_scale );
+   VG_VAR_I32( k_ragdoll_div );
+   VG_VAR_I32( k_ragdoll_debug_collider );
+   VG_VAR_I32( k_ragdoll_debug_constraints );
+}
+
 VG_STATIC void player_init_ragdoll_bone_collider( struct skeleton_bone *bone,
                                                   struct ragdoll_part *rp )
 {
index 69be37e75411da8af5af97fbc3b3dccc6e8ef836..464ef50d9326a81264d94a565be1fb1a03d08918 100644 (file)
@@ -7,12 +7,9 @@
 
 typedef struct jump_info jump_info;
 
-struct player_skate
-{
-   struct
-   {
-      enum skate_activity
-      {
+struct player_skate{
+   struct{
+      enum skate_activity{
          k_skate_activity_air,
          k_skate_activity_air_to_grind,
          k_skate_activity_ground,
@@ -123,8 +120,7 @@ struct player_skate
    float substep,
          substep_delta;
 
-   struct jump_info
-   {
+   struct jump_info{
       v3f   log[50];
       v3f   n;
       v3f   apex;
@@ -136,8 +132,7 @@ struct player_skate
       float score,
             land_dist;
 
-      enum prediction_type
-      {
+      enum prediction_type{
          k_prediction_none,
          k_prediction_unset,
          k_prediction_land,
@@ -163,8 +158,7 @@ struct player_skate
 
    float grind_strength;
 
-   struct grind_limit
-   {
+   struct grind_limit{
       v3f ra, n;
       float p;
    }
@@ -172,6 +166,86 @@ struct player_skate
    u32 limit_count;
 };
 
+VG_STATIC float 
+   k_friction_lat          = 12.0f,
+   k_friction_resistance   = 0.01f,
+
+   k_max_push_speed        = 16.0f,
+   k_push_accel            = 10.0f,
+   k_push_cycle_rate       = 8.0f,
+
+   k_steer_ground          = 2.5f,
+   k_steer_air             = 3.6f,
+
+   k_jump_charge_speed     = (1.0f/0.4f),
+   k_jump_force            = 5.0f,
+
+   k_cog_spring            = 0.2f,
+   k_cog_damp              = 0.02f,
+   k_cog_mass_ratio        = 0.9f,
+
+   k_mmthrow_scale         = 6.0f,
+   k_mmcollect_lat         = 2.0f,
+   k_mmcollect_vert        = 0.0f,
+   k_mmdecay               = 12.0f,
+   k_spring_angular        = 1.0f,
+
+   k_spring_force          = 300.0f,
+   k_spring_dampener       = 5.0f,
+
+   k_grind_spring          = 50.0f,
+   k_grind_aligment        = 10.0f,
+   k_grind_dampener        = 5.0f,
+
+   k_surface_spring        = 100.0f,
+   k_surface_dampener      = 40.0f,
+   k_manul_spring          = 200.0f,
+   k_manul_dampener        = 30.0f,
+   k_board_interia         = 8.0f,
+
+   k_grind_decayxy         = 30.0f,
+   k_grind_axel_min_vel    = 1.0f,
+   k_grind_axel_max_angle  = 0.95f, /* cosine(|a|) */
+   k_grind_axel_max_vangle = 0.4f,
+   k_grind_max_friction    = 3.0f,
+   k_grind_max_edge_angle  = 0.97f,
+
+   k_board_length          = 0.45f,
+   k_board_width           = 0.13f,
+   k_board_end_radius      = 0.1f,
+   k_board_radius          = 0.14f,    /* 0.07 */
+   
+   k_grind_balance         = -40.0f;
+
+VG_STATIC void player__skate_register(void)
+{
+   VG_VAR_F32( k_grind_dampener,       flags=VG_VAR_CHEAT );
+   VG_VAR_F32( k_grind_spring,         flags=VG_VAR_CHEAT );
+   VG_VAR_F32( k_grind_aligment,       flags=VG_VAR_CHEAT );
+   VG_VAR_F32( k_surface_spring,       flags=VG_VAR_CHEAT );
+   VG_VAR_F32( k_surface_dampener,     flags=VG_VAR_CHEAT );
+   VG_VAR_F32( k_board_interia,        flags=VG_VAR_CHEAT );
+   VG_VAR_F32( k_grind_decayxy,        flags=VG_VAR_CHEAT );
+   VG_VAR_F32( k_grind_axel_min_vel,   flags=VG_VAR_CHEAT );
+   VG_VAR_F32( k_grind_axel_max_angle, flags=VG_VAR_CHEAT );
+   VG_VAR_F32( k_grind_max_friction,   flags=VG_VAR_CHEAT );
+   VG_VAR_F32( k_grind_balance,        flags=VG_VAR_CHEAT );
+   VG_VAR_F32( k_friction_lat,         flags=VG_VAR_CHEAT );
+
+   VG_VAR_F32( k_cog_spring,           flags=VG_VAR_CHEAT );
+   VG_VAR_F32( k_cog_damp,             flags=VG_VAR_CHEAT );
+   VG_VAR_F32( k_cog_mass_ratio,       flags=VG_VAR_CHEAT );
+
+   VG_VAR_F32( k_spring_force,         flags=VG_VAR_CHEAT );
+   VG_VAR_F32( k_spring_dampener,      flags=VG_VAR_CHEAT );
+   VG_VAR_F32( k_spring_angular,       flags=VG_VAR_CHEAT );
+
+   VG_VAR_F32( k_mmthrow_scale,        flags=VG_VAR_CHEAT );
+   VG_VAR_F32( k_mmcollect_lat,        flags=VG_VAR_CHEAT );
+   VG_VAR_F32( k_mmcollect_vert,       flags=VG_VAR_CHEAT );
+   VG_VAR_F32( k_mmdecay,              flags=VG_VAR_CHEAT );
+}
+
 VG_STATIC void player__skate_bind         ( player_instance *player );
 VG_STATIC void player__skate_pre_update   ( player_instance *player );
 VG_STATIC void player__skate_update       ( player_instance *player );
index 29c210dd599d682495cdff3e83f63f5ded7be7df..4c6b7a39af89ce320966403f10d8b4d151ae0314 100644 (file)
@@ -3,12 +3,10 @@
 
 #include "player_api.h"
 
-struct player_walk
-{
+struct player_walk{
    rb_capsule collider;
 
-   struct
-   {
+   struct{
       v3f prev_pos;
       v3f drop_in_target,
           drop_in_foot_anchor,
@@ -18,8 +16,7 @@ struct player_walk
       float drop_in_start_angle,
             drop_in_angle;
 
-      enum walk_activity
-      {
+      enum walk_activity{
          k_walk_activity_air,
          k_walk_activity_ground,
          k_walk_activity_sleep,
@@ -28,8 +25,7 @@ struct player_walk
       }
       activity;
 
-      enum walk_outro
-      {
+      enum walk_outro{
          k_walk_outro_none,
          k_walk_outro_jump_to_air,
          k_walk_outro_drop_in,
@@ -57,6 +53,25 @@ struct player_walk
    int step_phase;
 };
 
+VG_STATIC float
+   k_walkspeed             = 10.0f,
+   k_airspeed              = 1.2f,
+   k_stopspeed             = 4.0f,
+   k_walk_accel            = 10.0f,
+   k_walk_air_accel        = 7.0f,
+   k_walk_friction         = 10.0f,
+   k_walk_step_height      = 0.2f;
+
+VG_STATIC void player__walk_register(void)
+{
+   VG_VAR_F32( k_walkspeed,      flags=VG_VAR_CHEAT );
+   VG_VAR_F32( k_stopspeed,      flags=VG_VAR_CHEAT );
+   VG_VAR_F32( k_airspeed,       flags=VG_VAR_CHEAT );
+   VG_VAR_F32( k_walk_friction,  flags=VG_VAR_CHEAT );
+   VG_VAR_F32( k_walk_air_accel, flags=VG_VAR_CHEAT );
+   VG_VAR_F32( k_walk_accel,     flags=VG_VAR_CHEAT );
+}
+
 VG_STATIC void player__walk_pre_update  ( player_instance *player );
 VG_STATIC void player__walk_update      ( player_instance *player );
 VG_STATIC void player__walk_post_update ( player_instance *player );
index 712961ea3f196dc6956aeefe0b3c5164e2aef45c..64cf8f1ecaa432d8f5e2013672b064269f4df26a 100644 (file)
--- a/render.h
+++ b/render.h
@@ -31,8 +31,7 @@ typedef struct framebuffer framebuffer;
 /* 
  * All standard buffers used in rendering
  */
-VG_STATIC struct pipeline
-{
+VG_STATIC struct pipeline{
    glmesh fsquad;
 
    framebuffer *fb_main,
@@ -45,8 +44,7 @@ VG_STATIC struct pipeline
 }
 gpipeline = { .view_render_scale = 1.0f };
 
-struct framebuffer
-{
+struct framebuffer{
    const char *display_name;
    int         resolution_div,   /* definition */
                fixed_w,
@@ -55,20 +53,17 @@ struct framebuffer
                render_w,         /* runtime */
                render_h;
 
-   struct framebuffer_attachment
-   {
+   struct framebuffer_attachment{
       const char *display_name;
       
-      enum framebuffer_attachment_type
-      {
+      enum framebuffer_attachment_type{
          k_framebuffer_attachment_type_none,
          k_framebuffer_attachment_type_colour,
          k_framebuffer_attachment_type_renderbuffer
       }
       purpose;
 
-      enum framebuffer_quality_profile
-      {
+      enum framebuffer_quality_profile{
          k_framebuffer_quality_all,
          k_framebuffer_quality_high_only
       }
@@ -233,8 +228,7 @@ VG_STATIC void render_fb_bind_texture( framebuffer *fb,
 {
    struct framebuffer_attachment *at = &fb->attachments[attachment];
 
-   if( at->purpose != k_framebuffer_attachment_type_colour )
-   {
+   if( at->purpose != k_framebuffer_attachment_type_colour ){
       vg_fatal_exit_loop( "illegal operation: bind non-colour framebuffer"
                           " attachment to texture slot" );
    }
@@ -378,13 +372,11 @@ VG_STATIC void render_fb_allocate_texture( struct framebuffer *fb,
    int rx, ry;
    render_fb_get_current_res( fb, &rx, &ry );
 
-   if( a->purpose == k_framebuffer_attachment_type_renderbuffer )
-   {
+   if( a->purpose == k_framebuffer_attachment_type_renderbuffer ){
       glBindRenderbuffer( GL_RENDERBUFFER, a->id );
       glRenderbufferStorage( GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, rx, ry );
    }
-   else if( a->purpose == k_framebuffer_attachment_type_colour )
-   {
+   else if( a->purpose == k_framebuffer_attachment_type_colour ){
       glBindTexture( GL_TEXTURE_2D, a->id );
       glTexImage2D( GL_TEXTURE_2D, 0, a->internalformat, rx, ry,
                                    0, a->format, a->type, NULL );
@@ -408,8 +400,7 @@ VG_STATIC void render_fb_allocate( struct framebuffer *fb )
    GLenum colour_attachments[4];
    u32    colour_count = 0;
 
-   for( int j=0; j<vg_list_size(fb->attachments); j++ )
-   {
+   for( int j=0; j<vg_list_size(fb->attachments); j++ ){
       struct framebuffer_attachment *attachment = &fb->attachments[j];
 
       if( attachment->purpose == k_framebuffer_attachment_type_none )
@@ -419,16 +410,14 @@ VG_STATIC void render_fb_allocate( struct framebuffer *fb )
                   render_fb_attachment_str( attachment->attachment ),
                   render_fb_format_str( attachment->internalformat ) );
 
-      if( attachment->purpose == k_framebuffer_attachment_type_renderbuffer )
-      {
+      if( attachment->purpose == k_framebuffer_attachment_type_renderbuffer ){
          glGenRenderbuffers( 1, &attachment->id );
          render_fb_allocate_texture( fb, attachment );
          glFramebufferRenderbuffer( GL_FRAMEBUFFER, 
                                     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_colour ){
          glGenTextures( 1, &attachment->id );
          render_fb_allocate_texture( fb, attachment );
          glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
@@ -450,8 +439,7 @@ VG_STATIC void render_fb_allocate( struct framebuffer *fb )
     */
    GLenum result = glCheckFramebufferStatus( GL_FRAMEBUFFER );
 
-   if( result == GL_FRAMEBUFFER_COMPLETE )
-   {
+   if( result == GL_FRAMEBUFFER_COMPLETE ){
       /* 
        * Attatch to gpipeline
        */
@@ -461,8 +449,7 @@ VG_STATIC void render_fb_allocate( struct framebuffer *fb )
       vg_success( "  status: complete\n" );
       vg_info( "}\n" );
    }
-   else
-   {
+   else{
       if( result == GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT )
          vg_error( "  status: Incomplete attachment" );
       else if( result == GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT )
@@ -485,11 +472,9 @@ VG_STATIC void render_fb_resize(void)
    if( !gpipeline.ready )
       return;
 
-   for( int i=0; i<vg_list_size(framebuffers); i++ )
-   {
+   for( int i=0; i<vg_list_size(framebuffers); i++ ){
       struct framebuffer *fb = &framebuffers[i];
-      for( int j=0; j<vg_list_size(fb->attachments); j++ )
-      {
+      for( int j=0; j<vg_list_size(fb->attachments); j++ ){
          struct framebuffer_attachment *attachment = &fb->attachments[j];
          render_fb_allocate_texture( fb, attachment );
       }
@@ -502,8 +487,7 @@ VG_STATIC void render_init_fs_quad(void)
 {
    vg_info( "[render] Allocate quad\n" );
 
-   float quad[] = 
-   { 
+   float quad[] = { 
       0.00f,0.00f, 1.00f,1.00f, 0.00f,1.00f,
       0.00f,0.00f, 1.00f,0.00f, 1.00f,1.00f,
 
@@ -534,12 +518,8 @@ VG_STATIC void render_init_fs_quad(void)
       0.60f,0.60f, 0.90f,0.60f, 0.90f,0.90f,
    };
 
-       vg_function_push( (struct vg_cmd)
-   {
-               .name = "fb",
-               .function = render_framebuffer_control,
-      .poll_suggest = render_framebuffer_poll
-       });
+   vg_console_reg_cmd( "fb", render_framebuffer_control, 
+                             render_framebuffer_poll );
 
    glGenVertexArrays( 1, &gpipeline.fsquad.vao );
    glGenBuffers( 1, &gpipeline.fsquad.vbo );
@@ -565,8 +545,7 @@ VG_STATIC void render_init(void)
       /* 
        * Complete Framebuffers
        */
-      for( int i=0; i<vg_list_size(framebuffers); i++ )
-      {
+      for( int i=0; i<vg_list_size(framebuffers); i++ ){
          struct framebuffer *fb = &framebuffers[i];
          render_fb_allocate( fb );
       }
@@ -668,8 +647,7 @@ VG_STATIC void render_framebuffer_show( struct framebuffer *fb,
  */
 VG_STATIC int render_framebuffer_control( int argc, char const *argv[] )
 {
-   if( argc < 2 )
-   {
+   if( argc < 2 ){
       vg_error( "Usage: fb \"show/hide\" <name>/\"all\" <name>/none\n" );
       return 0;
    }
@@ -681,8 +659,7 @@ VG_STATIC int render_framebuffer_control( int argc, char const *argv[] )
       operation = 1;
    else if( !strcmp( argv[0], "hide" ) )
       operation = 0;
-   else
-   {
+   else{
       vg_error( "Unknown framebuffer operation: '%s'\n", argv[0] );
       return 0;
    }
@@ -690,25 +667,20 @@ VG_STATIC int render_framebuffer_control( int argc, char const *argv[] )
    if( !strcmp( argv[1], "all" ) )
       modify_all = 1;
 
-   for( int i=0; i<vg_list_size(framebuffers); i++ )
-   {
+   for( int i=0; i<vg_list_size(framebuffers); i++ ){
       struct framebuffer *fb = &framebuffers[i];
       
-      for( int j=0; j<vg_list_size(fb->attachments); j++ )
-      {
+      for( int j=0; j<vg_list_size(fb->attachments); j++ ){
          struct framebuffer_attachment *at = &fb->attachments[j];
 
          if( at->purpose == k_framebuffer_attachment_type_none )
             continue;
 
-         if( modify_all )
-         {
+         if( modify_all ){
             render_framebuffer_show( fb, at, operation );
          }
-         else
-         {
-            if( !strcmp( fb->display_name, argv[1] ) )
-            {
+         else{
+            if( !strcmp( fb->display_name, argv[1] ) ){
                if( argc == 2 )
                   render_framebuffer_show( fb, at, operation );
                else if( !strcmp( at->display_name, argv[2] ) )
@@ -725,45 +697,37 @@ VG_STATIC void render_framebuffer_poll( int argc, char const *argv[] )
 {
    const char *term = argv[argc-1];
 
-   if( argc == 1 )
-   {
+   if( argc == 1 ){
       console_suggest_score_text( "show", term, 0 );
       console_suggest_score_text( "hide", term, 0 );
    }
-   else if( argc == 2 )
-   {
+   else if( argc == 2 ){
       console_suggest_score_text( "all", term, 0 );
 
-      for( int i=0; i<vg_list_size(framebuffers); i++ )
-      {
+      for( int i=0; i<vg_list_size(framebuffers); i++ ){
          struct framebuffer *fb = &framebuffers[i];
          console_suggest_score_text( fb->display_name, term, 0 );
       }
    }
-   else if( argc == 3 )
-   {
+   else if( argc == 3 ){
       int modify_all = 0;
 
       if( !strcmp( argv[1], "all" ) )
          modify_all = 1;
 
-      for( int i=0; i<vg_list_size(framebuffers); i++ )
-      {
+      for( int i=0; i<vg_list_size(framebuffers); i++ ){
          struct framebuffer *fb = &framebuffers[i];
          
-         for( int j=0; j<vg_list_size(fb->attachments); j++ )
-         {
+         for( int j=0; j<vg_list_size(fb->attachments); j++ ){
             struct framebuffer_attachment *at = &fb->attachments[j];
 
             if( at->purpose == k_framebuffer_attachment_type_none )
                continue;
 
-            if( modify_all )
-            {
+            if( modify_all ){
                console_suggest_score_text( at->display_name, term, 0 );
             }
-            else if( !strcmp( fb->display_name, argv[1] ) )
-            {
+            else if( !strcmp( fb->display_name, argv[1] ) ){
                console_suggest_score_text( at->display_name, term, 0 );
             }
          }
index c10f4f8b40edbddaa9356a14e403538f461d1dc8..5796c7aed341b577afad3bc607e40a7b046bcabf 100644 (file)
@@ -44,25 +44,10 @@ VG_STATIC float
 
 VG_STATIC void rb_register_cvar(void)
 {
-   vg_var_push( (struct vg_var){
-      .name = "k_limit_bias", .data = &k_limit_bias,
-      .data_type = k_var_dtype_f32, .opt_f32 = {.clamp = 0}, .persistent = 1
-   });
-
-   vg_var_push( (struct vg_var){
-      .name = "k_joint_bias", .data = &k_joint_bias,
-      .data_type = k_var_dtype_f32, .opt_f32 = {.clamp = 0}, .persistent = 1
-   });
-
-   vg_var_push( (struct vg_var){
-      .name = "k_joint_correction", .data = &k_joint_correction,
-      .data_type = k_var_dtype_f32, .opt_f32 = {.clamp = 0}, .persistent = 1
-   });
-
-   vg_var_push( (struct vg_var){
-      .name = "k_joint_impulse", .data = &k_joint_impulse,
-      .data_type = k_var_dtype_f32, .opt_f32 = {.clamp = 0}, .persistent = 1
-   });
+   VG_VAR_F32( k_limit_bias, flags=VG_VAR_CHEAT );
+   VG_VAR_F32( k_joint_bias, flags=VG_VAR_CHEAT );
+   VG_VAR_F32( k_joint_correction, flags=VG_VAR_CHEAT );
+   VG_VAR_F32( k_joint_impulse, flags=VG_VAR_CHEAT );
 }
 
 /* 
@@ -78,23 +63,19 @@ typedef struct rb_sphere rb_sphere;
 typedef struct rb_capsule rb_capsule;
 typedef struct rb_scene rb_scene;
 
-struct rb_sphere
-{
+struct rb_sphere{
    float radius;
 };
 
-struct rb_capsule
-{
+struct rb_capsule{
    float height, radius;
 };
 
-struct rb_scene
-{
+struct rb_scene{
    bh_tree *bh_scene;
 };
 
-struct rigidbody
-{
+struct rigidbody{
    v3f co, v, w;
    v4f q;
 
@@ -108,8 +89,7 @@ struct rigidbody
 };
 
 /* simple objects */
-struct rb_object
-{
+struct rb_object{
    rigidbody rb;
    enum rb_shape{
       k_rb_shape_box     = 0,
@@ -119,8 +99,7 @@ struct rb_object
    } 
    type;
    
-   union
-   {
+   union{
       struct rb_sphere sphere;
       struct rb_capsule capsule;
       struct rb_scene scene;
@@ -128,8 +107,7 @@ struct rb_object
    inf;
 };
 
-VG_STATIC struct contact
-{
+VG_STATIC struct contact{
    rigidbody *rba, *rbb;
    v3f co, n;
    v3f t[2];
@@ -146,14 +124,12 @@ VG_STATIC int rb_contact_count = 0;
 typedef struct rb_constr_pos rb_constr_pos;
 typedef struct rb_constr_swingtwist rb_constr_swingtwist;
 
-struct rb_constr_pos
-{
+struct rb_constr_pos{
    rigidbody *rba, *rbb;
    v3f lca, lcb;
 };
 
-struct rb_constr_swingtwist
-{
+struct rb_constr_swingtwist{
    rigidbody *rba, *rbb;
 
    v4f conevx, conevy; /* relative to rba */
@@ -167,8 +143,7 @@ struct rb_constr_swingtwist
    float tangent_mass, axis_mass;
 };
 
-struct rb_constr_spring
-{
+struct rb_constr_spring{
    int nothing;
 };
 
@@ -187,14 +162,12 @@ VG_STATIC float sphere_volume( float radius )
 VG_STATIC void rb_tangent_basis( v3f n, v3f tx, v3f ty )
 {
    /* Compute tangent basis (box2d) */
-   if( fabsf( n[0] ) >= 0.57735027f )
-   {
+   if( fabsf( n[0] ) >= 0.57735027f ){
       tx[0] =  n[1];
       tx[1] = -n[0];
       tx[2] =  0.0f;
    }
-   else
-   {
+   else{
       tx[0] =  0.0f;
       tx[1] =  n[2];
       tx[2] = -n[1];
@@ -215,13 +188,11 @@ VG_STATIC void rb_debug_contact( rb_ct *ct )
    v3f p1;
    v3_muladds( ct->co, ct->n, 0.05f, p1 );
 
-   if( ct->type == k_contact_type_default )
-   {
+   if( ct->type == k_contact_type_default ){
       vg_line_pt3( ct->co, 0.0125f, 0xff0000ff );
       vg_line( ct->co, p1, 0xffffffff );
    }
-   else if( ct->type == k_contact_type_edge )
-   {
+   else if( ct->type == k_contact_type_edge ){
       vg_line_pt3( ct->co, 0.0125f, 0xff00ffc0 );
       vg_line( ct->co, p1, 0xffffffff );
    }
@@ -233,8 +204,7 @@ VG_STATIC void debug_sphere( m4x3f m, float radius, u32 colour )
        lx = { 0.0f, radius, 0.0f },
        lz = { 0.0f, 0.0f, radius };
    
-   for( int i=0; i<16; i++ )
-   {
+   for( int i=0; i<16; i++ ){
       float t = ((float)(i+1) * (1.0f/16.0f)) * VG_PIf * 2.0f,
             s = sinf(t),
             c = cosf(t);
@@ -292,8 +262,7 @@ VG_STATIC void debug_capsule( m4x3f m, float radius, float h, u32 colour )
    vg_line( a0, a1, colour );
    vg_line( b0, b1, colour );
    
-   for( int i=0; i<16; i++ )
-   {
+   for( int i=0; i<16; i++ ){
       float t = ((float)(i+1) * (1.0f/16.0f)) * VG_PIf * 2.0f,
             s1 = sinf(t)*radius,
             c1 = cosf(t)*radius;
@@ -320,15 +289,13 @@ VG_STATIC void debug_capsule( m4x3f m, float radius, float h, u32 colour )
       vg_line( a0, a1, colour );
       vg_line( b0, b1, colour );
 
-      if( c0 < 0.0f )
-      {
+      if( c0 < 0.0f ){
          v3_add( p0, e2, a0 );
          v3_add( p0, e3, a1 );
          v3_add( p0, e4, b0 );
          v3_add( p0, e5, b1 );
       }
-      else
-      {
+      else{
          v3_add( p1, e2, a0 );
          v3_add( p1, e3, a1 );
          v3_add( p1, e4, b0 );
index 6678dea45b01e5387ea754a487ac23a203764b28..76658f2151aa1176439cea0d1489673131037d9d 100644 (file)
@@ -19,7 +19,8 @@ float sdLine( vec3 p, vec3 a, vec3 b )
 float compute_board_shadow()
 {
    // player shadow
-   float dist_to_player = max( 0.0, sdLine( aWorldCo, uBoard0, uBoard1 )-0.1 );
+   float dist_to_player = max( 0.0, sdLine( aWorldCo, g_board_0.xyz,
+                                                      g_board_1.xyz )-0.1 );
    float player_shadow = max( 1.0-dist_to_player*2.7, 0.0 );
    player_shadow *= player_shadow*player_shadow*player_shadow;
 
index 2b708858895c4afc8685bec62825c5529a1787d2..8926c21586c40d6cdd59d867a291d9f174dbd5ca 100644 (file)
@@ -16,6 +16,8 @@ layout (std140) uniform ub_world_lighting
    vec4 g_sunset_ambient;
    vec4 g_sun_colour;
    vec4 g_sun_dir;
+   vec4 g_board_0;
+   vec4 g_board_1;
 
    float g_water_fog;
    float g_time;
index bae097d5a097ba0826ebe46fb9728b6fb8587ac9..327a7a8c79cca38beff7453a4910989fe0960a6a 100644 (file)
@@ -102,6 +102,8 @@ static struct vg_shader _shader_model_character_view = {
 "   vec4 g_sunset_ambient;\n"
 "   vec4 g_sun_colour;\n"
 "   vec4 g_sun_dir;\n"
+"   vec4 g_board_0;\n"
+"   vec4 g_board_1;\n"
 "\n"
 "   float g_water_fog;\n"
 "   float g_time;\n"
@@ -202,7 +204,7 @@ static struct vg_shader _shader_model_character_view = {
 "   return ambient + (light_sun + sky_reflection) * shadow;\n"
 "}\n"
 "\n"
-"#line     42        0 \n"
+"#line     44        0 \n"
 "\n"
 "float world_depth_sample( vec3 pos )\n"
 "{\n"
index b5b58e5fd24f50675a358ed563b99bbbdb0ff615..6c0ba2aa2be919f58169a19942e1890c65f081a7 100644 (file)
@@ -96,6 +96,8 @@ static struct vg_shader _shader_model_sky = {
 "   vec4 g_sunset_ambient;\n"
 "   vec4 g_sun_colour;\n"
 "   vec4 g_sun_dir;\n"
+"   vec4 g_board_0;\n"
+"   vec4 g_board_1;\n"
 "\n"
 "   float g_water_fog;\n"
 "   float g_time;\n"
@@ -196,7 +198,7 @@ static struct vg_shader _shader_model_sky = {
 "   return ambient + (light_sun + sky_reflection) * shadow;\n"
 "}\n"
 "\n"
-"#line     42        0 \n"
+"#line     44        0 \n"
 "\n"
 "float world_depth_sample( vec3 pos )\n"
 "{\n"
index f1c5af34368ff017a54d28f43935d47d905a7724..e2a8e017ef0b39e30139a101b3473084adfea484 100644 (file)
@@ -95,6 +95,8 @@ static struct vg_shader _shader_scene_depth = {
 "   vec4 g_sunset_ambient;\n"
 "   vec4 g_sun_colour;\n"
 "   vec4 g_sun_dir;\n"
+"   vec4 g_board_0;\n"
+"   vec4 g_board_1;\n"
 "\n"
 "   float g_water_fog;\n"
 "   float g_time;\n"
@@ -195,7 +197,7 @@ static struct vg_shader _shader_scene_depth = {
 "   return ambient + (light_sun + sky_reflection) * shadow;\n"
 "}\n"
 "\n"
-"#line     42        0 \n"
+"#line     44        0 \n"
 "\n"
 "float world_depth_sample( vec3 pos )\n"
 "{\n"
@@ -390,7 +392,8 @@ static struct vg_shader _shader_scene_depth = {
 "float compute_board_shadow()\n"
 "{\n"
 "   // player shadow\n"
-"   float dist_to_player = max( 0.0, sdLine( aWorldCo, uBoard0, uBoard1 )-0.1 );\n"
+"   float dist_to_player = max( 0.0, sdLine( aWorldCo, g_board_0.xyz,\n"
+"                                                      g_board_1.xyz )-0.1 );\n"
 "   float player_shadow = max( 1.0-dist_to_player*2.7, 0.0 );\n"
 "   player_shadow *= player_shadow*player_shadow*player_shadow;\n"
 "\n"
index 029b8aae59fcc122f0e9846b9075f7acbac29610..e0b9982965b21b8de05c7688c807239a1355f437 100644 (file)
@@ -95,6 +95,8 @@ static struct vg_shader _shader_scene_position = {
 "   vec4 g_sunset_ambient;\n"
 "   vec4 g_sun_colour;\n"
 "   vec4 g_sun_dir;\n"
+"   vec4 g_board_0;\n"
+"   vec4 g_board_1;\n"
 "\n"
 "   float g_water_fog;\n"
 "   float g_time;\n"
@@ -195,7 +197,7 @@ static struct vg_shader _shader_scene_position = {
 "   return ambient + (light_sun + sky_reflection) * shadow;\n"
 "}\n"
 "\n"
-"#line     42        0 \n"
+"#line     44        0 \n"
 "\n"
 "float world_depth_sample( vec3 pos )\n"
 "{\n"
@@ -390,7 +392,8 @@ static struct vg_shader _shader_scene_position = {
 "float compute_board_shadow()\n"
 "{\n"
 "   // player shadow\n"
-"   float dist_to_player = max( 0.0, sdLine( aWorldCo, uBoard0, uBoard1 )-0.1 );\n"
+"   float dist_to_player = max( 0.0, sdLine( aWorldCo, g_board_0.xyz,\n"
+"                                                      g_board_1.xyz )-0.1 );\n"
 "   float player_shadow = max( 1.0-dist_to_player*2.7, 0.0 );\n"
 "   player_shadow *= player_shadow*player_shadow*player_shadow;\n"
 "\n"
index 93ed9b1380e3b5171e7111f9c3ed95cabc04ad6c..a4a3b133603335a07a6ecf329588e58edd548f1f 100644 (file)
@@ -2,8 +2,6 @@ uniform sampler2D uTexGarbage;
 uniform sampler2D uTexGradients;
 uniform vec3 uCamera;
 uniform vec4 uColour;
-uniform vec3 uBoard0;
-uniform vec3 uBoard1;
 
 #include "common_scene.glsl"
 #include "motion_vectors_fs.glsl"
index a381ee0ee71fbae9333955eea22bd5dcbd5b4de7..99610753c125f6599d936b537e1a0973d8ed4ace 100644 (file)
@@ -66,8 +66,6 @@ static struct vg_shader _shader_scene_route = {
 "uniform sampler2D uTexGradients;\n"
 "uniform vec3 uCamera;\n"
 "uniform vec4 uColour;\n"
-"uniform vec3 uBoard0;\n"
-"uniform vec3 uBoard1;\n"
 "\n"
 "#line       1        1 \n"
 "// :D\n"
@@ -96,6 +94,8 @@ static struct vg_shader _shader_scene_route = {
 "   vec4 g_sunset_ambient;\n"
 "   vec4 g_sun_colour;\n"
 "   vec4 g_sun_dir;\n"
+"   vec4 g_board_0;\n"
+"   vec4 g_board_1;\n"
 "\n"
 "   float g_water_fog;\n"
 "   float g_time;\n"
@@ -196,7 +196,7 @@ static struct vg_shader _shader_scene_route = {
 "   return ambient + (light_sun + sky_reflection) * shadow;\n"
 "}\n"
 "\n"
-"#line     42        0 \n"
+"#line     44        0 \n"
 "\n"
 "float world_depth_sample( vec3 pos )\n"
 "{\n"
@@ -391,7 +391,8 @@ static struct vg_shader _shader_scene_route = {
 "float compute_board_shadow()\n"
 "{\n"
 "   // player shadow\n"
-"   float dist_to_player = max( 0.0, sdLine( aWorldCo, uBoard0, uBoard1 )-0.1 );\n"
+"   float dist_to_player = max( 0.0, sdLine( aWorldCo, g_board_0.xyz,\n"
+"                                                      g_board_1.xyz )-0.1 );\n"
 "   float player_shadow = max( 1.0-dist_to_player*2.7, 0.0 );\n"
 "   player_shadow *= player_shadow*player_shadow*player_shadow;\n"
 "\n"
@@ -403,7 +404,7 @@ static struct vg_shader _shader_scene_route = {
 "   return world_compute_lighting( diffuse, normal, co, compute_board_shadow() );\n"
 "}\n"
 "\n"
-"#line      9        0 \n"
+"#line      7        0 \n"
 "#line       1        2 \n"
 "const float k_motion_lerp_amount = 0.01;\n"
 "\n"
@@ -423,7 +424,7 @@ static struct vg_shader _shader_scene_route = {
 "   oMotionVec = (vmotion1-vmotion0) * (1.0/k_motion_lerp_amount);\n"
 "}\n"
 "\n"
-"#line     10        0 \n"
+"#line      8        0 \n"
 "\n"
 "float filtered_stripe( in float p, in float ddx, in float ddy )\n"
 "{\n"
@@ -482,8 +483,6 @@ static GLuint _uniform_scene_route_uTexGarbage;
 static GLuint _uniform_scene_route_uTexGradients;
 static GLuint _uniform_scene_route_uCamera;
 static GLuint _uniform_scene_route_uColour;
-static GLuint _uniform_scene_route_uBoard0;
-static GLuint _uniform_scene_route_uBoard1;
 static GLuint _uniform_scene_route_g_world_depth;
 static GLuint _uniform_scene_route_uLightsArray;
 static GLuint _uniform_scene_route_uLightsIndex;
@@ -508,12 +507,6 @@ static void shader_scene_route_uCamera(v3f v){
 static void shader_scene_route_uColour(v4f v){
    glUniform4fv(_uniform_scene_route_uColour,1,v);
 }
-static void shader_scene_route_uBoard0(v3f v){
-   glUniform3fv(_uniform_scene_route_uBoard0,1,v);
-}
-static void shader_scene_route_uBoard1(v3f v){
-   glUniform3fv(_uniform_scene_route_uBoard1,1,v);
-}
 static void shader_scene_route_g_world_depth(int i){
    glUniform1i(_uniform_scene_route_g_world_depth,i);
 }
@@ -529,8 +522,6 @@ static void shader_scene_route_link(void){
    _uniform_scene_route_uTexGradients = glGetUniformLocation( _shader_scene_route.id, "uTexGradients" );
    _uniform_scene_route_uCamera = glGetUniformLocation( _shader_scene_route.id, "uCamera" );
    _uniform_scene_route_uColour = glGetUniformLocation( _shader_scene_route.id, "uColour" );
-   _uniform_scene_route_uBoard0 = glGetUniformLocation( _shader_scene_route.id, "uBoard0" );
-   _uniform_scene_route_uBoard1 = glGetUniformLocation( _shader_scene_route.id, "uBoard1" );
    _uniform_scene_route_g_world_depth = glGetUniformLocation( _shader_scene_route.id, "g_world_depth" );
    _uniform_scene_route_uLightsArray = glGetUniformLocation( _shader_scene_route.id, "uLightsArray" );
    _uniform_scene_route_uLightsIndex = glGetUniformLocation( _shader_scene_route.id, "uLightsIndex" );
index 16792a67f1ed531e68f6b67a07e48d336cb1b0ab..37b24fce1748829d5021efda7d7ad2e460c465b0 100644 (file)
@@ -86,8 +86,6 @@ static struct vg_shader _shader_scene_scoretext = {
 "uniform sampler2D uTexMain;\n"
 "uniform vec3 uCamera;\n"
 "uniform vec4 uPlane;\n"
-"uniform vec3 uBoard0;\n"
-"uniform vec3 uBoard1;\n"
 "\n"
 "#line       1        1 \n"
 "// :D\n"
@@ -116,6 +114,8 @@ static struct vg_shader _shader_scene_scoretext = {
 "   vec4 g_sunset_ambient;\n"
 "   vec4 g_sun_colour;\n"
 "   vec4 g_sun_dir;\n"
+"   vec4 g_board_0;\n"
+"   vec4 g_board_1;\n"
 "\n"
 "   float g_water_fog;\n"
 "   float g_time;\n"
@@ -216,7 +216,7 @@ static struct vg_shader _shader_scene_scoretext = {
 "   return ambient + (light_sun + sky_reflection) * shadow;\n"
 "}\n"
 "\n"
-"#line     42        0 \n"
+"#line     44        0 \n"
 "\n"
 "float world_depth_sample( vec3 pos )\n"
 "{\n"
@@ -411,7 +411,8 @@ static struct vg_shader _shader_scene_scoretext = {
 "float compute_board_shadow()\n"
 "{\n"
 "   // player shadow\n"
-"   float dist_to_player = max( 0.0, sdLine( aWorldCo, uBoard0, uBoard1 )-0.1 );\n"
+"   float dist_to_player = max( 0.0, sdLine( aWorldCo, g_board_0.xyz,\n"
+"                                                      g_board_1.xyz )-0.1 );\n"
 "   float player_shadow = max( 1.0-dist_to_player*2.7, 0.0 );\n"
 "   player_shadow *= player_shadow*player_shadow*player_shadow;\n"
 "\n"
@@ -423,7 +424,7 @@ static struct vg_shader _shader_scene_scoretext = {
 "   return world_compute_lighting( diffuse, normal, co, compute_board_shadow() );\n"
 "}\n"
 "\n"
-"#line      9        0 \n"
+"#line      7        0 \n"
 "#line       1        2 \n"
 "const float k_motion_lerp_amount = 0.01;\n"
 "\n"
@@ -443,7 +444,7 @@ static struct vg_shader _shader_scene_scoretext = {
 "   oMotionVec = (vmotion1-vmotion0) * (1.0/k_motion_lerp_amount);\n"
 "}\n"
 "\n"
-"#line     10        0 \n"
+"#line      8        0 \n"
 "\n"
 "void main()\n"
 "{\n"
@@ -474,8 +475,6 @@ static GLuint _uniform_scene_scoretext_uTexGarbage;
 static GLuint _uniform_scene_scoretext_uTexMain;
 static GLuint _uniform_scene_scoretext_uCamera;
 static GLuint _uniform_scene_scoretext_uPlane;
-static GLuint _uniform_scene_scoretext_uBoard0;
-static GLuint _uniform_scene_scoretext_uBoard1;
 static GLuint _uniform_scene_scoretext_g_world_depth;
 static GLuint _uniform_scene_scoretext_uLightsArray;
 static GLuint _uniform_scene_scoretext_uLightsIndex;
@@ -503,12 +502,6 @@ static void shader_scene_scoretext_uCamera(v3f v){
 static void shader_scene_scoretext_uPlane(v4f v){
    glUniform4fv(_uniform_scene_scoretext_uPlane,1,v);
 }
-static void shader_scene_scoretext_uBoard0(v3f v){
-   glUniform3fv(_uniform_scene_scoretext_uBoard0,1,v);
-}
-static void shader_scene_scoretext_uBoard1(v3f v){
-   glUniform3fv(_uniform_scene_scoretext_uBoard1,1,v);
-}
 static void shader_scene_scoretext_g_world_depth(int i){
    glUniform1i(_uniform_scene_scoretext_g_world_depth,i);
 }
@@ -525,8 +518,6 @@ static void shader_scene_scoretext_link(void){
    _uniform_scene_scoretext_uTexMain = glGetUniformLocation( _shader_scene_scoretext.id, "uTexMain" );
    _uniform_scene_scoretext_uCamera = glGetUniformLocation( _shader_scene_scoretext.id, "uCamera" );
    _uniform_scene_scoretext_uPlane = glGetUniformLocation( _shader_scene_scoretext.id, "uPlane" );
-   _uniform_scene_scoretext_uBoard0 = glGetUniformLocation( _shader_scene_scoretext.id, "uBoard0" );
-   _uniform_scene_scoretext_uBoard1 = glGetUniformLocation( _shader_scene_scoretext.id, "uBoard1" );
    _uniform_scene_scoretext_g_world_depth = glGetUniformLocation( _shader_scene_scoretext.id, "g_world_depth" );
    _uniform_scene_scoretext_uLightsArray = glGetUniformLocation( _shader_scene_scoretext.id, "uLightsArray" );
    _uniform_scene_scoretext_uLightsIndex = glGetUniformLocation( _shader_scene_scoretext.id, "uLightsIndex" );
index 7fcf1d5e03777e8b99b44f4b810bffa262cbbe05..58a472da906bf048d8cd1d2def94d505d4894910 100644 (file)
@@ -2,8 +2,6 @@ uniform sampler2D uTexGarbage;
 uniform sampler2D uTexMain;
 uniform vec3 uCamera;
 uniform vec4 uPlane;
-uniform vec3 uBoard0;
-uniform vec3 uBoard1;
 
 #include "common_scene.glsl"
 #include "motion_vectors_fs.glsl"
index e6d6e6f67c2ffbceca693801c413af7c431ee536..bacef090005f3979d1ed31f7be8e1dc89578d0be 100644 (file)
@@ -66,8 +66,6 @@ static struct vg_shader _shader_scene_standard = {
 "uniform sampler2D uTexMain;\n"
 "uniform vec3 uCamera;\n"
 "uniform vec4 uPlane;\n"
-"uniform vec3 uBoard0;\n"
-"uniform vec3 uBoard1;\n"
 "\n"
 "#line       1        1 \n"
 "// :D\n"
@@ -96,6 +94,8 @@ static struct vg_shader _shader_scene_standard = {
 "   vec4 g_sunset_ambient;\n"
 "   vec4 g_sun_colour;\n"
 "   vec4 g_sun_dir;\n"
+"   vec4 g_board_0;\n"
+"   vec4 g_board_1;\n"
 "\n"
 "   float g_water_fog;\n"
 "   float g_time;\n"
@@ -196,7 +196,7 @@ static struct vg_shader _shader_scene_standard = {
 "   return ambient + (light_sun + sky_reflection) * shadow;\n"
 "}\n"
 "\n"
-"#line     42        0 \n"
+"#line     44        0 \n"
 "\n"
 "float world_depth_sample( vec3 pos )\n"
 "{\n"
@@ -391,7 +391,8 @@ static struct vg_shader _shader_scene_standard = {
 "float compute_board_shadow()\n"
 "{\n"
 "   // player shadow\n"
-"   float dist_to_player = max( 0.0, sdLine( aWorldCo, uBoard0, uBoard1 )-0.1 );\n"
+"   float dist_to_player = max( 0.0, sdLine( aWorldCo, g_board_0.xyz,\n"
+"                                                      g_board_1.xyz )-0.1 );\n"
 "   float player_shadow = max( 1.0-dist_to_player*2.7, 0.0 );\n"
 "   player_shadow *= player_shadow*player_shadow*player_shadow;\n"
 "\n"
@@ -403,7 +404,7 @@ static struct vg_shader _shader_scene_standard = {
 "   return world_compute_lighting( diffuse, normal, co, compute_board_shadow() );\n"
 "}\n"
 "\n"
-"#line      9        0 \n"
+"#line      7        0 \n"
 "#line       1        2 \n"
 "const float k_motion_lerp_amount = 0.01;\n"
 "\n"
@@ -423,7 +424,7 @@ static struct vg_shader _shader_scene_standard = {
 "   oMotionVec = (vmotion1-vmotion0) * (1.0/k_motion_lerp_amount);\n"
 "}\n"
 "\n"
-"#line     10        0 \n"
+"#line      8        0 \n"
 "\n"
 "void main()\n"
 "{\n"
@@ -453,8 +454,6 @@ static GLuint _uniform_scene_standard_uTexGarbage;
 static GLuint _uniform_scene_standard_uTexMain;
 static GLuint _uniform_scene_standard_uCamera;
 static GLuint _uniform_scene_standard_uPlane;
-static GLuint _uniform_scene_standard_uBoard0;
-static GLuint _uniform_scene_standard_uBoard1;
 static GLuint _uniform_scene_standard_g_world_depth;
 static GLuint _uniform_scene_standard_uLightsArray;
 static GLuint _uniform_scene_standard_uLightsIndex;
@@ -479,12 +478,6 @@ static void shader_scene_standard_uCamera(v3f v){
 static void shader_scene_standard_uPlane(v4f v){
    glUniform4fv(_uniform_scene_standard_uPlane,1,v);
 }
-static void shader_scene_standard_uBoard0(v3f v){
-   glUniform3fv(_uniform_scene_standard_uBoard0,1,v);
-}
-static void shader_scene_standard_uBoard1(v3f v){
-   glUniform3fv(_uniform_scene_standard_uBoard1,1,v);
-}
 static void shader_scene_standard_g_world_depth(int i){
    glUniform1i(_uniform_scene_standard_g_world_depth,i);
 }
@@ -500,8 +493,6 @@ static void shader_scene_standard_link(void){
    _uniform_scene_standard_uTexMain = glGetUniformLocation( _shader_scene_standard.id, "uTexMain" );
    _uniform_scene_standard_uCamera = glGetUniformLocation( _shader_scene_standard.id, "uCamera" );
    _uniform_scene_standard_uPlane = glGetUniformLocation( _shader_scene_standard.id, "uPlane" );
-   _uniform_scene_standard_uBoard0 = glGetUniformLocation( _shader_scene_standard.id, "uBoard0" );
-   _uniform_scene_standard_uBoard1 = glGetUniformLocation( _shader_scene_standard.id, "uBoard1" );
    _uniform_scene_standard_g_world_depth = glGetUniformLocation( _shader_scene_standard.id, "g_world_depth" );
    _uniform_scene_standard_uLightsArray = glGetUniformLocation( _shader_scene_standard.id, "uLightsArray" );
    _uniform_scene_standard_uLightsIndex = glGetUniformLocation( _shader_scene_standard.id, "uLightsIndex" );
index fe8f10c652cf27cb699425a085340c53c93c2027..d7127a7e3e32eb092de1a4c7eff538210a4027d3 100644 (file)
@@ -1,7 +1,5 @@
 uniform sampler2D uTexGarbage;
 uniform sampler2D uTexMain;
-uniform vec3 uBoard0;
-uniform vec3 uBoard1;
 uniform vec3 uCamera;
 uniform vec4 uPlane;
 
index f14bd6c7793e7b3d33edb44614819185b61a4017..c512d36190bf952b2af5d49fcd0ed2412c578343 100644 (file)
@@ -64,8 +64,6 @@ static struct vg_shader _shader_scene_standard_alphatest = {
 .static_src = 
 "uniform sampler2D uTexGarbage;\n"
 "uniform sampler2D uTexMain;\n"
-"uniform vec3 uBoard0;\n"
-"uniform vec3 uBoard1;\n"
 "uniform vec3 uCamera;\n"
 "uniform vec4 uPlane;\n"
 "\n"
@@ -96,6 +94,8 @@ static struct vg_shader _shader_scene_standard_alphatest = {
 "   vec4 g_sunset_ambient;\n"
 "   vec4 g_sun_colour;\n"
 "   vec4 g_sun_dir;\n"
+"   vec4 g_board_0;\n"
+"   vec4 g_board_1;\n"
 "\n"
 "   float g_water_fog;\n"
 "   float g_time;\n"
@@ -196,7 +196,7 @@ static struct vg_shader _shader_scene_standard_alphatest = {
 "   return ambient + (light_sun + sky_reflection) * shadow;\n"
 "}\n"
 "\n"
-"#line     42        0 \n"
+"#line     44        0 \n"
 "\n"
 "float world_depth_sample( vec3 pos )\n"
 "{\n"
@@ -391,7 +391,8 @@ static struct vg_shader _shader_scene_standard_alphatest = {
 "float compute_board_shadow()\n"
 "{\n"
 "   // player shadow\n"
-"   float dist_to_player = max( 0.0, sdLine( aWorldCo, uBoard0, uBoard1 )-0.1 );\n"
+"   float dist_to_player = max( 0.0, sdLine( aWorldCo, g_board_0.xyz,\n"
+"                                                      g_board_1.xyz )-0.1 );\n"
 "   float player_shadow = max( 1.0-dist_to_player*2.7, 0.0 );\n"
 "   player_shadow *= player_shadow*player_shadow*player_shadow;\n"
 "\n"
@@ -403,7 +404,7 @@ static struct vg_shader _shader_scene_standard_alphatest = {
 "   return world_compute_lighting( diffuse, normal, co, compute_board_shadow() );\n"
 "}\n"
 "\n"
-"#line      9        0 \n"
+"#line      7        0 \n"
 "#line       1        2 \n"
 "const float k_motion_lerp_amount = 0.01;\n"
 "\n"
@@ -423,7 +424,7 @@ static struct vg_shader _shader_scene_standard_alphatest = {
 "   oMotionVec = (vmotion1-vmotion0) * (1.0/k_motion_lerp_amount);\n"
 "}\n"
 "\n"
-"#line     10        0 \n"
+"#line      8        0 \n"
 "\n"
 "void main()\n"
 "{\n"
@@ -454,8 +455,6 @@ static GLuint _uniform_scene_standard_alphatest_uPv;
 static GLuint _uniform_scene_standard_alphatest_uPvmPrev;
 static GLuint _uniform_scene_standard_alphatest_uTexGarbage;
 static GLuint _uniform_scene_standard_alphatest_uTexMain;
-static GLuint _uniform_scene_standard_alphatest_uBoard0;
-static GLuint _uniform_scene_standard_alphatest_uBoard1;
 static GLuint _uniform_scene_standard_alphatest_uCamera;
 static GLuint _uniform_scene_standard_alphatest_uPlane;
 static GLuint _uniform_scene_standard_alphatest_g_world_depth;
@@ -476,12 +475,6 @@ static void shader_scene_standard_alphatest_uTexGarbage(int i){
 static void shader_scene_standard_alphatest_uTexMain(int i){
    glUniform1i(_uniform_scene_standard_alphatest_uTexMain,i);
 }
-static void shader_scene_standard_alphatest_uBoard0(v3f v){
-   glUniform3fv(_uniform_scene_standard_alphatest_uBoard0,1,v);
-}
-static void shader_scene_standard_alphatest_uBoard1(v3f v){
-   glUniform3fv(_uniform_scene_standard_alphatest_uBoard1,1,v);
-}
 static void shader_scene_standard_alphatest_uCamera(v3f v){
    glUniform3fv(_uniform_scene_standard_alphatest_uCamera,1,v);
 }
@@ -501,8 +494,6 @@ static void shader_scene_standard_alphatest_link(void){
    _uniform_scene_standard_alphatest_uPvmPrev = glGetUniformLocation( _shader_scene_standard_alphatest.id, "uPvmPrev" );
    _uniform_scene_standard_alphatest_uTexGarbage = glGetUniformLocation( _shader_scene_standard_alphatest.id, "uTexGarbage" );
    _uniform_scene_standard_alphatest_uTexMain = glGetUniformLocation( _shader_scene_standard_alphatest.id, "uTexMain" );
-   _uniform_scene_standard_alphatest_uBoard0 = glGetUniformLocation( _shader_scene_standard_alphatest.id, "uBoard0" );
-   _uniform_scene_standard_alphatest_uBoard1 = glGetUniformLocation( _shader_scene_standard_alphatest.id, "uBoard1" );
    _uniform_scene_standard_alphatest_uCamera = glGetUniformLocation( _shader_scene_standard_alphatest.id, "uCamera" );
    _uniform_scene_standard_alphatest_uPlane = glGetUniformLocation( _shader_scene_standard_alphatest.id, "uPlane" );
    _uniform_scene_standard_alphatest_g_world_depth = glGetUniformLocation( _shader_scene_standard_alphatest.id, "g_world_depth" );
index d9d0bf119f80746a4a3483e3bf9e0d352a8fa3f8..a1feb1a3be500a9141925bc3e62ce509d9367ab0 100644 (file)
@@ -3,8 +3,6 @@ uniform sampler2D uTexGradients;
 uniform vec3 uCamera;
 uniform vec3 uSandColour;
 uniform vec2 uBlendOffset;
-uniform vec3 uBoard0;
-uniform vec3 uBoard1;
 
 #include "common_scene.glsl"
 #include "motion_vectors_fs.glsl"
index 00e9399683f21884280e053f30e80cd6f3426603..9886809ac7a509afeb3279bb01392b84beff1b05 100644 (file)
@@ -67,8 +67,6 @@ static struct vg_shader _shader_scene_terrain = {
 "uniform vec3 uCamera;\n"
 "uniform vec3 uSandColour;\n"
 "uniform vec2 uBlendOffset;\n"
-"uniform vec3 uBoard0;\n"
-"uniform vec3 uBoard1;\n"
 "\n"
 "#line       1        1 \n"
 "// :D\n"
@@ -97,6 +95,8 @@ static struct vg_shader _shader_scene_terrain = {
 "   vec4 g_sunset_ambient;\n"
 "   vec4 g_sun_colour;\n"
 "   vec4 g_sun_dir;\n"
+"   vec4 g_board_0;\n"
+"   vec4 g_board_1;\n"
 "\n"
 "   float g_water_fog;\n"
 "   float g_time;\n"
@@ -197,7 +197,7 @@ static struct vg_shader _shader_scene_terrain = {
 "   return ambient + (light_sun + sky_reflection) * shadow;\n"
 "}\n"
 "\n"
-"#line     42        0 \n"
+"#line     44        0 \n"
 "\n"
 "float world_depth_sample( vec3 pos )\n"
 "{\n"
@@ -392,7 +392,8 @@ static struct vg_shader _shader_scene_terrain = {
 "float compute_board_shadow()\n"
 "{\n"
 "   // player shadow\n"
-"   float dist_to_player = max( 0.0, sdLine( aWorldCo, uBoard0, uBoard1 )-0.1 );\n"
+"   float dist_to_player = max( 0.0, sdLine( aWorldCo, g_board_0.xyz,\n"
+"                                                      g_board_1.xyz )-0.1 );\n"
 "   float player_shadow = max( 1.0-dist_to_player*2.7, 0.0 );\n"
 "   player_shadow *= player_shadow*player_shadow*player_shadow;\n"
 "\n"
@@ -404,7 +405,7 @@ static struct vg_shader _shader_scene_terrain = {
 "   return world_compute_lighting( diffuse, normal, co, compute_board_shadow() );\n"
 "}\n"
 "\n"
-"#line     10        0 \n"
+"#line      8        0 \n"
 "#line       1        2 \n"
 "const float k_motion_lerp_amount = 0.01;\n"
 "\n"
@@ -424,7 +425,7 @@ static struct vg_shader _shader_scene_terrain = {
 "   oMotionVec = (vmotion1-vmotion0) * (1.0/k_motion_lerp_amount);\n"
 "}\n"
 "\n"
-"#line     11        0 \n"
+"#line      9        0 \n"
 "\n"
 "void main()\n"
 "{\n"
@@ -477,8 +478,6 @@ static GLuint _uniform_scene_terrain_uTexGradients;
 static GLuint _uniform_scene_terrain_uCamera;
 static GLuint _uniform_scene_terrain_uSandColour;
 static GLuint _uniform_scene_terrain_uBlendOffset;
-static GLuint _uniform_scene_terrain_uBoard0;
-static GLuint _uniform_scene_terrain_uBoard1;
 static GLuint _uniform_scene_terrain_g_world_depth;
 static GLuint _uniform_scene_terrain_uLightsArray;
 static GLuint _uniform_scene_terrain_uLightsIndex;
@@ -506,12 +505,6 @@ static void shader_scene_terrain_uSandColour(v3f v){
 static void shader_scene_terrain_uBlendOffset(v2f v){
    glUniform2fv(_uniform_scene_terrain_uBlendOffset,1,v);
 }
-static void shader_scene_terrain_uBoard0(v3f v){
-   glUniform3fv(_uniform_scene_terrain_uBoard0,1,v);
-}
-static void shader_scene_terrain_uBoard1(v3f v){
-   glUniform3fv(_uniform_scene_terrain_uBoard1,1,v);
-}
 static void shader_scene_terrain_g_world_depth(int i){
    glUniform1i(_uniform_scene_terrain_g_world_depth,i);
 }
@@ -528,8 +521,6 @@ static void shader_scene_terrain_link(void){
    _uniform_scene_terrain_uCamera = glGetUniformLocation( _shader_scene_terrain.id, "uCamera" );
    _uniform_scene_terrain_uSandColour = glGetUniformLocation( _shader_scene_terrain.id, "uSandColour" );
    _uniform_scene_terrain_uBlendOffset = glGetUniformLocation( _shader_scene_terrain.id, "uBlendOffset" );
-   _uniform_scene_terrain_uBoard0 = glGetUniformLocation( _shader_scene_terrain.id, "uBoard0" );
-   _uniform_scene_terrain_uBoard1 = glGetUniformLocation( _shader_scene_terrain.id, "uBoard1" );
    _uniform_scene_terrain_g_world_depth = glGetUniformLocation( _shader_scene_terrain.id, "g_world_depth" );
    _uniform_scene_terrain_uLightsArray = glGetUniformLocation( _shader_scene_terrain.id, "uLightsArray" );
    _uniform_scene_terrain_uLightsIndex = glGetUniformLocation( _shader_scene_terrain.id, "uLightsIndex" );
index e9c5c15519b8adcf511343b39f86a4378094b28d..0368b20a5fab902e288202c9ac8653d8ce12feab 100644 (file)
@@ -1,8 +1,6 @@
 uniform sampler2D uTexGarbage;
 uniform sampler2D uTexGradients;
 uniform vec3 uCamera;
-uniform vec3 uBoard0;
-uniform vec3 uBoard1;
 
 #include "common_scene.glsl"
 #include "motion_vectors_fs.glsl"
index 17c6f91694eae9f3be8cf5b06a7c268d6ba09a78..5a2afe2c20d4f5a922db721e30e62cca8a1c49c5 100644 (file)
@@ -65,8 +65,6 @@ static struct vg_shader _shader_scene_vertex_blend = {
 "uniform sampler2D uTexGarbage;\n"
 "uniform sampler2D uTexGradients;\n"
 "uniform vec3 uCamera;\n"
-"uniform vec3 uBoard0;\n"
-"uniform vec3 uBoard1;\n"
 "\n"
 "#line       1        1 \n"
 "// :D\n"
@@ -95,6 +93,8 @@ static struct vg_shader _shader_scene_vertex_blend = {
 "   vec4 g_sunset_ambient;\n"
 "   vec4 g_sun_colour;\n"
 "   vec4 g_sun_dir;\n"
+"   vec4 g_board_0;\n"
+"   vec4 g_board_1;\n"
 "\n"
 "   float g_water_fog;\n"
 "   float g_time;\n"
@@ -195,7 +195,7 @@ static struct vg_shader _shader_scene_vertex_blend = {
 "   return ambient + (light_sun + sky_reflection) * shadow;\n"
 "}\n"
 "\n"
-"#line     42        0 \n"
+"#line     44        0 \n"
 "\n"
 "float world_depth_sample( vec3 pos )\n"
 "{\n"
@@ -390,7 +390,8 @@ static struct vg_shader _shader_scene_vertex_blend = {
 "float compute_board_shadow()\n"
 "{\n"
 "   // player shadow\n"
-"   float dist_to_player = max( 0.0, sdLine( aWorldCo, uBoard0, uBoard1 )-0.1 );\n"
+"   float dist_to_player = max( 0.0, sdLine( aWorldCo, g_board_0.xyz,\n"
+"                                                      g_board_1.xyz )-0.1 );\n"
 "   float player_shadow = max( 1.0-dist_to_player*2.7, 0.0 );\n"
 "   player_shadow *= player_shadow*player_shadow*player_shadow;\n"
 "\n"
@@ -402,7 +403,7 @@ static struct vg_shader _shader_scene_vertex_blend = {
 "   return world_compute_lighting( diffuse, normal, co, compute_board_shadow() );\n"
 "}\n"
 "\n"
-"#line      8        0 \n"
+"#line      6        0 \n"
 "#line       1        2 \n"
 "const float k_motion_lerp_amount = 0.01;\n"
 "\n"
@@ -422,7 +423,7 @@ static struct vg_shader _shader_scene_vertex_blend = {
 "   oMotionVec = (vmotion1-vmotion0) * (1.0/k_motion_lerp_amount);\n"
 "}\n"
 "\n"
-"#line      9        0 \n"
+"#line      7        0 \n"
 "\n"
 "void main()\n"
 "{\n"
@@ -469,8 +470,6 @@ static GLuint _uniform_scene_vertex_blend_uPvmPrev;
 static GLuint _uniform_scene_vertex_blend_uTexGarbage;
 static GLuint _uniform_scene_vertex_blend_uTexGradients;
 static GLuint _uniform_scene_vertex_blend_uCamera;
-static GLuint _uniform_scene_vertex_blend_uBoard0;
-static GLuint _uniform_scene_vertex_blend_uBoard1;
 static GLuint _uniform_scene_vertex_blend_g_world_depth;
 static GLuint _uniform_scene_vertex_blend_uLightsArray;
 static GLuint _uniform_scene_vertex_blend_uLightsIndex;
@@ -492,12 +491,6 @@ static void shader_scene_vertex_blend_uTexGradients(int i){
 static void shader_scene_vertex_blend_uCamera(v3f v){
    glUniform3fv(_uniform_scene_vertex_blend_uCamera,1,v);
 }
-static void shader_scene_vertex_blend_uBoard0(v3f v){
-   glUniform3fv(_uniform_scene_vertex_blend_uBoard0,1,v);
-}
-static void shader_scene_vertex_blend_uBoard1(v3f v){
-   glUniform3fv(_uniform_scene_vertex_blend_uBoard1,1,v);
-}
 static void shader_scene_vertex_blend_g_world_depth(int i){
    glUniform1i(_uniform_scene_vertex_blend_g_world_depth,i);
 }
@@ -512,8 +505,6 @@ static void shader_scene_vertex_blend_link(void){
    _uniform_scene_vertex_blend_uTexGarbage = glGetUniformLocation( _shader_scene_vertex_blend.id, "uTexGarbage" );
    _uniform_scene_vertex_blend_uTexGradients = glGetUniformLocation( _shader_scene_vertex_blend.id, "uTexGradients" );
    _uniform_scene_vertex_blend_uCamera = glGetUniformLocation( _shader_scene_vertex_blend.id, "uCamera" );
-   _uniform_scene_vertex_blend_uBoard0 = glGetUniformLocation( _shader_scene_vertex_blend.id, "uBoard0" );
-   _uniform_scene_vertex_blend_uBoard1 = glGetUniformLocation( _shader_scene_vertex_blend.id, "uBoard1" );
    _uniform_scene_vertex_blend_g_world_depth = glGetUniformLocation( _shader_scene_vertex_blend.id, "g_world_depth" );
    _uniform_scene_vertex_blend_uLightsArray = glGetUniformLocation( _shader_scene_vertex_blend.id, "uLightsArray" );
    _uniform_scene_vertex_blend_uLightsIndex = glGetUniformLocation( _shader_scene_vertex_blend.id, "uLightsIndex" );
index a62842adb3fab234de5d81b4ddddfc1f4698ed51..cd59ac17bf451e035ece9b0bfe07cad3bd152bae 100644 (file)
@@ -103,6 +103,8 @@ static struct vg_shader _shader_scene_water = {
 "   vec4 g_sunset_ambient;\n"
 "   vec4 g_sun_colour;\n"
 "   vec4 g_sun_dir;\n"
+"   vec4 g_board_0;\n"
+"   vec4 g_board_1;\n"
 "\n"
 "   float g_water_fog;\n"
 "   float g_time;\n"
@@ -203,7 +205,7 @@ static struct vg_shader _shader_scene_water = {
 "   return ambient + (light_sun + sky_reflection) * shadow;\n"
 "}\n"
 "\n"
-"#line     42        0 \n"
+"#line     44        0 \n"
 "\n"
 "float world_depth_sample( vec3 pos )\n"
 "{\n"
@@ -398,7 +400,8 @@ static struct vg_shader _shader_scene_water = {
 "float compute_board_shadow()\n"
 "{\n"
 "   // player shadow\n"
-"   float dist_to_player = max( 0.0, sdLine( aWorldCo, uBoard0, uBoard1 )-0.1 );\n"
+"   float dist_to_player = max( 0.0, sdLine( aWorldCo, g_board_0.xyz,\n"
+"                                                      g_board_1.xyz )-0.1 );\n"
 "   float player_shadow = max( 1.0-dist_to_player*2.7, 0.0 );\n"
 "   player_shadow *= player_shadow*player_shadow*player_shadow;\n"
 "\n"
index b4510c7e31292b0dcaf62556bd1b64c3bdb05778..84fc918c61493946fe36612c398b2de086f23f18 100644 (file)
@@ -100,6 +100,8 @@ static struct vg_shader _shader_scene_water_fast = {
 "   vec4 g_sunset_ambient;\n"
 "   vec4 g_sun_colour;\n"
 "   vec4 g_sun_dir;\n"
+"   vec4 g_board_0;\n"
+"   vec4 g_board_1;\n"
 "\n"
 "   float g_water_fog;\n"
 "   float g_time;\n"
@@ -200,7 +202,7 @@ static struct vg_shader _shader_scene_water_fast = {
 "   return ambient + (light_sun + sky_reflection) * shadow;\n"
 "}\n"
 "\n"
-"#line     42        0 \n"
+"#line     44        0 \n"
 "\n"
 "float world_depth_sample( vec3 pos )\n"
 "{\n"
@@ -395,7 +397,8 @@ static struct vg_shader _shader_scene_water_fast = {
 "float compute_board_shadow()\n"
 "{\n"
 "   // player shadow\n"
-"   float dist_to_player = max( 0.0, sdLine( aWorldCo, uBoard0, uBoard1 )-0.1 );\n"
+"   float dist_to_player = max( 0.0, sdLine( aWorldCo, g_board_0.xyz,\n"
+"                                                      g_board_1.xyz )-0.1 );\n"
 "   float player_shadow = max( 1.0-dist_to_player*2.7, 0.0 );\n"
 "   player_shadow *= player_shadow*player_shadow*player_shadow;\n"
 "\n"
index 7b1d1d15dbcc723067562329187f0bff4676e56f..df5c1479f8fd01ea8729570474f71d2c7834567b 100644 (file)
@@ -20,9 +20,8 @@
 #include "audio.h"
 #include "world.h"
 #include "font.h"
-
-
 #include "player.h"
+
 static player_instance localplayer;
 VG_STATIC struct player_avatar localplayer_avatar;
 VG_STATIC glmesh localplayer_meshes[3];
@@ -37,9 +36,6 @@ player_instance *tmp_localplayer(void)
 #include "menu.h"
 #include "vehicle.h"
 
-static int cl_ui      = 1,
-           cl_light_edit = 0;
-
 #define DEV_AARON
 #ifdef DEV_AARON
 static rb_object aaron={
@@ -123,35 +119,8 @@ VG_STATIC void vg_preload(void)
 {
    g_conf_init();
 
-   common_var_temp();
-
-   vg_var_push( (struct vg_var){
-      .name = "cl_ui",
-      .data = &cl_ui,
-      .data_type = k_var_dtype_i32,
-      .opt_i32 = { .min=0, .max=1, .clamp=1 },
-      .persistent = 0
-   });
-
-   vg_var_push( (struct vg_var){
-      .name = "ledit",
-      .data = &cl_light_edit,
-      .data_type = k_var_dtype_i32,
-      .opt_i32 = { .min=0, .max=1, .clamp=1 },
-      .persistent = 0
-   });
-
-   vg_function_push( (struct vg_cmd) {
-      .name = "respawn",
-      .function = __respawn,
-      //.poll_suggest = reset_player_poll
-   });
-
-   vg_function_push( (struct vg_cmd) {
-      .name = "ded",
-      .function = __kill,
-      //.poll_suggest = reset_player_poll
-   });
+   vg_console_reg_cmd( "respawn", __respawn, NULL );
+   vg_console_reg_cmd( "ded", __kill, NULL );
 
 vg_info(" Copyright  .        . .       -----, ,----- ,---.   .---.  \n" );
 vg_info(" 2021-2022  |\\      /| |           /  |      |    | |    /| \n" );
@@ -233,14 +202,13 @@ VG_STATIC void vg_load(void)
    vg_loader_step( render_init, NULL );
    vg_loader_step( menu_init, NULL );
    vg_loader_step( world_init, NULL );
+   vg_loader_step( vehicle_init, NULL );
    vg_loader_step( font3d_init, NULL );
 
    font3d_load( &world_global.font, "models/rs_font.mdl", vg_mem.rtmemory );
 
-   //vg_loader_step( player_init, NULL );
-   vg_loader_step( vehicle_init, NULL );
-   //
-   //vg_loader_step( player_model_init, NULL );
+   vg_loader_step( player_init, NULL );
+   vg_loader_step( player_ragdoll_init, NULL );
    
    /* ----------------- */
    vg_loader_step( load_playermodels, NULL );
@@ -522,6 +490,7 @@ VG_STATIC void render_scene(void)
       return;
    }
 
+   world_prerender( view_world );
    render_world( view_world, &main_camera, 0 );
 
    render_water_texture( view_world, &main_camera, 0 );
diff --git a/steam.h b/steam.h
index f6eadcd1ba81390c1c2aec756482b1f5440ce2f4..7bd0ab84a42bed5ae86d7695066cd306d2ef12ce 100644 (file)
--- a/steam.h
+++ b/steam.h
@@ -257,23 +257,9 @@ VG_STATIC int steam_init(void)
       vg_warn( "No Steam Logon: Cannot request stats\n" );
 
 
-       vg_function_push( (struct vg_cmd)
-   {
-               .name = "ach_list",
-               .function = steam_list_achievements
-       });
-
-       vg_function_push( (struct vg_cmd)
-   {
-               .name = "ach_clear_all",
-               .function = steam_clear_all_achievements
-       });
-
-       vg_function_push( (struct vg_cmd)
-   {
-               .name = "ach_set",
-               .function = steam_set_achievemnt_test
-       });
+   vg_console_reg_cmd( "ach_list", steam_list_achievements, NULL );
+   vg_console_reg_cmd( "ach_clear_all", steam_clear_all_achievements, NULL );
+   vg_console_reg_cmd( "ach_set", steam_set_achievemnt_test, NULL );
 
    steam_hInput = SteamAPI_SteamInput();
    SteamAPI_ISteamInput_Init( steam_hInput, 0 );
index 54a2591e11e4110dd48b37a8e9ad9d0701931014..02ceb041440a084dae3817f8a91dd9c64f3ea4ed 100644 (file)
--- a/vehicle.h
+++ b/vehicle.h
@@ -76,22 +76,19 @@ VG_STATIC void vehicle_init(void)
    v3_zero( gzoomer.obj.rb.co );
    rb_init_object( &gzoomer.obj );
 
-   VG_VAR_F32_PERSISTENT( k_car_spring );
-   VG_VAR_F32_PERSISTENT( k_car_spring_damp );
-   VG_VAR_F32_PERSISTENT( k_car_spring_length );
-   VG_VAR_F32_PERSISTENT( k_car_wheel_radius );
-   VG_VAR_F32_PERSISTENT( k_car_friction_lat );
-   VG_VAR_F32_PERSISTENT( k_car_friction_roll );
-   VG_VAR_F32_PERSISTENT( k_car_drive_force );
-   VG_VAR_F32_PERSISTENT( k_car_air_resistance );
-   VG_VAR_F32_PERSISTENT( k_car_downforce );
+   VG_VAR_F32( k_car_spring,        flags=VG_VAR_PERSISTENT );
+   VG_VAR_F32( k_car_spring_damp,   flags=VG_VAR_PERSISTENT );
+   VG_VAR_F32( k_car_spring_length, flags=VG_VAR_PERSISTENT );
+   VG_VAR_F32( k_car_wheel_radius,  flags=VG_VAR_PERSISTENT );
+   VG_VAR_F32( k_car_friction_lat,  flags=VG_VAR_PERSISTENT );
+   VG_VAR_F32( k_car_friction_roll, flags=VG_VAR_PERSISTENT );
+   VG_VAR_F32( k_car_drive_force,   flags=VG_VAR_PERSISTENT );
+   VG_VAR_F32( k_car_air_resistance,flags=VG_VAR_PERSISTENT );
+   VG_VAR_F32( k_car_downforce,     flags=VG_VAR_PERSISTENT );
 
    VG_VAR_I32( gzoomer.inside );
 
-       vg_function_push( (struct vg_cmd){
-               .name = "spawn_car",
-               .function = spawn_car
-       });
+   vg_console_reg_cmd( "spawn_car", spawn_car, NULL );
 
    v3_copy((v3f){ -1.0f, -0.25f, -1.5f }, gzoomer.wheels_local[0] );
    v3_copy((v3f){  1.0f, -0.25f, -1.5f }, gzoomer.wheels_local[1] );
diff --git a/world.h b/world.h
index ab663d005e4ffadacb32956e34c3e503c9287679..c782ae09d7369cd90ddb51c3b25ef774166feced 100644 (file)
--- a/world.h
+++ b/world.h
@@ -87,6 +87,8 @@ struct world_instance {
       v4f g_sunset_ambient;
       v4f g_sun_colour;
       v4f g_sun_dir;
+      v4f g_board_0;
+      v4f g_board_1;
 
       float g_water_fog;
       float g_time;
@@ -277,6 +279,13 @@ int ray_world( world_instance *world, v3f pos, v3f dir, ray_hit *hit );
  * Submodules
  */
 
+VG_STATIC float
+   k_day_length            = 30.0f; /* minutes */
+
+VG_STATIC int   k_debug_light_indices = 0,
+                k_debug_light_complexity = 0,
+                k_light_preview = 0;
+
 #include "world_routes.h"
 #include "world_sfd.h"
 #include "world_render.h"
@@ -299,6 +308,11 @@ VG_STATIC int world_stop_sound( int argc, const char *argv[] )
 
 VG_STATIC void world_init(void)
 {
+   VG_VAR_F32( k_day_length );
+   VG_VAR_I32( k_debug_light_indices );
+   VG_VAR_I32( k_debug_light_complexity );
+   VG_VAR_I32( k_light_preview );
+
    world_global.sky_rate = 1.0;
    world_global.sky_target_rate = 1.0;
 
@@ -473,48 +487,6 @@ VG_STATIC void entity_call( world_instance *world, ent_call *call )
 
 VG_STATIC void world_update( world_instance *world, v3f pos )
 {
-   /* TEMP!!!!!! */
-   static double g_time = 0.0;
-   g_time += vg.time_delta * (1.0/(k_day_length*60.0));
-
-
-   struct ub_world_lighting *state = &world->ub_lighting;
-
-   state->g_time = g_time;
-   state->g_realtime = vg.time;
-   state->g_debug_indices = k_debug_light_indices;
-   state->g_light_preview = k_light_preview;
-   state->g_debug_complexity = k_debug_light_complexity;
-
-   state->g_time_of_day = vg_fractf( g_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 );
-
-   state->g_day_phase    =       state->g_day_phase    * 0.5f + 0.5f;
-   state->g_sunset_phase = powf( state->g_sunset_phase * 0.5f + 0.5f, 6.0f );
-
-   float a = state->g_time_of_day * VG_PIf * 2.0f;
-   state->g_sun_dir[0] = sinf( a );
-   state->g_sun_dir[1] = cosf( a );
-   state->g_sun_dir[2] = 0.2f;
-   v3_normalize( state->g_sun_dir );
-
-
-   world->probabilities[ k_probability_curve_constant ] = 1.0f;
-
-   float dp = state->g_day_phase;
-
-   world->probabilities[ k_probability_curve_wildlife_day ] =
-      (dp*dp*0.8f+state->g_sunset_phase)*0.8f;
-   world->probabilities[ k_probability_curve_wildlife_night ] = 
-      1.0f-powf(fabsf((state->g_time_of_day-0.5f)*5.0f),5.0f);
-      
-
-   glBindBuffer( GL_UNIFORM_BUFFER, world->ubo_lighting );
-   glBufferSubData( GL_UNIFORM_BUFFER, 0, 
-                    sizeof(struct ub_world_lighting), &world->ub_lighting );
-   /* TEMP!!!!!! */
-
    world_global.sky_time += world_global.sky_rate * vg.time_delta;
    world_global.sky_rate = vg_lerp( world_global.sky_rate, 
                                     world_global.sky_target_rate, 
@@ -563,8 +535,6 @@ VG_STATIC void world_update( world_instance *world, v3f pos )
       }
    }
    sfd_update();
-   
-
 
    static float random_accum = 0.0f;
    random_accum += vg.time_delta;
index e04a6bb85455da4aaebecc7b71bc5cccf175705a..ad0d5c43a2d469fdb31c1650a7559241e08a7457 100644 (file)
@@ -183,8 +183,6 @@ VG_STATIC void render_world_vb( world_instance *world, camera *cam )
    shader_scene_vertex_blend_uPvmPrev( cam->mtx_prev.pv );
    shader_scene_vertex_blend_uMdl( identity_matrix );
    shader_scene_vertex_blend_uCamera( cam->transform[3] );
-   shader_scene_vertex_blend_uBoard0( TEMP_BOARD_0 );
-   shader_scene_vertex_blend_uBoard1( TEMP_BOARD_1 );
 
    world_render_both_stages( world, k_shader_standard_vertex_blend,
                              bindpoint_diffuse_texture1 );
@@ -213,8 +211,6 @@ VG_STATIC void render_world_standard( world_instance *world, camera *cam )
 
    shader_scene_standard_uMdl( identity_matrix );
    shader_scene_standard_uCamera( cam->transform[3] );
-   shader_scene_standard_uBoard0( TEMP_BOARD_0 );
-   shader_scene_standard_uBoard1( TEMP_BOARD_1 );
    
    world_render_both_stages( world, k_shader_standard,
                              bindpoint_diffuse_texture1 );
@@ -244,8 +240,6 @@ VG_STATIC void render_world_alphatest( world_instance *world, camera *cam )
 
    shader_scene_standard_alphatest_uMdl( identity_matrix );
    shader_scene_standard_alphatest_uCamera( cam->transform[3] );
-   shader_scene_standard_alphatest_uBoard0( TEMP_BOARD_0 );
-   shader_scene_standard_alphatest_uBoard1( TEMP_BOARD_1 );
 
    glDisable(GL_CULL_FACE);
    
@@ -289,8 +283,6 @@ VG_STATIC void render_terrain( world_instance *world, camera *cam )
 
    shader_scene_terrain_uMdl( identity_matrix );
    shader_scene_terrain_uCamera( cam->transform[3] );
-   shader_scene_terrain_uBoard0( TEMP_BOARD_0 );
-   shader_scene_terrain_uBoard1( TEMP_BOARD_1 );
 
    world_render_both_stages( world, k_shader_terrain_blend, bindpoint_terrain );
 }
@@ -380,6 +372,49 @@ VG_STATIC void render_world_gates( world_instance *world, camera *cam,
    }
 }
 
+VG_STATIC void world_prerender( world_instance *world )
+{
+   static double g_time = 0.0;
+   g_time += vg.time_delta * (1.0/(k_day_length*60.0));
+
+
+   struct ub_world_lighting *state = &world->ub_lighting;
+
+   state->g_time = g_time;
+   state->g_realtime = vg.time;
+   state->g_debug_indices = k_debug_light_indices;
+   state->g_light_preview = k_light_preview;
+   state->g_debug_complexity = k_debug_light_complexity;
+
+   state->g_time_of_day = vg_fractf( g_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 );
+
+   state->g_day_phase    =       state->g_day_phase    * 0.5f + 0.5f;
+   state->g_sunset_phase = powf( state->g_sunset_phase * 0.5f + 0.5f, 6.0f );
+
+   float a = state->g_time_of_day * VG_PIf * 2.0f;
+   state->g_sun_dir[0] = sinf( a );
+   state->g_sun_dir[1] = cosf( a );
+   state->g_sun_dir[2] = 0.2f;
+   v3_normalize( state->g_sun_dir );
+
+
+   world->probabilities[ k_probability_curve_constant ] = 1.0f;
+
+   float dp = state->g_day_phase;
+
+   world->probabilities[ k_probability_curve_wildlife_day ] =
+      (dp*dp*0.8f+state->g_sunset_phase)*0.8f;
+   world->probabilities[ k_probability_curve_wildlife_night ] = 
+      1.0f-powf(fabsf((state->g_time_of_day-0.5f)*5.0f),5.0f);
+      
+
+   glBindBuffer( GL_UNIFORM_BUFFER, world->ubo_lighting );
+   glBufferSubData( GL_UNIFORM_BUFFER, 0, 
+                    sizeof(struct ub_world_lighting), &world->ub_lighting );
+}
+
 VG_STATIC void render_world( world_instance *world, camera *cam,
                              int layer_depth )
 {
index df758da8bd7a7fe5d7bb218ac00b7f6742eb7fed..acb58131436f80b1a43ef7864a561410d22e5ce4 100644 (file)
@@ -565,11 +565,6 @@ VG_STATIC void world_routes_ent_init( world_instance *world )
 
    for( u32 i=0; i<mdl_arrcount(&world->ent_gate); i++ ){
       ent_gate *gate = mdl_arritm( &world->ent_gate, i );
-
-      vg_info( "ROUTES :: %hu %hu %hu %hu\n", gate->routes[0],
-                                              gate->routes[1],
-                                              gate->routes[2],
-                                              gate->routes[3] );
    }
 
    world_routes_clear( world );
@@ -584,7 +579,7 @@ VG_STATIC void world_routes_ent_init( world_instance *world )
 VG_STATIC void world_routes_init(void)
 {
    world_global.current_run_version = 200;
-   world_global.time = RESET_MAX_TIME*2.0;
+   world_global.time = 300.0;
    world_global.last_use = 0.0;
 
    shader_scene_route_register();
@@ -855,8 +850,6 @@ VG_STATIC void render_world_routes( world_instance *world, camera *cam,
    shader_scene_route_uPvmPrev( cam->mtx_prev.pv );
    shader_scene_route_uMdl( identity_matrix );
    shader_scene_route_uCamera( cam->transform[3] );
-   shader_scene_route_uBoard0( TEMP_BOARD_0 );
-   shader_scene_route_uBoard1( TEMP_BOARD_1 );
 
    mesh_bind( &world->mesh_route_lines );
 
index 69501e288723cfd81a5aa5996b1788f838ce8e23..98d34b2498ed1ccedf43b4f09b5528cf9ab9a2dd 100644 (file)
@@ -156,11 +156,7 @@ VG_STATIC void world_sfd_init(void)
 {
    vg_info( "world_sfd_init\n" );
    shader_scene_scoretext_register();
-
-       vg_function_push( (struct vg_cmd){
-               .name = "sfd",
-               .function = world_sfd_test
-       });
+   vg_console_reg_cmd( "sfd", world_sfd_test, NULL );
 
    vg_linear_clear( vg_mem.scratch );