diff --git a/assignment-client/src/octree/OctreeSendThread.cpp b/assignment-client/src/octree/OctreeSendThread.cpp index 4e61793910..cb2d2931ef 100644 --- a/assignment-client/src/octree/OctreeSendThread.cpp +++ b/assignment-client/src/octree/OctreeSendThread.cpp @@ -290,7 +290,7 @@ int OctreeSendThread::packetDistributor(OctreeQueryNode* nodeData, bool viewFrus } // calculate max number of packets that can be sent during this interval - int clientMaxPacketsPerInterval = std::max(1, (nodeData->getMaxOctreePacketsPerSecond() / INTERVALS_PER_SECOND)); + int clientMaxPacketsPerInterval = std::max(1, (nodeData->getMaxQueryPacketsPerSecond() / INTERVALS_PER_SECOND)); int maxPacketsPerInterval = std::min(clientMaxPacketsPerInterval, _myServer->getPacketsPerClientPerInterval()); int truePacketsSent = 0; diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 05dc2baf84..088b2ddf96 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -183,6 +183,8 @@ const QString CHECK_VERSION_URL = "https://highfidelity.com/latestVersion.xml"; const QString SKIP_FILENAME = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/hifi.skipversion"; const QString DEFAULT_SCRIPTS_JS_URL = "http://s3.amazonaws.com/hifi-public/scripts/defaultScripts.js"; +Setting::Handle maxOctreePacketsPerSecond("maxOctreePPS", DEFAULT_MAX_OCTREE_PPS); + #ifdef Q_OS_WIN class MyNativeEventFilter : public QAbstractNativeEventFilter { @@ -333,7 +335,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : _isVSyncOn(true), _aboutToQuit(false), _notifiedPacketVersionMismatchThisDomain(false), - _domainConnectionRefusals(QList()) + _domainConnectionRefusals(QList()), + _maxOctreePPS(maxOctreePacketsPerSecond.get()) { #ifdef Q_OS_WIN installNativeEventFilter(&MyNativeEventFilter::getInstance()); @@ -2683,7 +2686,7 @@ void Application::queryOctree(NodeType_t serverType, PacketType packetType, Node int perServerPPS = 0; const int SMALL_BUDGET = 10; int perUnknownServer = SMALL_BUDGET; - int totalPPS = _octreeQuery.getMaxOctreePacketsPerSecond(); + int totalPPS = getMaxOctreePacketsPerSecond(); // determine PPS based on number of servers if (inViewServers >= 1) { @@ -2746,7 +2749,7 @@ void Application::queryOctree(NodeType_t serverType, PacketType packetType, Node } if (inView) { - _octreeQuery.setMaxOctreePacketsPerSecond(perServerPPS); + _octreeQuery.setMaxQueryPacketsPerSecond(perServerPPS); } else if (unknownView) { if (wantExtraDebugging) { qCDebug(interfaceapp) << "no known jurisdiction for node " << *node << ", give it budget of " @@ -2770,9 +2773,9 @@ void Application::queryOctree(NodeType_t serverType, PacketType packetType, Node qCDebug(interfaceapp) << "Using regular camera position for node" << *node; } } - _octreeQuery.setMaxOctreePacketsPerSecond(perUnknownServer); + _octreeQuery.setMaxQueryPacketsPerSecond(perUnknownServer); } else { - _octreeQuery.setMaxOctreePacketsPerSecond(0); + _octreeQuery.setMaxQueryPacketsPerSecond(0); } // set up the packet for sending... unsigned char* endOfQueryPacket = queryPacket; @@ -4648,3 +4651,14 @@ PickRay Application::computePickRay() const { bool Application::hasFocus() const { return _glWidget->hasFocus(); } + +void Application::setMaxOctreePacketsPerSecond(int maxOctreePPS) { + if (maxOctreePPS != _maxOctreePPS) { + _maxOctreePPS = maxOctreePPS; + maxOctreePacketsPerSecond.set(_maxOctreePPS); + } +} + +int Application::getMaxOctreePacketsPerSecond() { + return _maxOctreePPS; +} diff --git a/interface/src/Application.h b/interface/src/Application.h index 5a3756e768..09edaba341 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -344,6 +344,9 @@ public: bool canAcceptURL(const QString& url); bool acceptURL(const QString& url); + void setMaxOctreePacketsPerSecond(int maxOctreePPS); + int getMaxOctreePacketsPerSecond(); + signals: /// Fired when we're simulating; allows external parties to hook in. @@ -662,6 +665,8 @@ private: QList _domainConnectionRefusals; glm::uvec2 _renderResolution; + + int _maxOctreePPS = DEFAULT_MAX_OCTREE_PPS; }; #endif // hifi_Application_h diff --git a/interface/src/ui/PreferencesDialog.cpp b/interface/src/ui/PreferencesDialog.cpp index ac436cbb10..4622ffd7ed 100644 --- a/interface/src/ui/PreferencesDialog.cpp +++ b/interface/src/ui/PreferencesDialog.cpp @@ -168,7 +168,7 @@ void PreferencesDialog::loadPreferences() { ui.avatarScaleSpin->setValue(myAvatar->getScale()); - ui.maxOctreePPSSpin->setValue(qApp->getOctreeQuery().getMaxOctreePacketsPerSecond()); + ui.maxOctreePPSSpin->setValue(qApp->getMaxOctreePacketsPerSecond()); ui.oculusUIAngularSizeSpin->setValue(qApp->getApplicationOverlay().getHmdUIAngularSize()); @@ -228,7 +228,7 @@ void PreferencesDialog::savePreferences() { faceshift->setHostname(ui.faceshiftHostnameEdit->text()); - qApp->getOctreeQuery().setMaxOctreePacketsPerSecond(ui.maxOctreePPSSpin->value()); + qApp->setMaxOctreePacketsPerSecond(ui.maxOctreePPSSpin->value()); qApp->getApplicationOverlay().setHmdUIAngularSize(ui.oculusUIAngularSizeSpin->value()); diff --git a/libraries/octree/src/OctreeHeadlessViewer.cpp b/libraries/octree/src/OctreeHeadlessViewer.cpp index 63cd6d39a2..0da694833a 100644 --- a/libraries/octree/src/OctreeHeadlessViewer.cpp +++ b/libraries/octree/src/OctreeHeadlessViewer.cpp @@ -186,7 +186,7 @@ void OctreeHeadlessViewer::queryOctree() { } if (inView) { - _octreeQuery.setMaxOctreePacketsPerSecond(perServerPPS); + _octreeQuery.setMaxQueryPacketsPerSecond(perServerPPS); if (wantExtraDebugging) { qCDebug(octree) << "inView for node " << *node << ", give it budget of " << perServerPPS; } @@ -213,9 +213,9 @@ void OctreeHeadlessViewer::queryOctree() { qCDebug(octree) << "Using regular camera position for node" << *node; } } - _octreeQuery.setMaxOctreePacketsPerSecond(perUnknownServer); + _octreeQuery.setMaxQueryPacketsPerSecond(perUnknownServer); } else { - _octreeQuery.setMaxOctreePacketsPerSecond(0); + _octreeQuery.setMaxQueryPacketsPerSecond(0); } // set up the packet for sending... unsigned char* endOfQueryPacket = queryPacket; diff --git a/libraries/octree/src/OctreeQuery.cpp b/libraries/octree/src/OctreeQuery.cpp index 6ca55fc4cc..08197a587e 100644 --- a/libraries/octree/src/OctreeQuery.cpp +++ b/libraries/octree/src/OctreeQuery.cpp @@ -11,25 +11,15 @@ #include #include -#include #include "OctreeConstants.h" #include "OctreeQuery.h" -Setting::Handle maxOctreePacketsPerSecond("maxOctreePPS", DEFAULT_MAX_OCTREE_PPS); OctreeQuery::OctreeQuery() { - _maxOctreePPS = maxOctreePacketsPerSecond.get(); + _maxQueryPPS = DEFAULT_MAX_OCTREE_PPS; } -void OctreeQuery::setMaxOctreePacketsPerSecond(int maxOctreePPS) { - if (maxOctreePPS != _maxOctreePPS) { - _maxOctreePPS = maxOctreePPS; - maxOctreePacketsPerSecond.set(_maxOctreePPS); - } -} - - int OctreeQuery::getBroadcastData(unsigned char* destinationBuffer) { unsigned char* bufferStart = destinationBuffer; @@ -59,8 +49,8 @@ int OctreeQuery::getBroadcastData(unsigned char* destinationBuffer) { *destinationBuffer++ = bitItems; // desired Max Octree PPS - memcpy(destinationBuffer, &_maxOctreePPS, sizeof(_maxOctreePPS)); - destinationBuffer += sizeof(_maxOctreePPS); + memcpy(destinationBuffer, &_maxQueryPPS, sizeof(_maxQueryPPS)); + destinationBuffer += sizeof(_maxQueryPPS); // desired voxelSizeScale memcpy(destinationBuffer, &_octreeElementSizeScale, sizeof(_octreeElementSizeScale)); @@ -103,8 +93,8 @@ int OctreeQuery::parseData(const QByteArray& packet) { _wantCompression = oneAtBit(bitItems, WANT_COMPRESSION); // desired Max Octree PPS - memcpy(&_maxOctreePPS, sourceBuffer, sizeof(_maxOctreePPS)); - sourceBuffer += sizeof(_maxOctreePPS); + memcpy(&_maxQueryPPS, sourceBuffer, sizeof(_maxQueryPPS)); + sourceBuffer += sizeof(_maxQueryPPS); // desired _octreeElementSizeScale memcpy(&_octreeElementSizeScale, sourceBuffer, sizeof(_octreeElementSizeScale)); diff --git a/libraries/octree/src/OctreeQuery.h b/libraries/octree/src/OctreeQuery.h index 1fefabdf68..3c204ff938 100644 --- a/libraries/octree/src/OctreeQuery.h +++ b/libraries/octree/src/OctreeQuery.h @@ -76,7 +76,7 @@ public: bool getWantLowResMoving() const { return _wantLowResMoving; } bool getWantOcclusionCulling() const { return _wantOcclusionCulling; } bool getWantCompression() const { return _wantCompression; } - int getMaxOctreePacketsPerSecond() const { return _maxOctreePPS; } + int getMaxQueryPacketsPerSecond() const { return _maxQueryPPS; } float getOctreeSizeScale() const { return _octreeElementSizeScale; } int getBoundaryLevelAdjust() const { return _boundaryLevelAdjust; } @@ -86,7 +86,7 @@ public slots: void setWantDelta(bool wantDelta) { _wantDelta = wantDelta; } void setWantOcclusionCulling(bool wantOcclusionCulling) { _wantOcclusionCulling = wantOcclusionCulling; } void setWantCompression(bool wantCompression) { _wantCompression = wantCompression; } - void setMaxOctreePacketsPerSecond(int maxOctreePPS); + void setMaxQueryPacketsPerSecond(int maxQueryPPS) { _maxQueryPPS = maxQueryPPS; } void setOctreeSizeScale(float octreeSizeScale) { _octreeElementSizeScale = octreeSizeScale; } void setBoundaryLevelAdjust(int boundaryLevelAdjust) { _boundaryLevelAdjust = boundaryLevelAdjust; } @@ -106,7 +106,7 @@ protected: bool _wantLowResMoving = true; bool _wantOcclusionCulling = false; bool _wantCompression = false; - int _maxOctreePPS = DEFAULT_MAX_OCTREE_PPS; + int _maxQueryPPS = DEFAULT_MAX_OCTREE_PPS; float _octreeElementSizeScale = DEFAULT_OCTREE_SIZE_SCALE; /// used for LOD calculations int _boundaryLevelAdjust = 0; /// used for LOD calculations