From 584b64379146fe52d1038e04a19010bded8c3599 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Wed, 6 May 2015 16:01:00 -0700 Subject: [PATCH] lock entitySimulation during physics simulation --- interface/src/Application.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 5c9842b777..2c30e9f32d 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2420,15 +2420,19 @@ void Application::update(float deltaTime) { PerformanceTimer perfTimer("physics"); _myAvatar->relayDriveKeysToCharacterController(); + _entitySimulation.lock(); _physicsEngine.deleteObjects(_entitySimulation.getObjectsToDelete()); _physicsEngine.addObjects(_entitySimulation.getObjectsToAdd()); _physicsEngine.changeObjects(_entitySimulation.getObjectsToChange()); + _entitySimulation.unlock(); _physicsEngine.stepSimulation(); if (_physicsEngine.hasOutgoingChanges()) { + _entitySimulation.lock(); _entitySimulation.handleOutgoingChanges(_physicsEngine.getOutgoingChanges()); _entitySimulation.handleCollisionEvents(_physicsEngine.getCollisionEvents()); + _entitySimulation.unlock(); _physicsEngine.dumpStatsIfNecessary(); } }