Showing the changes to interface/src/Application.cpp (1 of 168 files). Show all
Unified · Split
| @@ -23,6 +23,7 @@ · 22 unmodified lines | |||
| 23 | // include this before QGLWidget, which includes an earlier version of OpenGL | 23 | // include this before QGLWidget, which includes an earlier version of OpenGL |
| 24 | #include "InterfaceConfig.h" | 24 | #include "InterfaceConfig.h" |
| 25 | 25 | ||
| 26 | #include <QAbstractNativeEventFilter> | ||
| 26 | #include <QActionGroup> | 27 | #include <QActionGroup> |
| 27 | #include <QColorDialog> | 28 | #include <QColorDialog> |
| 28 | #include <QDesktopWidget> | 29 | #include <QDesktopWidget> |
| @@ -73,6 +74,7 @@ · 44 unmodified lines | |||
| 73 | #include <PhysicsEngine.h> | 74 | #include <PhysicsEngine.h> |
| 74 | #include <ProgramObject.h> | 75 | #include <ProgramObject.h> |
| 75 | #include <ResourceCache.h> | 76 | #include <ResourceCache.h> |
| 77 | #include <ScriptCache.h> | ||
| 76 | #include <SettingHandle.h> | 78 | #include <SettingHandle.h> |
| 77 | #include <SoundCache.h> | 79 | #include <SoundCache.h> |
| 78 | #include <TextRenderer.h> | 80 | #include <TextRenderer.h> |
| @@ -80,13 +82,15 @@ · 1 unmodified line | |||
| 80 | #include <UUID.h> | 82 | #include <UUID.h> |
| 81 | 83 | ||
| 82 | #include "Application.h" | 84 | #include "Application.h" |
| 83 | #include "Audio.h" | 85 | #include "AudioClient.h" |
| 84 | #include "InterfaceVersion.h" | 86 | #include "InterfaceVersion.h" |
| 85 | #include "LODManager.h" | 87 | #include "LODManager.h" |
| 86 | #include "Menu.h" | 88 | #include "Menu.h" |
| 87 | #include "ModelUploader.h" | 89 | #include "ModelUploader.h" |
| 88 | #include "Util.h" | 90 | #include "Util.h" |
| 89 | 91 | ||
| 92 | #include "avatar/AvatarManager.h" | ||
| 93 | |||
| 90 | #include "audio/AudioToolBox.h" | 94 | #include "audio/AudioToolBox.h" |
| 91 | #include "audio/AudioIOStatsRenderer.h" | 95 | #include "audio/AudioIOStatsRenderer.h" |
| 92 | #include "audio/AudioScope.h" | 96 | #include "audio/AudioScope.h" |
| @@ -127,17 +131,12 @@ · 34 unmodified lines | |||
| 127 | #include "ui/StandAloneJSConsole.h" | 131 | #include "ui/StandAloneJSConsole.h" |
| 128 | #include "ui/Stats.h" | 132 | #include "ui/Stats.h" |
| 129 | 133 | ||
| 130 | |||
| 131 | |||
| 132 | using namespace std; | 134 | using namespace std; |
| 133 | 135 | ||
| 134 | // Starfield information | 136 | // Starfield information |
| 135 | static unsigned STARFIELD_NUM_STARS = 50000; | 137 | static unsigned STARFIELD_NUM_STARS = 50000; |
| 136 | static unsigned STARFIELD_SEED = 1; | 138 | static unsigned STARFIELD_SEED = 1; |
| 137 | 139 | ||
| 138 | static const int BANDWIDTH_METER_CLICK_MAX_DRAG_LENGTH = 6; // farther dragged clicks are ignored | ||
| 139 | |||
| 140 | |||
| 141 | const qint64 MAXIMUM_CACHE_SIZE = 10737418240; // 10GB | 140 | const qint64 MAXIMUM_CACHE_SIZE = 10737418240; // 10GB |
| 142 | 141 | ||
| 143 | static QTimer* idleTimer = NULL; | 142 | static QTimer* idleTimer = NULL; |
| @@ -147,6 +146,37 @@ const QString SKIP_FILENAME = QStandardPaths::writableLocation(QStandardPaths::D · 3 unmodified lines | |||
| 147 | 146 | ||
| 148 | const QString DEFAULT_SCRIPTS_JS_URL = "http://s3.amazonaws.com/hifi-public/scripts/defaultScripts.js"; | 147 | const QString DEFAULT_SCRIPTS_JS_URL = "http://s3.amazonaws.com/hifi-public/scripts/defaultScripts.js"; |
| 149 | 148 | ||
| 149 | #ifdef Q_OS_WIN | ||
| 150 | class MyNativeEventFilter : public QAbstractNativeEventFilter { | ||
| 151 | public: | ||
| 152 | static MyNativeEventFilter& getInstance() { | ||
| 153 | static MyNativeEventFilter staticInstance; | ||
| 154 | return staticInstance; | ||
| 155 | } | ||
| 156 | |||
| 157 | bool nativeEventFilter(const QByteArray &eventType, void* msg, long* result) Q_DECL_OVERRIDE { | ||
| 158 | if (eventType == "windows_generic_MSG") { | ||
| 159 | MSG* message = (MSG*)msg; | ||
| 160 | if (message->message == UWM_IDENTIFY_INSTANCES) { | ||
| 161 | *result = UWM_IDENTIFY_INSTANCES; | ||
| 162 | return true; | ||
| 163 | } | ||
| 164 | if (message->message == WM_SHOWWINDOW) { | ||
| 165 | Application::getInstance()->getWindow()->showNormal(); | ||
| 166 | } | ||
| 167 | if (message->message == WM_COPYDATA) { | ||
| 168 | COPYDATASTRUCT* pcds = (COPYDATASTRUCT*)(message->lParam); | ||
| 169 | QUrl url = QUrl((const char*)(pcds->lpData)); | ||
| 170 | if (url.isValid() && url.scheme() == HIFI_URL_SCHEME) { | ||
| 171 | DependencyManager::get<AddressManager>()->handleLookupString(url.toString()); | ||
| 172 | } | ||
| 173 | } | ||
| 174 | } | ||
| 175 | return false; | ||
| 176 | } | ||
| 177 | }; | ||
| 178 | #endif | ||
| 179 | |||
| 150 | void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& message) { | 180 | void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& message) { |
| 151 | QString logMessage = LogHandler::getInstance().printMessage((LogMsgType) type, context, message); | 181 | QString logMessage = LogHandler::getInstance().printMessage((LogMsgType) type, context, message); |
| 152 | 182 | ||
| @@ -166,6 +196,7 @@ bool setupEssentials(int& argc, char** argv) { · 13 unmodified lines | |||
| 166 | QCoreApplication::setApplicationVersion(BUILD_VERSION); | 196 | QCoreApplication::setApplicationVersion(BUILD_VERSION); |
| 167 | 197 | ||
| 168 | DependencyManager::registerInheritance<LimitedNodeList, NodeList>(); | 198 | DependencyManager::registerInheritance<LimitedNodeList, NodeList>(); |
| 199 | DependencyManager::registerInheritance<AvatarHashMap, AvatarManager>(); | ||
| 169 | 200 | ||
| 170 | // Set dependencies | 201 | // Set dependencies |
| 171 | auto glCanvas = DependencyManager::set<GLCanvas>(); | 202 | auto glCanvas = DependencyManager::set<GLCanvas>(); |
| @@ -174,7 +205,7 @@ bool setupEssentials(int& argc, char** argv) { · 2 unmodified lines | |||
| 174 | auto geometryCache = DependencyManager::set<GeometryCache>(); | 205 | auto geometryCache = DependencyManager::set<GeometryCache>(); |
| 175 | auto glowEffect = DependencyManager::set<GlowEffect>(); | 206 | auto glowEffect = DependencyManager::set<GlowEffect>(); |
| 176 | auto faceshift = DependencyManager::set<Faceshift>(); | 207 | auto faceshift = DependencyManager::set<Faceshift>(); |
| 177 | auto audio = DependencyManager::set<Audio>(); | 208 | auto audio = DependencyManager::set<AudioClient>(); |
| 178 | auto audioScope = DependencyManager::set<AudioScope>(); | 209 | auto audioScope = DependencyManager::set<AudioScope>(); |
| 179 | auto audioIOStatsRenderer = DependencyManager::set<AudioIOStatsRenderer>(); | 210 | auto audioIOStatsRenderer = DependencyManager::set<AudioIOStatsRenderer>(); |
| 180 | auto deferredLightingEffect = DependencyManager::set<DeferredLightingEffect>(); | 211 | auto deferredLightingEffect = DependencyManager::set<DeferredLightingEffect>(); |
| @@ -185,10 +216,12 @@ bool setupEssentials(int& argc, char** argv) { · 4 unmodified lines | |||
| 185 | auto ddeFaceTracker = DependencyManager::set<DdeFaceTracker>(); | 216 | auto ddeFaceTracker = DependencyManager::set<DdeFaceTracker>(); |
| 186 | auto modelBlender = DependencyManager::set<ModelBlender>(); | 217 | auto modelBlender = DependencyManager::set<ModelBlender>(); |
| 187 | auto audioToolBox = DependencyManager::set<AudioToolBox>(); | 218 | auto audioToolBox = DependencyManager::set<AudioToolBox>(); |
| 219 | auto avatarManager = DependencyManager::set<AvatarManager>(); | ||
| 188 | auto lodManager = DependencyManager::set<LODManager>(); | 220 | auto lodManager = DependencyManager::set<LODManager>(); |
| 189 | auto jsConsole = DependencyManager::set<StandAloneJSConsole>(); | 221 | auto jsConsole = DependencyManager::set<StandAloneJSConsole>(); |
| 190 | auto dialogsManager = DependencyManager::set<DialogsManager>(); | 222 | auto dialogsManager = DependencyManager::set<DialogsManager>(); |
| 191 | auto bandwidthRecorder = DependencyManager::set<BandwidthRecorder>(); | 223 | auto bandwidthRecorder = DependencyManager::set<BandwidthRecorder>(); |
| 224 | auto resouceCacheSharedItems = DependencyManager::set<ResouceCacheSharedItems>(); | ||
| 192 | #if defined(Q_OS_MAC) || defined(Q_OS_WIN) | 225 | #if defined(Q_OS_MAC) || defined(Q_OS_WIN) |
| 193 | auto speechRecognizer = DependencyManager::set<SpeechRecognizer>(); | 226 | auto speechRecognizer = DependencyManager::set<SpeechRecognizer>(); |
| 194 | #endif | 227 | #endif |
| @@ -224,6 +257,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 29 unmodified lines | |||
| 224 | _scaleMirror(1.0f), | 257 | _scaleMirror(1.0f), |
| 225 | _rotateMirror(0.0f), | 258 | _rotateMirror(0.0f), |
| 226 | _raiseMirror(0.0f), | 259 | _raiseMirror(0.0f), |
| 260 | _cursorVisible(true), | ||
| 227 | _lastMouseMove(usecTimestampNow()), | 261 | _lastMouseMove(usecTimestampNow()), |
| 228 | _lastMouseMoveWasSimulated(false), | 262 | _lastMouseMoveWasSimulated(false), |
| 229 | _touchAvgX(0.0f), | 263 | _touchAvgX(0.0f), |
| @@ -243,9 +277,13 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 13 unmodified lines | |||
| 243 | _aboutToQuit(false), | 277 | _aboutToQuit(false), |
| 244 | _notifiedPacketVersionMismatchThisDomain(false) | 278 | _notifiedPacketVersionMismatchThisDomain(false) |
| 245 | { | 279 | { |
| 280 | #ifdef Q_OS_WIN | ||
| 281 | installNativeEventFilter(&MyNativeEventFilter::getInstance()); | ||
| 282 | #endif | ||
| 283 | |||
| 246 | _logger = new FileLogger(this); // After setting organization name in order to get correct directory | 284 | _logger = new FileLogger(this); // After setting organization name in order to get correct directory |
| 247 | qInstallMessageHandler(messageHandler); | 285 | qInstallMessageHandler(messageHandler); |
| 248 | 286 | ||
| 249 | QFontDatabase::addApplicationFont(PathUtils::resourcesPath() + "styles/Inconsolata.otf"); | 287 | QFontDatabase::addApplicationFont(PathUtils::resourcesPath() + "styles/Inconsolata.otf"); |
| 250 | _window->setWindowTitle("Interface"); | 288 | _window->setWindowTitle("Interface"); |
| 251 | 289 | ||
| @@ -254,7 +292,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 2 unmodified lines | |||
| 254 | auto glCanvas = DependencyManager::get<GLCanvas>(); | 292 | auto glCanvas = DependencyManager::get<GLCanvas>(); |
| 255 | auto nodeList = DependencyManager::get<NodeList>(); | 293 | auto nodeList = DependencyManager::get<NodeList>(); |
| 256 | 294 | ||
| 257 | _myAvatar = _avatarManager.getMyAvatar(); | 295 | _myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar(); |
| 258 | 296 | ||
| 259 | _applicationStartupTime = startup_time; | 297 | _applicationStartupTime = startup_time; |
| 260 | 298 | ||
| @@ -285,9 +323,13 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 24 unmodified lines | |||
| 285 | QThread* audioThread = new QThread(this); | 323 | QThread* audioThread = new QThread(this); |
| 286 | audioThread->setObjectName("Audio Thread"); | 324 | audioThread->setObjectName("Audio Thread"); |
| 287 | 325 | ||
| 288 | auto audioIO = DependencyManager::get<Audio>(); | 326 | auto audioIO = DependencyManager::get<AudioClient>(); |
| 327 | |||
| 328 | audioIO->setPositionGetter(getPositionForAudio); | ||
| 329 | audioIO->setOrientationGetter(getOrientationForAudio); | ||
| 330 | |||
| 289 | audioIO->moveToThread(audioThread); | 331 | audioIO->moveToThread(audioThread); |
| 290 | connect(audioThread, &QThread::started, audioIO.data(), &Audio::start); | 332 | connect(audioThread, &QThread::started, audioIO.data(), &AudioClient::start); |
| 291 | connect(audioIO.data(), SIGNAL(muteToggled()), this, SLOT(audioMuteToggled())); | 333 | connect(audioIO.data(), SIGNAL(muteToggled()), this, SLOT(audioMuteToggled())); |
| 292 | 334 | ||
| 293 | audioThread->start(); | 335 | audioThread->start(); |
| @@ -331,9 +373,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 37 unmodified lines | |||
| 331 | auto dialogsManager = DependencyManager::get<DialogsManager>(); | 373 | auto dialogsManager = DependencyManager::get<DialogsManager>(); |
| 332 | connect(&accountManager, &AccountManager::authRequired, dialogsManager.data(), &DialogsManager::showLoginDialog); | 374 | connect(&accountManager, &AccountManager::authRequired, dialogsManager.data(), &DialogsManager::showLoginDialog); |
| 333 | connect(&accountManager, &AccountManager::usernameChanged, this, &Application::updateWindowTitle); | 375 | connect(&accountManager, &AccountManager::usernameChanged, this, &Application::updateWindowTitle); |
| 334 | |||
| 335 | // once we have a profile in account manager make sure we generate a new keypair | ||
| 336 | connect(&accountManager, &AccountManager::profileChanged, &accountManager, &AccountManager::generateNewKeypair); | ||
| 337 | 376 | ||
| 338 | // set the account manager's root URL and trigger a login request if we don't have the access token | 377 | // set the account manager's root URL and trigger a login request if we don't have the access token |
| 339 | accountManager.setAuthURL(DEFAULT_NODE_AUTH_URL); | 378 | accountManager.setAuthURL(DEFAULT_NODE_AUTH_URL); |
| @@ -498,7 +537,7 @@ Application::~Application() { · 158 unmodified lines | |||
| 498 | // kill any audio injectors that are still around | 537 | // kill any audio injectors that are still around |
| 499 | AudioScriptingInterface::getInstance().stopAllInjectors(); | 538 | AudioScriptingInterface::getInstance().stopAllInjectors(); |
| 500 | 539 | ||
| 501 | auto audioIO = DependencyManager::get<Audio>(); | 540 | auto audioIO = DependencyManager::get<AudioClient>(); |
| 502 | 541 | ||
| 503 | // stop the audio process | 542 | // stop the audio process |
| 504 | QMetaObject::invokeMethod(audioIO.data(), "stop", Qt::BlockingQueuedConnection); | 543 | QMetaObject::invokeMethod(audioIO.data(), "stop", Qt::BlockingQueuedConnection); |
| @@ -515,6 +554,11 @@ Application::~Application() { · 10 unmodified lines | |||
| 515 | _myAvatar = NULL; | 554 | _myAvatar = NULL; |
| 516 | 555 | ||
| 517 | DependencyManager::destroy<GLCanvas>(); | 556 | DependencyManager::destroy<GLCanvas>(); |
| 557 | DependencyManager::destroy<AnimationCache>(); | ||
| 558 | DependencyManager::destroy<TextureCache>(); | ||
| 559 | DependencyManager::destroy<GeometryCache>(); | ||
| 560 | DependencyManager::destroy<ScriptCache>(); | ||
| 561 | DependencyManager::destroy<SoundCache>(); | ||
| 518 | } | 562 | } |
| 519 | 563 | ||
| 520 | void Application::initializeGL() { | 564 | void Application::initializeGL() { |
| @@ -702,7 +746,7 @@ void Application::runTests() { · 181 unmodified lines | |||
| 702 | void Application::audioMuteToggled() { | 746 | void Application::audioMuteToggled() { |
| 703 | QAction* muteAction = Menu::getInstance()->getActionForOption(MenuOption::MuteAudio); | 747 | QAction* muteAction = Menu::getInstance()->getActionForOption(MenuOption::MuteAudio); |
| 704 | Q_CHECK_PTR(muteAction); | 748 | Q_CHECK_PTR(muteAction); |
| 705 | muteAction->setChecked(DependencyManager::get<Audio>()->isMuted()); | 749 | muteAction->setChecked(DependencyManager::get<AudioClient>()->isMuted()); |
| 706 | } | 750 | } |
| 707 | 751 | ||
| 708 | void Application::aboutApp() { | 752 | void Application::aboutApp() { |
| @@ -1474,6 +1518,8 @@ void Application::setEnableVRMode(bool enableVRMode) { · 765 unmodified lines | |||
| 1474 | 1518 | ||
| 1475 | auto glCanvas = DependencyManager::get<GLCanvas>(); | 1519 | auto glCanvas = DependencyManager::get<GLCanvas>(); |
| 1476 | resizeGL(glCanvas->getDeviceWidth(), glCanvas->getDeviceHeight()); | 1520 | resizeGL(glCanvas->getDeviceWidth(), glCanvas->getDeviceHeight()); |
| 1521 | |||
| 1522 | updateCursorVisibility(); | ||
| 1477 | } | 1523 | } |
| 1478 | 1524 | ||
| 1479 | void Application::setLowVelocityFilter(bool lowVelocityFilter) { | 1525 | void Application::setLowVelocityFilter(bool lowVelocityFilter) { |
| @@ -1560,13 +1606,16 @@ bool Application::exportEntities(const QString& filename, float x, float y, floa · 80 unmodified lines | |||
| 1560 | } | 1606 | } |
| 1561 | 1607 | ||
| 1562 | void Application::loadSettings() { | 1608 | void Application::loadSettings() { |
| 1563 | DependencyManager::get<Audio>()->loadSettings(); | 1609 | |
| 1610 | DependencyManager::get<AudioClient>()->loadSettings(); | ||
| 1611 | |||
| 1564 | Menu::getInstance()->loadSettings(); | 1612 | Menu::getInstance()->loadSettings(); |
| 1565 | _myAvatar->loadData(); | 1613 | _myAvatar->loadData(); |
| 1566 | } | 1614 | } |
| 1567 | 1615 | ||
| 1568 | void Application::saveSettings() { | 1616 | void Application::saveSettings() { |
| 1569 | DependencyManager::get<Audio>()->saveSettings(); | 1617 | DependencyManager::get<AudioClient>()->saveSettings(); |
| 1618 | |||
| 1570 | Menu::getInstance()->saveSettings(); | 1619 | Menu::getInstance()->saveSettings(); |
| 1571 | _myAvatar->saveData(); | 1620 | _myAvatar->saveData(); |
| 1572 | } | 1621 | } |
| @@ -1600,7 +1649,7 @@ void Application::init() { · 27 unmodified lines | |||
| 1600 | DependencyManager::get<AmbientOcclusionEffect>()->init(this); | 1649 | DependencyManager::get<AmbientOcclusionEffect>()->init(this); |
| 1601 | 1650 | ||
| 1602 | // TODO: move _myAvatar out of Application. Move relevant code to MyAvataar or AvatarManager | 1651 | // TODO: move _myAvatar out of Application. Move relevant code to MyAvataar or AvatarManager |
| 1603 | _avatarManager.init(); | 1652 | DependencyManager::get<AvatarManager>()->init(); |
| 1604 | _myCamera.setMode(CAMERA_MODE_FIRST_PERSON); | 1653 | _myCamera.setMode(CAMERA_MODE_FIRST_PERSON); |
| 1605 | 1654 | ||
| 1606 | _mirrorCamera.setMode(CAMERA_MODE_MIRROR); | 1655 | _mirrorCamera.setMode(CAMERA_MODE_MIRROR); |
| @@ -1941,35 +1990,22 @@ void Application::updateCursor(float deltaTime) { · 334 unmodified lines | |||
| 1941 | 1990 | ||
| 1942 | static QPoint lastMousePos = QPoint(); | 1991 | static QPoint lastMousePos = QPoint(); |
| 1943 | _lastMouseMove = (lastMousePos == QCursor::pos()) ? _lastMouseMove : usecTimestampNow(); | 1992 | _lastMouseMove = (lastMousePos == QCursor::pos()) ? _lastMouseMove : usecTimestampNow(); |
| 1944 | bool hideMouse = false; | ||
| 1945 | bool underMouse = QGuiApplication::topLevelAt(QCursor::pos()) == | ||
| 1946 | Application::getInstance()->getWindow()->windowHandle(); | ||
| 1947 | |||
| 1948 | static const int HIDE_CURSOR_TIMEOUT = 3 * USECS_PER_SECOND; // 3 second | ||
| 1949 | int elapsed = usecTimestampNow() - _lastMouseMove; | ||
| 1950 | if ((elapsed > HIDE_CURSOR_TIMEOUT) || | ||
| 1951 | (OculusManager::isConnected() && Menu::getInstance()->isOptionChecked(MenuOption::EnableVRMode))) { | ||
| 1952 | hideMouse = underMouse; | ||
| 1953 | } | ||
| 1954 | |||
| 1955 | setCursorVisible(!hideMouse); | ||
| 1956 | lastMousePos = QCursor::pos(); | 1993 | lastMousePos = QCursor::pos(); |
| 1957 | } | 1994 | } |
| 1958 | 1995 | ||
| 1959 | void Application::setCursorVisible(bool visible) { | 1996 | void Application::updateCursorVisibility() { |
| 1960 | if (visible) { | 1997 | if (!_cursorVisible || Menu::getInstance()->isOptionChecked(MenuOption::EnableVRMode)) { |
| 1961 | if (overrideCursor() != NULL) { | 1998 | DependencyManager::get<GLCanvas>()->setCursor(Qt::BlankCursor); |
| 1962 | restoreOverrideCursor(); | ||
| 1963 | } | ||
| 1964 | } else { | 1999 | } else { |
| 1965 | if (overrideCursor() != NULL) { | 2000 | DependencyManager::get<GLCanvas>()->unsetCursor(); |
| 1966 | changeOverrideCursor(Qt::BlankCursor); | ||
| 1967 | } else { | ||
| 1968 | setOverrideCursor(Qt::BlankCursor); | ||
| 1969 | } | ||
| 1970 | } | 2001 | } |
| 1971 | } | 2002 | } |
| 1972 | 2003 | ||
| 2004 | void Application::setCursorVisible(bool visible) { | ||
| 2005 | _cursorVisible = visible; | ||
| 2006 | updateCursorVisibility(); | ||
| 2007 | } | ||
| 2008 | |||
| 1973 | void Application::update(float deltaTime) { | 2009 | void Application::update(float deltaTime) { |
| 1974 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); | 2010 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); |
| 1975 | PerformanceWarning warn(showWarnings, "Application::update()"); | 2011 | PerformanceWarning warn(showWarnings, "Application::update()"); |
| @@ -1992,7 +2028,7 @@ void Application::update(float deltaTime) { · 16 unmodified lines | |||
| 1992 | 2028 | ||
| 1993 | updateThreads(deltaTime); // If running non-threaded, then give the threads some time to process... | 2029 | updateThreads(deltaTime); // If running non-threaded, then give the threads some time to process... |
| 1994 | 2030 | ||
| 1995 | _avatarManager.updateOtherAvatars(deltaTime); //loop through all the other avatars and simulate them... | 2031 | DependencyManager::get<AvatarManager>()->updateOtherAvatars(deltaTime); //loop through all the other avatars and simulate them... |
| 1996 | 2032 | ||
| 1997 | updateMetavoxels(deltaTime); // update metavoxels | 2033 | updateMetavoxels(deltaTime); // update metavoxels |
| 1998 | updateCamera(deltaTime); // handle various camera tweaks like off axis projection | 2034 | updateCamera(deltaTime); // handle various camera tweaks like off axis projection |
| @@ -2019,7 +2055,7 @@ void Application::update(float deltaTime) { · 20 unmodified lines | |||
| 2019 | { | 2055 | { |
| 2020 | PerformanceTimer perfTimer("myAvatar"); | 2056 | PerformanceTimer perfTimer("myAvatar"); |
| 2021 | updateMyAvatarLookAtPosition(); | 2057 | updateMyAvatarLookAtPosition(); |
| 2022 | updateMyAvatar(deltaTime); // Sample hardware, update view frustum if needed, and send avatar data to mixer/nodes | 2058 | DependencyManager::get<AvatarManager>()->updateMyAvatar(deltaTime); // Sample hardware, update view frustum if needed, and send avatar data to mixer/nodes |
| 2023 | } | 2059 | } |
| 2024 | 2060 | ||
| 2025 | { | 2061 | { |
| @@ -2076,31 +2112,11 @@ void Application::update(float deltaTime) { · 50 unmodified lines | |||
| 2076 | if (sinceLastNack > TOO_LONG_SINCE_LAST_SEND_DOWNSTREAM_AUDIO_STATS) { | 2112 | if (sinceLastNack > TOO_LONG_SINCE_LAST_SEND_DOWNSTREAM_AUDIO_STATS) { |
| 2077 | _lastSendDownstreamAudioStats = now; | 2113 | _lastSendDownstreamAudioStats = now; |
| 2078 | 2114 | ||
| 2079 | QMetaObject::invokeMethod(DependencyManager::get<Audio>().data(), "sendDownstreamAudioStatsPacket", Qt::QueuedConnection); | 2115 | QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(), "sendDownstreamAudioStatsPacket", Qt::QueuedConnection); |
| 2080 | } | 2116 | } |
| 2081 | } | 2117 | } |
| 2082 | } | 2118 | } |
| 2083 | 2119 | ||
| 2084 | void Application::updateMyAvatar(float deltaTime) { | ||
| 2085 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); | ||
| 2086 | PerformanceWarning warn(showWarnings, "Application::updateMyAvatar()"); | ||
| 2087 | |||
| 2088 | _myAvatar->update(deltaTime); | ||
| 2089 | |||
| 2090 | quint64 now = usecTimestampNow(); | ||
| 2091 | quint64 dt = now - _lastSendAvatarDataTime; | ||
| 2092 | |||
| 2093 | if (dt > MIN_TIME_BETWEEN_MY_AVATAR_DATA_SENDS) { | ||
| 2094 | // send head/hand data to the avatar mixer and voxel server | ||
| 2095 | PerformanceTimer perfTimer("send"); | ||
| 2096 | QByteArray packet = byteArrayWithPopulatedHeader(PacketTypeAvatarData); | ||
| 2097 | packet.append(_myAvatar->toByteArray()); | ||
| 2098 | controlledBroadcastToNodes(packet, NodeSet() << NodeType::AvatarMixer); | ||
| 2099 | |||
| 2100 | _lastSendAvatarDataTime = now; | ||
| 2101 | } | ||
| 2102 | } | ||
| 2103 | |||
| 2104 | int Application::sendNackPackets() { | 2120 | int Application::sendNackPackets() { |
| 2105 | 2121 | ||
| 2106 | if (Menu::getInstance()->isOptionChecked(MenuOption::DisableNackPackets)) { | 2122 | if (Menu::getInstance()->isOptionChecked(MenuOption::DisableNackPackets)) { |
| @@ -2540,7 +2556,7 @@ void Application::updateShadowMap() { · 433 unmodified lines | |||
| 2540 | 2556 | ||
| 2541 | { | 2557 | { |
| 2542 | PerformanceTimer perfTimer("avatarManager"); | 2558 | PerformanceTimer perfTimer("avatarManager"); |
| 2543 | _avatarManager.renderAvatars(Avatar::SHADOW_RENDER_MODE); | 2559 | DependencyManager::get<AvatarManager>()->renderAvatars(Avatar::SHADOW_RENDER_MODE); |
| 2544 | } | 2560 | } |
| 2545 | 2561 | ||
| 2546 | { | 2562 | { |
| @@ -2792,7 +2808,7 @@ void Application::displaySide(Camera& theCamera, bool selfAvatarOnly, RenderArgs · 245 unmodified lines | |||
| 2792 | bool mirrorMode = (theCamera.getMode() == CAMERA_MODE_MIRROR); | 2808 | bool mirrorMode = (theCamera.getMode() == CAMERA_MODE_MIRROR); |
| 2793 | { | 2809 | { |
| 2794 | PerformanceTimer perfTimer("avatars"); | 2810 | PerformanceTimer perfTimer("avatars"); |
| 2795 | _avatarManager.renderAvatars(mirrorMode ? Avatar::MIRROR_RENDER_MODE : Avatar::NORMAL_RENDER_MODE, | 2811 | DependencyManager::get<AvatarManager>()->renderAvatars(mirrorMode ? Avatar::MIRROR_RENDER_MODE : Avatar::NORMAL_RENDER_MODE, |
| 2796 | false, selfAvatarOnly); | 2812 | false, selfAvatarOnly); |
| 2797 | } | 2813 | } |
| 2798 | 2814 | ||
| @@ -2807,7 +2823,7 @@ void Application::displaySide(Camera& theCamera, bool selfAvatarOnly, RenderArgs · 8 unmodified lines | |||
| 2807 | 2823 | ||
| 2808 | { | 2824 | { |
| 2809 | PerformanceTimer perfTimer("avatarsPostLighting"); | 2825 | PerformanceTimer perfTimer("avatarsPostLighting"); |
| 2810 | _avatarManager.renderAvatars(mirrorMode ? Avatar::MIRROR_RENDER_MODE : Avatar::NORMAL_RENDER_MODE, | 2826 | DependencyManager::get<AvatarManager>()->renderAvatars(mirrorMode ? Avatar::MIRROR_RENDER_MODE : Avatar::NORMAL_RENDER_MODE, |
| 2811 | true, selfAvatarOnly); | 2827 | true, selfAvatarOnly); |
| 2812 | } | 2828 | } |
| 2813 | 2829 | ||
| @@ -3071,7 +3087,7 @@ void Application::resetSensors() { · 257 unmodified lines | |||
| 3071 | 3087 | ||
| 3072 | _myAvatar->reset(); | 3088 | _myAvatar->reset(); |
| 3073 | 3089 | ||
| 3074 | QMetaObject::invokeMethod(DependencyManager::get<Audio>().data(), "reset", Qt::QueuedConnection); | 3090 | QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(), "reset", Qt::QueuedConnection); |
| 3075 | } | 3091 | } |
| 3076 | 3092 | ||
| 3077 | static void setShortcutsEnabled(QWidget* widget, bool enabled) { | 3093 | static void setShortcutsEnabled(QWidget* widget, bool enabled) { |
| @@ -3211,7 +3227,7 @@ void Application::nodeKilled(SharedNodePointer node) { · 133 unmodified lines | |||
| 3211 | _entityEditSender.nodeKilled(node); | 3227 | _entityEditSender.nodeKilled(node); |
| 3212 | 3228 | ||
| 3213 | if (node->getType() == NodeType::AudioMixer) { | 3229 | if (node->getType() == NodeType::AudioMixer) { |
| 3214 | QMetaObject::invokeMethod(DependencyManager::get<Audio>().data(), "audioMixerKilled"); | 3230 | QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(), "audioMixerKilled"); |
| 3215 | } | 3231 | } |
| 3216 | 3232 | ||
| 3217 | if (node->getType() == NodeType::EntityServer) { | 3233 | if (node->getType() == NodeType::EntityServer) { |
| @@ -3254,7 +3270,7 @@ void Application::nodeKilled(SharedNodePointer node) { · 36 unmodified lines | |||
| 3254 | 3270 | ||
| 3255 | } else if (node->getType() == NodeType::AvatarMixer) { | 3271 | } else if (node->getType() == NodeType::AvatarMixer) { |
| 3256 | // our avatar mixer has gone away - clear the hash of avatars | 3272 | // our avatar mixer has gone away - clear the hash of avatars |
| 3257 | _avatarManager.clearOtherAvatars(); | 3273 | DependencyManager::get<AvatarManager>()->clearOtherAvatars(); |
| 3258 | } | 3274 | } |
| 3259 | } | 3275 | } |
| 3260 | 3276 | ||
| @@ -3403,7 +3419,7 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri · 142 unmodified lines | |||
| 3403 | 3419 | ||
| 3404 | // hook our avatar and avatar hash map object into this script engine | 3420 | // hook our avatar and avatar hash map object into this script engine |
| 3405 | scriptEngine->setAvatarData(_myAvatar, "MyAvatar"); // leave it as a MyAvatar class to expose thrust features | 3421 | scriptEngine->setAvatarData(_myAvatar, "MyAvatar"); // leave it as a MyAvatar class to expose thrust features |
| 3406 | scriptEngine->setAvatarHashMap(&_avatarManager, "AvatarList"); | 3422 | scriptEngine->setAvatarHashMap(DependencyManager::get<AvatarManager>().data(), "AvatarList"); |
| 3407 | 3423 | ||
| 3408 | scriptEngine->registerGlobalObject("Camera", &_myCamera); | 3424 | scriptEngine->registerGlobalObject("Camera", &_myCamera); |
| 3409 | 3425 | ||
| @@ -3444,7 +3460,7 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri · 34 unmodified lines | |||
| 3444 | scriptEngine->registerGlobalObject("GlobalServices", GlobalServicesScriptingInterface::getInstance()); | 3460 | scriptEngine->registerGlobalObject("GlobalServices", GlobalServicesScriptingInterface::getInstance()); |
| 3445 | qScriptRegisterMetaType(scriptEngine, DownloadInfoResultToScriptValue, DownloadInfoResultFromScriptValue); | 3461 | qScriptRegisterMetaType(scriptEngine, DownloadInfoResultToScriptValue, DownloadInfoResultFromScriptValue); |
| 3446 | 3462 | ||
| 3447 | scriptEngine->registerGlobalObject("AvatarManager", &_avatarManager); | 3463 | scriptEngine->registerGlobalObject("AvatarManager", DependencyManager::get<AvatarManager>().data()); |
| 3448 | 3464 | ||
| 3449 | scriptEngine->registerGlobalObject("Joysticks", &JoystickScriptingInterface::getInstance()); | 3465 | scriptEngine->registerGlobalObject("Joysticks", &JoystickScriptingInterface::getInstance()); |
| 3450 | qScriptRegisterMetaType(scriptEngine, joystickToScriptValue, joystickFromScriptValue); | 3466 | qScriptRegisterMetaType(scriptEngine, joystickToScriptValue, joystickFromScriptValue); |
| @@ -3746,10 +3762,6 @@ void Application::toggleLogDialog() { · 295 unmodified lines | |||
| 3746 | } | 3762 | } |
| 3747 | } | 3763 | } |
| 3748 | 3764 | ||
| 3749 | void Application::initAvatarAndViewFrustum() { | ||
| 3750 | updateMyAvatar(0.0f); | ||
| 3751 | } | ||
| 3752 | |||
| 3753 | void Application::checkVersion() { | 3765 | void Application::checkVersion() { |
| 3754 | QNetworkRequest latestVersionRequest((QUrl(CHECK_VERSION_URL))); | 3766 | QNetworkRequest latestVersionRequest((QUrl(CHECK_VERSION_URL))); |
| 3755 | latestVersionRequest.setHeader(QNetworkRequest::UserAgentHeader, HIGH_FIDELITY_USER_AGENT); | 3767 | latestVersionRequest.setHeader(QNetworkRequest::UserAgentHeader, HIGH_FIDELITY_USER_AGENT); |