From d4da00674b14822d214c73f009f737843bb8e87a Mon Sep 17 00:00:00 2001 From: RaphaelIT7 Date: Fri, 15 Dec 2023 00:12:41 +0100 Subject: [PATCH] Revert "Workaround for Gmod ConVars causing a crash" This reverts commit 1d4db16dd6c1b249753f6efd100e6a45c0ed7347. --- vphysics_jolt/cbase.h | 2 +- vphysics_jolt/vjolt_collide_trace.cpp | 12 +-- vphysics_jolt/vjolt_constraints.cpp | 2 +- vphysics_jolt/vjolt_controller_player.cpp | 2 +- vphysics_jolt/vjolt_controller_vehicle.cpp | 4 +- vphysics_jolt/vjolt_convar.cpp | 87 ---------------------- vphysics_jolt/vjolt_convar.h | 72 ------------------ vphysics_jolt/vjolt_debugrender.cpp | 2 +- vphysics_jolt/vjolt_environment.cpp | 8 +- vphysics_jolt/vphysics_jolt_inc.vpc | 2 - 10 files changed, 16 insertions(+), 177 deletions(-) delete mode 100644 vphysics_jolt/vjolt_convar.cpp delete mode 100644 vphysics_jolt/vjolt_convar.h diff --git a/vphysics_jolt/cbase.h b/vphysics_jolt/cbase.h index be2d8a99..d3266884 100644 --- a/vphysics_jolt/cbase.h +++ b/vphysics_jolt/cbase.h @@ -54,7 +54,7 @@ #include "mathlib/vector.h" // Tier1 -#include "vjolt_convar.h" // Also includes tier1/tier1.h +#include "tier1/tier1.h" #include "tier1/strtools.h" #include "tier1/interface.h" #ifndef GAME_L4D2_OR_NEWER diff --git a/vphysics_jolt/vjolt_collide_trace.cpp b/vphysics_jolt/vjolt_collide_trace.cpp index 1560d8ae..da6138c6 100644 --- a/vphysics_jolt/vjolt_collide_trace.cpp +++ b/vphysics_jolt/vjolt_collide_trace.cpp @@ -27,18 +27,18 @@ static constexpr float kCharacterPadding = 0.02f; // Also in vjolt_collide.cpp, should unify or just remove entirely static constexpr float kMaxConvexRadius = JPH::cDefaultConvexRadius; -static JoltConVar vjolt_trace_debug( "vjolt_trace_debug", "0", FCVAR_CHEAT ); -static JoltConVar vjolt_trace_debug_castray( "vjolt_trace_debug_castray", "0", FCVAR_CHEAT ); -static JoltConVar vjolt_trace_debug_collidepoint( "vjolt_trace_debug_collidepoint", "0", FCVAR_CHEAT ); -static JoltConVar vjolt_trace_debug_castbox( "vjolt_trace_debug_castbox", "0", FCVAR_CHEAT ); -static JoltConVar vjolt_trace_debug_collidebox( "vjolt_trace_debug_collidebox", "0", FCVAR_CHEAT ); +static ConVar vjolt_trace_debug( "vjolt_trace_debug", "0", FCVAR_CHEAT ); +static ConVar vjolt_trace_debug_castray( "vjolt_trace_debug_castray", "0", FCVAR_CHEAT ); +static ConVar vjolt_trace_debug_collidepoint( "vjolt_trace_debug_collidepoint", "0", FCVAR_CHEAT ); +static ConVar vjolt_trace_debug_castbox( "vjolt_trace_debug_castbox", "0", FCVAR_CHEAT ); +static ConVar vjolt_trace_debug_collidebox( "vjolt_trace_debug_collidebox", "0", FCVAR_CHEAT ); // Josh: Enables a hack to make portals work. For some reason when we enable colliding with // backfaces, the player gets easily stuck in all sorts of things! // Slart and I have not been able to determine the root cause of this problem and have tried for a long time... // // Slart: Portal 2 probably passes in a bad winding order in the polyhedron or something, dunno if it affects Portal 1 -static JoltConVar vjolt_trace_portal_hack( "vjolt_trace_portal_hack", "0", FCVAR_NONE ); +static ConVar vjolt_trace_portal_hack( "vjolt_trace_portal_hack", "0", FCVAR_NONE ); //------------------------------------------------------------------------------------------------- // diff --git a/vphysics_jolt/vjolt_constraints.cpp b/vphysics_jolt/vjolt_constraints.cpp index 0aca5a49..17d5cd06 100644 --- a/vphysics_jolt/vjolt_constraints.cpp +++ b/vphysics_jolt/vjolt_constraints.cpp @@ -16,7 +16,7 @@ //------------------------------------------------------------------------------------------------- -static JoltConVar vjolt_ragdoll_hinge_optimization( "vjolt_ragdoll_hinge_optimization", "1", FCVAR_REPLICATED, +static ConVar vjolt_ragdoll_hinge_optimization( "vjolt_ragdoll_hinge_optimization", "1", FCVAR_REPLICATED, "Optimizes ragdolls to use hinge constraints for joints with 1 degree of freedom. Additionally fixes legs going back on themselves. Currently breaks ragdolls of NPCs killed in a pose (they inherit the pose)."); //------------------------------------------------------------------------------------------------- diff --git a/vphysics_jolt/vjolt_controller_player.cpp b/vphysics_jolt/vjolt_controller_player.cpp index 909acb0c..1a11e1b1 100644 --- a/vphysics_jolt/vjolt_controller_player.cpp +++ b/vphysics_jolt/vjolt_controller_player.cpp @@ -10,7 +10,7 @@ //------------------------------------------------------------------------------------------------- -static JoltConVar vjolt_player_collision_tolerance( "vjolt_player_collision_tolerance", "0.05" ); +static ConVar vjolt_player_collision_tolerance( "vjolt_player_collision_tolerance", "0.05" ); //------------------------------------------------------------------------------------------------- diff --git a/vphysics_jolt/vjolt_controller_vehicle.cpp b/vphysics_jolt/vjolt_controller_vehicle.cpp index c7c58710..6c2cd5b0 100644 --- a/vphysics_jolt/vjolt_controller_vehicle.cpp +++ b/vphysics_jolt/vjolt_controller_vehicle.cpp @@ -10,9 +10,9 @@ //------------------------------------------------------------------------------------------------ -static JoltConVar vjolt_vehicle_wheel_debug( "vjolt_vehicle_wheel_debug", "0", FCVAR_CHEAT ); +static ConVar vjolt_vehicle_wheel_debug( "vjolt_vehicle_wheel_debug", "0", FCVAR_CHEAT ); -static JoltConVar vjolt_vehicle_throttle_opposition_limit( "vjolt_vehicle_throttle_opposition_limit", "5", FCVAR_NONE, +static ConVar vjolt_vehicle_throttle_opposition_limit( "vjolt_vehicle_throttle_opposition_limit", "5", FCVAR_NONE, "Below what speed should we be attempting to drive/climb with handbrake on to avoid falling down." ); //------------------------------------------------------------------------------------------------ diff --git a/vphysics_jolt/vjolt_convar.cpp b/vphysics_jolt/vjolt_convar.cpp deleted file mode 100644 index 4aa2d934..00000000 --- a/vphysics_jolt/vjolt_convar.cpp +++ /dev/null @@ -1,87 +0,0 @@ -#include "cbase.h" - -#ifdef GAME_GMOD -JoltConVar::JoltConVar( const char *pName, const char *pDefaultValue, int flags, const char *pHelpString, bool bMin, float fMin, bool bMax, float fMax ) -{ - // ConVar stuff - m_pszName = pName; - m_pszDefaultValue = pDefaultValue; - - SetValue(m_pszDefaultValue); - - m_bHasMin = bMin; - m_fMinVal = fMin; - m_bHasMax = bMax; - m_fMaxVal = fMax; - - // Set the callback - m_bUsingNewCommandCallback = true; - //m_fnCompletionCallback = JoltConVar_CompletionFunc; - m_bHasCompletionCallback = ( m_fnCompletionCallback != 0 ); - m_bUsingCommandCallbackInterface = false; - - // Setup the rest - BaseClass::CreateBase( pName, pHelpString, flags ); -} - -JoltConVar::~JoltConVar( void ) -{ - if (m_pszString) { - delete[] m_pszString; - } -} - -void JoltConVar::Dispatch( const CCommand &cmd ) -{ - if ( cmd.ArgC() == 1 ) { - Msg( "%s: %s\n", m_pszName, GetString() ); - } else if ( cmd.ArgC() == 2 ) { - SetValue( cmd.Arg(1) ); - Msg( "%s set to %s\n", m_pszName, GetString() ); - } -} - -int JoltConVar::AutoCompleteSuggest( const char *partial, CUtlVector< CUtlString > &commands ) -{ - std::string cmd = partial; - size_t found = cmd.find_first_of( " " ); - if ( found ) { - cmd = cmd.substr(0, found); - } - - commands.AddToTail(( cmd + " " + GetString() ).c_str() ); - return 1; -} - -void JoltConVar::SetValueInternal( const char* m_pszValue ) -{ - if (m_pszString) { - delete[] m_pszString; - } - - m_StringLength = V_strlen( m_pszValue ) + 1; - m_pszString = new char[m_StringLength]; - memcpy( m_pszString, m_pszValue, m_StringLength ); - - m_fValue = ( float )atof( m_pszString ); - m_nValue = atoi( m_pszString ); -} - -void JoltConVar::SetValue( const char* m_pszValue ) -{ - SetValueInternal(m_pszValue); - - float m_fClamped = m_fValue; - if (m_bHasMin) { - m_fClamped = clamp(m_fValue, m_fMinVal, m_fValue); - } - - if (m_bHasMax) { - m_fClamped = clamp(m_fValue, m_fValue, m_fMaxVal); - } - - if (m_fClamped != m_fValue) { - SetValueInternal(std::to_string(m_fClamped).c_str()); - } -} -#endif \ No newline at end of file diff --git a/vphysics_jolt/vjolt_convar.h b/vphysics_jolt/vjolt_convar.h deleted file mode 100644 index a1677222..00000000 --- a/vphysics_jolt/vjolt_convar.h +++ /dev/null @@ -1,72 +0,0 @@ - -#pragma once - -#include "tier1/tier1.h" - -#ifndef JOLTCONVAR_H -#define JOLTCONVAR_H - -#ifdef GAME_GMOD -class JoltConVar : public ConCommandBase -{ -friend class CCvar; - -public: - typedef ConCommandBase BaseClass; - - JoltConVar( const char *pName, const char *pDefaultValue, int flags = 0, const char *pHelpString = "", bool bMin = false, float fMin = 0.0, bool bMax = false, float fMax = 0.0 ); - - virtual ~JoltConVar( void ); - - virtual bool IsCommand( void ) const { return true; }; - - virtual int AutoCompleteSuggest( const char *partial, CUtlVector< CUtlString > &commands ); - - virtual bool CanAutoComplete( void ) { return true; }; - - virtual void Dispatch( const CCommand &command ); -public: - virtual float GetFloat(){ return m_fValue; } - virtual int GetInt(){ return m_nValue; } - virtual bool GetBool() { return !!GetInt(); } - virtual const char* GetString() { return m_pszString; } - - virtual void SetValue(const char*); -private: - union - { - FnCommandCallbackVoid_t m_fnCommandCallbackV1; - FnCommandCallback_t m_fnCommandCallback; - ICommandCallback *m_pCommandCallback; - }; - - union - { - FnCommandCompletionCallback m_fnCompletionCallback; - ICommandCompletionCallback *m_pCommandCompletionCallback; - }; - - bool m_bHasCompletionCallback : 1; - bool m_bUsingNewCommandCallback : 1; - bool m_bUsingCommandCallbackInterface : 1; -private: - virtual void SetValueInternal(const char*); - - const char* m_pszName; - const char *m_pszDefaultValue; - - char *m_pszString; - int m_StringLength; - - float m_fValue; - int m_nValue; - - bool m_bHasMin; - float m_fMinVal; - bool m_bHasMax; - float m_fMaxVal; -}; -#else - #define JoltConVar ConVar -#endif -#endif \ No newline at end of file diff --git a/vphysics_jolt/vjolt_debugrender.cpp b/vphysics_jolt/vjolt_debugrender.cpp index 7c18ad1b..bece2483 100644 --- a/vphysics_jolt/vjolt_debugrender.cpp +++ b/vphysics_jolt/vjolt_debugrender.cpp @@ -25,7 +25,7 @@ #define JOLT_VERTEX_BUFFER_NAME "Jolt Debug Renderer Vertices" #define JOLT_INDEX_BUFFER_NAME "Jolt Debug Renderer Indices" -static JoltConVar vjolt_debugrender( "vjolt_debugrender", "0", FCVAR_CHEAT ); +static ConVar vjolt_debugrender( "vjolt_debugrender", "0", FCVAR_CHEAT ); #ifndef VJOLT_USE_PHYSICS_DEBUG_OVERLAY static ConVar vjolt_debugrender_picture_in_picture( "vjolt_debugrender_picture_in_picture", "1" ); static ConVar vjolt_debugrender_clear_rt( "vjolt_debugrender_clear_rt", "1" ); diff --git a/vphysics_jolt/vjolt_environment.cpp b/vphysics_jolt/vjolt_environment.cpp index 3cb280c4..c8d412a8 100644 --- a/vphysics_jolt/vjolt_environment.cpp +++ b/vphysics_jolt/vjolt_environment.cpp @@ -49,12 +49,12 @@ static constexpr uint kMaxBodyPairs = kMaxBodies; // number then these contacts will be ignored and bodies will start interpenetrating / fall through the world. static constexpr uint kMaxContactConstraints = kMaxBodies; -static JoltConVar vjolt_linearcast( "vjolt_linearcast", "1", FCVAR_NONE, "Whether bodies will be created with linear cast motion quality (only takes effect after map restart)." ); -static JoltConVar vjolt_initial_simulation( "vjolt_initial_simulation", "0", FCVAR_NONE, "Whether to pre-settle physics objects on map load." ); +static ConVar vjolt_linearcast( "vjolt_linearcast", "1", FCVAR_NONE, "Whether bodies will be created with linear cast motion quality (only takes effect after map restart)." ); +static ConVar vjolt_initial_simulation( "vjolt_initial_simulation", "0", FCVAR_NONE, "Whether to pre-settle physics objects on map load." ); -static JoltConVar vjolt_substeps_collision( "vjolt_substeps_collision", "1", FCVAR_NONE, "Number of collision steps to perform.", true, 0.0f, true, 4.0f ); +static ConVar vjolt_substeps_collision( "vjolt_substeps_collision", "1", FCVAR_NONE, "Number of collision steps to perform.", true, 0.0f, true, 4.0f ); -static JoltConVar vjolt_baumgarte_factor( "vjolt_baumgarte_factor", "0.2", FCVAR_NONE, "Baumgarte stabilization factor (how much of the position error to 'fix' in 1 update). Changing this may help with constraint stability. Requires a map restart to change.", true, 0.0f, true, 1.0f ); +static ConVar vjolt_baumgarte_factor( "vjolt_baumgarte_factor", "0.2", FCVAR_NONE, "Baumgarte stabilization factor (how much of the position error to 'fix' in 1 update). Changing this may help with constraint stability. Requires a map restart to change.", true, 0.0f, true, 1.0f ); //------------------------------------------------------------------------------------------------- diff --git a/vphysics_jolt/vphysics_jolt_inc.vpc b/vphysics_jolt/vphysics_jolt_inc.vpc index a3e12c36..8ec5143a 100644 --- a/vphysics_jolt/vphysics_jolt_inc.vpc +++ b/vphysics_jolt/vphysics_jolt_inc.vpc @@ -90,7 +90,6 @@ $Project "$PROJNAME" $File "vjolt_controller_player.cpp" $File "vjolt_controller_vehicle.cpp" $File "vjolt_controller_shadow.cpp" - $File "vjolt_convar.cpp" $File "vjolt_debugrender.cpp" $File "vjolt_environment.cpp" $File "vjolt_friction.cpp" @@ -129,7 +128,6 @@ $Project "$PROJNAME" $File "vjolt_controller_player.h" $File "vjolt_controller_vehicle.h" $File "vjolt_controller_shadow.h" - $File "vjolt_convar.h" $File "vjolt_debugrender.h" $File "vjolt_environment.h" $File "vjolt_friction.h"