lock entitySimulation during physics simulation

This commit is contained in:
Andrew Meadows 2015-05-06 16:01:00 -07:00
parent 326d17072e
commit 584b643791

View file

@ -2420,15 +2420,19 @@ void Application::update(float deltaTime) {
PerformanceTimer perfTimer("physics"); PerformanceTimer perfTimer("physics");
_myAvatar->relayDriveKeysToCharacterController(); _myAvatar->relayDriveKeysToCharacterController();
_entitySimulation.lock();
_physicsEngine.deleteObjects(_entitySimulation.getObjectsToDelete()); _physicsEngine.deleteObjects(_entitySimulation.getObjectsToDelete());
_physicsEngine.addObjects(_entitySimulation.getObjectsToAdd()); _physicsEngine.addObjects(_entitySimulation.getObjectsToAdd());
_physicsEngine.changeObjects(_entitySimulation.getObjectsToChange()); _physicsEngine.changeObjects(_entitySimulation.getObjectsToChange());
_entitySimulation.unlock();
_physicsEngine.stepSimulation(); _physicsEngine.stepSimulation();
if (_physicsEngine.hasOutgoingChanges()) { if (_physicsEngine.hasOutgoingChanges()) {
_entitySimulation.lock();
_entitySimulation.handleOutgoingChanges(_physicsEngine.getOutgoingChanges()); _entitySimulation.handleOutgoingChanges(_physicsEngine.getOutgoingChanges());
_entitySimulation.handleCollisionEvents(_physicsEngine.getCollisionEvents()); _entitySimulation.handleCollisionEvents(_physicsEngine.getCollisionEvents());
_entitySimulation.unlock();
_physicsEngine.dumpStatsIfNecessary(); _physicsEngine.dumpStatsIfNecessary();
} }
} }