From eb4678659a454286ffb3298612ca49fac862d7bb Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Fri, 23 Jan 2015 15:56:44 -0800 Subject: [PATCH 01/38] remove EntityItem::getDistanceToBottomOfEntity() and also isRestingOnSurface() --- libraries/entities/src/EntityItem.cpp | 21 +-------------------- libraries/entities/src/EntityItem.h | 4 ---- 2 files changed, 1 insertion(+), 24 deletions(-) diff --git a/libraries/entities/src/EntityItem.cpp b/libraries/entities/src/EntityItem.cpp index 1ebde85d65..cd9140968e 100644 --- a/libraries/entities/src/EntityItem.cpp +++ b/libraries/entities/src/EntityItem.cpp @@ -595,17 +595,6 @@ void EntityItem::setMass(float mass) { const float ENTITY_ITEM_EPSILON_VELOCITY_LENGTH = 0.001f / (float)TREE_SCALE; -// TODO: we probably want to change this to make "down" be the direction of the entity's gravity vector -// for now, this is always true DOWN even if entity has non-down gravity. -// TODO: the old code had "&& _velocity.y >= -EPSILON && _velocity.y <= EPSILON" --- what was I thinking? -bool EntityItem::isRestingOnSurface() const { - glm::vec3 downwardVelocity = glm::vec3(0.0f, _velocity.y, 0.0f); - - return _position.y <= getDistanceToBottomOfEntity() - && (glm::length(downwardVelocity) <= ENTITY_ITEM_EPSILON_VELOCITY_LENGTH) - && _gravity.y < 0.0f; -} - void EntityItem::simulate(const quint64& now) { bool wantDebug = false; @@ -623,7 +612,6 @@ void EntityItem::simulate(const quint64& now) { qDebug() << " timeElapsed=" << timeElapsed; qDebug() << " hasVelocity=" << hasVelocity(); qDebug() << " hasGravity=" << hasGravity(); - qDebug() << " isRestingOnSurface=" << isRestingOnSurface(); qDebug() << " hasAngularVelocity=" << hasAngularVelocity(); qDebug() << " getAngularVelocity=" << getAngularVelocity(); qDebug() << " isMortal=" << isMortal(); @@ -631,11 +619,10 @@ void EntityItem::simulate(const quint64& now) { qDebug() << " getLifetime()=" << getLifetime(); - if (hasVelocity() || (hasGravity() && !isRestingOnSurface())) { + if (hasVelocity() || hasGravity()) { qDebug() << " MOVING...="; qDebug() << " hasVelocity=" << hasVelocity(); qDebug() << " hasGravity=" << hasGravity(); - qDebug() << " isRestingOnSurface=" << isRestingOnSurface(); qDebug() << " hasAngularVelocity=" << hasAngularVelocity(); qDebug() << " getAngularVelocity=" << getAngularVelocity(); } @@ -717,7 +704,6 @@ void EntityItem::simulateKinematicMotion(float timeElapsed) { qDebug() << " old position:" << position; qDebug() << " old velocity:" << velocity; qDebug() << " old getAABox:" << getAABox(); - qDebug() << " getDistanceToBottomOfEntity():" << getDistanceToBottomOfEntity() * (float)TREE_SCALE << " in meters"; qDebug() << " newPosition:" << newPosition; qDebug() << " glm::distance(newPosition, position):" << glm::distance(newPosition, position); } @@ -872,11 +858,6 @@ float EntityItem::getSize() const { return glm::length(_dimensions); } -float EntityItem::getDistanceToBottomOfEntity() const { - glm::vec3 minimumPoint = getAABox().getMinimumPoint(); - return getPosition().y - minimumPoint.y; -} - // TODO: doesn't this need to handle rotation? glm::vec3 EntityItem::getCenter() const { return _position + (_dimensions * (glm::vec3(0.5f,0.5f,0.5f) - _registrationPoint)); diff --git a/libraries/entities/src/EntityItem.h b/libraries/entities/src/EntityItem.h index d266a30f62..e4ab349fc1 100644 --- a/libraries/entities/src/EntityItem.h +++ b/libraries/entities/src/EntityItem.h @@ -155,7 +155,6 @@ public: const glm::vec3& getDimensions() const { return _dimensions; } /// get dimensions in domain scale units (0.0 - 1.0) glm::vec3 getDimensionsInMeters() const { return _dimensions * (float) TREE_SCALE; } /// get dimensions in meters - float getDistanceToBottomOfEntity() const; /// get the distance from the position of the entity to its "bottom" in y axis float getLargestDimension() const { return glm::length(_dimensions); } /// get the largest possible dimension /// set dimensions in domain scale units (0.0 - 1.0) this will also reset radius appropriately @@ -191,9 +190,6 @@ public: void setGravityInMeters(const glm::vec3& value) { _gravity = value / (float) TREE_SCALE; } /// gravity in meters bool hasGravity() const { return _gravity != ENTITY_ITEM_ZERO_VEC3; } - // TODO: this should eventually be updated to support resting on collisions with other surfaces - bool isRestingOnSurface() const; - float getDamping() const { return _damping; } void setDamping(float value) { _damping = value; } From 44083dd34325e3c581ea857029aba4a5ce6b47a6 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Tue, 27 Jan 2015 13:10:11 -0800 Subject: [PATCH 02/38] Add user warning if domain has mismatched packet versions --- interface/src/Application.cpp | 24 ++++++++++++++++--- interface/src/Application.h | 4 ++++ .../src/octree/OctreePacketProcessor.cpp | 3 ++- interface/src/octree/OctreePacketProcessor.h | 4 ++++ libraries/networking/src/LimitedNodeList.cpp | 2 ++ libraries/networking/src/LimitedNodeList.h | 2 ++ 6 files changed, 35 insertions(+), 4 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 86af8b0e91..80766f0c24 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -221,7 +221,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : _lastNackTime(usecTimestampNow()), _lastSendDownstreamAudioStats(usecTimestampNow()), _isVSyncOn(true), - _aboutToQuit(false) + _aboutToQuit(false), + _notifiedPacketVersionMismatchThisDomain(false) { auto glCanvas = DependencyManager::get(); auto nodeList = DependencyManager::get(); @@ -305,6 +306,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : connect(nodeList.data(), SIGNAL(nodeKilled(SharedNodePointer)), SLOT(nodeKilled(SharedNodePointer))); connect(nodeList.data(), &NodeList::uuidChanged, _myAvatar, &MyAvatar::setSessionUUID); connect(nodeList.data(), &NodeList::limitOfSilentDomainCheckInsReached, nodeList.data(), &NodeList::reset); + connect(nodeList.data(), &NodeList::packetVersionMismatch, this, &Application::notifyPacketVersionMismatch); // connect to appropriate slots on AccountManager AccountManager& accountManager = AccountManager::getInstance(); @@ -576,6 +578,7 @@ void Application::initializeGL() { // create thread for parsing of octee data independent of the main network and rendering threads _octreeProcessor.initialize(_enableProcessOctreeThread); + connect(&_octreeProcessor, &OctreePacketProcessor::packetVersionMismatch, this, &Application::notifyPacketVersionMismatch); _entityEditSender.initialize(_enableProcessOctreeThread); // call our timer function every second @@ -3218,11 +3221,11 @@ void Application::connectedToDomain(const QString& hostname) { if (accountManager.isLoggedIn() && !domainID.isNull()) { // update our data-server with the domain-server we're logged in with - QString domainPutJsonString = "{\"location\":{\"domain_id\":\"" + uuidStringWithoutCurlyBraces(domainID) + "\"}}"; - accountManager.authenticatedRequest("/api/v1/user/location", QNetworkAccessManager::PutOperation, JSONCallbackParameters(), domainPutJsonString.toUtf8()); + + _notifiedPacketVersionMismatchThisDomain = false; } } @@ -3988,3 +3991,18 @@ int Application::getRenderAmbientLight() const { return -1; } } + +void Application::notifyPacketVersionMismatch() { + if (!_notifiedPacketVersionMismatchThisDomain) { + _notifiedPacketVersionMismatchThisDomain = true; + + QString message = "The location you are visiting is running an incompatible server version.\n"; + message += "Content may not display properly."; + + QMessageBox msgBox; + msgBox.setText(message); + msgBox.setStandardButtons(QMessageBox::Ok); + msgBox.setIcon(QMessageBox::Warning); + msgBox.exec(); + } +} diff --git a/interface/src/Application.h b/interface/src/Application.h index 3b793978a8..7dd3e30017 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -361,6 +361,8 @@ public slots: void resetSensors(); + void notifyPacketVersionMismatch(); + private slots: void clearDomainOctreeDetails(); void timer(); @@ -579,6 +581,8 @@ private: bool _aboutToQuit; Bookmarks* _bookmarks; + + bool _notifiedPacketVersionMismatchThisDomain; }; #endif // hifi_Application_h diff --git a/interface/src/octree/OctreePacketProcessor.cpp b/interface/src/octree/OctreePacketProcessor.cpp index 7129debd34..65a5c6f1a1 100644 --- a/interface/src/octree/OctreePacketProcessor.cpp +++ b/interface/src/octree/OctreePacketProcessor.cpp @@ -68,11 +68,12 @@ void OctreePacketProcessor::processPacket(const SharedNodePointer& sendingNode, << senderUUID << "sent" << (int)packetVersion << "but" << (int)expectedVersion << "expected."; + emit packetVersionMismatch(); + versionDebugSuppressMap.insert(senderUUID, voxelPacketType); } return; // bail since piggyback version doesn't match } - app->trackIncomingOctreePacket(mutablePacket, sendingNode, wasStatsPacket); diff --git a/interface/src/octree/OctreePacketProcessor.h b/interface/src/octree/OctreePacketProcessor.h index abdf271cfb..5c52dec002 100644 --- a/interface/src/octree/OctreePacketProcessor.h +++ b/interface/src/octree/OctreePacketProcessor.h @@ -18,6 +18,10 @@ /// the user is responsible for reading inbound packets and adding them to the processing queue by calling queueReceivedPacket() class OctreePacketProcessor : public ReceivedPacketProcessor { Q_OBJECT + +signals: + void packetVersionMismatch(); + protected: virtual void processPacket(const SharedNodePointer& sendingNode, const QByteArray& packet); }; diff --git a/libraries/networking/src/LimitedNodeList.cpp b/libraries/networking/src/LimitedNodeList.cpp index 5bf416af7f..75d83e9647 100644 --- a/libraries/networking/src/LimitedNodeList.cpp +++ b/libraries/networking/src/LimitedNodeList.cpp @@ -169,6 +169,8 @@ bool LimitedNodeList::packetVersionAndHashMatch(const QByteArray& packet) { qDebug() << "Packet version mismatch on" << packetTypeForPacket(packet) << "- Sender" << uuidFromPacketHeader(packet) << "sent" << qPrintable(QString::number(packet[numPacketTypeBytes])) << "but" << qPrintable(QString::number(versionForPacketType(mismatchType))) << "expected."; + + emit packetVersionMismatch(); versionDebugSuppressMap.insert(senderUUID, checkType); } diff --git a/libraries/networking/src/LimitedNodeList.h b/libraries/networking/src/LimitedNodeList.h index 1c841637df..8a9ad09148 100644 --- a/libraries/networking/src/LimitedNodeList.h +++ b/libraries/networking/src/LimitedNodeList.h @@ -180,6 +180,8 @@ signals: void localSockAddrChanged(const HifiSockAddr& localSockAddr); void publicSockAddrChanged(const HifiSockAddr& publicSockAddr); + + void packetVersionMismatch(); protected: LimitedNodeList(unsigned short socketListenPort = 0, unsigned short dtlsListenPort = 0); From 1cfd98b2d7703eb9561d111716947ad24ddcbce0 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Sat, 31 Jan 2015 00:50:12 -0800 Subject: [PATCH 03/38] Name threads --- assignment-client/src/audio/AudioMixer.cpp | 1 + assignment-client/src/octree/OctreeServer.cpp | 1 + interface/src/Application.cpp | 5 ++++- interface/src/ModelUploader.cpp | 1 + interface/src/ui/ModelsBrowser.cpp | 1 + libraries/audio/src/AudioScriptingInterface.cpp | 1 + libraries/avatars/src/Player.cpp | 1 + libraries/networking/src/AccountManager.cpp | 1 + 8 files changed, 11 insertions(+), 1 deletion(-) diff --git a/assignment-client/src/audio/AudioMixer.cpp b/assignment-client/src/audio/AudioMixer.cpp index b7dfdd9b24..b862cd0c78 100644 --- a/assignment-client/src/audio/AudioMixer.cpp +++ b/assignment-client/src/audio/AudioMixer.cpp @@ -648,6 +648,7 @@ void AudioMixer::run() { // setup a QThread with us as parent that will house the AudioMixerDatagramProcessor _datagramProcessingThread = new QThread(this); + _datagramProcessingThread->setObjectName("Datagram Processor Thread"); // create an AudioMixerDatagramProcessor and move it to that thread AudioMixerDatagramProcessor* datagramProcessor = new AudioMixerDatagramProcessor(nodeList->getNodeSocket(), thread()); diff --git a/assignment-client/src/octree/OctreeServer.cpp b/assignment-client/src/octree/OctreeServer.cpp index aaf37c2beb..85d4749b27 100644 --- a/assignment-client/src/octree/OctreeServer.cpp +++ b/assignment-client/src/octree/OctreeServer.cpp @@ -879,6 +879,7 @@ void OctreeServer::setupDatagramProcessingThread() { // setup a QThread with us as parent that will house the OctreeServerDatagramProcessor _datagramProcessingThread = new QThread(this); + _datagramProcessingThread->setObjectName("Octree Datagram Processor"); // create an OctreeServerDatagramProcessor and move it to that thread OctreeServerDatagramProcessor* datagramProcessor = new OctreeServerDatagramProcessor(nodeList->getNodeSocket(), thread()); diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 8f31872437..f712899afa 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -281,6 +281,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : _runningScriptsWidget = new RunningScriptsWidget(_window); // start the nodeThread so its event loop is running + _nodeThread->setObjectName("Datagram Processor Thread"); _nodeThread->start(); // make sure the node thread is given highest priority @@ -295,6 +296,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : // put the audio processing on a separate thread QThread* audioThread = new QThread(this); + audioThread->setObjectName("Audio Thread"); auto audioIO = DependencyManager::get