diff --git a/vphysics_jolt/compat/branch_overrides.h b/vphysics_jolt/compat/branch_overrides.h index a62b370e..46580e35 100644 --- a/vphysics_jolt/compat/branch_overrides.h +++ b/vphysics_jolt/compat/branch_overrides.h @@ -1,7 +1,15 @@ #pragma once -#if defined( GAME_CSGO ) || defined( GAME_DESOLATION ) || defined( GAME_CHAOS ) +#if defined( GAME_STRATA ) +#define override_strata override +#define override_not_strata +#else +#define override_strata +#define override_not_strata override +#endif + +#if defined( GAME_CSGO ) || defined( GAME_DESOLATION ) || defined( GAME_STRATA ) #define GAME_CSGO_OR_NEWER #define override_csgo override #define override_not_csgo @@ -19,7 +27,7 @@ #define override_not_gmod override #endif -#if defined( GAME_CSGO ) || defined( GAME_DESOLATION ) || defined( GAME_CHAOS ) || defined( GAME_PORTAL2 ) +#if defined( GAME_CSGO ) || defined( GAME_DESOLATION ) || defined( GAME_STRATA ) || defined( GAME_PORTAL2 ) #define GAME_PORTAL2_OR_NEWER #define override_portal2 override #define override_not_portal2 @@ -28,7 +36,7 @@ #define override_not_portal2 override #endif -#if defined( GAME_CSGO ) || defined( GAME_DESOLATION ) || defined( GAME_CHAOS ) || defined( GAME_PORTAL2 ) || defined( GAME_L4D2 ) +#if defined( GAME_CSGO ) || defined( GAME_DESOLATION ) || defined( GAME_STRATA ) || defined( GAME_PORTAL2 ) || defined( GAME_L4D2 ) #define GAME_L4D2_OR_NEWER #define override_l4d2 override #define override_not_l4d2 @@ -37,7 +45,7 @@ #define override_not_l4d2 override #endif -#if defined( GAME_CSGO ) || defined( GAME_DESOLATION ) || defined( GAME_CHAOS ) || defined( GAME_PORTAL2 ) || defined( GAME_L4D2 ) || defined( GAME_ASW ) +#if defined( GAME_CSGO ) || defined( GAME_DESOLATION ) || defined( GAME_STRATA ) || defined( GAME_PORTAL2 ) || defined( GAME_L4D2 ) || defined( GAME_ASW ) #define GAME_ASW_OR_NEWER #define override_asw override #define override_not_asw diff --git a/vphysics_jolt/vjolt_object.cpp b/vphysics_jolt/vjolt_object.cpp index 5637c5a9..4463a6eb 100644 --- a/vphysics_jolt/vjolt_object.cpp +++ b/vphysics_jolt/vjolt_object.cpp @@ -62,6 +62,9 @@ JoltPhysicsObject::JoltPhysicsObject( JPH::Body *pBody, JoltPhysicsEnvironment * JoltPhysicsObject::~JoltPhysicsObject() { + if ( m_pDestroyCallback ) + m_pDestroyCallback( m_pDestroyCallbackData, this ); + RemoveShadowController(); // Josh: @@ -1042,6 +1045,14 @@ uint32 JoltPhysicsObject::GetCollisionHints() const //------------------------------------------------------------------------------------------------- +void JoltPhysicsObject::SetDestroyCallback( void(*pCallback)( void*, IPhysicsObject* ), void* pData ) +{ + m_pDestroyCallback = pCallback; + m_pDestroyCallbackData = pData; +} + +//------------------------------------------------------------------------------------------------- + IPredictedPhysicsObject *JoltPhysicsObject::GetPredictedInterface() const { Log_Stub( LOG_VJolt ); diff --git a/vphysics_jolt/vjolt_object.h b/vphysics_jolt/vjolt_object.h index 2da30058..25ee4cc7 100644 --- a/vphysics_jolt/vjolt_object.h +++ b/vphysics_jolt/vjolt_object.h @@ -154,6 +154,8 @@ class JoltPhysicsObject final : public IPhysicsObjectInterface void SetErrorDelta_Position( const Vector& vPosition ) override_csgo {} void SetErrorDelta_Velocity( const Vector& vVelocity ) override_csgo {} + void SetDestroyCallback( void(*pCallback)( void*, IPhysicsObject* ), void* pData ) override_strata; + public: JoltPhysicsEnvironment *GetEnvironment() { return m_pEnvironment; } @@ -275,6 +277,9 @@ class JoltPhysicsObject final : public IPhysicsObjectInterface JPH::Body *m_pBody = nullptr; // Underlying Jolt body JoltPhysicsEnvironment *m_pEnvironment = nullptr; // Physics environment this body belongs to JPH::PhysicsSystem *m_pPhysicsSystem = nullptr; // Physics system this body belongs to + + void (*m_pDestroyCallback)( void*, IPhysicsObject* ) = nullptr; + void *m_pDestroyCallbackData = nullptr; }; // Josh: This doesn't handle mass change and is kind of a hack and sliightly wrong.