From 4fa2b3a6e99bbb11abc68d1b1e87a6c71cc09f54 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Mon, 9 Feb 2015 22:07:12 -0800 Subject: [PATCH 01/14] Fix maximized Windows window unintentionally changing to windowed This stops a maximized Windows window changing to being windowed when you click on a menu item. --- interface/src/Application.cpp | 13 +++++++++++-- interface/src/Application.h | 2 ++ interface/src/main.cpp | 3 +-- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 95b8cbb835..aa24711509 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -156,18 +156,27 @@ public: bool nativeEventFilter(const QByteArray &eventType, void* msg, long* result) Q_DECL_OVERRIDE { if (eventType == "windows_generic_MSG") { MSG* message = (MSG*)msg; + if (message->message == UWM_IDENTIFY_INSTANCES) { *result = UWM_IDENTIFY_INSTANCES; return true; } - if (message->message == WM_SHOWWINDOW) { - Application::getInstance()->getWindow()->showNormal(); + + if (message->message == UWM_SHOW_APPLICATION) { + MainWindow* applicationWindow = Application::getInstance()->getWindow(); + if (applicationWindow->isMinimized()) { + applicationWindow->showNormal(); // Restores to windowed or maximized state appropriately. + } + Application::getInstance()->setActiveWindow(applicationWindow); // Flashes the taskbar icon if not focus. + return true; } + if (message->message == WM_COPYDATA) { COPYDATASTRUCT* pcds = (COPYDATASTRUCT*)(message->lParam); QUrl url = QUrl((const char*)(pcds->lpData)); if (url.isValid() && url.scheme() == HIFI_URL_SCHEME) { DependencyManager::get()->handleLookupString(url.toString()); + return true; } } } diff --git a/interface/src/Application.h b/interface/src/Application.h index e131766309..d015d09035 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -117,6 +117,8 @@ static const QString INFO_EDIT_ENTITIES_PATH = "html/edit-entities-commands.html #ifdef Q_OS_WIN static const UINT UWM_IDENTIFY_INSTANCES = RegisterWindowMessage("UWM_IDENTIFY_INSTANCES_{8AB82783-B74A-4258-955B-8188C22AA0D6}"); +static const UINT UWM_SHOW_APPLICATION = + RegisterWindowMessage("UWM_SHOW_APPLICATION_{71123FD6-3DA8-4DC1-9C27-8A12A6250CBA}"); #endif class Application; diff --git a/interface/src/main.cpp b/interface/src/main.cpp index 4881bd4ff4..61278821ee 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -46,8 +46,7 @@ int main(int argc, const char * argv[]) { HWND otherInstance = NULL; EnumWindows(enumWindowsCallback, (LPARAM)&otherInstance); if (otherInstance) { - ShowWindow(otherInstance, SW_RESTORE); - SetForegroundWindow(otherInstance); + SendMessage(otherInstance, UWM_SHOW_APPLICATION, 0, 0); QUrl url = QUrl(argv[1]); if (url.isValid() && url.scheme() == HIFI_URL_SCHEME) { From 45c0d0e6a963d3def1e2e59d6ee50f9d996ac6ec Mon Sep 17 00:00:00 2001 From: David Rowe Date: Mon, 9 Feb 2015 23:50:43 -0800 Subject: [PATCH 02/14] Fix Windows --url command line parameter handling --- interface/src/main.cpp | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/interface/src/main.cpp b/interface/src/main.cpp index 61278821ee..64ecb2b9e7 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -8,6 +8,7 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include #include #include #include @@ -36,7 +37,7 @@ static BOOL CALLBACK enumWindowsCallback(HWND hWnd, LPARAM lParam) { #endif -int main(int argc, const char * argv[]) { +int main(int argc, const char* argv[]) { #ifdef Q_OS_WIN // Run only one instance of Interface at a time. HANDLE mutex = CreateMutex(NULL, FALSE, "High Fidelity Interface"); @@ -46,14 +47,32 @@ int main(int argc, const char * argv[]) { HWND otherInstance = NULL; EnumWindows(enumWindowsCallback, (LPARAM)&otherInstance); if (otherInstance) { + // Show other instance. SendMessage(otherInstance, UWM_SHOW_APPLICATION, 0, 0); - QUrl url = QUrl(argv[1]); - if (url.isValid() && url.scheme() == HIFI_URL_SCHEME) { - COPYDATASTRUCT cds; - cds.cbData = strlen(argv[1]) + 1; - cds.lpData = (PVOID)argv[1]; - SendMessage(otherInstance, WM_COPYDATA, 0, (LPARAM)&cds); + // Send command line --url value to other instance. + if (argc >= 3) { + QStringList arguments; + for (int i = 0; i < argc; i += 1) { + arguments << argv[i]; + } + + QCommandLineParser parser; + QCommandLineOption urlOption("url", "", "value"); + parser.addOption(urlOption); + parser.process(arguments); + + if (parser.isSet(urlOption)) { + QUrl url = QUrl(parser.value(urlOption)); + if (url.isValid() && url.scheme() == HIFI_URL_SCHEME) { + QByteArray urlBytes = url.toString().toLatin1(); + const char* urlChars = urlBytes.data(); + COPYDATASTRUCT cds; + cds.cbData = urlBytes.length() + 1; + cds.lpData = (PVOID)urlChars; + SendMessage(otherInstance, WM_COPYDATA, 0, (LPARAM)&cds); + } + } } } return 0; From 7ac3bd3ee862cfcb9ab971748e8cec5c28a76033 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Tue, 10 Feb 2015 09:02:53 -0800 Subject: [PATCH 03/14] Add padding to buttons in entity list --- examples/html/entityList.html | 2 +- examples/html/style.css | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/examples/html/entityList.html b/examples/html/entityList.html index 01061f1eb0..9a910b40d3 100644 --- a/examples/html/entityList.html +++ b/examples/html/entityList.html @@ -168,7 +168,7 @@ -
+
diff --git a/examples/html/style.css b/examples/html/style.css index 8b52447ea2..d7ff8d6ff6 100644 --- a/examples/html/style.css +++ b/examples/html/style.css @@ -86,6 +86,10 @@ input[type=button] { font-weight: bold; } +#entity-list-header { + padding: 0.5em; +} + textarea, input { margin: 0; padding: 1.5pt; From 8d65caaaefb5fbfdce04c03a31272684d305a6f0 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Tue, 10 Feb 2015 09:03:21 -0800 Subject: [PATCH 04/14] Update entity list search input to be full width with margin --- examples/html/entityList.html | 4 +++- examples/html/style.css | 10 ++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/examples/html/entityList.html b/examples/html/entityList.html index 9a910b40d3..bbfa4d81b8 100644 --- a/examples/html/entityList.html +++ b/examples/html/entityList.html @@ -175,7 +175,9 @@
- +
+ +
diff --git a/examples/html/style.css b/examples/html/style.css index d7ff8d6ff6..254c6545d6 100644 --- a/examples/html/style.css +++ b/examples/html/style.css @@ -90,6 +90,16 @@ input[type=button] { padding: 0.5em; } +#search-area { + width: 100%; + padding: 0.5em; + box-sizing: border-box; +} + +#search-area input { + width: 100%; +} + textarea, input { margin: 0; padding: 1.5pt; From 39cc6c86ae0205cdad6af9b04e34922c4bbd7c26 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Tue, 10 Feb 2015 09:03:48 -0800 Subject: [PATCH 05/14] Update selected entity color to have more contrast --- examples/html/style.css | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/html/style.css b/examples/html/style.css index 254c6545d6..7177b8c8ba 100644 --- a/examples/html/style.css +++ b/examples/html/style.css @@ -134,6 +134,7 @@ table#entity-table { } #entity-table tr.selected { + color: rgb(43, 43, 43); background-color: #AAA; } From fe79d8902e173cdc06944ad2c034fc3f812934ae Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Tue, 10 Feb 2015 10:05:38 -0800 Subject: [PATCH 06/14] replace data with metaverse for highfidelity urls --- domain-server/resources/describe-settings.json | 4 ++-- domain-server/resources/web/js/settings.js | 4 ++-- examples/libraries/modelUploader.js | 2 +- examples/lobby.js | 2 +- interface/src/ui/LoginDialog.cpp | 2 +- interface/ui/loginDialog.ui | 4 ++-- libraries/networking/src/LimitedNodeList.cpp | 2 +- libraries/script-engine/src/XMLHttpRequestClass.cpp | 2 +- 8 files changed, 11 insertions(+), 11 deletions(-) diff --git a/domain-server/resources/describe-settings.json b/domain-server/resources/describe-settings.json index 83b270c772..1ff82f58eb 100644 --- a/domain-server/resources/describe-settings.json +++ b/domain-server/resources/describe-settings.json @@ -6,7 +6,7 @@ { "name": "access_token", "label": "Access Token", - "help": "This is an access token generated on the My Security page of your High Fidelity account.
Generate a token with the 'domains' scope and paste it here.
This is required to associate this domain-server with a domain in your account." + "help": "This is an access token generated on the My Security page of your High Fidelity account.
Generate a token with the 'domains' scope and paste it here.
This is required to associate this domain-server with a domain in your account." }, { "name": "id", @@ -30,7 +30,7 @@ }, { "value": "disabled", - "label": "None: use the network information I have entered for this domain at data.highfidelity.io" + "label": "None: use the network information I have entered for this domain at metaverse.highfidelity.io" } ] }, diff --git a/domain-server/resources/web/js/settings.js b/domain-server/resources/web/js/settings.js index bdd80df9ec..f62515c863 100644 --- a/domain-server/resources/web/js/settings.js +++ b/domain-server/resources/web/js/settings.js @@ -652,7 +652,7 @@ function chooseFromHighFidelityDomains(clickedButton) { clickedButton.attr('disabled', 'disabled') // get a list of user domains from data-web - data_web_domains_url = "https://data.highfidelity.io/api/v1/domains?access_token=" + data_web_domains_url = "https://metaverse.highfidelity.io/api/v1/domains?access_token=" $.getJSON(data_web_domains_url + Settings.initialValues.metaverse.access_token, function(data){ modal_buttons = { @@ -682,7 +682,7 @@ function chooseFromHighFidelityDomains(clickedButton) { modal_buttons["success"] = { label: 'Create new domain', callback: function() { - window.open("https://data.highfidelity.io/user/domains", '_blank'); + window.open("https://metaverse.highfidelity.io/user/domains", '_blank'); } } modal_body = "

You do not have any domains in your High Fidelity account." + diff --git a/examples/libraries/modelUploader.js b/examples/libraries/modelUploader.js index 7f575a54ef..fcc96854ab 100644 --- a/examples/libraries/modelUploader.js +++ b/examples/libraries/modelUploader.js @@ -21,7 +21,7 @@ modelUploader = (function () { //svoBuffer, mapping, geometry, - API_URL = "https://data.highfidelity.io/api/v1/models", + API_URL = "https://metaverse.highfidelity.io/api/v1/models", MODEL_URL = "http://public.highfidelity.io/models/content", NAME_FIELD = "name", SCALE_FIELD = "scale", diff --git a/examples/lobby.js b/examples/lobby.js index fcac7a490b..1936a4e531 100644 --- a/examples/lobby.js +++ b/examples/lobby.js @@ -152,7 +152,7 @@ var places = {}; function changeLobbyTextures() { var req = new XMLHttpRequest(); - req.open("GET", "https://data.highfidelity.io/api/v1/places?limit=21", false); + req.open("GET", "https://metaverse.highfidelity.io/api/v1/places?limit=21", false); req.send(); places = JSON.parse(req.responseText).data.places; diff --git a/interface/src/ui/LoginDialog.cpp b/interface/src/ui/LoginDialog.cpp index 3fd6e8e3cd..049e5bd1cd 100644 --- a/interface/src/ui/LoginDialog.cpp +++ b/interface/src/ui/LoginDialog.cpp @@ -22,7 +22,7 @@ #include "ui_loginDialog.h" #include "LoginDialog.h" -const QString FORGOT_PASSWORD_URL = "https://data.highfidelity.io/users/password/new"; +const QString FORGOT_PASSWORD_URL = "https://metaverse.highfidelity.io/users/password/new"; LoginDialog::LoginDialog(QWidget* parent) : FramelessDialog(parent, 0, FramelessDialog::POSITION_TOP), diff --git a/interface/ui/loginDialog.ui b/interface/ui/loginDialog.ui index 73d466b68a..c986db7f50 100644 --- a/interface/ui/loginDialog.ui +++ b/interface/ui/loginDialog.ui @@ -136,7 +136,7 @@ <style type="text/css"> a { text-decoration: none; color: #267077;} </style> -Invalid username or password. <a href="https://data.highfidelity.io/password/new">Recover?</a> +Invalid username or password. <a href="https://metaverse.highfidelity.io/password/new">Recover?</a> Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter @@ -458,7 +458,7 @@ border-radius: 4px; padding-top: 1px; <style type="text/css"> a { text-decoration: none; color: #267077;} </style> -<a href="https://data.highfidelity.io/password/new">Recover password?</a> +<a href="https://metaverse.highfidelity.io/password/new">Recover password?</a> true diff --git a/libraries/networking/src/LimitedNodeList.cpp b/libraries/networking/src/LimitedNodeList.cpp index 5fa6d43b9a..13bb2b1ad8 100644 --- a/libraries/networking/src/LimitedNodeList.cpp +++ b/libraries/networking/src/LimitedNodeList.cpp @@ -36,7 +36,7 @@ const char SOLO_NODE_TYPES[2] = { NodeType::AudioMixer }; -const QUrl DEFAULT_NODE_AUTH_URL = QUrl("https://data.highfidelity.io"); +const QUrl DEFAULT_NODE_AUTH_URL = QUrl("https://metaverse.highfidelity.io"); LimitedNodeList::LimitedNodeList(unsigned short socketListenPort, unsigned short dtlsListenPort) : _sessionUUID(), diff --git a/libraries/script-engine/src/XMLHttpRequestClass.cpp b/libraries/script-engine/src/XMLHttpRequestClass.cpp index cd2e2f3732..116548db61 100644 --- a/libraries/script-engine/src/XMLHttpRequestClass.cpp +++ b/libraries/script-engine/src/XMLHttpRequestClass.cpp @@ -207,7 +207,7 @@ void XMLHttpRequestClass::open(const QString& method, const QString& url, bool a notImplemented(); } } else { - if (url.toLower().left(33) == "https://data.highfidelity.io/api/") { + if (url.toLower().left(33) == "https://metaverse.highfidelity.io/api/") { AccountManager& accountManager = AccountManager::getInstance(); if (accountManager.hasValidAccessToken()) { From 438978b8559620918eff9b721491560780f97bac Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Tue, 10 Feb 2015 19:25:12 +0100 Subject: [PATCH 07/14] Fix reverb memory leak --- libraries/audio-client/src/AudioClient.cpp | 16 ++++++++++++++++ libraries/audio-client/src/AudioClient.h | 1 + 2 files changed, 17 insertions(+) diff --git a/libraries/audio-client/src/AudioClient.cpp b/libraries/audio-client/src/AudioClient.cpp index 9f569c9893..7f6c509626 100644 --- a/libraries/audio-client/src/AudioClient.cpp +++ b/libraries/audio-client/src/AudioClient.cpp @@ -135,6 +135,15 @@ AudioClient::AudioClient() : updateTimer->start(DEVICE_CHECK_INTERVAL_MSECS); } +AudioClient::~AudioClient() { + if (_gverbLocal) { + gverb_free(_gverbLocal); + } + if (_gverb) { + gverb_free(_gverb); + } +} + void AudioClient::reset() { _receivedAudioStream.reset(); _stats.reset(); @@ -522,10 +531,17 @@ bool AudioClient::switchOutputToAudioDevice(const QString& outputDeviceName) { void AudioClient::initGverb() { // Initialize a new gverb instance + if (_gverbLocal) { + gverb_free(_gverbLocal); + } _gverbLocal = gverb_new(_outputFormat.sampleRate(), _reverbOptions->getMaxRoomSize(), _reverbOptions->getRoomSize(), _reverbOptions->getReverbTime(), _reverbOptions->getDamping(), _reverbOptions->getSpread(), _reverbOptions->getInputBandwidth(), _reverbOptions->getEarlyLevel(), _reverbOptions->getTailLevel()); + + if (_gverb) { + gverb_free(_gverb); + } _gverb = gverb_new(_outputFormat.sampleRate(), _reverbOptions->getMaxRoomSize(), _reverbOptions->getRoomSize(), _reverbOptions->getReverbTime(), _reverbOptions->getDamping(), _reverbOptions->getSpread(), _reverbOptions->getInputBandwidth(), _reverbOptions->getEarlyLevel(), diff --git a/libraries/audio-client/src/AudioClient.h b/libraries/audio-client/src/AudioClient.h index ed487e4ea1..e55a116e06 100644 --- a/libraries/audio-client/src/AudioClient.h +++ b/libraries/audio-client/src/AudioClient.h @@ -186,6 +186,7 @@ signals: protected: AudioClient(); + ~AudioClient(); private: void outputFormatChanged(); From 562b289c0541f98e877381d7f45000244cca3216 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Tue, 10 Feb 2015 19:25:38 +0100 Subject: [PATCH 08/14] Fix warning --- libraries/fbx/src/FBXReader.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/libraries/fbx/src/FBXReader.cpp b/libraries/fbx/src/FBXReader.cpp index 1da0a7e09f..043bd43115 100644 --- a/libraries/fbx/src/FBXReader.cpp +++ b/libraries/fbx/src/FBXReader.cpp @@ -1166,7 +1166,6 @@ int matchTextureUVSetToAttributeChannel(const QString& texUVSetName, const QHash FBXLight extractLight(const FBXNode& object) { FBXLight light; - int unkwnon = 0; foreach (const FBXNode& subobject, object.children) { QString childname = QString(subobject.name); if (subobject.name == "Properties70") { From 53f58ad3820f4793851243b4a3c60eaed366ae25 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Tue, 10 Feb 2015 10:51:20 -0800 Subject: [PATCH 09/14] add possibility of desktop GVR build --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dff49df7d7..d7803259c2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -125,6 +125,6 @@ if (NOT ANDROID) add_subdirectory(interface) add_subdirectory(tests) add_subdirectory(tools) -else () +elseif (ANDROID OR DESKTOP_GVR) add_subdirectory(gvr-interface) endif () \ No newline at end of file From 9997ef1b97153d4e36b0429fc91d4e6c46c98c19 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Tue, 10 Feb 2015 14:23:00 -0800 Subject: [PATCH 10/14] Increase size of text entity --- examples/editEntities.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/editEntities.js b/examples/editEntities.js index d73c6fa6e7..83550811f1 100644 --- a/examples/editEntities.js +++ b/examples/editEntities.js @@ -425,7 +425,7 @@ var toolBar = (function () { placingEntityID = Entities.addEntity({ type: "Text", position: grid.snapToSurface(grid.snapToGrid(position, false, DEFAULT_DIMENSIONS), DEFAULT_DIMENSIONS), - dimensions: { x: 0.5, y: 0.3, z: 0.01 }, + dimensions: { x: 0.65, y: 0.3, z: 0.01 }, backgroundColor: { red: 64, green: 64, blue: 64 }, textColor: { red: 255, green: 255, blue: 255 }, text: "some text", From 6eca8610b6b370b03fef10d320c87d24d8becb24 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Tue, 10 Feb 2015 15:54:04 -0800 Subject: [PATCH 11/14] Increase entity-resize timeout to 2 minutes --- examples/editEntities.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/editEntities.js b/examples/editEntities.js index 83550811f1..ea566c6702 100644 --- a/examples/editEntities.js +++ b/examples/editEntities.js @@ -245,7 +245,7 @@ var toolBar = (function () { }; var RESIZE_INTERVAL = 50; - var RESIZE_TIMEOUT = 20000; + var RESIZE_TIMEOUT = 120000; // 2 minutes var RESIZE_MAX_CHECKS = RESIZE_TIMEOUT / RESIZE_INTERVAL; function addModel(url) { var position; From 8016fb5e0d613e7f46a2f9d89c58864f5e9a7b6e Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Tue, 10 Feb 2015 17:35:27 -0800 Subject: [PATCH 12/14] fix color issues with quads --- libraries/render-utils/src/GeometryCache.cpp | 14 +++++---- libraries/render-utils/src/GeometryCache.h | 30 ++++++++++++++++---- 2 files changed, 32 insertions(+), 12 deletions(-) diff --git a/libraries/render-utils/src/GeometryCache.cpp b/libraries/render-utils/src/GeometryCache.cpp index abf57843b7..1a51e9aed9 100644 --- a/libraries/render-utils/src/GeometryCache.cpp +++ b/libraries/render-utils/src/GeometryCache.cpp @@ -999,12 +999,12 @@ void GeometryCache::renderBevelCornersRect(int x, int y, int width, int height, void GeometryCache::renderQuad(const glm::vec2& minCorner, const glm::vec2& maxCorner, const glm::vec4& color, int id) { bool registered = (id != UNKNOWN_ID); - Vec2Pair key(minCorner, maxCorner); + Vec4Pair key(glm::vec4(minCorner.x, minCorner.y, maxCorner.x, maxCorner.y), color); BatchItemDetails& details = registered ? _registeredQuad2D[id] : _quad2D[key]; // if this is a registered quad, and we have buffers, then check to see if the geometry changed and rebuild if needed if (registered && details.isCreated) { - Vec2Pair& lastKey = _lastRegisteredQuad2D[id]; + Vec4Pair & lastKey = _lastRegisteredQuad2D[id]; if (lastKey != key) { details.clear(); _lastRegisteredQuad2D[id] = key; @@ -1082,12 +1082,14 @@ void GeometryCache::renderQuad(const glm::vec2& minCorner, const glm::vec2& maxC const glm::vec4& color, int id) { bool registered = (id != UNKNOWN_ID); - Vec2PairPair key(Vec2Pair(minCorner, maxCorner), Vec2Pair(texCoordMinCorner, texCoordMaxCorner)); + Vec4PairVec4 key(Vec4Pair(glm::vec4(minCorner.x, minCorner.y, maxCorner.x, maxCorner.y), + glm::vec4(texCoordMinCorner.x, texCoordMinCorner.y, texCoordMaxCorner.x, texCoordMaxCorner.y)), + color); BatchItemDetails& details = registered ? _registeredQuad2DTextures[id] : _quad2DTextures[key]; // if this is a registered quad, and we have buffers, then check to see if the geometry changed and rebuild if needed if (registered && details.isCreated) { - Vec2PairPair& lastKey = _lastRegisteredQuad2DTexture[id]; + Vec4PairVec4& lastKey = _lastRegisteredQuad2DTexture[id]; if (lastKey != key) { details.clear(); _lastRegisteredQuad2DTexture[id] = key; @@ -1172,12 +1174,12 @@ void GeometryCache::renderQuad(const glm::vec2& minCorner, const glm::vec2& maxC void GeometryCache::renderQuad(const glm::vec3& minCorner, const glm::vec3& maxCorner, const glm::vec4& color, int id) { bool registered = (id != UNKNOWN_ID); - Vec3Pair key(minCorner, maxCorner); + Vec3PairVec4 key(Vec3Pair(minCorner, maxCorner), color); BatchItemDetails& details = registered ? _registeredQuad3D[id] : _quad3D[key]; // if this is a registered quad, and we have buffers, then check to see if the geometry changed and rebuild if needed if (registered && details.isCreated) { - Vec3Pair& lastKey = _lastRegisteredQuad3D[id]; + Vec3PairVec4& lastKey = _lastRegisteredQuad3D[id]; if (lastKey != key) { details.clear(); _lastRegisteredQuad3D[id] = key; diff --git a/libraries/render-utils/src/GeometryCache.h b/libraries/render-utils/src/GeometryCache.h index 300e68aadd..558887426c 100644 --- a/libraries/render-utils/src/GeometryCache.h +++ b/libraries/render-utils/src/GeometryCache.h @@ -41,7 +41,9 @@ typedef QPair Vec2PairPair; typedef QPair Vec3Pair; typedef QPair Vec4Pair; typedef QPair Vec3PairVec2Pair; +typedef QPair Vec3PairVec4; typedef QPair Vec3PairVec4Pair; +typedef QPair Vec4PairVec4; typedef QPair Vec4PairVec4Pair; inline uint qHash(const glm::vec2& v, uint seed) { @@ -87,6 +89,14 @@ inline uint qHash(const Vec3PairVec2Pair& v, uint seed) { 5077 * v.second.second.x + 5081 * v.second.second.y, seed); } +inline uint qHash(const Vec3PairVec4& v, uint seed) { + // multiply by prime numbers greater than the possible size + return qHash(v.first.first.x + 5009 * v.first.first.y + 5011 * v.first.first.z + + 5021 * v.first.second.x + 5023 * v.first.second.y + 5039 * v.first.second.z + + 5051 * v.second.x + 5059 * v.second.y + 5077 * v.second.z + 5081 * v.second.w, seed); +} + + inline uint qHash(const Vec3PairVec4Pair& v, uint seed) { // multiply by prime numbers greater than the possible size return qHash(v.first.first.x + 5009 * v.first.first.y + 5011 * v.first.first.z @@ -96,6 +106,14 @@ inline uint qHash(const Vec3PairVec4Pair& v, uint seed) { seed); } +inline uint qHash(const Vec4PairVec4& v, uint seed) { + // multiply by prime numbers greater than the possible size + return qHash(v.first.first.x + 5009 * v.first.first.y + 5011 * v.first.first.z + 5021 * v.first.first.w + + 5023 * v.first.second.x + 5039 * v.first.second.y + 5051 * v.first.second.z + 5059 * v.first.second.w + + 5077 * v.second.x + 5081 * v.second.y + 5087 * v.second.z + 5099 * v.second.w, + seed); +} + inline uint qHash(const Vec4PairVec4Pair& v, uint seed) { // multiply by prime numbers greater than the possible size return qHash(v.first.first.x + 5009 * v.first.first.y + 5011 * v.first.first.z + 5021 * v.first.first.w @@ -236,16 +254,16 @@ private: QHash _quad3DTextures; QHash _registeredQuad3DTextures; - QHash _lastRegisteredQuad2DTexture; - QHash _quad2DTextures; + QHash _lastRegisteredQuad2DTexture; + QHash _quad2DTextures; QHash _registeredQuad2DTextures; - QHash _lastRegisteredQuad3D; - QHash _quad3D; + QHash _lastRegisteredQuad3D; + QHash _quad3D; QHash _registeredQuad3D; - QHash _lastRegisteredQuad2D; - QHash _quad2D; + QHash _lastRegisteredQuad2D; + QHash _quad2D; QHash _registeredQuad2D; QHash _lastRegisteredBevelRects; From b9fd116dbf20ed442ef971140f4d8d01858f1d87 Mon Sep 17 00:00:00 2001 From: Sam Gateau Date: Tue, 10 Feb 2015 18:38:48 -0800 Subject: [PATCH 13/14] Introduce a cache bit in networkGemometry to capture the status of texture LOaded and avoid requiring everything once everything is loaded and get rid of the Transform stack calls on gl from gpu --- libraries/gpu/src/gpu/Batch.h | 22 +--- libraries/gpu/src/gpu/GLBackend.cpp | 131 ------------------- libraries/gpu/src/gpu/GLBackend.h | 12 +- libraries/render-utils/src/GeometryCache.cpp | 18 ++- libraries/render-utils/src/GeometryCache.h | 2 + libraries/render-utils/src/Model.cpp | 31 ++++- 6 files changed, 40 insertions(+), 176 deletions(-) diff --git a/libraries/gpu/src/gpu/Batch.h b/libraries/gpu/src/gpu/Batch.h index 64b94344c2..0657eacd6e 100644 --- a/libraries/gpu/src/gpu/Batch.h +++ b/libraries/gpu/src/gpu/Batch.h @@ -129,17 +129,7 @@ public: void _glUniform1f(GLint location, GLfloat v0); void _glUniform2f(GLint location, GLfloat v0, GLfloat v1); void _glUniform4fv(GLint location, GLsizei count, const GLfloat* value); - void _glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); - - void _glMatrixMode(GLenum mode); - void _glPushMatrix(); - void _glPopMatrix(); - void _glMultMatrixf(const GLfloat *m); - void _glLoadMatrixf(const GLfloat *m); - void _glLoadIdentity(void); - void _glRotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z); - void _glScalef(GLfloat x, GLfloat y, GLfloat z); - void _glTranslatef(GLfloat x, GLfloat y, GLfloat z); + void _glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); void _glDrawArrays(GLenum mode, GLint first, GLsizei count); void _glDrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices); @@ -201,16 +191,6 @@ public: COMMAND_glUniform4fv, COMMAND_glUniformMatrix4fv, - COMMAND_glMatrixMode, - COMMAND_glPushMatrix, - COMMAND_glPopMatrix, - COMMAND_glMultMatrixf, - COMMAND_glLoadMatrixf, - COMMAND_glLoadIdentity, - COMMAND_glRotatef, - COMMAND_glScalef, - COMMAND_glTranslatef, - COMMAND_glDrawArrays, COMMAND_glDrawRangeElements, diff --git a/libraries/gpu/src/gpu/GLBackend.cpp b/libraries/gpu/src/gpu/GLBackend.cpp index 519b20eca7..34ca47f300 100644 --- a/libraries/gpu/src/gpu/GLBackend.cpp +++ b/libraries/gpu/src/gpu/GLBackend.cpp @@ -54,16 +54,6 @@ GLBackend::CommandCall GLBackend::_commandCalls[Batch::NUM_COMMANDS] = (&::gpu::GLBackend::do_glUniform4fv), (&::gpu::GLBackend::do_glUniformMatrix4fv), - (&::gpu::GLBackend::do_glMatrixMode), - (&::gpu::GLBackend::do_glPushMatrix), - (&::gpu::GLBackend::do_glPopMatrix), - (&::gpu::GLBackend::do_glMultMatrixf), - (&::gpu::GLBackend::do_glLoadMatrixf), - (&::gpu::GLBackend::do_glLoadIdentity), - (&::gpu::GLBackend::do_glRotatef), - (&::gpu::GLBackend::do_glScalef), - (&::gpu::GLBackend::do_glTranslatef), - (&::gpu::GLBackend::do_glDrawArrays), (&::gpu::GLBackend::do_glDrawRangeElements), @@ -747,127 +737,6 @@ void GLBackend::do_glUniformMatrix4fv(Batch& batch, uint32 paramOffset) { CHECK_GL_ERROR(); } -void Batch::_glMatrixMode(GLenum mode) { - ADD_COMMAND_GL(glMatrixMode); - - _params.push_back(mode); - - DO_IT_NOW(_glMatrixMode, 1); -} -void GLBackend::do_glMatrixMode(Batch& batch, uint32 paramOffset) { - glMatrixMode(batch._params[paramOffset]._uint); - CHECK_GL_ERROR(); -} - -void Batch::_glPushMatrix() { - ADD_COMMAND_GL(glPushMatrix); - - DO_IT_NOW(_glPushMatrix, 0); -} -void GLBackend::do_glPushMatrix(Batch& batch, uint32 paramOffset) { - glPushMatrix(); - CHECK_GL_ERROR(); -} - -void Batch::_glPopMatrix() { - ADD_COMMAND_GL(glPopMatrix); - - DO_IT_NOW(_glPopMatrix, 0); -} -void GLBackend::do_glPopMatrix(Batch& batch, uint32 paramOffset) { - glPopMatrix(); - CHECK_GL_ERROR(); -} - -void Batch::_glMultMatrixf(const GLfloat *m) { - ADD_COMMAND_GL(glMultMatrixf); - - const int MATRIX4_SIZE = 16 * sizeof(float); - _params.push_back(cacheData(MATRIX4_SIZE, m)); - - DO_IT_NOW(_glMultMatrixf, 1); -} -void GLBackend::do_glMultMatrixf(Batch& batch, uint32 paramOffset) { - glMultMatrixf((const GLfloat*)batch.editData(batch._params[paramOffset]._uint)); - CHECK_GL_ERROR(); -} - -void Batch::_glLoadMatrixf(const GLfloat *m) { - ADD_COMMAND_GL(glLoadMatrixf); - - const int MATRIX4_SIZE = 16 * sizeof(float); - _params.push_back(cacheData(MATRIX4_SIZE, m)); - - DO_IT_NOW(_glLoadMatrixf, 1); -} -void GLBackend::do_glLoadMatrixf(Batch& batch, uint32 paramOffset) { - glLoadMatrixf((const GLfloat*)batch.editData(batch._params[paramOffset]._uint)); - CHECK_GL_ERROR(); -} - -void Batch::_glLoadIdentity(void) { - ADD_COMMAND_GL(glLoadIdentity); - - DO_IT_NOW(_glLoadIdentity, 0); -} -void GLBackend::do_glLoadIdentity(Batch& batch, uint32 paramOffset) { - glLoadIdentity(); - CHECK_GL_ERROR(); -} - -void Batch::_glRotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z) { - ADD_COMMAND_GL(glRotatef); - - _params.push_back(z); - _params.push_back(y); - _params.push_back(x); - _params.push_back(angle); - - DO_IT_NOW(_glRotatef, 4); -} -void GLBackend::do_glRotatef(Batch& batch, uint32 paramOffset) { - glRotatef( - batch._params[paramOffset + 3]._float, - batch._params[paramOffset + 2]._float, - batch._params[paramOffset + 1]._float, - batch._params[paramOffset + 0]._float); - CHECK_GL_ERROR(); -} - -void Batch::_glScalef(GLfloat x, GLfloat y, GLfloat z) { - ADD_COMMAND_GL(glScalef); - - _params.push_back(z); - _params.push_back(y); - _params.push_back(x); - - DO_IT_NOW(_glScalef, 3); -} -void GLBackend::do_glScalef(Batch& batch, uint32 paramOffset) { - glScalef( - batch._params[paramOffset + 2]._float, - batch._params[paramOffset + 1]._float, - batch._params[paramOffset + 0]._float); - CHECK_GL_ERROR(); -} - -void Batch::_glTranslatef(GLfloat x, GLfloat y, GLfloat z) { - ADD_COMMAND_GL(glTranslatef); - - _params.push_back(z); - _params.push_back(y); - _params.push_back(x); - - DO_IT_NOW(_glTranslatef, 3); -} -void GLBackend::do_glTranslatef(Batch& batch, uint32 paramOffset) { - glTranslatef( - batch._params[paramOffset + 2]._float, - batch._params[paramOffset + 1]._float, - batch._params[paramOffset + 0]._float); - CHECK_GL_ERROR(); -} - void Batch::_glDrawArrays(GLenum mode, GLint first, GLsizei count) { ADD_COMMAND_GL(glDrawArrays); diff --git a/libraries/gpu/src/gpu/GLBackend.h b/libraries/gpu/src/gpu/GLBackend.h index 1731701022..e3450ae71a 100644 --- a/libraries/gpu/src/gpu/GLBackend.h +++ b/libraries/gpu/src/gpu/GLBackend.h @@ -175,17 +175,7 @@ protected: void do_glUniform1f(Batch& batch, uint32 paramOffset); void do_glUniform2f(Batch& batch, uint32 paramOffset); void do_glUniform4fv(Batch& batch, uint32 paramOffset); - void do_glUniformMatrix4fv(Batch& batch, uint32 paramOffset); - - void do_glMatrixMode(Batch& batch, uint32 paramOffset); - void do_glPushMatrix(Batch& batch, uint32 paramOffset); - void do_glPopMatrix(Batch& batch, uint32 paramOffset); - void do_glMultMatrixf(Batch& batch, uint32 paramOffset); - void do_glLoadMatrixf(Batch& batch, uint32 paramOffset); - void do_glLoadIdentity(Batch& batch, uint32 paramOffset); - void do_glRotatef(Batch& batch, uint32 paramOffset); - void do_glScalef(Batch& batch, uint32 paramOffset); - void do_glTranslatef(Batch& batch, uint32 paramOffset); + void do_glUniformMatrix4fv(Batch& batch, uint32 paramOffset); void do_glDrawArrays(Batch& batch, uint32 paramOffset); void do_glDrawRangeElements(Batch& batch, uint32 paramOffset); diff --git a/libraries/render-utils/src/GeometryCache.cpp b/libraries/render-utils/src/GeometryCache.cpp index abf57843b7..16bf958920 100644 --- a/libraries/render-utils/src/GeometryCache.cpp +++ b/libraries/render-utils/src/GeometryCache.cpp @@ -1753,15 +1753,18 @@ bool NetworkGeometry::isLoadedWithTextures() const { if (!isLoaded()) { return false; } - foreach (const NetworkMesh& mesh, _meshes) { - foreach (const NetworkMeshPart& part, mesh.parts) { - if ((part.diffuseTexture && !part.diffuseTexture->isLoaded()) || - (part.normalTexture && !part.normalTexture->isLoaded()) || - (part.specularTexture && !part.specularTexture->isLoaded()) || - (part.emissiveTexture && !part.emissiveTexture->isLoaded())) { - return false; + if (!_isLoadedWithTextures) { + foreach (const NetworkMesh& mesh, _meshes) { + foreach (const NetworkMeshPart& part, mesh.parts) { + if ((part.diffuseTexture && !part.diffuseTexture->isLoaded()) || + (part.normalTexture && !part.normalTexture->isLoaded()) || + (part.specularTexture && !part.specularTexture->isLoaded()) || + (part.emissiveTexture && !part.emissiveTexture->isLoaded())) { + return false; + } } } + _isLoadedWithTextures = true; } return true; } @@ -1938,6 +1941,7 @@ void NetworkGeometry::setTextureWithNameToURL(const QString& name, const QUrl& u // we don't have meshes downloaded yet, so hold this texture as pending _pendingTextureChanges.insert(name, url); } + _isLoadedWithTextures = false; } QStringList NetworkGeometry::getTextureNames() const { diff --git a/libraries/render-utils/src/GeometryCache.h b/libraries/render-utils/src/GeometryCache.h index 300e68aadd..04cea4f9f8 100644 --- a/libraries/render-utils/src/GeometryCache.h +++ b/libraries/render-utils/src/GeometryCache.h @@ -339,6 +339,8 @@ private: QHash, QVector > _jointMappings; QHash _pendingTextureChanges; + + mutable bool _isLoadedWithTextures = false; }; /// The state associated with a single mesh part. diff --git a/libraries/render-utils/src/Model.cpp b/libraries/render-utils/src/Model.cpp index 79f938e7f6..1bf379208a 100644 --- a/libraries/render-utils/src/Model.cpp +++ b/libraries/render-utils/src/Model.cpp @@ -686,7 +686,7 @@ bool Model::renderCore(float alpha, RenderMode mode, RenderArgs* args) { // Let's introduce a gpu::Batch to capture all the calls to the graphics api _renderBatch.clear(); gpu::Batch& batch = _renderBatch; - GLBATCH(glPushMatrix)(); + //GLBATCH(glPushMatrix)(); // Capture the view matrix once for the rendering of this model if (_transforms.empty()) { @@ -835,12 +835,23 @@ bool Model::renderCore(float alpha, RenderMode mode, RenderArgs* args) { GLBATCH(glBindBuffer)(GL_ELEMENT_ARRAY_BUFFER, 0); GLBATCH(glBindTexture)(GL_TEXTURE_2D, 0); - GLBATCH(glPopMatrix)(); + //GLBATCH(glPopMatrix)(); // Render! { PROFILE_RANGE("render Batch"); + + #if defined(ANDROID) + #else + glPushMatrix(); + #endif + ::gpu::GLBackend::renderBatch(batch); + + #if defined(ANDROID) + #else + glPopMatrix(); + #endif } // restore all the default material settings @@ -1638,7 +1649,7 @@ void Model::startScene(RenderArgs::RenderSide renderSide) { } void Model::setupBatchTransform(gpu::Batch& batch) { - GLBATCH(glPushMatrix)(); + //GLBATCH(glPushMatrix)(); // Capture the view matrix once for the rendering of this model if (_transforms.empty()) { @@ -1811,7 +1822,17 @@ void Model::endScene(RenderMode mode, RenderArgs* args) { // Render! { PROFILE_RANGE("render Batch"); + #if defined(ANDROID) + #else + glPushMatrix(); + #endif + ::gpu::GLBackend::renderBatch(_sceneRenderBatch); + + #if defined(ANDROID) + #else + glPopMatrix(); + #endif } // restore all the default material settings @@ -2271,7 +2292,7 @@ int Model::renderMeshesForModelsInScene(gpu::Batch& batch, RenderMode mode, bool } model->setupBatchTransform(batch); meshPartsRendered += model->renderMeshesFromList(list, batch, mode, translucent, alphaThreshold, args, locations, skinLocations); - GLBATCH(glPopMatrix)(); + //GLBATCH(glPopMatrix)(); } } } @@ -2437,11 +2458,9 @@ int Model::renderMeshesFromList(QVector& list, gpu::Batch& batch, RenderMod } static bool showDiffuse = true; if (showDiffuse && diffuseMap) { - // GLBATCH(glBindTexture)(GL_TEXTURE_2D, diffuseMap->getID()); batch.setUniformTexture(0, diffuseMap->getGPUTexture()); } else { - // GLBATCH(glBindTexture)(GL_TEXTURE_2D, textureCache->getWhiteTextureID()); batch.setUniformTexture(0, textureCache->getWhiteTexture()); } From a6f006a36d998cfd6450a66ec445e229c029483c Mon Sep 17 00:00:00 2001 From: Sam Gateau Date: Tue, 10 Feb 2015 18:41:36 -0800 Subject: [PATCH 14/14] more cleaning --- libraries/render-utils/src/Model.cpp | 7 ------- 1 file changed, 7 deletions(-) diff --git a/libraries/render-utils/src/Model.cpp b/libraries/render-utils/src/Model.cpp index 1bf379208a..f166aecae9 100644 --- a/libraries/render-utils/src/Model.cpp +++ b/libraries/render-utils/src/Model.cpp @@ -686,7 +686,6 @@ bool Model::renderCore(float alpha, RenderMode mode, RenderArgs* args) { // Let's introduce a gpu::Batch to capture all the calls to the graphics api _renderBatch.clear(); gpu::Batch& batch = _renderBatch; - //GLBATCH(glPushMatrix)(); // Capture the view matrix once for the rendering of this model if (_transforms.empty()) { @@ -835,8 +834,6 @@ bool Model::renderCore(float alpha, RenderMode mode, RenderArgs* args) { GLBATCH(glBindBuffer)(GL_ELEMENT_ARRAY_BUFFER, 0); GLBATCH(glBindTexture)(GL_TEXTURE_2D, 0); - //GLBATCH(glPopMatrix)(); - // Render! { PROFILE_RANGE("render Batch"); @@ -1649,7 +1646,6 @@ void Model::startScene(RenderArgs::RenderSide renderSide) { } void Model::setupBatchTransform(gpu::Batch& batch) { - //GLBATCH(glPushMatrix)(); // Capture the view matrix once for the rendering of this model if (_transforms.empty()) { @@ -2292,7 +2288,6 @@ int Model::renderMeshesForModelsInScene(gpu::Batch& batch, RenderMode mode, bool } model->setupBatchTransform(batch); meshPartsRendered += model->renderMeshesFromList(list, batch, mode, translucent, alphaThreshold, args, locations, skinLocations); - //GLBATCH(glPopMatrix)(); } } } @@ -2392,8 +2387,6 @@ int Model::renderMeshesFromList(QVector& list, gpu::Batch& batch, RenderMod } } - // GLBATCH(glPushMatrix)(); - const MeshState& state = _meshStates.at(i); if (state.clusterMatrices.size() > 1) { GLBATCH(glUniformMatrix4fv)(skinLocations->clusterMatrices, state.clusterMatrices.size(), false,