From f1b125a1a5e7a3b4e14cfbe0c4ab1474d81a9ddd Mon Sep 17 00:00:00 2001 From: hgn Date: Sat, 31 May 2025 18:42:47 +0100 Subject: [PATCH] y --- vg_audio.c | 3 +-- vg_console.c | 8 ++++---- vg_console.h | 2 +- vg_engine.c | 2 ++ vg_rigidbody.c | 11 +++++++---- vg_rigidbody.h | 12 +++++++----- 6 files changed, 22 insertions(+), 16 deletions(-) diff --git a/vg_audio.c b/vg_audio.c index 47ef9e8..3113fc7 100644 --- a/vg_audio.c +++ b/vg_audio.c @@ -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 ) diff --git a/vg_console.c b/vg_console.c index c4179c2..6fa0795 100644 --- a/vg_console.c +++ b/vg_console.c @@ -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 ); diff --git a/vg_console.h b/vg_console.h index e3ccf4f..2c1d290 100644 --- a/vg_console.h +++ b/vg_console.h @@ -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 ); diff --git a/vg_engine.c b/vg_engine.c index e5b286f..131f592 100644 --- a/vg_engine.c +++ b/vg_engine.c @@ -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(); diff --git a/vg_rigidbody.c b/vg_rigidbody.c index 322f42a..c833a9d 100644 --- a/vg_rigidbody.c +++ b/vg_rigidbody.c @@ -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 */ diff --git a/vg_rigidbody.h b/vg_rigidbody.h index bf7fdb3..68ed57d 100644 --- a/vg_rigidbody.h +++ b/vg_rigidbody.h @@ -15,9 +15,11 @@ #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 ); -- 2.25.1