unjack AvatarData locks

This commit is contained in:
Seth Alves 2015-03-18 14:11:02 -07:00
parent 1cab14064d
commit e2a104c38a

View file

@ -298,6 +298,7 @@ void PhysicsEngine::stepSimulation() {
_clock.reset(); _clock.reset();
float timeStep = btMin(dt, MAX_TIMESTEP); float timeStep = btMin(dt, MAX_TIMESTEP);
_avatarData->lockForRead();
if (_avatarData->isPhysicsEnabled()) { if (_avatarData->isPhysicsEnabled()) {
// update character controller // update character controller
glm::quat rotation = _avatarData->getOrientation(); glm::quat rotation = _avatarData->getOrientation();
@ -307,6 +308,7 @@ void PhysicsEngine::stepSimulation() {
btVector3 walkVelocity = glmToBullet(_avatarData->getVelocity()); btVector3 walkVelocity = glmToBullet(_avatarData->getVelocity());
_characterController->setVelocityForTimeInterval(walkVelocity, timeStep); _characterController->setVelocityForTimeInterval(walkVelocity, timeStep);
} }
_avatarData->unlock();
// This is step (2). // This is step (2).
int numSubsteps = _dynamicsWorld->stepSimulation(timeStep, MAX_NUM_SUBSTEPS, PHYSICS_ENGINE_FIXED_SUBSTEP); int numSubsteps = _dynamicsWorld->stepSimulation(timeStep, MAX_NUM_SUBSTEPS, PHYSICS_ENGINE_FIXED_SUBSTEP);
@ -342,7 +344,6 @@ void PhysicsEngine::stepSimulation() {
} }
unlock(); unlock();
_avatarData->unlock();
_entityTree->unlock(); _entityTree->unlock();
computeCollisionEvents(); computeCollisionEvents();