From cc791dd3112d9f102be0b152fd2be49fd0d03eb8 Mon Sep 17 00:00:00 2001 From: RaphaelIT7 Date: Sun, 1 Oct 2023 06:25:00 +0200 Subject: [PATCH] Small bug fixes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [#] Fixed some engine traces failing.  (some traces the engine uses to determent if you can unduck failed) [#] Fixed CheckCollision checking collisions even if collisions are disabled(IsCollisionEnabled = false) [#] JoltPhysicsObject::GetName() now returns a proper name instead of "NoName" In Gmod If you used tostring(Entity(1):GetPhysicsObject()) it returned NoName instead of player_stand or player_crouch. --- vphysics_jolt/vjolt_collide_trace.cpp | 7 ++++--- vphysics_jolt/vjolt_controller_player.cpp | 2 ++ vphysics_jolt/vjolt_object.cpp | 4 ++-- vphysics_jolt/vjolt_object.h | 1 + 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/vphysics_jolt/vjolt_collide_trace.cpp b/vphysics_jolt/vjolt_collide_trace.cpp index da6138c..efd0e36 100644 --- a/vphysics_jolt/vjolt_collide_trace.cpp +++ b/vphysics_jolt/vjolt_collide_trace.cpp @@ -38,7 +38,8 @@ static ConVar vjolt_trace_debug_collidebox( "vjolt_trace_debug_collidebox", "0", // 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 ConVar vjolt_trace_portal_hack( "vjolt_trace_portal_hack", "0", FCVAR_NONE ); +// RaphaelIT7: We this needs to always be enabled because else the traces the engine uses to determent if you can unduck fail. +// static ConVar vjolt_trace_portal_hack( "vjolt_trace_portal_hack", "0", FCVAR_NONE ); //------------------------------------------------------------------------------------------------- // @@ -492,8 +493,8 @@ static void CastBoxVsShape( const Ray_t &ray, uint32 contentsMask, IConvexInfo * //settings.mBackFaceModeTriangles = JPH::EBackFaceMode::CollideWithBackFaces; // Josh: Had to re-enable CollideWithBackFaces to allow triggers for the Portal Environment to work. // Come back here if we start getting stuck on things again... - if ( vjolt_trace_portal_hack.GetBool() ) - settings.mBackFaceModeConvex = JPH::EBackFaceMode::CollideWithBackFaces; + // if ( vjolt_trace_portal_hack.GetBool() ) + settings.mBackFaceModeConvex = JPH::EBackFaceMode::CollideWithBackFaces; //settings.mCollisionTolerance = kCollisionTolerance; settings.mUseShrunkenShapeAndConvexRadius = true; settings.mReturnDeepestPoint = true; diff --git a/vphysics_jolt/vjolt_controller_player.cpp b/vphysics_jolt/vjolt_controller_player.cpp index 1a11e1b..6fd2409 100644 --- a/vphysics_jolt/vjolt_controller_player.cpp +++ b/vphysics_jolt/vjolt_controller_player.cpp @@ -157,6 +157,8 @@ bool JoltPhysicsPlayerController::WasFrozen() static void CheckCollision( JoltPhysicsObject *pObject, JPH::CollideShapeCollector &ioCollector, JPH::BodyFilter &ioFilter ) { + if (!pObject->IsCollisionEnabled()) { return; } // If we have no collisions, we have nothing to check. + JPH::PhysicsSystem *pSystem = pObject->GetEnvironment()->GetPhysicsSystem(); // TODO(Josh): Make a PLAYER ONLY layer that will only collide with MOVING ONLY annd diff --git a/vphysics_jolt/vjolt_object.cpp b/vphysics_jolt/vjolt_object.cpp index 784e1f0..cf21dd1 100644 --- a/vphysics_jolt/vjolt_object.cpp +++ b/vphysics_jolt/vjolt_object.cpp @@ -31,6 +31,7 @@ JoltPhysicsObject::JoltPhysicsObject( JPH::Body *pBody, JoltPhysicsEnvironment * , m_pGameData( pParams->pGameData ) , m_materialIndex( Max( nMaterialIndex, 0 ) ) // Sometimes we get passed -1. , m_flVolume( pParams->volume ) + , m_pName( pParams->pName ) { // Josh: // Assert that m_pGameData is the first element, some games @@ -916,8 +917,7 @@ const CPhysCollide *JoltPhysicsObject::GetCollide() const const char *JoltPhysicsObject::GetName() const { - // Slart: Jolt used to store debug names in JPH::Body, but it was removed. So now everybody's NoName. - return "NoName"; + return m_pName; } //------------------------------------------------------------------------------------------------- diff --git a/vphysics_jolt/vjolt_object.h b/vphysics_jolt/vjolt_object.h index aeeab42..2da3005 100644 --- a/vphysics_jolt/vjolt_object.h +++ b/vphysics_jolt/vjolt_object.h @@ -239,6 +239,7 @@ private: // remain un-named offset by the vtable to get to this // instead of calling GetGameData(). void *m_pGameData = nullptr; + const char *m_pName = "NoName"; uint16 m_gameFlags = 0; uint16 m_gameIndex = 0;