Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions game/shared/physics_shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -500,10 +500,7 @@ void PhysDestroyObject( IPhysicsObject *pObject, CBaseEntity *pEntity )
g_EntityCollisionHash->RemoveAllPairsForObject( pEntity );
}

if ( physenv )
{
physenv->DestroyObject( pObject );
}
DestroyPhysicsObject( pObject );
}

static void AddSurfacepropFile( const char *pFileName, IPhysicsSurfaceProps *pProps, IFileSystem *pFileSystem )
Expand Down
11 changes: 11 additions & 0 deletions public/vphysics_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -863,8 +863,19 @@ abstract_class IPhysicsObject
// dumps info about the object to Msg()
virtual void OutputDebugInfo() const = 0;

// returns the buoyancy of the object.
// newly added by Valve in new builds since it was requested by Rubat to solve https://github.com/Facepunch/garrysmod-issues/issues/5696
virtual float GetBuoyancyRatio( void ) const = 0;

// returns the environment this object belongs to
virtual IPhysicsEnvironment *GetEnvironment( void ) const = 0;
};

// Helper function - destroys the given object using the right environment
static inline void DestroyPhysicsObject( IPhysicsObject* pObject )
{
pObject->GetEnvironment()->DestroyObject( pObject );
}

abstract_class IPhysicsSpring
{
Expand Down
6 changes: 6 additions & 0 deletions vphysics/physics_object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1454,6 +1454,12 @@ void CPhysicsObject::OutputDebugInfo() const
}
}

IPhysicsEnvironment *CPhysicsObject::GetEnvironment() const
{
// Same as GetVPhysicsEnvironment but this function is exposed for the game dlls
return (CPhysicsEnvironment *) (m_pObject->get_environment()->client_data);
}

bool CPhysicsObject::IsAttachedToConstraint( bool bExternalOnly ) const
{
if ( m_pObject )
Expand Down
5 changes: 4 additions & 1 deletion vphysics/physics_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,10 @@ class CPhysicsObject : public IPhysicsObject

void OutputDebugInfo() const override;

[[nodiscard]] float GetBuoyancyRatio( void ) const override { return m_buoyancyRatio; }

[[nodiscard]] IPhysicsEnvironment *GetEnvironment() const override;

// local functions
[[nodiscard]] inline IVP_Real_Object *GetObject( void ) const { return m_pObject; }
// dimhotepus: int -> unsigned short.
Expand All @@ -202,7 +206,6 @@ class CPhysicsObject : public IPhysicsObject

[[nodiscard]] inline intp GetActiveIndex( void ) const { return m_activeIndex; }
inline void SetActiveIndex( intp index ) { m_activeIndex = index; }
[[nodiscard]] inline float GetBuoyancyRatio( void ) const { return m_buoyancyRatio; }
// returns true if the mass center is set to the default for the collision model
[[nodiscard]] bool IsMassCenterAtDefault() const;

Expand Down