From 18a293c020f8bda43569c47478ad2a7fd1e7f094 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 28 Mar 2014 08:58:49 -0700 Subject: [PATCH 1/9] add a symmetric socket to the Node class --- libraries/shared/src/Node.cpp | 1 + libraries/shared/src/Node.h | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/libraries/shared/src/Node.cpp b/libraries/shared/src/Node.cpp index dadf39f790..d300cd7ba0 100644 --- a/libraries/shared/src/Node.cpp +++ b/libraries/shared/src/Node.cpp @@ -51,6 +51,7 @@ Node::Node(const QUuid& uuid, char type, const HifiSockAddr& publicSocket, const _lastHeardMicrostamp(usecTimestampNow()), _publicSocket(publicSocket), _localSocket(localSocket), + _symmetricSocket(), _activeSocket(NULL), _connectionSecret(), _bytesReceivedMovingAverage(NULL), diff --git a/libraries/shared/src/Node.h b/libraries/shared/src/Node.h index 43ec5baf81..1c9ee97477 100644 --- a/libraries/shared/src/Node.h +++ b/libraries/shared/src/Node.h @@ -70,7 +70,9 @@ public: void setPublicSocket(const HifiSockAddr& publicSocket); const HifiSockAddr& getLocalSocket() const { return _localSocket; } void setLocalSocket(const HifiSockAddr& localSocket); - + const HifiSockAddr& getSymmetricSocket() const { return _symmetricSocket; } + void setSymmetricSocket(const HifiSockAddr& symmetricSocket) { _symmetricSocket = symmetricSocket; } + const HifiSockAddr* getActiveSocket() const { return _activeSocket; } void activatePublicSocket(); @@ -110,6 +112,7 @@ private: quint64 _lastHeardMicrostamp; HifiSockAddr _publicSocket; HifiSockAddr _localSocket; + HifiSockAddr _symmetricSocket; HifiSockAddr* _activeSocket; QUuid _connectionSecret; SimpleMovingAverage* _bytesReceivedMovingAverage; From f80b415497e6c1402ed46217280702fae0129f1b Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 28 Mar 2014 09:07:30 -0700 Subject: [PATCH 2/9] handle activation and setting of symmetric socket --- libraries/shared/src/Node.cpp | 14 ++++++++++++++ libraries/shared/src/Node.h | 3 ++- libraries/shared/src/NodeList.cpp | 12 ++++++++++++ libraries/shared/src/NodeList.h | 1 + 4 files changed, 29 insertions(+), 1 deletion(-) diff --git a/libraries/shared/src/Node.cpp b/libraries/shared/src/Node.cpp index d300cd7ba0..a4491fb707 100644 --- a/libraries/shared/src/Node.cpp +++ b/libraries/shared/src/Node.cpp @@ -85,6 +85,15 @@ void Node::setLocalSocket(const HifiSockAddr& localSocket) { _localSocket = localSocket; } +void Node::setSymmetricSocket(const HifiSockAddr& symmetricSocket) { + if (_activeSocket == &_symmetricSocket) { + // if the active socket was the symmetric socket then reset it to NULL + _activeSocket = NULL; + } + + _symmetricSocket = symmetricSocket; +} + void Node::activateLocalSocket() { qDebug() << "Activating local socket for node" << *this; _activeSocket = &_localSocket; @@ -95,6 +104,11 @@ void Node::activatePublicSocket() { _activeSocket = &_publicSocket; } +void Node::activateSymmetricSocket() { + qDebug() << "Activating symmetric socket for node" << *this; + _activeSocket = &_symmetricSocket; +} + void Node::recordBytesReceived(int bytesReceived) { if (!_bytesReceivedMovingAverage) { _bytesReceivedMovingAverage = new SimpleMovingAverage(100); diff --git a/libraries/shared/src/Node.h b/libraries/shared/src/Node.h index 1c9ee97477..79d75629a6 100644 --- a/libraries/shared/src/Node.h +++ b/libraries/shared/src/Node.h @@ -71,12 +71,13 @@ public: const HifiSockAddr& getLocalSocket() const { return _localSocket; } void setLocalSocket(const HifiSockAddr& localSocket); const HifiSockAddr& getSymmetricSocket() const { return _symmetricSocket; } - void setSymmetricSocket(const HifiSockAddr& symmetricSocket) { _symmetricSocket = symmetricSocket; } + void setSymmetricSocket(const HifiSockAddr& symmetricSocket); const HifiSockAddr* getActiveSocket() const { return _activeSocket; } void activatePublicSocket(); void activateLocalSocket(); + void activateSymmetricSocket(); const QUuid& getConnectionSecret() const { return _connectionSecret; } void setConnectionSecret(const QUuid& connectionSecret) { _connectionSecret = connectionSecret; } diff --git a/libraries/shared/src/NodeList.cpp b/libraries/shared/src/NodeList.cpp index 761ea40d55..bcd40a8de4 100644 --- a/libraries/shared/src/NodeList.cpp +++ b/libraries/shared/src/NodeList.cpp @@ -294,6 +294,15 @@ void NodeList::processNodeData(const HifiSockAddr& senderSockAddr, const QByteAr matchingNode->setLastHeardMicrostamp(usecTimestampNow()); QByteArray replyPacket = constructPingReplyPacket(packet); writeDatagram(replyPacket, matchingNode, senderSockAddr); + + // If we don't have a symmetric socket for this node and this socket doesn't match + // what we have for public and local then set it as the symmetric. + // This allows a server on a reachable port to communicate with nodes on symmetric NATs + if (matchingNode->getSymmetricSocket().isNull()) { + if (senderSockAddr != matchingNode->getLocalSocket() && senderSockAddr != matchingNode->getPublicSocket()) { + matchingNode->setSymmetricSocket(senderSockAddr); + } + } } break; @@ -879,6 +888,9 @@ void NodeList::activateSocketFromNodeCommunication(const QByteArray& packet, con sendingNode->activateLocalSocket(); } else if (pingType == PingType::Public && !sendingNode->getActiveSocket()) { sendingNode->activatePublicSocket(); + } else if (pingType == PingType::Symmetric && !sendingNode->getActiveSocket()) { + + } } diff --git a/libraries/shared/src/NodeList.h b/libraries/shared/src/NodeList.h index d05d6a2fbc..182c72b670 100644 --- a/libraries/shared/src/NodeList.h +++ b/libraries/shared/src/NodeList.h @@ -58,6 +58,7 @@ namespace PingType { const PingType_t Agnostic = 0; const PingType_t Local = 1; const PingType_t Public = 2; + const PingType_t Symmetric = 3; } class NodeList : public QObject { From 8b1b2d8d9901a07fa9483ef7a30fe743b70b5f91 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 28 Mar 2014 09:11:20 -0700 Subject: [PATCH 3/9] send a symmetric ping packet if appropriate when pinging nodes --- libraries/shared/src/NodeList.cpp | 9 +++++++-- libraries/shared/src/NodeList.h | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/libraries/shared/src/NodeList.cpp b/libraries/shared/src/NodeList.cpp index bcd40a8de4..879377a2fd 100644 --- a/libraries/shared/src/NodeList.cpp +++ b/libraries/shared/src/NodeList.cpp @@ -791,7 +791,7 @@ QByteArray NodeList::constructPingReplyPacket(const QByteArray& pingPacket) { return replyPacket; } -void NodeList::pingPublicAndLocalSocketsForInactiveNode(const SharedNodePointer& node) { +void NodeList::pingPunchForInactiveNode(const SharedNodePointer& node) { // send the ping packet to the local and public sockets for this node QByteArray localPingPacket = constructPingPacket(PingType::Local); @@ -799,6 +799,11 @@ void NodeList::pingPublicAndLocalSocketsForInactiveNode(const SharedNodePointer& QByteArray publicPingPacket = constructPingPacket(PingType::Public); writeDatagram(publicPingPacket, node, node->getPublicSocket()); + + if (!node->getSymmetricSocket().isNull()) { + QByteArray symmetricPingPacket = constructPingPacket(PingType::Symmetric); + writeDatagram(symmetricPingPacket, node, node->getSymmetricSocket()); + } } SharedNodePointer NodeList::addOrUpdateNode(const QUuid& uuid, char nodeType, @@ -869,7 +874,7 @@ void NodeList::pingInactiveNodes() { foreach (const SharedNodePointer& node, getNodeHash()) { if (!node->getActiveSocket()) { // we don't have an active link to this node, ping it to set that up - pingPublicAndLocalSocketsForInactiveNode(node); + pingPunchForInactiveNode(node); } } } diff --git a/libraries/shared/src/NodeList.h b/libraries/shared/src/NodeList.h index 182c72b670..34078b6a94 100644 --- a/libraries/shared/src/NodeList.h +++ b/libraries/shared/src/NodeList.h @@ -102,7 +102,7 @@ public: QByteArray constructPingPacket(PingType_t pingType = PingType::Agnostic); QByteArray constructPingReplyPacket(const QByteArray& pingPacket); - void pingPublicAndLocalSocketsForInactiveNode(const SharedNodePointer& node); + void pingPunchForInactiveNode(const SharedNodePointer& node); SharedNodePointer nodeWithUUID(const QUuid& nodeUUID, bool blockingLock = true); SharedNodePointer sendingNodeForPacket(const QByteArray& packet); From 0c289076098f4a86a4676f5b6379b53a10fe8618 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 28 Mar 2014 10:08:00 -0700 Subject: [PATCH 4/9] fix the hydraMove script to pull you based on head orientation, not body --- examples/hydraMove.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/hydraMove.js b/examples/hydraMove.js index 92c594df9e..6268a38ba3 100644 --- a/examples/hydraMove.js +++ b/examples/hydraMove.js @@ -162,11 +162,11 @@ function flyWithHydra(deltaTime) { if (thrustMultiplier < MAX_THRUST_MULTIPLIER) { thrustMultiplier *= 1 + (deltaTime * THRUST_INCREASE_RATE); } - var currentOrientation = MyAvatar.orientation; + var headOrientation = MyAvatar.headOrientation; - var front = Quat.getFront(currentOrientation); - var right = Quat.getRight(currentOrientation); - var up = Quat.getUp(currentOrientation); + var front = Quat.getFront(headOrientation); + var right = Quat.getRight(headOrientation); + var up = Quat.getUp(headOrientation); var thrustFront = Vec3.multiply(front, MyAvatar.scale * THRUST_MAG_HAND_JETS * thrustJoystickPosition.y * thrustMultiplier * deltaTime); From 4d16547362be06bbafbc2664b24bd1b703034b69 Mon Sep 17 00:00:00 2001 From: Grayson Stebbins Date: Fri, 28 Mar 2014 14:50:26 -0700 Subject: [PATCH 5/9] Note about shortcut for domain dialog (set your domain via Cmnd+D/Cntrl+D) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f8a6725ed8..ab1212f656 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ Running Interface When you launch interface, you will automatically connect to our default domain: "root.highfidelity.io". If you don't see anything, make sure your preferences are pointing to -root.highfidelity.io, if you still have no luck it's possible our servers are +root.highfidelity.io (set your domain via Cmnd+D/Cntrl+D), if you still have no luck it's possible our servers are simply down; if you're experiencing a major bug, let us know by adding an issue to this repository. Make sure to include details about your computer and how to reproduce the bug. From 6880160bc00492ed907ebce06af713ead53ba6b2 Mon Sep 17 00:00:00 2001 From: James Brotchie Date: Mon, 31 Mar 2014 22:08:38 +1000 Subject: [PATCH 6/9] Remember most recently opened script location. Previously when running a script from a file you were always taken back to your desktop directory. Now you will be taken to the location of your most recently opened script. --- interface/interface_en.ts | 8 ++++---- interface/src/Application.cpp | 15 ++++++++++++--- interface/src/Application.h | 2 ++ 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/interface/interface_en.ts b/interface/interface_en.ts index 519e2b61c1..7c5d1ecbcf 100644 --- a/interface/interface_en.ts +++ b/interface/interface_en.ts @@ -4,22 +4,22 @@ Application - + Export Voxels - + Sparse Voxel Octree Files (*.svo) - + Open Script - + JavaScript Files (*.js) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index c6fc522fca..d91e686844 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -169,6 +169,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : _bytesPerSecond(0), _recentMaxPackets(0), _resetRecentMaxPacketsSoon(true), + _previousScriptLocation(), _logger(new FileLogger(this)) { // read the ApplicationInfo.ini file for Name/Version/Domain information @@ -3610,12 +3611,20 @@ void Application::loadScript(const QString& scriptName) { } void Application::loadDialog() { - // shut down and stop any existing script - QString desktopLocation = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation); - QString suggestedName = desktopLocation.append("/script.js"); + QString suggestedName; + + if (_previousScriptLocation.isEmpty()) { + QString desktopLocation = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation); + suggestedName = desktopLocation.append("/script.js"); + } else { + suggestedName = _previousScriptLocation; + } QString fileNameString = QFileDialog::getOpenFileName(_glWidget, tr("Open Script"), suggestedName, tr("JavaScript Files (*.js)")); + if (!fileNameString.isEmpty()) { + _previousScriptLocation = fileNameString; + } loadScript(fileNameString); } diff --git a/interface/src/Application.h b/interface/src/Application.h index 15778f2a17..bab7578ca4 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -483,6 +483,8 @@ private: ControllerScriptingInterface _controllerScriptingInterface; QPointer _logDialog; + QString _previousScriptLocation; + FileLogger* _logger; void checkVersion(); From 59bc0ffb9dc652a87d191946f736fd6ff65a79da Mon Sep 17 00:00:00 2001 From: James Brotchie Date: Mon, 31 Mar 2014 23:33:17 +1000 Subject: [PATCH 7/9] Update BUILD.md Not sure about anybody else but I needed glm 0.9.5.2 the compile without errors. 0.9.5.0 (as suggested in the current BUILD.md) failed because the precision template parameter was undefined. --- BUILD.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BUILD.md b/BUILD.md index 8f871c3cea..6464f14d08 100644 --- a/BUILD.md +++ b/BUILD.md @@ -3,7 +3,7 @@ Dependencies * [cmake](http://www.cmake.org/cmake/resources/software.html) ~> 2.8.11 * [Qt](http://qt-project.org/downloads) ~> 5.2.0 * [zLib](http://www.zlib.net/) ~> 1.2.8 -* [glm](http://glm.g-truc.net/0.9.5/index.html) ~> 0.9.5.0 +* [glm](http://glm.g-truc.net/0.9.5/index.html) ~> 0.9.5.2 * [qxmpp](https://code.google.com/p/qxmpp/) ~> 0.7.6 #####Linux only @@ -142,4 +142,4 @@ If you need to debug Interface, you can run interface from within Visual Studio ####Debugging Interface * In the Solution Explorer, right click interface and click Set as StartUp Project * Set the "Working Directory" for the Interface debugging sessions to the Debug output directory so that your application can load resources. Do this: right click interface and click Properties, choose Debugging from Configuration Properties, set Working Directory to .\Debug -* Now you can run and debug interface through Visual Studio \ No newline at end of file +* Now you can run and debug interface through Visual Studio From da116608a036ca8bb5792a8537a18552d744c860 Mon Sep 17 00:00:00 2001 From: James Brotchie Date: Tue, 1 Apr 2014 07:38:22 +1000 Subject: [PATCH 8/9] Hitting enter no longer shows chat window when chat is disabled. When chat is disabled (QXMPP library not available or XMPP disconnected) hitting enter would show the chat window, even when the Tools -> Chat menu item is grayed out! --- interface/src/Menu.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index 7748c466c7..ec20401fef 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -1102,6 +1102,11 @@ void Menu::showMetavoxelEditor() { } void Menu::showChat() { + if (!_chatAction->isEnabled()) { + // Don't do anything if chat is disabled (No + // QXMPP library or xmpp is disconnected). + return; + } QMainWindow* mainWindow = Application::getInstance()->getWindow(); if (!_chatWindow) { mainWindow->addDockWidget(Qt::NoDockWidgetArea, _chatWindow = new ChatWindow()); From 135d97d0a7500134e39e1b283ed274a0eafb6f74 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Mon, 31 Mar 2014 15:59:54 -0700 Subject: [PATCH 9/9] add a pretty important missing line for symmetric socket activation --- libraries/shared/src/NodeList.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libraries/shared/src/NodeList.cpp b/libraries/shared/src/NodeList.cpp index 879377a2fd..b725914bfd 100644 --- a/libraries/shared/src/NodeList.cpp +++ b/libraries/shared/src/NodeList.cpp @@ -894,8 +894,7 @@ void NodeList::activateSocketFromNodeCommunication(const QByteArray& packet, con } else if (pingType == PingType::Public && !sendingNode->getActiveSocket()) { sendingNode->activatePublicSocket(); } else if (pingType == PingType::Symmetric && !sendingNode->getActiveSocket()) { - - + sendingNode->activateSymmetricSocket(); } }