Game Development Community

T3D 1.1 Final - Bullet physics World destroyed before Player - RESOLVED (THREED-2003)

by Jason Eubank · in Torque 3D Professional · 06/19/2011 (7:09 pm) · 3 replies

Thread Body:

Build: 1.1 Final
Platform: Windows Vista 7 64 bit
Target: Visual Studio

Issues: When exiting a mission with Bullet physics enabled BtWorld is destroyed before BtPlayer; crash is in BtPlayer::_releaseController() line 39 (mWorld->getDynamicsWorld()->removeCollisionObject( mGhostObject );)

mWorld->getDynamicsWorld() is returning a bad pointer.

Steps to Repeat:
1. Using a "Full" project template, compile with includeModule('bullet') in the config
2. Run the game and load a mission
3. Exit the game
4. You will crash in BtPlayer::_releaseController()

Suggested Fix: change the order of calls in disconnect() in scripts/client/serverConnection.cs:

function disconnect()
{
   // We need to stop the client side simulation
   // else physics resources will not cleanup properly.
   physicsStopSimulation( "client" );

   disconnectedCleanup();

   // Delete the connection if it's still there.
   if (isObject(ServerConnection))
      ServerConnection.delete();

   // Call destroyServer in case we're hosting
   destroyServer();
}

should be:

function disconnect()
{
   // We need to stop the client side simulation
   // else physics resources will not cleanup properly.
   physicsStopSimulation( "client" );

   // Delete the connection if it's still there.
   if (isObject(ServerConnection))
      ServerConnection.delete();
      
   disconnectedCleanup(); // don't call until the connection is deleted

   // Call destroyServer in case we're hosting
   destroyServer();
}

About the author

Programmer at Certain Affinity. Titles shipped: Age of Booty (XBLA), Left 4 Dead, Call of Duty: World At War, Halo Waypoint, CoD: Black Ops, Halo: Reach Defiant Map Pack, Halo: Combat Evolved Anniversary