From cf3b33a96b33257e6b4a620f856486d546fd6d45 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Thu, 24 Sep 2015 17:03:00 +0200 Subject: [PATCH 01/33] Replace Application::getInstance() with qApp --- assignment-client/src/octree/OctreeServer.cpp | 2 +- interface/src/Application.cpp | 34 ++++++------ interface/src/Application.h | 9 ++-- interface/src/GLCanvas.cpp | 8 +-- interface/src/LODManager.cpp | 4 +- interface/src/avatar/Avatar.cpp | 18 +++---- interface/src/avatar/AvatarManager.cpp | 10 ++-- interface/src/avatar/AvatarUpdate.cpp | 10 ++-- interface/src/avatar/Head.cpp | 2 +- interface/src/avatar/MyAvatar.cpp | 52 +++++++++---------- interface/src/devices/RealSense.cpp | 2 +- .../src/octree/OctreePacketProcessor.cpp | 4 +- .../scripting/ClipboardScriptingInterface.cpp | 10 ++-- .../ControllerScriptingInterface.cpp | 2 +- .../scripting/DesktopScriptingInterface.cpp | 4 +- .../GlobalServicesScriptingInterface.cpp | 2 +- .../src/scripting/HMDScriptingInterface.cpp | 23 ++++++-- .../src/scripting/HMDScriptingInterface.h | 18 ++++--- interface/src/scripting/WebWindowClass.cpp | 6 +-- .../scripting/WindowScriptingInterface.cpp | 36 ++++++------- interface/src/ui/AvatarInputs.cpp | 2 +- interface/src/ui/ChatMessageArea.cpp | 2 +- interface/src/ui/DataWebDialog.cpp | 2 +- interface/src/ui/DataWebPage.cpp | 6 +-- interface/src/ui/HMDToolsDialog.cpp | 24 ++++----- interface/src/ui/JSConsole.cpp | 2 +- interface/src/ui/MarketplaceDialog.cpp | 4 +- interface/src/ui/OctreeStatsDialog.cpp | 10 ++-- interface/src/ui/PreferencesDialog.cpp | 6 +-- interface/src/ui/RunningScriptsWidget.cpp | 28 +++++----- interface/src/ui/ScriptEditorWidget.cpp | 10 ++-- interface/src/ui/ScriptEditorWindow.cpp | 6 +-- interface/src/ui/Stats.cpp | 4 +- interface/src/ui/ToolWindow.cpp | 6 +-- interface/src/ui/overlays/Billboardable.cpp | 2 +- interface/src/ui/overlays/ModelOverlay.cpp | 2 +- interface/src/ui/overlays/Overlays.cpp | 6 +-- 37 files changed, 197 insertions(+), 181 deletions(-) diff --git a/assignment-client/src/octree/OctreeServer.cpp b/assignment-client/src/octree/OctreeServer.cpp index ee0403d57b..7899591998 100644 --- a/assignment-client/src/octree/OctreeServer.cpp +++ b/assignment-client/src/octree/OctreeServer.cpp @@ -191,7 +191,7 @@ void OctreeServer::trackPacketSendingTime(float time) { } -void OctreeServer::trackProcessWaitTime(float time) { +void OctreeServer::trackProcessWaitTime(float time) const float MAX_SHORT_TIME = 10.0f; const float MAX_LONG_TIME = 100.0f; if (time == SKIP_TIME) { diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index b25f3aa6a5..5b21f6bc39 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -218,11 +218,11 @@ public: } if (message->message == UWM_SHOW_APPLICATION) { - MainWindow* applicationWindow = Application::getInstance()->getWindow(); + MainWindow* applicationWindow = qApp->getWindow(); if (applicationWindow->isMinimized()) { applicationWindow->showNormal(); // Restores to windowed or maximized state appropriately. } - Application::getInstance()->setActiveWindow(applicationWindow); // Flashes the taskbar icon if not focus. + qApp->setActiveWindow(applicationWindow); // Flashes the taskbar icon if not focus. return true; } @@ -248,7 +248,7 @@ void messageHandler(QtMsgType type, const QMessageLogContext& context, const QSt OutputDebugStringA(logMessage.toLocal8Bit().constData()); OutputDebugStringA("\n"); #endif - Application::getInstance()->getLogger()->addMessage(qPrintable(logMessage + "\n")); + qApp->getLogger()->addMessage(qPrintable(logMessage + "\n")); } } @@ -1104,7 +1104,7 @@ void Application::paintGL() { PerformanceTimer perfTimer("renderOverlay"); // NOTE: There is no batch associated with this renderArgs // the ApplicationOverlay class assumes it's viewport is setup to be the device size - QSize size = qApp->getDeviceSize(); + QSize size = getDeviceSize(); renderArgs._viewport = glm::ivec4(0, 0, size.width(), size.height()); _applicationOverlay.renderOverlay(&renderArgs); } @@ -1116,7 +1116,7 @@ void Application::paintGL() { if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON || _myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) { Menu::getInstance()->setIsOptionChecked(MenuOption::FirstPerson, _myAvatar->getBoomLength() <= MyAvatar::ZOOM_MIN); Menu::getInstance()->setIsOptionChecked(MenuOption::ThirdPerson, !(_myAvatar->getBoomLength() <= MyAvatar::ZOOM_MIN)); - Application::getInstance()->cameraMenuChanged(); + cameraMenuChanged(); } // The render mode is default or mirror if the camera is in mirror mode, assigned further below @@ -3561,7 +3561,7 @@ namespace render { skybox = skyStage->getSkybox(); if (skybox) { - skybox->render(batch, *(Application::getInstance()->getDisplayViewFrustum())); + skybox->render(batch, *(qApp->getDisplayViewFrustum())); } } } @@ -4526,7 +4526,7 @@ void Application::loadDialog() { } void Application::loadScriptURLDialog() { - QInputDialog scriptURLDialog(Application::getInstance()->getWindow()); + QInputDialog scriptURLDialog(getWindow()); scriptURLDialog.setWindowTitle("Open and Run Script URL"); scriptURLDialog.setLabelText("Script:"); scriptURLDialog.setWindowFlags(Qt::Sheet); @@ -5095,8 +5095,8 @@ void Application::emulateMouse(Hand* hand, float click, float shift, int index) unsigned int deviceID = index == 0 ? CONTROLLER_0_EVENT : CONTROLLER_1_EVENT; - if (qApp->isHMDMode()) { - pos = qApp->getApplicationCompositor().getPalmClickLocation(palm); + if (isHMDMode()) { + pos = getApplicationCompositor().getPalmClickLocation(palm); } else { // Get directon relative to avatar orientation @@ -5105,7 +5105,7 @@ void Application::emulateMouse(Hand* hand, float click, float shift, int index) // Get the angles, scaled between (-0.5,0.5) float xAngle = (atan2f(direction.z, direction.x) + (float)M_PI_2); float yAngle = 0.5f - ((atan2f(direction.z, direction.y) + (float)M_PI_2)); - auto canvasSize = qApp->getCanvasSize(); + auto canvasSize = getCanvasSize(); // Get the pixel range over which the xAngle and yAngle are scaled float cursorRange = canvasSize.x * InputDevice::getCursorPixelRangeMult(); @@ -5120,14 +5120,14 @@ void Application::emulateMouse(Hand* hand, float click, float shift, int index) if (_oldHandLeftClick[index]) { QMouseEvent mouseEvent(QEvent::MouseButtonRelease, pos, Qt::LeftButton, Qt::LeftButton, 0); - qApp->mouseReleaseEvent(&mouseEvent, deviceID); + mouseReleaseEvent(&mouseEvent, deviceID); _oldHandLeftClick[index] = false; } if (_oldHandRightClick[index]) { QMouseEvent mouseEvent(QEvent::MouseButtonRelease, pos, Qt::RightButton, Qt::RightButton, 0); - qApp->mouseReleaseEvent(&mouseEvent, deviceID); + mouseReleaseEvent(&mouseEvent, deviceID); _oldHandRightClick[index] = false; } @@ -5141,7 +5141,7 @@ void Application::emulateMouse(Hand* hand, float click, float shift, int index) // Only send the mouse event if the opposite left button isnt held down. // Is this check necessary? if (!_oldHandLeftClick[(int)(!index)]) { - qApp->mouseMoveEvent(&mouseEvent, deviceID); + mouseMoveEvent(&mouseEvent, deviceID); } } _oldHandMouseX[index] = pos.x(); @@ -5162,12 +5162,12 @@ void Application::emulateMouse(Hand* hand, float click, float shift, int index) QMouseEvent mouseEvent(QEvent::MouseButtonPress, pos, Qt::RightButton, Qt::RightButton, 0); - qApp->mousePressEvent(&mouseEvent, deviceID); + mousePressEvent(&mouseEvent, deviceID); } } else if (_oldHandRightClick[index]) { QMouseEvent mouseEvent(QEvent::MouseButtonRelease, pos, Qt::RightButton, Qt::RightButton, 0); - qApp->mouseReleaseEvent(&mouseEvent, deviceID); + mouseReleaseEvent(&mouseEvent, deviceID); _oldHandRightClick[index] = false; } @@ -5179,12 +5179,12 @@ void Application::emulateMouse(Hand* hand, float click, float shift, int index) QMouseEvent mouseEvent(QEvent::MouseButtonPress, pos, Qt::LeftButton, Qt::LeftButton, 0); - qApp->mousePressEvent(&mouseEvent, deviceID); + mousePressEvent(&mouseEvent, deviceID); } } else if (_oldHandLeftClick[index]) { QMouseEvent mouseEvent(QEvent::MouseButtonRelease, pos, Qt::LeftButton, Qt::LeftButton, 0); - qApp->mouseReleaseEvent(&mouseEvent, deviceID); + mouseReleaseEvent(&mouseEvent, deviceID); _oldHandLeftClick[index] = false; } diff --git a/interface/src/Application.h b/interface/src/Application.h index 20ae2f23ab..883f2dd30e 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -139,11 +139,10 @@ class Application : public QApplication, public AbstractViewStateInterface, publ friend class DatagramProcessor; public: - static Application* getInstance() { return qApp; } // TODO: replace fully by qApp - static const glm::vec3& getPositionForPath() { return getInstance()->_myAvatar->getPosition(); } - static glm::quat getOrientationForPath() { return getInstance()->_myAvatar->getOrientation(); } - static glm::vec3 getPositionForAudio() { return getInstance()->_myAvatar->getPositionForAudio(); } - static glm::quat getOrientationForAudio() { return getInstance()->_myAvatar->getOrientationForAudio(); } + static const glm::vec3& getPositionForPath() { return qApp->_myAvatar->getPosition(); } + static glm::quat getOrientationForPath() { return qApp->_myAvatar->getOrientation(); } + static glm::vec3 getPositionForAudio() { return qApp->_myAvatar->getPositionForAudio(); } + static glm::quat getOrientationForAudio() { return qApp->_myAvatar->getOrientationForAudio(); } static void initPlugins(); static void shutdownPlugins(); diff --git a/interface/src/GLCanvas.cpp b/interface/src/GLCanvas.cpp index 66aae5343b..1988cdffbe 100644 --- a/interface/src/GLCanvas.cpp +++ b/interface/src/GLCanvas.cpp @@ -62,13 +62,13 @@ void GLCanvas::paintGL() { // FIXME - I'm not sure why this still remains, it appears as if this GLCanvas gets a single paintGL call near // the beginning of the application starting up. I'm not sure if we really need to call Application::paintGL() // in this case, since the display plugins eventually handle all the painting - if (!Application::getInstance()->getWindow()->isMinimized() || !Application::getInstance()->isThrottleFPSEnabled()) { - Application::getInstance()->paintGL(); + if (!qApp->getWindow()->isMinimized() || !qApp->isThrottleFPSEnabled()) { + qApp->paintGL(); } } void GLCanvas::resizeGL(int width, int height) { - Application::getInstance()->resizeGL(); + qApp->resizeGL(); } int updateTime = 0; @@ -95,7 +95,7 @@ bool GLCanvas::event(QEvent* event) { break; case QEvent::Paint: // Ignore paint events that occur after we've decided to quit - if (Application::getInstance()->isAboutToQuit()) { + if (qApp->isAboutToQuit()) { return true; } break; diff --git a/interface/src/LODManager.cpp b/interface/src/LODManager.cpp index c57f1d0aa7..2a2edef831 100644 --- a/interface/src/LODManager.cpp +++ b/interface/src/LODManager.cpp @@ -26,14 +26,14 @@ LODManager::LODManager() { } float LODManager::getLODDecreaseFPS() { - if (Application::getInstance()->isHMDMode()) { + if (qApp->isHMDMode()) { return getHMDLODDecreaseFPS(); } return getDesktopLODDecreaseFPS(); } float LODManager::getLODIncreaseFPS() { - if (Application::getInstance()->isHMDMode()) { + if (qApp->isHMDMode()) { return getHMDLODIncreaseFPS(); } return getDesktopLODIncreaseFPS(); diff --git a/interface/src/avatar/Avatar.cpp b/interface/src/avatar/Avatar.cpp index faf4bffeba..a7a4879403 100644 --- a/interface/src/avatar/Avatar.cpp +++ b/interface/src/avatar/Avatar.cpp @@ -72,7 +72,7 @@ namespace render { avatarPtr->setDisplayingLookatTarget(renderLookAtTarget); if (avatarPtr->isInitialized() && args) { - avatarPtr->render(args, Application::getInstance()->getCamera()->getPosition()); + avatarPtr->render(args, qApp->getCamera()->getPosition()); } } } @@ -98,7 +98,7 @@ Avatar::Avatar(RigPointer rig) : _voiceSphereID(GeometryCache::UNKNOWN_ID) { // we may have been created in the network thread, but we live in the main thread - moveToThread(Application::getInstance()->thread()); + moveToThread(qApp->thread()); // give the pointer to our head to inherited _headData variable from AvatarData _headData = static_cast(new Head(this)); @@ -152,7 +152,7 @@ void Avatar::simulate(float deltaTime) { // update the avatar's position according to its referential if (_referential) { if (_referential->hasExtraData()) { - EntityTreePointer tree = Application::getInstance()->getEntities()->getTree(); + EntityTreePointer tree = qApp->getEntities()->getTree(); switch (_referential->type()) { case Referential::MODEL: _referential = new ModelReferential(_referential, @@ -189,7 +189,7 @@ void Avatar::simulate(float deltaTime) { // simple frustum check float boundingRadius = getBillboardSize(); - bool inViewFrustum = Application::getInstance()->getViewFrustum()->sphereInFrustum(_position, boundingRadius) != + bool inViewFrustum = qApp->getViewFrustum()->sphereInFrustum(_position, boundingRadius) != ViewFrustum::OUTSIDE; { @@ -388,9 +388,9 @@ void Avatar::render(RenderArgs* renderArgs, const glm::vec3& cameraPosition) { float boundingRadius = getBillboardSize(); ViewFrustum* frustum = nullptr; if (renderArgs->_renderMode == RenderArgs::SHADOW_RENDER_MODE) { - frustum = Application::getInstance()->getShadowViewFrustum(); + frustum = qApp->getShadowViewFrustum(); } else { - frustum = Application::getInstance()->getDisplayViewFrustum(); + frustum = qApp->getDisplayViewFrustum(); } if (frustum->sphereInFrustum(getPosition(), boundingRadius) == ViewFrustum::OUTSIDE) { @@ -539,7 +539,7 @@ void Avatar::render(RenderArgs* renderArgs, const glm::vec3& cameraPosition) { const float DISPLAYNAME_DISTANCE = 20.0f; setShowDisplayName(distanceToTarget < DISPLAYNAME_DISTANCE); - auto cameraMode = Application::getInstance()->getCamera()->getMode(); + auto cameraMode = qApp->getCamera()->getMode(); if (!isMyAvatar() || cameraMode != CAMERA_MODE_FIRST_PERSON) { renderDisplayName(batch, *renderArgs->_viewFrustum, renderArgs->_viewport); } @@ -566,7 +566,7 @@ void Avatar::fixupModelsInScene() { // check to see if when we added our models to the scene they were ready, if they were not ready, then // fix them up in the scene - render::ScenePointer scene = Application::getInstance()->getMain3DScene(); + render::ScenePointer scene = qApp->getMain3DScene(); render::PendingChanges pendingChanges; if (_skeletonModel.isRenderable() && _skeletonModel.needsFixupInScene()) { _skeletonModel.removeFromScene(scene, pendingChanges); @@ -653,7 +653,7 @@ void Avatar::renderBillboard(RenderArgs* renderArgs) { } // rotate about vertical to face the camera glm::quat rotation = getOrientation(); - glm::vec3 cameraVector = glm::inverse(rotation) * (Application::getInstance()->getCamera()->getPosition() - _position); + glm::vec3 cameraVector = glm::inverse(rotation) * (qApp->getCamera()->getPosition() - _position); rotation = rotation * glm::angleAxis(atan2f(-cameraVector.x, -cameraVector.z), glm::vec3(0.0f, 1.0f, 0.0f)); // compute the size from the billboard camera parameters and scale diff --git a/interface/src/avatar/AvatarManager.cpp b/interface/src/avatar/AvatarManager.cpp index 1790682e56..69d76db7de 100644 --- a/interface/src/avatar/AvatarManager.cpp +++ b/interface/src/avatar/AvatarManager.cpp @@ -81,7 +81,7 @@ void AvatarManager::init() { connect(DependencyManager::get().data(), &SceneScriptingInterface::shouldRenderAvatarsChanged, this, &AvatarManager::updateAvatarRenderStatus, Qt::QueuedConnection); - render::ScenePointer scene = Application::getInstance()->getMain3DScene(); + render::ScenePointer scene = qApp->getMain3DScene(); render::PendingChanges pendingChanges; if (DependencyManager::get()->shouldRenderAvatars()) { _myAvatar->addToScene(_myAvatar, scene, pendingChanges); @@ -146,7 +146,7 @@ void AvatarManager::simulateAvatarFades(float deltaTime) { const float SHRINK_RATE = 0.9f; const float MIN_FADE_SCALE = 0.001f; - render::ScenePointer scene = Application::getInstance()->getMain3DScene(); + render::ScenePointer scene = qApp->getMain3DScene(); render::PendingChanges pendingChanges; while (fadingIterator != _avatarFades.end()) { auto avatar = std::static_pointer_cast(*fadingIterator); @@ -171,7 +171,7 @@ AvatarSharedPointer AvatarManager::newSharedAvatar() { // virtual AvatarSharedPointer AvatarManager::addAvatar(const QUuid& sessionUUID, const QWeakPointer& mixerWeakPointer) { auto avatar = std::dynamic_pointer_cast(AvatarHashMap::addAvatar(sessionUUID, mixerWeakPointer)); - render::ScenePointer scene = Application::getInstance()->getMain3DScene(); + render::ScenePointer scene = qApp->getMain3DScene(); render::PendingChanges pendingChanges; if (DependencyManager::get()->shouldRenderAvatars()) { avatar->addToScene(avatar, scene, pendingChanges); @@ -328,7 +328,7 @@ void AvatarManager::updateAvatarRenderStatus(bool shouldRenderAvatars) { if (DependencyManager::get()->shouldRenderAvatars()) { for (auto avatarData : _avatarHash) { auto avatar = std::dynamic_pointer_cast(avatarData); - render::ScenePointer scene = Application::getInstance()->getMain3DScene(); + render::ScenePointer scene = qApp->getMain3DScene(); render::PendingChanges pendingChanges; avatar->addToScene(avatar, scene, pendingChanges); scene->enqueuePendingChanges(pendingChanges); @@ -336,7 +336,7 @@ void AvatarManager::updateAvatarRenderStatus(bool shouldRenderAvatars) { } else { for (auto avatarData : _avatarHash) { auto avatar = std::dynamic_pointer_cast(avatarData); - render::ScenePointer scene = Application::getInstance()->getMain3DScene(); + render::ScenePointer scene = qApp->getMain3DScene(); render::PendingChanges pendingChanges; avatar->removeFromScene(avatar, scene, pendingChanges); scene->enqueuePendingChanges(pendingChanges); diff --git a/interface/src/avatar/AvatarUpdate.cpp b/interface/src/avatar/AvatarUpdate.cpp index a4391172a7..909d3a7bb9 100644 --- a/interface/src/avatar/AvatarUpdate.cpp +++ b/interface/src/avatar/AvatarUpdate.cpp @@ -29,11 +29,11 @@ AvatarUpdate::AvatarUpdate() : GenericThread(), _lastAvatarUpdate(0) { void AvatarUpdate::synchronousProcess() { // Keep our own updated value, so that our asynchronous code can consult it. - _isHMDMode = Application::getInstance()->isHMDMode(); - _headPose = Application::getInstance()->getActiveDisplayPlugin()->getHeadPose(); + _isHMDMode = qApp->isHMDMode(); + _headPose = qApp->getActiveDisplayPlugin()->getHeadPose(); if (_updateBillboard) { - Application::getInstance()->getMyAvatar()->doUpdateBillboard(); + qApp->getMyAvatar()->doUpdateBillboard(); } if (!isThreaded()) { @@ -47,7 +47,7 @@ bool AvatarUpdate::process() { quint64 deltaMicroseconds = start - _lastAvatarUpdate; _lastAvatarUpdate = start; float deltaSeconds = (float) deltaMicroseconds / (float) USECS_PER_SECOND; - Application::getInstance()->setAvatarSimrateSample(1.0f / deltaSeconds); + qApp->setAvatarSimrateSample(1.0f / deltaSeconds); QSharedPointer manager = DependencyManager::get(); MyAvatar* myAvatar = manager->getMyAvatar(); @@ -57,7 +57,7 @@ bool AvatarUpdate::process() { manager->updateOtherAvatars(deltaSeconds); myAvatar->startUpdate(); - Application::getInstance()->updateMyAvatarLookAtPosition(); + qApp->updateMyAvatarLookAtPosition(); // Sample hardware, update view frustum if needed, and send avatar data to mixer/nodes manager->updateMyAvatar(deltaSeconds); myAvatar->endUpdate(); diff --git a/interface/src/avatar/Head.cpp b/interface/src/avatar/Head.cpp index d9a1b190d6..1a9b8a49e2 100644 --- a/interface/src/avatar/Head.cpp +++ b/interface/src/avatar/Head.cpp @@ -94,7 +94,7 @@ void Head::simulate(float deltaTime, bool isMine, bool billboard) { // Only use face trackers when not playing back a recording. if (!myAvatar->isPlaying()) { - FaceTracker* faceTracker = Application::getInstance()->getActiveFaceTracker(); + FaceTracker* faceTracker = qApp->getActiveFaceTracker(); _isFaceTrackerConnected = faceTracker != NULL && !faceTracker->isMuted(); if (_isFaceTrackerConnected) { _blendshapeCoefficients = faceTracker->getBlendshapeCoefficients(); diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index 9654305d70..ce5768de48 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -126,7 +126,7 @@ MyAvatar::~MyAvatar() { } QByteArray MyAvatar::toByteArray(bool cullSmallChanges, bool sendAll) { - CameraMode mode = Application::getInstance()->getCamera()->getMode(); + CameraMode mode = qApp->getCamera()->getMode(); if (mode == CAMERA_MODE_THIRD_PERSON || mode == CAMERA_MODE_INDEPENDENT) { // fake the avatar position that is sent up to the AvatarMixer glm::vec3 oldPosition = _position; @@ -374,7 +374,7 @@ void MyAvatar::updateFromTrackers(float deltaTime) { return; } - FaceTracker* tracker = Application::getInstance()->getActiveFaceTracker(); + FaceTracker* tracker = qApp->getActiveFaceTracker(); bool inFacetracker = tracker && !tracker->isMuted(); if (inHmd) { @@ -388,7 +388,7 @@ void MyAvatar::updateFromTrackers(float deltaTime) { estimatedPosition = tracker->getHeadTranslation(); _trackedHeadPosition = estimatedPosition; estimatedRotation = glm::degrees(safeEulerAngles(tracker->getHeadRotation())); - if (Application::getInstance()->getCamera()->getMode() == CAMERA_MODE_MIRROR) { + if (qApp->getCamera()->getMode() == CAMERA_MODE_MIRROR) { // Invert yaw and roll when in mirror mode // NOTE: this is kinda a hack, it's the same hack we use to make the head tilt. But it's not really a mirror // it just makes you feel like you're looking in a mirror because the body movements of the avatar appear to @@ -442,7 +442,7 @@ void MyAvatar::updateFromTrackers(float deltaTime) { // NOTE: this is kinda a hack, it's the same hack we use to make the head tilt. But it's not really a mirror // it just makes you feel like you're looking in a mirror because the body movements of the avatar appear to // match your body movements. - if ((inHmd || inFacetracker) && Application::getInstance()->getCamera()->getMode() == CAMERA_MODE_MIRROR) { + if ((inHmd || inFacetracker) && qApp->getCamera()->getMode() == CAMERA_MODE_MIRROR) { relativePosition.x = -relativePosition.x; } @@ -538,7 +538,7 @@ void MyAvatar::clearReferential() { } bool MyAvatar::setModelReferential(const QUuid& id) { - EntityTreePointer tree = Application::getInstance()->getEntities()->getTree(); + EntityTreePointer tree = qApp->getEntities()->getTree(); changeReferential(new ModelReferential(id, tree, this)); if (_referential->isValid()) { return true; @@ -549,7 +549,7 @@ bool MyAvatar::setModelReferential(const QUuid& id) { } bool MyAvatar::setJointReferential(const QUuid& id, int jointIndex) { - EntityTreePointer tree = Application::getInstance()->getEntities()->getTree(); + EntityTreePointer tree = qApp->getEntities()->getTree(); changeReferential(new JointReferential(jointIndex, id, tree, this)); if (!_referential->isValid()) { return true; @@ -856,7 +856,7 @@ void MyAvatar::setEnableDebugDrawAnimPose(bool isEnabled) { } void MyAvatar::setEnableMeshVisible(bool isEnabled) { - render::ScenePointer scene = Application::getInstance()->getMain3DScene(); + render::ScenePointer scene = qApp->getMain3DScene(); _skeletonModel.setVisibleInScene(isEnabled, scene); } @@ -1005,7 +1005,7 @@ void MyAvatar::updateLookAtTargetAvatar() { _targetAvatarPosition = glm::vec3(0.0f); glm::vec3 lookForward = getHead()->getFinalOrientationInWorldFrame() * IDENTITY_FRONT; - glm::vec3 cameraPosition = Application::getInstance()->getCamera()->getPosition(); + glm::vec3 cameraPosition = qApp->getCamera()->getPosition(); float smallestAngleTo = glm::radians(DEFAULT_FIELD_OF_VIEW_DEGREES) / 2.0f; const float KEEP_LOOKING_AT_CURRENT_ANGLE_FACTOR = 1.3f; @@ -1023,7 +1023,7 @@ void MyAvatar::updateLookAtTargetAvatar() { _targetAvatarPosition = avatarPointer->getPosition(); smallestAngleTo = angleTo; } - if (Application::getInstance()->isLookingAtMyAvatar(avatar)) { + if (qApp->isLookingAtMyAvatar(avatar)) { // Alter their gaze to look directly at my camera; this looks more natural than looking at my avatar's face. glm::vec3 lookAtPosition = avatar->getHead()->getLookAtPosition(); // A position, in world space, on my avatar. @@ -1035,11 +1035,11 @@ void MyAvatar::updateLookAtTargetAvatar() { // When not in HMD, these might both answer identity (i.e., the bridge of the nose). That's ok. // By my inpsection of the code and live testing, getEyeOffset and getEyePose are the same. (Application hands identity as offset matrix.) // This might be more work than needed for any given use, but as we explore different formulations, we go mad if we don't work in world space. - glm::mat4 leftEye = Application::getInstance()->getEyeOffset(Eye::Left); - glm::mat4 rightEye = Application::getInstance()->getEyeOffset(Eye::Right); + glm::mat4 leftEye = qApp->getEyeOffset(Eye::Left); + glm::mat4 rightEye = qApp->getEyeOffset(Eye::Right); glm::vec3 leftEyeHeadLocal = glm::vec3(leftEye[3]); glm::vec3 rightEyeHeadLocal = glm::vec3(rightEye[3]); - auto humanSystem = Application::getInstance()->getViewFrustum(); + auto humanSystem = qApp->getViewFrustum(); glm::vec3 humanLeftEye = humanSystem->getPosition() + (humanSystem->getOrientation() * leftEyeHeadLocal); glm::vec3 humanRightEye = humanSystem->getPosition() + (humanSystem->getOrientation() * rightEyeHeadLocal); @@ -1065,7 +1065,7 @@ void MyAvatar::updateLookAtTargetAvatar() { */ // And now we can finally add that offset to the camera. - glm::vec3 corrected = Application::getInstance()->getViewFrustum()->getPosition() + gazeOffset; + glm::vec3 corrected = qApp->getViewFrustum()->getPosition() + gazeOffset; avatar->getHead()->setCorrectedLookAtPosition(corrected); @@ -1172,7 +1172,7 @@ void MyAvatar::clearJointAnimationPriorities() { void MyAvatar::setFaceModelURL(const QUrl& faceModelURL) { Avatar::setFaceModelURL(faceModelURL); - render::ScenePointer scene = Application::getInstance()->getMain3DScene(); + render::ScenePointer scene = qApp->getMain3DScene(); getHead()->getFaceModel().setVisibleInScene(_prevShouldDrawHead, scene); _billboardValid = false; } @@ -1180,7 +1180,7 @@ void MyAvatar::setFaceModelURL(const QUrl& faceModelURL) { void MyAvatar::setSkeletonModelURL(const QUrl& skeletonModelURL) { Avatar::setSkeletonModelURL(skeletonModelURL); - render::ScenePointer scene = Application::getInstance()->getMain3DScene(); + render::ScenePointer scene = qApp->getMain3DScene(); _billboardValid = false; _skeletonModel.setVisibleInScene(true, scene); _headBoneSet.clear(); @@ -1238,7 +1238,7 @@ void MyAvatar::setAttachmentData(const QVector& attachmentData) } glm::vec3 MyAvatar::getSkeletonPosition() const { - CameraMode mode = Application::getInstance()->getCamera()->getMode(); + CameraMode mode = qApp->getCamera()->getMode(); if (mode == CAMERA_MODE_THIRD_PERSON || mode == CAMERA_MODE_INDEPENDENT) { // The avatar is rotated PI about the yAxis, so we have to correct for it // to get the skeleton offset contribution in the world-frame. @@ -1339,13 +1339,13 @@ void MyAvatar::renderBody(RenderArgs* renderArgs, ViewFrustum* renderFrustum, fl // This is drawing the lookat vectors from our avatar to wherever we're looking. if (qApp->isHMDMode()) { - glm::vec3 cameraPosition = Application::getInstance()->getCamera()->getPosition(); + glm::vec3 cameraPosition = qApp->getCamera()->getPosition(); - glm::mat4 leftEyePose = Application::getInstance()->getActiveDisplayPlugin()->getEyePose(Eye::Left); + glm::mat4 leftEyePose = qApp->getActiveDisplayPlugin()->getEyePose(Eye::Left); glm::vec3 leftEyePosition = glm::vec3(leftEyePose[3]); - glm::mat4 rightEyePose = Application::getInstance()->getActiveDisplayPlugin()->getEyePose(Eye::Right); + glm::mat4 rightEyePose = qApp->getActiveDisplayPlugin()->getEyePose(Eye::Right); glm::vec3 rightEyePosition = glm::vec3(rightEyePose[3]); - glm::mat4 headPose = Application::getInstance()->getActiveDisplayPlugin()->getHeadPose(); + glm::mat4 headPose = qApp->getActiveDisplayPlugin()->getHeadPose(); glm::vec3 headPosition = glm::vec3(headPose[3]); getHead()->renderLookAts(renderArgs, @@ -1421,7 +1421,7 @@ void MyAvatar::destroyAnimGraph() { void MyAvatar::preRender(RenderArgs* renderArgs) { - render::ScenePointer scene = Application::getInstance()->getMain3DScene(); + render::ScenePointer scene = qApp->getMain3DScene(); const bool shouldDrawHead = shouldRenderHead(renderArgs); if (_skeletonModel.initWhenReady(scene)) { @@ -1476,13 +1476,13 @@ const float RENDER_HEAD_CUTOFF_DISTANCE = 0.50f; bool MyAvatar::cameraInsideHead() const { const Head* head = getHead(); - const glm::vec3 cameraPosition = Application::getInstance()->getCamera()->getPosition(); + const glm::vec3 cameraPosition = qApp->getCamera()->getPosition(); return glm::length(cameraPosition - head->getEyePosition()) < (RENDER_HEAD_CUTOFF_DISTANCE * _scale); } bool MyAvatar::shouldRenderHead(const RenderArgs* renderArgs) const { return ((renderArgs->_renderMode != RenderArgs::DEFAULT_RENDER_MODE) || - (Application::getInstance()->getCamera()->getMode() != CAMERA_MODE_FIRST_PERSON) || + (qApp->getCamera()->getMode() != CAMERA_MODE_FIRST_PERSON) || !cameraInsideHead()); } @@ -1526,7 +1526,7 @@ void MyAvatar::updateOrientation(float deltaTime) { glm::vec3 euler = glm::eulerAngles(localOrientation) * DEGREES_PER_RADIAN; //Invert yaw and roll when in mirror mode - if (Application::getInstance()->getCamera()->getMode() == CAMERA_MODE_MIRROR) { + if (qApp->getCamera()->getMode() == CAMERA_MODE_MIRROR) { YAW(euler) *= -1.0f; ROLL(euler) *= -1.0f; } @@ -1951,7 +1951,7 @@ glm::vec3 MyAvatar::getPositionForAudio() { case AudioListenerMode::FROM_HEAD: return getHead()->getPosition(); case AudioListenerMode::FROM_CAMERA: - return Application::getInstance()->getCamera()->getPosition(); + return qApp->getCamera()->getPosition(); case AudioListenerMode::CUSTOM: return _customListenPosition; } @@ -1963,7 +1963,7 @@ glm::quat MyAvatar::getOrientationForAudio() { case AudioListenerMode::FROM_HEAD: return getHead()->getFinalOrientationInWorldFrame(); case AudioListenerMode::FROM_CAMERA: - return Application::getInstance()->getCamera()->getOrientation(); + return qApp->getCamera()->getOrientation(); case AudioListenerMode::CUSTOM: return _customListenOrientation; } diff --git a/interface/src/devices/RealSense.cpp b/interface/src/devices/RealSense.cpp index d9b1486f09..ce28e40f2b 100644 --- a/interface/src/devices/RealSense.cpp +++ b/interface/src/devices/RealSense.cpp @@ -250,7 +250,7 @@ void RealSense::update() { void RealSense::loadRSSDKFile() { QString locationDir(QStandardPaths::displayName(QStandardPaths::DesktopLocation)); - QString fileNameString = QFileDialog::getOpenFileName(Application::getInstance()->getWindow(), tr("Open RSSDK clip"), + QString fileNameString = QFileDialog::getOpenFileName(qApp->getWindow(), tr("Open RSSDK clip"), locationDir, tr("RSSDK Recordings (*.rssdk)")); if (!fileNameString.isEmpty()) { diff --git a/interface/src/octree/OctreePacketProcessor.cpp b/interface/src/octree/OctreePacketProcessor.cpp index 4a92e7e8ac..8dfee8f73b 100644 --- a/interface/src/octree/OctreePacketProcessor.cpp +++ b/interface/src/octree/OctreePacketProcessor.cpp @@ -33,11 +33,11 @@ void OctreePacketProcessor::processPacket(QSharedPointer packet, Share const int WAY_BEHIND = 300; - if (packetsToProcessCount() > WAY_BEHIND && Application::getInstance()->getLogger()->extraDebugging()) { + if (packetsToProcessCount() > WAY_BEHIND && qApp->getLogger()->extraDebugging()) { qDebug("OctreePacketProcessor::processPacket() packets to process=%d", packetsToProcessCount()); } - Application* app = Application::getInstance(); + Application* app = qApp; bool wasStatsPacket = false; PacketType octreePacketType = packet->getType(); diff --git a/interface/src/scripting/ClipboardScriptingInterface.cpp b/interface/src/scripting/ClipboardScriptingInterface.cpp index 4cebb85648..b0ef6c760d 100644 --- a/interface/src/scripting/ClipboardScriptingInterface.cpp +++ b/interface/src/scripting/ClipboardScriptingInterface.cpp @@ -15,12 +15,12 @@ ClipboardScriptingInterface::ClipboardScriptingInterface() { } float ClipboardScriptingInterface::getClipboardContentsLargestDimension() { - return Application::getInstance()->getEntityClipboard()->getContentsLargestDimension(); + return qApp->getEntityClipboard()->getContentsLargestDimension(); } bool ClipboardScriptingInterface::exportEntities(const QString& filename, const QVector& entityIDs) { bool retVal; - QMetaObject::invokeMethod(Application::getInstance(), "exportEntities", Qt::BlockingQueuedConnection, + QMetaObject::invokeMethod(qApp, "exportEntities", Qt::BlockingQueuedConnection, Q_RETURN_ARG(bool, retVal), Q_ARG(const QString&, filename), Q_ARG(const QVector&, entityIDs)); @@ -29,7 +29,7 @@ bool ClipboardScriptingInterface::exportEntities(const QString& filename, const bool ClipboardScriptingInterface::exportEntities(const QString& filename, float x, float y, float z, float s) { bool retVal; - QMetaObject::invokeMethod(Application::getInstance(), "exportEntities", Qt::BlockingQueuedConnection, + QMetaObject::invokeMethod(qApp, "exportEntities", Qt::BlockingQueuedConnection, Q_RETURN_ARG(bool, retVal), Q_ARG(const QString&, filename), Q_ARG(float, x), @@ -41,7 +41,7 @@ bool ClipboardScriptingInterface::exportEntities(const QString& filename, float bool ClipboardScriptingInterface::importEntities(const QString& filename) { bool retVal; - QMetaObject::invokeMethod(Application::getInstance(), "importEntities", Qt::BlockingQueuedConnection, + QMetaObject::invokeMethod(qApp, "importEntities", Qt::BlockingQueuedConnection, Q_RETURN_ARG(bool, retVal), Q_ARG(const QString&, filename)); return retVal; @@ -49,7 +49,7 @@ bool ClipboardScriptingInterface::importEntities(const QString& filename) { QVector ClipboardScriptingInterface::pasteEntities(glm::vec3 position) { QVector retVal; - QMetaObject::invokeMethod(Application::getInstance(), "pasteEntities", Qt::BlockingQueuedConnection, + QMetaObject::invokeMethod(qApp, "pasteEntities", Qt::BlockingQueuedConnection, Q_RETURN_ARG(QVector, retVal), Q_ARG(float, position.x), Q_ARG(float, position.y), diff --git a/interface/src/scripting/ControllerScriptingInterface.cpp b/interface/src/scripting/ControllerScriptingInterface.cpp index b182d3b339..6f36a6267f 100644 --- a/interface/src/scripting/ControllerScriptingInterface.cpp +++ b/interface/src/scripting/ControllerScriptingInterface.cpp @@ -378,7 +378,7 @@ void ControllerScriptingInterface::releaseJoystick(int joystickIndex) { } glm::vec2 ControllerScriptingInterface::getViewportDimensions() const { - return Application::getInstance()->getUiSize(); + return qApp->getUiSize(); } AbstractInputController* ControllerScriptingInterface::createInputController(const QString& deviceName, const QString& tracker) { diff --git a/interface/src/scripting/DesktopScriptingInterface.cpp b/interface/src/scripting/DesktopScriptingInterface.cpp index 746cdaf36f..843a40348e 100644 --- a/interface/src/scripting/DesktopScriptingInterface.cpp +++ b/interface/src/scripting/DesktopScriptingInterface.cpp @@ -18,10 +18,10 @@ #include "MainWindow.h" int DesktopScriptingInterface::getWidth() { - QSize size = Application::getInstance()->getWindow()->windowHandle()->screen()->virtualSize(); + QSize size = qApp->getWindow()->windowHandle()->screen()->virtualSize(); return size.width(); } int DesktopScriptingInterface::getHeight() { - QSize size = Application::getInstance()->getWindow()->windowHandle()->screen()->virtualSize(); + QSize size = qApp->getWindow()->windowHandle()->screen()->virtualSize(); return size.height(); } diff --git a/interface/src/scripting/GlobalServicesScriptingInterface.cpp b/interface/src/scripting/GlobalServicesScriptingInterface.cpp index 668bd92664..8ca381a607 100644 --- a/interface/src/scripting/GlobalServicesScriptingInterface.cpp +++ b/interface/src/scripting/GlobalServicesScriptingInterface.cpp @@ -143,5 +143,5 @@ void GlobalServicesScriptingInterface::updateDownloadInfo() { } void GlobalServicesScriptingInterface::editFriends() { - QMetaObject::invokeMethod(Application::getInstance(), "showFriendsWindow"); + QMetaObject::invokeMethod(qApp, "showFriendsWindow"); } diff --git a/interface/src/scripting/HMDScriptingInterface.cpp b/interface/src/scripting/HMDScriptingInterface.cpp index 68ac511eaf..b3630a4453 100644 --- a/interface/src/scripting/HMDScriptingInterface.cpp +++ b/interface/src/scripting/HMDScriptingInterface.cpp @@ -10,22 +10,27 @@ // #include "HMDScriptingInterface.h" -#include "display-plugins/DisplayPlugin.h" + +#include + #include +#include "Application.h" +#include "display-plugins/DisplayPlugin.h" + HMDScriptingInterface& HMDScriptingInterface::getInstance() { static HMDScriptingInterface sharedInstance; return sharedInstance; } bool HMDScriptingInterface::getHUDLookAtPosition3D(glm::vec3& result) const { - Camera* camera = Application::getInstance()->getCamera(); + Camera* camera = qApp->getCamera(); glm::vec3 position = camera->getPosition(); glm::quat orientation = camera->getOrientation(); glm::vec3 direction = orientation * glm::vec3(0.0f, 0.0f, -1.0f); - const auto& compositor = Application::getInstance()->getApplicationCompositor(); + const auto& compositor = qApp->getApplicationCompositor(); return compositor.calculateRayUICollisionPoint(position, direction, result); } @@ -40,7 +45,7 @@ QScriptValue HMDScriptingInterface::getHUDLookAtPosition2D(QScriptContext* conte glm::vec3 direction = glm::inverse(myAvatar->getOrientation()) * (hudIntersection - sphereCenter); glm::quat rotation = ::rotationBetween(glm::vec3(0.0f, 0.0f, -1.0f), direction); glm::vec3 eulers = ::safeEulerAngles(rotation); - return qScriptValueFromValue(engine, Application::getInstance()->getApplicationCompositor() + return qScriptValueFromValue(engine, qApp->getApplicationCompositor() .sphericalToOverlay(glm::vec2(eulers.y, -eulers.x))); } return QScriptValue::NullValue; @@ -55,5 +60,13 @@ QScriptValue HMDScriptingInterface::getHUDLookAtPosition3D(QScriptContext* conte } float HMDScriptingInterface::getIPD() const { - return Application::getInstance()->getActiveDisplayPlugin()->getIPD(); + return qApp->getActiveDisplayPlugin()->getIPD(); +} + +void HMDScriptingInterface::toggleMagnifier() { + qApp->getApplicationCompositor().toggleMagnifier(); +} + +bool HMDScriptingInterface::getMagnifier() const { + return qApp->getApplicationCompositor().hasMagnifier(); } diff --git a/interface/src/scripting/HMDScriptingInterface.h b/interface/src/scripting/HMDScriptingInterface.h index 82b444abaa..b118fab62b 100644 --- a/interface/src/scripting/HMDScriptingInterface.h +++ b/interface/src/scripting/HMDScriptingInterface.h @@ -12,32 +12,36 @@ #ifndef hifi_HMDScriptingInterface_h #define hifi_HMDScriptingInterface_h +#include + #include -#include "Application.h" +class QScriptContext; +class QScriptEngine; + class HMDScriptingInterface : public QObject { Q_OBJECT Q_PROPERTY(bool magnifier READ getMagnifier) Q_PROPERTY(bool active READ isHMDMode) Q_PROPERTY(float ipd READ getIPD) + public: static HMDScriptingInterface& getInstance(); - + static QScriptValue getHUDLookAtPosition2D(QScriptContext* context, QScriptEngine* engine); static QScriptValue getHUDLookAtPosition3D(QScriptContext* context, QScriptEngine* engine); public slots: - void toggleMagnifier() { Application::getInstance()->getApplicationCompositor().toggleMagnifier(); }; + void toggleMagnifier(); private: - HMDScriptingInterface() {}; - bool getMagnifier() const { return Application::getInstance()->getApplicationCompositor().hasMagnifier(); }; - bool isHMDMode() const { return Application::getInstance()->isHMDMode(); } + HMDScriptingInterface() = default; + bool getMagnifier() const; + bool isHMDMode() const; float getIPD() const; bool getHUDLookAtPosition3D(glm::vec3& result) const; - }; #endif // hifi_HMDScriptingInterface_h diff --git a/interface/src/scripting/WebWindowClass.cpp b/interface/src/scripting/WebWindowClass.cpp index a549410305..f9dc9e07ae 100644 --- a/interface/src/scripting/WebWindowClass.cpp +++ b/interface/src/scripting/WebWindowClass.cpp @@ -41,7 +41,7 @@ WebWindowClass::WebWindowClass(const QString& title, const QString& url, int wid _isToolWindow(isToolWindow) { if (_isToolWindow) { - ToolWindow* toolWindow = Application::getInstance()->getToolWindow(); + ToolWindow* toolWindow = qApp->getToolWindow(); auto dockWidget = new QDockWidget(title, toolWindow); dockWidget->setFeatures(QDockWidget::DockWidgetMovable); @@ -56,7 +56,7 @@ WebWindowClass::WebWindowClass(const QString& title, const QString& url, int wid _windowWidget = dockWidget; } else { - auto dialogWidget = new QDialog(Application::getInstance()->getWindow(), Qt::Window); + auto dialogWidget = new QDialog(qApp->getWindow(), Qt::Window); dialogWidget->setWindowTitle(title); dialogWidget->resize(width, height); dialogWidget->installEventFilter(this); @@ -120,7 +120,7 @@ void WebWindowClass::setVisible(bool visible) { if (visible) { if (_isToolWindow) { QMetaObject::invokeMethod( - Application::getInstance()->getToolWindow(), "setVisible", Qt::AutoConnection, Q_ARG(bool, visible)); + qApp->getToolWindow(), "setVisible", Qt::AutoConnection, Q_ARG(bool, visible)); } else { QMetaObject::invokeMethod(_windowWidget, "showNormal", Qt::AutoConnection); QMetaObject::invokeMethod(_windowWidget, "raise", Qt::AutoConnection); diff --git a/interface/src/scripting/WindowScriptingInterface.cpp b/interface/src/scripting/WindowScriptingInterface.cpp index 6be67a7261..a5c7087adc 100644 --- a/interface/src/scripting/WindowScriptingInterface.cpp +++ b/interface/src/scripting/WindowScriptingInterface.cpp @@ -32,8 +32,8 @@ WindowScriptingInterface::WindowScriptingInterface() : { const DomainHandler& domainHandler = DependencyManager::get()->getDomainHandler(); connect(&domainHandler, &DomainHandler::connectedToDomain, this, &WindowScriptingInterface::domainChanged); - connect(Application::getInstance(), &Application::svoImportRequested, this, &WindowScriptingInterface::svoImportRequested); - connect(Application::getInstance(), &Application::domainConnectionRefused, this, &WindowScriptingInterface::domainConnectionRefused); + connect(qApp, &Application::svoImportRequested, this, &WindowScriptingInterface::svoImportRequested); + connect(qApp, &Application::domainConnectionRefused, this, &WindowScriptingInterface::domainConnectionRefused); } WebWindowClass* WindowScriptingInterface::doCreateWebWindow(const QString& title, const QString& url, int width, int height, bool isToolWindow) { @@ -41,13 +41,13 @@ WebWindowClass* WindowScriptingInterface::doCreateWebWindow(const QString& title } QScriptValue WindowScriptingInterface::hasFocus() { - return Application::getInstance()->hasFocus(); + return qApp->hasFocus(); } void WindowScriptingInterface::setFocus() { // It's forbidden to call focus() from another thread. - Application::getInstance()->postLambdaEvent([] { - auto window = Application::getInstance()->getWindow(); + qApp->postLambdaEvent([] { + auto window = qApp->getWindow(); window->activateWindow(); window->setFocus(); }); @@ -55,18 +55,18 @@ void WindowScriptingInterface::setFocus() { void WindowScriptingInterface::raiseMainWindow() { // It's forbidden to call raise() from another thread. - Application::getInstance()->postLambdaEvent([] { - Application::getInstance()->getWindow()->raise(); + qApp->postLambdaEvent([] { + qApp->getWindow()->raise(); }); } void WindowScriptingInterface::setCursorVisible(bool visible) { - QMetaObject::invokeMethod(Application::getInstance(), "setCursorVisible", Qt::BlockingQueuedConnection, + QMetaObject::invokeMethod(qApp, "setCursorVisible", Qt::BlockingQueuedConnection, Q_ARG(bool, visible)); } bool WindowScriptingInterface::isCursorVisible() const { - return !Application::getInstance()->isMouseHidden(); + return !qApp->isMouseHidden(); } void WindowScriptingInterface::setCursorPosition(int x, int y) { @@ -167,7 +167,7 @@ QScriptValue WindowScriptingInterface::peekNonBlockingFormResult(QScriptValue fo /// \param const QString& message message to display /// \return QScriptValue::UndefinedValue QScriptValue WindowScriptingInterface::showAlert(const QString& message) { - QMessageBox::warning(Application::getInstance()->getWindow(), "", message); + QMessageBox::warning(qApp->getWindow(), "", message); return QScriptValue::UndefinedValue; } @@ -175,7 +175,7 @@ QScriptValue WindowScriptingInterface::showAlert(const QString& message) { /// \param const QString& message message to display /// \return QScriptValue `true` if 'Yes' was clicked, `false` otherwise QScriptValue WindowScriptingInterface::showConfirm(const QString& message) { - QMessageBox::StandardButton response = QMessageBox::question(Application::getInstance()->getWindow(), "", message); + QMessageBox::StandardButton response = QMessageBox::question(qApp->getWindow(), "", message); return QScriptValue(response == QMessageBox::Yes); } @@ -487,7 +487,7 @@ QScriptValue WindowScriptingInterface::showForm(const QString& title, QScriptVal QDialog* WindowScriptingInterface::createForm(const QString& title, QScriptValue form) { - QDialog* editDialog = new QDialog(Application::getInstance()->getWindow()); + QDialog* editDialog = new QDialog(qApp->getWindow()); editDialog->setWindowTitle(title); bool cancelButton = false; @@ -597,7 +597,7 @@ QDialog* WindowScriptingInterface::createForm(const QString& title, QScriptValue /// \param const QString& defaultText default text in the text box /// \return QScriptValue string text value in text box if the dialog was accepted, `null` otherwise. QScriptValue WindowScriptingInterface::showPrompt(const QString& message, const QString& defaultText) { - QInputDialog promptDialog(Application::getInstance()->getWindow()); + QInputDialog promptDialog(qApp->getWindow()); promptDialog.setWindowTitle(""); promptDialog.setLabelText(message); promptDialog.setTextValue(defaultText); @@ -627,7 +627,7 @@ QScriptValue WindowScriptingInterface::showBrowse(const QString& title, const QS path = fileInfo.filePath(); } - QFileDialog fileDialog(Application::getInstance()->getWindow(), title, path, nameFilter); + QFileDialog fileDialog(qApp->getWindow(), title, path, nameFilter); fileDialog.setAcceptMode(acceptMode); QUrl fileUrl(directory); if (acceptMode == QFileDialog::AcceptSave) { @@ -657,17 +657,17 @@ QScriptValue WindowScriptingInterface::showS3Browse(const QString& nameFilter) { } int WindowScriptingInterface::getInnerWidth() { - return Application::getInstance()->getWindow()->geometry().width(); + return qApp->getWindow()->geometry().width(); } int WindowScriptingInterface::getInnerHeight() { - return Application::getInstance()->getWindow()->geometry().height(); + return qApp->getWindow()->geometry().height(); } int WindowScriptingInterface::getX() { - return Application::getInstance()->getWindow()->x(); + return qApp->getWindow()->x(); } int WindowScriptingInterface::getY() { - return Application::getInstance()->getWindow()->y(); + return qApp->getWindow()->y(); } diff --git a/interface/src/ui/AvatarInputs.cpp b/interface/src/ui/AvatarInputs.cpp index 019deb9690..bc9181945f 100644 --- a/interface/src/ui/AvatarInputs.cpp +++ b/interface/src/ui/AvatarInputs.cpp @@ -106,7 +106,7 @@ void AvatarInputs::update() { } void AvatarInputs::toggleCameraMute() { - FaceTracker* faceTracker = Application::getInstance()->getSelectedFaceTracker(); + FaceTracker* faceTracker = qApp->getSelectedFaceTracker(); if (faceTracker) { faceTracker->toggleMute(); } diff --git a/interface/src/ui/ChatMessageArea.cpp b/interface/src/ui/ChatMessageArea.cpp index 1dc38e9c94..bef22b9fed 100644 --- a/interface/src/ui/ChatMessageArea.cpp +++ b/interface/src/ui/ChatMessageArea.cpp @@ -20,7 +20,7 @@ ChatMessageArea::ChatMessageArea(bool useFixedHeight) : QTextBrowser(), _useFixe connect(document()->documentLayout(), &QAbstractTextDocumentLayout::documentSizeChanged, this, &ChatMessageArea::updateLayout); - connect(this, &QTextBrowser::anchorClicked, Application::getInstance(), &Application::openUrl); + connect(this, &QTextBrowser::anchorClicked, qApp, &Application::openUrl); } void ChatMessageArea::setHtml(const QString& html) { diff --git a/interface/src/ui/DataWebDialog.cpp b/interface/src/ui/DataWebDialog.cpp index f405ef50c5..a92e0ac214 100644 --- a/interface/src/ui/DataWebDialog.cpp +++ b/interface/src/ui/DataWebDialog.cpp @@ -28,7 +28,7 @@ DataWebDialog::DataWebDialog() { setPage(new DataWebPage(this)); // have the Application handle external links - connect(this, &QWebView::linkClicked, Application::getInstance(), &Application::openUrl); + connect(this, &QWebView::linkClicked, qApp, &Application::openUrl); } DataWebDialog* DataWebDialog::dialogForPath(const QString& path, diff --git a/interface/src/ui/DataWebPage.cpp b/interface/src/ui/DataWebPage.cpp index 69c9954245..01feacc393 100644 --- a/interface/src/ui/DataWebPage.cpp +++ b/interface/src/ui/DataWebPage.cpp @@ -34,15 +34,15 @@ void DataWebPage::javaScriptConsoleMessage(const QString& message, int lineNumbe bool DataWebPage::acceptNavigationRequest(QWebFrame* frame, const QNetworkRequest& request, QWebPage::NavigationType type) { // Handle hifi:// links and links to files with particular extensions QString urlString = request.url().toString(); - if (Application::getInstance()->canAcceptURL(urlString)) { - if (Application::getInstance()->acceptURL(urlString)) { + if (qApp->canAcceptURL(urlString)) { + if (qApp->acceptURL(urlString)) { return false; // we handled it, so QWebPage doesn't need to handle it } } // Make hyperlinks with target="_blank" open in user's Web browser if (type == QWebPage::NavigationTypeLinkClicked && frame == nullptr) { - Application::getInstance()->openUrl(request.url()); + qApp->openUrl(request.url()); return false; // We handled it. } diff --git a/interface/src/ui/HMDToolsDialog.cpp b/interface/src/ui/HMDToolsDialog.cpp index e03e05912c..f37a4a9ba6 100644 --- a/interface/src/ui/HMDToolsDialog.cpp +++ b/interface/src/ui/HMDToolsDialog.cpp @@ -78,11 +78,11 @@ HMDToolsDialog::HMDToolsDialog(QWidget* parent) : // what screens we're allowed on watchWindow(windowHandle()); auto dialogsManager = DependencyManager::get(); - if (Application::getInstance()->getRunningScriptsWidget()) { - watchWindow(Application::getInstance()->getRunningScriptsWidget()->windowHandle()); + if (qApp->getRunningScriptsWidget()) { + watchWindow(qApp->getRunningScriptsWidget()->windowHandle()); } - if (Application::getInstance()->getToolWindow()) { - watchWindow(Application::getInstance()->getToolWindow()->windowHandle()); + if (qApp->getToolWindow()) { + watchWindow(qApp->getToolWindow()->windowHandle()); } if (dialogsManager->getBandwidthDialog()) { watchWindow(dialogsManager->getBandwidthDialog()->windowHandle()); @@ -110,7 +110,7 @@ HMDToolsDialog::HMDToolsDialog(QWidget* parent) : }); // watch for our application window moving screens. If it does we want to update our screen details - QWindow* mainWindow = Application::getInstance()->getWindow()->windowHandle(); + QWindow* mainWindow = qApp->getWindow()->windowHandle(); connect(mainWindow, &QWindow::screenChanged, [this]{ updateUi(); }); @@ -142,7 +142,7 @@ QString HMDToolsDialog::getDebugDetails() const { results += "Desktop's Primary Screen: " + desktopPrimaryScreen->name() + "\n"; results += "Application Primary Screen: " + QGuiApplication::primaryScreen()->name() + "\n"; - QScreen* mainWindowScreen = Application::getInstance()->getWindow()->windowHandle()->screen(); + QScreen* mainWindowScreen = qApp->getWindow()->windowHandle()->screen(); results += "Application Main Window Screen: " + mainWindowScreen->name() + "\n"; results += "Total Screens: " + QString::number(QApplication::desktop()->screenCount()) + "\n"; @@ -159,15 +159,15 @@ void HMDToolsDialog::toggleHMDMode() { void HMDToolsDialog::enterHMDMode() { if (!qApp->isHMDMode()) { - Application::getInstance()->setActiveDisplayPlugin(_hmdPluginName); - Application::getInstance()->getWindow()->activateWindow(); + qApp->setActiveDisplayPlugin(_hmdPluginName); + qApp->getWindow()->activateWindow(); } } void HMDToolsDialog::leaveHMDMode() { if (qApp->isHMDMode()) { - Application::getInstance()->setActiveDisplayPlugin(_defaultPluginName); - Application::getInstance()->getWindow()->activateWindow(); + qApp->setActiveDisplayPlugin(_defaultPluginName); + qApp->getWindow()->activateWindow(); } } @@ -200,7 +200,7 @@ void HMDToolsDialog::showEvent(QShowEvent* event) { void HMDToolsDialog::hideEvent(QHideEvent* event) { // center the cursor on the main application window - centerCursorOnWidget(Application::getInstance()->getWindow()); + centerCursorOnWidget(qApp->getWindow()); } void HMDToolsDialog::screenCountChanged(int newCount) { @@ -275,7 +275,7 @@ void HMDWindowWatcher::windowScreenChanged(QScreen* screen) { QScreen* betterScreen = NULL; QScreen* lastApplicationScreen = _hmdTools->getLastApplicationScreen(); - QWindow* appWindow = Application::getInstance()->getWindow()->windowHandle(); + QWindow* appWindow = qApp->getWindow()->windowHandle(); QScreen* appScreen = appWindow->screen(); if (_previousScreen && _previousScreen != hmdScreen) { diff --git a/interface/src/ui/JSConsole.cpp b/interface/src/ui/JSConsole.cpp index 74585df855..6e5b22399d 100644 --- a/interface/src/ui/JSConsole.cpp +++ b/interface/src/ui/JSConsole.cpp @@ -53,7 +53,7 @@ JSConsole::JSConsole(QWidget* parent, ScriptEngine* scriptEngine) : if (_scriptEngine == NULL) { - _scriptEngine = Application::getInstance()->loadScript(QString(), false); + _scriptEngine = qApp->loadScript(QString(), false); } connect(_scriptEngine, SIGNAL(evaluationFinished(QScriptValue, bool)), diff --git a/interface/src/ui/MarketplaceDialog.cpp b/interface/src/ui/MarketplaceDialog.cpp index b9c640054c..11286e0ee1 100644 --- a/interface/src/ui/MarketplaceDialog.cpp +++ b/interface/src/ui/MarketplaceDialog.cpp @@ -20,8 +20,8 @@ MarketplaceDialog::MarketplaceDialog(QQuickItem* parent) : OffscreenQmlDialog(pa bool MarketplaceDialog::navigationRequested(const QString& url) { qDebug() << url; - if (Application::getInstance()->canAcceptURL(url)) { - if (Application::getInstance()->acceptURL(url)) { + if (qApp->canAcceptURL(url)) { + if (qApp->acceptURL(url)) { return false; // we handled it, so QWebPage doesn't need to handle it } } diff --git a/interface/src/ui/OctreeStatsDialog.cpp b/interface/src/ui/OctreeStatsDialog.cpp index c2d72de9d6..d3ff017633 100644 --- a/interface/src/ui/OctreeStatsDialog.cpp +++ b/interface/src/ui/OctreeStatsDialog.cpp @@ -129,7 +129,7 @@ OctreeStatsDialog::~OctreeStatsDialog() { void OctreeStatsDialog::paintEvent(QPaintEvent* event) { // Processed Entities Related stats - auto entities = Application::getInstance()->getEntities(); + auto entities = qApp->getEntities(); auto entitiesTree = entities->getTree(); // Do this ever paint event... even if we don't update @@ -196,7 +196,7 @@ void OctreeStatsDialog::paintEvent(QPaintEvent* event) { unsigned long totalInternal = 0; unsigned long totalLeaves = 0; - NodeToOctreeSceneStats* sceneStats = Application::getInstance()->getOcteeSceneStats(); + NodeToOctreeSceneStats* sceneStats = qApp->getOcteeSceneStats(); sceneStats->withReadLock([&] { for (NodeToOctreeSceneStatsIterator i = sceneStats->begin(); i != sceneStats->end(); i++) { //const QUuid& uuid = i->first; @@ -264,7 +264,7 @@ void OctreeStatsDialog::paintEvent(QPaintEvent* event) { QString averageReadBitstreamPerPacketString = locale.toString(averageReadBitstreamPerPacket); label = _labels[_processedPackets]; - const OctreePacketProcessor& entitiesPacketProcessor = Application::getInstance()->getOctreePacketProcessor(); + const OctreePacketProcessor& entitiesPacketProcessor = qApp->getOctreePacketProcessor(); auto incomingPPS = entitiesPacketProcessor.getIncomingPPS(); auto processedPPS = entitiesPacketProcessor.getProcessedPPS(); @@ -351,7 +351,7 @@ void OctreeStatsDialog::showAllOctreeServers() { int serverCount = 0; showOctreeServersOfType(serverCount, NodeType::EntityServer, "Entity", - Application::getInstance()->getEntityServerJurisdictions()); + qApp->getEntityServerJurisdictions()); if (_octreeServerLabelsCount > serverCount) { for (int i = serverCount; i < _octreeServerLabelsCount; i++) { @@ -427,7 +427,7 @@ void OctreeStatsDialog::showOctreeServersOfType(int& serverCount, NodeType_t ser // now lookup stats details for this server... if (_extraServerDetails[serverCount-1] != LESS) { - NodeToOctreeSceneStats* sceneStats = Application::getInstance()->getOcteeSceneStats(); + NodeToOctreeSceneStats* sceneStats = qApp->getOcteeSceneStats(); sceneStats->withReadLock([&] { if (sceneStats->find(nodeUUID) != sceneStats->end()) { OctreeSceneStats& stats = sceneStats->at(nodeUUID); diff --git a/interface/src/ui/PreferencesDialog.cpp b/interface/src/ui/PreferencesDialog.cpp index 81e4d61b5e..1b55c6fa2b 100644 --- a/interface/src/ui/PreferencesDialog.cpp +++ b/interface/src/ui/PreferencesDialog.cpp @@ -45,14 +45,14 @@ PreferencesDialog::PreferencesDialog(QWidget* parent) : connect(ui.buttonBrowseLocation, &QPushButton::clicked, this, &PreferencesDialog::openSnapshotLocationBrowser); connect(ui.buttonBrowseScriptsLocation, &QPushButton::clicked, this, &PreferencesDialog::openScriptsLocationBrowser); - connect(ui.buttonReloadDefaultScripts, &QPushButton::clicked, Application::getInstance(), &Application::loadDefaultScripts); + connect(ui.buttonReloadDefaultScripts, &QPushButton::clicked, qApp, &Application::loadDefaultScripts); connect(ui.buttonChangeAppearance, &QPushButton::clicked, this, &PreferencesDialog::openFullAvatarModelBrowser); connect(ui.appearanceDescription, &QLineEdit::textChanged, this, [this](const QString& url) { DependencyManager::get()->getMyAvatar()->useFullAvatarURL(url, ""); this->fullAvatarURLChanged(url, ""); }); - connect(Application::getInstance(), &Application::fullAvatarURLChanged, this, &PreferencesDialog::fullAvatarURLChanged); + connect(qApp, &Application::fullAvatarURLChanged, this, &PreferencesDialog::fullAvatarURLChanged); // move dialog to left side move(parentWidget()->geometry().topLeft()); @@ -298,7 +298,7 @@ void PreferencesDialog::savePreferences() { audio->setOutputStarveDetectionThreshold(ui.outputStarveDetectionThresholdSpinner->value()); audio->setOutputStarveDetectionPeriod(ui.outputStarveDetectionPeriodSpinner->value()); - Application::getInstance()->resizeGL(); + qApp->resizeGL(); // LOD items auto lodManager = DependencyManager::get(); diff --git a/interface/src/ui/RunningScriptsWidget.cpp b/interface/src/ui/RunningScriptsWidget.cpp index 61b03bd610..3752ea2176 100644 --- a/interface/src/ui/RunningScriptsWidget.cpp +++ b/interface/src/ui/RunningScriptsWidget.cpp @@ -57,15 +57,15 @@ RunningScriptsWidget::RunningScriptsWidget(QWidget* parent) : connect(ui->filterLineEdit, &QLineEdit::textChanged, this, &RunningScriptsWidget::updateFileFilter); connect(ui->scriptTreeView, &QTreeView::doubleClicked, this, &RunningScriptsWidget::loadScriptFromList); - connect(ui->reloadAllButton, &QPushButton::clicked, Application::getInstance(), &Application::reloadAllScripts); + connect(ui->reloadAllButton, &QPushButton::clicked, qApp, &Application::reloadAllScripts); connect(ui->stopAllButton, &QPushButton::clicked, this, &RunningScriptsWidget::allScriptsStopped); - connect(ui->loadScriptFromDiskButton, &QPushButton::clicked, Application::getInstance(), &Application::loadDialog); - connect(ui->loadScriptFromURLButton, &QPushButton::clicked, Application::getInstance(), &Application::loadScriptURLDialog); + connect(ui->loadScriptFromDiskButton, &QPushButton::clicked, qApp, &Application::loadDialog); + connect(ui->loadScriptFromURLButton, &QPushButton::clicked, qApp, &Application::loadScriptURLDialog); connect(&_reloadSignalMapper, static_cast(&QSignalMapper::mapped), - Application::getInstance(), &Application::reloadOneScript); + qApp, &Application::reloadOneScript); connect(&_stopSignalMapper, static_cast(&QSignalMapper::mapped), - [](const QString& script) { Application::getInstance()->stopScript(script); }); + [](const QString& script) { qApp->stopScript(script); }); UIUtil::scaleWidgetFontSizes(this); } @@ -83,7 +83,7 @@ void RunningScriptsWidget::updateFileFilter(const QString& filter) { void RunningScriptsWidget::loadScriptFromList(const QModelIndex& index) { QVariant scriptFile = _scriptsModelFilter.data(index, ScriptsModel::ScriptPath); - Application::getInstance()->loadScript(scriptFile.toString()); + qApp->loadScript(scriptFile.toString()); } void RunningScriptsWidget::loadSelectedScript() { @@ -172,7 +172,7 @@ void RunningScriptsWidget::showEvent(QShowEvent* event) { ui->filterLineEdit->setFocus(); } - QRect parentGeometry = Application::getInstance()->getDesirableApplicationGeometry(); + QRect parentGeometry = qApp->getDesirableApplicationGeometry(); int titleBarHeight = UIUtil::getWindowTitleBarHeight(this); int topMargin = titleBarHeight; @@ -217,13 +217,13 @@ void RunningScriptsWidget::keyPressEvent(QKeyEvent *keyEvent) { } void RunningScriptsWidget::allScriptsStopped() { - Application::getInstance()->stopAllScripts(); + qApp->stopAllScripts(); } QVariantList RunningScriptsWidget::getRunning() { const int WINDOWS_DRIVE_LETTER_SIZE = 1; QVariantList result; - foreach(const QString& runningScript, Application::getInstance()->getRunningScripts()) { + foreach(const QString& runningScript, qApp->getRunningScripts()) { QUrl runningScriptURL = QUrl(runningScript); if (runningScriptURL.scheme().size() <= WINDOWS_DRIVE_LETTER_SIZE) { runningScriptURL = QUrl::fromLocalFile(runningScriptURL.toDisplayString(QUrl::FormattingOptions(QUrl::FullyEncoded))); @@ -245,7 +245,7 @@ QVariantList RunningScriptsWidget::getPublic() { QVariantList RunningScriptsWidget::getPublicChildNodes(TreeNodeFolder* parent) { QVariantList result; - QList treeNodes = Application::getInstance()->getRunningScriptsWidget()->getScriptsModel() + QList treeNodes = qApp->getRunningScriptsWidget()->getScriptsModel() ->getFolderNodes(parent); for (int i = 0; i < treeNodes.size(); i++) { TreeNodeBase* node = treeNodes.at(i); @@ -273,7 +273,7 @@ QVariantList RunningScriptsWidget::getPublicChildNodes(TreeNodeFolder* parent) { QVariantList RunningScriptsWidget::getLocal() { QVariantList result; - QList treeNodes = Application::getInstance()->getRunningScriptsWidget()->getScriptsModel() + QList treeNodes = qApp->getRunningScriptsWidget()->getScriptsModel() ->getFolderNodes(NULL); for (int i = 0; i < treeNodes.size(); i++) { TreeNodeBase* node = treeNodes.at(i); @@ -293,14 +293,14 @@ QVariantList RunningScriptsWidget::getLocal() { } bool RunningScriptsWidget::stopScriptByName(const QString& name) { - foreach (const QString& runningScript, Application::getInstance()->getRunningScripts()) { + foreach (const QString& runningScript, qApp->getRunningScripts()) { if (QUrl(runningScript).fileName().toLower() == name.trimmed().toLower()) { - return Application::getInstance()->stopScript(runningScript, false); + return qApp->stopScript(runningScript, false); } } return false; } bool RunningScriptsWidget::stopScript(const QString& name, bool restart) { - return Application::getInstance()->stopScript(name, restart); + return qApp->stopScript(name, restart); } diff --git a/interface/src/ui/ScriptEditorWidget.cpp b/interface/src/ui/ScriptEditorWidget.cpp index fa829d4ace..76327804b6 100644 --- a/interface/src/ui/ScriptEditorWidget.cpp +++ b/interface/src/ui/ScriptEditorWidget.cpp @@ -98,7 +98,7 @@ bool ScriptEditorWidget::setRunning(bool run) { if (run) { const QString& scriptURLString = QUrl(_currentScript).toString(); // Reload script so that an out of date copy is not retrieved from the cache - _scriptEngine = Application::getInstance()->loadScript(scriptURLString, true, true, false, true); + _scriptEngine = qApp->loadScript(scriptURLString, true, true, false, true); connect(_scriptEngine, &ScriptEngine::runningStateChanged, this, &ScriptEditorWidget::runningStateChanged); connect(_scriptEngine, &ScriptEngine::errorMessage, this, &ScriptEditorWidget::onScriptError); connect(_scriptEngine, &ScriptEngine::printedMessage, this, &ScriptEditorWidget::onScriptPrint); @@ -106,7 +106,7 @@ bool ScriptEditorWidget::setRunning(bool run) { connect(_scriptEngine, &ScriptEngine::finished, this, &ScriptEditorWidget::onScriptFinished); } else { connect(_scriptEngine, &ScriptEngine::finished, this, &ScriptEditorWidget::onScriptFinished); - Application::getInstance()->stopScript(_currentScript); + qApp->stopScript(_currentScript); _scriptEngine = NULL; } return true; @@ -170,7 +170,7 @@ void ScriptEditorWidget::loadFile(const QString& scriptPath) { } const QString& scriptURLString = QUrl(_currentScript).toString(); - _scriptEngine = Application::getInstance()->getScriptEngine(scriptURLString); + _scriptEngine = qApp->getScriptEngine(scriptURLString); if (_scriptEngine != NULL) { connect(_scriptEngine, &ScriptEngine::runningStateChanged, this, &ScriptEditorWidget::runningStateChanged); connect(_scriptEngine, &ScriptEngine::errorMessage, this, &ScriptEditorWidget::onScriptError); @@ -186,10 +186,10 @@ bool ScriptEditorWidget::save() { bool ScriptEditorWidget::saveAs() { QString fileName = QFileDialog::getSaveFileName(this, tr("Save script"), - Application::getInstance()->getPreviousScriptLocation(), + qApp->getPreviousScriptLocation(), tr("JavaScript Files (*.js)")); if (!fileName.isEmpty()) { - Application::getInstance()->setPreviousScriptLocation(fileName); + qApp->setPreviousScriptLocation(fileName); return saveFile(fileName); } else { return false; diff --git a/interface/src/ui/ScriptEditorWindow.cpp b/interface/src/ui/ScriptEditorWindow.cpp index 41d172cf48..b5c8500083 100644 --- a/interface/src/ui/ScriptEditorWindow.cpp +++ b/interface/src/ui/ScriptEditorWindow.cpp @@ -90,10 +90,10 @@ void ScriptEditorWindow::loadScriptMenu(const QString& scriptName) { void ScriptEditorWindow::loadScriptClicked() { QString scriptName = QFileDialog::getOpenFileName(this, tr("Interface"), - Application::getInstance()->getPreviousScriptLocation(), + qApp->getPreviousScriptLocation(), tr("JavaScript Files (*.js)")); if (!scriptName.isEmpty()) { - Application::getInstance()->setPreviousScriptLocation(scriptName); + qApp->setPreviousScriptLocation(scriptName); addScriptEditorWidget("loading...")->loadFile(scriptName); updateButtons(); } @@ -101,7 +101,7 @@ void ScriptEditorWindow::loadScriptClicked() { void ScriptEditorWindow::loadMenuAboutToShow() { _loadMenu->clear(); - QStringList runningScripts = Application::getInstance()->getRunningScripts(); + QStringList runningScripts = qApp->getRunningScripts(); if (runningScripts.count() > 0) { QSignalMapper* signalMapper = new QSignalMapper(this); foreach (const QString& runningScript, runningScripts) { diff --git a/interface/src/ui/Stats.cpp b/interface/src/ui/Stats.cpp index 831664e3e6..f4ff2feb02 100644 --- a/interface/src/ui/Stats.cpp +++ b/interface/src/ui/Stats.cpp @@ -115,7 +115,7 @@ void Stats::updateStats(bool force) { STAT_UPDATE(avatarCount, avatarManager->size() - 1); STAT_UPDATE(serverCount, nodeList->size()); STAT_UPDATE(framerate, (int)qApp->getFps()); - STAT_UPDATE(simrate, (int)Application::getInstance()->getAverageSimsPerSecond()); + STAT_UPDATE(simrate, (int)qApp->getAverageSimsPerSecond()); STAT_UPDATE(avatarSimrate, (int)qApp->getAvatarSimrate()); auto bandwidthRecorder = DependencyManager::get(); @@ -207,7 +207,7 @@ void Stats::updateStats(bool force) { unsigned long totalLeaves = 0; std::stringstream sendingModeStream(""); sendingModeStream << "["; - NodeToOctreeSceneStats* octreeServerSceneStats = Application::getInstance()->getOcteeSceneStats(); + NodeToOctreeSceneStats* octreeServerSceneStats = qApp->getOcteeSceneStats(); for (NodeToOctreeSceneStatsIterator i = octreeServerSceneStats->begin(); i != octreeServerSceneStats->end(); i++) { //const QUuid& uuid = i->first; OctreeSceneStats& stats = i->second; diff --git a/interface/src/ui/ToolWindow.cpp b/interface/src/ui/ToolWindow.cpp index 4edae4f2a4..95dd522415 100644 --- a/interface/src/ui/ToolWindow.cpp +++ b/interface/src/ui/ToolWindow.cpp @@ -25,7 +25,7 @@ ToolWindow::ToolWindow(QWidget* parent) : # ifndef Q_OS_LINUX setDockOptions(QMainWindow::ForceTabbedDocks); # endif - Application::getInstance()->installEventFilter(this); + qApp->installEventFilter(this); } bool ToolWindow::event(QEvent* event) { @@ -34,7 +34,7 @@ bool ToolWindow::event(QEvent* event) { if (!_hasShown) { _hasShown = true; - QMainWindow* mainWindow = Application::getInstance()->getWindow(); + QMainWindow* mainWindow = qApp->getWindow(); QRect mainGeometry = mainWindow->geometry(); int titleBarHeight = UIUtil::getWindowTitleBarHeight(this); @@ -57,7 +57,7 @@ bool ToolWindow::eventFilter(QObject* sender, QEvent* event) { # ifndef Q_OS_LINUX switch (event->type()) { case QEvent::WindowStateChange: - if (Application::getInstance()->getWindow()->isMinimized()) { + if (qApp->getWindow()->isMinimized()) { // If we are already visible, we are self-hiding _selfHidden = isVisible(); setVisible(false); diff --git a/interface/src/ui/overlays/Billboardable.cpp b/interface/src/ui/overlays/Billboardable.cpp index c6edad501f..18e80c2b4f 100644 --- a/interface/src/ui/overlays/Billboardable.cpp +++ b/interface/src/ui/overlays/Billboardable.cpp @@ -30,7 +30,7 @@ QScriptValue Billboardable::getProperty(QScriptEngine* scriptEngine, const QStri void Billboardable::pointTransformAtCamera(Transform& transform, glm::quat offsetRotation) { if (isFacingAvatar()) { glm::vec3 billboardPos = transform.getTranslation(); - glm::vec3 cameraPos = Application::getInstance()->getCamera()->getPosition(); + glm::vec3 cameraPos = qApp->getCamera()->getPosition(); glm::vec3 look = cameraPos - billboardPos; float elevation = -asinf(look.y / glm::length(look)); float azimuth = atan2f(look.x, look.z); diff --git a/interface/src/ui/overlays/ModelOverlay.cpp b/interface/src/ui/overlays/ModelOverlay.cpp index b6422d86e0..b9cbde9f31 100644 --- a/interface/src/ui/overlays/ModelOverlay.cpp +++ b/interface/src/ui/overlays/ModelOverlay.cpp @@ -71,7 +71,7 @@ void ModelOverlay::render(RenderArgs* args) { // check to see if when we added our model to the scene they were ready, if they were not ready, then // fix them up in the scene - render::ScenePointer scene = Application::getInstance()->getMain3DScene(); + render::ScenePointer scene = qApp->getMain3DScene(); render::PendingChanges pendingChanges; if (_model.needsFixupInScene()) { _model.removeFromScene(scene, pendingChanges); diff --git a/interface/src/ui/overlays/Overlays.cpp b/interface/src/ui/overlays/Overlays.cpp index db3360cbbf..29e9d62542 100644 --- a/interface/src/ui/overlays/Overlays.cpp +++ b/interface/src/ui/overlays/Overlays.cpp @@ -76,7 +76,7 @@ void Overlays::update(float deltatime) { void Overlays::cleanupOverlaysToDelete() { if (!_overlaysToDelete.isEmpty()) { - render::ScenePointer scene = Application::getInstance()->getMain3DScene(); + render::ScenePointer scene = qApp->getMain3DScene(); render::PendingChanges pendingChanges; { @@ -169,7 +169,7 @@ unsigned int Overlays::addOverlay(const QString& type, const QScriptValue& prope } else if (type == Grid3DOverlay::TYPE) { thisOverlay = std::make_shared(); } else if (type == LocalModelsOverlay::TYPE) { - thisOverlay = std::make_shared(Application::getInstance()->getEntityClipboardRenderer()); + thisOverlay = std::make_shared(qApp->getEntityClipboardRenderer()); } else if (type == ModelOverlay::TYPE) { thisOverlay = std::make_shared(); } else if (type == Web3DOverlay::TYPE) { @@ -196,7 +196,7 @@ unsigned int Overlays::addOverlay(Overlay::Pointer overlay) { } else { _overlaysWorld[thisID] = overlay; - render::ScenePointer scene = Application::getInstance()->getMain3DScene(); + render::ScenePointer scene = qApp->getMain3DScene(); render::PendingChanges pendingChanges; overlay->addToScene(overlay, scene, pendingChanges); From 0f18db886c45e7f65bd953ee84b7a079c41ef80f Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Thu, 24 Sep 2015 17:19:50 +0200 Subject: [PATCH 02/33] Remove 4 Application static methods - Replace by lambda - Cleaned up global scope --- interface/src/Application.cpp | 8 ++++---- interface/src/Application.h | 4 ---- libraries/audio-client/src/AudioClient.h | 4 ++-- libraries/networking/src/AddressManager.h | 9 ++++----- 4 files changed, 10 insertions(+), 15 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 5b21f6bc39..88dae16ee2 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -432,8 +432,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : auto audioIO = DependencyManager::get(); - audioIO->setPositionGetter(getPositionForAudio); - audioIO->setOrientationGetter(getOrientationForAudio); + audioIO->setPositionGetter([]{ return qApp->_myAvatar->getPositionForAudio(); }); + audioIO->setOrientationGetter([]{ return qApp->_myAvatar->getOrientationForAudio(); }); audioIO->moveToThread(audioThread); @@ -524,8 +524,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : auto addressManager = DependencyManager::get(); // use our MyAvatar position and quat for address manager path - addressManager->setPositionGetter(getPositionForPath); - addressManager->setOrientationGetter(getOrientationForPath); + addressManager->setPositionGetter([]{ return qApp->_myAvatar->getPosition(); }); + addressManager->setOrientationGetter([]{ return qApp->_myAvatar->getOrientation(); }); connect(addressManager.data(), &AddressManager::hostChanged, this, &Application::updateWindowTitle); connect(this, &QCoreApplication::aboutToQuit, addressManager.data(), &AddressManager::storeCurrentAddress); diff --git a/interface/src/Application.h b/interface/src/Application.h index 883f2dd30e..799ec30471 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -139,10 +139,6 @@ class Application : public QApplication, public AbstractViewStateInterface, publ friend class DatagramProcessor; public: - static const glm::vec3& getPositionForPath() { return qApp->_myAvatar->getPosition(); } - static glm::quat getOrientationForPath() { return qApp->_myAvatar->getOrientation(); } - static glm::vec3 getPositionForAudio() { return qApp->_myAvatar->getPositionForAudio(); } - static glm::quat getOrientationForAudio() { return qApp->_myAvatar->getOrientationForAudio(); } static void initPlugins(); static void shutdownPlugins(); diff --git a/libraries/audio-client/src/AudioClient.h b/libraries/audio-client/src/AudioClient.h index 1ef56649fa..e699ee9266 100644 --- a/libraries/audio-client/src/AudioClient.h +++ b/libraries/audio-client/src/AudioClient.h @@ -76,8 +76,6 @@ class QIODevice; typedef struct ty_gverb ty_gverb; -typedef glm::vec3 (*AudioPositionGetter)(); -typedef glm::quat (*AudioOrientationGetter)(); class NLPacket; @@ -85,6 +83,8 @@ class AudioClient : public AbstractAudioInterface, public Dependency { Q_OBJECT SINGLETON_DEPENDENCY public: + using AudioPositionGetter = std::function; + using AudioOrientationGetter = std::function; class AudioOutputIODevice : public QIODevice { public: diff --git a/libraries/networking/src/AddressManager.h b/libraries/networking/src/AddressManager.h index fbb895795b..e0b54e4072 100644 --- a/libraries/networking/src/AddressManager.h +++ b/libraries/networking/src/AddressManager.h @@ -28,9 +28,6 @@ const QString INDEX_PATH = "/"; const QString GET_PLACE = "/api/v1/places/%1"; -typedef const glm::vec3& (*PositionGetter)(); -typedef glm::quat (*OrientationGetter)(); - class AddressManager : public QObject, public Dependency { Q_OBJECT SINGLETON_DEPENDENCY @@ -40,6 +37,8 @@ class AddressManager : public QObject, public Dependency { Q_PROPERTY(QString hostname READ getHost) Q_PROPERTY(QString pathname READ currentPath) public: + using PositionGetter = std::function; + using OrientationGetter = std::function; enum LookupTrigger { UserInput, @@ -130,8 +129,8 @@ private: QString _host; quint16 _port; QUuid _rootPlaceID; - PositionGetter _positionGetter { nullptr }; - OrientationGetter _orientationGetter { nullptr }; + PositionGetter _positionGetter; + OrientationGetter _orientationGetter; QStack _backStack; QStack _forwardStack; From 92e974929c8bd2c73e7ef70930e26a56b8b15970 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Thu, 24 Sep 2015 17:26:55 +0200 Subject: [PATCH 03/33] Move tray icon to MainWindow --- interface/src/Application.cpp | 4 ---- interface/src/Application.h | 4 ---- interface/src/MainWindow.cpp | 1 + interface/src/MainWindow.h | 2 ++ 4 files changed, 3 insertions(+), 8 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 88dae16ee2..40104f8fbf 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -36,7 +36,6 @@ #include #include #include -#include #include #include #include @@ -357,7 +356,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : _octreeProcessor(), _runningScriptsWidget(NULL), _runningScriptsWidgetWasVisible(false), - _trayIcon(new QSystemTrayIcon(_window)), _lastNackTime(usecTimestampNow()), _lastSendDownstreamAudioStats(usecTimestampNow()), _isThrottleFPSEnabled(true), @@ -664,8 +662,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : cameraMenuChanged(); } - _trayIcon->show(); - // set the local loopback interface for local sounds from audio scripts AudioScriptingInterface::getInstance().setLocalAudioInterface(audioIO.data()); diff --git a/interface/src/Application.h b/interface/src/Application.h index 799ec30471..a3a34f3cea 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -77,7 +77,6 @@ class QGLWidget; class QKeyEvent; class QMouseEvent; -class QSystemTrayIcon; class QTouchEvent; class QWheelEvent; class OffscreenGlCanvas; @@ -233,7 +232,6 @@ public: FaceTracker* getActiveFaceTracker(); FaceTracker* getSelectedFaceTracker(); - QSystemTrayIcon* getTrayIcon() { return _trayIcon; } ApplicationOverlay& getApplicationOverlay() { return _applicationOverlay; } const ApplicationOverlay& getApplicationOverlay() const { return _applicationOverlay; } ApplicationCompositor& getApplicationCompositor() { return _compositor; } @@ -621,8 +619,6 @@ private: bool _runningScriptsWidgetWasVisible; QString _scriptsLocation; - QSystemTrayIcon* _trayIcon; - quint64 _lastNackTime; quint64 _lastSendDownstreamAudioStats; diff --git a/interface/src/MainWindow.cpp b/interface/src/MainWindow.cpp index 16aedc4bb7..34e1638e94 100644 --- a/interface/src/MainWindow.cpp +++ b/interface/src/MainWindow.cpp @@ -31,6 +31,7 @@ MainWindow::MainWindow(QWidget* parent) : _windowState("WindowState", 0) { setAcceptDrops(true); + _trayIcon.show(); } void MainWindow::restoreGeometry() { diff --git a/interface/src/MainWindow.h b/interface/src/MainWindow.h index eb262e0f97..6a401cf2b7 100644 --- a/interface/src/MainWindow.h +++ b/interface/src/MainWindow.h @@ -13,6 +13,7 @@ #define __hifi__MainWindow__ #include +#include #include @@ -42,6 +43,7 @@ protected: private: Setting::Handle _windowGeometry; Setting::Handle _windowState; + QSystemTrayIcon _trayIcon; }; #endif /* defined(__hifi__MainWindow__) */ From 0aab013a0e0101f2003782a23c9e0a051fae6cbf Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Thu, 24 Sep 2015 17:55:34 +0200 Subject: [PATCH 04/33] Remove unused members --- interface/src/Application.cpp | 9 +-------- interface/src/Application.h | 7 ------- interface/src/GLCanvas.cpp | 1 - 3 files changed, 1 insertion(+), 16 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 40104f8fbf..ef179c65f3 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -327,7 +327,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : _window(new MainWindow(desktop())), _toolWindow(NULL), _friendsWindow(NULL), - _undoStack(), _undoStackScriptingInterface(&_undoStack), _frameCount(0), _fps(60.0f), @@ -336,8 +335,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : _entities(true, this, this), _entityClipboardRenderer(false, this, this), _entityClipboard(new EntityTree()), - _viewFrustum(), - _lastQueriedViewFrustum(), _lastQueriedTime(usecTimestampNow()), _mirrorViewRect(QRect(MIRROR_VIEW_LEFT_PADDING, MIRROR_VIEW_TOP_PADDING, MIRROR_VIEW_WIDTH, MIRROR_VIEW_HEIGHT)), _firstRun("firstRun", true), @@ -353,7 +350,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : _isTouchPressed(false), _mousePressed(false), _enableProcessOctreeThread(true), - _octreeProcessor(), _runningScriptsWidget(NULL), _runningScriptsWidgetWasVisible(false), _lastNackTime(usecTimestampNow()), @@ -361,10 +357,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : _isThrottleFPSEnabled(true), _aboutToQuit(false), _notifiedPacketVersionMismatchThisDomain(false), - _domainConnectionRefusals(QList()), _maxOctreePPS(maxOctreePacketsPerSecond.get()), - _lastFaceTrackerUpdate(0), - _applicationOverlay() + _lastFaceTrackerUpdate(0) { thread()->setObjectName("Main Thread"); @@ -1342,7 +1336,6 @@ void Application::resizeGL() { uvec2 framebufferSize = getActiveDisplayPlugin()->getRecommendedRenderSize(); uvec2 renderSize = uvec2(vec2(framebufferSize) * getRenderResolutionScale()); if (_renderResolution != renderSize) { - _numFramesSinceLastResize = 0; _renderResolution = renderSize; DependencyManager::get()->setFrameBufferSize(fromGlm(renderSize)); diff --git a/interface/src/Application.h b/interface/src/Application.h index a3a34f3cea..0501b2c34d 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -518,8 +518,6 @@ private: QUndoStack _undoStack; UndoStackScriptingInterface _undoStackScriptingInterface; - glm::vec3 _gravity; - // Frame Rate Measurement int _frameCount; @@ -543,8 +541,6 @@ private: ViewFrustum _shadowViewFrustum; quint64 _lastQueriedTime; - float _trailingAudioLoudness; - OctreeQuery _octreeQuery; // NodeData derived class for querying octee cells from octree servers KeyboardMouseDevice* _keyboardMouseDevice{ nullptr }; // Default input device, the good old keyboard mouse and maybe touchpad @@ -659,10 +655,7 @@ private: int _oldHandMouseY[2]; bool _oldHandLeftClick[2]; bool _oldHandRightClick[2]; - int _numFramesSinceLastResize = 0; - bool _overlayEnabled = true; - QRect _savedGeometry; DialogsManagerScriptingInterface* _dialogsManagerScriptingInterface = new DialogsManagerScriptingInterface(); EntityItemID _keyboardFocusedItem; diff --git a/interface/src/GLCanvas.cpp b/interface/src/GLCanvas.cpp index 1988cdffbe..306e57cfa0 100644 --- a/interface/src/GLCanvas.cpp +++ b/interface/src/GLCanvas.cpp @@ -71,7 +71,6 @@ void GLCanvas::resizeGL(int width, int height) { qApp->resizeGL(); } -int updateTime = 0; bool GLCanvas::event(QEvent* event) { switch (event->type()) { case QEvent::MouseMove: From a5f31dba5f377540dabff1e17e7e9bf8acafbbf6 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Thu, 24 Sep 2015 17:56:11 +0200 Subject: [PATCH 05/33] Fix startup timer --- interface/src/Application.cpp | 14 ++++---------- interface/src/Application.h | 2 -- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index ef179c65f3..e0892a90eb 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -321,7 +321,7 @@ Cube3DOverlay* _keyboardFocusHighlight{ nullptr }; int _keyboardFocusHighlightID{ -1 }; PluginContainer* _pluginContainer; -Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : +Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : QApplication(argc, argv), _dependencyManagerIsSetup(setupEssentials(argc, argv)), _window(new MainWindow(desktop())), @@ -330,7 +330,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : _undoStackScriptingInterface(&_undoStack), _frameCount(0), _fps(60.0f), - _justStarted(true), _physicsEngine(new PhysicsEngine(Vectors::ZERO)), _entities(true, this, this), _entityClipboardRenderer(false, this, this), @@ -385,8 +384,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : _myAvatar = DependencyManager::get()->getMyAvatar(); - _applicationStartupTime = startup_time; - qCDebug(interfaceapp) << "[VERSION] Build sequence: " << qPrintable(applicationVersion()); _bookmarks = new Bookmarks(); // Before setting up the menu @@ -765,6 +762,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : }); connect(this, &Application::applicationStateChanged, this, &Application::activeChanged); + + + qCDebug(interfaceapp, "Startup time: %4.2f seconds.", (double)startupTimer.elapsed() / 1000.0f); } void Application::aboutToQuit() { @@ -959,12 +959,6 @@ void Application::initializeGL() { idleTimer->start(TARGET_SIM_FRAME_PERIOD_MS); _idleLoopStdev.reset(); - if (_justStarted) { - float startupTime = (float)_applicationStartupTime.elapsed() / 1000.0f; - _justStarted = false; - qCDebug(interfaceapp, "Startup time: %4.2f seconds.", (double)startupTime); - } - // update before the first render update(1.0f / _fps); diff --git a/interface/src/Application.h b/interface/src/Application.h index 0501b2c34d..c879dbf0ce 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -522,10 +522,8 @@ private: int _frameCount; float _fps; - QElapsedTimer _applicationStartupTime; QElapsedTimer _timerStart; QElapsedTimer _lastTimeUpdated; - bool _justStarted; ShapeManager _shapeManager; PhysicalEntitySimulation _entitySimulation; From e74df484cc197b4c74c8d24cd59d13458110bcd9 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Thu, 24 Sep 2015 18:12:27 +0200 Subject: [PATCH 06/33] Remove unused methods --- interface/src/Application.cpp | 19 ------------------- interface/src/Application.h | 5 ----- 2 files changed, 24 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index e0892a90eb..ef9b91e639 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -3766,25 +3766,6 @@ void Application::resetSensors() { QMetaObject::invokeMethod(DependencyManager::get().data(), "reset", Qt::QueuedConnection); } -static void setShortcutsEnabled(QWidget* widget, bool enabled) { - foreach (QAction* action, widget->actions()) { - QKeySequence shortcut = action->shortcut(); - if (!shortcut.isEmpty() && (shortcut[0] & (Qt::CTRL | Qt::ALT | Qt::META)) == 0) { - // it's a shortcut that may coincide with a "regular" key, so switch its context - action->setShortcutContext(enabled ? Qt::WindowShortcut : Qt::WidgetShortcut); - } - } - foreach (QObject* child, widget->children()) { - if (child->isWidgetType()) { - setShortcutsEnabled(static_cast(child), enabled); - } - } -} - -void Application::setMenuShortcutsEnabled(bool enabled) { - setShortcutsEnabled(_window->menuBar(), enabled); -} - void Application::updateWindowTitle(){ QString buildVersion = " (build " + applicationVersion() + ")"; diff --git a/interface/src/Application.h b/interface/src/Application.h index c879dbf0ce..176e2524e0 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -497,11 +497,6 @@ private: void renderRearViewMirror(RenderArgs* renderArgs, const QRect& region, bool billboard = false); - void setMenuShortcutsEnabled(bool enabled); - - static void attachNewHeadToNode(Node *newNode); - static void* networkReceive(void* args); // network receive thread - int sendNackPackets(); bool _dependencyManagerIsSetup; From 77a78148549f27448cf4dab496fbf72d52d6bf96 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Thu, 24 Sep 2015 18:48:26 +0200 Subject: [PATCH 07/33] Move sendPingPackets --- interface/src/Application.cpp | 54 ++++++-------------- interface/src/Application.h | 2 - libraries/networking/src/LimitedNodeList.cpp | 16 ++++++ libraries/networking/src/LimitedNodeList.h | 1 + 4 files changed, 34 insertions(+), 39 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index ef9b91e639..f5c87e1b96 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -163,22 +163,6 @@ extern "C" { } #endif -enum CustomEventTypes { - Lambda = QEvent::User + 1 -}; - -class LambdaEvent : public QEvent { - std::function _fun; -public: - LambdaEvent(const std::function & fun) : - QEvent(static_cast(Lambda)), _fun(fun) { - } - LambdaEvent(std::function && fun) : - QEvent(static_cast(Lambda)), _fun(fun) { - } - void call() { _fun(); } -}; - using namespace std; static QTimer* locationUpdateTimer = NULL; @@ -239,6 +223,22 @@ public: }; #endif +enum CustomEventTypes { + Lambda = QEvent::User + 1 +}; + +class LambdaEvent : public QEvent { + std::function _fun; +public: + LambdaEvent(const std::function & fun) : + QEvent(static_cast(Lambda)), _fun(fun) { + } + LambdaEvent(std::function && fun) : + QEvent(static_cast(Lambda)), _fun(fun) { + } + void call() { _fun(); } +}; + void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& message) { QString logMessage = LogHandler::getInstance().printMessage((LogMsgType) type, context, message); @@ -2090,29 +2090,10 @@ bool Application::acceptSnapshot(const QString& urlString) { return true; } -void Application::sendPingPackets() { - - auto nodeList = DependencyManager::get(); - - nodeList->eachMatchingNode([](const SharedNodePointer& node)->bool { - switch (node->getType()) { - case NodeType::AvatarMixer: - case NodeType::AudioMixer: - case NodeType::EntityServer: - case NodeType::AssetServer: - return true; - default: - return false; - } - }, [nodeList](const SharedNodePointer& node) { - nodeList->sendPacket(nodeList->constructPingPacket(), *node); - }); -} - // Every second, check the frame rates and other stuff void Application::checkFPS() { if (Menu::getInstance()->isOptionChecked(MenuOption::TestPing)) { - sendPingPackets(); + DependencyManager::get()->sendPingPackets(); } float diffTime = (float)_timerStart.nsecsElapsed() / 1000000000.0f; @@ -3804,7 +3785,6 @@ void Application::clearDomainOctreeDetails() { // reset the model renderer _entities.clear(); - } void Application::domainChanged(const QString& domainHostname) { diff --git a/interface/src/Application.h b/interface/src/Application.h index 176e2524e0..5ae8219b99 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -464,8 +464,6 @@ private slots: private: void resetCameras(Camera& camera, const glm::uvec2& size); - void sendPingPackets(); - void initDisplay(); void init(); diff --git a/libraries/networking/src/LimitedNodeList.cpp b/libraries/networking/src/LimitedNodeList.cpp index c13a82f821..630c4c79bf 100644 --- a/libraries/networking/src/LimitedNodeList.cpp +++ b/libraries/networking/src/LimitedNodeList.cpp @@ -661,6 +661,22 @@ void LimitedNodeList::sendSTUNRequest() { _nodeSocket.writeDatagram(stunRequestPacket, sizeof(stunRequestPacket), _stunSockAddr); } +void LimitedNodeList::sendPingPackets() { + eachMatchingNode([](const SharedNodePointer& node)->bool { + switch (node->getType()) { + case NodeType::AvatarMixer: + case NodeType::AudioMixer: + case NodeType::EntityServer: + case NodeType::AssetServer: + return true; + default: + return false; + } + }, [&](const SharedNodePointer& node) { + sendPacket(constructPingPacket(), *node); + }); +} + void LimitedNodeList::processSTUNResponse(std::unique_ptr packet) { // check the cookie to make sure this is actually a STUN response // and read the first attribute and make sure it is a XOR_MAPPED_ADDRESS diff --git a/libraries/networking/src/LimitedNodeList.h b/libraries/networking/src/LimitedNodeList.h index abf292e65e..40c5390c7e 100644 --- a/libraries/networking/src/LimitedNodeList.h +++ b/libraries/networking/src/LimitedNodeList.h @@ -230,6 +230,7 @@ public slots: void startSTUNPublicSocketUpdate(); virtual void sendSTUNRequest(); + void sendPingPackets(); void killNodeWithUUID(const QUuid& nodeUUID); From 7da55747f51537b7ae56e23c0fa422cdae3b596f Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Thu, 24 Sep 2015 19:21:04 +0200 Subject: [PATCH 08/33] Simplify friends window --- interface/src/Application.cpp | 20 +++++++++----------- interface/src/Application.h | 2 -- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index f5c87e1b96..9dc2a50d10 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -326,7 +326,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : _dependencyManagerIsSetup(setupEssentials(argc, argv)), _window(new MainWindow(desktop())), _toolWindow(NULL), - _friendsWindow(NULL), _undoStackScriptingInterface(&_undoStack), _frameCount(0), _fps(60.0f), @@ -4625,21 +4624,20 @@ void Application::activeChanged(Qt::ApplicationState state) { } } void Application::showFriendsWindow() { + const QString FRIENDS_WINDOW_OBJECT_NAME = "FriendsWindow"; const QString FRIENDS_WINDOW_TITLE = "Add/Remove Friends"; const QString FRIENDS_WINDOW_URL = "https://metaverse.highfidelity.com/user/friends"; const int FRIENDS_WINDOW_WIDTH = 290; const int FRIENDS_WINDOW_HEIGHT = 500; - if (!_friendsWindow) { - _friendsWindow = new WebWindowClass(FRIENDS_WINDOW_TITLE, FRIENDS_WINDOW_URL, FRIENDS_WINDOW_WIDTH, - FRIENDS_WINDOW_HEIGHT, false); - connect(_friendsWindow, &WebWindowClass::closed, this, &Application::friendsWindowClosed); + auto webWindowClass = _window->findChildren(FRIENDS_WINDOW_OBJECT_NAME); + if (webWindowClass.empty()) { + auto friendsWindow = new WebWindowClass(FRIENDS_WINDOW_TITLE, FRIENDS_WINDOW_URL, FRIENDS_WINDOW_WIDTH, + FRIENDS_WINDOW_HEIGHT, false); + friendsWindow->setParent(_window); + friendsWindow->setObjectName(FRIENDS_WINDOW_OBJECT_NAME); + connect(friendsWindow, &WebWindowClass::closed, &WebWindowClass::deleteLater); + friendsWindow->setVisible(true); } - _friendsWindow->setVisible(true); -} - -void Application::friendsWindowClosed() { - delete _friendsWindow; - _friendsWindow = NULL; } void Application::postLambdaEvent(std::function f) { diff --git a/interface/src/Application.h b/interface/src/Application.h index 5ae8219b99..9bb19dd6b7 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -393,7 +393,6 @@ public slots: void saveScripts(); void showFriendsWindow(); - void friendsWindowClosed(); void packageModel(); @@ -506,7 +505,6 @@ private: MainWindow* _window; ToolWindow* _toolWindow; - WebWindowClass* _friendsWindow; QUndoStack _undoStack; UndoStackScriptingInterface _undoStackScriptingInterface; From 765608d0fffabb6313897cafabb541d44d8d0d6c Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Thu, 24 Sep 2015 19:49:02 +0200 Subject: [PATCH 09/33] More unused --- interface/src/Application.cpp | 10 ---------- interface/src/Application.h | 17 +---------------- .../src/AbstractViewStateInterface.h | 3 +-- 3 files changed, 2 insertions(+), 28 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 9dc2a50d10..278c1fcddc 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2962,12 +2962,6 @@ void Application::update(float deltaTime) { _avatarUpdate->synchronousProcess(); - { - PerformanceTimer perfTimer("emitSimulating"); - // let external parties know we're updating - emit simulating(deltaTime); - } - // Update _viewFrustum with latest camera and view frustum data... // NOTE: we get this from the view frustum, to make it simpler, since the // loadViewFrumstum() method will get the correct details from the camera @@ -3316,10 +3310,6 @@ glm::vec3 Application::getSunDirection() { // FIXME, preprocessor guard this check to occur only in DEBUG builds static QThread * activeRenderingThread = nullptr; -bool Application::shouldRenderMesh(float largestDimension, float distanceToCamera) { - return DependencyManager::get()->shouldRenderMesh(largestDimension, distanceToCamera); -} - float Application::getSizeScale() const { return DependencyManager::get()->getOctreeSizeScale(); } diff --git a/interface/src/Application.h b/interface/src/Application.h index 9bb19dd6b7..d1db393cbc 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -252,10 +252,6 @@ public: virtual AbstractControllerScriptingInterface* getControllerScriptingInterface() { return &_controllerScriptingInterface; } virtual void registerScriptEngineWithApplicationServices(ScriptEngine* scriptEngine); - void resetProfile(const QString& username); - - virtual bool shouldRenderMesh(float largestDimension, float distanceToCamera); - QImage renderAvatarBillboard(RenderArgs* renderArgs); void displaySide(RenderArgs* renderArgs, Camera& whichCamera, bool selfAvatarOnly = false, bool billboard = false); @@ -319,10 +315,8 @@ public: int getMaxOctreePacketsPerSecond(); render::ScenePointer getMain3DScene() { return _main3DScene; } - render::EnginePointer getRenderEngine() { return _renderEngine; } - render::ScenePointer getMain3DScene() const { return _main3DScene; } - + render::EnginePointer getRenderEngine() { return _renderEngine; } gpu::ContextPointer getGPUContext() const { return _gpuContext; } const QRect& getMirrorViewRect() const { return _mirrorViewRect; } @@ -336,13 +330,6 @@ public: float getAverageSimsPerSecond(); signals: - - /// Fired when we're simulating; allows external parties to hook in. - void simulating(float deltaTime); - - /// Fired when the import window is closed - void importDone(); - void scriptLocationChanged(const QString& newPath); void svoImportRequested(const QString& url); @@ -350,8 +337,6 @@ signals: void checkBackgroundDownloads(); void domainConnectionRefused(const QString& reason); - void headURLChanged(const QString& newValue, const QString& modelName); - void bodyURLChanged(const QString& newValue, const QString& modelName); void fullAvatarURLChanged(const QString& newValue, const QString& modelName); void beforeAboutToQuit(); diff --git a/libraries/render-utils/src/AbstractViewStateInterface.h b/libraries/render-utils/src/AbstractViewStateInterface.h index a9cd7db20c..2b6c66b36a 100644 --- a/libraries/render-utils/src/AbstractViewStateInterface.h +++ b/libraries/render-utils/src/AbstractViewStateInterface.h @@ -44,8 +44,7 @@ public: virtual ViewFrustum* getShadowViewFrustum() = 0; virtual QThread* getMainThread() = 0; - - virtual bool shouldRenderMesh(float largestDimension, float distanceToCamera) = 0; + virtual float getSizeScale() const = 0; virtual int getBoundaryLevelAdjust() const = 0; virtual PickRay computePickRay(float x, float y) const = 0; From 311edabe51603754077ee5ece8bfa51b4837afbe Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Thu, 24 Sep 2015 20:05:09 +0200 Subject: [PATCH 10/33] More header cleanup --- interface/src/Application.cpp | 20 ++++++++++++++ interface/src/Application.h | 36 ++------------------------ interface/src/PluginContainerProxy.cpp | 4 +-- interface/src/avatar/Avatar.h | 3 +++ 4 files changed, 27 insertions(+), 36 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 278c1fcddc..de227cd934 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -172,6 +172,26 @@ static QTimer* billboardPacketTimer = NULL; static QTimer* checkFPStimer = NULL; static QTimer* idleTimer = NULL; +static const QString SNAPSHOT_EXTENSION = ".jpg"; +static const QString SVO_EXTENSION = ".svo"; +static const QString SVO_JSON_EXTENSION = ".svo.json"; +static const QString JS_EXTENSION = ".js"; +static const QString FST_EXTENSION = ".fst"; + +static const int MIRROR_VIEW_TOP_PADDING = 5; +static const int MIRROR_VIEW_LEFT_PADDING = 10; +static const int MIRROR_VIEW_WIDTH = 265; +static const int MIRROR_VIEW_HEIGHT = 215; +static const float MIRROR_FULLSCREEN_DISTANCE = 0.389f; +static const float MIRROR_REARVIEW_DISTANCE = 0.722f; +static const float MIRROR_REARVIEW_BODY_DISTANCE = 2.56f; +static const float MIRROR_FIELD_OF_VIEW = 30.0f; + +static const quint64 TOO_LONG_SINCE_LAST_SEND_DOWNSTREAM_AUDIO_STATS = 1 * USECS_PER_SECOND; + +static const QString INFO_HELP_PATH = "html/interface-welcome.html"; +static const QString INFO_EDIT_ENTITIES_PATH = "html/edit-commands.html"; + static const unsigned int TARGET_SIM_FRAMERATE = 60; static const unsigned int THROTTLED_SIM_FRAMERATE = 15; static const int TARGET_SIM_FRAME_PERIOD_MS = MSECS_PER_SECOND / TARGET_SIM_FRAMERATE; diff --git a/interface/src/Application.h b/interface/src/Application.h index d1db393cbc..71a678c6a2 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -74,48 +74,17 @@ #include "render/Engine.h" -class QGLWidget; -class QKeyEvent; -class QMouseEvent; -class QTouchEvent; -class QWheelEvent; class OffscreenGlCanvas; class GLCanvas; class FaceTracker; class MainWindow; -class Node; -class ScriptEngine; namespace gpu { class Context; typedef std::shared_ptr ContextPointer; } - -static const QString SNAPSHOT_EXTENSION = ".jpg"; -static const QString SVO_EXTENSION = ".svo"; -static const QString SVO_JSON_EXTENSION = ".svo.json"; -static const QString JS_EXTENSION = ".js"; -static const QString FST_EXTENSION = ".fst"; - -static const float BILLBOARD_FIELD_OF_VIEW = 30.0f; // degrees -static const float BILLBOARD_DISTANCE = 5.56f; // meters - -static const int MIRROR_VIEW_TOP_PADDING = 5; -static const int MIRROR_VIEW_LEFT_PADDING = 10; -static const int MIRROR_VIEW_WIDTH = 265; -static const int MIRROR_VIEW_HEIGHT = 215; -static const float MIRROR_FULLSCREEN_DISTANCE = 0.389f; -static const float MIRROR_REARVIEW_DISTANCE = 0.722f; -static const float MIRROR_REARVIEW_BODY_DISTANCE = 2.56f; -static const float MIRROR_FIELD_OF_VIEW = 30.0f; - -static const quint64 TOO_LONG_SINCE_LAST_SEND_DOWNSTREAM_AUDIO_STATS = 1 * USECS_PER_SECOND; - -static const QString INFO_HELP_PATH = "html/interface-welcome.html"; -static const QString INFO_EDIT_ENTITIES_PATH = "html/edit-commands.html"; - #ifdef Q_OS_WIN static const UINT UWM_IDENTIFY_INSTANCES = RegisterWindowMessage("UWM_IDENTIFY_INSTANCES_{8AB82783-B74A-4258-955B-8188C22AA0D6}_" + qgetenv("USERNAME")); @@ -129,8 +98,6 @@ class Application; #endif #define qApp (static_cast(QCoreApplication::instance())) -typedef bool (Application::* AcceptURLMethod)(const QString &); - class Application : public QApplication, public AbstractViewStateInterface, public AbstractScriptingServicesInterface { Q_OBJECT @@ -606,7 +573,8 @@ private: GLCanvas* _glWidget{ nullptr }; void checkSkeleton(); - + + typedef bool (Application::* AcceptURLMethod)(const QString &); QHash _acceptedExtensions; QList _domainConnectionRefusals; diff --git a/interface/src/PluginContainerProxy.cpp b/interface/src/PluginContainerProxy.cpp index 469e7f7c77..3310d9e4cd 100644 --- a/interface/src/PluginContainerProxy.cpp +++ b/interface/src/PluginContainerProxy.cpp @@ -78,7 +78,7 @@ void PluginContainerProxy::setIsOptionChecked(const QString& path, bool checked) // Additionally, setting fullscreen isn't hiding the menu on windows // make it useless for stereoscopic modes. void PluginContainerProxy::setFullscreen(const QScreen* target, bool hideMenu) { - auto _window = qApp->_window; + auto _window = qApp->getWindow(); if (!_window->isFullScreen()) { _savedGeometry = _window->geometry(); } @@ -101,7 +101,7 @@ void PluginContainerProxy::setFullscreen(const QScreen* target, bool hideMenu) { } void PluginContainerProxy::unsetFullscreen(const QScreen* avoid) { - auto _window = qApp->_window; + auto _window = qApp->getWindow(); _window->showNormal(); QRect targetGeometry = _savedGeometry; diff --git a/interface/src/avatar/Avatar.h b/interface/src/avatar/Avatar.h index 5ff3f37ef5..2515f260a1 100644 --- a/interface/src/avatar/Avatar.h +++ b/interface/src/avatar/Avatar.h @@ -37,6 +37,9 @@ static const float SCALING_RATIO = .05f; static const float SMOOTHING_RATIO = .05f; // 0 < ratio < 1 static const float RESCALING_TOLERANCE = .02f; +static const float BILLBOARD_FIELD_OF_VIEW = 30.0f; // degrees +static const float BILLBOARD_DISTANCE = 5.56f; // meters + extern const float CHAT_MESSAGE_SCALE; extern const float CHAT_MESSAGE_HEIGHT; From 38f23ef79eb3d5ed6987032588594ecfa264de3e Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Thu, 24 Sep 2015 21:01:34 +0200 Subject: [PATCH 11/33] Remove Application friend --- interface/src/Application.h | 12 ++++++------ interface/src/PluginContainerProxy.cpp | 2 +- interface/src/octree/OctreePacketProcessor.cpp | 9 ++++----- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/interface/src/Application.h b/interface/src/Application.h index 71a678c6a2..21a4a4429a 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -100,11 +100,13 @@ class Application; class Application : public QApplication, public AbstractViewStateInterface, public AbstractScriptingServicesInterface { Q_OBJECT - + + // TODO? Get rid of those friend class OctreePacketProcessor; - friend class DatagramProcessor; + friend class PluginContainerProxy; public: + // FIXME? Empty methods, do we still need them? static void initPlugins(); static void shutdownPlugins(); @@ -205,6 +207,8 @@ public: const ApplicationCompositor& getApplicationCompositor() const { return _compositor; } Overlays& getOverlays() { return _overlays; } + bool isForeground() const { return _isForeground; } + float getFps() const { return _fps; } float getFieldOfView() { return _fieldOfView.get(); } @@ -239,8 +243,6 @@ public: DisplayPlugin* getActiveDisplayPlugin(); const DisplayPlugin* getActiveDisplayPlugin() const; -public: - FileLogger* getLogger() { return _logger; } glm::vec2 getViewportDimensions() const; @@ -608,8 +610,6 @@ private: quint64 _lastSimsPerSecondUpdate = 0; bool _isForeground = true; // starts out assumed to be in foreground bool _inPaint = false; - - friend class PluginContainerProxy; }; #endif // hifi_Application_h diff --git a/interface/src/PluginContainerProxy.cpp b/interface/src/PluginContainerProxy.cpp index 3310d9e4cd..4126b7b9bd 100644 --- a/interface/src/PluginContainerProxy.cpp +++ b/interface/src/PluginContainerProxy.cpp @@ -17,7 +17,7 @@ PluginContainerProxy::PluginContainerProxy() { } bool PluginContainerProxy::isForeground() { - return qApp->_isForeground && !qApp->getWindow()->isMinimized(); + return qApp->isForeground() && !qApp->getWindow()->isMinimized(); } void PluginContainerProxy::addMenu(const QString& menuName) { diff --git a/interface/src/octree/OctreePacketProcessor.cpp b/interface/src/octree/OctreePacketProcessor.cpp index 8dfee8f73b..2fa0267dc6 100644 --- a/interface/src/octree/OctreePacketProcessor.cpp +++ b/interface/src/octree/OctreePacketProcessor.cpp @@ -37,7 +37,6 @@ void OctreePacketProcessor::processPacket(QSharedPointer packet, Share qDebug("OctreePacketProcessor::processPacket() packets to process=%d", packetsToProcessCount()); } - Application* app = qApp; bool wasStatsPacket = false; PacketType octreePacketType = packet->getType(); @@ -46,7 +45,7 @@ void OctreePacketProcessor::processPacket(QSharedPointer packet, Share // immediately following them inside the same packet. So, we process the PacketType_OCTREE_STATS first // then process any remaining bytes as if it was another packet if (octreePacketType == PacketType::OctreeStats) { - int statsMessageLength = app->processOctreeStats(*packet, sendingNode); + int statsMessageLength = qApp->processOctreeStats(*packet, sendingNode); wasStatsPacket = true; int piggybackBytes = packet->getPayloadSize() - statsMessageLength; @@ -84,7 +83,7 @@ void OctreePacketProcessor::processPacket(QSharedPointer packet, Share return; // bail since piggyback version doesn't match } - app->trackIncomingOctreePacket(*packet, sendingNode, wasStatsPacket); + qApp->trackIncomingOctreePacket(*packet, sendingNode, wasStatsPacket); // seek back to beginning of packet after tracking packet->seek(0); @@ -92,13 +91,13 @@ void OctreePacketProcessor::processPacket(QSharedPointer packet, Share switch(packetType) { case PacketType::EntityErase: { if (DependencyManager::get()->shouldRenderEntities()) { - app->_entities.processEraseMessage(*packet, sendingNode); + qApp->getEntities()->processEraseMessage(*packet, sendingNode); } } break; case PacketType::EntityData: { if (DependencyManager::get()->shouldRenderEntities()) { - app->_entities.processDatagram(*packet, sendingNode); + qApp->getEntities()->processDatagram(*packet, sendingNode); } } break; From f55f146d1be953558baa5f8ca23b560051870fc2 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Thu, 24 Sep 2015 21:24:10 +0200 Subject: [PATCH 12/33] More code cleanup --- interface/src/Application.h | 8 ++------ interface/src/ui/DialogsManager.cpp | 14 ++++++++++++++ interface/src/ui/DialogsManager.h | 16 +--------------- interface/src/ui/HMDToolsDialog.cpp | 7 ++++--- interface/src/ui/HMDToolsDialog.h | 1 + interface/src/ui/OverlayConductor.cpp | 7 ++++--- interface/src/ui/Stats.cpp | 1 + 7 files changed, 27 insertions(+), 27 deletions(-) diff --git a/interface/src/Application.h b/interface/src/Application.h index 21a4a4429a..c2c8606653 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -12,6 +12,8 @@ #ifndef hifi_Application_h #define hifi_Application_h +#include + #include #include #include @@ -19,24 +21,19 @@ #include #include #include -#include #include #include #include #include -#include #include -#include #include -#include #include #include #include #include #include #include -#include #include #include @@ -171,7 +168,6 @@ public: EntityTreeRenderer* getEntities() { return &_entities; } QUndoStack* getUndoStack() { return &_undoStack; } MainWindow* getWindow() { return _window; } - OctreeQuery& getOctreeQuery() { return _octreeQuery; } EntityTreePointer getEntityClipboard() { return _entityClipboard; } EntityTreeRenderer* getEntityClipboardRenderer() { return &_entityClipboardRenderer; } EntityEditPacketSender* getEntityEditPacketSender() { return &_entityEditSender; } diff --git a/interface/src/ui/DialogsManager.cpp b/interface/src/ui/DialogsManager.cpp index 308cfc9e8c..00bc95b5fa 100644 --- a/interface/src/ui/DialogsManager.cpp +++ b/interface/src/ui/DialogsManager.cpp @@ -14,6 +14,7 @@ #include #include +#include #include #include @@ -32,6 +33,19 @@ #include "ScriptEditorWindow.h" #include "UpdateDialog.h" +template +void DialogsManager::maybeCreateDialog(QPointer& member) { + if (!member) { + MainWindow* parent = qApp->getWindow(); + Q_CHECK_PTR(parent); + member = new T(parent); + Q_CHECK_PTR(member); + + if (_hmdToolsDialog && member->windowHandle()) { + _hmdToolsDialog->watchWindow(member->windowHandle()); + } + } +} void DialogsManager::toggleAddressBar() { AddressBarDialog::toggle(); diff --git a/interface/src/ui/DialogsManager.h b/interface/src/ui/DialogsManager.h index d54e91b9d6..133fe459d0 100644 --- a/interface/src/ui/DialogsManager.h +++ b/interface/src/ui/DialogsManager.h @@ -14,13 +14,10 @@ #include -#include #include #include "HMDToolsDialog.h" -class QAction; - class AnimationsDialog; class AttachmentsDialog; class AudioStatsDialog; @@ -78,18 +75,7 @@ private: DialogsManager() {} template - void maybeCreateDialog(QPointer& member) { - if (!member) { - MainWindow* parent = qApp->getWindow(); - Q_CHECK_PTR(parent); - member = new T(parent); - Q_CHECK_PTR(member); - - if (_hmdToolsDialog && member->windowHandle()) { - _hmdToolsDialog->watchWindow(member->windowHandle()); - } - } - } + void maybeCreateDialog(QPointer& member); QPointer _animationsDialog; QPointer _attachmentsDialog; diff --git a/interface/src/ui/HMDToolsDialog.cpp b/interface/src/ui/HMDToolsDialog.cpp index f37a4a9ba6..c1ea541864 100644 --- a/interface/src/ui/HMDToolsDialog.cpp +++ b/interface/src/ui/HMDToolsDialog.cpp @@ -9,11 +9,11 @@ // 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 @@ -22,6 +22,7 @@ #include #include +#include "Application.h" #include "MainWindow.h" #include "Menu.h" #include "ui/DialogsManager.h" diff --git a/interface/src/ui/HMDToolsDialog.h b/interface/src/ui/HMDToolsDialog.h index 11cab91673..7d30fc17f6 100644 --- a/interface/src/ui/HMDToolsDialog.h +++ b/interface/src/ui/HMDToolsDialog.h @@ -15,6 +15,7 @@ #include class HMDWindowWatcher; +class QLabel; class HMDToolsDialog : public QDialog { Q_OBJECT diff --git a/interface/src/ui/OverlayConductor.cpp b/interface/src/ui/OverlayConductor.cpp index 6e4d7e8248..f777e5d4dc 100644 --- a/interface/src/ui/OverlayConductor.cpp +++ b/interface/src/ui/OverlayConductor.cpp @@ -8,10 +8,11 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include "Application.h" -#include "InterfaceLogging.h" -#include "avatar/AvatarManager.h" +#include +#include "Application.h" +#include "avatar/AvatarManager.h" +#include "InterfaceLogging.h" #include "OverlayConductor.h" OverlayConductor::OverlayConductor() { diff --git a/interface/src/ui/Stats.cpp b/interface/src/ui/Stats.cpp index f4ff2feb02..fe5769c65c 100644 --- a/interface/src/ui/Stats.cpp +++ b/interface/src/ui/Stats.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include "BandwidthRecorder.h" From 34bba28775f354d171f131375fec492c8dddf0dd Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Thu, 24 Sep 2015 21:53:57 +0200 Subject: [PATCH 13/33] More header cleanup --- interface/src/Application.cpp | 7 ++++--- interface/src/Application.h | 24 +++++++----------------- interface/src/avatar/MyAvatar.cpp | 2 ++ interface/src/ui/AvatarInputs.cpp | 5 +++-- interface/src/ui/ScriptEditBox.cpp | 5 ++++- 5 files changed, 20 insertions(+), 23 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index de227cd934..8e7f2b6973 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -111,12 +111,16 @@ #include "LODManager.h" #include "Menu.h" #include "ModelPackager.h" +#include "Stars.h" #include "Util.h" #include "InterfaceLogging.h" #include "InterfaceActionFactory.h" +#include "PluginContainerProxy.h" +#include "AnimDebugDraw.h" #include "avatar/AvatarManager.h" #include "audio/AudioScope.h" + #include "devices/DdeFaceTracker.h" #include "devices/EyeTracker.h" #include "devices/Faceshift.h" @@ -152,9 +156,6 @@ #include "ui/UpdateDialog.h" #include "ui/overlays/Cube3DOverlay.h" -#include "PluginContainerProxy.h" -#include "AnimDebugDraw.h" - // ON WIndows PC, NVidia Optimus laptop, we want to enable NVIDIA GPU // FIXME seems to be broken. #if defined(Q_OS_WIN) diff --git a/interface/src/Application.h b/interface/src/Application.h index c2c8606653..e9eacf7e36 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -37,31 +37,27 @@ #include #include -#include "AudioClient.h" + #include "Bookmarks.h" #include "Camera.h" #include "Environment.h" #include "FileLogger.h" #include "Menu.h" #include "Physics.h" -#include "Stars.h" #include "avatar/AvatarUpdate.h" -#include "avatar/Avatar.h" #include "avatar/MyAvatar.h" #include "scripting/ControllerScriptingInterface.h" #include "scripting/DialogsManagerScriptingInterface.h" -#include "scripting/WebWindowClass.h" -#include "ui/AudioStatsDialog.h" -#include "ui/BandwidthDialog.h" -#include "ui/ModelsBrowser.h" -#include "ui/OctreeStatsDialog.h" #include "ui/SnapshotShareDialog.h" -#include "ui/LodToolsDialog.h" -#include "ui/LogDialog.h" -#include "ui/overlays/Overlays.h" #include "ui/ApplicationOverlay.h" #include "ui/ApplicationCompositor.h" +#include "ui/AudioStatsDialog.h" +#include "ui/BandwidthDialog.h" +#include "ui/LodToolsDialog.h" +#include "ui/LogDialog.h" +#include "ui/OctreeStatsDialog.h" #include "ui/OverlayConductor.h" +#include "ui/overlays/Overlays.h" #include "ui/RunningScriptsWidget.h" #include "ui/ToolWindow.h" #include "octree/OctreePacketProcessor.h" @@ -72,16 +68,10 @@ #include "render/Engine.h" class OffscreenGlCanvas; - class GLCanvas; class FaceTracker; class MainWindow; -namespace gpu { - class Context; - typedef std::shared_ptr ContextPointer; -} - #ifdef Q_OS_WIN static const UINT UWM_IDENTIFY_INSTANCES = RegisterWindowMessage("UWM_IDENTIFY_INSTANCES_{8AB82783-B74A-4258-955B-8188C22AA0D6}_" + qgetenv("USERNAME")); diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index ce5768de48..6ed2cf9ad0 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -37,6 +38,7 @@ #include "devices/Faceshift.h" + #include "Application.h" #include "AvatarManager.h" #include "Environment.h" diff --git a/interface/src/ui/AvatarInputs.cpp b/interface/src/ui/AvatarInputs.cpp index bc9181945f..a9827a23c2 100644 --- a/interface/src/ui/AvatarInputs.cpp +++ b/interface/src/ui/AvatarInputs.cpp @@ -7,13 +7,14 @@ // -#include "Application.h" #include "AvatarInputs.h" +#include #include -#include "Menu.h" +#include "Application.h" #include "devices/FaceTracker.h" +#include "Menu.h" HIFI_QML_DEF(AvatarInputs) diff --git a/interface/src/ui/ScriptEditBox.cpp b/interface/src/ui/ScriptEditBox.cpp index acabaa3c8f..2aea225b17 100644 --- a/interface/src/ui/ScriptEditBox.cpp +++ b/interface/src/ui/ScriptEditBox.cpp @@ -10,8 +10,11 @@ // #include "ScriptEditBox.h" + +#include +#include + #include "ScriptLineNumberArea.h" -#include "Application.h" ScriptEditBox::ScriptEditBox(QWidget* parent) : QPlainTextEdit(parent) From dde11c5cd1394fd934859de5aebe0bbac350cf6f Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Thu, 24 Sep 2015 22:38:49 +0200 Subject: [PATCH 14/33] More unused --- interface/src/Application.cpp | 5 ----- interface/src/Application.h | 9 --------- interface/src/scripting/WindowScriptingInterface.cpp | 4 ---- interface/src/scripting/WindowScriptingInterface.h | 2 -- interface/src/ui/ApplicationCompositor.cpp | 2 +- 5 files changed, 1 insertion(+), 21 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 8e7f2b6973..c6a8feb1a4 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -363,7 +363,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : _scaleMirror(1.0f), _rotateMirror(0.0f), _raiseMirror(0.0f), - _cursorVisible(true), _lastMouseMove(usecTimestampNow()), _lastMouseMoveWasSimulated(false), _isTouchPressed(false), @@ -2809,10 +2808,6 @@ void Application::updateCursor(float deltaTime) { lastMousePos = QCursor::pos(); } -void Application::setCursorVisible(bool visible) { - _cursorVisible = visible; -} - void Application::update(float deltaTime) { bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); PerformanceWarning warn(showWarnings, "Application::update()"); diff --git a/interface/src/Application.h b/interface/src/Application.h index e9eacf7e36..98aa4b3013 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -163,7 +163,6 @@ public: EntityEditPacketSender* getEntityEditPacketSender() { return &_entityEditSender; } bool isMousePressed() const { return _mousePressed; } - bool isMouseHidden() const { return !_cursorVisible; } const glm::vec3& getMouseRayOrigin() const { return _mouseRayOrigin; } const glm::vec3& getMouseRayDirection() const { return _mouseRayDirection; } bool mouseOnScreen() const; @@ -397,12 +396,9 @@ private slots: void audioMuteToggled(); void faceTrackerMuteToggled(); - void setCursorVisible(bool visible); void activeChanged(Qt::ApplicationState state); private: - void resetCameras(Camera& camera, const glm::uvec2& size); - void initDisplay(); void init(); @@ -423,10 +419,6 @@ private: void updateDialogs(float deltaTime); void updateCursor(float deltaTime); - Avatar* findLookatTargetAvatar(glm::vec3& eyePosition, QUuid &nodeUUID); - - void renderLookatIndicator(glm::vec3 pointOfInterest); - void queryOctree(NodeType_t serverType, PacketType packetType, NodeToJurisdictionMap& jurisdictions); void loadViewFrustum(Camera& camera, ViewFrustum& viewFrustum); @@ -497,7 +489,6 @@ private: Environment _environment; - bool _cursorVisible; ivec2 _mouseDragStarted; quint64 _lastMouseMove; diff --git a/interface/src/scripting/WindowScriptingInterface.cpp b/interface/src/scripting/WindowScriptingInterface.cpp index a5c7087adc..46edbe7420 100644 --- a/interface/src/scripting/WindowScriptingInterface.cpp +++ b/interface/src/scripting/WindowScriptingInterface.cpp @@ -65,10 +65,6 @@ void WindowScriptingInterface::setCursorVisible(bool visible) { Q_ARG(bool, visible)); } -bool WindowScriptingInterface::isCursorVisible() const { - return !qApp->isMouseHidden(); -} - void WindowScriptingInterface::setCursorPosition(int x, int y) { QCursor::setPos(x, y); } diff --git a/interface/src/scripting/WindowScriptingInterface.h b/interface/src/scripting/WindowScriptingInterface.h index 9bc8a834bd..678a66102d 100644 --- a/interface/src/scripting/WindowScriptingInterface.h +++ b/interface/src/scripting/WindowScriptingInterface.h @@ -27,14 +27,12 @@ class WindowScriptingInterface : public QObject, public Dependency { Q_PROPERTY(int innerHeight READ getInnerHeight) Q_PROPERTY(int x READ getX) Q_PROPERTY(int y READ getY) - Q_PROPERTY(bool cursorVisible READ isCursorVisible WRITE setCursorVisible) public: WindowScriptingInterface(); int getInnerWidth(); int getInnerHeight(); int getX(); int getY(); - bool isCursorVisible() const; public slots: QScriptValue getCursorPositionX(); diff --git a/interface/src/ui/ApplicationCompositor.cpp b/interface/src/ui/ApplicationCompositor.cpp index 98c2efc8f3..5e88a90d71 100644 --- a/interface/src/ui/ApplicationCompositor.cpp +++ b/interface/src/ui/ApplicationCompositor.cpp @@ -425,7 +425,7 @@ bool ApplicationCompositor::calculateRayUICollisionPoint(const glm::vec3& positi //Renders optional pointers void ApplicationCompositor::renderPointers(gpu::Batch& batch) { - if (qApp->isHMDMode() && !qApp->getLastMouseMoveWasSimulated() && !qApp->isMouseHidden()) { + if (qApp->isHMDMode() && !qApp->getLastMouseMoveWasSimulated()) { //If we are in oculus, render reticle later auto trueMouse = qApp->getTrueMouse(); trueMouse /= qApp->getCanvasSize(); From 4ccc2bbcd08be024a22efd602ecc658dde648cfb Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Thu, 24 Sep 2015 23:15:37 +0200 Subject: [PATCH 15/33] Enclose entire functions in ifdef --- interface/src/Application.cpp | 19 +++++-------------- interface/src/Application.h | 4 +++- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index c6a8feb1a4..6cd129af4d 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2304,8 +2304,8 @@ void Application::setActiveFaceTracker() { #endif } -void Application::setActiveEyeTracker() { #ifdef HAVE_IVIEWHMD +void Application::setActiveEyeTracker() { auto eyeTracker = DependencyManager::get(); if (!eyeTracker->isInitialized()) { return; @@ -2318,29 +2318,20 @@ void Application::setActiveEyeTracker() { Menu::getInstance()->getActionForOption(MenuOption::OnePointCalibration)->setEnabled(isEyeTracking && !isSimulating); Menu::getInstance()->getActionForOption(MenuOption::ThreePointCalibration)->setEnabled(isEyeTracking && !isSimulating); Menu::getInstance()->getActionForOption(MenuOption::FivePointCalibration)->setEnabled(isEyeTracking && !isSimulating); -#endif } void Application::calibrateEyeTracker1Point() { -#ifdef HAVE_IVIEWHMD - auto eyeTracker = DependencyManager::get(); - eyeTracker->calibrate(1); -#endif + DependencyManager::get()->calibrate(1); } void Application::calibrateEyeTracker3Points() { -#ifdef HAVE_IVIEWHMD - auto eyeTracker = DependencyManager::get(); - eyeTracker->calibrate(3); -#endif + DependencyManager::get()->calibrate(3); } void Application::calibrateEyeTracker5Points() { -#ifdef HAVE_IVIEWHMD - auto eyeTracker = DependencyManager::get(); - eyeTracker->calibrate(5); -#endif + DependencyManager::get()->calibrate(5); } +#endif bool Application::exportEntities(const QString& filename, const QVector& entityIDs) { QVector entities; diff --git a/interface/src/Application.h b/interface/src/Application.h index 98aa4b3013..5172f34269 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -350,11 +350,13 @@ public slots: void resetSensors(); void setActiveFaceTracker(); - + +#ifdef HAVE_IVIEWHMD void setActiveEyeTracker(); void calibrateEyeTracker1Point(); void calibrateEyeTracker3Points(); void calibrateEyeTracker5Points(); +#endif void aboutApp(); void showEditEntitiesHelp(); From 8c653c70fb838563d5559ecd5fb138b290f4a7e1 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Thu, 24 Sep 2015 23:19:55 +0200 Subject: [PATCH 16/33] Remove fps throttle from Application --- interface/src/Application.cpp | 5 ----- interface/src/Application.h | 5 ----- interface/src/GLCanvas.cpp | 4 +++- 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 6cd129af4d..04c7eafc4f 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -372,7 +372,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : _runningScriptsWidgetWasVisible(false), _lastNackTime(usecTimestampNow()), _lastSendDownstreamAudioStats(usecTimestampNow()), - _isThrottleFPSEnabled(true), _aboutToQuit(false), _notifiedPacketVersionMismatchThisDomain(false), _maxOctreePPS(maxOctreePacketsPerSecond.get()), @@ -4526,10 +4525,6 @@ void Application::takeSnapshot() { } -void Application::setThrottleFPSEnabled() { - _isThrottleFPSEnabled = Menu::getInstance()->isOptionChecked(MenuOption::ThrottleFPSIfNotFocus); -} - float Application::getRenderResolutionScale() const { if (Menu::getInstance()->isOptionChecked(MenuOption::RenderResolutionOne)) { return 1.0f; diff --git a/interface/src/Application.h b/interface/src/Application.h index 5172f34269..a85efd53a7 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -345,9 +345,6 @@ public slots: void domainSettingsReceived(const QJsonObject& domainSettingsObject); - void setThrottleFPSEnabled(); - bool isThrottleFPSEnabled() { return _isThrottleFPSEnabled; } - void resetSensors(); void setActiveFaceTracker(); @@ -539,8 +536,6 @@ private: quint64 _lastNackTime; quint64 _lastSendDownstreamAudioStats; - - bool _isThrottleFPSEnabled; bool _aboutToQuit; diff --git a/interface/src/GLCanvas.cpp b/interface/src/GLCanvas.cpp index 306e57cfa0..d9cde868a9 100644 --- a/interface/src/GLCanvas.cpp +++ b/interface/src/GLCanvas.cpp @@ -17,6 +17,7 @@ #include #include "MainWindow.h" +#include "Menu.h" static QGLFormat& getDesiredGLFormat() { // Specify an OpenGL 3.3 format using the Core profile. @@ -62,7 +63,8 @@ void GLCanvas::paintGL() { // FIXME - I'm not sure why this still remains, it appears as if this GLCanvas gets a single paintGL call near // the beginning of the application starting up. I'm not sure if we really need to call Application::paintGL() // in this case, since the display plugins eventually handle all the painting - if (!qApp->getWindow()->isMinimized() || !qApp->isThrottleFPSEnabled()) { + bool isThrottleFPSEnabled = Menu::getInstance()->isOptionChecked(MenuOption::ThrottleFPSIfNotFocus); + if (!qApp->getWindow()->isMinimized() || !isThrottleFPSEnabled) { qApp->paintGL(); } } From 9c7a480fdac4dc6e57ebedd46a093e6648fb4754 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Thu, 24 Sep 2015 23:27:14 +0200 Subject: [PATCH 17/33] Remove shadowMatrices/Distances --- interface/src/Application.h | 5 ----- libraries/render-utils/src/AbstractViewStateInterface.h | 4 ---- 2 files changed, 9 deletions(-) diff --git a/interface/src/Application.h b/interface/src/Application.h index a85efd53a7..75e65a893a 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -212,7 +212,6 @@ public: void displaySide(RenderArgs* renderArgs, Camera& whichCamera, bool selfAvatarOnly = false, bool billboard = false); - virtual const glm::vec3& getShadowDistances() const { return _shadowDistances; } virtual ViewFrustum* getCurrentViewFrustum() { return getDisplayViewFrustum(); } virtual QThread* getMainThread() { return thread(); } virtual float getSizeScale() const; @@ -482,10 +481,6 @@ private: float _rotateMirror; float _raiseMirror; - static const int CASCADED_SHADOW_MATRIX_COUNT = 4; - glm::mat4 _shadowMatrices[CASCADED_SHADOW_MATRIX_COUNT]; - glm::vec3 _shadowDistances; - Environment _environment; ivec2 _mouseDragStarted; diff --git a/libraries/render-utils/src/AbstractViewStateInterface.h b/libraries/render-utils/src/AbstractViewStateInterface.h index 2b6c66b36a..b65289933c 100644 --- a/libraries/render-utils/src/AbstractViewStateInterface.h +++ b/libraries/render-utils/src/AbstractViewStateInterface.h @@ -29,10 +29,6 @@ class EnvironmentData; /// Interface provided by Application to other objects that need access to the current view state details class AbstractViewStateInterface { public: - - /// Returns the shadow distances for the current view state - virtual const glm::vec3& getShadowDistances() const = 0; - /// gets the current view frustum for rendering the view state virtual ViewFrustum* getCurrentViewFrustum() = 0; From ba5c20b7a6ab0ff9a54a0956b91a15465fe93069 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Fri, 25 Sep 2015 17:42:42 +0200 Subject: [PATCH 18/33] Header cleanup --- interface/src/Util.cpp | 12 +++++++----- interface/src/scripting/MenuScriptingInterface.cpp | 4 ++-- interface/src/scripting/MenuScriptingInterface.h | 5 +---- .../src/scripting/SettingsScriptingInterface.cpp | 3 +-- interface/src/scripting/SettingsScriptingInterface.h | 3 --- interface/src/ui/ScriptLineNumberArea.cpp | 2 +- interface/src/ui/ScriptLineNumberArea.h | 3 ++- interface/src/ui/overlays/Billboard3DOverlay.cpp | 1 - interface/src/ui/overlays/Billboardable.cpp | 1 + interface/src/ui/overlays/Billboardable.h | 7 +++++-- interface/src/ui/overlays/Image3DOverlay.cpp | 2 +- interface/src/ui/overlays/OverlayPanel.cpp | 1 - interface/src/ui/overlays/OverlaysPayload.cpp | 2 +- interface/src/ui/overlays/Text3DOverlay.cpp | 4 ++-- 14 files changed, 24 insertions(+), 26 deletions(-) diff --git a/interface/src/Util.cpp b/interface/src/Util.cpp index d09dd41999..3d97d48f90 100644 --- a/interface/src/Util.cpp +++ b/interface/src/Util.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include "Util.h" + #include #include #include @@ -19,17 +21,17 @@ #include #include +#include #include #include -#include #include +#include +#include +#include -#include "world.h" -#include "Application.h" #include "InterfaceLogging.h" - -#include "Util.h" +#include "world.h" using namespace std; diff --git a/interface/src/scripting/MenuScriptingInterface.cpp b/interface/src/scripting/MenuScriptingInterface.cpp index 277c611f04..ff7784b9ae 100644 --- a/interface/src/scripting/MenuScriptingInterface.cpp +++ b/interface/src/scripting/MenuScriptingInterface.cpp @@ -9,10 +9,10 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include "Application.h" - #include "MenuScriptingInterface.h" +#include "Menu.h" +#include MenuScriptingInterface* MenuScriptingInterface::getInstance() { static MenuScriptingInterface sharedInstance; diff --git a/interface/src/scripting/MenuScriptingInterface.h b/interface/src/scripting/MenuScriptingInterface.h index fda8207780..5c01318a38 100644 --- a/interface/src/scripting/MenuScriptingInterface.h +++ b/interface/src/scripting/MenuScriptingInterface.h @@ -12,13 +12,10 @@ #ifndef hifi_MenuScriptingInterface_h #define hifi_MenuScriptingInterface_h -#include -#include #include #include -#include "Menu.h" -#include +class MenuItemProperties; class MenuScriptingInterface : public QObject { Q_OBJECT diff --git a/interface/src/scripting/SettingsScriptingInterface.cpp b/interface/src/scripting/SettingsScriptingInterface.cpp index a5994779e2..2f14c33dc7 100644 --- a/interface/src/scripting/SettingsScriptingInterface.cpp +++ b/interface/src/scripting/SettingsScriptingInterface.cpp @@ -9,10 +9,9 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include - #include "SettingsScriptingInterface.h" +#include SettingsScriptingInterface* SettingsScriptingInterface::getInstance() { static SettingsScriptingInterface sharedInstance; diff --git a/interface/src/scripting/SettingsScriptingInterface.h b/interface/src/scripting/SettingsScriptingInterface.h index e3138be4a0..2fe55eaea0 100644 --- a/interface/src/scripting/SettingsScriptingInterface.h +++ b/interface/src/scripting/SettingsScriptingInterface.h @@ -12,12 +12,9 @@ #ifndef hifi_SettingsScriptingInterface_h #define hifi_SettingsScriptingInterface_h -#include #include #include -#include "Application.h" - class SettingsScriptingInterface : public QObject { Q_OBJECT SettingsScriptingInterface() { }; diff --git a/interface/src/ui/ScriptLineNumberArea.cpp b/interface/src/ui/ScriptLineNumberArea.cpp index 5bb08918b9..6d7e9185ea 100644 --- a/interface/src/ui/ScriptLineNumberArea.cpp +++ b/interface/src/ui/ScriptLineNumberArea.cpp @@ -11,7 +11,7 @@ #include "ScriptLineNumberArea.h" -#include "Application.h" +#include "ScriptEditBox.h" ScriptLineNumberArea::ScriptLineNumberArea(ScriptEditBox* scriptEditBox) : QWidget(scriptEditBox) diff --git a/interface/src/ui/ScriptLineNumberArea.h b/interface/src/ui/ScriptLineNumberArea.h index 47c540ca0e..00bd078170 100644 --- a/interface/src/ui/ScriptLineNumberArea.h +++ b/interface/src/ui/ScriptLineNumberArea.h @@ -13,7 +13,8 @@ #define hifi_ScriptLineNumberArea_h #include -#include "ScriptEditBox.h" + +class ScriptEditBox; class ScriptLineNumberArea : public QWidget { diff --git a/interface/src/ui/overlays/Billboard3DOverlay.cpp b/interface/src/ui/overlays/Billboard3DOverlay.cpp index 0b27673e18..908676e0eb 100644 --- a/interface/src/ui/overlays/Billboard3DOverlay.cpp +++ b/interface/src/ui/overlays/Billboard3DOverlay.cpp @@ -10,7 +10,6 @@ // #include "Billboard3DOverlay.h" -#include "Application.h" Billboard3DOverlay::Billboard3DOverlay(const Billboard3DOverlay* billboard3DOverlay) : Planar3DOverlay(billboard3DOverlay), diff --git a/interface/src/ui/overlays/Billboardable.cpp b/interface/src/ui/overlays/Billboardable.cpp index 18e80c2b4f..997cf27609 100644 --- a/interface/src/ui/overlays/Billboardable.cpp +++ b/interface/src/ui/overlays/Billboardable.cpp @@ -12,6 +12,7 @@ #include "Billboardable.h" #include +#include void Billboardable::setProperties(const QScriptValue &properties) { QScriptValue isFacingAvatar = properties.property("isFacingAvatar"); diff --git a/interface/src/ui/overlays/Billboardable.h b/interface/src/ui/overlays/Billboardable.h index 1388f13e60..82387ad703 100644 --- a/interface/src/ui/overlays/Billboardable.h +++ b/interface/src/ui/overlays/Billboardable.h @@ -13,9 +13,12 @@ #define hifi_Billboardable_h #include -#include -#include +#include + +class QScriptEngine; +class QString; +class Transform; class Billboardable { public: diff --git a/interface/src/ui/overlays/Image3DOverlay.cpp b/interface/src/ui/overlays/Image3DOverlay.cpp index 2f8450131f..11fb647f01 100644 --- a/interface/src/ui/overlays/Image3DOverlay.cpp +++ b/interface/src/ui/overlays/Image3DOverlay.cpp @@ -18,8 +18,8 @@ #include #include #include +#include -#include "Application.h" #include "GeometryUtil.h" diff --git a/interface/src/ui/overlays/OverlayPanel.cpp b/interface/src/ui/overlays/OverlayPanel.cpp index db91b7e0e3..3d7b93822e 100644 --- a/interface/src/ui/overlays/OverlayPanel.cpp +++ b/interface/src/ui/overlays/OverlayPanel.cpp @@ -18,7 +18,6 @@ #include "avatar/AvatarManager.h" #include "avatar/MyAvatar.h" -#include "Application.h" #include "Base3DOverlay.h" PropertyBinding::PropertyBinding(QString avatar, QUuid entity) : diff --git a/interface/src/ui/overlays/OverlaysPayload.cpp b/interface/src/ui/overlays/OverlaysPayload.cpp index 5b91ff5b52..02d432ea81 100644 --- a/interface/src/ui/overlays/OverlaysPayload.cpp +++ b/interface/src/ui/overlays/OverlaysPayload.cpp @@ -13,8 +13,8 @@ #include #include -#include #include +#include #include #include diff --git a/interface/src/ui/overlays/Text3DOverlay.cpp b/interface/src/ui/overlays/Text3DOverlay.cpp index 563f454057..8c448234ad 100644 --- a/interface/src/ui/overlays/Text3DOverlay.cpp +++ b/interface/src/ui/overlays/Text3DOverlay.cpp @@ -11,11 +11,11 @@ #include "Text3DOverlay.h" #include +#include +#include #include #include -#include "Application.h" - const xColor DEFAULT_BACKGROUND_COLOR = { 0, 0, 0 }; const float DEFAULT_BACKGROUND_ALPHA = 0.7f; const float DEFAULT_MARGIN = 0.1f; From 9827c9085156be3eadb996ff1a906bc3b1736b1e Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Fri, 2 Oct 2015 16:03:38 -0700 Subject: [PATCH 19/33] Rebase fixes --- interface/src/Application.cpp | 3 +-- interface/src/FileLogger.cpp | 2 +- interface/src/ui/Stats.cpp | 1 + interface/src/ui/overlays/Overlays.cpp | 5 +++-- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 04c7eafc4f..472b516e6c 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -402,7 +402,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : _myAvatar = DependencyManager::get()->getMyAvatar(); - qCDebug(interfaceapp) << "[VERSION] Build sequence: " << qPrintable(applicationVersion()); + qCDebug(interfaceapp) << "[VERSION] Build sequence:" << qPrintable(applicationVersion()); _bookmarks = new Bookmarks(); // Before setting up the menu @@ -781,7 +781,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : connect(this, &Application::applicationStateChanged, this, &Application::activeChanged); - qCDebug(interfaceapp, "Startup time: %4.2f seconds.", (double)startupTimer.elapsed() / 1000.0f); } diff --git a/interface/src/FileLogger.cpp b/interface/src/FileLogger.cpp index f09397322f..10dce38fbc 100644 --- a/interface/src/FileLogger.cpp +++ b/interface/src/FileLogger.cpp @@ -59,7 +59,7 @@ protected: _lastRollTime = now; file.open(QIODevice::WriteOnly | QIODevice::Truncate); file.close(); - qDebug() << "Rolled log file: " << newFileName; + qDebug() << "Rolled log file:" << newFileName; } } } diff --git a/interface/src/ui/Stats.cpp b/interface/src/ui/Stats.cpp index fe5769c65c..5e73e62832 100644 --- a/interface/src/ui/Stats.cpp +++ b/interface/src/ui/Stats.cpp @@ -18,6 +18,7 @@ #include #include +#include #include #include #include diff --git a/interface/src/ui/overlays/Overlays.cpp b/interface/src/ui/overlays/Overlays.cpp index 29e9d62542..96553843c8 100644 --- a/interface/src/ui/overlays/Overlays.cpp +++ b/interface/src/ui/overlays/Overlays.cpp @@ -10,10 +10,11 @@ #include "Overlays.h" -#include - #include +#include + +#include #include #include From 2fc80e58b64cbd6e8fc410fdf06e06dce71c8119 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Fri, 2 Oct 2015 17:09:49 -0700 Subject: [PATCH 20/33] Fix warning --- interface/src/Application.cpp | 2 +- interface/src/Application.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 472b516e6c..642d60a785 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -781,7 +781,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : connect(this, &Application::applicationStateChanged, this, &Application::activeChanged); - qCDebug(interfaceapp, "Startup time: %4.2f seconds.", (double)startupTimer.elapsed() / 1000.0f); + qCDebug(interfaceapp, "Startup time: %4.2f seconds.", (double)startupTimer.elapsed() / 1000.0); } void Application::aboutToQuit() { diff --git a/interface/src/Application.h b/interface/src/Application.h index 75e65a893a..1afb43a8a3 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -97,7 +97,7 @@ public: static void initPlugins(); static void shutdownPlugins(); - Application(int& argc, char** argv, QElapsedTimer &startup_time); + Application(int& argc, char** argv, QElapsedTimer& startup_time); ~Application(); void postLambdaEvent(std::function f); From 35e2f8cd89045b9580e54017aac3751bcc90800f Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Fri, 2 Oct 2015 19:37:49 -0700 Subject: [PATCH 21/33] Removed _myAvatar from Application --- interface/src/Application.cpp | 292 ++++++++++++-------------- interface/src/Application.h | 13 +- interface/src/avatar/Avatar.cpp | 8 + interface/src/avatar/Avatar.h | 6 +- interface/src/avatar/AvatarUpdate.cpp | 2 +- interface/src/avatar/MyAvatar.cpp | 2 +- 6 files changed, 146 insertions(+), 177 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 642d60a785..b1ca987640 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -400,8 +400,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : auto nodeList = DependencyManager::get(); - _myAvatar = DependencyManager::get()->getMyAvatar(); - qCDebug(interfaceapp) << "[VERSION] Build sequence:" << qPrintable(applicationVersion()); _bookmarks = new Bookmarks(); // Before setting up the menu @@ -439,8 +437,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : auto audioIO = DependencyManager::get(); - audioIO->setPositionGetter([]{ return qApp->_myAvatar->getPositionForAudio(); }); - audioIO->setOrientationGetter([]{ return qApp->_myAvatar->getOrientationForAudio(); }); + audioIO->setPositionGetter([this]{ return getMyAvatar()->getPositionForAudio(); }); + audioIO->setOrientationGetter([this]{ return getMyAvatar()->getOrientationForAudio(); }); audioIO->moveToThread(audioThread); @@ -455,8 +453,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : connect(audioIO.data(), &AudioClient::disconnected, &audioScriptingInterface, &AudioScriptingInterface::disconnected); connect(audioIO.data(), &AudioClient::muteEnvironmentRequested, [](glm::vec3 position, float radius) { auto audioClient = DependencyManager::get(); - float distance = glm::distance(DependencyManager::get()->getMyAvatar()->getPosition(), - position); + auto myAvatarPosition = DependencyManager::get()->getMyAvatar()->getPosition(); + float distance = glm::distance(myAvatarPosition, position); bool shouldMute = !audioClient->isMuted() && (distance < radius); if (shouldMute) { @@ -500,8 +498,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : connect(nodeList.data(), &NodeList::nodeAdded, this, &Application::nodeAdded); connect(nodeList.data(), &NodeList::nodeKilled, this, &Application::nodeKilled); - connect(nodeList.data(), SIGNAL(nodeKilled(SharedNodePointer)), SLOT(nodeKilled(SharedNodePointer))); - connect(nodeList.data(), &NodeList::uuidChanged, _myAvatar, &MyAvatar::setSessionUUID); + connect(nodeList.data(), &NodeList::uuidChanged, getMyAvatar(), &MyAvatar::setSessionUUID); connect(nodeList.data(), &NodeList::uuidChanged, this, &Application::setSessionUUID); connect(nodeList.data(), &NodeList::limitOfSilentDomainCheckInsReached, nodeList.data(), &NodeList::reset); connect(nodeList.data(), &NodeList::packetVersionMismatch, this, &Application::notifyPacketVersionMismatch); @@ -531,8 +528,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : auto addressManager = DependencyManager::get(); // use our MyAvatar position and quat for address manager path - addressManager->setPositionGetter([]{ return qApp->_myAvatar->getPosition(); }); - addressManager->setOrientationGetter([]{ return qApp->_myAvatar->getOrientation(); }); + addressManager->setPositionGetter([this]{ return getMyAvatar()->getPosition(); }); + addressManager->setOrientationGetter([this]{ return getMyAvatar()->getOrientation(); }); connect(addressManager.data(), &AddressManager::hostChanged, this, &Application::updateWindowTitle); connect(this, &QCoreApplication::aboutToQuit, addressManager.data(), &AddressManager::storeCurrentAddress); @@ -551,12 +548,12 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : // send the identity packet for our avatar each second to our avatar mixer identityPacketTimer = new QTimer(); - connect(identityPacketTimer, &QTimer::timeout, _myAvatar, &MyAvatar::sendIdentityPacket); + connect(identityPacketTimer, &QTimer::timeout, getMyAvatar(), &MyAvatar::sendIdentityPacket); identityPacketTimer->start(AVATAR_IDENTITY_PACKET_SEND_INTERVAL_MSECS); // send the billboard packet for our avatar every few seconds billboardPacketTimer = new QTimer(); - connect(billboardPacketTimer, &QTimer::timeout, _myAvatar, &MyAvatar::sendBillboardPacket); + connect(billboardPacketTimer, &QTimer::timeout, getMyAvatar(), &MyAvatar::sendBillboardPacket); billboardPacketTimer->start(AVATAR_BILLBOARD_PACKET_SEND_INTERVAL_MSECS); QString cachePath = QStandardPaths::writableLocation(QStandardPaths::DataLocation); @@ -623,7 +620,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : connect(&nodeList->getPacketReceiver(), &PacketReceiver::dataReceived, bandwidthRecorder.data(), &BandwidthRecorder::updateInboundData); - connect(&_myAvatar->getSkeletonModel(), &SkeletonModel::skeletonLoaded, + connect(&getMyAvatar()->getSkeletonModel(), &SkeletonModel::skeletonLoaded, this, &Application::checkSkeleton, Qt::QueuedConnection); // Setup the userInputMapper with the actions @@ -712,7 +709,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : applicationUpdater->checkForUpdate(); // Now that menu is initalized we can sync myAvatar with it's state. - _myAvatar->updateMotionBehaviorFromMenu(); + getMyAvatar()->updateMotionBehaviorFromMenu(); // the 3Dconnexion device wants to be initiliazed after a window is displayed. ConnexionClient::getInstance().init(); @@ -877,7 +874,6 @@ Application::~Application() { Menu::getInstance()->deleteLater(); _physicsEngine->setCharacterController(NULL); - _myAvatar = NULL; ModelEntityItem::cleanupLoadedAnimations(); @@ -1057,7 +1053,7 @@ void Application::paintGL() { _offscreenContext->makeCurrent(); // update the avatar with a fresh HMD pose - _myAvatar->updateFromHMDSensorMatrix(getHMDSensorPose()); + getMyAvatar()->updateFromHMDSensorMatrix(getHMDSensorPose()); auto lodManager = DependencyManager::get(); @@ -1112,8 +1108,10 @@ void Application::paintGL() { { PerformanceTimer perfTimer("CameraUpdates"); - - _myAvatar->startCapture(); + + auto myAvatar = getMyAvatar(); + + myAvatar->startCapture(); if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON || _myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) { Menu::getInstance()->setIsOptionChecked(MenuOption::FirstPerson, _myAvatar->getBoomLength() <= MyAvatar::ZOOM_MIN); Menu::getInstance()->setIsOptionChecked(MenuOption::ThirdPerson, !(_myAvatar->getBoomLength() <= MyAvatar::ZOOM_MIN)); @@ -1128,51 +1126,51 @@ void Application::paintGL() { // or with changes from the face tracker if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON) { if (isHMDMode()) { - mat4 camMat = _myAvatar->getSensorToWorldMatrix() * _myAvatar->getHMDSensorMatrix(); + mat4 camMat = myAvatar->getSensorToWorldMatrix() * myAvatar->getHMDSensorMatrix(); _myCamera.setPosition(extractTranslation(camMat)); _myCamera.setRotation(glm::quat_cast(camMat)); } else { - _myCamera.setPosition(_myAvatar->getDefaultEyePosition()); - _myCamera.setRotation(_myAvatar->getHead()->getCameraOrientation()); + _myCamera.setPosition(myAvatar->getDefaultEyePosition()); + _myCamera.setRotation(myAvatar->getHead()->getCameraOrientation()); } } else if (_myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) { if (isHMDMode()) { - glm::quat hmdRotation = extractRotation(_myAvatar->getHMDSensorMatrix()); - _myCamera.setRotation(_myAvatar->getWorldAlignedOrientation() * hmdRotation); + glm::quat hmdRotation = extractRotation(myAvatar->getHMDSensorMatrix()); + _myCamera.setRotation(myAvatar->getWorldAlignedOrientation() * hmdRotation); // Ignore MenuOption::CenterPlayerInView in HMD view - glm::vec3 hmdOffset = extractTranslation(_myAvatar->getHMDSensorMatrix()); - _myCamera.setPosition(_myAvatar->getDefaultEyePosition() - + _myAvatar->getOrientation() - * (_myAvatar->getScale() * _myAvatar->getBoomLength() * glm::vec3(0.0f, 0.0f, 1.0f) + hmdOffset)); + glm::vec3 hmdOffset = extractTranslation(myAvatar->getHMDSensorMatrix()); + _myCamera.setPosition(myAvatar->getDefaultEyePosition() + + myAvatar->getOrientation() + * (myAvatar->getScale() * myAvatar->getBoomLength() * glm::vec3(0.0f, 0.0f, 1.0f) + hmdOffset)); } else { - _myCamera.setRotation(_myAvatar->getHead()->getOrientation()); + _myCamera.setRotation(myAvatar->getHead()->getOrientation()); if (Menu::getInstance()->isOptionChecked(MenuOption::CenterPlayerInView)) { - _myCamera.setPosition(_myAvatar->getDefaultEyePosition() + _myCamera.setPosition(myAvatar->getDefaultEyePosition() + _myCamera.getRotation() - * (_myAvatar->getScale() * _myAvatar->getBoomLength() * glm::vec3(0.0f, 0.0f, 1.0f))); + * (myAvatar->getScale() * myAvatar->getBoomLength() * glm::vec3(0.0f, 0.0f, 1.0f))); } else { - _myCamera.setPosition(_myAvatar->getDefaultEyePosition() - + _myAvatar->getOrientation() - * (_myAvatar->getScale() * _myAvatar->getBoomLength() * glm::vec3(0.0f, 0.0f, 1.0f))); + _myCamera.setPosition(myAvatar->getDefaultEyePosition() + + myAvatar->getOrientation() + * (myAvatar->getScale() * myAvatar->getBoomLength() * glm::vec3(0.0f, 0.0f, 1.0f))); } } } else if (_myCamera.getMode() == CAMERA_MODE_MIRROR) { if (isHMDMode()) { - glm::quat hmdRotation = extractRotation(_myAvatar->getHMDSensorMatrix()); - _myCamera.setRotation(_myAvatar->getWorldAlignedOrientation() + glm::quat hmdRotation = extractRotation(myAvatar->getHMDSensorMatrix()); + _myCamera.setRotation(myAvatar->getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f)) * hmdRotation); - glm::vec3 hmdOffset = extractTranslation(_myAvatar->getHMDSensorMatrix()); - _myCamera.setPosition(_myAvatar->getDefaultEyePosition() - + glm::vec3(0, _raiseMirror * _myAvatar->getScale(), 0) - + (_myAvatar->getOrientation() * glm::quat(glm::vec3(0.0f, _rotateMirror, 0.0f))) * + glm::vec3 hmdOffset = extractTranslation(myAvatar->getHMDSensorMatrix()); + _myCamera.setPosition(myAvatar->getDefaultEyePosition() + + glm::vec3(0, _raiseMirror * myAvatar->getScale(), 0) + + (myAvatar->getOrientation() * glm::quat(glm::vec3(0.0f, _rotateMirror, 0.0f))) * glm::vec3(0.0f, 0.0f, -1.0f) * MIRROR_FULLSCREEN_DISTANCE * _scaleMirror - + (_myAvatar->getOrientation() * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f))) * hmdOffset); + + (myAvatar->getOrientation() * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f))) * hmdOffset); } else { - _myCamera.setRotation(_myAvatar->getWorldAlignedOrientation() + _myCamera.setRotation(myAvatar->getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f))); - _myCamera.setPosition(_myAvatar->getDefaultEyePosition() - + glm::vec3(0, _raiseMirror * _myAvatar->getScale(), 0) - + (_myAvatar->getOrientation() * glm::quat(glm::vec3(0.0f, _rotateMirror, 0.0f))) * + _myCamera.setPosition(myAvatar->getDefaultEyePosition() + + glm::vec3(0, _raiseMirror * myAvatar->getScale(), 0) + + (myAvatar->getOrientation() * glm::quat(glm::vec3(0.0f, _rotateMirror, 0.0f))) * glm::vec3(0.0f, 0.0f, -1.0f) * MIRROR_FULLSCREEN_DISTANCE * _scaleMirror); } renderArgs._renderMode = RenderArgs::MIRROR_RENDER_MODE; @@ -1181,7 +1179,7 @@ void Application::paintGL() { if (!isHMDMode()) { _myCamera.update(1.0f / _fps); } - _myAvatar->endCapture(); + myAvatar->endCapture(); } // Primary rendering pass @@ -1704,7 +1702,7 @@ void Application::keyPressEvent(QKeyEvent* event) { auto& cursorManager = Cursor::Manager::instance(); cursorManager.setScale(cursorManager.getScale() * 1.1f); } else { - _myAvatar->increaseSize(); + getMyAvatar()->increaseSize(); } break; } @@ -1714,13 +1712,13 @@ void Application::keyPressEvent(QKeyEvent* event) { auto& cursorManager = Cursor::Manager::instance(); cursorManager.setScale(cursorManager.getScale() / 1.1f); } else { - _myAvatar->decreaseSize(); + getMyAvatar()->decreaseSize(); } break; } case Qt::Key_Equal: - _myAvatar->resetSize(); + getMyAvatar()->resetSize(); break; case Qt::Key_Space: { if (!event->isAutoRepeat()) { @@ -2408,7 +2406,7 @@ void Application::loadSettings() { //DependencyManager::get()->setAutomaticLODAdjust(false); Menu::getInstance()->loadSettings(); - _myAvatar->loadData(); + getMyAvatar()->loadData(); } void Application::saveSettings() { @@ -2416,7 +2414,7 @@ void Application::saveSettings() { DependencyManager::get()->saveSettings(); Menu::getInstance()->saveSettings(); - _myAvatar->saveData(); + getMyAvatar()->saveData(); } bool Application::importEntities(const QString& urlOrFilename) { @@ -2451,7 +2449,6 @@ void Application::init() { DependencyManager::get()->init(this); - // TODO: move _myAvatar out of Application. Move relevant code to MyAvataar or AvatarManager DependencyManager::get()->init(); _myCamera.setMode(CAMERA_MODE_FIRST_PERSON); @@ -2504,7 +2501,7 @@ void Application::init() { // Make sure any new sounds are loaded as soon as know about them. connect(tree.get(), &EntityTree::newCollisionSoundURL, DependencyManager::get().data(), &SoundCache::getSound); - connect(_myAvatar, &MyAvatar::newCollisionSoundURL, DependencyManager::get().data(), &SoundCache::getSound); + connect(getMyAvatar(), &MyAvatar::newCollisionSoundURL, DependencyManager::get().data(), &SoundCache::getSound); setAvatarUpdateThreading(); } @@ -2529,47 +2526,19 @@ void Application::setAvatarUpdateThreading(bool isThreaded) { if (_avatarUpdate && (_avatarUpdate->isThreaded() == isThreaded)) { return; } - bool isRigEnabled = getMyAvatar()->getEnableRigAnimations(); - bool isGraphEnabled = getMyAvatar()->getEnableAnimGraph(); + + auto myAvatar = getMyAvatar(); + bool isRigEnabled = myAvatar->getEnableRigAnimations(); + bool isGraphEnabled = myAvatar->getEnableAnimGraph(); if (_avatarUpdate) { _avatarUpdate->terminate(); // Must be before we shutdown anim graph. } - getMyAvatar()->setEnableRigAnimations(false); - getMyAvatar()->setEnableAnimGraph(false); + myAvatar->setEnableRigAnimations(false); + myAvatar->setEnableAnimGraph(false); _avatarUpdate = new AvatarUpdate(); _avatarUpdate->initialize(isThreaded); - getMyAvatar()->setEnableRigAnimations(isRigEnabled); - getMyAvatar()->setEnableAnimGraph(isGraphEnabled); -} - - -void Application::closeMirrorView() { - if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) { - Menu::getInstance()->triggerOption(MenuOption::Mirror); - } -} - -void Application::restoreMirrorView() { - if (!Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror)) { - Menu::getInstance()->triggerOption(MenuOption::FullscreenMirror); - } -} - -void Application::shrinkMirrorView() { - if (Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror)) { - Menu::getInstance()->triggerOption(MenuOption::FullscreenMirror); - } -} - -const float HEAD_SPHERE_RADIUS = 0.1f; - -bool Application::isLookingAtMyAvatar(AvatarSharedPointer avatar) { - glm::vec3 theirLookAt = dynamic_pointer_cast(avatar)->getHead()->getLookAtPosition(); - glm::vec3 myEyePosition = _myAvatar->getHead()->getEyePosition(); - if (pointInSphere(theirLookAt, myEyePosition, HEAD_SPHERE_RADIUS * _myAvatar->getScale())) { - return true; - } - return false; + myAvatar->setEnableRigAnimations(isRigEnabled); + myAvatar->setEnableAnimGraph(isGraphEnabled); } void Application::updateLOD() { @@ -2614,7 +2583,8 @@ void Application::updateMyAvatarLookAtPosition() { bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); PerformanceWarning warn(showWarnings, "Application::updateMyAvatarLookAtPosition()"); - _myAvatar->updateLookAtTargetAvatar(); + auto myAvatar = getMyAvatar(); + myAvatar->updateLookAtTargetAvatar(); FaceTracker* faceTracker = getActiveFaceTracker(); auto eyeTracker = DependencyManager::get(); @@ -2630,28 +2600,28 @@ void Application::updateMyAvatarLookAtPosition() { if (isHMD) { glm::mat4 headPose = getActiveDisplayPlugin()->getHeadPose(); glm::quat hmdRotation = glm::quat_cast(headPose); - lookAtSpot = _myCamera.getPosition() + _myAvatar->getOrientation() * (hmdRotation * lookAtPosition); + lookAtSpot = _myCamera.getPosition() + myAvatar->getOrientation() * (hmdRotation * lookAtPosition); } else { - lookAtSpot = _myAvatar->getHead()->getEyePosition() - + (_myAvatar->getHead()->getFinalOrientationInWorldFrame() * lookAtPosition); + lookAtSpot = myAvatar->getHead()->getEyePosition() + + (myAvatar->getHead()->getFinalOrientationInWorldFrame() * lookAtPosition); } } else { - AvatarSharedPointer lookingAt = _myAvatar->getLookAtTargetAvatar().lock(); - if (lookingAt && _myAvatar != lookingAt.get()) { + AvatarSharedPointer lookingAt = myAvatar->getLookAtTargetAvatar().lock(); + if (lookingAt && myAvatar != lookingAt.get()) { // If I am looking at someone else, look directly at one of their eyes isLookingAtSomeone = true; auto lookingAtHead = static_pointer_cast(lookingAt)->getHead(); const float MAXIMUM_FACE_ANGLE = 65.0f * RADIANS_PER_DEGREE; glm::vec3 lookingAtFaceOrientation = lookingAtHead->getFinalOrientationInWorldFrame() * IDENTITY_FRONT; - glm::vec3 fromLookingAtToMe = glm::normalize(_myAvatar->getHead()->getEyePosition() + glm::vec3 fromLookingAtToMe = glm::normalize(myAvatar->getHead()->getEyePosition() - lookingAtHead->getEyePosition()); float faceAngle = glm::angle(lookingAtFaceOrientation, fromLookingAtToMe); if (faceAngle < MAXIMUM_FACE_ANGLE) { // Randomly look back and forth between look targets eyeContactTarget target = Menu::getInstance()->isOptionChecked(MenuOption::FixGaze) ? - LEFT_EYE : _myAvatar->getEyeContactTarget(); + LEFT_EYE : myAvatar->getEyeContactTarget(); switch (target) { case LEFT_EYE: lookAtSpot = lookingAtHead->getLeftEyePosition(); @@ -2673,10 +2643,10 @@ void Application::updateMyAvatarLookAtPosition() { glm::mat4 headPose = _avatarUpdate->getHeadPose() ; glm::quat headRotation = glm::quat_cast(headPose); lookAtSpot = _myCamera.getPosition() + - _myAvatar->getOrientation() * (headRotation * glm::vec3(0.0f, 0.0f, -TREE_SCALE)); + myAvatar->getOrientation() * (headRotation * glm::vec3(0.0f, 0.0f, -TREE_SCALE)); } else { - lookAtSpot = _myAvatar->getHead()->getEyePosition() + - (_myAvatar->getHead()->getFinalOrientationInWorldFrame() * glm::vec3(0.0f, 0.0f, -TREE_SCALE)); + lookAtSpot = myAvatar->getHead()->getEyePosition() + + (myAvatar->getHead()->getFinalOrientationInWorldFrame() * glm::vec3(0.0f, 0.0f, -TREE_SCALE)); } } @@ -2685,7 +2655,7 @@ void Application::updateMyAvatarLookAtPosition() { float eyePitch = faceTracker->getEstimatedEyePitch(); float eyeYaw = faceTracker->getEstimatedEyeYaw(); const float GAZE_DEFLECTION_REDUCTION_DURING_EYE_CONTACT = 0.1f; - glm::vec3 origin = _myAvatar->getHead()->getEyePosition(); + glm::vec3 origin = myAvatar->getHead()->getEyePosition(); float deflection = faceTracker->getEyeDeflection(); if (isLookingAtSomeone) { deflection *= GAZE_DEFLECTION_REDUCTION_DURING_EYE_CONTACT; @@ -2696,7 +2666,7 @@ void Application::updateMyAvatarLookAtPosition() { } } - _myAvatar->getHead()->setLookAtPosition(lookAtSpot); + myAvatar->getHead()->setLookAtPosition(lookAtSpot); } void Application::updateThreads(float deltaTime) { @@ -2719,13 +2689,13 @@ void Application::cameraMenuChanged() { } else if (Menu::getInstance()->isOptionChecked(MenuOption::FirstPerson)) { if (_myCamera.getMode() != CAMERA_MODE_FIRST_PERSON) { _myCamera.setMode(CAMERA_MODE_FIRST_PERSON); - _myAvatar->setBoomLength(MyAvatar::ZOOM_MIN); + getMyAvatar()->setBoomLength(MyAvatar::ZOOM_MIN); } } else if (Menu::getInstance()->isOptionChecked(MenuOption::ThirdPerson)) { if (_myCamera.getMode() != CAMERA_MODE_THIRD_PERSON) { _myCamera.setMode(CAMERA_MODE_THIRD_PERSON); - if (_myAvatar->getBoomLength() == MyAvatar::ZOOM_MIN) { - _myAvatar->setBoomLength(MyAvatar::ZOOM_DEFAULT); + if (getMyAvatar()->getBoomLength() == MyAvatar::ZOOM_MIN) { + getMyAvatar()->setBoomLength(MyAvatar::ZOOM_DEFAULT); } } } else if (Menu::getInstance()->isOptionChecked(MenuOption::IndependentMode)) { @@ -2753,7 +2723,7 @@ void Application::reloadResourceCaches() { void Application::rotationModeChanged() { if (!Menu::getInstance()->isOptionChecked(MenuOption::CenterPlayerInView)) { - _myAvatar->setHeadPitch(0); + getMyAvatar()->setHeadPitch(0); } } @@ -2839,8 +2809,9 @@ void Application::update(float deltaTime) { } + auto myAvatar = getMyAvatar(); auto userInputMapper = DependencyManager::get(); - userInputMapper->setSensorToWorldMat(_myAvatar->getSensorToWorldMatrix()); + userInputMapper->setSensorToWorldMat(myAvatar->getSensorToWorldMatrix()); userInputMapper->update(deltaTime); // This needs to go after userInputMapper->update() because of the keyboard @@ -2861,15 +2832,15 @@ void Application::update(float deltaTime) { _controllerScriptingInterface.updateInputControllers(); // Transfer the user inputs to the driveKeys - _myAvatar->clearDriveKeys(); + myAvatar->clearDriveKeys(); if (_myCamera.getMode() != CAMERA_MODE_INDEPENDENT) { if (!_controllerScriptingInterface.areActionsCaptured()) { - _myAvatar->setDriveKeys(FWD, userInputMapper->getActionState(UserInputMapper::LONGITUDINAL_FORWARD)); - _myAvatar->setDriveKeys(BACK, userInputMapper->getActionState(UserInputMapper::LONGITUDINAL_BACKWARD)); - _myAvatar->setDriveKeys(UP, userInputMapper->getActionState(UserInputMapper::VERTICAL_UP)); - _myAvatar->setDriveKeys(DOWN, userInputMapper->getActionState(UserInputMapper::VERTICAL_DOWN)); - _myAvatar->setDriveKeys(LEFT, userInputMapper->getActionState(UserInputMapper::LATERAL_LEFT)); - _myAvatar->setDriveKeys(RIGHT, userInputMapper->getActionState(UserInputMapper::LATERAL_RIGHT)); + myAvatar->setDriveKeys(FWD, userInputMapper->getActionState(UserInputMapper::LONGITUDINAL_FORWARD)); + myAvatar->setDriveKeys(BACK, userInputMapper->getActionState(UserInputMapper::LONGITUDINAL_BACKWARD)); + myAvatar->setDriveKeys(UP, userInputMapper->getActionState(UserInputMapper::VERTICAL_UP)); + myAvatar->setDriveKeys(DOWN, userInputMapper->getActionState(UserInputMapper::VERTICAL_DOWN)); + myAvatar->setDriveKeys(LEFT, userInputMapper->getActionState(UserInputMapper::LATERAL_LEFT)); + myAvatar->setDriveKeys(RIGHT, userInputMapper->getActionState(UserInputMapper::LATERAL_RIGHT)); if (deltaTime > FLT_EPSILON) { // For rotations what we really want are meausures of "angles per second" (in order to prevent // fps-dependent spin rates) so we need to scale the units of the controller contribution. @@ -2877,14 +2848,14 @@ void Application::update(float deltaTime) { // controllers to provide a delta_per_second value rather than a raw delta.) const float EXPECTED_FRAME_RATE = 60.0f; float timeFactor = EXPECTED_FRAME_RATE * deltaTime; - _myAvatar->setDriveKeys(ROT_UP, userInputMapper->getActionState(UserInputMapper::PITCH_UP) / timeFactor); - _myAvatar->setDriveKeys(ROT_DOWN, userInputMapper->getActionState(UserInputMapper::PITCH_DOWN) / timeFactor); - _myAvatar->setDriveKeys(ROT_LEFT, userInputMapper->getActionState(UserInputMapper::YAW_LEFT) / timeFactor); - _myAvatar->setDriveKeys(ROT_RIGHT, userInputMapper->getActionState(UserInputMapper::YAW_RIGHT) / timeFactor); + myAvatar->setDriveKeys(ROT_UP, userInputMapper->getActionState(UserInputMapper::PITCH_UP) / timeFactor); + myAvatar->setDriveKeys(ROT_DOWN, userInputMapper->getActionState(UserInputMapper::PITCH_DOWN) / timeFactor); + myAvatar->setDriveKeys(ROT_LEFT, userInputMapper->getActionState(UserInputMapper::YAW_LEFT) / timeFactor); + myAvatar->setDriveKeys(ROT_RIGHT, userInputMapper->getActionState(UserInputMapper::YAW_RIGHT) / timeFactor); } } - _myAvatar->setDriveKeys(BOOM_IN, userInputMapper->getActionState(UserInputMapper::BOOM_IN)); - _myAvatar->setDriveKeys(BOOM_OUT, userInputMapper->getActionState(UserInputMapper::BOOM_OUT)); + myAvatar->setDriveKeys(BOOM_IN, userInputMapper->getActionState(UserInputMapper::BOOM_IN)); + myAvatar->setDriveKeys(BOOM_OUT, userInputMapper->getActionState(UserInputMapper::BOOM_OUT)); } UserInputMapper::PoseValue leftHand = userInputMapper->getPoseState(UserInputMapper::LEFT_HAND); UserInputMapper::PoseValue rightHand = userInputMapper->getPoseState(UserInputMapper::RIGHT_HAND); @@ -2906,7 +2877,7 @@ void Application::update(float deltaTime) { { PerformanceTimer perfTimer("physics"); - _myAvatar->relayDriveKeysToCharacterController(); + myAvatar->relayDriveKeysToCharacterController(); static VectorOfMotionStates motionStates; _entitySimulation.getObjectsToDelete(motionStates); @@ -3025,7 +2996,7 @@ void Application::update(float deltaTime) { } // update sensorToWorldMatrix for rendering camera. - _myAvatar->updateSensorToWorldMatrix(); + myAvatar->updateSensorToWorldMatrix(); } @@ -3336,6 +3307,14 @@ PickRay Application::computePickRay(float x, float y) const { return result; } +MyAvatar* Application::getMyAvatar() const { + return DependencyManager::get()->getMyAvatar(); +} + +const glm::vec3& Application::getAvatarPosition() const { + return getMyAvatar()->getPosition(); +} + QImage Application::renderAvatarBillboard(RenderArgs* renderArgs) { const int BILLBOARD_SIZE = 64; @@ -3530,9 +3509,10 @@ void Application::displaySide(RenderArgs* renderArgs, Camera& theCamera, bool se // FIXME: This preRender call is temporary until we create a separate render::scene for the mirror rendering. // Then we can move this logic into the Avatar::simulate call. - _myAvatar->startRender(); - _myAvatar->preRender(renderArgs); - _myAvatar->endRender(); + auto myAvatar = getMyAvatar(); + myAvatar->startRender(); + myAvatar->preRender(renderArgs); + myAvatar->endRender(); activeRenderingThread = QThread::currentThread(); @@ -3646,9 +3626,9 @@ void Application::displaySide(RenderArgs* renderArgs, Camera& theCamera, bool se _renderEngine->setRenderContext(renderContext); // Before the deferred pass, let's try to use the render engine - _myAvatar->startRenderRun(); + myAvatar->startRenderRun(); _renderEngine->run(); - _myAvatar->endRenderRun(); + myAvatar->endRenderRun(); auto engineRC = _renderEngine->getRenderContext(); sceneInterface->setEngineFeedOpaqueItems(engineRC->_numFeedOpaqueItems); @@ -3671,15 +3651,17 @@ void Application::renderRearViewMirror(RenderArgs* renderArgs, const QRect& regi float aspect = (float)region.width() / region.height(); float fov = MIRROR_FIELD_OF_VIEW; + auto myAvatar = getMyAvatar(); + // bool eyeRelativeCamera = false; if (billboard) { fov = BILLBOARD_FIELD_OF_VIEW; // degees - _mirrorCamera.setPosition(_myAvatar->getPosition() + - _myAvatar->getOrientation() * glm::vec3(0.0f, 0.0f, -1.0f) * BILLBOARD_DISTANCE * _myAvatar->getScale()); + _mirrorCamera.setPosition(myAvatar->getPosition() + + myAvatar->getOrientation() * glm::vec3(0.0f, 0.0f, -1.0f) * BILLBOARD_DISTANCE * myAvatar->getScale()); } else if (!AvatarInputs::getInstance()->mirrorZoomed()) { - _mirrorCamera.setPosition(_myAvatar->getChestPosition() + - _myAvatar->getOrientation() * glm::vec3(0.0f, 0.0f, -1.0f) * MIRROR_REARVIEW_BODY_DISTANCE * _myAvatar->getScale()); + _mirrorCamera.setPosition(myAvatar->getChestPosition() + + myAvatar->getOrientation() * glm::vec3(0.0f, 0.0f, -1.0f) * MIRROR_REARVIEW_BODY_DISTANCE * myAvatar->getScale()); } else { // HEAD zoom level // FIXME note that the positioing of the camera relative to the avatar can suffer limited @@ -3698,11 +3680,11 @@ void Application::renderRearViewMirror(RenderArgs* renderArgs, const QRect& regi // This was removed in commit 71e59cfa88c6563749594e25494102fe01db38e9 but could be further // investigated in order to adapt the technique while fixing the head rendering issue, // but the complexity of the hack suggests that a better approach - _mirrorCamera.setPosition(_myAvatar->getDefaultEyePosition() + - _myAvatar->getOrientation() * glm::vec3(0.0f, 0.0f, -1.0f) * MIRROR_REARVIEW_DISTANCE * _myAvatar->getScale()); + _mirrorCamera.setPosition(myAvatar->getDefaultEyePosition() + + myAvatar->getOrientation() * glm::vec3(0.0f, 0.0f, -1.0f) * MIRROR_REARVIEW_DISTANCE * myAvatar->getScale()); } _mirrorCamera.setProjection(glm::perspective(glm::radians(fov), aspect, DEFAULT_NEAR_CLIP, DEFAULT_FAR_CLIP)); - _mirrorCamera.setRotation(_myAvatar->getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PI, 0.0f))); + _mirrorCamera.setRotation(myAvatar->getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PI, 0.0f))); // set the bounds of rear mirror view @@ -3736,7 +3718,7 @@ void Application::resetSensors() { QPoint windowCenter = mainWindow->geometry().center(); _glWidget->cursor().setPos(currentScreen, windowCenter); - _myAvatar->reset(); + getMyAvatar()->reset(); QMetaObject::invokeMethod(DependencyManager::get().data(), "reset", Qt::QueuedConnection); } @@ -3819,7 +3801,7 @@ void Application::connectedToDomain(const QString& hostname) { void Application::nodeAdded(SharedNodePointer node) { if (node->getType() == NodeType::AvatarMixer) { // new avatar mixer, send off our identity packet right away - _myAvatar->sendIdentityPacket(); + getMyAvatar()->sendIdentityPacket(); } else if (node->getType() == NodeType::AssetServer) { // the addition of an asset-server always re-enables the upload to asset server menu option Menu::getInstance()->getActionForOption(MenuOption::UploadAsset)->setEnabled(true); @@ -4008,7 +3990,7 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri AvatarManager::registerMetaTypes(scriptEngine); // hook our avatar and avatar hash map object into this script engine - scriptEngine->registerGlobalObject("MyAvatar", _myAvatar); + scriptEngine->registerGlobalObject("MyAvatar", getMyAvatar()); qScriptRegisterMetaType(scriptEngine, audioListenModeToScriptValue, audioListenModeFromScriptValue); scriptEngine->registerGlobalObject("AvatarList", DependencyManager::get().data()); @@ -4181,7 +4163,7 @@ bool Application::askToSetAvatarUrl(const QString& url) { msgBox.exec(); if (msgBox.clickedButton() == bodyAndHeadButton) { - _myAvatar->useFullAvatarURL(url, modelName); + getMyAvatar()->useFullAvatarURL(url, modelName); emit fullAvatarURLChanged(url, modelName); } else { qCDebug(interfaceapp) << "Declined to use the avatar: " << url; @@ -4309,8 +4291,8 @@ void Application::stopAllScripts(bool restart) { // HACK: ATM scripts cannot set/get their animation priorities, so we clear priorities // whenever a script stops in case it happened to have been setting joint rotations. // TODO: expose animation priorities and provide a layered animation control system. - _myAvatar->clearJointAnimationPriorities(); - _myAvatar->clearScriptableSettings(); + getMyAvatar()->clearJointAnimationPriorities(); + getMyAvatar()->clearScriptableSettings(); } bool Application::stopScript(const QString& scriptHash, bool restart) { @@ -4328,10 +4310,10 @@ bool Application::stopScript(const QString& scriptHash, bool restart) { // HACK: ATM scripts cannot set/get their animation priorities, so we clear priorities // whenever a script stops in case it happened to have been setting joint rotations. // TODO: expose animation priorities and provide a layered animation control system. - _myAvatar->clearJointAnimationPriorities(); + getMyAvatar()->clearJointAnimationPriorities(); } if (_scriptEnginesHash.empty()) { - _myAvatar->clearScriptableSettings(); + getMyAvatar()->clearScriptableSettings(); } return stoppedScript; } @@ -4390,22 +4372,6 @@ void Application::openUrl(const QUrl& url) { } } -void Application::updateMyAvatarTransform() { - const float SIMULATION_OFFSET_QUANTIZATION = 16.0f; // meters - glm::vec3 avatarPosition = _myAvatar->getPosition(); - glm::vec3 physicsWorldOffset = _physicsEngine->getOriginOffset(); - if (glm::distance(avatarPosition, physicsWorldOffset) > SIMULATION_OFFSET_QUANTIZATION) { - glm::vec3 newOriginOffset = avatarPosition; - int halfExtent = (int)HALF_SIMULATION_EXTENT; - for (int i = 0; i < 3; ++i) { - newOriginOffset[i] = (float)(glm::max(halfExtent, - ((int)(avatarPosition[i] / SIMULATION_OFFSET_QUANTIZATION)) * (int)SIMULATION_OFFSET_QUANTIZATION)); - } - // TODO: Andrew to replace this with method that actually moves existing object positions in PhysicsEngine - _physicsEngine->setOriginOffset(newOriginOffset); - } -} - void Application::domainSettingsReceived(const QJsonObject& domainSettingsObject) { // from the domain-handler, figure out the satoshi cost per voxel and per meter cubed const QString VOXEL_SETTINGS_KEY = "voxels"; @@ -4584,7 +4550,7 @@ void Application::notifyPacketVersionMismatch() { } void Application::checkSkeleton() { - if (_myAvatar->getSkeletonModel().isActive() && !_myAvatar->getSkeletonModel().hasSkeleton()) { + if (getMyAvatar()->getSkeletonModel().isActive() && !getMyAvatar()->getSkeletonModel().hasSkeleton()) { qCDebug(interfaceapp) << "MyAvatar model has no skeleton"; QString message = "Your selected avatar body has no skeleton.\n\nThe default body will be loaded..."; @@ -4594,9 +4560,9 @@ void Application::checkSkeleton() { msgBox.setIcon(QMessageBox::Warning); msgBox.exec(); - _myAvatar->useFullAvatarURL(AvatarData::defaultFullAvatarModelUrl(), DEFAULT_FULL_AVATAR_MODEL_NAME); + getMyAvatar()->useFullAvatarURL(AvatarData::defaultFullAvatarModelUrl(), DEFAULT_FULL_AVATAR_MODEL_NAME); } else { - _physicsEngine->setCharacterController(_myAvatar->getCharacterController()); + _physicsEngine->setCharacterController(getMyAvatar()->getCharacterController()); } } @@ -4956,8 +4922,8 @@ void Application::setPalmData(Hand* hand, UserInputMapper::PoseValue pose, float // transform from sensor space, to world space, to avatar model space. glm::mat4 poseMat = createMatFromQuatAndPos(pose.getRotation(), pose.getTranslation()); - glm::mat4 sensorToWorldMat = _myAvatar->getSensorToWorldMatrix(); - glm::mat4 modelMat = createMatFromQuatAndPos(_myAvatar->getOrientation(), _myAvatar->getPosition()); + glm::mat4 sensorToWorldMat = getMyAvatar()->getSensorToWorldMatrix(); + glm::mat4 modelMat = createMatFromQuatAndPos(getMyAvatar()->getOrientation(), getMyAvatar()->getPosition()); glm::mat4 objectPose = glm::inverse(modelMat) * sensorToWorldMat * poseMat; glm::vec3 position = extractTranslation(objectPose); @@ -5033,7 +4999,7 @@ void Application::emulateMouse(Hand* hand, float click, float shift, int index) } else { // Get directon relative to avatar orientation - glm::vec3 direction = glm::inverse(_myAvatar->getOrientation()) * palm->getFingerDirection(); + glm::vec3 direction = glm::inverse(getMyAvatar()->getOrientation()) * palm->getFingerDirection(); // Get the angles, scaled between (-0.5,0.5) float xAngle = (atan2f(direction.z, direction.x) + (float)M_PI_2); diff --git a/interface/src/Application.h b/interface/src/Application.h index 1afb43a8a3..4df7e42004 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -217,7 +217,7 @@ public: virtual float getSizeScale() const; virtual int getBoundaryLevelAdjust() const; virtual PickRay computePickRay(float x, float y) const; - virtual const glm::vec3& getAvatarPosition() const { return _myAvatar->getPosition(); } + virtual const glm::vec3& getAvatarPosition() const; virtual void overrideEnvironmentData(const EnvironmentData& newData) { _environment.override(newData); } virtual void endOverrideEnvironmentData() { _environment.endOverride(); } virtual qreal getDevicePixelRatio(); @@ -235,8 +235,6 @@ public: QStringList getRunningScripts() { return _scriptEnginesHash.keys(); } ScriptEngine* getScriptEngine(const QString& scriptHash) { return _scriptEnginesHash.value(scriptHash, NULL); } - - bool isLookingAtMyAvatar(AvatarSharedPointer avatar); float getRenderResolutionScale() const; int getRenderAmbientLight() const; @@ -276,7 +274,6 @@ public: void updateMyAvatarLookAtPosition(); AvatarUpdate* getAvatarUpdater() { return _avatarUpdate; } - MyAvatar* getMyAvatar() { return _myAvatar; } float getAvatarSimrate(); void setAvatarSimrateSample(float sample); @@ -336,7 +333,6 @@ public slots: void openUrl(const QUrl& url); - void updateMyAvatarTransform(); void setAvatarUpdateThreading(); void setAvatarUpdateThreading(bool isThreaded); void setRawAvatarUpdateThreading(); @@ -383,10 +379,6 @@ private slots: void rotationModeChanged(); - void closeMirrorView(); - void restoreMirrorView(); - void shrinkMirrorView(); - void manageRunningScriptsWidgetVisibility(bool shown); void runTests(); @@ -425,6 +417,8 @@ private: void renderRearViewMirror(RenderArgs* renderArgs, const QRect& region, bool billboard = false); int sendNackPackets(); + + MyAvatar* getMyAvatar() const; bool _dependencyManagerIsSetup; @@ -463,7 +457,6 @@ private: OctreeQuery _octreeQuery; // NodeData derived class for querying octee cells from octree servers KeyboardMouseDevice* _keyboardMouseDevice{ nullptr }; // Default input device, the good old keyboard mouse and maybe touchpad - MyAvatar* _myAvatar; // TODO: move this and relevant code to AvatarManager (or MyAvatar as the case may be) AvatarUpdate* _avatarUpdate {nullptr}; SimpleMovingAverage _avatarSimsPerSecond {10}; int _avatarSimsPerSecondReport {0}; diff --git a/interface/src/avatar/Avatar.cpp b/interface/src/avatar/Avatar.cpp index a7a4879403..ddee5dfc1f 100644 --- a/interface/src/avatar/Avatar.cpp +++ b/interface/src/avatar/Avatar.cpp @@ -245,6 +245,14 @@ void Avatar::simulate(float deltaTime) { measureMotionDerivatives(deltaTime); } +bool Avatar::isLookingAtMe(AvatarSharedPointer avatar) { + const float HEAD_SPHERE_RADIUS = 0.1f; + glm::vec3 theirLookAt = dynamic_pointer_cast(avatar)->getHead()->getLookAtPosition(); + glm::vec3 myEyePosition = getHead()->getEyePosition(); + + return glm::distance(theirLookAt, myEyePosition) <= (HEAD_SPHERE_RADIUS * getScale()); +} + void Avatar::slamPosition(const glm::vec3& newPosition) { setPosition(newPosition); _positionDeltaAccumulator = glm::vec3(0.0f); diff --git a/interface/src/avatar/Avatar.h b/interface/src/avatar/Avatar.h index 2515f260a1..1800f4fdd1 100644 --- a/interface/src/avatar/Avatar.h +++ b/interface/src/avatar/Avatar.h @@ -80,7 +80,7 @@ public: typedef render::Payload Payload; typedef std::shared_ptr PayloadPointer; - + void init(); void simulate(float deltaTime); @@ -201,7 +201,9 @@ protected: glm::vec3 _worldUpDirection; float _stringLength; bool _moving; ///< set when position is changing - + + bool isLookingAtMe(AvatarSharedPointer avatar); + // protected methods... glm::vec3 getBodyRightDirection() const { return getOrientation() * IDENTITY_RIGHT; } glm::vec3 getBodyUpDirection() const { return getOrientation() * IDENTITY_UP; } diff --git a/interface/src/avatar/AvatarUpdate.cpp b/interface/src/avatar/AvatarUpdate.cpp index 909d3a7bb9..acdb251950 100644 --- a/interface/src/avatar/AvatarUpdate.cpp +++ b/interface/src/avatar/AvatarUpdate.cpp @@ -33,7 +33,7 @@ void AvatarUpdate::synchronousProcess() { _headPose = qApp->getActiveDisplayPlugin()->getHeadPose(); if (_updateBillboard) { - qApp->getMyAvatar()->doUpdateBillboard(); + DependencyManager::get()->getMyAvatar()->doUpdateBillboard(); } if (!isThreaded()) { diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index 6ed2cf9ad0..60f7857f27 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -1025,7 +1025,7 @@ void MyAvatar::updateLookAtTargetAvatar() { _targetAvatarPosition = avatarPointer->getPosition(); smallestAngleTo = angleTo; } - if (qApp->isLookingAtMyAvatar(avatar)) { + if (isLookingAtMe(avatar)) { // Alter their gaze to look directly at my camera; this looks more natural than looking at my avatar's face. glm::vec3 lookAtPosition = avatar->getHead()->getLookAtPosition(); // A position, in world space, on my avatar. From 60ebd3a544d2866257c80fc3183fd26d488a8a1c Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Fri, 2 Oct 2015 19:42:06 -0700 Subject: [PATCH 22/33] Remove unused members (Mostly mouse stuff) --- interface/src/Application.cpp | 109 +------------- interface/src/Application.h | 162 +++++++++------------ interface/src/ui/ApplicationCompositor.cpp | 2 +- 3 files changed, 69 insertions(+), 204 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index b1ca987640..cb6ce018c5 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -11,8 +11,6 @@ #include "Application.h" -#include - #include #include #include @@ -363,10 +361,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : _scaleMirror(1.0f), _rotateMirror(0.0f), _raiseMirror(0.0f), - _lastMouseMove(usecTimestampNow()), _lastMouseMoveWasSimulated(false), - _isTouchPressed(false), - _mousePressed(false), _enableProcessOctreeThread(true), _runningScriptsWidget(NULL), _runningScriptsWidgetWasVisible(false), @@ -1724,7 +1719,7 @@ void Application::keyPressEvent(QKeyEvent* event) { if (!event->isAutoRepeat()) { // this starts an HFActionEvent HFActionEvent startActionEvent(HFActionEvent::startType(), - computePickRay(getTrueMouseX(), getTrueMouseY())); + computePickRay(getTrueMouse().x, getTrueMouse().y)); sendEvent(this, &startActionEvent); } @@ -1775,7 +1770,7 @@ void Application::keyReleaseEvent(QKeyEvent* event) { if (!event->isAutoRepeat()) { // this ends the HFActionEvent HFActionEvent endActionEvent(HFActionEvent::endType(), - computePickRay(getTrueMouseX(), getTrueMouseY())); + computePickRay(getTrueMouse().x, getTrueMouse().y)); sendEvent(this, &endActionEvent); } break; @@ -1817,9 +1812,6 @@ void Application::mouseMoveEvent(QMouseEvent* event, unsigned int deviceID) { PROFILE_RANGE(__FUNCTION__); // Used by application overlay to determine how to draw cursor(s) _lastMouseMoveWasSimulated = deviceID > 0; - if (!_lastMouseMoveWasSimulated) { - _lastMouseMove = usecTimestampNow(); - } if (_aboutToQuit) { return; @@ -1897,9 +1889,6 @@ void Application::mousePressEvent(QMouseEvent* event, unsigned int deviceID) { } if (event->button() == Qt::LeftButton) { - _mouseDragStarted = getTrueMouse(); - _mousePressed = true; - // nobody handled this - make it an action event on the _window object HFActionEvent actionEvent(HFActionEvent::startType(), computePickRay(event->x(), event->y())); @@ -1955,8 +1944,6 @@ void Application::mouseReleaseEvent(QMouseEvent* event, unsigned int deviceID) { } if (event->button() == Qt::LeftButton) { - _mousePressed = false; - // fire an action end event HFActionEvent actionEvent(HFActionEvent::endType(), computePickRay(event->x(), event->y())); @@ -1982,24 +1969,6 @@ void Application::touchUpdateEvent(QTouchEvent* event) { if (Menu::getInstance()->isOptionChecked(KeyboardMouseDevice::NAME)) { _keyboardMouseDevice->touchUpdateEvent(event); } - - bool validTouch = false; - if (hasFocus()) { - const QList& tPoints = event->touchPoints(); - _touchAvg = vec2(); - int numTouches = tPoints.count(); - if (numTouches > 1) { - for (int i = 0; i < numTouches; ++i) { - _touchAvg += toGlm(tPoints[i].pos()); - } - _touchAvg /= (float)(numTouches); - validTouch = true; - } - } - if (!_isTouchPressed) { - _touchDragStartedAvg = _touchAvg; - } - _isTouchPressed = validTouch; } void Application::touchBeginEvent(QTouchEvent* event) { @@ -2037,9 +2006,6 @@ void Application::touchEndEvent(QTouchEvent* event) { } // put any application specific touch behavior below here.. - _touchDragStartedAvg = _touchAvg; - _isTouchPressed = false; - } void Application::wheelEvent(QWheelEvent* event) { @@ -2230,19 +2196,6 @@ void Application::setLowVelocityFilter(bool lowVelocityFilter) { InputDevice::setLowVelocityFilter(lowVelocityFilter); } -bool Application::mouseOnScreen() const { - glm::ivec2 mousePosition = getTrueMouse(); - return (glm::all(glm::greaterThanEqual(mousePosition, glm::ivec2(0))) && - glm::all(glm::lessThanEqual(mousePosition, glm::ivec2(getCanvasSize())))); -} - -ivec2 Application::getMouseDragStarted() const { - if (isHMDMode()) { - return _compositor.screenToOverlay(getTrueMouseDragStarted()); - } - return getTrueMouseDragStarted(); -} - ivec2 Application::getMouse() const { if (isHMDMode()) { return _compositor.screenToOverlay(getTrueMouse()); @@ -2250,11 +2203,6 @@ ivec2 Application::getMouse() const { return getTrueMouse(); } - -ivec2 Application::getTrueMouseDragStarted() const { - return _mouseDragStarted; -} - FaceTracker* Application::getActiveFaceTracker() { auto faceshift = DependencyManager::get(); auto dde = DependencyManager::get(); @@ -2551,29 +2499,6 @@ void Application::updateLOD() { } } -void Application::updateMouseRay() { - PerformanceTimer perfTimer("mouseRay"); - - bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); - PerformanceWarning warn(showWarnings, "Application::updateMouseRay()"); - - // make sure the frustum is up-to-date - loadViewFrustum(_myCamera, _viewFrustum); - - PickRay pickRay = computePickRay(getTrueMouseX(), getTrueMouseY()); - _mouseRayOrigin = pickRay.origin; - _mouseRayDirection = pickRay.direction; - - // adjust for mirroring - if (_myCamera.getMode() == CAMERA_MODE_MIRROR) { - glm::vec3 mouseRayOffset = _mouseRayOrigin - _viewFrustum.getPosition(); - _mouseRayOrigin -= 2.0f * (_viewFrustum.getDirection() * glm::dot(_viewFrustum.getDirection(), mouseRayOffset) + - _viewFrustum.getRight() * glm::dot(_viewFrustum.getRight(), mouseRayOffset)); - _mouseRayDirection -= 2.0f * (_viewFrustum.getDirection() * glm::dot(_viewFrustum.getDirection(), _mouseRayDirection) + - _viewFrustum.getRight() * glm::dot(_viewFrustum.getRight(), _mouseRayDirection)); - } -} - // Called during Application::update immediately before AvatarManager::updateMyAvatar, updating my data that is then sent to everyone. // (Maybe this code should be moved there?) // The principal result is to call updateLookAtTargetAvatar() and then setLookAtPosition(). @@ -2727,12 +2652,6 @@ void Application::rotationModeChanged() { } } -void Application::updateCamera(float deltaTime) { - PerformanceTimer perfTimer("updateCamera"); - bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); - PerformanceWarning warn(showWarnings, "Application::updateCamera()"); -} - void Application::updateDialogs(float deltaTime) { PerformanceTimer perfTimer("updateDialogs"); bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); @@ -2757,22 +2676,11 @@ void Application::updateDialogs(float deltaTime) { } } -void Application::updateCursor(float deltaTime) { - PerformanceTimer perfTimer("updateCursor"); - bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); - PerformanceWarning warn(showWarnings, "Application::updateCursor()"); - - static QPoint lastMousePos = QPoint(); - _lastMouseMove = (lastMousePos == QCursor::pos()) ? _lastMouseMove : usecTimestampNow(); - lastMousePos = QCursor::pos(); -} - void Application::update(float deltaTime) { bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); PerformanceWarning warn(showWarnings, "Application::update()"); updateLOD(); - updateMouseRay(); // check what's under the mouse and update the mouse voxel { PerformanceTimer perfTimer("devices"); @@ -2870,10 +2778,7 @@ void Application::update(float deltaTime) { } updateThreads(deltaTime); // If running non-threaded, then give the threads some time to process... - - updateCamera(deltaTime); // handle various camera tweaks like off axis projection updateDialogs(deltaTime); // update various stats dialogs if present - updateCursor(deltaTime); // Handle cursor updates { PerformanceTimer perfTimer("physics"); @@ -4334,14 +4239,6 @@ void Application::loadDefaultScripts() { } } -void Application::manageRunningScriptsWidgetVisibility(bool shown) { - if (_runningScriptsWidgetWasVisible && shown) { - _runningScriptsWidget->show(); - } else if (_runningScriptsWidgetWasVisible && !shown) { - _runningScriptsWidget->hide(); - } -} - void Application::toggleRunningScriptsWidget() { if (_runningScriptsWidget->isVisible()) { if (_runningScriptsWidget->hasFocus()) { @@ -4624,7 +4521,7 @@ QSize Application::getDeviceSize() const { } PickRay Application::computePickRay() const { - return computePickRay(getTrueMouseX(), getTrueMouseY()); + return computePickRay(getTrueMouse().x, getTrueMouse().y); } bool Application::isThrottleRendering() const { diff --git a/interface/src/Application.h b/interface/src/Application.h index 4df7e42004..68cfc6aeaf 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -111,27 +111,6 @@ public: void paintGL(); void resizeGL(); - void resizeEvent(QResizeEvent * size); - - void keyPressEvent(QKeyEvent* event); - void keyReleaseEvent(QKeyEvent* event); - - void focusOutEvent(QFocusEvent* event); - void focusInEvent(QFocusEvent* event); - - void mouseMoveEvent(QMouseEvent* event, unsigned int deviceID = 0); - void mousePressEvent(QMouseEvent* event, unsigned int deviceID = 0); - void mouseDoublePressEvent(QMouseEvent* event, unsigned int deviceID = 0); - void mouseReleaseEvent(QMouseEvent* event, unsigned int deviceID = 0); - - void touchBeginEvent(QTouchEvent* event); - void touchEndEvent(QTouchEvent* event); - void touchUpdateEvent(QTouchEvent* event); - - void wheelEvent(QWheelEvent* event); - void dropEvent(QDropEvent* event); - void dragEnterEvent(QDragEnterEvent* event); - bool event(QEvent* event); bool eventFilter(QObject* object, QEvent* event); @@ -162,25 +141,8 @@ public: EntityTreeRenderer* getEntityClipboardRenderer() { return &_entityClipboardRenderer; } EntityEditPacketSender* getEntityEditPacketSender() { return &_entityEditSender; } - bool isMousePressed() const { return _mousePressed; } - const glm::vec3& getMouseRayOrigin() const { return _mouseRayOrigin; } - const glm::vec3& getMouseRayDirection() const { return _mouseRayDirection; } - bool mouseOnScreen() const; - ivec2 getMouse() const; ivec2 getTrueMouse() const; - ivec2 getMouseDragStarted() const; - ivec2 getTrueMouseDragStarted() const; - - // TODO get rid of these and use glm types directly - int getMouseX() const { return getMouse().x; } - int getMouseY() const { return getMouse().y; } - int getTrueMouseX() const { return getTrueMouse().x; } - int getTrueMouseY() const { return getTrueMouse().y; } - int getMouseDragStartedX() const { return getMouseDragStarted().x; } - int getMouseDragStartedY() const { return getMouseDragStarted().y; } - int getTrueMouseDragStartedX() const { return getTrueMouseDragStarted().x; } - int getTrueMouseDragStartedY() const { return getTrueMouseDragStarted().y; } bool getLastMouseMoveWasSimulated() const { return _lastMouseMoveWasSimulated; } FaceTracker* getActiveFaceTracker(); @@ -199,8 +161,6 @@ public: float getFieldOfView() { return _fieldOfView.get(); } void setFieldOfView(float fov) { _fieldOfView.set(fov); } - bool importSVOFromURL(const QString& urlString); - NodeToOctreeSceneStats* getOcteeSceneStats() { return &_octreeServerSceneStats; } ToolWindow* getToolWindow() { return _toolWindow ; } @@ -210,8 +170,6 @@ public: QImage renderAvatarBillboard(RenderArgs* renderArgs); - void displaySide(RenderArgs* renderArgs, Camera& whichCamera, bool selfAvatarOnly = false, bool billboard = false); - virtual ViewFrustum* getCurrentViewFrustum() { return getDisplayViewFrustum(); } virtual QThread* getMainThread() { return thread(); } virtual float getSizeScale() const; @@ -237,7 +195,6 @@ public: ScriptEngine* getScriptEngine(const QString& scriptHash) { return _scriptEnginesHash.value(scriptHash, NULL); } float getRenderResolutionScale() const; - int getRenderAmbientLight() const; bool isAboutToQuit() const { return _aboutToQuit; } @@ -258,7 +215,6 @@ public: QString getScriptsLocation(); void setScriptsLocation(const QString& scriptsLocation); - void initializeAcceptedFiles(); bool canAcceptURL(const QString& url); bool acceptURL(const QString& url); @@ -293,15 +249,6 @@ signals: void activeDisplayPluginChanged(); public slots: - void setSessionUUID(const QUuid& sessionUUID); - void domainChanged(const QString& domainHostname); - void updateWindowTitle(); - void nodeAdded(SharedNodePointer node); - void nodeKilled(SharedNodePointer node); - void packetSent(quint64 length); - void updateDisplayMode(); - void updateInputModes(); - QVector pasteEntities(float x, float y, float z); bool exportEntities(const QString& filename, const QVector& entityIDs); bool exportEntities(const QString& filename, float x, float y, float z, float scale); @@ -311,21 +258,15 @@ public slots: void loadDialog(); void loadScriptURLDialog(); void toggleLogDialog(); - bool acceptSnapshot(const QString& urlString); - bool askToSetAvatarUrl(const QString& url); - bool askToLoadScript(const QString& scriptFilenameOrURL); ScriptEngine* loadScript(const QString& scriptFilename = QString(), bool isUserLoaded = true, bool loadScriptFromEditor = false, bool activateMainWindow = false, bool reload = false); - void reloadScript(const QString& scriptName, bool isUserLoaded = true); - void scriptFinished(const QString& scriptName); void stopAllScripts(bool restart = false); bool stopScript(const QString& scriptHash, bool restart = false); void reloadAllScripts(); void reloadOneScript(const QString& scriptName); void loadDefaultScripts(); void toggleRunningScriptsWidget(); - void saveScripts(); void showFriendsWindow(); @@ -338,8 +279,6 @@ public slots: void setRawAvatarUpdateThreading(); void setRawAvatarUpdateThreading(bool isThreaded); - void domainSettingsReceived(const QJsonObject& domainSettingsObject); - void resetSensors(); void setActiveFaceTracker(); @@ -353,19 +292,16 @@ public slots: void aboutApp(); void showEditEntitiesHelp(); - void loadSettings(); - void saveSettings(); - - void notifyPacketVersionMismatch(); - - void handleDomainConnectionDeniedPacket(QSharedPointer packet); - void cameraMenuChanged(); void reloadResourceCaches(); void crashApplication(); - + + void rotationModeChanged(); + + void runTests(); + private slots: void clearDomainOctreeDetails(); void checkFPS(); @@ -377,17 +313,36 @@ private slots: void connectedToDomain(const QString& hostname); - void rotationModeChanged(); - - void manageRunningScriptsWidgetVisibility(bool shown); - - void runTests(); - void audioMuteToggled(); void faceTrackerMuteToggled(); void activeChanged(Qt::ApplicationState state); - + + void domainSettingsReceived(const QJsonObject& domainSettingsObject); + void handleDomainConnectionDeniedPacket(QSharedPointer packet); + + void notifyPacketVersionMismatch(); + + void loadSettings(); + void saveSettings(); + + void scriptFinished(const QString& scriptName); + void saveScripts(); + void reloadScript(const QString& scriptName, bool isUserLoaded = true); + + bool acceptSnapshot(const QString& urlString); + bool askToSetAvatarUrl(const QString& url); + bool askToLoadScript(const QString& scriptFilenameOrURL); + + void setSessionUUID(const QUuid& sessionUUID); + void domainChanged(const QString& domainHostname); + void updateWindowTitle(); + void nodeAdded(SharedNodePointer node); + void nodeKilled(SharedNodePointer node); + void packetSent(quint64 length); + void updateDisplayMode(); + void updateInputModes(); + private: void initDisplay(); void init(); @@ -403,11 +358,8 @@ private: // Various helper functions called during update() void updateLOD(); - void updateMouseRay(); void updateThreads(float deltaTime); - void updateCamera(float deltaTime); void updateDialogs(float deltaTime); - void updateCursor(float deltaTime); void queryOctree(NodeType_t serverType, PacketType packetType, NodeToJurisdictionMap& jurisdictions); void loadViewFrustum(Camera& camera, ViewFrustum& viewFrustum); @@ -418,7 +370,41 @@ private: int sendNackPackets(); + void takeSnapshot(); + MyAvatar* getMyAvatar() const; + + void initializeAcceptedFiles(); + int getRenderAmbientLight() const; + + void displaySide(RenderArgs* renderArgs, Camera& whichCamera, bool selfAvatarOnly = false, bool billboard = false); + + bool importSVOFromURL(const QString& urlString); + + int processOctreeStats(NLPacket& packet, SharedNodePointer sendingNode); + void trackIncomingOctreePacket(NLPacket& packet, SharedNodePointer sendingNode, bool wasStatsPacket); + + void resizeEvent(QResizeEvent* size); + + void keyPressEvent(QKeyEvent* event); + void keyReleaseEvent(QKeyEvent* event); + + void focusOutEvent(QFocusEvent* event); + void focusInEvent(QFocusEvent* event); + + void mouseMoveEvent(QMouseEvent* event, unsigned int deviceID = 0); + void mousePressEvent(QMouseEvent* event, unsigned int deviceID = 0); + void mouseDoublePressEvent(QMouseEvent* event, unsigned int deviceID = 0); + void mouseReleaseEvent(QMouseEvent* event, unsigned int deviceID = 0); + + void touchBeginEvent(QTouchEvent* event); + void touchEndEvent(QTouchEvent* event); + void touchUpdateEvent(QTouchEvent* event); + + void wheelEvent(QWheelEvent* event); + void dropEvent(QDropEvent* event); + void dragEnterEvent(QDragEnterEvent* event); + bool _dependencyManagerIsSetup; @@ -476,21 +462,8 @@ private: Environment _environment; - ivec2 _mouseDragStarted; - - quint64 _lastMouseMove; bool _lastMouseMoveWasSimulated; - glm::vec3 _mouseRayOrigin; - glm::vec3 _mouseRayDirection; - - vec2 _touchAvg; - vec2 _touchDragStartedAvg; - - bool _isTouchPressed; // true if multitouch has been pressed (clear when finished) - - bool _mousePressed; // true if mouse has been pressed (clear when finished) - QSet _keysPressed; bool _enableProcessOctreeThread; @@ -501,9 +474,6 @@ private: StDev _idleLoopStdev; float _idleLoopMeasuredJitter; - int processOctreeStats(NLPacket& packet, SharedNodePointer sendingNode); - void trackIncomingOctreePacket(NLPacket& packet, SharedNodePointer sendingNode, bool wasStatsPacket); - NodeToJurisdictionMap _entityServerJurisdictions; NodeToOctreeSceneStats _octreeServerSceneStats; @@ -513,8 +483,6 @@ private: FileLogger* _logger; - void takeSnapshot(); - TouchEvent _lastTouchEvent; RunningScriptsWidget* _runningScriptsWidget; diff --git a/interface/src/ui/ApplicationCompositor.cpp b/interface/src/ui/ApplicationCompositor.cpp index 5e88a90d71..cb4ae9990c 100644 --- a/interface/src/ui/ApplicationCompositor.cpp +++ b/interface/src/ui/ApplicationCompositor.cpp @@ -429,7 +429,7 @@ void ApplicationCompositor::renderPointers(gpu::Batch& batch) { //If we are in oculus, render reticle later auto trueMouse = qApp->getTrueMouse(); trueMouse /= qApp->getCanvasSize(); - QPoint position = QPoint(qApp->getTrueMouseX(), qApp->getTrueMouseY()); + QPoint position = QPoint(qApp->getTrueMouse().x, qApp->getTrueMouse().y); _reticlePosition[MOUSE] = position; _reticleActive[MOUSE] = true; _magActive[MOUSE] = _magnifier; From 5e9425d9ebb940028bc5c80b402fb81b0c89d98b Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Sun, 4 Oct 2015 19:48:28 -0700 Subject: [PATCH 23/33] Fix view frustum preference --- interface/src/Application.cpp | 24 +++++++++++++++--------- interface/src/Application.h | 2 +- interface/src/avatar/MyAvatar.cpp | 3 +-- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index cb6ce018c5..f6fddc06fd 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1316,6 +1316,13 @@ void Application::faceTrackerMuteToggled() { Menu::getInstance()->getActionForOption(MenuOption::CalibrateCamera)->setEnabled(!isMuted); } +void Application::setFieldOfView(float fov) { + if (fov != _fieldOfView.get()) { + _fieldOfView.set(fov); + resizeGL(); + } +} + void Application::aboutApp() { InfoView::show(INFO_HELP_PATH); } @@ -1342,16 +1349,15 @@ void Application::resizeGL() { if (_renderResolution != renderSize) { _renderResolution = renderSize; DependencyManager::get()->setFrameBufferSize(fromGlm(renderSize)); - - // Possible change in aspect ratio - loadViewFrustum(_myCamera, _viewFrustum); - float fov = glm::radians(DEFAULT_FIELD_OF_VIEW_DEGREES); - // FIXME the aspect ratio for stereo displays is incorrect based on this. - float aspectRatio = displayPlugin->getRecommendedAspectRatio(); - _myCamera.setProjection(glm::perspective(fov, aspectRatio, DEFAULT_NEAR_CLIP, DEFAULT_FAR_CLIP)); } - - + + // FIXME the aspect ratio for stereo displays is incorrect based on this. + float aspectRatio = displayPlugin->getRecommendedAspectRatio(); + _myCamera.setProjection(glm::perspective(glm::radians(_fieldOfView.get()), aspectRatio, + DEFAULT_NEAR_CLIP, DEFAULT_FAR_CLIP)); + // Possible change in aspect ratio + loadViewFrustum(_myCamera, _viewFrustum); + auto offscreenUi = DependencyManager::get(); auto uiSize = displayPlugin->getRecommendedUiSize(); // Bit of a hack since there's no device pixel ratio change event I can find. diff --git a/interface/src/Application.h b/interface/src/Application.h index 68cfc6aeaf..fa736b5ac6 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -159,7 +159,7 @@ public: float getFps() const { return _fps; } float getFieldOfView() { return _fieldOfView.get(); } - void setFieldOfView(float fov) { _fieldOfView.set(fov); } + void setFieldOfView(float fov); NodeToOctreeSceneStats* getOcteeSceneStats() { return &_octreeServerSceneStats; } diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index 60f7857f27..f94362c4e4 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -428,8 +428,7 @@ void MyAvatar::updateFromTrackers(float deltaTime) { head->setDeltaYaw(estimatedRotation.y); head->setDeltaRoll(estimatedRotation.z); } else { - float magnifyFieldOfView = qApp->getFieldOfView() / - _realWorldFieldOfView.get(); + float magnifyFieldOfView = qApp->getViewFrustum()->getFieldOfView() / _realWorldFieldOfView.get(); head->setDeltaPitch(estimatedRotation.x * magnifyFieldOfView); head->setDeltaYaw(estimatedRotation.y * magnifyFieldOfView); head->setDeltaRoll(estimatedRotation.z); From e9b7125894ebc6350f3f111612284e55979849bf Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Sun, 4 Oct 2015 21:11:32 -0700 Subject: [PATCH 24/33] Misc cleanup --- interface/src/Application.cpp | 31 ++++++++++------------- interface/src/Application.h | 8 +++--- interface/src/avatar/MyAvatar.cpp | 2 +- interface/src/devices/3DConnexionClient.h | 2 -- interface/src/ui/PreferencesDialog.cpp | 4 +-- 5 files changed, 21 insertions(+), 26 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index f6fddc06fd..2df1d7a687 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -199,6 +199,13 @@ static const int THROTTLED_SIM_FRAME_PERIOD_MS = MSECS_PER_SECOND / THROTTLED_SI const QString CHECK_VERSION_URL = "https://highfidelity.com/latestVersion.xml"; const QString SKIP_FILENAME = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/hifi.skipversion"; +#ifndef __APPLE__ +static const QString DESKTOP_LOCATION = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation); +#else +// Temporary fix to Qt bug: http://stackoverflow.com/questions/16194475 +static const QString DESKTOP_LOCATION = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation).append("/script.js"); +#endif + const QString DEFAULT_SCRIPTS_JS_URL = "http://s3.amazonaws.com/hifi-public/scripts/defaultScripts.js"; Setting::Handle maxOctreePacketsPerSecond("maxOctreePPS", DEFAULT_MAX_OCTREE_PPS); @@ -355,8 +362,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : _lastQueriedTime(usecTimestampNow()), _mirrorViewRect(QRect(MIRROR_VIEW_LEFT_PADDING, MIRROR_VIEW_TOP_PADDING, MIRROR_VIEW_WIDTH, MIRROR_VIEW_HEIGHT)), _firstRun("firstRun", true), - _previousScriptLocation("LastScriptLocation"), - _scriptsLocationHandle("scriptsLocation"), + _previousScriptLocation("LastScriptLocation", DESKTOP_LOCATION), + _scriptsLocationHandle("scriptsLocation", DESKTOP_LOCATION), _fieldOfView("fieldOfView", DEFAULT_FIELD_OF_VIEW_DEGREES), _scaleMirror(1.0f), _rotateMirror(0.0f), @@ -1005,7 +1012,7 @@ void Application::initializeUi() { return result; }); offscreenUi->resume(); - connect(_window, &MainWindow::windowGeometryChanged, [this](const QRect & r){ + connect(_window, &MainWindow::windowGeometryChanged, [this](const QRect& r){ static qreal oldDevicePixelRatio = 0; qreal devicePixelRatio = getActiveDisplayPlugin()->devicePixelRatio(); if (devicePixelRatio != oldDevicePixelRatio) { @@ -1331,7 +1338,7 @@ void Application::showEditEntitiesHelp() { InfoView::show(INFO_EDIT_ENTITIES_PATH); } -void Application::resizeEvent(QResizeEvent * event) { +void Application::resizeEvent(QResizeEvent* event) { resizeGL(); } @@ -1340,11 +1347,11 @@ void Application::resizeGL() { if (nullptr == _displayPlugin) { return; } - + auto displayPlugin = getActiveDisplayPlugin(); // Set the desired FBO texture size. If it hasn't changed, this does nothing. // Otherwise, it must rebuild the FBOs - uvec2 framebufferSize = getActiveDisplayPlugin()->getRecommendedRenderSize(); + uvec2 framebufferSize = displayPlugin->getRecommendedRenderSize(); uvec2 renderSize = uvec2(vec2(framebufferSize) * getRenderResolutionScale()); if (_renderResolution != renderSize) { _renderResolution = renderSize; @@ -4303,17 +4310,7 @@ void Application::domainSettingsReceived(const QJsonObject& domainSettingsObject } QString Application::getPreviousScriptLocation() { - QString suggestedName; - if (_previousScriptLocation.get().isEmpty()) { - QString desktopLocation = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation); -// Temporary fix to Qt bug: http://stackoverflow.com/questions/16194475 -#ifdef __APPLE__ - suggestedName = desktopLocation.append("/script.js"); -#endif - } else { - suggestedName = _previousScriptLocation.get(); - } - return suggestedName; + return _previousScriptLocation.get(); } void Application::setPreviousScriptLocation(const QString& previousScriptLocation) { diff --git a/interface/src/Application.h b/interface/src/Application.h index fa736b5ac6..8e906c789b 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -451,10 +451,10 @@ private: Camera _mirrorCamera; // Cammera for mirror view QRect _mirrorViewRect; - Setting::Handle _firstRun; - Setting::Handle _previousScriptLocation; - Setting::Handle _scriptsLocationHandle; - Setting::Handle _fieldOfView; + Setting::Handle _firstRun; + Setting::Handle _previousScriptLocation; + Setting::Handle _scriptsLocationHandle; + Setting::Handle _fieldOfView; float _scaleMirror; float _rotateMirror; diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index f94362c4e4..0105d1b648 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -437,7 +437,6 @@ void MyAvatar::updateFromTrackers(float deltaTime) { // Update torso lean distance based on accelerometer data const float TORSO_LENGTH = 0.5f; glm::vec3 relativePosition = estimatedPosition - glm::vec3(0.0f, -TORSO_LENGTH, 0.0f); - const float MAX_LEAN = 45.0f; // Invert left/right lean when in mirror mode // NOTE: this is kinda a hack, it's the same hack we use to make the head tilt. But it's not really a mirror @@ -447,6 +446,7 @@ void MyAvatar::updateFromTrackers(float deltaTime) { relativePosition.x = -relativePosition.x; } + const float MAX_LEAN = 45.0f; head->setLeanSideways(glm::clamp(glm::degrees(atanf(relativePosition.x * _leanScale / TORSO_LENGTH)), -MAX_LEAN, MAX_LEAN)); head->setLeanForward(glm::clamp(glm::degrees(atanf(relativePosition.z * _leanScale / TORSO_LENGTH)), diff --git a/interface/src/devices/3DConnexionClient.h b/interface/src/devices/3DConnexionClient.h index dd5dc7cb08..cdf8e1e2a1 100755 --- a/interface/src/devices/3DConnexionClient.h +++ b/interface/src/devices/3DConnexionClient.h @@ -16,8 +16,6 @@ #include #include "InterfaceLogging.h" -#include "Application.h" - #ifndef HAVE_3DCONNEXIONCLIENT class ConnexionClient : public QObject { diff --git a/interface/src/ui/PreferencesDialog.cpp b/interface/src/ui/PreferencesDialog.cpp index 1b55c6fa2b..f90bac234d 100644 --- a/interface/src/ui/PreferencesDialog.cpp +++ b/interface/src/ui/PreferencesDialog.cpp @@ -183,7 +183,7 @@ void PreferencesDialog::loadPreferences() { ui.outputStarveDetectionThresholdSpinner->setValue(audio->getOutputStarveDetectionThreshold()); ui.outputStarveDetectionPeriodSpinner->setValue(audio->getOutputStarveDetectionPeriod()); - ui.realWorldFieldOfViewSpin->setValue(DependencyManager::get()->getMyAvatar()->getRealWorldFieldOfView()); + ui.realWorldFieldOfViewSpin->setValue(myAvatar->getRealWorldFieldOfView()); ui.fieldOfViewSpin->setValue(qApp->getFieldOfView()); @@ -258,7 +258,7 @@ void PreferencesDialog::savePreferences() { } } - DependencyManager::get()->getMyAvatar()->setRealWorldFieldOfView(ui.realWorldFieldOfViewSpin->value()); + myAvatar->setRealWorldFieldOfView(ui.realWorldFieldOfViewSpin->value()); qApp->setFieldOfView(ui.fieldOfViewSpin->value()); From 39e0d0e1dc6243c100580580860ce1093daaa906 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Sun, 4 Oct 2015 21:12:12 -0700 Subject: [PATCH 25/33] Put timers on the stack --- interface/src/Application.cpp | 63 +++++++++++++---------------------- 1 file changed, 24 insertions(+), 39 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 2df1d7a687..1bef9771eb 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -164,12 +164,12 @@ extern "C" { using namespace std; -static QTimer* locationUpdateTimer = NULL; -static QTimer* balanceUpdateTimer = NULL; -static QTimer* identityPacketTimer = NULL; -static QTimer* billboardPacketTimer = NULL; -static QTimer* checkFPStimer = NULL; -static QTimer* idleTimer = NULL; +static QTimer locationUpdateTimer; +static QTimer balanceUpdateTimer; +static QTimer identityPacketTimer; +static QTimer billboardPacketTimer; +static QTimer checkFPStimer; +static QTimer idleTimer; static const QString SNAPSHOT_EXTENSION = ".jpg"; static const QString SVO_EXTENSION = ".svo"; @@ -489,10 +489,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : // update our location every 5 seconds in the metaverse server, assuming that we are authenticated with one const qint64 DATA_SERVER_LOCATION_CHANGE_UPDATE_MSECS = 5 * 1000; - locationUpdateTimer = new QTimer(this); auto discoverabilityManager = DependencyManager::get(); - connect(locationUpdateTimer, &QTimer::timeout, discoverabilityManager.data(), &DiscoverabilityManager::updateLocation); - locationUpdateTimer->start(DATA_SERVER_LOCATION_CHANGE_UPDATE_MSECS); + connect(&locationUpdateTimer, &QTimer::timeout, discoverabilityManager.data(), &DiscoverabilityManager::updateLocation); + locationUpdateTimer.start(DATA_SERVER_LOCATION_CHANGE_UPDATE_MSECS); // if we get a domain change, immediately attempt update location in metaverse server connect(&nodeList->getDomainHandler(), &DomainHandler::connectedToDomain, @@ -510,9 +509,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : const qint64 BALANCE_UPDATE_INTERVAL_MSECS = 5 * 1000; - balanceUpdateTimer = new QTimer(this); - connect(balanceUpdateTimer, &QTimer::timeout, &accountManager, &AccountManager::updateBalance); - balanceUpdateTimer->start(BALANCE_UPDATE_INTERVAL_MSECS); + connect(&balanceUpdateTimer, &QTimer::timeout, &accountManager, &AccountManager::updateBalance); + balanceUpdateTimer.start(BALANCE_UPDATE_INTERVAL_MSECS); connect(&accountManager, &AccountManager::balanceChanged, this, &Application::updateWindowTitle); @@ -549,14 +547,12 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : connect(&_entityEditSender, &EntityEditPacketSender::packetSent, this, &Application::packetSent); // send the identity packet for our avatar each second to our avatar mixer - identityPacketTimer = new QTimer(); - connect(identityPacketTimer, &QTimer::timeout, getMyAvatar(), &MyAvatar::sendIdentityPacket); - identityPacketTimer->start(AVATAR_IDENTITY_PACKET_SEND_INTERVAL_MSECS); + connect(&identityPacketTimer, &QTimer::timeout, getMyAvatar(), &MyAvatar::sendIdentityPacket); + identityPacketTimer.start(AVATAR_IDENTITY_PACKET_SEND_INTERVAL_MSECS); // send the billboard packet for our avatar every few seconds - billboardPacketTimer = new QTimer(); - connect(billboardPacketTimer, &QTimer::timeout, getMyAvatar(), &MyAvatar::sendBillboardPacket); - billboardPacketTimer->start(AVATAR_BILLBOARD_PACKET_SEND_INTERVAL_MSECS); + connect(&billboardPacketTimer, &QTimer::timeout, getMyAvatar(), &MyAvatar::sendBillboardPacket); + billboardPacketTimer.start(AVATAR_BILLBOARD_PACKET_SEND_INTERVAL_MSECS); QString cachePath = QStandardPaths::writableLocation(QStandardPaths::DataLocation); QNetworkAccessManager& networkAccessManager = NetworkAccessManager::getInstance(); @@ -818,23 +814,14 @@ void Application::cleanupBeforeQuit() { // first stop all timers directly or by invokeMethod // depending on what thread they run in _avatarUpdate->terminate(); - locationUpdateTimer->stop(); - balanceUpdateTimer->stop(); - identityPacketTimer->stop(); - billboardPacketTimer->stop(); - checkFPStimer->stop(); - idleTimer->stop(); + locationUpdateTimer.stop(); + balanceUpdateTimer.stop(); + identityPacketTimer.stop(); + billboardPacketTimer.stop(); + checkFPStimer.stop(); + idleTimer.stop(); QMetaObject::invokeMethod(&_settingsTimer, "stop", Qt::BlockingQueuedConnection); - // and then delete those that got created by "new" - delete locationUpdateTimer; - delete balanceUpdateTimer; - delete identityPacketTimer; - delete billboardPacketTimer; - delete checkFPStimer; - delete idleTimer; - // no need to delete _settingsTimer here as it is no pointer - // save state _settingsThread.quit(); saveSettings(); @@ -964,14 +951,12 @@ void Application::initializeGL() { _entityEditSender.initialize(_enableProcessOctreeThread); // call our timer function every second - checkFPStimer = new QTimer(this); - connect(checkFPStimer, SIGNAL(timeout()), SLOT(checkFPS())); - checkFPStimer->start(1000); + connect(&checkFPStimer, &QTimer::timeout, &Application::checkFPS); + checkFPStimer.start(1000); // call our idle function whenever we can - idleTimer = new QTimer(this); - connect(idleTimer, SIGNAL(timeout()), SLOT(idle())); - idleTimer->start(TARGET_SIM_FRAME_PERIOD_MS); + connect(&idleTimer, &QTimer::timeout, &Application::idle); + idleTimer.start(TARGET_SIM_FRAME_PERIOD_MS); _idleLoopStdev.reset(); // update before the first render From 17edd38cb9e3b2ce0dac32fb2059eb6b77506d5c Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Sun, 4 Oct 2015 21:12:30 -0700 Subject: [PATCH 26/33] Remove unused variables --- interface/src/Application.cpp | 77 ++++++++++++++++------------------- interface/src/Application.h | 1 - 2 files changed, 36 insertions(+), 42 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 1bef9771eb..6d79510cb3 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -300,42 +300,42 @@ bool setupEssentials(int& argc, char** argv) { Setting::init(); // Set dependencies - auto addressManager = DependencyManager::set(); - auto nodeList = DependencyManager::set(NodeType::Agent, listenPort); - auto geometryCache = DependencyManager::set(); - auto modelCache = DependencyManager::set(); - auto scriptCache = DependencyManager::set(); - auto soundCache = DependencyManager::set(); - auto faceshift = DependencyManager::set(); - auto ddeFaceTracker = DependencyManager::set(); - auto eyeTracker = DependencyManager::set(); - auto audio = DependencyManager::set(); - auto audioScope = DependencyManager::set(); - auto deferredLightingEffect = DependencyManager::set(); - auto textureCache = DependencyManager::set(); - auto framebufferCache = DependencyManager::set(); - auto animationCache = DependencyManager::set(); - auto modelBlender = DependencyManager::set(); - auto avatarManager = DependencyManager::set(); - auto lodManager = DependencyManager::set(); - auto jsConsole = DependencyManager::set(); - auto dialogsManager = DependencyManager::set(); - auto bandwidthRecorder = DependencyManager::set(); - auto resourceCacheSharedItems = DependencyManager::set(); - auto desktopScriptingInterface = DependencyManager::set(); - auto entityScriptingInterface = DependencyManager::set(); - auto windowScriptingInterface = DependencyManager::set(); + DependencyManager::set(); + DependencyManager::set(NodeType::Agent, listenPort); + DependencyManager::set(); + DependencyManager::set(); + DependencyManager::set(); + DependencyManager::set(); + DependencyManager::set(); + DependencyManager::set(); + DependencyManager::set(); + DependencyManager::set(); + DependencyManager::set(); + DependencyManager::set(); + DependencyManager::set(); + DependencyManager::set(); + DependencyManager::set(); + DependencyManager::set(); + DependencyManager::set(); + DependencyManager::set(); + DependencyManager::set(); + DependencyManager::set(); + DependencyManager::set(); + DependencyManager::set(); + DependencyManager::set(); + DependencyManager::set(); + DependencyManager::set(); #if defined(Q_OS_MAC) || defined(Q_OS_WIN) - auto speechRecognizer = DependencyManager::set(); + DependencyManager::set(); #endif - auto discoverabilityManager = DependencyManager::set(); - auto sceneScriptingInterface = DependencyManager::set(); - auto offscreenUi = DependencyManager::set(); - auto autoUpdater = DependencyManager::set(); - auto pathUtils = DependencyManager::set(); - auto actionFactory = DependencyManager::set(); - auto assetClient = DependencyManager::set(); - auto userInputMapper = DependencyManager::set(); + DependencyManager::set(); + DependencyManager::set(); + DependencyManager::set(); + DependencyManager::set(); + DependencyManager::set(); + DependencyManager::set(); + DependencyManager::set(); + DependencyManager::set(); return true; } @@ -965,10 +965,6 @@ void Application::initializeGL() { InfoView::show(INFO_HELP_PATH, true); } -QWindow* getProxyWindow() { - return qApp->getWindow()->windowHandle(); -} - void Application::initializeUi() { AddressBarDialog::registerType(); ErrorDialog::registerType(); @@ -4543,7 +4539,7 @@ qreal Application::getDevicePixelRatio() { return (_window && _window->windowHandle()) ? _window->windowHandle()->devicePixelRatio() : 1.0; } -DisplayPlugin * Application::getActiveDisplayPlugin() { +DisplayPlugin* Application::getActiveDisplayPlugin() { if (nullptr == _displayPlugin) { updateDisplayMode(); Q_ASSERT(_displayPlugin); @@ -4551,7 +4547,7 @@ DisplayPlugin * Application::getActiveDisplayPlugin() { return _displayPlugin.data(); } -const DisplayPlugin * Application::getActiveDisplayPlugin() const { +const DisplayPlugin* Application::getActiveDisplayPlugin() const { return ((Application*)this)->getActiveDisplayPlugin(); } @@ -4559,7 +4555,6 @@ bool _activatingDisplayPlugin{ false }; QVector> _currentDisplayPluginActions; QVector> _currentInputPluginActions; - static void addDisplayPluginToMenu(DisplayPluginPointer displayPlugin, bool active = false) { auto menu = Menu::getInstance(); QString name = displayPlugin->getName(); diff --git a/interface/src/Application.h b/interface/src/Application.h index 8e906c789b..23b173f1ea 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -420,7 +420,6 @@ private: UndoStackScriptingInterface _undoStackScriptingInterface; // Frame Rate Measurement - int _frameCount; float _fps; QElapsedTimer _timerStart; From b63df98b8b26972ed39025214c03bccb41c5ec77 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Sun, 4 Oct 2015 21:35:50 -0700 Subject: [PATCH 27/33] More unused --- interface/src/Application.cpp | 5 ++--- interface/src/Application.h | 2 -- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 6d79510cb3..3cfb10c7bb 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -33,7 +33,6 @@ #include #include #include -#include #include #include #include @@ -951,11 +950,11 @@ void Application::initializeGL() { _entityEditSender.initialize(_enableProcessOctreeThread); // call our timer function every second - connect(&checkFPStimer, &QTimer::timeout, &Application::checkFPS); + connect(&checkFPStimer, &QTimer::timeout, this, &Application::checkFPS); checkFPStimer.start(1000); // call our idle function whenever we can - connect(&idleTimer, &QTimer::timeout, &Application::idle); + connect(&idleTimer, &QTimer::timeout, this, &Application::idle); idleTimer.start(TARGET_SIM_FRAME_PERIOD_MS); _idleLoopStdev.reset(); diff --git a/interface/src/Application.h b/interface/src/Application.h index 23b173f1ea..c315dde0ea 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -37,7 +37,6 @@ #include #include - #include "Bookmarks.h" #include "Camera.h" #include "Environment.h" @@ -119,7 +118,6 @@ public: QSize getDeviceSize() const; bool hasFocus() const; PickRay computePickRay() const; - PickRay computeViewPickRay(float xRatio, float yRatio) const; bool isThrottleRendering() const; From 775994f9d0c2298eeea9aceff3bb5f33c9a41bba Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Sun, 4 Oct 2015 22:02:11 -0700 Subject: [PATCH 28/33] Fix for 3DConnection --- interface/src/devices/3DConnexionClient.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/interface/src/devices/3DConnexionClient.cpp b/interface/src/devices/3DConnexionClient.cpp index d49fafa3e0..722fedcc3a 100755 --- a/interface/src/devices/3DConnexionClient.cpp +++ b/interface/src/devices/3DConnexionClient.cpp @@ -10,6 +10,7 @@ // #include "3DConnexionClient.h" +#include "Menu.h" #include "UserActivityLogger.h" const float MAX_AXIS = 75.0f; // max forward = 2x speed From 7b25c9d417ac2cdd67725be6efa7c636f52aa349 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Sun, 4 Oct 2015 23:53:34 -0700 Subject: [PATCH 29/33] More header cleanup --- interface/src/Application.cpp | 84 ++++++++++++++--------------------- interface/src/Application.h | 23 +++++----- 2 files changed, 43 insertions(+), 64 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 3cfb10c7bb..7d1886f10c 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -19,46 +19,34 @@ #include #include -#include -#include +#include +#include #include -#include #include +#include #include #include +#include #include +#include +#include #include -#include #include #include -#include #include #include #include +#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include #include -#include #include -#include -#include +#include #include +#include #include -#include -#include -#include #include - #include #include #include @@ -71,6 +59,7 @@ #include #include #include // this should probably be removed +#include #include #include #include @@ -78,80 +67,73 @@ #include #include #include -#include #include #include -#include +#include #include #include #include +#include +#include +#include #include #include #include #include -#include -#include #include #include #include +#include #include #include -#include #include -#include - -#include "AudioClient.h" -#include "CrashHandler.h" -#include "DiscoverabilityManager.h" -#include "GLCanvas.h" -#include "LODManager.h" -#include "Menu.h" -#include "ModelPackager.h" -#include "Stars.h" -#include "Util.h" -#include "InterfaceLogging.h" -#include "InterfaceActionFactory.h" -#include "PluginContainerProxy.h" #include "AnimDebugDraw.h" - -#include "avatar/AvatarManager.h" +#include "AudioClient.h" #include "audio/AudioScope.h" - +#include "avatar/AvatarManager.h" +#include "CrashHandler.h" +#include "devices/3DConnexionClient.h" #include "devices/DdeFaceTracker.h" #include "devices/EyeTracker.h" #include "devices/Faceshift.h" #include "devices/Leapmotion.h" -#include "devices/RealSense.h" #include "devices/MIDIManager.h" -#include "devices/3DConnexionClient.h" - +#include "devices/RealSense.h" +#include "DiscoverabilityManager.h" +#include "GLCanvas.h" +#include "InterfaceActionFactory.h" +#include "InterfaceLogging.h" +#include "LODManager.h" +#include "Menu.h" +#include "ModelPackager.h" +#include "PluginContainerProxy.h" #include "scripting/AccountScriptingInterface.h" #include "scripting/AudioDeviceScriptingInterface.h" #include "scripting/ClipboardScriptingInterface.h" #include "scripting/DesktopScriptingInterface.h" -#include "scripting/HMDScriptingInterface.h" #include "scripting/GlobalServicesScriptingInterface.h" +#include "scripting/HMDScriptingInterface.h" #include "scripting/LocationScriptingInterface.h" #include "scripting/MenuScriptingInterface.h" #include "scripting/SettingsScriptingInterface.h" -#include "scripting/WindowScriptingInterface.h" #include "scripting/WebWindowClass.h" - +#include "scripting/WindowScriptingInterface.h" #if defined(Q_OS_MAC) || defined(Q_OS_WIN) #include "SpeechRecognizer.h" #endif - +#include "Stars.h" #include "ui/AddressBarDialog.h" #include "ui/AvatarInputs.h" #include "ui/DataWebDialog.h" #include "ui/DialogsManager.h" #include "ui/LoginDialog.h" +#include "ui/overlays/Cube3DOverlay.h" #include "ui/Snapshot.h" #include "ui/StandAloneJSConsole.h" #include "ui/Stats.h" #include "ui/UpdateDialog.h" -#include "ui/overlays/Cube3DOverlay.h" +#include "Util.h" // ON WIndows PC, NVidia Optimus laptop, we want to enable NVIDIA GPU // FIXME seems to be broken. diff --git a/interface/src/Application.h b/interface/src/Application.h index c315dde0ea..ec5133b131 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -33,23 +33,24 @@ #include #include #include +#include #include #include -#include +#include "avatar/AvatarUpdate.h" +#include "avatar/MyAvatar.h" #include "Bookmarks.h" #include "Camera.h" #include "Environment.h" #include "FileLogger.h" +#include "gpu/Context.h" #include "Menu.h" -#include "Physics.h" -#include "avatar/AvatarUpdate.h" -#include "avatar/MyAvatar.h" +#include "octree/OctreePacketProcessor.h" +#include "render/Engine.h" #include "scripting/ControllerScriptingInterface.h" #include "scripting/DialogsManagerScriptingInterface.h" -#include "ui/SnapshotShareDialog.h" -#include "ui/ApplicationOverlay.h" #include "ui/ApplicationCompositor.h" +#include "ui/ApplicationOverlay.h" #include "ui/AudioStatsDialog.h" #include "ui/BandwidthDialog.h" #include "ui/LodToolsDialog.h" @@ -58,14 +59,10 @@ #include "ui/OverlayConductor.h" #include "ui/overlays/Overlays.h" #include "ui/RunningScriptsWidget.h" +#include "ui/SnapshotShareDialog.h" #include "ui/ToolWindow.h" -#include "octree/OctreePacketProcessor.h" #include "UndoStackScriptingInterface.h" -#include "gpu/Context.h" - -#include "render/Engine.h" - class OffscreenGlCanvas; class GLCanvas; class FaceTracker; @@ -372,6 +369,8 @@ private: MyAvatar* getMyAvatar() const; + void checkSkeleton(); + void initializeAcceptedFiles(); int getRenderAmbientLight() const; @@ -500,8 +499,6 @@ private: QTimer _settingsTimer; GLCanvas* _glWidget{ nullptr }; - - void checkSkeleton(); typedef bool (Application::* AcceptURLMethod)(const QString &); QHash _acceptedExtensions; From c745050dea1ab601bf43ba181e9ff9fbb7f66d5c Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Mon, 5 Oct 2015 12:59:41 -0700 Subject: [PATCH 30/33] Fix QObject::connect warning --- interface/src/Menu.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index 96f640b96e..9abfd1e34c 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -332,8 +332,7 @@ Menu::Menu() { ambientLightGroup->addAction(addCheckableActionToQMenuAndActionHash(ambientLightMenu, MenuOption::RenderAmbientLight8, 0, false)); ambientLightGroup->addAction(addCheckableActionToQMenuAndActionHash(ambientLightMenu, MenuOption::RenderAmbientLight9, 0, false)); - addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::ThrottleFPSIfNotFocus, 0, true, - qApp, SLOT(setThrottleFPSEnabled())); + addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::ThrottleFPSIfNotFocus, 0, true); MenuWrapper* resolutionMenu = renderOptionsMenu->addMenu(MenuOption::RenderResolution); QActionGroup* resolutionGroup = new QActionGroup(resolutionMenu); From ed13c02075afdf1f7d7f6989ef62846b7cf552b7 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Mon, 5 Oct 2015 18:53:42 -0700 Subject: [PATCH 31/33] Fix rebase --- interface/src/Application.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 7d1886f10c..b44ac6804d 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1077,8 +1077,8 @@ void Application::paintGL() { myAvatar->startCapture(); if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON || _myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) { - Menu::getInstance()->setIsOptionChecked(MenuOption::FirstPerson, _myAvatar->getBoomLength() <= MyAvatar::ZOOM_MIN); - Menu::getInstance()->setIsOptionChecked(MenuOption::ThirdPerson, !(_myAvatar->getBoomLength() <= MyAvatar::ZOOM_MIN)); + Menu::getInstance()->setIsOptionChecked(MenuOption::FirstPerson, myAvatar->getBoomLength() <= MyAvatar::ZOOM_MIN); + Menu::getInstance()->setIsOptionChecked(MenuOption::ThirdPerson, !(myAvatar->getBoomLength() <= MyAvatar::ZOOM_MIN)); cameraMenuChanged(); } From 8a7871e15bbada9f21afc4ea4b4fde99c7dd899b Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Tue, 6 Oct 2015 14:01:28 -0700 Subject: [PATCH 32/33] rebase fix --- assignment-client/src/octree/OctreeServer.cpp | 2 +- interface/src/scripting/HMDScriptingInterface.cpp | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/assignment-client/src/octree/OctreeServer.cpp b/assignment-client/src/octree/OctreeServer.cpp index 7899591998..ee0403d57b 100644 --- a/assignment-client/src/octree/OctreeServer.cpp +++ b/assignment-client/src/octree/OctreeServer.cpp @@ -191,7 +191,7 @@ void OctreeServer::trackPacketSendingTime(float time) { } -void OctreeServer::trackProcessWaitTime(float time) +void OctreeServer::trackProcessWaitTime(float time) { const float MAX_SHORT_TIME = 10.0f; const float MAX_LONG_TIME = 100.0f; if (time == SKIP_TIME) { diff --git a/interface/src/scripting/HMDScriptingInterface.cpp b/interface/src/scripting/HMDScriptingInterface.cpp index b3630a4453..f9a8fc1493 100644 --- a/interface/src/scripting/HMDScriptingInterface.cpp +++ b/interface/src/scripting/HMDScriptingInterface.cpp @@ -70,3 +70,7 @@ void HMDScriptingInterface::toggleMagnifier() { bool HMDScriptingInterface::getMagnifier() const { return qApp->getApplicationCompositor().hasMagnifier(); } + +bool HMDScriptingInterface::isHMDMode() const { + return qApp->isHMDMode(); +} From 76e0006732c6730abdf6fe1f8acb89a75f9237b9 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Tue, 6 Oct 2015 15:58:35 -0700 Subject: [PATCH 33/33] Remove forgotten cursorVisible --- examples/libraries/virtualKeyboard.js | 1 - interface/src/scripting/WindowScriptingInterface.cpp | 5 ----- interface/src/scripting/WindowScriptingInterface.h | 1 - 3 files changed, 7 deletions(-) diff --git a/examples/libraries/virtualKeyboard.js b/examples/libraries/virtualKeyboard.js index 7a0ec80a98..eca723dbcc 100644 --- a/examples/libraries/virtualKeyboard.js +++ b/examples/libraries/virtualKeyboard.js @@ -342,7 +342,6 @@ Keyboard = (function(params) { if (HMD.magnifier == visible) { HMD.toggleMagnifier(); } - Window.cursorVisible = !visible; Overlays.editOverlay(tthis.background, { visible: tthis.visible }); for (var i = 0; i < this.keys.length; i++) { this.keys[i].updateVisibility(); diff --git a/interface/src/scripting/WindowScriptingInterface.cpp b/interface/src/scripting/WindowScriptingInterface.cpp index 46edbe7420..a2886c8b77 100644 --- a/interface/src/scripting/WindowScriptingInterface.cpp +++ b/interface/src/scripting/WindowScriptingInterface.cpp @@ -60,11 +60,6 @@ void WindowScriptingInterface::raiseMainWindow() { }); } -void WindowScriptingInterface::setCursorVisible(bool visible) { - QMetaObject::invokeMethod(qApp, "setCursorVisible", Qt::BlockingQueuedConnection, - Q_ARG(bool, visible)); -} - void WindowScriptingInterface::setCursorPosition(int x, int y) { QCursor::setPos(x, y); } diff --git a/interface/src/scripting/WindowScriptingInterface.h b/interface/src/scripting/WindowScriptingInterface.h index 678a66102d..1395639cd0 100644 --- a/interface/src/scripting/WindowScriptingInterface.h +++ b/interface/src/scripting/WindowScriptingInterface.h @@ -38,7 +38,6 @@ public slots: QScriptValue getCursorPositionX(); QScriptValue getCursorPositionY(); void setCursorPosition(int x, int y); - void setCursorVisible(bool visible); QScriptValue hasFocus(); void setFocus(); void raiseMainWindow();