From 5cdc76ad35569d584412a0e2a35e13ae3e61c36b Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Sun, 11 Jan 2015 22:48:42 -0800 Subject: [PATCH 01/24] Put cache max size/count as class members --- libraries/networking/src/ResourceCache.cpp | 14 +++++--------- libraries/networking/src/ResourceCache.h | 6 +++--- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/libraries/networking/src/ResourceCache.cpp b/libraries/networking/src/ResourceCache.cpp index 4b769c9a28..962e256e02 100644 --- a/libraries/networking/src/ResourceCache.cpp +++ b/libraries/networking/src/ResourceCache.cpp @@ -73,22 +73,18 @@ QSharedPointer ResourceCache::getResource(const QUrl& url, const QUrl& } void ResourceCache::addUnusedResource(const QSharedPointer& resource) { - static const int BYTES_PER_MEGABYTES = 1024 * 1024; - const int RETAINED_RESOURCE_COUNT = 50; - const int RETAINED_RESOURCE_SIZE = 100 * BYTES_PER_MEGABYTES; - - while (_unusedResourcesTotalBytes + resource->getBytesTotal() > RETAINED_RESOURCE_SIZE && + while (_unusedResourcesSize + resource->getBytesTotal() > _unusedResourcesMaxSize && !_unusedResources.empty()) { // unload the oldest resource QMap >::iterator it = _unusedResources.begin(); - _unusedResourcesTotalBytes -= it.value()->getBytesTotal(); + _unusedResourcesSize -= it.value()->getBytesTotal(); it.value()->setCache(NULL); _unusedResources.erase(it); } - if (_unusedResources.size() > RETAINED_RESOURCE_COUNT) { + if (_unusedResources.size() > _unusedResourcesMaxCount) { // unload the oldest resource QMap >::iterator it = _unusedResources.begin(); it.value()->setCache(NULL); @@ -96,13 +92,13 @@ void ResourceCache::addUnusedResource(const QSharedPointer& resource) } resource->setLRUKey(++_lastLRUKey); _unusedResources.insert(resource->getLRUKey(), resource); - _unusedResourcesTotalBytes += resource->getBytesTotal(); + _unusedResourcesSize += resource->getBytesTotal(); } void ResourceCache::removeUnusedResource(const QSharedPointer& resource) { if (_unusedResources.contains(resource->getLRUKey())) { _unusedResources.remove(resource->getLRUKey()); - _unusedResourcesTotalBytes -= resource->getBytesTotal(); + _unusedResourcesSize -= resource->getBytesTotal(); } } diff --git a/libraries/networking/src/ResourceCache.h b/libraries/networking/src/ResourceCache.h index 0a4121ca5e..ca1a8a04d9 100644 --- a/libraries/networking/src/ResourceCache.h +++ b/libraries/networking/src/ResourceCache.h @@ -45,8 +45,9 @@ public: void refresh(const QUrl& url); protected: - - qint64 _unusedResourcesTotalBytes = 0; + int _unusedResourcesMaxCount = 50; + qint64 _unusedResourcesMaxSize = 100 * 1024 * 1024; + qint64 _unusedResourcesSize = 0; QMap > _unusedResources; /// Loads a resource from the specified URL. @@ -67,7 +68,6 @@ protected: static void requestCompleted(Resource* resource); private: - friend class Resource; QHash > _resources; From 98dd401ea363fa333cc696a4e8df6cb5e513fa76 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Mon, 12 Jan 2015 11:12:19 -0800 Subject: [PATCH 02/24] Remove duplicate definition --- interface/src/ModelUploader.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/interface/src/ModelUploader.cpp b/interface/src/ModelUploader.cpp index 89b6a4c9c0..7e9d857306 100644 --- a/interface/src/ModelUploader.cpp +++ b/interface/src/ModelUploader.cpp @@ -55,7 +55,6 @@ static const QString MODEL_URL = "/api/v1/models"; static const QString SETTING_NAME = "LastModelUploadLocation"; -static const long long BYTES_PER_MEGABYTES = 1024 * 1024; static const unsigned long long MAX_SIZE = 50 * 1024 * BYTES_PER_MEGABYTES; // 50 GB (Virtually remove limit) static const int MAX_TEXTURE_SIZE = 1024; static const int TIMEOUT = 1000; From 08317b51daaae2b3470b0357894e2e7709126636 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Mon, 12 Jan 2015 11:12:50 -0800 Subject: [PATCH 03/24] Use removeUnusedResources --- libraries/render-utils/src/TextureCache.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/render-utils/src/TextureCache.cpp b/libraries/render-utils/src/TextureCache.cpp index df860338ab..0f34282162 100644 --- a/libraries/render-utils/src/TextureCache.cpp +++ b/libraries/render-utils/src/TextureCache.cpp @@ -203,7 +203,7 @@ NetworkTexturePointer TextureCache::getTexture(const QUrl& url, TextureType type texture->setCache(this); _dilatableNetworkTextures.insert(url, texture); } else { - _unusedResources.remove(texture->getLRUKey()); + removeUnusedResource(texture); } return texture; } From cb3f07e6f53758ef4b2c0263ce86ef9fe0d2c7e3 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Mon, 12 Jan 2015 11:18:55 -0800 Subject: [PATCH 04/24] Remove unusedResourcesMaxCount --- libraries/networking/src/ResourceCache.cpp | 7 ------- libraries/networking/src/ResourceCache.h | 6 ++++-- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/libraries/networking/src/ResourceCache.cpp b/libraries/networking/src/ResourceCache.cpp index 962e256e02..1b3d4cc232 100644 --- a/libraries/networking/src/ResourceCache.cpp +++ b/libraries/networking/src/ResourceCache.cpp @@ -83,13 +83,6 @@ void ResourceCache::addUnusedResource(const QSharedPointer& resource) _unusedResources.erase(it); } - - if (_unusedResources.size() > _unusedResourcesMaxCount) { - // unload the oldest resource - QMap >::iterator it = _unusedResources.begin(); - it.value()->setCache(NULL); - _unusedResources.erase(it); - } resource->setLRUKey(++_lastLRUKey); _unusedResources.insert(resource->getLRUKey(), resource); _unusedResourcesSize += resource->getBytesTotal(); diff --git a/libraries/networking/src/ResourceCache.h b/libraries/networking/src/ResourceCache.h index ca1a8a04d9..90d228fb07 100644 --- a/libraries/networking/src/ResourceCache.h +++ b/libraries/networking/src/ResourceCache.h @@ -27,6 +27,9 @@ class QTimer; class Resource; +static constexpr qint64 BYTES_PER_MEGABYTES = 1024 * 1024; +static constexpr qint64 DEFAULT_MAX_SIZE = 100 * BYTES_PER_MEGABYTES; + /// Base class for resource caches. class ResourceCache : public QObject { Q_OBJECT @@ -45,8 +48,7 @@ public: void refresh(const QUrl& url); protected: - int _unusedResourcesMaxCount = 50; - qint64 _unusedResourcesMaxSize = 100 * 1024 * 1024; + qint64 _unusedResourcesMaxSize = DEFAULT_MAX_SIZE; qint64 _unusedResourcesSize = 0; QMap > _unusedResources; From ea0ffd01256b22468e9e46d1afe2fcfd81ab8dcb Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Mon, 12 Jan 2015 11:37:00 -0800 Subject: [PATCH 05/24] Introduce reserveUnusedResource --- libraries/networking/src/ResourceCache.cpp | 25 +++++++++++++++------- libraries/networking/src/ResourceCache.h | 1 + 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/libraries/networking/src/ResourceCache.cpp b/libraries/networking/src/ResourceCache.cpp index 1b3d4cc232..e2fef26b22 100644 --- a/libraries/networking/src/ResourceCache.cpp +++ b/libraries/networking/src/ResourceCache.cpp @@ -73,15 +73,12 @@ QSharedPointer ResourceCache::getResource(const QUrl& url, const QUrl& } void ResourceCache::addUnusedResource(const QSharedPointer& resource) { - while (_unusedResourcesSize + resource->getBytesTotal() > _unusedResourcesMaxSize && - !_unusedResources.empty()) { - // unload the oldest resource - QMap >::iterator it = _unusedResources.begin(); - - _unusedResourcesSize -= it.value()->getBytesTotal(); - it.value()->setCache(NULL); - _unusedResources.erase(it); + if (resource->getBytesTotal() > _unusedResourcesMaxSize) { + // If it doesn't fit anyway, let's leave whatever is already in the cache. + resource->setCache(nullptr); + return; } + reserveUnusedResource(resource->getBytesTotal()); resource->setLRUKey(++_lastLRUKey); _unusedResources.insert(resource->getLRUKey(), resource); @@ -95,6 +92,18 @@ void ResourceCache::removeUnusedResource(const QSharedPointer& resourc } } +void ResourceCache::reserveUnusedResource(qint64 resourceSize) { + while (!_unusedResources.empty() && + _unusedResourcesSize + resourceSize > _unusedResourcesMaxSize) { + // unload the oldest resource + QMap >::iterator it = _unusedResources.begin(); + + _unusedResourcesSize -= it.value()->getBytesTotal(); + it.value()->setCache(NULL); + _unusedResources.erase(it); + } +} + void ResourceCache::attemptRequest(Resource* resource) { if (_requestLimit <= 0) { // wait until a slot becomes available diff --git a/libraries/networking/src/ResourceCache.h b/libraries/networking/src/ResourceCache.h index 90d228fb07..6ae8b22445 100644 --- a/libraries/networking/src/ResourceCache.h +++ b/libraries/networking/src/ResourceCache.h @@ -65,6 +65,7 @@ protected: void addUnusedResource(const QSharedPointer& resource); void removeUnusedResource(const QSharedPointer& resource); + void reserveUnusedResource(qint64 resourceSize); static void attemptRequest(Resource* resource); static void requestCompleted(Resource* resource); From bad96e0ba40e4be3b158b16b917a07949c315da5 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Mon, 12 Jan 2015 11:37:42 -0800 Subject: [PATCH 06/24] cache size getter/setter --- libraries/networking/src/ResourceCache.cpp | 5 +++++ libraries/networking/src/ResourceCache.h | 3 +++ 2 files changed, 8 insertions(+) diff --git a/libraries/networking/src/ResourceCache.cpp b/libraries/networking/src/ResourceCache.cpp index e2fef26b22..63f4a658d1 100644 --- a/libraries/networking/src/ResourceCache.cpp +++ b/libraries/networking/src/ResourceCache.cpp @@ -72,6 +72,11 @@ QSharedPointer ResourceCache::getResource(const QUrl& url, const QUrl& return resource; } +void ResourceCache::setUnusedResourceCacheSize(qint64 unusedResourcesMaxSize) { + _unusedResourcesMaxSize = unusedResourcesMaxSize; + reserveUnusedResource(0); +} + void ResourceCache::addUnusedResource(const QSharedPointer& resource) { if (resource->getBytesTotal() > _unusedResourcesMaxSize) { // If it doesn't fit anyway, let's leave whatever is already in the cache. diff --git a/libraries/networking/src/ResourceCache.h b/libraries/networking/src/ResourceCache.h index 6ae8b22445..b2bb8b5a39 100644 --- a/libraries/networking/src/ResourceCache.h +++ b/libraries/networking/src/ResourceCache.h @@ -37,6 +37,9 @@ class ResourceCache : public QObject { public: static void setRequestLimit(int limit) { _requestLimit = limit; } static int getRequestLimit() { return _requestLimit; } + + void setUnusedResourceCacheSize(qint64 unusedResourcesMaxSize); + qint64 getUnusedResourceCacheSize() const { return _unusedResourcesMaxSize; } static const QList& getLoadingRequests() { return _loadingRequests; } From 81bf1e4f53a47f8ab490c574c3c20e509fd47d11 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Mon, 12 Jan 2015 11:46:38 -0800 Subject: [PATCH 07/24] Some code maintainance --- libraries/networking/src/ResourceCache.cpp | 25 +++++++++------------- libraries/networking/src/ResourceCache.h | 21 +++++++++--------- 2 files changed, 20 insertions(+), 26 deletions(-) diff --git a/libraries/networking/src/ResourceCache.cpp b/libraries/networking/src/ResourceCache.cpp index 63f4a658d1..089cdc5607 100644 --- a/libraries/networking/src/ResourceCache.cpp +++ b/libraries/networking/src/ResourceCache.cpp @@ -21,10 +21,7 @@ #include "ResourceCache.h" ResourceCache::ResourceCache(QObject* parent) : - QObject(parent), - _lastLRUKey(0) -{ - + QObject(parent) { } ResourceCache::~ResourceCache() { @@ -32,7 +29,7 @@ ResourceCache::~ResourceCache() { // list on destruction, so keep clearing until there are no references left while (!_unusedResources.isEmpty()) { foreach (const QSharedPointer& resource, _unusedResources) { - resource->setCache(NULL); + resource->setCache(nullptr); } _unusedResources.clear(); } @@ -104,7 +101,7 @@ void ResourceCache::reserveUnusedResource(qint64 resourceSize) { QMap >::iterator it = _unusedResources.begin(); _unusedResourcesSize -= it.value()->getBytesTotal(); - it.value()->setCache(NULL); + it.value()->setCache(nullptr); _unusedResources.erase(it); } } @@ -153,9 +150,7 @@ QList ResourceCache::_loadingRequests; Resource::Resource(const QUrl& url, bool delayLoad) : _url(url), - _request(url), - _lruKey(0), - _reply(NULL) { + _request(url) { init(); @@ -216,13 +211,13 @@ float Resource::getLoadPriority() { } void Resource::refresh() { - if (_reply == NULL && !(_loaded || _failedToLoad)) { + if (_reply == nullptr && !(_loaded || _failedToLoad)) { return; } if (_reply) { ResourceCache::requestCompleted(this); delete _reply; - _reply = NULL; + _reply = nullptr; } init(); _request.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::AlwaysNetwork); @@ -298,10 +293,10 @@ void Resource::handleDownloadProgress(qint64 bytesReceived, qint64 bytesTotal) { } _reply->disconnect(this); QNetworkReply* reply = _reply; - _reply = NULL; + _reply = nullptr; _replyTimer->disconnect(this); _replyTimer->deleteLater(); - _replyTimer = NULL; + _replyTimer = nullptr; ResourceCache::requestCompleted(this); downloadFinished(reply); @@ -333,10 +328,10 @@ void Resource::makeRequest() { void Resource::handleReplyError(QNetworkReply::NetworkError error, QDebug debug) { _reply->disconnect(this); _reply->deleteLater(); - _reply = NULL; + _reply = nullptr; _replyTimer->disconnect(this); _replyTimer->deleteLater(); - _replyTimer = NULL; + _replyTimer = nullptr; ResourceCache::requestCompleted(this); // retry for certain types of failures diff --git a/libraries/networking/src/ResourceCache.h b/libraries/networking/src/ResourceCache.h index b2bb8b5a39..8b5f1abc75 100644 --- a/libraries/networking/src/ResourceCache.h +++ b/libraries/networking/src/ResourceCache.h @@ -77,7 +77,7 @@ private: friend class Resource; QHash > _resources; - int _lastLRUKey; + int _lastLRUKey = 0; static int _requestLimit; static QList > _pendingRequests; @@ -158,9 +158,9 @@ protected: QUrl _url; QNetworkRequest _request; - bool _startedLoading; - bool _failedToLoad; - bool _loaded; + bool _startedLoading = false; + bool _failedToLoad = false; + bool _loaded = false; QHash, float> _loadPriorities; QWeakPointer _self; QPointer _cache; @@ -182,13 +182,12 @@ private: friend class ResourceCache; - int _lruKey; - QNetworkReply* _reply; - QTimer* _replyTimer; - int _index; - qint64 _bytesReceived; - qint64 _bytesTotal; - int _attempts; + int _lruKey = 0; + QNetworkReply* _reply = nullptr; + QTimer* _replyTimer = nullptr; + qint64 _bytesReceived = 0; + qint64 _bytesTotal = 0; + int _attempts = 0; }; uint qHash(const QPointer& value, uint seed = 0); From e70e435dcca6e7ad21656e90af083da9b60609d8 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Mon, 12 Jan 2015 12:45:13 -0800 Subject: [PATCH 08/24] Added Min/Max values for cache size --- libraries/networking/src/ResourceCache.cpp | 1 + libraries/networking/src/ResourceCache.h | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/libraries/networking/src/ResourceCache.cpp b/libraries/networking/src/ResourceCache.cpp index 089cdc5607..1187b311fc 100644 --- a/libraries/networking/src/ResourceCache.cpp +++ b/libraries/networking/src/ResourceCache.cpp @@ -166,6 +166,7 @@ Resource::~Resource() { if (_reply) { ResourceCache::requestCompleted(this); delete _reply; + _reply = nullptr; } } diff --git a/libraries/networking/src/ResourceCache.h b/libraries/networking/src/ResourceCache.h index 8b5f1abc75..0c2b6d2ce8 100644 --- a/libraries/networking/src/ResourceCache.h +++ b/libraries/networking/src/ResourceCache.h @@ -28,7 +28,10 @@ class QTimer; class Resource; static constexpr qint64 BYTES_PER_MEGABYTES = 1024 * 1024; -static constexpr qint64 DEFAULT_MAX_SIZE = 100 * BYTES_PER_MEGABYTES; +static constexpr qint64 BYTES_PER_GIGABYTES = 1024 * BYTES_PER_MEGABYTES; +static constexpr qint64 DEFAULT_UNUSED_MAX_SIZE = 100 * BYTES_PER_MEGABYTES; +static constexpr qint64 MIN_UNUSED_MAX_SIZE = 0; +static constexpr qint64 MAX_UNUSED_MAX_SIZE = 10 * BYTES_PER_GIGABYTES; /// Base class for resource caches. class ResourceCache : public QObject { @@ -51,7 +54,7 @@ public: void refresh(const QUrl& url); protected: - qint64 _unusedResourcesMaxSize = DEFAULT_MAX_SIZE; + qint64 _unusedResourcesMaxSize = DEFAULT_UNUSED_MAX_SIZE; qint64 _unusedResourcesSize = 0; QMap > _unusedResources; From 5be5dc716f50de4f264405603e34c41721045b3f Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Mon, 12 Jan 2015 12:45:50 -0800 Subject: [PATCH 09/24] Make sure every widget has diolog has a parent --- interface/src/ui/LodToolsDialog.cpp | 26 ++++++++++---------------- interface/src/ui/LodToolsDialog.h | 7 +++---- 2 files changed, 13 insertions(+), 20 deletions(-) diff --git a/interface/src/ui/LodToolsDialog.cpp b/interface/src/ui/LodToolsDialog.cpp index d9f2d788cd..8ff9eadc51 100644 --- a/interface/src/ui/LodToolsDialog.cpp +++ b/interface/src/ui/LodToolsDialog.cpp @@ -30,9 +30,9 @@ LodToolsDialog::LodToolsDialog(QWidget* parent) : this->setWindowTitle("LOD Tools"); // Create layouter - QFormLayout* form = new QFormLayout(); + QFormLayout* form = new QFormLayout(this); - _lodSize = new QSlider(Qt::Horizontal); + _lodSize = new QSlider(Qt::Horizontal, this); const int MAX_LOD_SIZE = MAX_LOD_SIZE_MULTIPLIER; const int MIN_LOD_SIZE = 0; const int STEP_LOD_SIZE = 1; @@ -50,7 +50,7 @@ LodToolsDialog::LodToolsDialog(QWidget* parent) : form->addRow("LOD Size Scale:", _lodSize); connect(_lodSize,SIGNAL(valueChanged(int)),this,SLOT(sizeScaleValueChanged(int))); - _boundaryLevelAdjust = new QSlider(Qt::Horizontal); + _boundaryLevelAdjust = new QSlider(Qt::Horizontal, this); const int MAX_ADJUST = 10; const int MIN_ADJUST = 0; const int STEP_ADJUST = 1; @@ -66,7 +66,7 @@ LodToolsDialog::LodToolsDialog(QWidget* parent) : connect(_boundaryLevelAdjust,SIGNAL(valueChanged(int)),this,SLOT(boundaryLevelValueChanged(int))); // Create a label with feedback... - _feedback = new QLabel(); + _feedback = new QLabel(this); QPalette palette = _feedback->palette(); const unsigned redish = 0xfff00000; palette.setColor(QPalette::WindowText, QColor::fromRgb(redish)); @@ -76,21 +76,21 @@ LodToolsDialog::LodToolsDialog(QWidget* parent) : _feedback->setFixedWidth(FEEDBACK_WIDTH); form->addRow("You can see... ", _feedback); - form->addRow("Automatic Avatar LOD Adjustment:", _automaticAvatarLOD = new QCheckBox()); + form->addRow("Automatic Avatar LOD Adjustment:", _automaticAvatarLOD = new QCheckBox(this)); _automaticAvatarLOD->setChecked(Menu::getInstance()->getAutomaticAvatarLOD()); connect(_automaticAvatarLOD, SIGNAL(toggled(bool)), SLOT(updateAvatarLODControls())); - form->addRow("Decrease Avatar LOD Below FPS:", _avatarLODDecreaseFPS = new QDoubleSpinBox()); + form->addRow("Decrease Avatar LOD Below FPS:", _avatarLODDecreaseFPS = new QDoubleSpinBox(this)); _avatarLODDecreaseFPS->setValue(Menu::getInstance()->getAvatarLODDecreaseFPS()); _avatarLODDecreaseFPS->setDecimals(0); connect(_avatarLODDecreaseFPS, SIGNAL(valueChanged(double)), SLOT(updateAvatarLODValues())); - form->addRow("Increase Avatar LOD Above FPS:", _avatarLODIncreaseFPS = new QDoubleSpinBox()); + form->addRow("Increase Avatar LOD Above FPS:", _avatarLODIncreaseFPS = new QDoubleSpinBox(this)); _avatarLODIncreaseFPS->setValue(Menu::getInstance()->getAvatarLODIncreaseFPS()); _avatarLODIncreaseFPS->setDecimals(0); connect(_avatarLODIncreaseFPS, SIGNAL(valueChanged(double)), SLOT(updateAvatarLODValues())); - form->addRow("Avatar LOD:", _avatarLOD = new QDoubleSpinBox()); + form->addRow("Avatar LOD:", _avatarLOD = new QDoubleSpinBox(this)); _avatarLOD->setDecimals(3); _avatarLOD->setRange(1.0 / MAXIMUM_AVATAR_LOD_DISTANCE_MULTIPLIER, 1.0 / MINIMUM_AVATAR_LOD_DISTANCE_MULTIPLIER); _avatarLOD->setSingleStep(0.001); @@ -98,21 +98,15 @@ LodToolsDialog::LodToolsDialog(QWidget* parent) : connect(_avatarLOD, SIGNAL(valueChanged(double)), SLOT(updateAvatarLODValues())); // Add a button to reset - QPushButton* resetButton = new QPushButton("Reset"); + QPushButton* resetButton = new QPushButton("Reset", this); form->addRow("", resetButton); - connect(resetButton,SIGNAL(clicked(bool)),this,SLOT(resetClicked(bool))); + connect(resetButton, SIGNAL(clicked(bool)), this, SLOT(resetClicked(bool))); this->QDialog::setLayout(form); updateAvatarLODControls(); } -LodToolsDialog::~LodToolsDialog() { - delete _feedback; - delete _lodSize; - delete _boundaryLevelAdjust; -} - void LodToolsDialog::reloadSliders() { _lodSize->setValue(Menu::getInstance()->getOctreeSizeScale() / TREE_SCALE); _boundaryLevelAdjust->setValue(Menu::getInstance()->getBoundaryLevelAdjust()); diff --git a/interface/src/ui/LodToolsDialog.h b/interface/src/ui/LodToolsDialog.h index 5b34a5efd0..772027790c 100644 --- a/interface/src/ui/LodToolsDialog.h +++ b/interface/src/ui/LodToolsDialog.h @@ -13,18 +13,17 @@ #define hifi_LodToolsDialog_h #include -#include -#include class QCheckBox; class QDoubleSpinBox; +class QLabel; +class QSlider; class LodToolsDialog : public QDialog { Q_OBJECT public: // Sets up the UI LodToolsDialog(QWidget* parent); - ~LodToolsDialog(); signals: void closed(); @@ -41,7 +40,7 @@ public slots: protected: // Emits a 'closed' signal when this dialog is closed. - void closeEvent(QCloseEvent*); + void closeEvent(QCloseEvent* event); private: QSlider* _lodSize; From 38dc1643ef9ed139c9a0418286eec905dd6dbd64 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Mon, 12 Jan 2015 12:46:11 -0800 Subject: [PATCH 10/24] New Caches size dialog --- interface/src/ui/CachesSizeDialog.cpp | 83 +++++++++++++++++++++++++++ interface/src/ui/CachesSizeDialog.h | 45 +++++++++++++++ 2 files changed, 128 insertions(+) create mode 100644 interface/src/ui/CachesSizeDialog.cpp create mode 100644 interface/src/ui/CachesSizeDialog.h diff --git a/interface/src/ui/CachesSizeDialog.cpp b/interface/src/ui/CachesSizeDialog.cpp new file mode 100644 index 0000000000..9e5d1fd9e0 --- /dev/null +++ b/interface/src/ui/CachesSizeDialog.cpp @@ -0,0 +1,83 @@ +// +// CachesSizeDialog.cpp +// +// +// Created by Clement on 1/12/15. +// Copyright 2015 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 +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "CachesSizeDialog.h" + + +QDoubleSpinBox* createDoubleSpinBox(QWidget* parent) { + QDoubleSpinBox* box = new QDoubleSpinBox(parent); + box->setDecimals(0); + box->setRange(MIN_UNUSED_MAX_SIZE / BYTES_PER_MEGABYTES, MAX_UNUSED_MAX_SIZE / BYTES_PER_MEGABYTES); + + return box; +} + +CachesSizeDialog::CachesSizeDialog(QWidget* parent) : + QDialog(parent, Qt::Window | Qt::WindowCloseButtonHint) +{ + setWindowTitle("Caches Size"); + + // Create layouter + QFormLayout* form = new QFormLayout(this); + setLayout(form); + + form->addRow("Animations cache size (MB):", _animations = createDoubleSpinBox(this)); + form->addRow("Geometries cache size (MB):", _geometries = createDoubleSpinBox(this)); + form->addRow("Scripts cache size (MB):", _scripts = createDoubleSpinBox(this)); + form->addRow("Sounds cache size (MB):", _sounds = createDoubleSpinBox(this)); + form->addRow("Textures cache size (MB):", _textures = createDoubleSpinBox(this)); + + resetClicked(true); + + // Add a button to reset + QPushButton* confirmButton = new QPushButton("Confirm", this); + QPushButton* resetButton = new QPushButton("Reset", this); + form->addRow(confirmButton, resetButton); + connect(confirmButton, SIGNAL(clicked(bool)), this, SLOT(confirmClicked(bool))); + connect(resetButton, SIGNAL(clicked(bool)), this, SLOT(resetClicked(bool))); +} + +void CachesSizeDialog::confirmClicked(bool checked) { + DependencyManager::get()->setUnusedResourceCacheSize(_animations->value() * BYTES_PER_MEGABYTES); + DependencyManager::get()->setUnusedResourceCacheSize(_geometries->value() * BYTES_PER_MEGABYTES); + DependencyManager::get()->setUnusedResourceCacheSize(_scripts->value() * BYTES_PER_MEGABYTES); + DependencyManager::get()->setUnusedResourceCacheSize(_sounds->value() * BYTES_PER_MEGABYTES); + DependencyManager::get()->setUnusedResourceCacheSize(_textures->value() * BYTES_PER_MEGABYTES); +} + +void CachesSizeDialog::resetClicked(bool checked) { + _animations->setValue(DependencyManager::get()->getUnusedResourceCacheSize() / BYTES_PER_MEGABYTES); + _geometries->setValue(DependencyManager::get()->getUnusedResourceCacheSize() / BYTES_PER_MEGABYTES); + _scripts->setValue(DependencyManager::get()->getUnusedResourceCacheSize() / BYTES_PER_MEGABYTES); + _sounds->setValue(DependencyManager::get()->getUnusedResourceCacheSize() / BYTES_PER_MEGABYTES); + _textures->setValue(DependencyManager::get()->getUnusedResourceCacheSize() / BYTES_PER_MEGABYTES); +} + +void CachesSizeDialog::reject() { + // Just regularly close upon ESC + this->QDialog::close(); +} + +void CachesSizeDialog::closeEvent(QCloseEvent* event) { + this->QDialog::closeEvent(event); + emit closed(); +} \ No newline at end of file diff --git a/interface/src/ui/CachesSizeDialog.h b/interface/src/ui/CachesSizeDialog.h new file mode 100644 index 0000000000..fa01ce4534 --- /dev/null +++ b/interface/src/ui/CachesSizeDialog.h @@ -0,0 +1,45 @@ +// +// CachesSizeDialog.h +// +// +// Created by Clement on 1/12/15. +// Copyright 2015 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 +// + +#ifndef hifi_CachesSizeDialog_h +#define hifi_CachesSizeDialog_h + +#include + +class QDoubleSpinBox; + +class CachesSizeDialog : public QDialog { + Q_OBJECT +public: + // Sets up the UI + CachesSizeDialog(QWidget* parent); + +signals: + void closed(); + +public slots: + void reject(); + void confirmClicked(bool checked); + void resetClicked(bool checked); + +protected: + // Emits a 'closed' signal when this dialog is closed. + void closeEvent(QCloseEvent* event); + +private: + QDoubleSpinBox* _animations = nullptr; + QDoubleSpinBox* _geometries = nullptr; + QDoubleSpinBox* _scripts = nullptr; + QDoubleSpinBox* _sounds = nullptr; + QDoubleSpinBox* _textures = nullptr; +}; + +#endif // hifi_CachesSizeDialog_h \ No newline at end of file From 19f321c171ce1d8cd679b8df2c850d2cab265321 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Mon, 12 Jan 2015 13:56:41 -0800 Subject: [PATCH 11/24] Fixed caches not in DM --- interface/src/ui/CachesSizeDialog.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/interface/src/ui/CachesSizeDialog.cpp b/interface/src/ui/CachesSizeDialog.cpp index 9e5d1fd9e0..12e88f5100 100644 --- a/interface/src/ui/CachesSizeDialog.cpp +++ b/interface/src/ui/CachesSizeDialog.cpp @@ -59,16 +59,16 @@ CachesSizeDialog::CachesSizeDialog(QWidget* parent) : void CachesSizeDialog::confirmClicked(bool checked) { DependencyManager::get()->setUnusedResourceCacheSize(_animations->value() * BYTES_PER_MEGABYTES); DependencyManager::get()->setUnusedResourceCacheSize(_geometries->value() * BYTES_PER_MEGABYTES); - DependencyManager::get()->setUnusedResourceCacheSize(_scripts->value() * BYTES_PER_MEGABYTES); - DependencyManager::get()->setUnusedResourceCacheSize(_sounds->value() * BYTES_PER_MEGABYTES); + ScriptCache::getInstance()->setUnusedResourceCacheSize(_scripts->value() * BYTES_PER_MEGABYTES); + SoundCache::getInstance().setUnusedResourceCacheSize(_sounds->value() * BYTES_PER_MEGABYTES); DependencyManager::get()->setUnusedResourceCacheSize(_textures->value() * BYTES_PER_MEGABYTES); } void CachesSizeDialog::resetClicked(bool checked) { _animations->setValue(DependencyManager::get()->getUnusedResourceCacheSize() / BYTES_PER_MEGABYTES); _geometries->setValue(DependencyManager::get()->getUnusedResourceCacheSize() / BYTES_PER_MEGABYTES); - _scripts->setValue(DependencyManager::get()->getUnusedResourceCacheSize() / BYTES_PER_MEGABYTES); - _sounds->setValue(DependencyManager::get()->getUnusedResourceCacheSize() / BYTES_PER_MEGABYTES); + _scripts->setValue(ScriptCache::getInstance()->getUnusedResourceCacheSize() / BYTES_PER_MEGABYTES); + _sounds->setValue(SoundCache::getInstance().getUnusedResourceCacheSize() / BYTES_PER_MEGABYTES); _textures->setValue(DependencyManager::get()->getUnusedResourceCacheSize() / BYTES_PER_MEGABYTES); } From 894c4c9d59c0692e6b93a64a5a5c9781057e04aa Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Mon, 12 Jan 2015 14:00:23 -0800 Subject: [PATCH 12/24] All dialogs in Menu are QPointers --- interface/src/Menu.cpp | 10 ++-------- interface/src/Menu.h | 12 ++++++------ 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index c50c722d4a..d4b4671ac1 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -93,17 +93,11 @@ const int CONSOLE_HEIGHT = 200; Menu::Menu() : _actionHash(), _receivedAudioStreamSettings(), - _bandwidthDialog(NULL), _fieldOfView(DEFAULT_FIELD_OF_VIEW_DEGREES), _realWorldFieldOfView(DEFAULT_REAL_WORLD_FIELD_OF_VIEW_DEGREES), _faceshiftEyeDeflection(DEFAULT_FACESHIFT_EYE_DEFLECTION), _faceshiftHostname(DEFAULT_FACESHIFT_HOSTNAME), _jsConsole(NULL), - _octreeStatsDialog(NULL), - _lodToolsDialog(NULL), - _hmdToolsDialog(NULL), - _newLocationDialog(NULL), - _userLocationsDialog(NULL), #if defined(Q_OS_MAC) || defined(Q_OS_WIN) _speechRecognizer(), #endif @@ -122,8 +116,8 @@ Menu::Menu() : _fpsAverage(FIVE_SECONDS_OF_FRAMES), _fastFPSAverage(ONE_SECOND_OF_FRAMES), _loginAction(NULL), - _preferencesDialog(NULL), - _loginDialog(NULL), + _newLocationDialog(NULL), + _userLocationsDialog(NULL), _hasLoginDialogDisplayed(false), _snapshotsLocation(), _scriptsLocation(), diff --git a/interface/src/Menu.h b/interface/src/Menu.h index 20408f1406..20a7e7ebb8 100644 --- a/interface/src/Menu.h +++ b/interface/src/Menu.h @@ -242,7 +242,6 @@ private: QHash _actionHash; InboundAudioStream::Settings _receivedAudioStreamSettings; - BandwidthDialog* _bandwidthDialog; float _fieldOfView; /// in Degrees, doesn't apply to HMD like Oculus float _realWorldFieldOfView; // The actual FOV set by the user's monitor size and view distance float _faceshiftEyeDeflection; @@ -252,11 +251,6 @@ private: QPointer _ScriptEditor; QPointer _chatWindow; QDialog* _jsConsole; - OctreeStatsDialog* _octreeStatsDialog; - LodToolsDialog* _lodToolsDialog; - HMDToolsDialog* _hmdToolsDialog; - QPointer _newLocationDialog; - QPointer _userLocationsDialog; #if defined(Q_OS_MAC) || defined(Q_OS_WIN) SpeechRecognizer _speechRecognizer; #endif @@ -276,6 +270,12 @@ private: SimpleMovingAverage _fpsAverage; SimpleMovingAverage _fastFPSAverage; QAction* _loginAction; + QPointer _bandwidthDialog; + QPointer _octreeStatsDialog; + QPointer _lodToolsDialog; + QPointer _hmdToolsDialog; + QPointer _newLocationDialog; + QPointer _userLocationsDialog; QPointer _preferencesDialog; QPointer _attachmentsDialog; QPointer _animationsDialog; From fd2b0edf7a65c1d977b94350ac9e07f89bc3cfdb Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Mon, 12 Jan 2015 14:01:56 -0800 Subject: [PATCH 13/24] Alphabetical order --- interface/src/Menu.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/interface/src/Menu.h b/interface/src/Menu.h index 20a7e7ebb8..502ab01633 100644 --- a/interface/src/Menu.h +++ b/interface/src/Menu.h @@ -270,17 +270,17 @@ private: SimpleMovingAverage _fpsAverage; SimpleMovingAverage _fastFPSAverage; QAction* _loginAction; + QPointer _addressBarDialog; + QPointer _animationsDialog; + QPointer _attachmentsDialog; QPointer _bandwidthDialog; - QPointer _octreeStatsDialog; - QPointer _lodToolsDialog; - QPointer _hmdToolsDialog; QPointer _newLocationDialog; QPointer _userLocationsDialog; - QPointer _preferencesDialog; - QPointer _attachmentsDialog; - QPointer _animationsDialog; - QPointer _addressBarDialog; + QPointer _hmdToolsDialog; + QPointer _lodToolsDialog; QPointer _loginDialog; + QPointer _octreeStatsDialog; + QPointer _preferencesDialog; bool _hasLoginDialogDisplayed; QAction* _chatAction; QString _snapshotsLocation; From e62fbe25579b385619abe8dd934859f79f4c497c Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Mon, 12 Jan 2015 14:09:26 -0800 Subject: [PATCH 14/24] Cleanup some headers --- interface/src/Menu.cpp | 32 ++++++++------------------------ interface/src/Menu.h | 11 +++++------ 2 files changed, 13 insertions(+), 30 deletions(-) diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index d4b4671ac1..c25ab67db5 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -51,13 +51,20 @@ #include "scripting/LocationScriptingInterface.h" #include "scripting/MenuScriptingInterface.h" #include "Util.h" +#include "ui/AddressBarDialog.h" #include "ui/AnimationsDialog.h" #include "ui/AttachmentsDialog.h" +#include "ui/BandwidthDialog" +#include "ui/DataWebDialog" +#include "ui/HMDToolsDialog" +#include "ui/LodToolsDialog" +#include "ui/LoginDialog.h" +#include "ui/OctreeStatsDialog" +#include "ui/PreferencesDialog" #include "ui/InfoView.h" #include "ui/MetavoxelEditor.h" #include "ui/MetavoxelNetworkSimulator.h" #include "ui/ModelsBrowser.h" -#include "ui/LoginDialog.h" #include "ui/NodeBounds.h" Menu* Menu::_instance = NULL; @@ -613,15 +620,6 @@ Menu::Menu() : #endif } -Menu::~Menu() { - bandwidthDetailsClosed(); - octreeStatsDetailsClosed(); - if (_hmdToolsDialog) { - delete _hmdToolsDialog; - _hmdToolsDialog = NULL; - } -} - void Menu::loadSettings(QSettings* settings) { bool lockedSettings = false; if (!settings) { @@ -1247,13 +1245,6 @@ void Menu::audioMuteToggled() { } } -void Menu::bandwidthDetailsClosed() { - if (_bandwidthDialog) { - delete _bandwidthDialog; - _bandwidthDialog = NULL; - } -} - void Menu::octreeStatsDetails() { if (!_octreeStatsDialog) { _octreeStatsDialog = new OctreeStatsDialog(DependencyManager::get().data(), @@ -1267,13 +1258,6 @@ void Menu::octreeStatsDetails() { _octreeStatsDialog->raise(); } -void Menu::octreeStatsDetailsClosed() { - if (_octreeStatsDialog) { - delete _octreeStatsDialog; - _octreeStatsDialog = NULL; - } -} - QString Menu::getLODFeedbackText() { // determine granularity feedback int boundaryLevelAdjust = getBoundaryLevelAdjust(); diff --git a/interface/src/Menu.h b/interface/src/Menu.h index 502ab01633..2cd9c8ecf2 100644 --- a/interface/src/Menu.h +++ b/interface/src/Menu.h @@ -27,12 +27,8 @@ #include "SpeechRecognizer.h" #endif -#include "ui/AddressBarDialog.h" #include "ui/ChatWindow.h" -#include "ui/DataWebDialog.h" #include "ui/JSConsole.h" -#include "ui/LoginDialog.h" -#include "ui/PreferencesDialog.h" #include "ui/ScriptEditorWindow.h" const float ADJUST_LOD_DOWN_FPS = 40.0; @@ -54,22 +50,25 @@ const float MAXIMUM_AVATAR_LOD_DISTANCE_MULTIPLIER = 15.0f; const QString SETTINGS_ADDRESS_KEY = "address"; class QSettings; +class AddressBarDialog; class AnimationsDialog; class AttachmentsDialog; class BandwidthDialog; +class DataWebDialog; class HMDToolsDialog; class LodToolsDialog; +class LoginDialog; +class OctreeStatsDialog; +class PreferencesDialog; class MetavoxelEditor; class MetavoxelNetworkSimulator; class ChatWindow; -class OctreeStatsDialog; class MenuItemProperties; class Menu : public QMenuBar { Q_OBJECT public: static Menu* getInstance(); - ~Menu(); void triggerOption(const QString& menuOption); QAction* getActionForOption(const QString& menuOption); From 7bf57b3cca68b09d75fc83d87ecb618b2241a175 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Mon, 12 Jan 2015 14:53:31 -0800 Subject: [PATCH 15/24] Removed unecessary method/cleanup header --- interface/src/Menu.cpp | 32 ++++++++++---------------------- interface/src/Menu.h | 10 ++++------ 2 files changed, 14 insertions(+), 28 deletions(-) diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index c25ab67db5..3e4f2c212a 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -54,13 +54,14 @@ #include "ui/AddressBarDialog.h" #include "ui/AnimationsDialog.h" #include "ui/AttachmentsDialog.h" -#include "ui/BandwidthDialog" -#include "ui/DataWebDialog" -#include "ui/HMDToolsDialog" -#include "ui/LodToolsDialog" +#include "ui/BandwidthDialog.h" +#include "ui/CachesSizeDialog.h" +#include "ui/DataWebDialog.h" +#include "ui/HMDToolsDialog.h" +#include "ui/LodToolsDialog.h" #include "ui/LoginDialog.h" -#include "ui/OctreeStatsDialog" -#include "ui/PreferencesDialog" +#include "ui/OctreeStatsDialog.h" +#include "ui/PreferencesDialog.h" #include "ui/InfoView.h" #include "ui/MetavoxelEditor.h" #include "ui/MetavoxelNetworkSimulator.h" @@ -122,13 +123,7 @@ Menu::Menu() : _lastAvatarDetailDrop(usecTimestampNow()), _fpsAverage(FIVE_SECONDS_OF_FRAMES), _fastFPSAverage(ONE_SECOND_OF_FRAMES), - _loginAction(NULL), - _newLocationDialog(NULL), - _userLocationsDialog(NULL), _hasLoginDialogDisplayed(false), - _snapshotsLocation(), - _scriptsLocation(), - _walletPrivateKey(), _shouldRenderTableNeedsRebuilding(true) { Application *appInstance = Application::getInstance(); @@ -1145,7 +1140,7 @@ void Menu::bandwidthDetails() { if (! _bandwidthDialog) { _bandwidthDialog = new BandwidthDialog(DependencyManager::get().data(), Application::getInstance()->getBandwidthMeter()); - connect(_bandwidthDialog, SIGNAL(closed()), SLOT(bandwidthDetailsClosed())); + connect(_bandwidthDialog, SIGNAL(closed()), _bandwidthDialog, SLOT(deleteLater())); _bandwidthDialog->show(); @@ -1249,7 +1244,7 @@ void Menu::octreeStatsDetails() { if (!_octreeStatsDialog) { _octreeStatsDialog = new OctreeStatsDialog(DependencyManager::get().data(), Application::getInstance()->getOcteeSceneStats()); - connect(_octreeStatsDialog, SIGNAL(closed()), SLOT(octreeStatsDetailsClosed())); + connect(_octreeStatsDialog, SIGNAL(closed()), _octreeStatsDialog, SLOT(deleteLater())); _octreeStatsDialog->show(); if (_hmdToolsDialog) { _hmdToolsDialog->watchWindow(_octreeStatsDialog->windowHandle()); @@ -1425,7 +1420,7 @@ bool Menu::shouldRenderMesh(float largestDimension, float distanceToCamera) { void Menu::lodTools() { if (!_lodToolsDialog) { _lodToolsDialog = new LodToolsDialog(DependencyManager::get().data()); - connect(_lodToolsDialog, SIGNAL(closed()), SLOT(lodToolsClosed())); + connect(_lodToolsDialog, SIGNAL(closed()), _lodToolsDialog, SLOT(deleteLater())); _lodToolsDialog->show(); if (_hmdToolsDialog) { _hmdToolsDialog->watchWindow(_lodToolsDialog->windowHandle()); @@ -1434,13 +1429,6 @@ void Menu::lodTools() { _lodToolsDialog->raise(); } -void Menu::lodToolsClosed() { - if (_lodToolsDialog) { - delete _lodToolsDialog; - _lodToolsDialog = NULL; - } -} - void Menu::hmdTools(bool showTools) { if (showTools) { if (!_hmdToolsDialog) { diff --git a/interface/src/Menu.h b/interface/src/Menu.h index 2cd9c8ecf2..3bc15fd99a 100644 --- a/interface/src/Menu.h +++ b/interface/src/Menu.h @@ -53,6 +53,7 @@ class QSettings; class AddressBarDialog; class AnimationsDialog; class AttachmentsDialog; +class CachesSizeDialog; class BandwidthDialog; class DataWebDialog; class HMDToolsDialog; @@ -190,9 +191,6 @@ private slots: void changePrivateKey(); void nameLocation(); void toggleLocationList(); - void bandwidthDetailsClosed(); - void octreeStatsDetailsClosed(); - void lodToolsClosed(); void hmdToolsClosed(); void runTests(); void showMetavoxelEditor(); @@ -263,16 +261,15 @@ private: float _avatarLODDistanceMultiplier; int _boundaryLevelAdjust; int _maxOctreePacketsPerSecond; - QString replaceLastOccurrence(QChar search, QChar replace, QString string); quint64 _lastAdjust; quint64 _lastAvatarDetailDrop; SimpleMovingAverage _fpsAverage; SimpleMovingAverage _fastFPSAverage; - QAction* _loginAction; QPointer _addressBarDialog; QPointer _animationsDialog; QPointer _attachmentsDialog; QPointer _bandwidthDialog; + QPointer _cachesSizeDialog; QPointer _newLocationDialog; QPointer _userLocationsDialog; QPointer _hmdToolsDialog; @@ -281,7 +278,8 @@ private: QPointer _octreeStatsDialog; QPointer _preferencesDialog; bool _hasLoginDialogDisplayed; - QAction* _chatAction; + QAction* _loginAction = nullptr; + QAction* _chatAction = nullptr; QString _snapshotsLocation; QString _scriptsLocation; QByteArray _walletPrivateKey; From 59c9e0bb50aa08925921a5e56d1d783942255b8f Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Mon, 12 Jan 2015 15:19:36 -0800 Subject: [PATCH 16/24] Wire CachesSizeDialog in Menu --- interface/src/Menu.cpp | 13 +++++++++++++ interface/src/Menu.h | 2 ++ interface/src/ui/CachesSizeDialog.cpp | 6 ++++-- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index 3e4f2c212a..2cc16102b0 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -488,6 +488,7 @@ Menu::Menu() : false, &UserActivityLogger::getInstance(), SLOT(disable(bool))); + addActionToQMenuAndActionHash(networkMenu, MenuOption::CachesSize, 0, this, SLOT(cachesSizeDialog())); addActionToQMenuAndActionHash(developerMenu, MenuOption::WalletPrivateKey, 0, this, SLOT(changePrivateKey())); @@ -1416,6 +1417,18 @@ bool Menu::shouldRenderMesh(float largestDimension, float distanceToCamera) { return (distanceToCamera <= visibleDistanceAtClosestScale); } +void Menu::cachesSizeDialog() { + qDebug() << "Caches size:" << _cachesSizeDialog.isNull(); + if (!_cachesSizeDialog) { + _cachesSizeDialog = new CachesSizeDialog(DependencyManager::get().data()); + connect(_cachesSizeDialog, SIGNAL(closed()), _cachesSizeDialog, SLOT(deleteLater())); + _cachesSizeDialog->show(); + if (_hmdToolsDialog) { + _hmdToolsDialog->watchWindow(_cachesSizeDialog->windowHandle()); + } + } + _cachesSizeDialog->raise(); +} void Menu::lodTools() { if (!_lodToolsDialog) { diff --git a/interface/src/Menu.h b/interface/src/Menu.h index 3bc15fd99a..c23559229d 100644 --- a/interface/src/Menu.h +++ b/interface/src/Menu.h @@ -159,6 +159,7 @@ public slots: void showLoginForCurrentDomain(); void bandwidthDetails(); void octreeStatsDetails(); + void cachesSizeDialog(); void lodTools(); void hmdTools(bool showTools); void loadSettings(QSettings* settings = NULL); @@ -315,6 +316,7 @@ namespace MenuOption { const QString BandwidthDetails = "Bandwidth Details"; const QString BlueSpeechSphere = "Blue Sphere While Speaking"; const QString CascadedShadows = "Cascaded"; + const QString CachesSize = "Caches Size"; const QString Chat = "Chat..."; const QString ChatCircling = "Chat Circling"; const QString CollideAsRagdoll = "Collide With Self (Ragdoll)"; diff --git a/interface/src/ui/CachesSizeDialog.cpp b/interface/src/ui/CachesSizeDialog.cpp index 12e88f5100..4d4457c922 100644 --- a/interface/src/ui/CachesSizeDialog.cpp +++ b/interface/src/ui/CachesSizeDialog.cpp @@ -62,6 +62,8 @@ void CachesSizeDialog::confirmClicked(bool checked) { ScriptCache::getInstance()->setUnusedResourceCacheSize(_scripts->value() * BYTES_PER_MEGABYTES); SoundCache::getInstance().setUnusedResourceCacheSize(_sounds->value() * BYTES_PER_MEGABYTES); DependencyManager::get()->setUnusedResourceCacheSize(_textures->value() * BYTES_PER_MEGABYTES); + + QDialog::close(); } void CachesSizeDialog::resetClicked(bool checked) { @@ -74,10 +76,10 @@ void CachesSizeDialog::resetClicked(bool checked) { void CachesSizeDialog::reject() { // Just regularly close upon ESC - this->QDialog::close(); + QDialog::close(); } void CachesSizeDialog::closeEvent(QCloseEvent* event) { - this->QDialog::closeEvent(event); + QDialog::closeEvent(event); emit closed(); } \ No newline at end of file From 8415098fc2ef0a22735d7662af3c6d1ae4c287e2 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Mon, 12 Jan 2015 15:36:36 -0800 Subject: [PATCH 17/24] Set different caches size depending on cache type --- libraries/animation/src/AnimationCache.cpp | 5 ++++- libraries/audio/src/SoundCache.cpp | 3 ++- libraries/metavoxels/src/ScriptCache.cpp | 7 +++++-- libraries/networking/src/ResourceCache.cpp | 4 +++- libraries/networking/src/ResourceCache.h | 7 +++++++ libraries/render-utils/src/GeometryCache.cpp | 2 ++ libraries/render-utils/src/TextureCache.cpp | 2 ++ 7 files changed, 25 insertions(+), 5 deletions(-) diff --git a/libraries/animation/src/AnimationCache.cpp b/libraries/animation/src/AnimationCache.cpp index 1a68aeb908..6c02ccbd2b 100644 --- a/libraries/animation/src/AnimationCache.cpp +++ b/libraries/animation/src/AnimationCache.cpp @@ -17,7 +17,10 @@ static int animationPointerMetaTypeId = qRegisterMetaType(); AnimationCache::AnimationCache(QObject* parent) : - ResourceCache(parent) { + ResourceCache(parent) +{ + const qint64 ANIMATION_DEFAULT_UNUSED_MAX_SIZE = 50 * BYTES_PER_MEGABYTES; + setUnusedResourceCacheSize(ANIMATION_DEFAULT_UNUSED_MAX_SIZE); } AnimationPointer AnimationCache::getAnimation(const QUrl& url) { diff --git a/libraries/audio/src/SoundCache.cpp b/libraries/audio/src/SoundCache.cpp index 4fbd98fea0..fe05372ce5 100644 --- a/libraries/audio/src/SoundCache.cpp +++ b/libraries/audio/src/SoundCache.cpp @@ -23,7 +23,8 @@ SoundCache& SoundCache::getInstance() { SoundCache::SoundCache(QObject* parent) : ResourceCache(parent) { - + const qint64 SOUND_DEFAULT_UNUSED_MAX_SIZE = 50 * BYTES_PER_MEGABYTES; + setUnusedResourceCacheSize(SOUND_DEFAULT_UNUSED_MAX_SIZE); } SharedSoundPointer SoundCache::getSound(const QUrl& url) { diff --git a/libraries/metavoxels/src/ScriptCache.cpp b/libraries/metavoxels/src/ScriptCache.cpp index ffd5200a2e..7e8dbc4bae 100644 --- a/libraries/metavoxels/src/ScriptCache.cpp +++ b/libraries/metavoxels/src/ScriptCache.cpp @@ -109,9 +109,12 @@ ScriptCache* ScriptCache::getInstance() { } ScriptCache::ScriptCache() : - _engine(NULL) { - + _engine(NULL) +{ setEngine(new QScriptEngine(this)); + + const qint64 SCRIPT_DEFAULT_UNUSED_MAX_SIZE = 50 * BYTES_PER_MEGABYTES; + setUnusedResourceCacheSize(SCRIPT_DEFAULT_UNUSED_MAX_SIZE); } void ScriptCache::setEngine(QScriptEngine* engine) { diff --git a/libraries/networking/src/ResourceCache.cpp b/libraries/networking/src/ResourceCache.cpp index 1187b311fc..f4d9a2909d 100644 --- a/libraries/networking/src/ResourceCache.cpp +++ b/libraries/networking/src/ResourceCache.cpp @@ -16,6 +16,8 @@ #include #include +#include + #include "NetworkAccessManager.h" #include "ResourceCache.h" @@ -70,7 +72,7 @@ QSharedPointer ResourceCache::getResource(const QUrl& url, const QUrl& } void ResourceCache::setUnusedResourceCacheSize(qint64 unusedResourcesMaxSize) { - _unusedResourcesMaxSize = unusedResourcesMaxSize; + _unusedResourcesMaxSize = glm::clamp(unusedResourcesMaxSize, MIN_UNUSED_MAX_SIZE, MAX_UNUSED_MAX_SIZE); reserveUnusedResource(0); } diff --git a/libraries/networking/src/ResourceCache.h b/libraries/networking/src/ResourceCache.h index 0c2b6d2ce8..7b8ffc392b 100644 --- a/libraries/networking/src/ResourceCache.h +++ b/libraries/networking/src/ResourceCache.h @@ -29,7 +29,14 @@ class Resource; static constexpr qint64 BYTES_PER_MEGABYTES = 1024 * 1024; static constexpr qint64 BYTES_PER_GIGABYTES = 1024 * BYTES_PER_MEGABYTES; + +// Windows can have troubles allocating that much memory in ram sometimes +// so default cache size at 100 MB on windows (1GB otherwise) +#ifdef Q_OS_WIN32 static constexpr qint64 DEFAULT_UNUSED_MAX_SIZE = 100 * BYTES_PER_MEGABYTES; +#else +static constexpr qint64 DEFAULT_UNUSED_MAX_SIZE = 1024 * BYTES_PER_MEGABYTES; +#endif static constexpr qint64 MIN_UNUSED_MAX_SIZE = 0; static constexpr qint64 MAX_UNUSED_MAX_SIZE = 10 * BYTES_PER_GIGABYTES; diff --git a/libraries/render-utils/src/GeometryCache.cpp b/libraries/render-utils/src/GeometryCache.cpp index 553e460a5c..25f988472f 100644 --- a/libraries/render-utils/src/GeometryCache.cpp +++ b/libraries/render-utils/src/GeometryCache.cpp @@ -30,6 +30,8 @@ const int GeometryCache::UNKNOWN_ID = -1; GeometryCache::GeometryCache() : _nextID(0) { + const qint64 GEOMETRY_DEFAULT_UNUSED_MAX_SIZE = DEFAULT_UNUSED_MAX_SIZE; + setUnusedResourceCacheSize(GEOMETRY_DEFAULT_UNUSED_MAX_SIZE); } GeometryCache::~GeometryCache() { diff --git a/libraries/render-utils/src/TextureCache.cpp b/libraries/render-utils/src/TextureCache.cpp index 0f34282162..3bd05a14ee 100644 --- a/libraries/render-utils/src/TextureCache.cpp +++ b/libraries/render-utils/src/TextureCache.cpp @@ -39,6 +39,8 @@ TextureCache::TextureCache() : _frameBufferSize(100, 100), _associatedWidget(NULL) { + const qint64 TEXTURE_DEFAULT_UNUSED_MAX_SIZE = DEFAULT_UNUSED_MAX_SIZE; + setUnusedResourceCacheSize(TEXTURE_DEFAULT_UNUSED_MAX_SIZE); } TextureCache::~TextureCache() { From e30b119464303707dc29ce64fe88c54ceeeee673 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Mon, 12 Jan 2015 15:55:25 -0800 Subject: [PATCH 18/24] Some simple code cleanup --- interface/src/Menu.cpp | 37 +------------- interface/src/Menu.h | 65 +++++++++++++++---------- interface/src/ui/JSConsole.h | 5 ++ interface/src/ui/ScriptEditorWindow.cpp | 2 - 4 files changed, 46 insertions(+), 63 deletions(-) diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index 2cc16102b0..48403b7511 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -87,44 +87,9 @@ Menu* Menu::getInstance() { return _instance; } -const float DEFAULT_FACESHIFT_EYE_DEFLECTION = 0.25f; -const QString DEFAULT_FACESHIFT_HOSTNAME = "localhost"; -const float DEFAULT_AVATAR_LOD_DISTANCE_MULTIPLIER = 1.0f; -const int ONE_SECOND_OF_FRAMES = 60; -const int FIVE_SECONDS_OF_FRAMES = 5 * ONE_SECOND_OF_FRAMES; - -const QString CONSOLE_TITLE = "Scripting Console"; -const float CONSOLE_WINDOW_OPACITY = 0.95f; -const int CONSOLE_WIDTH = 800; -const int CONSOLE_HEIGHT = 200; - Menu::Menu() : - _actionHash(), - _receivedAudioStreamSettings(), - _fieldOfView(DEFAULT_FIELD_OF_VIEW_DEGREES), - _realWorldFieldOfView(DEFAULT_REAL_WORLD_FIELD_OF_VIEW_DEGREES), - _faceshiftEyeDeflection(DEFAULT_FACESHIFT_EYE_DEFLECTION), - _faceshiftHostname(DEFAULT_FACESHIFT_HOSTNAME), - _jsConsole(NULL), -#if defined(Q_OS_MAC) || defined(Q_OS_WIN) - _speechRecognizer(), -#endif - _octreeSizeScale(DEFAULT_OCTREE_SIZE_SCALE), - _oculusUIAngularSize(DEFAULT_OCULUS_UI_ANGULAR_SIZE), - _sixenseReticleMoveSpeed(DEFAULT_SIXENSE_RETICLE_MOVE_SPEED), - _invertSixenseButtons(DEFAULT_INVERT_SIXENSE_MOUSE_BUTTONS), - _automaticAvatarLOD(true), - _avatarLODDecreaseFPS(DEFAULT_ADJUST_AVATAR_LOD_DOWN_FPS), - _avatarLODIncreaseFPS(ADJUST_LOD_UP_FPS), - _avatarLODDistanceMultiplier(DEFAULT_AVATAR_LOD_DISTANCE_MULTIPLIER), - _boundaryLevelAdjust(0), - _maxOctreePacketsPerSecond(DEFAULT_MAX_OCTREE_PPS), _lastAdjust(usecTimestampNow()), - _lastAvatarDetailDrop(usecTimestampNow()), - _fpsAverage(FIVE_SECONDS_OF_FRAMES), - _fastFPSAverage(ONE_SECOND_OF_FRAMES), - _hasLoginDialogDisplayed(false), - _shouldRenderTableNeedsRebuilding(true) + _lastAvatarDetailDrop(usecTimestampNow()) { Application *appInstance = Application::getInstance(); diff --git a/interface/src/Menu.h b/interface/src/Menu.h index c23559229d..563ed42d30 100644 --- a/interface/src/Menu.h +++ b/interface/src/Menu.h @@ -48,6 +48,13 @@ const float MINIMUM_AVATAR_LOD_DISTANCE_MULTIPLIER = 0.1f; const float MAXIMUM_AVATAR_LOD_DISTANCE_MULTIPLIER = 15.0f; const QString SETTINGS_ADDRESS_KEY = "address"; + +const float DEFAULT_FACESHIFT_EYE_DEFLECTION = 0.25f; +const QString DEFAULT_FACESHIFT_HOSTNAME = "localhost"; +const float DEFAULT_AVATAR_LOD_DISTANCE_MULTIPLIER = 1.0f; +const int ONE_SECOND_OF_FRAMES = 60; +const int FIVE_SECONDS_OF_FRAMES = 5 * ONE_SECOND_OF_FRAMES; + class QSettings; class AddressBarDialog; @@ -240,32 +247,37 @@ private: QHash _actionHash; InboundAudioStream::Settings _receivedAudioStreamSettings; - float _fieldOfView; /// in Degrees, doesn't apply to HMD like Oculus - float _realWorldFieldOfView; // The actual FOV set by the user's monitor size and view distance - float _faceshiftEyeDeflection; - QString _faceshiftHostname; - QPointer _MetavoxelEditor; - QPointer _metavoxelNetworkSimulator; - QPointer _ScriptEditor; - QPointer _chatWindow; - QDialog* _jsConsole; + // in Degrees, doesn't apply to HMD like Oculus + float _fieldOfView = DEFAULT_FIELD_OF_VIEW_DEGREES; + // The actual FOV set by the user's monitor size and view distance + float _realWorldFieldOfView = DEFAULT_REAL_WORLD_FIELD_OF_VIEW_DEGREES; + float _faceshiftEyeDeflection = DEFAULT_FACESHIFT_EYE_DEFLECTION; + QString _faceshiftHostname = DEFAULT_FACESHIFT_HOSTNAME; + + QDialog* _jsConsole = nullptr; #if defined(Q_OS_MAC) || defined(Q_OS_WIN) SpeechRecognizer _speechRecognizer; #endif - float _octreeSizeScale; - float _oculusUIAngularSize; - float _sixenseReticleMoveSpeed; - bool _invertSixenseButtons; - bool _automaticAvatarLOD; - float _avatarLODDecreaseFPS; - float _avatarLODIncreaseFPS; - float _avatarLODDistanceMultiplier; - int _boundaryLevelAdjust; - int _maxOctreePacketsPerSecond; + float _octreeSizeScale = DEFAULT_OCTREE_SIZE_SCALE; + float _oculusUIAngularSize;// = DEFAULT_OCULUS_UI_ANGULAR_SIZE; + float _sixenseReticleMoveSpeed;// = DEFAULT_SIXENSE_RETICLE_MOVE_SPEED; + bool _invertSixenseButtons;// = DEFAULT_INVERT_SIXENSE_MOUSE_BUTTONS; + bool _hasLoginDialogDisplayed = false; + + bool _automaticAvatarLOD = true; + float _avatarLODDecreaseFPS = DEFAULT_ADJUST_AVATAR_LOD_DOWN_FPS; + float _avatarLODIncreaseFPS = ADJUST_LOD_UP_FPS; + float _avatarLODDistanceMultiplier = DEFAULT_AVATAR_LOD_DISTANCE_MULTIPLIER; + + int _boundaryLevelAdjust = 0; + int _maxOctreePacketsPerSecond = DEFAULT_MAX_OCTREE_PPS; + quint64 _lastAdjust; quint64 _lastAvatarDetailDrop; - SimpleMovingAverage _fpsAverage; - SimpleMovingAverage _fastFPSAverage; + + SimpleMovingAverage _fpsAverage = FIVE_SECONDS_OF_FRAMES; + SimpleMovingAverage _fastFPSAverage = ONE_SECOND_OF_FRAMES; + QPointer _addressBarDialog; QPointer _animationsDialog; QPointer _attachmentsDialog; @@ -278,16 +290,20 @@ private: QPointer _loginDialog; QPointer _octreeStatsDialog; QPointer _preferencesDialog; - bool _hasLoginDialogDisplayed; + + QPointer _MetavoxelEditor; + QPointer _metavoxelNetworkSimulator; + QPointer _ScriptEditor; + QPointer _chatWindow; + QAction* _loginAction = nullptr; QAction* _chatAction = nullptr; QString _snapshotsLocation; QString _scriptsLocation; QByteArray _walletPrivateKey; - bool _shouldRenderTableNeedsRebuilding; + bool _shouldRenderTableNeedsRebuilding = true; QMap _shouldRenderTable; - }; namespace MenuOption { @@ -405,7 +421,6 @@ namespace MenuOption { const QString RenderTargetFramerate40 = "40"; const QString RenderTargetFramerate30 = "30"; const QString RenderTargetFramerateVSyncOn = "V-Sync On"; - const QString RenderResolution = "Scale Resolution"; const QString RenderResolutionOne = "1"; const QString RenderResolutionTwoThird = "2/3"; diff --git a/interface/src/ui/JSConsole.h b/interface/src/ui/JSConsole.h index f28132a1f5..daeba8ea15 100644 --- a/interface/src/ui/JSConsole.h +++ b/interface/src/ui/JSConsole.h @@ -20,6 +20,11 @@ #include "ui_console.h" #include "ScriptEngine.h" +const QString CONSOLE_TITLE = "Scripting Console"; +const float CONSOLE_WINDOW_OPACITY = 0.95f; +const int CONSOLE_WIDTH = 800; +const int CONSOLE_HEIGHT = 200; + class JSConsole : public QWidget { Q_OBJECT public: diff --git a/interface/src/ui/ScriptEditorWindow.cpp b/interface/src/ui/ScriptEditorWindow.cpp index 0496040724..f5cd6de49a 100644 --- a/interface/src/ui/ScriptEditorWindow.cpp +++ b/interface/src/ui/ScriptEditorWindow.cpp @@ -31,8 +31,6 @@ #include "FlowLayout.h" #include "JSConsole.h" -const int CONSOLE_HEIGHT = 150; - ScriptEditorWindow::ScriptEditorWindow() : _ScriptEditorWindowUI(new Ui::ScriptEditorWindow), _loadMenu(new QMenu), From 934d8d58ef43f25ee36c4a3a7a28c3620ccf4bee Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Mon, 12 Jan 2015 15:59:27 -0800 Subject: [PATCH 19/24] Move some constants out of Menu class files --- interface/src/Menu.cpp | 3 --- interface/src/Menu.h | 18 ++++++++++-------- interface/src/devices/Faceshift.h | 3 +++ 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index 48403b7511..12671ef6e3 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -11,7 +11,6 @@ #include - #include #include #include @@ -44,8 +43,6 @@ #include "Audio.h" #include "audio/AudioIOStatsRenderer.h" #include "audio/AudioScope.h" -#include "devices/Faceshift.h" -#include "devices/OculusManager.h" #include "devices/Visage.h" #include "Menu.h" #include "scripting/LocationScriptingInterface.h" diff --git a/interface/src/Menu.h b/interface/src/Menu.h index 563ed42d30..95436a5b8b 100644 --- a/interface/src/Menu.h +++ b/interface/src/Menu.h @@ -27,10 +27,14 @@ #include "SpeechRecognizer.h" #endif +#include "devices/Faceshift.h" +#include "devices/OculusManager.h" +#include "devices/SixenseManager.h" #include "ui/ChatWindow.h" #include "ui/JSConsole.h" #include "ui/ScriptEditorWindow.h" +// Make an LOD handler class and move everything overthere const float ADJUST_LOD_DOWN_FPS = 40.0; const float ADJUST_LOD_UP_FPS = 55.0; const float DEFAULT_ADJUST_AVATAR_LOD_DOWN_FPS = 30.0f; @@ -46,15 +50,13 @@ const float ADJUST_LOD_MAX_SIZE_SCALE = DEFAULT_OCTREE_SIZE_SCALE; const float MINIMUM_AVATAR_LOD_DISTANCE_MULTIPLIER = 0.1f; const float MAXIMUM_AVATAR_LOD_DISTANCE_MULTIPLIER = 15.0f; - -const QString SETTINGS_ADDRESS_KEY = "address"; - -const float DEFAULT_FACESHIFT_EYE_DEFLECTION = 0.25f; -const QString DEFAULT_FACESHIFT_HOSTNAME = "localhost"; const float DEFAULT_AVATAR_LOD_DISTANCE_MULTIPLIER = 1.0f; + const int ONE_SECOND_OF_FRAMES = 60; const int FIVE_SECONDS_OF_FRAMES = 5 * ONE_SECOND_OF_FRAMES; +////////////////////////////////////////////////////////// +const QString SETTINGS_ADDRESS_KEY = "address"; class QSettings; class AddressBarDialog; @@ -259,9 +261,9 @@ private: SpeechRecognizer _speechRecognizer; #endif float _octreeSizeScale = DEFAULT_OCTREE_SIZE_SCALE; - float _oculusUIAngularSize;// = DEFAULT_OCULUS_UI_ANGULAR_SIZE; - float _sixenseReticleMoveSpeed;// = DEFAULT_SIXENSE_RETICLE_MOVE_SPEED; - bool _invertSixenseButtons;// = DEFAULT_INVERT_SIXENSE_MOUSE_BUTTONS; + float _oculusUIAngularSize = DEFAULT_OCULUS_UI_ANGULAR_SIZE; + float _sixenseReticleMoveSpeed = DEFAULT_SIXENSE_RETICLE_MOVE_SPEED; + bool _invertSixenseButtons = DEFAULT_INVERT_SIXENSE_MOUSE_BUTTONS; bool _hasLoginDialogDisplayed = false; bool _automaticAvatarLOD = true; diff --git a/interface/src/devices/Faceshift.h b/interface/src/devices/Faceshift.h index b6b942dfee..9ed23ddb9f 100644 --- a/interface/src/devices/Faceshift.h +++ b/interface/src/devices/Faceshift.h @@ -23,6 +23,9 @@ #include "FaceTracker.h" +const float DEFAULT_FACESHIFT_EYE_DEFLECTION = 0.25f; +const QString DEFAULT_FACESHIFT_HOSTNAME = "localhost"; + /// Handles interaction with the Faceshift software, which provides head position/orientation and facial features. class Faceshift : public FaceTracker { Q_OBJECT From 80af2adf128a1a92bbd96067b3f7229dc4847c57 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Mon, 12 Jan 2015 16:42:27 -0800 Subject: [PATCH 20/24] Remove constexpr because windows can't handle them --- libraries/networking/src/ResourceCache.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libraries/networking/src/ResourceCache.h b/libraries/networking/src/ResourceCache.h index 7b8ffc392b..519b205d46 100644 --- a/libraries/networking/src/ResourceCache.h +++ b/libraries/networking/src/ResourceCache.h @@ -27,18 +27,18 @@ class QTimer; class Resource; -static constexpr qint64 BYTES_PER_MEGABYTES = 1024 * 1024; -static constexpr qint64 BYTES_PER_GIGABYTES = 1024 * BYTES_PER_MEGABYTES; +static const qint64 BYTES_PER_MEGABYTES = 1024 * 1024; +static const qint64 BYTES_PER_GIGABYTES = 1024 * BYTES_PER_MEGABYTES; // Windows can have troubles allocating that much memory in ram sometimes // so default cache size at 100 MB on windows (1GB otherwise) #ifdef Q_OS_WIN32 -static constexpr qint64 DEFAULT_UNUSED_MAX_SIZE = 100 * BYTES_PER_MEGABYTES; +static const qint64 DEFAULT_UNUSED_MAX_SIZE = 100 * BYTES_PER_MEGABYTES; #else -static constexpr qint64 DEFAULT_UNUSED_MAX_SIZE = 1024 * BYTES_PER_MEGABYTES; +static const qint64 DEFAULT_UNUSED_MAX_SIZE = 1024 * BYTES_PER_MEGABYTES; #endif -static constexpr qint64 MIN_UNUSED_MAX_SIZE = 0; -static constexpr qint64 MAX_UNUSED_MAX_SIZE = 10 * BYTES_PER_GIGABYTES; +static const qint64 MIN_UNUSED_MAX_SIZE = 0; +static const qint64 MAX_UNUSED_MAX_SIZE = 10 * BYTES_PER_GIGABYTES; /// Base class for resource caches. class ResourceCache : public QObject { From b6ba82653f4e355759b0af20d9390ccfa2c7da29 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Mon, 12 Jan 2015 17:00:39 -0800 Subject: [PATCH 21/24] Remove glm dependency --- libraries/networking/src/ResourceCache.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libraries/networking/src/ResourceCache.cpp b/libraries/networking/src/ResourceCache.cpp index f4d9a2909d..5a95bd6028 100644 --- a/libraries/networking/src/ResourceCache.cpp +++ b/libraries/networking/src/ResourceCache.cpp @@ -16,12 +16,14 @@ #include #include -#include - #include "NetworkAccessManager.h" #include "ResourceCache.h" +#define clamp(x, min, max) (((x) < (min)) ? (min) :\ + (((x) > (max)) ? (max) :\ + (x))) + ResourceCache::ResourceCache(QObject* parent) : QObject(parent) { } @@ -72,7 +74,7 @@ QSharedPointer ResourceCache::getResource(const QUrl& url, const QUrl& } void ResourceCache::setUnusedResourceCacheSize(qint64 unusedResourcesMaxSize) { - _unusedResourcesMaxSize = glm::clamp(unusedResourcesMaxSize, MIN_UNUSED_MAX_SIZE, MAX_UNUSED_MAX_SIZE); + _unusedResourcesMaxSize = clamp(unusedResourcesMaxSize, MIN_UNUSED_MAX_SIZE, MAX_UNUSED_MAX_SIZE); reserveUnusedResource(0); } From 7d39b45f16d9487cb6701f424118e749b3c5c332 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Mon, 12 Jan 2015 17:34:07 -0800 Subject: [PATCH 22/24] Hopefully fixes the windows compile error --- interface/src/devices/OculusManager.cpp | 1 + interface/src/devices/OculusManager.h | 2 -- libraries/script-engine/src/EventTypes.h | 2 +- libraries/script-engine/src/KeyEvent.h | 2 +- libraries/shared/src/SharedUtil.h | 2 +- 5 files changed, 4 insertions(+), 5 deletions(-) diff --git a/interface/src/devices/OculusManager.cpp b/interface/src/devices/OculusManager.cpp index f59ce639a0..2b444c4a25 100644 --- a/interface/src/devices/OculusManager.cpp +++ b/interface/src/devices/OculusManager.cpp @@ -13,6 +13,7 @@ #include "InterfaceConfig.h" #include "OculusManager.h" +#include "ui/overlays/Text3DOverlay.h" #include #include diff --git a/interface/src/devices/OculusManager.h b/interface/src/devices/OculusManager.h index d9700d9530..b9b5d81c68 100644 --- a/interface/src/devices/OculusManager.h +++ b/interface/src/devices/OculusManager.h @@ -19,8 +19,6 @@ #include -#include "ui/overlays/Text3DOverlay.h" - const float DEFAULT_OCULUS_UI_ANGULAR_SIZE = 72.0f; class Camera; diff --git a/libraries/script-engine/src/EventTypes.h b/libraries/script-engine/src/EventTypes.h index fc808ea560..906006e4f4 100644 --- a/libraries/script-engine/src/EventTypes.h +++ b/libraries/script-engine/src/EventTypes.h @@ -12,7 +12,7 @@ #ifndef hifi_EventTypes_h #define hifi_EventTypes_h -#include +#include void registerEventTypes(QScriptEngine* engine); diff --git a/libraries/script-engine/src/KeyEvent.h b/libraries/script-engine/src/KeyEvent.h index bdadcec374..350b733eaf 100644 --- a/libraries/script-engine/src/KeyEvent.h +++ b/libraries/script-engine/src/KeyEvent.h @@ -13,7 +13,7 @@ #define hifi_KeyEvent_h #include -#include +#include class KeyEvent { public: diff --git a/libraries/shared/src/SharedUtil.h b/libraries/shared/src/SharedUtil.h index 61b7365877..01dcd7ff02 100644 --- a/libraries/shared/src/SharedUtil.h +++ b/libraries/shared/src/SharedUtil.h @@ -19,7 +19,7 @@ #include // not on windows, not needed for mac or windows #endif -#include +#include const int BYTES_PER_COLOR = 3; const int BYTES_PER_FLAGS = 1; From 9ce405a7444475027e358bcf7af19d2f2987b895 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Mon, 12 Jan 2015 17:46:38 -0800 Subject: [PATCH 23/24] Text3DOverlay forward definition --- interface/src/devices/OculusManager.h | 1 + 1 file changed, 1 insertion(+) diff --git a/interface/src/devices/OculusManager.h b/interface/src/devices/OculusManager.h index b9b5d81c68..591ba53239 100644 --- a/interface/src/devices/OculusManager.h +++ b/interface/src/devices/OculusManager.h @@ -23,6 +23,7 @@ const float DEFAULT_OCULUS_UI_ANGULAR_SIZE = 72.0f; class Camera; class PalmData; +class Text3DOverlay; /// Handles interaction with the Oculus Rift. class OculusManager { From cf7089e145cb5209cf0b54c4a0282866d67a2732 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Mon, 12 Jan 2015 18:49:05 -0800 Subject: [PATCH 24/24] Move constant back to Menu --- interface/src/Menu.h | 3 ++- interface/src/devices/OculusManager.h | 2 -- interface/src/devices/SixenseManager.h | 2 ++ interface/src/ui/ApplicationOverlay.h | 1 + 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/interface/src/Menu.h b/interface/src/Menu.h index 95436a5b8b..6f30ca983b 100644 --- a/interface/src/Menu.h +++ b/interface/src/Menu.h @@ -28,7 +28,6 @@ #endif #include "devices/Faceshift.h" -#include "devices/OculusManager.h" #include "devices/SixenseManager.h" #include "ui/ChatWindow.h" #include "ui/JSConsole.h" @@ -56,6 +55,8 @@ const int ONE_SECOND_OF_FRAMES = 60; const int FIVE_SECONDS_OF_FRAMES = 5 * ONE_SECOND_OF_FRAMES; ////////////////////////////////////////////////////////// +const float DEFAULT_OCULUS_UI_ANGULAR_SIZE = 72.0f; + const QString SETTINGS_ADDRESS_KEY = "address"; class QSettings; diff --git a/interface/src/devices/OculusManager.h b/interface/src/devices/OculusManager.h index 591ba53239..71fc08c8f9 100644 --- a/interface/src/devices/OculusManager.h +++ b/interface/src/devices/OculusManager.h @@ -19,8 +19,6 @@ #include -const float DEFAULT_OCULUS_UI_ANGULAR_SIZE = 72.0f; - class Camera; class PalmData; class Text3DOverlay; diff --git a/interface/src/devices/SixenseManager.h b/interface/src/devices/SixenseManager.h index 0a7ab78c0e..4082edd153 100644 --- a/interface/src/devices/SixenseManager.h +++ b/interface/src/devices/SixenseManager.h @@ -25,6 +25,8 @@ #endif +class PalmData; + const unsigned int BUTTON_0 = 1U << 0; // the skinny button between 1 and 2 const unsigned int BUTTON_1 = 1U << 5; const unsigned int BUTTON_2 = 1U << 6; diff --git a/interface/src/ui/ApplicationOverlay.h b/interface/src/ui/ApplicationOverlay.h index e2094f2a8e..33dcea67a3 100644 --- a/interface/src/ui/ApplicationOverlay.h +++ b/interface/src/ui/ApplicationOverlay.h @@ -12,6 +12,7 @@ #ifndef hifi_ApplicationOverlay_h #define hifi_ApplicationOverlay_h +class Camera; class Overlays; class QOpenGLFramebufferObject;