parent
50cef39716
commit
9e0d54616f
|
@ -771,6 +771,10 @@ void JoltPhysicsEnvironment::Simulate( float deltaTime )
|
||||||
// doing the simulation...
|
// doing the simulation...
|
||||||
m_ContactListener.PostSimulationFrame();
|
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
|
// Run pre-simulation controllers
|
||||||
for ( IJoltPhysicsController *pController : m_pPhysicsControllers )
|
for ( IJoltPhysicsController *pController : m_pPhysicsControllers )
|
||||||
pController->OnPreSimulate( deltaTime );
|
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
|
// If the delete queue is disabled, we only added to it during the simulation
|
||||||
// ie. callbacks etc. So flush that now.
|
// ie. callbacks etc. So flush that now.
|
||||||
if ( !m_bEnableDeleteQueue )
|
if ( !m_bEnableDeleteQueue ) {
|
||||||
DeleteDeadObjects();
|
DeleteDeadObjects();
|
||||||
|
DeleteDeadObjects(true); // Also delete all bodies
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef JPH_DEBUG_RENDERER
|
#ifdef JPH_DEBUG_RENDERER
|
||||||
JoltPhysicsDebugRenderer::GetInstance().RenderPhysicsSystem( m_PhysicsSystem );
|
JoltPhysicsDebugRenderer::GetInstance().RenderPhysicsSystem( m_PhysicsSystem );
|
||||||
|
@ -1430,19 +1436,21 @@ void JoltPhysicsEnvironment::RemoveBodyAndDeleteObject( JoltPhysicsObject *pObje
|
||||||
delete pObject;
|
delete pObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
void JoltPhysicsEnvironment::DeleteDeadObjects()
|
void JoltPhysicsEnvironment::DeleteDeadObjects( bool delBodies )
|
||||||
{
|
{
|
||||||
for ( JoltPhysicsObject *pObject : m_pDeadObjects )
|
if (delBodies) {
|
||||||
RemoveBodyAndDeleteObject( pObject );
|
for ( JoltPhysicsObject *pObject : m_pDeadObjects )
|
||||||
m_pDeadObjects.clear();
|
RemoveBodyAndDeleteObject( pObject );
|
||||||
|
m_pDeadObjects.clear();
|
||||||
|
} else {
|
||||||
|
for ( JoltPhysicsConstraint *pConstraint : m_pDeadConstraints )
|
||||||
|
delete pConstraint;
|
||||||
|
m_pDeadConstraints.clear();
|
||||||
|
|
||||||
for ( JoltPhysicsConstraint *pConstraint : m_pDeadConstraints )
|
for ( CPhysCollide *pCollide : m_pDeadObjectCollides )
|
||||||
delete pConstraint;
|
JoltPhysicsCollision::GetInstance().DestroyCollide( pCollide );
|
||||||
m_pDeadConstraints.clear();
|
m_pDeadObjectCollides.clear();
|
||||||
|
}
|
||||||
for ( CPhysCollide *pCollide : m_pDeadObjectCollides )
|
|
||||||
JoltPhysicsCollision::GetInstance().DestroyCollide( pCollide );
|
|
||||||
m_pDeadObjectCollides.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -172,7 +172,7 @@ public:
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void RemoveBodyAndDeleteObject( JoltPhysicsObject* pObject );
|
void RemoveBodyAndDeleteObject( JoltPhysicsObject* pObject );
|
||||||
void DeleteDeadObjects();
|
void DeleteDeadObjects(bool delBodies = false);
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void AddPhysicsSaveRestorePointer( uintp oldPtr, T* newPtr );
|
void AddPhysicsSaveRestorePointer( uintp oldPtr, T* newPtr );
|
||||||
|
|
Loading…
Reference in New Issue