diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index ffc9b0333c..bd1a44fc76 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -3215,6 +3215,25 @@ void Application::update(float deltaTime) { updateLOD(); + if (!_physicsEnabled && _processOctreeStatsCounter > 0) { + + // process octree stats packets are sent in between full sends of a scene. + // We keep physics disabled until we've recieved a full scene and everything near the avatar in that + // scene is ready to compute its collision shape. + + if (nearbyEntitiesAreReadyForPhysics()) { + _physicsEnabled = true; + getMyAvatar()->updateMotionBehaviorFromMenu(); + } else { + auto characterController = getMyAvatar()->getCharacterController(); + if (characterController) { + // if we have a character controller, disable it here so the avatar doesn't get stuck due to + // a non-loading collision hull. + characterController->setEnabled(false); + } + } + } + { PerformanceTimer perfTimer("devices"); DeviceTracker::updateAll(); @@ -4260,22 +4279,7 @@ int Application::processOctreeStats(ReceivedMessage& message, SharedNodePointer }); }); - if (!_physicsEnabled) { - if (nearbyEntitiesAreReadyForPhysics()) { - // These stats packets are sent in between full sends of a scene. - // We keep physics disabled until we've recieved a full scene and everything near the avatar in that - // scene is ready to compute its collision shape. - _physicsEnabled = true; - getMyAvatar()->updateMotionBehaviorFromMenu(); - } else { - auto characterController = getMyAvatar()->getCharacterController(); - if (characterController) { - // if we have a character controller, disable it here so the avatar doesn't get stuck due to - // a non-loading collision hull. - characterController->setEnabled(false); - } - } - } + _processOctreeStatsCounter++; return statsMessageLength; } diff --git a/interface/src/Application.h b/interface/src/Application.h index 31c865ad90..2512bc7918 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -515,6 +515,8 @@ private: std::map> _preRenderLambdas; std::mutex _preRenderLambdasLock; + + std::atomic _processOctreeStatsCounter { 0 }; }; #endif // hifi_Application_h