History

CR

Clement committed 8 years ago

Commit b04c5bd1 parent 487a6303 files · +16 −12Browse files

Showing the changes to interface/src/Application.cpp (1 of 3 files). Show all

Unified · Split

interface/src/Application.cpp+8−8
@@ -967,7 +967,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 966 unmodified lines
967967 _entitySimulation(new PhysicalEntitySimulation()),
968968 _physicsEngine(new PhysicsEngine(Vectors::ZERO)),
969969 _entityClipboard(new EntityTree()),
970− _lastQueriedTime(usecTimestampNow()),
971970 _previousScriptLocation("LastScriptLocation", DESKTOP_LOCATION),
972971 _fieldOfView("fieldOfView", DEFAULT_FIELD_OF_VIEW_DEGREES),
973972 _hmdTabletScale("hmdTabletScale", DEFAULT_HMD_TABLET_SCALE_PERCENT),
@@ -5084,7 +5083,7 @@ void Application::reloadResourceCaches() { · 4110 unmodified lines
50845083 resetPhysicsReadyInformation();
50855084
50865085 // Query the octree to refresh everything in view
5087− _lastQueriedTime = 0;
5086+ _queryExpiry = SteadyClock::now();
50885087 _octreeQuery.incrementConnectionID();
50895088
50905089 queryOctree(NodeType::EntityServer, PacketType::EntityQuery);
@@ -5660,9 +5659,6 @@ void Application::update(float deltaTime) { · 569 unmodified lines
56605659 PROFILE_RANGE_EX(app, "QueryOctree", 0xffff0000, (uint64_t)getActiveDisplayPlugin()->presentCount());
56615660 PerformanceTimer perfTimer("queryOctree");
56625661 QMutexLocker viewLocker(&_viewMutex);
5663− quint64 sinceLastQuery = now - _lastQueriedTime;
5664− const quint64 TOO_LONG_SINCE_LAST_QUERY = 3 * USECS_PER_SECOND;
5665− bool queryIsDue = sinceLastQuery > TOO_LONG_SINCE_LAST_QUERY;
56665662
56675663 bool viewIsDifferentEnough = false;
56685664 if (_conicalViews.size() == _lastQueriedViews.size()) {
@@ -5678,14 +5674,16 @@ void Application::update(float deltaTime) { · 9 unmodified lines
56785674
56795675
56805676 // if it's been a while since our last query or the view has significantly changed then send a query, otherwise suppress it
5681− if (queryIsDue || viewIsDifferentEnough) {
5677+ static const std::chrono::seconds MIN_PERIOD_BETWEEN_QUERIES { 3 };
5678+ auto now = SteadyClock::now();
5679+ if (now > _queryExpiry || viewIsDifferentEnough) {
56825680 if (DependencyManager::get<SceneScriptingInterface>()->shouldRenderEntities()) {
56835681 queryOctree(NodeType::EntityServer, PacketType::EntityQuery);
56845682 }
56855683 queryAvatars();
56865684
56875685 _lastQueriedViews = _conicalViews;
5688− _lastQueriedTime = now;
5686+ _queryExpiry = now + MIN_PERIOD_BETWEEN_QUERIES;
56895687 }
56905688 }
56915689
@@ -6142,7 +6140,7 @@ void Application::nodeActivated(SharedNodePointer node) { · 450 unmodified lines
61426140 // If we get a new EntityServer activated, reset lastQueried time
61436141 // so we will do a proper query during update
61446142 if (node->getType() == NodeType::EntityServer) {
6145− _lastQueriedTime = 0;
6143+ _queryExpiry = SteadyClock::now();
61466144 _octreeQuery.incrementConnectionID();
61476145 }
61486146
@@ -6151,6 +6149,8 @@ void Application::nodeActivated(SharedNodePointer node) { · 2 unmodified lines
61516149 }
61526150
61536151 if (node->getType() == NodeType::AvatarMixer) {
6152+ _queryExpiry = SteadyClock::now();
6153+
61546154 // new avatar mixer, send off our identity packet on next update loop
61556155 // Reset skeletonModelUrl if the last server modified our choice.
61566156 // Override the avatar url (but not model name) here too.