From 015498a6e0281bd2ef9d43161745feb19b6aea46 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Fri, 26 Jun 2015 07:20:22 -0700 Subject: [PATCH] move function up so this builds in non-debug mode --- libraries/physics/src/EntityMotionState.cpp | 55 +++++++++++---------- 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/libraries/physics/src/EntityMotionState.cpp b/libraries/physics/src/EntityMotionState.cpp index 0dad876349..5e9591a031 100644 --- a/libraries/physics/src/EntityMotionState.cpp +++ b/libraries/physics/src/EntityMotionState.cpp @@ -27,6 +27,34 @@ static const float ACCELERATION_EQUIVALENT_EPSILON_RATIO = 0.1f; static const quint8 STEPS_TO_DECIDE_BALLISTIC = 4; +#ifdef WANT_DEBUG_ENTITY_TREE_LOCKS +bool EntityMotionState::entityTreeIsLocked() const { + EntityTreeElement* element = _entity ? _entity->getElement() : nullptr; + EntityTree* tree = element ? element->getTree() : nullptr; + if (tree) { + bool readSuccess = tree->tryLockForRead(); + if (readSuccess) { + tree->unlock(); + } + bool writeSuccess = tree->tryLockForWrite(); + if (writeSuccess) { + tree->unlock(); + } + if (readSuccess && writeSuccess) { + return false; // if we can take either kind of lock, there was no tree lock. + } + return true; // either read or write failed, so there is some lock in place. + } else { + return true; + } +} +#else +bool entityTreeIsLocked() { + return true; +} +#endif + + EntityMotionState::EntityMotionState(btCollisionShape* shape, EntityItemPointer entity) : ObjectMotionState(shape), _entity(entity), @@ -55,33 +83,6 @@ EntityMotionState::~EntityMotionState() { assert(!_entity); } -#ifdef WANT_DEBUG_ENTITY_TREE_LOCKS -bool EntityMotionState::entityTreeIsLocked() const { - EntityTreeElement* element = _entity ? _entity->getElement() : nullptr; - EntityTree* tree = element ? element->getTree() : nullptr; - if (tree) { - bool readSuccess = tree->tryLockForRead(); - if (readSuccess) { - tree->unlock(); - } - bool writeSuccess = tree->tryLockForWrite(); - if (writeSuccess) { - tree->unlock(); - } - if (readSuccess && writeSuccess) { - return false; // if we can take either kind of lock, there was no tree lock. - } - return true; // either read or write failed, so there is some lock in place. - } else { - return true; - } -} -#else -bool entityTreeIsLocked() { - return true; -} -#endif - void EntityMotionState::updateServerPhysicsVariables() { assert(entityTreeIsLocked()); _serverPosition = _entity->getPosition();