Skip to content

Commit 4f36327

Browse files
committed
Fix crash with physics springs being removed
1 parent 60ea72c commit 4f36327

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

vphysics_jolt/vjolt_environment.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -585,8 +585,11 @@ void JoltPhysicsSpring::OnJoltPhysicsObjectDestroyed( JoltPhysicsObject *pObject
585585

586586
// Raphael: As soon as one of the physics objects / bodies get destroyed,
587587
// we need to remove the constraint or else it will crash on the next simulation.
588-
m_pPhysicsSystem->RemoveConstraint( m_pConstraint );
589-
m_pConstraint = nullptr;
588+
if ( m_pConstraint )
589+
{
590+
m_pPhysicsSystem->RemoveConstraint( m_pConstraint );
591+
m_pConstraint = nullptr;
592+
}
590593
}
591594

592595
//-------------------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)