Merge 6493adbcc3
into 559217d991
This commit is contained in:
commit
102aad7d3f
|
@ -771,6 +771,10 @@ void JoltPhysicsEnvironment::Simulate( float deltaTime )
|
|||
// doing the simulation...
|
||||
m_ContactListener.PostSimulationFrame();
|
||||
|
||||
// RaphaelIT7: We need to delete all dead objects after m_ContactListener.PostSimulationFrame, or else Jolt freaks out for some reason.
|
||||
// This also needs to be before pController->OnPreSimulate or else we get some crashes.
|
||||
DeleteDeadObjects( true );
|
||||
|
||||
// Run pre-simulation controllers
|
||||
for ( IJoltPhysicsController *pController : m_pPhysicsControllers )
|
||||
pController->OnPreSimulate( deltaTime );
|
||||
|
@ -818,8 +822,10 @@ void JoltPhysicsEnvironment::Simulate( float deltaTime )
|
|||
|
||||
// If the delete queue is disabled, we only added to it during the simulation
|
||||
// ie. callbacks etc. So flush that now.
|
||||
if ( !m_bEnableDeleteQueue )
|
||||
if ( !m_bEnableDeleteQueue ) {
|
||||
DeleteDeadObjects();
|
||||
DeleteDeadObjects( true ); // Also delete all bodies
|
||||
}
|
||||
|
||||
#ifdef JPH_DEBUG_RENDERER
|
||||
JoltPhysicsDebugRenderer::GetInstance().RenderPhysicsSystem( m_PhysicsSystem );
|
||||
|
@ -1430,19 +1436,21 @@ void JoltPhysicsEnvironment::RemoveBodyAndDeleteObject( JoltPhysicsObject *pObje
|
|||
delete pObject;
|
||||
}
|
||||
|
||||
void JoltPhysicsEnvironment::DeleteDeadObjects()
|
||||
void JoltPhysicsEnvironment::DeleteDeadObjects( bool delBodies )
|
||||
{
|
||||
for ( JoltPhysicsObject *pObject : m_pDeadObjects )
|
||||
RemoveBodyAndDeleteObject( pObject );
|
||||
m_pDeadObjects.clear();
|
||||
if ( delBodies ) {
|
||||
for ( JoltPhysicsObject *pObject : m_pDeadObjects )
|
||||
RemoveBodyAndDeleteObject( pObject );
|
||||
m_pDeadObjects.clear();
|
||||
} else {
|
||||
for ( JoltPhysicsConstraint *pConstraint : m_pDeadConstraints )
|
||||
delete pConstraint;
|
||||
m_pDeadConstraints.clear();
|
||||
|
||||
for ( JoltPhysicsConstraint *pConstraint : m_pDeadConstraints )
|
||||
delete pConstraint;
|
||||
m_pDeadConstraints.clear();
|
||||
|
||||
for ( CPhysCollide *pCollide : m_pDeadObjectCollides )
|
||||
JoltPhysicsCollision::GetInstance().DestroyCollide( pCollide );
|
||||
m_pDeadObjectCollides.clear();
|
||||
for ( CPhysCollide *pCollide : m_pDeadObjectCollides )
|
||||
JoltPhysicsCollision::GetInstance().DestroyCollide( pCollide );
|
||||
m_pDeadObjectCollides.clear();
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -172,7 +172,7 @@ public:
|
|||
private:
|
||||
|
||||
void RemoveBodyAndDeleteObject( JoltPhysicsObject* pObject );
|
||||
void DeleteDeadObjects();
|
||||
void DeleteDeadObjects( bool delBodies = false );
|
||||
|
||||
template <typename T>
|
||||
void AddPhysicsSaveRestorePointer( uintp oldPtr, T* newPtr );
|
||||
|
|
Loading…
Reference in New Issue