y
authorhgn <hgodden00@gmail.com>
Sat, 31 May 2025 17:42:47 +0000 (18:42 +0100)
committerhgn <hgodden00@gmail.com>
Sat, 31 May 2025 17:42:47 +0000 (18:42 +0100)
vg_audio.c
vg_console.c
vg_console.h
vg_engine.c
vg_rigidbody.c
vg_rigidbody.h

index 47ef9e8f7bd1652e67869e26a753c35359f8ebd6..3113fc77f92a6a321eb69aaf6de02c65e4f5d4a0 100644 (file)
@@ -558,7 +558,7 @@ bool vg_audio_is_channel_using_clip( audio_channel_id id, audio_clip *clip )
 
 void vg_audio_fadeout_flagged_audio( u32 flag, f32 length )
 {
-   vg_audio_lock();
+   vg_audio_assert_lock();
    for( u32 id=1; id<=AUDIO_CHANNELS; id ++ )
    {
       audio_channel *channel = get_audio_channel( id );
@@ -569,7 +569,6 @@ void vg_audio_fadeout_flagged_audio( u32 flag, f32 length )
             vg_audio_crossfade( id, NULL, 1.0f );
       }
    }
-   vg_audio_unlock();
 }
 
 bool vg_audio_flagged_stopped( u32 flag )
index c4179c235682838d9be7729f686cc5da1dd3e276..6fa079521bdad56b9715da1bd3183ce9b7a1f739 100644 (file)
@@ -182,7 +182,7 @@ static vg_cmd *vg_console_match_cmd( const char *kw )
    return NULL;
 }
 
-void vg_execute_console_input( const char *cmd, bool silent )
+void vg_execute_console_input( const char *cmd, bool silent, bool cheat_override )
 {
        char temp[512];
        char const *args[8];
@@ -200,7 +200,7 @@ void vg_execute_console_input( const char *cmd, bool silent )
       if( arg_count >= 2 )
       {
 #ifdef VG_ENGINE
-         if( cv->flags & VG_VAR_CHEAT )
+         if( (cv->flags & VG_VAR_CHEAT) && !cheat_override )
          {
             bool cheats = vg_console.cheats;
             if( !cheats && !silent )
@@ -582,7 +582,7 @@ static void _vg_console_on_enter( ui_context *ctx, char *buf, u32 len, void *use
       }
 
       vg_console.history_pos = -1;
-      vg_execute_console_input( vg_console.input, 0 );
+      vg_execute_console_input( vg_console.input, 0, 0 );
       _ui_textbox_move_cursor( ctx, &ctx->textbox.cursor_user, &ctx->textbox.cursor_pos, -10000, 1 );
       vg_console.input[0] = '\0';
       console_update_suggestions( ctx );
@@ -614,7 +614,7 @@ static int vg_console_exec( int argc, const char *argv[] )
       {
                        line[ strcspn( line, "\r\n#" ) ] = 0x00;
                        if( line[0] != 0x00 )
-                               vg_execute_console_input( line, silent );
+                               vg_execute_console_input( line, silent, 0 );
                }
 
                fclose( fp );
index e3ccf4f5df3bd8c9d14e49aeb76c68f3a564abfe..2c1d290a9871ac8391f33c7da937107e7e88441b 100644 (file)
@@ -86,4 +86,4 @@ void console_suggest_prev( ui_context *ctx );
 #endif
 
 void vg_console_init(void);
-void vg_execute_console_input( const char *cmd, bool silent );
+void vg_execute_console_input( const char *cmd, bool silent, bool cheat_override );
index e5b286f36d4b175d06c73609a79feb9607052ce1..131f592682ef5531c4bdc35f3301a8a8f3a577e9 100644 (file)
@@ -742,6 +742,8 @@ void vg_run(void)
    vg_console_reg_var( "vg_quality", &vg.quality_profile, k_var_dtype_i32, VG_VAR_PERSISTENT );
    vg_console_reg_var( "vg_screen_mode", &vg.screen_mode, k_var_dtype_i32, VG_VAR_PERSISTENT );
 
+   rb_register_cvar();
+
    vg_audio_register();
    vg_console_load_autos();
 
index 322f42a97dc37a3266a1fd4492806d06d0c1b65b..c833a9dc26f03a42ded87a8bedbd377c576a8362 100644 (file)
@@ -11,16 +11,19 @@ static float
    k_joint_impulse    = 1.0f,
    k_joint_bias       = 0.08f;               /* positional joints */
 
-static void rb_register_cvar(void)
+f32 k_gravity = 9.6f;
+
+void rb_register_cvar(void)
 {
    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 );
+   VG_VAR_F32( k_gravity, flags=VG_VAR_CHEAT );
 }
 
-void rb_setbody_capsule( rigidbody *rb, f32 r, f32 h, 
-                         f32 density, f32 inertia_scale ){
+void rb_setbody_capsule( rigidbody *rb, f32 r, f32 h, f32 density, f32 inertia_scale )
+{
    f32 vol  = vg_capsule_volume( r, h ),
        mass = vol*density;
 
@@ -96,7 +99,7 @@ void rb_iter( rigidbody *rb )
             "or more components: %f %f %f\n", rb->v[0],rb->v[1],rb->v[2] );
    }
 
-   v3f gravity = { 0.0f, -9.8f, 0.0f };
+   v3f gravity = { 0.0f, -k_gravity, 0.0f };
    v3_muladds( rb->v, gravity, vg.time_fixed_delta, rb->v );
 
    /* intergrate velocity */
index bf7fdb34ea1b70fca66f0033789d022e0a62fcb9..68ed57da4924555b5be197ba486662d72e1566dd 100644 (file)
 #define k_penetration_slop 0.01f
 #define k_rb_inertia_scale 4.0f
 #define k_phys_baumgarte   0.2f
-#define k_gravity          9.6f
+//#define k_gravity          9.6f
 #define k_rb_density       8.0f
 
+extern f32 k_gravity;
+
 enum rb_shape {
    k_rb_shape_none    = 0,
    k_rb_shape_box     = 1,
@@ -44,11 +46,12 @@ struct rigidbody
    m4x3f to_world, to_local;
 };
 
+void rb_register_cvar(void);
+
 /* 
  * Initialize rigidbody inverse mass and inertia tensor with some common shapes
  */
-void rb_setbody_capsule( rigidbody *rb, f32 r, f32 h, 
-                         f32 density, f32 inertia_scale );
+void rb_setbody_capsule( rigidbody *rb, f32 r, f32 h, f32 density, f32 inertia_scale );
 void rb_setbody_box( rigidbody *rb, boxf box, f32 density, f32 inertia_scale );
 void rb_setbody_sphere( rigidbody *rb, f32 r, f32 density, f32 inertia_scale );
 
@@ -79,5 +82,4 @@ void rb_linear_impulse( rigidbody *rb, v3f delta, v3f impulse );
  * Effectors
  */
 void rb_effect_simple_bouyency( rigidbody *ra, v4f plane, f32 amt, f32 drag );
-void rb_effect_spring_target_vector( rigidbody *rba, v3f ra, v3f rt,
-                                     f32 spring, f32 dampening, f32 timestep );
+void rb_effect_spring_target_vector( rigidbody *rba, v3f ra, v3f rt, f32 spring, f32 dampening, f32 timestep );