From c34cd996dfe7ae8763f900b8d8d5dab23e3afd49 Mon Sep 17 00:00:00 2001 From: Kasen IO Date: Tue, 17 Dec 2019 00:03:59 +0100 Subject: [PATCH 01/21] change Metaverse API from setting --- assignment-client/src/avatars/MixerAvatar.cpp | 3 +- .../src/entities/EntityServer.cpp | 1 + domain-server/src/DomainServer.cpp | 9 +++-- ice-server/src/IceServer.cpp | 3 +- interface/src/Application.cpp | 5 ++- interface/src/commerce/Ledger.cpp | 16 ++++++-- interface/src/commerce/QmlCommerce.cpp | 4 +- interface/src/networking/CloseEventSender.cpp | 3 +- interface/src/ui/AddressBarDialog.h | 3 +- .../ui/overlays/ContextOverlayInterface.cpp | 3 +- .../src/RenderableWebEntityItem.cpp | 1 + libraries/entities/src/EntityItem.cpp | 3 +- libraries/entities/src/EntityTree.cpp | 5 ++- .../src/material-networking/TextureCache.cpp | 5 ++- libraries/networking/src/AccountManager.h | 5 ++- libraries/networking/src/AssetUtils.cpp | 1 + libraries/networking/src/DomainHandler.h | 1 + .../networking/src/FileResourceRequest.cpp | 1 + libraries/networking/src/MetaverseAPI.cpp | 38 +++++++++++++++++++ libraries/networking/src/MetaverseAPI.h | 22 +++++++++++ .../networking/src/NetworkingConstants.cpp | 24 ------------ .../networking/src/NetworkingConstants.h | 5 +-- .../src/OAuthNetworkAccessManager.cpp | 3 +- .../procedural/src/procedural/Procedural.cpp | 1 + libraries/qml/src/qml/OffscreenSurface.cpp | 1 + .../script-engine/src/XMLHttpRequestClass.cpp | 5 ++- libraries/ui/src/ui/types/RequestFilters.cpp | 3 +- tools/ac-client/src/ACClientApp.cpp | 3 +- tools/atp-client/src/ATPClientApp.cpp | 3 +- 29 files changed, 123 insertions(+), 57 deletions(-) create mode 100644 libraries/networking/src/MetaverseAPI.cpp create mode 100644 libraries/networking/src/MetaverseAPI.h delete mode 100644 libraries/networking/src/NetworkingConstants.cpp diff --git a/assignment-client/src/avatars/MixerAvatar.cpp b/assignment-client/src/avatars/MixerAvatar.cpp index 5203d25af6..f3d7bb8995 100644 --- a/assignment-client/src/avatars/MixerAvatar.cpp +++ b/assignment-client/src/avatars/MixerAvatar.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include "ClientTraitsHandler.h" @@ -235,7 +236,7 @@ void MixerAvatar::requestCurrentOwnership() { QNetworkRequest networkRequest; networkRequest.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true); networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json"); - QUrl requestURL = NetworkingConstants::METAVERSE_SERVER_URL(); + QUrl requestURL = MetaverseAPI::getCurrentMetaverseServerURL(); requestURL.setPath(POP_MARKETPLACE_API); networkRequest.setUrl(requestURL); diff --git a/assignment-client/src/entities/EntityServer.cpp b/assignment-client/src/entities/EntityServer.cpp index 6bbf4a0e3b..a6ab382781 100644 --- a/assignment-client/src/entities/EntityServer.cpp +++ b/assignment-client/src/entities/EntityServer.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include "../AssignmentDynamicFactory.h" diff --git a/domain-server/src/DomainServer.cpp b/domain-server/src/DomainServer.cpp index ceb4679137..a9bc24c483 100644 --- a/domain-server/src/DomainServer.cpp +++ b/domain-server/src/DomainServer.cpp @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -121,7 +122,7 @@ bool DomainServer::forwardMetaverseAPIRequest(HTTPConnection* connection, root.insert(requestSubobjectKey, subobject); QJsonDocument doc { root }; - QUrl url { NetworkingConstants::METAVERSE_SERVER_URL().toString() + metaversePath }; + QUrl url{ MetaverseAPI::getCurrentMetaverseServerURL().toString() + metaversePath }; QNetworkRequest req(url); req.setHeader(QNetworkRequest::UserAgentHeader, HIGH_FIDELITY_USER_AGENT); @@ -516,7 +517,7 @@ bool DomainServer::optionallySetupOAuth() { // if we don't have an oauth provider URL then we default to the default node auth url if (_oauthProviderURL.isEmpty()) { - _oauthProviderURL = NetworkingConstants::METAVERSE_SERVER_URL(); + _oauthProviderURL = MetaverseAPI::getCurrentMetaverseServerURL(); } _oauthClientSecret = QProcessEnvironment::systemEnvironment().value(OAUTH_CLIENT_SECRET_ENV); @@ -2222,7 +2223,7 @@ bool DomainServer::handleHTTPRequest(HTTPConnection* connection, const QUrl& url return true; } else if (url.path() == URI_API_METAVERSE_INFO) { QJsonObject rootJSON { - { "metaverse_url", NetworkingConstants::METAVERSE_SERVER_URL().toString() } + { "metaverse_url", MetaverseAPI::getCurrentMetaverseServerURL().toString() } }; QJsonDocument docJSON{ rootJSON }; @@ -2449,7 +2450,7 @@ bool DomainServer::handleHTTPRequest(HTTPConnection* connection, const QUrl& url QJsonDocument doc(root); - QUrl url { NetworkingConstants::METAVERSE_SERVER_URL().toString() + "/api/v1/places/" + place_id }; + QUrl url { MetaverseAPI::getCurrentMetaverseServerURL().toString() + "/api/v1/places/" + place_id }; url.setQuery("access_token=" + accessTokenVariant.toString()); diff --git a/ice-server/src/IceServer.cpp b/ice-server/src/IceServer.cpp index 6896c7a9c9..2d601048be 100644 --- a/ice-server/src/IceServer.cpp +++ b/ice-server/src/IceServer.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -209,7 +210,7 @@ void IceServer::requestDomainPublicKey(const QUuid& domainID) { // send a request to the metaverse API for the public key for this domain auto& networkAccessManager = NetworkAccessManager::getInstance(); - QUrl publicKeyURL { NetworkingConstants::METAVERSE_SERVER_URL() }; + QUrl publicKeyURL{ MetaverseAPI::getCurrentMetaverseServerURL() }; QString publicKeyPath = QString("/api/v1/domains/%1/public_key").arg(uuidStringWithoutCurlyBraces(domainID)); publicKeyURL.setPath(publicKeyPath); diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 9c60139d06..3eb83afe73 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -111,6 +111,7 @@ #include #include #include +#include #include #include #include @@ -1216,7 +1217,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo // set the account manager's root URL and trigger a login request if we don't have the access token accountManager->setIsAgent(true); - accountManager->setAuthURL(NetworkingConstants::METAVERSE_SERVER_URL()); + accountManager->setAuthURL(MetaverseAPI::getCurrentMetaverseServerURL()); if (!accountManager->hasKeyPair()) { accountManager->generateNewUserKeypair(); } @@ -8466,7 +8467,7 @@ void Application::loadAddAvatarBookmarkDialog() const { void Application::loadAvatarBrowser() const { auto tablet = dynamic_cast(DependencyManager::get()->getTablet("com.highfidelity.interface.tablet.system")); // construct the url to the marketplace item - QString url = NetworkingConstants::METAVERSE_SERVER_URL().toString() + "/marketplace?category=avatars"; + QString url = MetaverseAPI::getCurrentMetaverseServerURL().toString() + "/marketplace?category=avatars"; QString MARKETPLACES_INJECT_SCRIPT_PATH = "file:///" + qApp->applicationDirPath() + "/scripts/system/html/js/marketplacesInject.js"; tablet->gotoWebScreen(url, MARKETPLACES_INJECT_SCRIPT_PATH); diff --git a/interface/src/commerce/Ledger.cpp b/interface/src/commerce/Ledger.cpp index 60fefa5878..4a41374ba3 100644 --- a/interface/src/commerce/Ledger.cpp +++ b/interface/src/commerce/Ledger.cpp @@ -17,6 +17,7 @@ #include #include +#include #include #include "Wallet.h" @@ -181,21 +182,28 @@ QString hfcString(const QJsonValue& sentValue, const QJsonValue& receivedValue) } return result; } -static const QString USER_PAGE_BASE_URL = NetworkingConstants::METAVERSE_SERVER_URL().toString() + "/users/"; -static const QString PLACE_PAGE_BASE_URL = NetworkingConstants::METAVERSE_SERVER_URL().toString() + "/places/"; + +QString getUserPageBaseUrl() { + return MetaverseAPI::getCurrentMetaverseServerURL().toString() + "/users/"; +} + +QString getPlacePageBaseUrl() { + return MetaverseAPI::getCurrentMetaverseServerURL().toString() + "/places/"; +} + static const QStringList KNOWN_USERS(QStringList() << "highfidelity" << "marketplace"); QString userLink(const QString& username, const QString& placename) { if (username.isEmpty()) { if (placename.isEmpty()) { return QString("someone"); } else { - return QString("someone nearby").arg(PLACE_PAGE_BASE_URL, placename); + return QString("someone nearby").arg(getPlacePageBaseUrl(), placename); } } if (KNOWN_USERS.contains(username)) { return username; } - return QString("%2").arg(USER_PAGE_BASE_URL, username); + return QString("%2").arg(getUserPageBaseUrl(), username); } QString transactionString(const QJsonObject& valueObject) { diff --git a/interface/src/commerce/QmlCommerce.cpp b/interface/src/commerce/QmlCommerce.cpp index c8ea044f4b..47105e0f3a 100644 --- a/interface/src/commerce/QmlCommerce.cpp +++ b/interface/src/commerce/QmlCommerce.cpp @@ -72,11 +72,11 @@ void QmlCommerce::openSystemApp(const QString& appName) { else if (appPathIter->contains(".html", Qt::CaseInsensitive)) { QMap::const_iterator injectIter = systemInject.find(appName); if (appPathIter == systemInject.end()) { - tablet->gotoWebScreen(NetworkingConstants::METAVERSE_SERVER_URL().toString() + *appPathIter); + tablet->gotoWebScreen(MetaverseAPI::getCurrentMetaverseServerURL().toString() + *appPathIter); } else { QString inject = "file:///" + qApp->applicationDirPath() + *injectIter; - tablet->gotoWebScreen(NetworkingConstants::METAVERSE_SERVER_URL().toString() + *appPathIter, inject); + tablet->gotoWebScreen(MetaverseAPI::getCurrentMetaverseServerURL().toString() + *appPathIter, inject); } } else { diff --git a/interface/src/networking/CloseEventSender.cpp b/interface/src/networking/CloseEventSender.cpp index 16549d5510..5397c221ad 100644 --- a/interface/src/networking/CloseEventSender.cpp +++ b/interface/src/networking/CloseEventSender.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -28,7 +29,7 @@ QNetworkRequest createNetworkRequest() { QNetworkRequest request; - QUrl requestURL = NetworkingConstants::METAVERSE_SERVER_URL(); + QUrl requestURL = MetaverseAPI::getCurrentMetaverseServerURL(); requestURL.setPath(USER_ACTIVITY_URL); request.setUrl(requestURL); diff --git a/interface/src/ui/AddressBarDialog.h b/interface/src/ui/AddressBarDialog.h index 1254fabbd2..aa3c11e810 100644 --- a/interface/src/ui/AddressBarDialog.h +++ b/interface/src/ui/AddressBarDialog.h @@ -15,6 +15,7 @@ #include #include +#include class AddressBarDialog : public OffscreenQmlDialog { Q_OBJECT @@ -30,7 +31,7 @@ public: bool forwardEnabled() { return _forwardEnabled; } bool useFeed() { return _useFeed; } void setUseFeed(bool useFeed) { if (_useFeed != useFeed) { _useFeed = useFeed; emit useFeedChanged(); } } - QString metaverseServerUrl() { return NetworkingConstants::METAVERSE_SERVER_URL().toString(); } + QString metaverseServerUrl() { return MetaverseAPI::getCurrentMetaverseServerURL().toString(); } signals: void backEnabledChanged(); diff --git a/interface/src/ui/overlays/ContextOverlayInterface.cpp b/interface/src/ui/overlays/ContextOverlayInterface.cpp index 1c8a9019ea..0f1c8978f0 100644 --- a/interface/src/ui/overlays/ContextOverlayInterface.cpp +++ b/interface/src/ui/overlays/ContextOverlayInterface.cpp @@ -14,6 +14,7 @@ #include #include +#include #include #include #include @@ -305,7 +306,7 @@ void ContextOverlayInterface::requestOwnershipVerification(const QUuid& entityID QNetworkRequest networkRequest; networkRequest.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true); networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json"); - QUrl requestURL = NetworkingConstants::METAVERSE_SERVER_URL(); + QUrl requestURL = MetaverseAPI::getCurrentMetaverseServerURL(); requestURL.setPath("/api/v1/commerce/proof_of_purchase_status/transfer"); QJsonObject request; request["certificate_id"] = entityProperties.getCertificateID(); diff --git a/libraries/entities-renderer/src/RenderableWebEntityItem.cpp b/libraries/entities-renderer/src/RenderableWebEntityItem.cpp index b1feddfd47..1da4999bad 100644 --- a/libraries/entities-renderer/src/RenderableWebEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableWebEntityItem.cpp @@ -28,6 +28,7 @@ #include "EntitiesRendererLogging.h" #include +#include using namespace render; using namespace render::entities; diff --git a/libraries/entities/src/EntityItem.cpp b/libraries/entities/src/EntityItem.cpp index 598ac17510..fbbfc8b626 100644 --- a/libraries/entities/src/EntityItem.cpp +++ b/libraries/entities/src/EntityItem.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -3207,7 +3208,7 @@ void EntityItem::retrieveMarketplacePublicKey() { QNetworkAccessManager& networkAccessManager = NetworkAccessManager::getInstance(); QNetworkRequest networkRequest; networkRequest.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true); - QUrl requestURL = NetworkingConstants::METAVERSE_SERVER_URL(); + QUrl requestURL = MetaverseAPI::getCurrentMetaverseServerURL(); requestURL.setPath("/api/v1/commerce/marketplace_key"); QJsonObject request; networkRequest.setUrl(requestURL); diff --git a/libraries/entities/src/EntityTree.cpp b/libraries/entities/src/EntityTree.cpp index 6c12c6d019..a7416eac79 100644 --- a/libraries/entities/src/EntityTree.cpp +++ b/libraries/entities/src/EntityTree.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include "AccountManager.h" #include #include @@ -1464,7 +1465,7 @@ void EntityTree::startDynamicDomainVerificationOnServer(float minimumAgeToRemove QNetworkRequest networkRequest; networkRequest.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true); networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json"); - QUrl requestURL = NetworkingConstants::METAVERSE_SERVER_URL(); + QUrl requestURL = MetaverseAPI::getCurrentMetaverseServerURL(); requestURL.setPath("/api/v1/commerce/proof_of_purchase_status/location"); QJsonObject request; request["certificate_id"] = certificateID; @@ -1687,7 +1688,7 @@ void EntityTree::validatePop(const QString& certID, const EntityItemID& entityIt QNetworkRequest networkRequest; networkRequest.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true); networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json"); - QUrl requestURL = NetworkingConstants::METAVERSE_SERVER_URL(); + QUrl requestURL = MetaverseAPI::getCurrentMetaverseServerURL(); requestURL.setPath("/api/v1/commerce/proof_of_purchase_status/transfer"); QJsonObject request; request["certificate_id"] = certID; diff --git a/libraries/material-networking/src/material-networking/TextureCache.cpp b/libraries/material-networking/src/material-networking/TextureCache.cpp index 8ffcad0c69..4831223fe9 100644 --- a/libraries/material-networking/src/material-networking/TextureCache.cpp +++ b/libraries/material-networking/src/material-networking/TextureCache.cpp @@ -43,9 +43,10 @@ #include #include -#include "NetworkLogging.h" +#include #include "MaterialNetworkingLogging.h" -#include "NetworkingConstants.h" +#include +#include #include #include diff --git a/libraries/networking/src/AccountManager.h b/libraries/networking/src/AccountManager.h index 2e94ccf0ea..37cb548b7e 100644 --- a/libraries/networking/src/AccountManager.h +++ b/libraries/networking/src/AccountManager.h @@ -24,8 +24,9 @@ #include "AccountSettings.h" #include "DataServerAccountInfo.h" #include "NetworkingConstants.h" +#include "MetaverseAPI.h" #include "NetworkAccessManager.h" -#include "SharedUtil.h" +#include class JSONCallbackParameters { public: @@ -97,7 +98,7 @@ public: void setTemporaryDomain(const QUuid& domainID, const QString& key); const QString& getTemporaryDomainKey(const QUuid& domainID) { return _accountInfo.getTemporaryDomainKey(domainID); } - QUrl getMetaverseServerURL() { return NetworkingConstants::METAVERSE_SERVER_URL(); } + QUrl getMetaverseServerURL() { return MetaverseAPI::getCurrentMetaverseServerURL(); } void removeAccountFromFile(); diff --git a/libraries/networking/src/AssetUtils.cpp b/libraries/networking/src/AssetUtils.cpp index 6fb914a8b2..b0eb19bb73 100644 --- a/libraries/networking/src/AssetUtils.cpp +++ b/libraries/networking/src/AssetUtils.cpp @@ -21,6 +21,7 @@ #include "NetworkAccessManager.h" #include "NetworkLogging.h" #include "NetworkingConstants.h" +#include "MetaverseAPI.h" #include "ResourceManager.h" diff --git a/libraries/networking/src/DomainHandler.h b/libraries/networking/src/DomainHandler.h index fb18866001..27dd7cd95d 100644 --- a/libraries/networking/src/DomainHandler.h +++ b/libraries/networking/src/DomainHandler.h @@ -29,6 +29,7 @@ #include "Node.h" #include "ReceivedMessage.h" #include "NetworkingConstants.h" +#include "MetaverseAPI.h" const unsigned short DEFAULT_DOMAIN_SERVER_PORT = 40102; const unsigned short DEFAULT_DOMAIN_SERVER_DTLS_PORT = 40103; diff --git a/libraries/networking/src/FileResourceRequest.cpp b/libraries/networking/src/FileResourceRequest.cpp index 11489f13bd..f9ec7797be 100644 --- a/libraries/networking/src/FileResourceRequest.cpp +++ b/libraries/networking/src/FileResourceRequest.cpp @@ -22,6 +22,7 @@ #include "NetworkLogging.h" #include "ResourceManager.h" #include "NetworkingConstants.h" +#include "MetaverseAPI.h" void FileResourceRequest::doSend() { auto statTracker = DependencyManager::get(); diff --git a/libraries/networking/src/MetaverseAPI.cpp b/libraries/networking/src/MetaverseAPI.cpp new file mode 100644 index 0000000000..0fb0bcecad --- /dev/null +++ b/libraries/networking/src/MetaverseAPI.cpp @@ -0,0 +1,38 @@ +// +// MetaverseAPI.cpp +// libraries/networking/src +// +// Created by Kalila (kasenvr) on 2019-12-16. +// Copyright 2019 Project Athena +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#include "MetaverseAPI.h" + +#include +#include +#include "NetworkingConstants.h" +#include + + +namespace MetaverseAPI { + // You can change the return of this function if you want to use a custom metaverse URL at compile time + // or you can pass a custom URL via the env variable + QUrl getCurrentMetaverseServerURL() { + QUrl selectedMetaverseURL; + Setting::Handle selectedMetaverseURLSetting("private/selectedMetaverseURL", + NetworkingConstants::METAVERSE_SERVER_URL_STABLE); + + selectedMetaverseURL = selectedMetaverseURLSetting.get(); + + const QString HIFI_METAVERSE_URL_ENV = "HIFI_METAVERSE_URL"; + + if (QProcessEnvironment::systemEnvironment().contains(HIFI_METAVERSE_URL_ENV)) { + return QUrl(QProcessEnvironment::systemEnvironment().value(HIFI_METAVERSE_URL_ENV)); + } + + return selectedMetaverseURL; + }; +} diff --git a/libraries/networking/src/MetaverseAPI.h b/libraries/networking/src/MetaverseAPI.h new file mode 100644 index 0000000000..423f465229 --- /dev/null +++ b/libraries/networking/src/MetaverseAPI.h @@ -0,0 +1,22 @@ +// +// MetaverseAPI.h +// libraries/networking/src +// +// Created by Kalila (kasenvr) on 2019-12-16. +// Copyright 2019 Project Athena +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#ifndef athena_MetaverseAPI_h +#define athena_MetaverseAPI_h + +#include +#include + +namespace MetaverseAPI { + QUrl getCurrentMetaverseServerURL(); +} + +#endif // athena_MetaverseAPI_h diff --git a/libraries/networking/src/NetworkingConstants.cpp b/libraries/networking/src/NetworkingConstants.cpp deleted file mode 100644 index 622c307efa..0000000000 --- a/libraries/networking/src/NetworkingConstants.cpp +++ /dev/null @@ -1,24 +0,0 @@ -// -// NetworkingConstants.cpp -// libraries/networking/src -// -// Created by Seth Alves on 2018-2-28. -// Copyright 2018 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -#include "NetworkingConstants.h" - -namespace NetworkingConstants { - // You can change the return of this function if you want to use a custom metaverse URL at compile time - // or you can pass a custom URL via the env variable - QUrl METAVERSE_SERVER_URL() { - const QString HIFI_METAVERSE_URL_ENV = "HIFI_METAVERSE_URL"; - const QUrl serverURL = QProcessEnvironment::systemEnvironment().contains(HIFI_METAVERSE_URL_ENV) - ? QUrl(QProcessEnvironment::systemEnvironment().value(HIFI_METAVERSE_URL_ENV)) - : METAVERSE_SERVER_URL_STABLE; - return serverURL; - }; -} diff --git a/libraries/networking/src/NetworkingConstants.h b/libraries/networking/src/NetworkingConstants.h index 117a41c976..d5dae658c9 100644 --- a/libraries/networking/src/NetworkingConstants.h +++ b/libraries/networking/src/NetworkingConstants.h @@ -25,9 +25,8 @@ namespace NetworkingConstants { // if you manually generate a personal access token for the domains scope // at https://staging.highfidelity.com/user/tokens/new?for_domain_server=true - const QUrl METAVERSE_SERVER_URL_STABLE { "https://metaverse.highfidelity.com" }; - const QUrl METAVERSE_SERVER_URL_STAGING { "https://staging.highfidelity.com" }; - QUrl METAVERSE_SERVER_URL(); + const QUrl METAVERSE_SERVER_URL_STABLE { "https://metaverse.projectathena.io" }; + const QUrl METAVERSE_SERVER_URL_STAGING { "https://staging.projectathena.io" }; } const QString HIFI_URL_SCHEME_ABOUT = "about"; diff --git a/libraries/networking/src/OAuthNetworkAccessManager.cpp b/libraries/networking/src/OAuthNetworkAccessManager.cpp index 272ff47a49..b1e04da4b6 100644 --- a/libraries/networking/src/OAuthNetworkAccessManager.cpp +++ b/libraries/networking/src/OAuthNetworkAccessManager.cpp @@ -18,6 +18,7 @@ #include "AccountManager.h" #include "LimitedNodeList.h" #include "NetworkingConstants.h" +#include "MetaverseAPI.h" #include "SharedUtil.h" QThreadStorage oauthNetworkAccessManagers; @@ -35,7 +36,7 @@ QNetworkReply* OAuthNetworkAccessManager::createRequest(QNetworkAccessManager::O auto accountManager = DependencyManager::get(); if (accountManager->hasValidAccessToken() - && req.url().host() == NetworkingConstants::METAVERSE_SERVER_URL().host()) { + && req.url().host() == MetaverseAPI::getCurrentMetaverseServerURL().host()) { QNetworkRequest authenticatedRequest(req); authenticatedRequest.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true); authenticatedRequest.setHeader(QNetworkRequest::UserAgentHeader, HIGH_FIDELITY_USER_AGENT); diff --git a/libraries/procedural/src/procedural/Procedural.cpp b/libraries/procedural/src/procedural/Procedural.cpp index 43c6b25dcb..10f46f8efd 100644 --- a/libraries/procedural/src/procedural/Procedural.cpp +++ b/libraries/procedural/src/procedural/Procedural.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include "ShaderConstants.h" diff --git a/libraries/qml/src/qml/OffscreenSurface.cpp b/libraries/qml/src/qml/OffscreenSurface.cpp index d9fc8117bd..2678cb5591 100644 --- a/libraries/qml/src/qml/OffscreenSurface.cpp +++ b/libraries/qml/src/qml/OffscreenSurface.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include "Logging.h" #include "impl/SharedObject.h" diff --git a/libraries/script-engine/src/XMLHttpRequestClass.cpp b/libraries/script-engine/src/XMLHttpRequestClass.cpp index 571c0e2a0e..e62726f5d0 100644 --- a/libraries/script-engine/src/XMLHttpRequestClass.cpp +++ b/libraries/script-engine/src/XMLHttpRequestClass.cpp @@ -20,12 +20,11 @@ #include #include #include +#include #include "ResourceRequestObserver.h" #include "ScriptEngine.h" -const QString METAVERSE_API_URL = NetworkingConstants::METAVERSE_SERVER_URL().toString() + "/api/"; - Q_DECLARE_METATYPE(QByteArray*) XMLHttpRequestClass::XMLHttpRequestClass(QScriptEngine* engine) : @@ -126,6 +125,8 @@ void XMLHttpRequestClass::open(const QString& method, const QString& url, bool a _url.setUrl(url); _async = async; + const QString METAVERSE_API_URL = MetaverseAPI::getCurrentMetaverseServerURL().toString() + "/api/"; + if (url.toLower().left(METAVERSE_API_URL.length()) == METAVERSE_API_URL) { auto accountManager = DependencyManager::get(); diff --git a/libraries/ui/src/ui/types/RequestFilters.cpp b/libraries/ui/src/ui/types/RequestFilters.cpp index 3fa1cd0bd9..14fcc7a781 100644 --- a/libraries/ui/src/ui/types/RequestFilters.cpp +++ b/libraries/ui/src/ui/types/RequestFilters.cpp @@ -16,6 +16,7 @@ #include #include +#include #include #include "ContextAwareProfile.h" @@ -25,7 +26,7 @@ namespace { bool isAuthableHighFidelityURL(const QUrl& url) { - auto metaverseServerURL = NetworkingConstants::METAVERSE_SERVER_URL(); + auto metaverseServerURL = MetaverseAPI::getCurrentMetaverseServerURL(); static const QStringList HF_HOSTS = { "highfidelity.com", "highfidelity.io", metaverseServerURL.toString(), "metaverse.highfidelity.io" diff --git a/tools/ac-client/src/ACClientApp.cpp b/tools/ac-client/src/ACClientApp.cpp index 24805a3348..3b5db1a1b1 100644 --- a/tools/ac-client/src/ACClientApp.cpp +++ b/tools/ac-client/src/ACClientApp.cpp @@ -18,6 +18,7 @@ #include #include +#include #include #include #include @@ -106,7 +107,7 @@ ACClientApp::ACClientApp(int argc, char* argv[]) : auto accountManager = DependencyManager::get(); accountManager->setIsAgent(true); - accountManager->setAuthURL(NetworkingConstants::METAVERSE_SERVER_URL()); + accountManager->setAuthURL(MetaverseAPI::getCurrentMetaverseServerURL()); auto nodeList = DependencyManager::get(); diff --git a/tools/atp-client/src/ATPClientApp.cpp b/tools/atp-client/src/ATPClientApp.cpp index b2e7db5c87..09fcf38dff 100644 --- a/tools/atp-client/src/ATPClientApp.cpp +++ b/tools/atp-client/src/ATPClientApp.cpp @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -144,7 +145,7 @@ ATPClientApp::ATPClientApp(int argc, char* argv[]) : auto accountManager = DependencyManager::get(); accountManager->setIsAgent(true); - accountManager->setAuthURL(NetworkingConstants::METAVERSE_SERVER_URL()); + accountManager->setAuthURL(MetaverseAPI::getCurrentMetaverseServerURL()); auto nodeList = DependencyManager::get(); From 0ac8c178db8d5e15c3d5be87de466ee4c8e507a2 Mon Sep 17 00:00:00 2001 From: Thijs Wenker Date: Fri, 20 Dec 2019 12:43:43 +0100 Subject: [PATCH 02/21] fix spacing --- libraries/ui/src/ui/types/RequestFilters.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/ui/src/ui/types/RequestFilters.cpp b/libraries/ui/src/ui/types/RequestFilters.cpp index 14fcc7a781..943dd02c29 100644 --- a/libraries/ui/src/ui/types/RequestFilters.cpp +++ b/libraries/ui/src/ui/types/RequestFilters.cpp @@ -26,7 +26,7 @@ namespace { bool isAuthableHighFidelityURL(const QUrl& url) { - auto metaverseServerURL = MetaverseAPI::getCurrentMetaverseServerURL(); + auto metaverseServerURL = MetaverseAPI::getCurrentMetaverseServerURL(); static const QStringList HF_HOSTS = { "highfidelity.com", "highfidelity.io", metaverseServerURL.toString(), "metaverse.highfidelity.io" From 82bddeb5a7bae0aee6af41a1971d041e436d3280 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Fri, 22 Nov 2019 11:35:23 -0800 Subject: [PATCH 03/21] fix linux build --- libraries/shared/src/shared/QtHelpers.h | 2 +- tools/nitpick/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/shared/src/shared/QtHelpers.h b/libraries/shared/src/shared/QtHelpers.h index f57ba4af2d..9a9d33a3ce 100644 --- a/libraries/shared/src/shared/QtHelpers.h +++ b/libraries/shared/src/shared/QtHelpers.h @@ -12,7 +12,7 @@ #include -#if defined(Q_OS_WIN) || defined(Q_OS_LINUX) +#if defined(Q_OS_WIN) // Enable event queue debugging #define DEBUG_EVENT_QUEUE #endif diff --git a/tools/nitpick/CMakeLists.txt b/tools/nitpick/CMakeLists.txt index a5dd8d5236..d65505415d 100644 --- a/tools/nitpick/CMakeLists.txt +++ b/tools/nitpick/CMakeLists.txt @@ -93,7 +93,7 @@ if (WIN32) set_property(TARGET ${TARGET_NAME} APPEND_STRING PROPERTY LINK_FLAGS_DEBUG "/OPT:NOREF /OPT:NOICF") endif() -link_hifi_libraries(entities-renderer platform) +link_hifi_libraries(entities-renderer platform physics) # perform standard include and linking for found externals foreach(EXTERNAL ${OPTIONAL_EXTERNALS}) From fcc1f928a125be4371b797378fd7e11cc5d577b4 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Mon, 6 Jan 2020 10:58:49 +1300 Subject: [PATCH 04/21] Lint --- scripts/system/inspect.js | 51 ++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/scripts/system/inspect.js b/scripts/system/inspect.js index 18b26ab709..233517dd64 100644 --- a/scripts/system/inspect.js +++ b/scripts/system/inspect.js @@ -160,7 +160,7 @@ function restoreCameraState() { } function handleModes() { - var newMode = (mode == noMode) ? noMode : detachedMode; + var newMode = (mode === noMode) ? noMode : detachedMode; if (alt) { if (control) { if (shift) { @@ -174,32 +174,32 @@ function handleModes() { } // if entering detachMode - if (newMode == detachedMode && mode != detachedMode) { + if (newMode === detachedMode && mode !== detachedMode) { avatarPosition = MyAvatar.position; avatarOrientation = MyAvatar.orientation; } // if leaving detachMode - if (mode == detachedMode && newMode == detachedMode && - (avatarPosition.x != MyAvatar.position.x || - avatarPosition.y != MyAvatar.position.y || - avatarPosition.z != MyAvatar.position.z || - avatarOrientation.x != MyAvatar.orientation.x || - avatarOrientation.y != MyAvatar.orientation.y || - avatarOrientation.z != MyAvatar.orientation.z || - avatarOrientation.w != MyAvatar.orientation.w)) { + if (mode === detachedMode && newMode === detachedMode && + (avatarPosition.x !== MyAvatar.position.x || + avatarPosition.y !== MyAvatar.position.y || + avatarPosition.z !== MyAvatar.position.z || + avatarOrientation.x !== MyAvatar.orientation.x || + avatarOrientation.y !== MyAvatar.orientation.y || + avatarOrientation.z !== MyAvatar.orientation.z || + avatarOrientation.w !== MyAvatar.orientation.w)) { newMode = noMode; } - if (mode == noMode && newMode != noMode && Camera.mode == "independent") { + if (mode === noMode && newMode !== noMode && Camera.mode === "independent") { newMode = noMode; } // if leaving noMode - if (mode == noMode && newMode != noMode) { + if (mode === noMode && newMode !== noMode) { saveCameraState(); } // if entering noMode - if (newMode == noMode && mode != noMode) { + if (newMode === noMode && mode !== noMode) { restoreCameraState(); } @@ -209,15 +209,15 @@ function handleModes() { function keyPressEvent(event) { var changed = false; - if (event.text == "ALT") { + if (event.text === "ALT") { alt = true; changed = true; } - if (event.text == "CONTROL") { + if (event.text === "CONTROL") { control = true; changed = true; } - if (event.text == "SHIFT") { + if (event.text === "SHIFT") { shift = true; changed = true; } @@ -230,17 +230,17 @@ function keyPressEvent(event) { function keyReleaseEvent(event) { var changed = false; - if (event.text == "ALT") { + if (event.text === "ALT") { alt = false; changed = true; mode = noMode; restoreCameraState(); } - if (event.text == "CONTROL") { + if (event.text === "CONTROL") { control = false; changed = true; } - if (event.text == "SHIFT") { + if (event.text === "SHIFT") { shift = false; changed = true; } @@ -293,14 +293,14 @@ function mouseReleaseEvent(event) { } function mouseMoveEvent(event) { - if (isActive && mode != noMode && !rotatingTowardsTarget) { - if (mode == radialMode) { + if (isActive && mode !== noMode && !rotatingTowardsTarget) { + if (mode === radialMode) { handleRadialMode(event.x - mouseLastX, event.y - mouseLastY); } - if (mode == orbitMode) { + if (mode === orbitMode) { handleOrbitMode(event.x - mouseLastX, event.y - mouseLastY); } - if (mode == panningMode) { + if (mode === panningMode) { handlePanMode(event.x - mouseLastX, event.y - mouseLastY); } } @@ -316,12 +316,13 @@ function update() { } function rotateTowardsTarget() { - var newOrientation = Quat.mix(Camera.getOrientation(), targetCamOrientation, 0.1); + var MIX_FACTOR = 0.1; + var newOrientation = Quat.mix(Camera.getOrientation(), targetCamOrientation, MIX_FACTOR); Camera.setOrientation(newOrientation); } function scriptEnding() { - if (mode != noMode) { + if (mode !== noMode) { restoreCameraState(); } } From ac34d49c1b50e8936e638bfeca9ac442b76a8078 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Mon, 6 Jan 2020 11:04:23 +1300 Subject: [PATCH 05/21] Leave camera where it is after releasing Alt key --- scripts/system/inspect.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/scripts/system/inspect.js b/scripts/system/inspect.js index 233517dd64..b7ed987acd 100644 --- a/scripts/system/inspect.js +++ b/scripts/system/inspect.js @@ -233,8 +233,6 @@ function keyReleaseEvent(event) { if (event.text === "ALT") { alt = false; changed = true; - mode = noMode; - restoreCameraState(); } if (event.text === "CONTROL") { control = false; From 81e1dd4d6a1babdf6649a9a55fb6aa02043a1b96 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Mon, 6 Jan 2020 11:10:10 +1300 Subject: [PATCH 06/21] Exit inspect mode when press Esc or move avatar --- scripts/system/inspect.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/system/inspect.js b/scripts/system/inspect.js index b7ed987acd..90a84c514b 100644 --- a/scripts/system/inspect.js +++ b/scripts/system/inspect.js @@ -222,6 +222,12 @@ function keyPressEvent(event) { changed = true; } + if (mode !== noMode && !alt && !control && !shift && /^ESC|LEFT|RIGHT|UP|DOWN|[wasdWASD]$/.test(event.text)) { + mode = noMode; + restoreCameraState(); + changed = true; + } + if (changed) { handleModes(); } From a1056f34ed540a9ad9b6ff4f3fb21a3ccd436741 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Mon, 6 Jan 2020 11:14:12 +1300 Subject: [PATCH 07/21] Cope with slight avatar position and orientation jitter when stationary --- scripts/system/inspect.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/scripts/system/inspect.js b/scripts/system/inspect.js index 90a84c514b..c84cdef5c3 100644 --- a/scripts/system/inspect.js +++ b/scripts/system/inspect.js @@ -25,6 +25,9 @@ var ALTITUDE_RATE = 200.0; var RADIUS_RATE = 1.0 / 100.0; var PAN_RATE = 250.0; +var AVATAR_POSITION_SLOP = 0.1; +var AVATAR_ROTATION_SLOP = 0.09; // 5 degrees + var Y_AXIS = { x: 0, y: 1, @@ -179,14 +182,10 @@ function handleModes() { avatarOrientation = MyAvatar.orientation; } // if leaving detachMode - if (mode === detachedMode && newMode === detachedMode && - (avatarPosition.x !== MyAvatar.position.x || - avatarPosition.y !== MyAvatar.position.y || - avatarPosition.z !== MyAvatar.position.z || - avatarOrientation.x !== MyAvatar.orientation.x || - avatarOrientation.y !== MyAvatar.orientation.y || - avatarOrientation.z !== MyAvatar.orientation.z || - avatarOrientation.w !== MyAvatar.orientation.w)) { + if (mode === detachedMode && newMode === detachedMode && ( + Vec3.length(Vec3.subtract(avatarPosition, MyAvatar.position)) > AVATAR_POSITION_SLOP + || Vec3.length(Vec3.subtract(Quat.getFront(avatarOrientation), Quat.getFront(MyAvatar.orientation))) + > AVATAR_ROTATION_SLOP)) { newMode = noMode; } From 31b76a0a22d1200439cccef3383b4f926f0dddaf Mon Sep 17 00:00:00 2001 From: David Rowe Date: Mon, 6 Jan 2020 11:25:39 +1300 Subject: [PATCH 08/21] Don't go "away" when press Esc key while inspecting --- scripts/system/inspect.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/system/inspect.js b/scripts/system/inspect.js index c84cdef5c3..30f9e1c2df 100644 --- a/scripts/system/inspect.js +++ b/scripts/system/inspect.js @@ -203,6 +203,10 @@ function handleModes() { } mode = newMode; + + // Don't go "away" when press Esc key while inspecting. + var CHANNEL_AWAY_ENABLE = "Hifi-Away-Enable"; + Messages.sendMessage(CHANNEL_AWAY_ENABLE, mode === noMode ? "enable" : "disable" , true); } function keyPressEvent(event) { From 6749239e4e87061c95922b143af506fe6101c311 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Mon, 6 Jan 2020 11:27:39 +1300 Subject: [PATCH 09/21] Reduce the duration of the initial look-at time --- scripts/system/inspect.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/system/inspect.js b/scripts/system/inspect.js index 30f9e1c2df..64c46addb5 100644 --- a/scripts/system/inspect.js +++ b/scripts/system/inspect.js @@ -39,7 +39,7 @@ var X_AXIS = { z: 0 }; -var LOOK_AT_TIME = 500; +var LOOK_AT_TIME = 100; // ms var alt = false; var shift = false; From 3857fa1a4d7858f9dd70a4ee98d2fa566cfbd967 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Mon, 6 Jan 2020 11:35:53 +1300 Subject: [PATCH 10/21] Restore "away" behavior when restart script --- scripts/system/inspect.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/scripts/system/inspect.js b/scripts/system/inspect.js index 64c46addb5..0e4be4320f 100644 --- a/scripts/system/inspect.js +++ b/scripts/system/inspect.js @@ -147,6 +147,11 @@ function handlePanMode(dx, dy) { Camera.setOrientation(orientationOf(vector)); } +function enableAway(enable) { + var CHANNEL_AWAY_ENABLE = "Hifi-Away-Enable"; + Messages.sendMessage(CHANNEL_AWAY_ENABLE, enable ? "enable" : "disable", true); +} + function saveCameraState() { oldMode = Camera.mode; oldPosition = Camera.getPosition(); @@ -204,9 +209,7 @@ function handleModes() { mode = newMode; - // Don't go "away" when press Esc key while inspecting. - var CHANNEL_AWAY_ENABLE = "Hifi-Away-Enable"; - Messages.sendMessage(CHANNEL_AWAY_ENABLE, mode === noMode ? "enable" : "disable" , true); + enableAway(mode === noMode); } function keyPressEvent(event) { @@ -331,6 +334,7 @@ function rotateTowardsTarget() { function scriptEnding() { if (mode !== noMode) { restoreCameraState(); + enableAway(true); } } From 32848ef8c6775f7a115bdaaf8811e0d50ec20009 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Mon, 6 Jan 2020 11:41:05 +1300 Subject: [PATCH 11/21] Update description of operation --- scripts/system/inspect.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/scripts/system/inspect.js b/scripts/system/inspect.js index 0e4be4320f..fc37d70331 100644 --- a/scripts/system/inspect.js +++ b/scripts/system/inspect.js @@ -5,13 +5,16 @@ // Created by Clément Brisset on March 20, 2014 // Copyright 2014 High Fidelity, Inc. // -// Allows you to inspect non moving objects (Voxels or Avatars) using Atl, Control (Command on Mac) and Shift +// Enables you to inspect entities and avatars using Alt and key combinations: +// - Alt + mouse up/down zooms in/out. +// - Alt + mouse left/right orbits left/right. +// - Alt + Ctrl + mouse up/down/left/right: orbits over / under / left / right. +// - Alt + Ctrl + Shift + mouse up/down/left/right: pans down / up / right / left. // -// radial mode = hold ALT -// orbit mode = hold ALT + CONTROL -// pan mode = hold ALT + CONTROL + SHIFT -// Once you are in a mode left click on the object to inspect and hold the click -// Dragging the mouse will move your camera according to the mode you are in. +// Your camera stays where it is when you release the Alt key, enabling you to Alt + left - click on another entity or +// avatar to further move your view. +// +// Press Esc or move your avatar to revert back to your default view. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html From 37b7a9c5f45d393d071cc76f9471d12691de4707 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Sun, 12 Jan 2020 16:26:23 +1300 Subject: [PATCH 12/21] Use Picks API and orbit about point in space if no intersection --- scripts/system/inspect.js | 59 ++++++++++++++++++++++----------------- 1 file changed, 33 insertions(+), 26 deletions(-) diff --git a/scripts/system/inspect.js b/scripts/system/inspect.js index fc37d70331..980444d247 100644 --- a/scripts/system/inspect.js +++ b/scripts/system/inspect.js @@ -59,6 +59,13 @@ var detachedMode = 4; var mode = noMode; +var pick = Picks.createPick(PickType.Ray, { + filter: Picks.PICK_DOMAIN_ENTITIES | Picks.PICK_AVATAR_ENTITIES | Picks.PICK_AVATARS + | Picks.PICK_INCLUDE_COLLIDABLE | Picks.PICK_INCLUDE_NONCOLLIDABLE | Picks.PICK_PRECISE, + joint: "Mouse", + enabled: false +}); + var mouseLastX = 0; var mouseLastY = 0; @@ -221,6 +228,7 @@ function keyPressEvent(event) { if (event.text === "ALT") { alt = true; changed = true; + Picks.enablePick(pick); } if (event.text === "CONTROL") { control = true; @@ -248,6 +256,7 @@ function keyReleaseEvent(event) { if (event.text === "ALT") { alt = false; changed = true; + Picks.disablePick(pick); } if (event.text === "CONTROL") { control = false; @@ -268,34 +277,32 @@ function mousePressEvent(event) { mouseLastX = event.x; mouseLastY = event.y; - // Compute trajectories related values - var pickRay = Camera.computePickRay(mouseLastX, mouseLastY); - var modelIntersection = Entities.findRayIntersection(pickRay, true); - var avatarIntersection = AvatarList.findRayIntersection(pickRay); + position = Camera.position; - position = Camera.getPosition(); - - if (avatarIntersection.intersects || (modelIntersection.intersects && modelIntersection.accurate)) { - if (avatarIntersection.intersects) { - center = avatarIntersection.intersection; - } else { - center = modelIntersection.intersection; - } - // We've selected our target, now orbit towards it automatically - rotatingTowardsTarget = true; - // calculate our target cam rotation - Script.setTimeout(function () { - rotatingTowardsTarget = false; - }, LOOK_AT_TIME); - - vector = Vec3.subtract(position, center); - targetCamOrientation = orientationOf(vector); - radius = Vec3.length(vector); - azimuth = Math.atan2(vector.z, vector.x); - altitude = Math.asin(vector.y / Vec3.length(vector)); - - isActive = true; + var pickResult = Picks.getPrevPickResult(pick); + if (pickResult.intersects) { + // Orbit about intersection. + center = pickResult.intersection; + } else { + // Orbit about point in space. + var ORBIT_DISTANCE = 10.0; + center = Vec3.sum(position, Vec3.multiply(ORBIT_DISTANCE, pickResult.searchRay.direction)); } + + // We've selected our target, now orbit towards it automatically + rotatingTowardsTarget = true; + // calculate our target cam rotation + Script.setTimeout(function () { + rotatingTowardsTarget = false; + }, LOOK_AT_TIME); + + vector = Vec3.subtract(position, center); + targetCamOrientation = orientationOf(vector); + radius = Vec3.length(vector); + azimuth = Math.atan2(vector.z, vector.x); + altitude = Math.asin(vector.y / Vec3.length(vector)); + + isActive = true; } } From 4ebf4e5cfd5c0e1eed9751a0c46bb0fcd8e06dd2 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Sun, 12 Jan 2020 16:27:03 +1300 Subject: [PATCH 13/21] Ignore invisible --- scripts/system/inspect.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/system/inspect.js b/scripts/system/inspect.js index 980444d247..db98211d9f 100644 --- a/scripts/system/inspect.js +++ b/scripts/system/inspect.js @@ -60,7 +60,7 @@ var detachedMode = 4; var mode = noMode; var pick = Picks.createPick(PickType.Ray, { - filter: Picks.PICK_DOMAIN_ENTITIES | Picks.PICK_AVATAR_ENTITIES | Picks.PICK_AVATARS + filter: Picks.PICK_DOMAIN_ENTITIES | Picks.PICK_AVATAR_ENTITIES | Picks.PICK_AVATARS | Picks.INCLUDE_VISIBLE | Picks.PICK_INCLUDE_COLLIDABLE | Picks.PICK_INCLUDE_NONCOLLIDABLE | Picks.PICK_PRECISE, joint: "Mouse", enabled: false From 2abbdfbfe9742f4fc9d88126c751cf0d6d989785 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Sun, 12 Jan 2020 16:32:20 +1300 Subject: [PATCH 14/21] Fix unnecessary "away" enabling and disabling --- scripts/system/inspect.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/scripts/system/inspect.js b/scripts/system/inspect.js index db98211d9f..6f21e7e8ba 100644 --- a/scripts/system/inspect.js +++ b/scripts/system/inspect.js @@ -59,6 +59,8 @@ var detachedMode = 4; var mode = noMode; +var isAwayEnabled = true; + var pick = Picks.createPick(PickType.Ray, { filter: Picks.PICK_DOMAIN_ENTITIES | Picks.PICK_AVATAR_ENTITIES | Picks.PICK_AVATARS | Picks.INCLUDE_VISIBLE | Picks.PICK_INCLUDE_COLLIDABLE | Picks.PICK_INCLUDE_NONCOLLIDABLE | Picks.PICK_PRECISE, @@ -158,8 +160,11 @@ function handlePanMode(dx, dy) { } function enableAway(enable) { - var CHANNEL_AWAY_ENABLE = "Hifi-Away-Enable"; - Messages.sendMessage(CHANNEL_AWAY_ENABLE, enable ? "enable" : "disable", true); + if (enable !== isAwayEnabled) { + var CHANNEL_AWAY_ENABLE = "Hifi-Away-Enable"; + Messages.sendMessage(CHANNEL_AWAY_ENABLE, enable ? "enable" : "disable", true); + } + isAwayEnabled = enable; } function saveCameraState() { From 316abaeedc743110335a98ab49bcd901f70f493b Mon Sep 17 00:00:00 2001 From: David Rowe Date: Sun, 12 Jan 2020 17:37:58 +1300 Subject: [PATCH 15/21] Fix jitter when start moving camera in edit mode focused on entity --- scripts/system/inspect.js | 21 ++++++++++++++++++++ scripts/system/libraries/entityCameraTool.js | 4 ++++ 2 files changed, 25 insertions(+) diff --git a/scripts/system/inspect.js b/scripts/system/inspect.js index 6f21e7e8ba..e00dd5f3c2 100644 --- a/scripts/system/inspect.js +++ b/scripts/system/inspect.js @@ -61,6 +61,20 @@ var mode = noMode; var isAwayEnabled = true; +var EDIT_CAMERA_MANAGER_CHANNEL = "Edit-Camera-Manager-Channel"; +var isEditUsingCamera = false; +Messages.messageReceived.connect(function (channel, data, senderID, localOnly) { + if (channel === EDIT_CAMERA_MANAGER_CHANNEL && senderID === MyAvatar.sessionUUID && localOnly) { + var message; + try { + message = JSON.parse(data); + isEditUsingCamera = message.enabled; + } catch (e) { + // Ignore. + } + } +}); + var pick = Picks.createPick(PickType.Ray, { filter: Picks.PICK_DOMAIN_ENTITIES | Picks.PICK_AVATAR_ENTITIES | Picks.PICK_AVATARS | Picks.INCLUDE_VISIBLE | Picks.PICK_INCLUDE_COLLIDABLE | Picks.PICK_INCLUDE_NONCOLLIDABLE | Picks.PICK_PRECISE, @@ -183,6 +197,10 @@ function restoreCameraState() { } function handleModes() { + if (isEditUsingCamera) { + return; + } + var newMode = (mode === noMode) ? noMode : detachedMode; if (alt) { if (control) { @@ -231,6 +249,9 @@ function keyPressEvent(event) { var changed = false; if (event.text === "ALT") { + if (isEditUsingCamera) { + return; + } alt = true; changed = true; Picks.enablePick(pick); diff --git a/scripts/system/libraries/entityCameraTool.js b/scripts/system/libraries/entityCameraTool.js index 2968b8e903..b93879d8e1 100644 --- a/scripts/system/libraries/entityCameraTool.js +++ b/scripts/system/libraries/entityCameraTool.js @@ -68,6 +68,8 @@ CameraManager = function() { that.enabled = false; that.mode = MODE_INACTIVE; + var EDIT_CAMERA_MANAGER_CHANNEL = "Edit-Camera-Manager-Channel"; + Messages.sendLocalMessage(EDIT_CAMERA_MANAGER_CHANNEL, JSON.stringify({ enabled: false })); var actions = { orbitLeft: 0, @@ -153,6 +155,7 @@ CameraManager = function() { that.enabled = true; that.mode = MODE_INACTIVE; + Messages.sendLocalMessage(EDIT_CAMERA_MANAGER_CHANNEL, JSON.stringify({ enabled: true })); // Pick a point INITIAL_ZOOM_DISTANCE in front of the camera to use as a focal point that.zoomDistance = INITIAL_ZOOM_DISTANCE; @@ -193,6 +196,7 @@ CameraManager = function() { that.enabled = false; that.mode = MODE_INACTIVE; + Messages.sendLocalMessage(EDIT_CAMERA_MANAGER_CHANNEL, JSON.stringify({ enabled: false })); if (!ignoreCamera) { Camera.mode = that.previousCameraMode; From 336b5e275b5ad533638f3bc3aa6715a4186856e6 Mon Sep 17 00:00:00 2001 From: Kasen IO Date: Sun, 12 Jan 2020 23:13:01 -0500 Subject: [PATCH 16/21] Removed obsolete default scripts + more branding changes. --- interface/src/Application.cpp | 4 ++-- libraries/entities/src/EntityItemProperties.cpp | 2 +- scripts/defaultScripts.js | 2 -- scripts/system/create/edit.js | 2 +- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 3994a574d7..ee9abbfedb 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -3184,7 +3184,7 @@ void Application::showLoginScreen() { QJsonObject loginData = {}; loginData["action"] = "login dialog popped up"; UserActivityLogger::getInstance().logAction("encourageLoginDialog", loginData); - _window->setWindowTitle("High Fidelity"); + _window->setWindowTitle("Project Athena"); } else { resumeAfterLoginDialogActionTaken(); } @@ -7066,7 +7066,7 @@ void Application::updateWindowTitle() const { auto accountManager = DependencyManager::get(); auto isInErrorState = nodeList->getDomainHandler().isInErrorState(); - QString buildVersion = " - Project Athena v0.86.0 K2 - " + QString buildVersion = " - Project Athena Interface v0.86.0 K2 - " + (BuildInfo::BUILD_TYPE == BuildInfo::BuildType::Stable ? QString("Version") : QString("Build")) + " " + applicationVersion(); diff --git a/libraries/entities/src/EntityItemProperties.cpp b/libraries/entities/src/EntityItemProperties.cpp index 2b8f2b4c14..9afaa5e85b 100644 --- a/libraries/entities/src/EntityItemProperties.cpp +++ b/libraries/entities/src/EntityItemProperties.cpp @@ -1366,7 +1366,7 @@ EntityPropertyFlags EntityItemProperties::getChangedProperties() const { * var METERS_TO_INCHES = 39.3701; * var entity = Entities.addEntity({ * type: "Web", - * sourceUrl: "https://highfidelity.com/", + * sourceUrl: "https://projectathena.io/", * position: Vec3.sum(MyAvatar.position, Vec3.multiplyQbyV(MyAvatar.orientation, { x: 0, y: 0.75, z: -4 })), * rotation: MyAvatar.orientation, * dimensions: { diff --git a/scripts/defaultScripts.js b/scripts/defaultScripts.js index 795458f05d..07708ec509 100644 --- a/scripts/defaultScripts.js +++ b/scripts/defaultScripts.js @@ -24,9 +24,7 @@ var DEFAULT_SCRIPTS_COMBINED = [ "system/avatarapp.js", "system/makeUserConnection.js", "system/tablet-goto.js", - "system/marketplaces/marketplaces.js", "system/notifications.js", - "system/commerce/wallet.js", "system/create/edit.js", "system/dialTone.js", "system/firstPersonHMD.js", diff --git a/scripts/system/create/edit.js b/scripts/system/create/edit.js index c57f4bae50..ef07aa4d6e 100644 --- a/scripts/system/create/edit.js +++ b/scripts/system/create/edit.js @@ -427,7 +427,7 @@ const DEFAULT_ENTITY_PROPERTIES = { y: 0.9, z: 0.01 }, - sourceUrl: "https://highfidelity.com/", + sourceUrl: "https://projectathena.io/", dpi: 30, }, ParticleEffect: { From 681bd3cb1ec35db96de1d185f406d6002813e99b Mon Sep 17 00:00:00 2001 From: David Rowe Date: Tue, 14 Jan 2020 11:34:16 +1300 Subject: [PATCH 17/21] Fix inspect not working after change camera mode --- scripts/system/inspect.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/system/inspect.js b/scripts/system/inspect.js index e00dd5f3c2..17260a4358 100644 --- a/scripts/system/inspect.js +++ b/scripts/system/inspect.js @@ -354,6 +354,11 @@ function mouseMoveEvent(event) { mouseLastY = event.y; } +function onCameraModeUpdated(newMode) { + mode = noMode; + handleModes(); +} + function update() { handleModes(); if (rotatingTowardsTarget) { @@ -381,5 +386,7 @@ Controller.mousePressEvent.connect(mousePressEvent); Controller.mouseReleaseEvent.connect(mouseReleaseEvent); Controller.mouseMoveEvent.connect(mouseMoveEvent); +Camera.modeUpdated.connect(onCameraModeUpdated); + Script.update.connect(update); Script.scriptEnding.connect(scriptEnding); From ae620b78afa46c33cb7a1d3888e161d15f991f9b Mon Sep 17 00:00:00 2001 From: Fluffy Jenkins Date: Mon, 13 Jan 2020 23:45:38 +0000 Subject: [PATCH 18/21] Added /l /d /g chatbar switches and /goto --- scripts/communityModules/chat/FloofChat.html | 4 +- scripts/communityModules/chat/FloofChat.js | 81 ++++++++++++++++---- 2 files changed, 70 insertions(+), 15 deletions(-) diff --git a/scripts/communityModules/chat/FloofChat.html b/scripts/communityModules/chat/FloofChat.html index 469ef7cf10..ccfc547b2e 100644 --- a/scripts/communityModules/chat/FloofChat.html +++ b/scripts/communityModules/chat/FloofChat.html @@ -194,7 +194,7 @@ var part1 = text.substring(0, firstMatch - 2); var part2 = text.substring(firstMatch, secondMatch); var part3 = text.substring(secondMatch + 2); - text = part1 + "" + part2 + "" + part3; + text = part1 + "" + part2 + "" + part3; } } else if (text.indexOf("*") !== -1) { var firstMatch = text.indexOf("*") + 1; @@ -204,7 +204,7 @@ var part1 = text.substring(0, firstMatch - 1); var part2 = text.substring(firstMatch, secondMatch); var part3 = text.substring(secondMatch + 1); - text = part1 + "" + part2 + "" + part3; + text = part1 + "" + part2 + "" + part3; } } else if (text.indexOf("__") !== -1) { var firstMatch = text.indexOf("__") + 2; diff --git a/scripts/communityModules/chat/FloofChat.js b/scripts/communityModules/chat/FloofChat.js index 2c5d0a28e1..92f69c9c32 100644 --- a/scripts/communityModules/chat/FloofChat.js +++ b/scripts/communityModules/chat/FloofChat.js @@ -170,6 +170,51 @@ function chatColour(tab) { } } +var chatBarChannel = "Local"; + + +function gotoConfirm(url) { + var result = Window.confirm("Do you want to goto " + ((url.indexOf("/") !== -1) ? url.split("/")[2] : url) + " ?"); + if (result) { + location = url; + } +} + +function processChat(cmd) { + var msg = cmd.message; + if (msg.indexOf("/") === 0) { + msg = msg.substring(1); + var commandList = msg.split(" "); + var cmd1 = commandList[0].toLowerCase(); + if (cmd1 === "l") { + chatBarChannel = "Local"; + msg = ""; + } + if (cmd1 === "d") { + chatBarChannel = "Domain"; + msg = ""; + } + if (cmd1 === "g") { + chatBarChannel = "Grid"; + msg = ""; + } + + if (cmd1 === "goto") { + gotoConfirm(commandList[1]); + msg = ""; + } + + if (cmd1 === "me") { + var tempList = commandList; + tempList.shift(); + msg = cmd.avatarName + " " + tempList.join(" "); + cmd.avatarName = ""; + } + } + cmd.message = msg; + return cmd; +} + function onWebEventReceived(event) { event = JSON.parse(event); if (event.type === "ready") { @@ -189,10 +234,7 @@ function onWebEventReceived(event) { chatHistory.setPosition({x: 0, y: Window.innerHeight - 700}); } if (event.cmd === "GOTO") { - var result = Window.confirm("Do you want to goto " + event.url.split("/")[2] + " ?"); - if (result) { - location = event.url; - } + gotoConfirm(event.url); } if (event.cmd === "URL") { new OverlayWebWindow({ @@ -208,6 +250,8 @@ function onWebEventReceived(event) { } } if (event.type === "WEBMSG") { + event.avatarName = MyAvatar.displayName; + event = processChat(event); if (event.message === "") return; sendWS({ uuid: "", @@ -215,10 +259,12 @@ function onWebEventReceived(event) { channel: event.tab, colour: chatColour(event.tab), message: event.message, - displayName: MyAvatar.displayName + displayName: event.avatarName }); } if (event.type === "MSG") { + event.avatarName = MyAvatar.displayName; + event = processChat(event); if (event.message === "") return; Messages.sendMessage("Chat", JSON.stringify({ type: "TransmitChatMessage", @@ -226,7 +272,7 @@ function onWebEventReceived(event) { channel: event.tab, colour: chatColour(event.tab), message: event.message, - displayName: MyAvatar.displayName + displayName: event.avatarName })); setVisible(false); } @@ -242,7 +288,7 @@ function replaceFormatting(text) { var part1 = text.substring(0, firstMatch - 2); var part2 = text.substring(firstMatch, secondMatch); var part3 = text.substring(secondMatch + 2); - text = part1 + "" + part2 + "" + part3; + text = part1 + "" + part2 + "" + part3; } } else if (text.indexOf("*") !== -1) { var firstMatch = text.indexOf("*") + 1; @@ -252,7 +298,7 @@ function replaceFormatting(text) { var part1 = text.substring(0, firstMatch - 1); var part2 = text.substring(firstMatch, secondMatch); var part3 = text.substring(secondMatch + 1); - text = part1 + "" + part2 + "" + part3; + text = part1 + "" + part2 + "" + part3; } } else if (text.indexOf("__") !== -1) { var firstMatch = text.indexOf("__") + 2; @@ -386,28 +432,37 @@ function fromQml(message) { if (cmd.type === "MSG") { if (cmd.message !== "") { if (cmd.event.modifiers === CONTROL_KEY) { + cmd.avatarName = MyAvatar.displayName; + cmd = processChat(cmd); + if (cmd.message === "") return; Messages.sendMessage(FLOOF_CHAT_CHANNEL, JSON.stringify({ type: "TransmitChatMessage", channel: "Domain", colour: chatColour("Domain"), message: cmd.message, - displayName: MyAvatar.displayName + displayName: cmd.avatarName })); } else if (cmd.event.modifiers === CONTROL_KEY + SHIFT_KEY) { + cmd.avatarName = MyAvatar.displayName; + cmd = processChat(cmd); + if (cmd.message === "") return; sendWS({ uuid: "", type: "WebChat", channel: "Grid", colour: chatColour("Grid"), message: cmd.message, - displayName: MyAvatar.displayName + displayName: cmd.avatarName }); } else { + cmd.avatarName = MyAvatar.displayName; + cmd = processChat(cmd); + if (cmd.message === "") return; Messages.sendMessage(FLOOF_CHAT_CHANNEL, JSON.stringify({ type: "TransmitChatMessage", - channel: "Local", + channel: chatBarChannel, position: MyAvatar.position, - colour: chatColour("Local"), + colour: chatColour(chatBarChannel), message: cmd.message, - displayName: MyAvatar.displayName + displayName: cmd.avatarName })); } } From 195f8867d825d8a18258ac59ba5453111f0b88c7 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Tue, 14 Jan 2020 12:48:16 +1300 Subject: [PATCH 19/21] Disable API docs old analytics --- tools/jsdoc/hifi-jsdoc-template/tmpl/layout.tmpl | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tools/jsdoc/hifi-jsdoc-template/tmpl/layout.tmpl b/tools/jsdoc/hifi-jsdoc-template/tmpl/layout.tmpl index b9cc34ca09..90641a5523 100644 --- a/tools/jsdoc/hifi-jsdoc-template/tmpl/layout.tmpl +++ b/tools/jsdoc/hifi-jsdoc-template/tmpl/layout.tmpl @@ -72,6 +72,7 @@ + + + + From 64149af8ce188452365b851690b715a2a07dcccf Mon Sep 17 00:00:00 2001 From: Fluffy Jenkins Date: Mon, 13 Jan 2020 23:54:57 +0000 Subject: [PATCH 20/21] Fixed goto to go to in dialog I HOPE YOU'RE HAPPY KALILA ;w; --- scripts/communityModules/chat/FloofChat.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/communityModules/chat/FloofChat.js b/scripts/communityModules/chat/FloofChat.js index 92f69c9c32..438adb662d 100644 --- a/scripts/communityModules/chat/FloofChat.js +++ b/scripts/communityModules/chat/FloofChat.js @@ -174,7 +174,7 @@ var chatBarChannel = "Local"; function gotoConfirm(url) { - var result = Window.confirm("Do you want to goto " + ((url.indexOf("/") !== -1) ? url.split("/")[2] : url) + " ?"); + var result = Window.confirm("Do you want to go to '" + ((url.indexOf("/") !== -1) ? url.split("/")[2] : url) + "'?"); if (result) { location = url; } From 6ac090dea5c797ec662a407e01c4d9dd83e2fea3 Mon Sep 17 00:00:00 2001 From: Marcus Llewellyn Date: Tue, 14 Jan 2020 20:33:39 -0600 Subject: [PATCH 21/21] Quick fix for the metaverse API We did have the dfault metaverse API as metaverse.projectathena.io, but that doesn't not yet exist, and it turns out we can't just do a redirect. So for now changing it to metaverse.highfidelity.com --- libraries/networking/src/NetworkingConstants.h | 2 +- tools/nitpick/AppDataHighFidelity/Interface.json | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/networking/src/NetworkingConstants.h b/libraries/networking/src/NetworkingConstants.h index d5dae658c9..fabf8b0e44 100644 --- a/libraries/networking/src/NetworkingConstants.h +++ b/libraries/networking/src/NetworkingConstants.h @@ -25,7 +25,7 @@ namespace NetworkingConstants { // if you manually generate a personal access token for the domains scope // at https://staging.highfidelity.com/user/tokens/new?for_domain_server=true - const QUrl METAVERSE_SERVER_URL_STABLE { "https://metaverse.projectathena.io" }; + const QUrl METAVERSE_SERVER_URL_STABLE { "https://metaverse.highfidelity.com" }; const QUrl METAVERSE_SERVER_URL_STAGING { "https://staging.projectathena.io" }; } diff --git a/tools/nitpick/AppDataHighFidelity/Interface.json b/tools/nitpick/AppDataHighFidelity/Interface.json index 7a8a15e002..5991ed64aa 100644 --- a/tools/nitpick/AppDataHighFidelity/Interface.json +++ b/tools/nitpick/AppDataHighFidelity/Interface.json @@ -279,5 +279,6 @@ "toolbar/com.highfidelity.interface.toolbar.system/x": 655, "toolbar/com.highfidelity.interface.toolbar.system/y": 953, "toolbar/constrainToolbarToCenterX": true, + "private/selectedMetaverseURL": "https://metaverse.highfidelity.com", "wallet/autoLogout": true }