From 70f7329a7e804430c3a71833e366fb9394c1486d Mon Sep 17 00:00:00 2001 From: David Rowe Date: Sat, 9 May 2015 17:59:10 -0700 Subject: [PATCH 01/11] Disable pragma that Windows doesn't know about --- libraries/networking/src/DataServerAccountInfo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/networking/src/DataServerAccountInfo.cpp b/libraries/networking/src/DataServerAccountInfo.cpp index 44e8dbef90..aa9c5bed93 100644 --- a/libraries/networking/src/DataServerAccountInfo.cpp +++ b/libraries/networking/src/DataServerAccountInfo.cpp @@ -17,7 +17,7 @@ #include "NetworkLogging.h" #include "DataServerAccountInfo.h" -#ifndef __GNUC__ +#if !defined(__GNUC__) && !defined(Q_OS_WIN) #pragma clang diagnostic ignored "-Wdeprecated-declarations" #endif From 662f07a9214220efc75c4ce3f8740021a122386d Mon Sep 17 00:00:00 2001 From: David Rowe Date: Mon, 11 May 2015 09:31:12 -0700 Subject: [PATCH 02/11] Better #if condition for clang --- libraries/networking/src/DataServerAccountInfo.cpp | 2 +- libraries/networking/src/RSAKeypairGenerator.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/networking/src/DataServerAccountInfo.cpp b/libraries/networking/src/DataServerAccountInfo.cpp index aa9c5bed93..fd2c6da13d 100644 --- a/libraries/networking/src/DataServerAccountInfo.cpp +++ b/libraries/networking/src/DataServerAccountInfo.cpp @@ -17,7 +17,7 @@ #include "NetworkLogging.h" #include "DataServerAccountInfo.h" -#if !defined(__GNUC__) && !defined(Q_OS_WIN) +#ifdef __clang__ #pragma clang diagnostic ignored "-Wdeprecated-declarations" #endif diff --git a/libraries/networking/src/RSAKeypairGenerator.cpp b/libraries/networking/src/RSAKeypairGenerator.cpp index 2368b5e6d2..53b9b27cc6 100644 --- a/libraries/networking/src/RSAKeypairGenerator.cpp +++ b/libraries/networking/src/RSAKeypairGenerator.cpp @@ -18,7 +18,7 @@ #include "NetworkLogging.h" #include "RSAKeypairGenerator.h" -#ifndef __GNUC__ +#ifdef __clang__ #pragma clang diagnostic ignored "-Wdeprecated-declarations" #endif From fb9ff6e016e402478ea7a3d4bf0e5a1fb848d90d Mon Sep 17 00:00:00 2001 From: Nex Pro Date: Mon, 11 May 2015 18:50:54 +0100 Subject: [PATCH 03/11] In some cases when the addMenuItem function was called the separator boolean was true by default. This fix addresses this issue by setting it to false. --- libraries/script-engine/src/MenuItemProperties.cpp | 13 ++++++++----- libraries/script-engine/src/MenuItemProperties.h | 4 ++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/libraries/script-engine/src/MenuItemProperties.cpp b/libraries/script-engine/src/MenuItemProperties.cpp index 97fbdef1fa..7015f0abe3 100644 --- a/libraries/script-engine/src/MenuItemProperties.cpp +++ b/libraries/script-engine/src/MenuItemProperties.cpp @@ -23,12 +23,13 @@ MenuItemProperties::MenuItemProperties() : beforeItem(""), afterItem(""), isCheckable(false), - isChecked(false) + isChecked(false), + isSeparator(false) { }; MenuItemProperties::MenuItemProperties(const QString& menuName, const QString& menuItemName, - const QString& shortcutKey, bool checkable, bool checked) : + const QString& shortcutKey, bool checkable, bool checked, bool separator) : menuName(menuName), menuItemName(menuItemName), shortcutKey(shortcutKey), @@ -38,12 +39,13 @@ MenuItemProperties::MenuItemProperties(const QString& menuName, const QString& m beforeItem(""), afterItem(""), isCheckable(checkable), - isChecked(checked) + isChecked(checked), + isSeparator(separator) { } MenuItemProperties::MenuItemProperties(const QString& menuName, const QString& menuItemName, - const KeyEvent& shortcutKeyEvent, bool checkable, bool checked) : + const KeyEvent& shortcutKeyEvent, bool checkable, bool checked, bool separator) : menuName(menuName), menuItemName(menuItemName), shortcutKey(""), @@ -53,7 +55,8 @@ MenuItemProperties::MenuItemProperties(const QString& menuName, const QString& m beforeItem(""), afterItem(""), isCheckable(checkable), - isChecked(checked) + isChecked(checked), + isSeparator(separator) { } diff --git a/libraries/script-engine/src/MenuItemProperties.h b/libraries/script-engine/src/MenuItemProperties.h index 889fb3855a..e58ebe2afb 100644 --- a/libraries/script-engine/src/MenuItemProperties.h +++ b/libraries/script-engine/src/MenuItemProperties.h @@ -22,9 +22,9 @@ class MenuItemProperties { public: MenuItemProperties(); MenuItemProperties(const QString& menuName, const QString& menuItemName, - const QString& shortcutKey = QString(""), bool checkable = false, bool checked = false); + const QString& shortcutKey = QString(""), bool checkable = false, bool checked = false, bool separator = false); MenuItemProperties(const QString& menuName, const QString& menuItemName, - const KeyEvent& shortcutKeyEvent, bool checkable = false, bool checked = false); + const KeyEvent& shortcutKeyEvent, bool checkable = false, bool checked = false, bool separator = false); QString menuName; QString menuItemName; From 83748096efc79b858e6f52cec344770aba54811b Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Mon, 11 May 2015 11:37:53 -0700 Subject: [PATCH 04/11] max pps for an octree-query is a per-query thing, not an application-wide thing. move the settings-related max-octree-pps stuff into the entity tree --- .../src/octree/OctreeSendThread.cpp | 2 +- interface/src/Application.cpp | 8 ++++---- interface/src/Application.h | 1 + interface/src/ui/PreferencesDialog.cpp | 4 ++-- libraries/octree/src/Octree.cpp | 16 +++++++++++++++- libraries/octree/src/Octree.h | 5 +++++ libraries/octree/src/OctreeHeadlessViewer.cpp | 6 +++--- libraries/octree/src/OctreeQuery.cpp | 19 +++++++------------ libraries/octree/src/OctreeQuery.h | 6 +++--- 9 files changed, 41 insertions(+), 26 deletions(-) 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..14742e18f6 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2683,7 +2683,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 = getEntityTree()->getMaxOctreePacketsPerSecond(); // determine PPS based on number of servers if (inViewServers >= 1) { @@ -2746,7 +2746,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 +2770,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; diff --git a/interface/src/Application.h b/interface/src/Application.h index 5a3756e768..a86512ec17 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -208,6 +208,7 @@ public: ViewFrustum* getShadowViewFrustum() { return &_shadowViewFrustum; } const OctreePacketProcessor& getOctreePacketProcessor() const { return _octreeProcessor; } EntityTreeRenderer* getEntities() { return &_entities; } + EntityTree* getEntityTree() { return _entities.getTree(); } Environment* getEnvironment() { return &_environment; } QUndoStack* getUndoStack() { return &_undoStack; } MainWindow* getWindow() { return _window; } diff --git a/interface/src/ui/PreferencesDialog.cpp b/interface/src/ui/PreferencesDialog.cpp index ac436cbb10..96b8bd8056 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->getEntityTree()->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->getEntityTree()->setMaxOctreePacketsPerSecond(ui.maxOctreePPSSpin->value()); qApp->getApplicationOverlay().setHmdUIAngularSize(ui.oculusUIAngularSizeSpin->value()); diff --git a/libraries/octree/src/Octree.cpp b/libraries/octree/src/Octree.cpp index d53d29e444..77f5be4805 100644 --- a/libraries/octree/src/Octree.cpp +++ b/libraries/octree/src/Octree.cpp @@ -40,6 +40,7 @@ #include #include #include +#include #include "CoverageMap.h" #include "OctreeConstants.h" @@ -50,6 +51,7 @@ QVector PERSIST_EXTENSIONS = {"svo", "json"}; +Setting::Handle maxOctreePacketsPerSecond("maxOctreePPS", DEFAULT_MAX_OCTREE_PPS); float boundaryDistanceForRenderLevel(unsigned int renderLevel, float voxelSizeScale) { return voxelSizeScale / powf(2, renderLevel); @@ -62,7 +64,8 @@ Octree::Octree(bool shouldReaverage) : _stopImport(false), _lock(QReadWriteLock::Recursive), _isViewing(false), - _isServer(false) + _isServer(false), + _maxOctreePPS(maxOctreePacketsPerSecond.get()) { } @@ -2201,3 +2204,14 @@ void Octree::cancelImport() { _stopImport = true; } +void Octree::setMaxOctreePacketsPerSecond(int maxOctreePPS) { + if (maxOctreePPS != _maxOctreePPS) { + _maxOctreePPS = maxOctreePPS; + maxOctreePacketsPerSecond.set(_maxOctreePPS); + } +} + +int Octree::getMaxOctreePacketsPerSecond() { + return _maxOctreePPS; +} + diff --git a/libraries/octree/src/Octree.h b/libraries/octree/src/Octree.h index d7fc58699f..408271dc36 100644 --- a/libraries/octree/src/Octree.h +++ b/libraries/octree/src/Octree.h @@ -370,6 +370,9 @@ public: virtual void dumpTree() { }; virtual void pruneTree() { }; + void setMaxOctreePacketsPerSecond(int maxOctreePPS); + int getMaxOctreePacketsPerSecond(); + signals: void importSize(float x, float y, float z); void importProgress(int progress); @@ -403,6 +406,8 @@ protected: bool _isViewing; bool _isServer; + + int _maxOctreePPS = DEFAULT_MAX_OCTREE_PPS; }; float boundaryDistanceForRenderLevel(unsigned int renderLevel, float voxelSizeScale); 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..cac063213c 100644 --- a/libraries/octree/src/OctreeQuery.cpp +++ b/libraries/octree/src/OctreeQuery.cpp @@ -11,22 +11,17 @@ #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); - } +void OctreeQuery::setMaxQueryPacketsPerSecond(int maxQueryPPS) { + _maxQueryPPS = maxQueryPPS; } @@ -59,8 +54,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 +98,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..c3f0971a85 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); 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 From 51a29bdba60828cf0d44fec50cdd3b169f7ec92c Mon Sep 17 00:00:00 2001 From: Howard Stearns Date: Mon, 11 May 2015 11:52:41 -0700 Subject: [PATCH 05/11] Put back the script-fix that belongs in this branch. --- libraries/entities-renderer/src/EntityTreeRenderer.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libraries/entities-renderer/src/EntityTreeRenderer.cpp b/libraries/entities-renderer/src/EntityTreeRenderer.cpp index 943a3824c3..50477356cb 100644 --- a/libraries/entities-renderer/src/EntityTreeRenderer.cpp +++ b/libraries/entities-renderer/src/EntityTreeRenderer.cpp @@ -142,7 +142,9 @@ QString EntityTreeRenderer::loadScriptContents(const QString& scriptMaybeURLorTe QUrl url(scriptMaybeURLorText); // If the url is not valid, this must be script text... - if (!url.isValid()) { + // We document "direct injection" scripts as starting with "(function...", and that would never be a valid url. + // But QUrl thinks it is. + if (!url.isValid() || scriptMaybeURLorText.startsWith("(")) { isURL = false; return scriptMaybeURLorText; } From de9e74a725f96342c1971d6538868fae7c20605d Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Mon, 11 May 2015 12:01:13 -0700 Subject: [PATCH 06/11] put max-octree-pps in Application rather than in the Octree --- interface/src/Application.cpp | 19 +++++++++++++++++-- interface/src/Application.h | 5 +++++ interface/src/ui/PreferencesDialog.cpp | 4 ++-- libraries/octree/src/Octree.cpp | 17 +---------------- libraries/octree/src/Octree.h | 5 ----- 5 files changed, 25 insertions(+), 25 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 14742e18f6..e17846bfda 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -87,6 +87,7 @@ #include #include #include +#include #include "Application.h" #include "AudioClient.h" @@ -183,6 +184,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 +336,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 +2687,7 @@ void Application::queryOctree(NodeType_t serverType, PacketType packetType, Node int perServerPPS = 0; const int SMALL_BUDGET = 10; int perUnknownServer = SMALL_BUDGET; - int totalPPS = getEntityTree()->getMaxOctreePacketsPerSecond(); + int totalPPS = getMaxOctreePacketsPerSecond(); // determine PPS based on number of servers if (inViewServers >= 1) { @@ -4648,3 +4652,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 a86512ec17..da4a61649e 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -345,6 +345,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. @@ -663,6 +666,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 96b8bd8056..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->getEntityTree()->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->getEntityTree()->setMaxOctreePacketsPerSecond(ui.maxOctreePPSSpin->value()); + qApp->setMaxOctreePacketsPerSecond(ui.maxOctreePPSSpin->value()); qApp->getApplicationOverlay().setHmdUIAngularSize(ui.oculusUIAngularSizeSpin->value()); diff --git a/libraries/octree/src/Octree.cpp b/libraries/octree/src/Octree.cpp index 77f5be4805..1a2bc89820 100644 --- a/libraries/octree/src/Octree.cpp +++ b/libraries/octree/src/Octree.cpp @@ -40,7 +40,6 @@ #include #include #include -#include #include "CoverageMap.h" #include "OctreeConstants.h" @@ -51,7 +50,6 @@ QVector PERSIST_EXTENSIONS = {"svo", "json"}; -Setting::Handle maxOctreePacketsPerSecond("maxOctreePPS", DEFAULT_MAX_OCTREE_PPS); float boundaryDistanceForRenderLevel(unsigned int renderLevel, float voxelSizeScale) { return voxelSizeScale / powf(2, renderLevel); @@ -64,8 +62,7 @@ Octree::Octree(bool shouldReaverage) : _stopImport(false), _lock(QReadWriteLock::Recursive), _isViewing(false), - _isServer(false), - _maxOctreePPS(maxOctreePacketsPerSecond.get()) + _isServer(false) { } @@ -2203,15 +2200,3 @@ bool Octree::countOctreeElementsOperation(OctreeElement* element, void* extraDat void Octree::cancelImport() { _stopImport = true; } - -void Octree::setMaxOctreePacketsPerSecond(int maxOctreePPS) { - if (maxOctreePPS != _maxOctreePPS) { - _maxOctreePPS = maxOctreePPS; - maxOctreePacketsPerSecond.set(_maxOctreePPS); - } -} - -int Octree::getMaxOctreePacketsPerSecond() { - return _maxOctreePPS; -} - diff --git a/libraries/octree/src/Octree.h b/libraries/octree/src/Octree.h index 408271dc36..d7fc58699f 100644 --- a/libraries/octree/src/Octree.h +++ b/libraries/octree/src/Octree.h @@ -370,9 +370,6 @@ public: virtual void dumpTree() { }; virtual void pruneTree() { }; - void setMaxOctreePacketsPerSecond(int maxOctreePPS); - int getMaxOctreePacketsPerSecond(); - signals: void importSize(float x, float y, float z); void importProgress(int progress); @@ -406,8 +403,6 @@ protected: bool _isViewing; bool _isServer; - - int _maxOctreePPS = DEFAULT_MAX_OCTREE_PPS; }; float boundaryDistanceForRenderLevel(unsigned int renderLevel, float voxelSizeScale); From 9bd101ee2ae3381d9b458fc8281083bda55461aa Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Mon, 11 May 2015 12:01:59 -0700 Subject: [PATCH 07/11] oops --- interface/src/Application.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index e17846bfda..088b2ddf96 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -87,7 +87,6 @@ #include #include #include -#include #include "Application.h" #include "AudioClient.h" From ead200b77aa558b6d4bbd73a6f6f4e3e3efb9b0d Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Mon, 11 May 2015 12:03:10 -0700 Subject: [PATCH 08/11] remove unneeded code --- interface/src/Application.h | 1 - 1 file changed, 1 deletion(-) diff --git a/interface/src/Application.h b/interface/src/Application.h index da4a61649e..09edaba341 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -208,7 +208,6 @@ public: ViewFrustum* getShadowViewFrustum() { return &_shadowViewFrustum; } const OctreePacketProcessor& getOctreePacketProcessor() const { return _octreeProcessor; } EntityTreeRenderer* getEntities() { return &_entities; } - EntityTree* getEntityTree() { return _entities.getTree(); } Environment* getEnvironment() { return &_environment; } QUndoStack* getUndoStack() { return &_undoStack; } MainWindow* getWindow() { return _window; } From 635f49258d18a5932b5fdd45ab2e671d7f932abe Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Mon, 11 May 2015 12:04:31 -0700 Subject: [PATCH 09/11] formatting --- libraries/octree/src/Octree.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/octree/src/Octree.cpp b/libraries/octree/src/Octree.cpp index 1a2bc89820..d53d29e444 100644 --- a/libraries/octree/src/Octree.cpp +++ b/libraries/octree/src/Octree.cpp @@ -2200,3 +2200,4 @@ bool Octree::countOctreeElementsOperation(OctreeElement* element, void* extraDat void Octree::cancelImport() { _stopImport = true; } + From ddb907ae5fd7e83e6e8773595cd4416f173553d8 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Mon, 11 May 2015 12:15:52 -0700 Subject: [PATCH 10/11] inline setMaxQueryPacketsPerSecond --- libraries/octree/src/OctreeQuery.cpp | 5 ----- libraries/octree/src/OctreeQuery.h | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/libraries/octree/src/OctreeQuery.cpp b/libraries/octree/src/OctreeQuery.cpp index cac063213c..08197a587e 100644 --- a/libraries/octree/src/OctreeQuery.cpp +++ b/libraries/octree/src/OctreeQuery.cpp @@ -20,11 +20,6 @@ OctreeQuery::OctreeQuery() { _maxQueryPPS = DEFAULT_MAX_OCTREE_PPS; } -void OctreeQuery::setMaxQueryPacketsPerSecond(int maxQueryPPS) { - _maxQueryPPS = maxQueryPPS; -} - - int OctreeQuery::getBroadcastData(unsigned char* destinationBuffer) { unsigned char* bufferStart = destinationBuffer; diff --git a/libraries/octree/src/OctreeQuery.h b/libraries/octree/src/OctreeQuery.h index c3f0971a85..3c204ff938 100644 --- a/libraries/octree/src/OctreeQuery.h +++ b/libraries/octree/src/OctreeQuery.h @@ -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 setMaxQueryPacketsPerSecond(int maxQueryPPS); + void setMaxQueryPacketsPerSecond(int maxQueryPPS) { _maxQueryPPS = maxQueryPPS; } void setOctreeSizeScale(float octreeSizeScale) { _octreeElementSizeScale = octreeSizeScale; } void setBoundaryLevelAdjust(int boundaryLevelAdjust) { _boundaryLevelAdjust = boundaryLevelAdjust; } From 237eb72bec0aae81527de9b55e80bde944e0cd0f Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Mon, 11 May 2015 16:01:50 -0700 Subject: [PATCH 11/11] if two people grab an enitity at once, don't forget about the original gravity --- examples/grab.js | 44 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 38 insertions(+), 6 deletions(-) diff --git a/examples/grab.js b/examples/grab.js index efacc26612..552a194100 100644 --- a/examples/grab.js +++ b/examples/grab.js @@ -27,7 +27,7 @@ var ANGULAR_DAMPING_RATE = 0.40; var SCREEN_TO_METERS = 0.001; var currentPosition, currentVelocity, cameraEntityDistance, currentRotation; var velocityTowardTarget, desiredVelocity, addedVelocity, newVelocity, dPosition, camYaw, distanceToTarget, targetPosition; -var originalGravity; +var originalGravity = {x: 0, y: 0, z: 0}; var shouldRotate = false; var dQ, theta, axisAngle, dT; var angularVelocity = { @@ -56,6 +56,15 @@ var dropLine = Overlays.addOverlay("line3d", { }); +function vectorIsZero(v) { + return v.x == 0 && v.y == 0 && v.z == 0; +} + +function vectorToString(v) { + return "(" + v.x + ", " + v.y + ", " + v.z + ")" +} + + function mousePressEvent(event) { if (!event.isLeftButton) { return; @@ -67,10 +76,16 @@ function mousePressEvent(event) { var props = Entities.getEntityProperties(grabbedEntity) isGrabbing = true; originalGravity = props.gravity; + print("mouse-press setting originalGravity " + originalGravity + " " + vectorToString(originalGravity)); targetPosition = props.position; currentPosition = props.position; currentVelocity = props.velocity; updateDropLine(targetPosition); + + Entities.editEntity(grabbedEntity, { + gravity: {x: 0, y: 0, z: 0} + }); + Audio.playSound(grabSound, { position: props.position, volume: 0.4 @@ -99,9 +114,20 @@ function mouseReleaseEvent() { if (isGrabbing) { isGrabbing = false; - Entities.editEntity(grabbedEntity, { - gravity: originalGravity - }); + // only restore the original gravity if it's not zero. This is to avoid... + // 1. interface A grabs an entity and locally saves off its gravity + // 2. interface A sets the entity's gravity to zero + // 3. interface B grabs the entity and saves off its gravity (which is zero) + // 4. interface A releases the entity and puts the original gravity back + // 5. interface B releases the entity and puts the original gravity back (to zero) + if (!vectorIsZero(originalGravity)) { + print("mouse-release restoring originalGravity" + vectorToString(originalGravity)); + Entities.editEntity(grabbedEntity, { + gravity: originalGravity + }); + } else { + print("mouse-release not restoring originalGravity of zero"); + } Overlays.editOverlay(dropLine, { visible: false @@ -117,6 +143,13 @@ function mouseReleaseEvent() { function mouseMoveEvent(event) { if (isGrabbing) { + // see if something added/restored gravity + var props = Entities.getEntityProperties(grabbedEntity); + if (!vectorIsZero(props.gravity)) { + originalGravity = props.gravity; + print("mouse-move adopting originalGravity" + vectorToString(originalGravity)); + } + deltaMouse.x = event.x - prevMouse.x; if (!moveUpDown) { deltaMouse.z = event.y - prevMouse.y; @@ -211,8 +244,7 @@ function update(deltaTime) { Entities.editEntity(grabbedEntity, { velocity: newVelocity, - angularVelocity: angularVelocity, - gravity: {x: 0, y: 0, z: 0} + angularVelocity: angularVelocity }) updateDropLine(targetPosition); }