From 647a935eaa5e0753f0b076e576ab80779d0b3fb2 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Thu, 29 Jan 2015 14:38:41 -0800 Subject: [PATCH] Remove app->getAvatar --- interface/src/Application.h | 4 +- interface/src/DatagramProcessor.cpp | 3 +- interface/src/Menu.cpp | 11 ++-- interface/src/avatar/Avatar.cpp | 7 ++- interface/src/avatar/Hand.cpp | 10 ++-- interface/src/devices/OculusManager.cpp | 7 ++- interface/src/devices/PrioVR.cpp | 7 ++- interface/src/devices/SixenseManager.cpp | 24 ++++---- .../ControllerScriptingInterface.cpp | 12 ++-- interface/src/ui/AnimationsDialog.cpp | 20 ++++--- interface/src/ui/ApplicationOverlay.cpp | 57 ++++++++----------- interface/src/ui/AttachmentsDialog.cpp | 19 ++++--- interface/src/ui/MetavoxelEditor.cpp | 4 +- interface/src/ui/PreferencesDialog.cpp | 5 +- interface/src/ui/Snapshot.cpp | 7 ++- interface/src/ui/Snapshot.h | 1 + interface/src/ui/Stats.cpp | 2 +- interface/src/ui/overlays/Overlays.cpp | 4 +- 18 files changed, 105 insertions(+), 99 deletions(-) diff --git a/interface/src/Application.h b/interface/src/Application.h index 4282272e55..1b305a4e38 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -171,8 +171,6 @@ public: bool isThrottleRendering() const { return DependencyManager::get()->isThrottleRendering(); } - MyAvatar* getAvatar() { return _myAvatar; } - const MyAvatar* getAvatar() const { return _myAvatar; } Camera* getCamera() { return &_myCamera; } ViewFrustum* getViewFrustum() { return &_viewFrustum; } ViewFrustum* getDisplayViewFrustum() { return &_displayViewFrustum; } @@ -266,7 +264,7 @@ public: virtual float getSizeScale() const; virtual int getBoundaryLevelAdjust() const; virtual PickRay computePickRay(float x, float y); - virtual const glm::vec3& getAvatarPosition() const { return getAvatar()->getPosition(); } + virtual const glm::vec3& getAvatarPosition() const { return _myAvatar->getPosition(); } NodeBounds& getNodeBoundsDisplay() { return _nodeBoundsDisplay; } diff --git a/interface/src/DatagramProcessor.cpp b/interface/src/DatagramProcessor.cpp index 34f10e5038..0d958b2ecc 100644 --- a/interface/src/DatagramProcessor.cpp +++ b/interface/src/DatagramProcessor.cpp @@ -140,7 +140,8 @@ void DatagramProcessor::processDatagrams() { int headerSize = numBytesForPacketHeaderGivenPacketType(PacketTypeMuteEnvironment); memcpy(&position, incomingPacket.constData() + headerSize, sizeof(glm::vec3)); memcpy(&radius, incomingPacket.constData() + headerSize + sizeof(glm::vec3), sizeof(float)); - distance = glm::distance(Application::getInstance()->getAvatar()->getPosition(), position); + distance = glm::distance(DependencyManager::get()->getMyAvatar()->getPosition(), + position); mute = mute && (distance < radius); } diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index 350c703514..4d9820d70e 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -26,6 +26,7 @@ #include "AccountManager.h" #include "audio/AudioIOStatsRenderer.h" #include "audio/AudioScope.h" +#include "avatar/AvatarManager.h" #include "devices/Faceshift.h" #include "devices/RealSense.h" #include "devices/SixenseManager.h" @@ -186,26 +187,26 @@ Menu::Menu() { SLOT(resetSensors())); QMenu* avatarMenu = addMenu("Avatar"); + QObject* avatar = DependencyManager::get()->getMyAvatar(); QMenu* avatarSizeMenu = avatarMenu->addMenu("Size"); addActionToQMenuAndActionHash(avatarSizeMenu, MenuOption::IncreaseAvatarSize, Qt::Key_Plus, - qApp->getAvatar(), + avatar, SLOT(increaseSize())); addActionToQMenuAndActionHash(avatarSizeMenu, MenuOption::DecreaseAvatarSize, Qt::Key_Minus, - qApp->getAvatar(), + avatar, SLOT(decreaseSize())); addActionToQMenuAndActionHash(avatarSizeMenu, MenuOption::ResetAvatarSize, Qt::Key_Equal, - qApp->getAvatar(), + avatar, SLOT(resetSize())); - QObject* avatar = qApp->getAvatar(); - addCheckableActionToQMenuAndActionHash(avatarMenu, MenuOption::KeyboardMotorControl, + addCheckableActionToQMenuAndActionHash(avatarMenu, MenuOption::KeyboardMotorControl, Qt::CTRL | Qt::SHIFT | Qt::Key_K, true, avatar, SLOT(updateMotionBehavior())); addCheckableActionToQMenuAndActionHash(avatarMenu, MenuOption::ScriptedMotorControl, 0, true, avatar, SLOT(updateMotionBehavior())); diff --git a/interface/src/avatar/Avatar.cpp b/interface/src/avatar/Avatar.cpp index 48804069f2..941a62a0a1 100644 --- a/interface/src/avatar/Avatar.cpp +++ b/interface/src/avatar/Avatar.cpp @@ -273,7 +273,8 @@ void Avatar::render(const glm::vec3& cameraPosition, RenderMode renderMode, bool _referential->update(); } - if (postLighting && glm::distance(Application::getInstance()->getAvatar()->getPosition(), _position) < 10.0f) { + if (postLighting && + glm::distance(DependencyManager::get()->getMyAvatar()->getPosition(), _position) < 10.0f) { auto geometryCache = DependencyManager::get(); // render pointing lasers @@ -354,7 +355,7 @@ void Avatar::render(const glm::vec3& cameraPosition, RenderMode renderMode, bool const float GLOW_MAX_LOUDNESS = 2500.0f; const float MAX_GLOW = 0.5f; - float GLOW_FROM_AVERAGE_LOUDNESS = ((this == Application::getInstance()->getAvatar()) + float GLOW_FROM_AVERAGE_LOUDNESS = ((this == DependencyManager::get()->getMyAvatar()) ? 0.0f : MAX_GLOW * getHeadData()->getAudioLoudness() / GLOW_MAX_LOUDNESS); if (!Menu::getInstance()->isOptionChecked(MenuOption::GlowWhenSpeaking)) { @@ -1054,7 +1055,7 @@ void Avatar::setShowDisplayName(bool showDisplayName) { } // For myAvatar, the alpha update is not done (called in simulate for other avatars) - if (Application::getInstance()->getAvatar() == this) { + if (DependencyManager::get()->getMyAvatar() == this) { if (showDisplayName) { _displayNameAlpha = DISPLAYNAME_ALPHA; } else { diff --git a/interface/src/avatar/Hand.cpp b/interface/src/avatar/Hand.cpp index b477f606d7..7aebd5a25b 100644 --- a/interface/src/avatar/Hand.cpp +++ b/interface/src/avatar/Hand.cpp @@ -12,15 +12,14 @@ #include -#include - #include +#include #include -#include "Application.h" -#include "Avatar.h" +#include "AvatarManager.h" #include "Hand.h" #include "Menu.h" +#include "MyAvatar.h" #include "Util.h" using namespace std; @@ -132,8 +131,7 @@ void Hand::render(bool isMine, Model::RenderMode renderMode) { void Hand::renderHandTargets(bool isMine) { glPushMatrix(); - MyAvatar* myAvatar = Application::getInstance()->getAvatar(); - const float avatarScale = Application::getInstance()->getAvatar()->getScale(); + const float avatarScale = DependencyManager::get()->getMyAvatar()->getScale(); const float alpha = 1.0f; const glm::vec3 handColor(1.0, 0.0, 0.0); // Color the hand targets red to be different than skin diff --git a/interface/src/devices/OculusManager.cpp b/interface/src/devices/OculusManager.cpp index 256c09f602..9b1470ad67 100644 --- a/interface/src/devices/OculusManager.cpp +++ b/interface/src/devices/OculusManager.cpp @@ -22,6 +22,8 @@ #include +#include +#include #include #include #include @@ -198,11 +200,12 @@ void OculusManager::disconnect() { #ifdef HAVE_LIBOVR void OculusManager::positionCalibrationBillboard(Text3DOverlay* billboard) { - glm::quat headOrientation = Application::getInstance()->getAvatar()->getHeadOrientation(); + MyAvatar* myAvatar = DependencyManager::get()->getMyAvatar(); + glm::quat headOrientation = myAvatar->getHeadOrientation(); headOrientation.x = 0; headOrientation.z = 0; glm::normalize(headOrientation); - billboard->setPosition(Application::getInstance()->getAvatar()->getHeadPosition() + billboard->setPosition(myAvatar->getHeadPosition() + headOrientation * glm::vec3(0.0f, 0.0f, -CALIBRATION_MESSAGE_DISTANCE)); billboard->setRotation(headOrientation); } diff --git a/interface/src/devices/PrioVR.cpp b/interface/src/devices/PrioVR.cpp index 78b802ac9c..6f0186714d 100644 --- a/interface/src/devices/PrioVR.cpp +++ b/interface/src/devices/PrioVR.cpp @@ -12,6 +12,7 @@ #include #include +#include #include #include #include @@ -42,7 +43,7 @@ static int indexOfHumanIKJoint(const char* jointName) { } static void setPalm(float deltaTime, int index) { - MyAvatar* avatar = Application::getInstance()->getAvatar(); + MyAvatar* avatar = DependencyManager::get()->getMyAvatar(); Hand* hand = avatar->getHand(); PalmData* palm; bool foundHand = false; @@ -86,9 +87,9 @@ static void setPalm(float deltaTime, int index) { // TODO: transfom this to stay in the model-frame. glm::vec3 position; glm::quat rotation; - SkeletonModel* skeletonModel = &Application::getInstance()->getAvatar()->getSkeletonModel(); + SkeletonModel* skeletonModel = &DependencyManager::get()->getMyAvatar()->getSkeletonModel(); int jointIndex; - glm::quat inverseRotation = glm::inverse(Application::getInstance()->getAvatar()->getOrientation()); + glm::quat inverseRotation = glm::inverse(DependencyManager::get()->getMyAvatar()->getOrientation()); if (index == LEFT_HAND_INDEX) { jointIndex = skeletonModel->getLeftHandJointIndex(); skeletonModel->getJointRotationInWorldFrame(jointIndex, rotation); diff --git a/interface/src/devices/SixenseManager.cpp b/interface/src/devices/SixenseManager.cpp index d11d527904..ffaa5260db 100644 --- a/interface/src/devices/SixenseManager.cpp +++ b/interface/src/devices/SixenseManager.cpp @@ -11,6 +11,7 @@ #include +#include #include #include "Application.h" @@ -144,7 +145,7 @@ void SixenseManager::setFilter(bool filter) { void SixenseManager::update(float deltaTime) { #ifdef HAVE_SIXENSE - Hand* hand = Application::getInstance()->getAvatar()->getHand(); + Hand* hand = DependencyManager::get()->getMyAvatar()->getHand(); if (_isInitialized && _isEnabled) { #ifdef __APPLE__ SixenseBaseFunction sixenseGetNumActiveControllers = @@ -458,8 +459,7 @@ void SixenseManager::updateCalibration(const sixenseControllerData* controllers) //Injecting mouse movements and clicks void SixenseManager::emulateMouse(PalmData* palm, int index) { - Application* application = Application::getInstance(); - MyAvatar* avatar = application->getAvatar(); + MyAvatar* avatar = DependencyManager::get()->getMyAvatar(); auto glCanvas = DependencyManager::get(); QPoint pos; @@ -478,7 +478,7 @@ void SixenseManager::emulateMouse(PalmData* palm, int index) { if (Menu::getInstance()->isOptionChecked(MenuOption::SixenseLasers) || Menu::getInstance()->isOptionChecked(MenuOption::EnableVRMode)) { - pos = application->getApplicationOverlay().getPalmClickLocation(palm); + pos = qApp->getApplicationOverlay().getPalmClickLocation(palm); } else { // Get directon relative to avatar orientation glm::vec3 direction = glm::inverse(avatar->getOrientation()) * palm->getFingerDirection(); @@ -501,14 +501,14 @@ void SixenseManager::emulateMouse(PalmData* palm, int index) { if (_bumperPressed[index]) { QMouseEvent mouseEvent(QEvent::MouseButtonRelease, pos, bumperButton, bumperButton, 0); - application->mouseReleaseEvent(&mouseEvent, deviceID); + qApp->mouseReleaseEvent(&mouseEvent, deviceID); _bumperPressed[index] = false; } if (_triggerPressed[index]) { QMouseEvent mouseEvent(QEvent::MouseButtonRelease, pos, triggerButton, triggerButton, 0); - application->mouseReleaseEvent(&mouseEvent, deviceID); + qApp->mouseReleaseEvent(&mouseEvent, deviceID); _triggerPressed[index] = false; } @@ -522,11 +522,11 @@ void SixenseManager::emulateMouse(PalmData* palm, int index) { //Only send the mouse event if the opposite left button isnt held down. if (triggerButton == Qt::LeftButton) { if (!_triggerPressed[(int)(!index)]) { - application->mouseMoveEvent(&mouseEvent, deviceID); + qApp->mouseMoveEvent(&mouseEvent, deviceID); } } else { if (!_bumperPressed[(int)(!index)]) { - application->mouseMoveEvent(&mouseEvent, deviceID); + qApp->mouseMoveEvent(&mouseEvent, deviceID); } } } @@ -549,12 +549,12 @@ void SixenseManager::emulateMouse(PalmData* palm, int index) { QMouseEvent mouseEvent(QEvent::MouseButtonPress, pos, bumperButton, bumperButton, 0); - application->mousePressEvent(&mouseEvent, deviceID); + qApp->mousePressEvent(&mouseEvent, deviceID); } } else if (_bumperPressed[index]) { QMouseEvent mouseEvent(QEvent::MouseButtonRelease, pos, bumperButton, bumperButton, 0); - application->mouseReleaseEvent(&mouseEvent, deviceID); + qApp->mouseReleaseEvent(&mouseEvent, deviceID); _bumperPressed[index] = false; } @@ -566,12 +566,12 @@ void SixenseManager::emulateMouse(PalmData* palm, int index) { QMouseEvent mouseEvent(QEvent::MouseButtonPress, pos, triggerButton, triggerButton, 0); - application->mousePressEvent(&mouseEvent, deviceID); + qApp->mousePressEvent(&mouseEvent, deviceID); } } else if (_triggerPressed[index]) { QMouseEvent mouseEvent(QEvent::MouseButtonRelease, pos, triggerButton, triggerButton, 0); - application->mouseReleaseEvent(&mouseEvent, deviceID); + qApp->mouseReleaseEvent(&mouseEvent, deviceID); _triggerPressed[index] = false; } diff --git a/interface/src/scripting/ControllerScriptingInterface.cpp b/interface/src/scripting/ControllerScriptingInterface.cpp index f8b0a61487..929a763e70 100644 --- a/interface/src/scripting/ControllerScriptingInterface.cpp +++ b/interface/src/scripting/ControllerScriptingInterface.cpp @@ -9,10 +9,12 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include +#include +#include #include #include -#include "Application.h" #include "devices/MotionTracker.h" #include "devices/SixenseManager.h" #include "ControllerScriptingInterface.h" @@ -41,7 +43,7 @@ void ControllerScriptingInterface::handleMetaEvent(HFMetaEvent* event) { const PalmData* ControllerScriptingInterface::getPrimaryPalm() const { int leftPalmIndex, rightPalmIndex; - const HandData* handData = Application::getInstance()->getAvatar()->getHandData(); + const HandData* handData = DependencyManager::get()->getMyAvatar()->getHandData(); handData->getLeftRightPalmIndices(leftPalmIndex, rightPalmIndex); if (rightPalmIndex != -1) { @@ -52,7 +54,7 @@ const PalmData* ControllerScriptingInterface::getPrimaryPalm() const { } int ControllerScriptingInterface::getNumberOfActivePalms() const { - const HandData* handData = Application::getInstance()->getAvatar()->getHandData(); + const HandData* handData = DependencyManager::get()->getMyAvatar()->getHandData(); int numberOfPalms = handData->getNumPalms(); int numberOfActivePalms = 0; for (int i = 0; i < numberOfPalms; i++) { @@ -64,12 +66,12 @@ int ControllerScriptingInterface::getNumberOfActivePalms() const { } const PalmData* ControllerScriptingInterface::getPalm(int palmIndex) const { - const HandData* handData = Application::getInstance()->getAvatar()->getHandData(); + const HandData* handData = DependencyManager::get()->getMyAvatar()->getHandData(); return &handData->getPalms()[palmIndex]; } const PalmData* ControllerScriptingInterface::getActivePalm(int palmIndex) const { - const HandData* handData = Application::getInstance()->getAvatar()->getHandData(); + const HandData* handData = DependencyManager::get()->getMyAvatar()->getHandData(); int numberOfPalms = handData->getNumPalms(); int numberOfActivePalms = 0; for (int i = 0; i < numberOfPalms; i++) { diff --git a/interface/src/ui/AnimationsDialog.cpp b/interface/src/ui/AnimationsDialog.cpp index 74f6310ea1..a06893fda4 100644 --- a/interface/src/ui/AnimationsDialog.cpp +++ b/interface/src/ui/AnimationsDialog.cpp @@ -16,23 +16,24 @@ #include #include #include +#include #include #include #include +#include +#include #include #include "AnimationsDialog.h" -#include "Application.h" -#include "MainWindow.h" namespace SettingHandles { const SettingHandle animationDirectory("animation_directory", QString()); } AnimationsDialog::AnimationsDialog(QWidget* parent) : - QDialog(parent) { - + QDialog(parent) +{ setWindowTitle("Edit Animations"); setAttribute(Qt::WA_DeleteOnClose); @@ -48,7 +49,8 @@ AnimationsDialog::AnimationsDialog(QWidget* parent) : area->setWidget(container); _animations->addStretch(1); - foreach (const AnimationHandlePointer& handle, Application::getInstance()->getAvatar()->getAnimationHandles()) { + MyAvatar* myAvatar = DependencyManager::get()->getMyAvatar(); + foreach (const AnimationHandlePointer& handle, myAvatar->getAnimationHandles()) { _animations->insertWidget(_animations->count() - 1, new AnimationPanel(this, handle)); } @@ -74,8 +76,8 @@ void AnimationsDialog::setVisible(bool visible) { } void AnimationsDialog::addAnimation() { - _animations->insertWidget(_animations->count() - 1, new AnimationPanel( - this, Application::getInstance()->getAvatar()->addAnimationHandle())); + _animations->insertWidget(_animations->count() - 1, new AnimationPanel(this, + DependencyManager::get()->getMyAvatar()->addAnimationHandle())); } AnimationPanel::AnimationPanel(AnimationsDialog* dialog, const AnimationHandlePointer& handle) : @@ -176,7 +178,7 @@ void AnimationPanel::chooseURL() { void AnimationPanel::chooseMaskedJoints() { QMenu menu; QStringList maskedJoints = _handle->getMaskedJoints(); - foreach (const QString& jointName, Application::getInstance()->getAvatar()->getJointNames()) { + foreach (const QString& jointName, DependencyManager::get()->getMyAvatar()->getJointNames()) { QAction* action = menu.addAction(jointName); action->setCheckable(true); action->setChecked(maskedJoints.contains(jointName)); @@ -207,6 +209,6 @@ void AnimationPanel::updateHandle() { } void AnimationPanel::removeHandle() { - Application::getInstance()->getAvatar()->removeAnimationHandle(_handle); + DependencyManager::get()->getMyAvatar()->removeAnimationHandle(_handle); deleteLater(); } diff --git a/interface/src/ui/ApplicationOverlay.cpp b/interface/src/ui/ApplicationOverlay.cpp index 17a6beb65f..3651e14be3 100644 --- a/interface/src/ui/ApplicationOverlay.cpp +++ b/interface/src/ui/ApplicationOverlay.cpp @@ -13,6 +13,7 @@ #include +#include #include #include @@ -161,8 +162,7 @@ ApplicationOverlay::~ApplicationOverlay() { // Renders the overlays either to a texture or to the screen void ApplicationOverlay::renderOverlay(bool renderToTexture) { PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), "ApplicationOverlay::displayOverlay()"); - Application* application = Application::getInstance(); - Overlays& overlays = application->getOverlays(); + Overlays& overlays = qApp->getOverlays(); auto glCanvas = DependencyManager::get(); _textureFov = glm::radians(_oculusUIAngularSize); @@ -206,7 +206,7 @@ void ApplicationOverlay::renderOverlay(bool renderToTexture) { renderStatsAndLogs(); // give external parties a change to hook in - emit application->renderingOverlay(); + emit qApp->renderingOverlay(); overlays.renderHUD(); @@ -278,7 +278,7 @@ void ApplicationOverlay::displayOverlayTextureOculus(Camera& whichCamera) { //Update and draw the magnifiers - MyAvatar* myAvatar = Application::getInstance()->getAvatar(); + MyAvatar* myAvatar = DependencyManager::get()->getMyAvatar(); const glm::quat& orientation = myAvatar->getOrientation(); const glm::vec3& position = myAvatar->getDefaultEyePosition(); const float scale = myAvatar->getScale() * _oculusUIRadius; @@ -343,10 +343,8 @@ void ApplicationOverlay::displayOverlayTexture3DTV(Camera& whichCamera, float as return; } - Application* application = Application::getInstance(); - - MyAvatar* myAvatar = application->getAvatar(); - const glm::vec3& viewMatrixTranslation = application->getViewMatrixTranslation(); + MyAvatar* myAvatar = DependencyManager::get()->getMyAvatar(); + const glm::vec3& viewMatrixTranslation = qApp->getViewMatrixTranslation(); glActiveTexture(GL_TEXTURE0); @@ -407,8 +405,8 @@ void ApplicationOverlay::displayOverlayTexture3DTV(Camera& whichCamera, float as const float reticleSize = 40.0f / glCanvas->width() * quadWidth; x -= reticleSize / 2.0f; y += reticleSize / 2.0f; - const float mouseX = (application->getMouseX() / (float)glCanvas->width()) * quadWidth; - const float mouseY = (1.0 - (application->getMouseY() / (float)glCanvas->height())) * quadHeight; + const float mouseX = (qApp->getMouseX() / (float)glCanvas->width()) * quadWidth; + const float mouseY = (1.0 - (qApp->getMouseY() / (float)glCanvas->height())) * quadHeight; glColor3f(RETICLE_COLOR[0], RETICLE_COLOR[1], RETICLE_COLOR[2]); @@ -441,22 +439,21 @@ void ApplicationOverlay::computeOculusPickRay(float x, float y, glm::vec3& origi const glm::vec3 localDirection = orientation * IDENTITY_FRONT; //Rotate the UI pick ray by the avatar orientation - const MyAvatar* myAvatar = Application::getInstance()->getAvatar(); + const MyAvatar* myAvatar = DependencyManager::get()->getMyAvatar(); origin = myAvatar->getDefaultEyePosition(); direction = myAvatar->getOrientation() * localDirection; } //Caculate the click location using one of the sixense controllers. Scale is not applied QPoint ApplicationOverlay::getPalmClickLocation(const PalmData *palm) const { - Application* application = Application::getInstance(); auto glCanvas = DependencyManager::get(); - MyAvatar* myAvatar = application->getAvatar(); + MyAvatar* myAvatar = DependencyManager::get()->getMyAvatar(); glm::vec3 tip = myAvatar->getLaserPointerTipPosition(palm); glm::vec3 eyePos = myAvatar->getHead()->getEyePosition(); glm::quat invOrientation = glm::inverse(myAvatar->getOrientation()); //direction of ray goes towards camera - glm::vec3 dir = invOrientation * glm::normalize(application->getCamera()->getPosition() - tip); + glm::vec3 dir = invOrientation * glm::normalize(qApp->getCamera()->getPosition() - tip); glm::vec3 tipPos = invOrientation * (tip - eyePos); QPoint rv; @@ -490,7 +487,7 @@ QPoint ApplicationOverlay::getPalmClickLocation(const PalmData *palm) const { } } else { glm::dmat4 projection; - application->getProjectionMatrix(&projection); + qApp->getProjectionMatrix(&projection); glm::vec4 clipSpacePos = glm::vec4(projection * glm::dvec4(tipPos, 1.0)); glm::vec3 ndcSpacePos; @@ -506,8 +503,7 @@ QPoint ApplicationOverlay::getPalmClickLocation(const PalmData *palm) const { //Finds the collision point of a world space ray bool ApplicationOverlay::calculateRayUICollisionPoint(const glm::vec3& position, const glm::vec3& direction, glm::vec3& result) const { - Application* application = Application::getInstance(); - MyAvatar* myAvatar = application->getAvatar(); + MyAvatar* myAvatar = DependencyManager::get()->getMyAvatar(); glm::quat orientation = myAvatar->getOrientation(); @@ -527,7 +523,6 @@ bool ApplicationOverlay::calculateRayUICollisionPoint(const glm::vec3& position, //Renders optional pointers void ApplicationOverlay::renderPointers() { - Application* application = Application::getInstance(); auto glCanvas = DependencyManager::get(); //lazily load crosshair texture @@ -539,12 +534,12 @@ void ApplicationOverlay::renderPointers() { glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, _crosshairTexture); - if (OculusManager::isConnected() && !application->getLastMouseMoveWasSimulated()) { + if (OculusManager::isConnected() && !qApp->getLastMouseMoveWasSimulated()) { //If we are in oculus, render reticle later if (_lastMouseMove == 0) { _lastMouseMove = usecTimestampNow(); } - QPoint position = QPoint(application->getTrueMouseX(), application->getTrueMouseY()); + QPoint position = QPoint(qApp->getTrueMouseX(), qApp->getTrueMouseY()); static const int MAX_IDLE_TIME = 3; if (_reticlePosition[MOUSE] != position) { @@ -563,7 +558,7 @@ void ApplicationOverlay::renderPointers() { _magActive[MOUSE] = true; _reticleActive[LEFT_CONTROLLER] = false; _reticleActive[RIGHT_CONTROLLER] = false; - } else if (application->getLastMouseMoveWasSimulated() && Menu::getInstance()->isOptionChecked(MenuOption::SixenseMouseInput)) { + } else if (qApp->getLastMouseMoveWasSimulated() && Menu::getInstance()->isOptionChecked(MenuOption::SixenseMouseInput)) { _lastMouseMove = 0; //only render controller pointer if we aren't already rendering a mouse pointer _reticleActive[MOUSE] = false; @@ -575,16 +570,15 @@ void ApplicationOverlay::renderPointers() { } void ApplicationOverlay::renderControllerPointers() { - Application* application = Application::getInstance(); auto glCanvas = DependencyManager::get(); - MyAvatar* myAvatar = application->getAvatar(); + MyAvatar* myAvatar = DependencyManager::get()->getMyAvatar(); //Static variables used for storing controller state static quint64 pressedTime[NUMBER_OF_RETICLES] = { 0ULL, 0ULL, 0ULL }; static bool isPressed[NUMBER_OF_RETICLES] = { false, false, false }; static bool stateWhenPressed[NUMBER_OF_RETICLES] = { false, false, false }; - const HandData* handData = Application::getInstance()->getAvatar()->getHandData(); + const HandData* handData = DependencyManager::get()->getMyAvatar()->getHandData(); for (unsigned int palmIndex = 2; palmIndex < 4; palmIndex++) { const int index = palmIndex - 1; @@ -692,7 +686,7 @@ void ApplicationOverlay::renderPointersOculus(const glm::vec3& eyePos) { glMatrixMode(GL_MODELVIEW); //Controller Pointers - MyAvatar* myAvatar = Application::getInstance()->getAvatar(); + MyAvatar* myAvatar = DependencyManager::get()->getMyAvatar(); for (int i = 0; i < (int)myAvatar->getHand()->getNumPalms(); i++) { PalmData& palm = myAvatar->getHand()->getPalms()[i]; @@ -904,13 +898,10 @@ void ApplicationOverlay::renderAudioMeter() { } void ApplicationOverlay::renderStatsAndLogs() { - - Application* application = Application::getInstance(); - auto glCanvas = DependencyManager::get(); - const OctreePacketProcessor& octreePacketProcessor = application->getOctreePacketProcessor(); - BandwidthMeter* bandwidthMeter = application->getBandwidthMeter(); - NodeBounds& nodeBoundsDisplay = application->getNodeBoundsDisplay(); + const OctreePacketProcessor& octreePacketProcessor = qApp->getOctreePacketProcessor(); + BandwidthMeter* bandwidthMeter = qApp->getBandwidthMeter(); + NodeBounds& nodeBoundsDisplay = qApp->getNodeBoundsDisplay(); // Display stats and log text onscreen glLineWidth(1.0f); @@ -921,8 +912,8 @@ void ApplicationOverlay::renderStatsAndLogs() { int horizontalOffset = MIRROR_VIEW_WIDTH + MIRROR_VIEW_LEFT_PADDING * 2; int voxelPacketsToProcess = octreePacketProcessor.packetsToProcessCount(); // Onscreen text about position, servers, etc - Stats::getInstance()->display(WHITE_TEXT, horizontalOffset, application->getFps(), - application->getPacketsPerSecond(), application->getBytesPerSecond(), voxelPacketsToProcess); + Stats::getInstance()->display(WHITE_TEXT, horizontalOffset, qApp->getFps(), + qApp->getPacketsPerSecond(), qApp->getBytesPerSecond(), voxelPacketsToProcess); // Bandwidth meter if (Menu::getInstance()->isOptionChecked(MenuOption::Bandwidth)) { Stats::drawBackground(0x33333399, glCanvas->width() - 296, glCanvas->height() - 68, 296, 68); diff --git a/interface/src/ui/AttachmentsDialog.cpp b/interface/src/ui/AttachmentsDialog.cpp index 9fce905197..58b46e5bbf 100644 --- a/interface/src/ui/AttachmentsDialog.cpp +++ b/interface/src/ui/AttachmentsDialog.cpp @@ -18,9 +18,12 @@ #include #include -#include "Application.h" +#include +#include +#include + #include "AttachmentsDialog.h" -#include "MainWindow.h" +#include "ModelsBrowser.h" AttachmentsDialog::AttachmentsDialog(QWidget* parent) : QDialog(parent) { @@ -40,7 +43,7 @@ AttachmentsDialog::AttachmentsDialog(QWidget* parent) : area->setWidget(container); _attachments->addStretch(1); - foreach (const AttachmentData& data, Application::getInstance()->getAvatar()->getAttachmentData()) { + foreach (const AttachmentData& data, DependencyManager::get()->getMyAvatar()->getAttachmentData()) { addAttachment(data); } @@ -70,7 +73,7 @@ void AttachmentsDialog::updateAttachmentData() { for (int i = 0; i < _attachments->count() - 1; i++) { data.append(static_cast(_attachments->itemAt(i)->widget())->getAttachmentData()); } - Application::getInstance()->getAvatar()->setAttachmentData(data); + DependencyManager::get()->getMyAvatar()->setAttachmentData(data); } void AttachmentsDialog::addAttachment(const AttachmentData& data) { @@ -116,7 +119,7 @@ AttachmentPanel::AttachmentPanel(AttachmentsDialog* dialog, const AttachmentData connect(chooseURL, SIGNAL(clicked(bool)), SLOT(chooseModelURL())); layout->addRow("Joint:", _jointName = new QComboBox()); - QSharedPointer geometry = Application::getInstance()->getAvatar()->getSkeletonModel().getGeometry(); + QSharedPointer geometry = DependencyManager::get()->getMyAvatar()->getSkeletonModel().getGeometry(); if (geometry && geometry->isLoaded()) { foreach (const FBXJoint& joint, geometry->getFBXGeometry().joints) { _jointName->addItem(joint.name); @@ -177,7 +180,7 @@ void AttachmentPanel::modelURLChanged() { _dialog->updateAttachmentData(); return; } - AttachmentData attachment = Application::getInstance()->getAvatar()->loadAttachmentData(_modelURL->text()); + AttachmentData attachment = DependencyManager::get()->getMyAvatar()->loadAttachmentData(_modelURL->text()); if (attachment.isValid()) { _applying = true; _jointName->setCurrentText(attachment.jointName); @@ -195,7 +198,7 @@ void AttachmentPanel::jointNameChanged() { _dialog->updateAttachmentData(); return; } - AttachmentData attachment = Application::getInstance()->getAvatar()->loadAttachmentData( + AttachmentData attachment = DependencyManager::get()->getMyAvatar()->loadAttachmentData( _modelURL->text(), _jointName->currentText()); if (attachment.isValid()) { applyAttachmentData(attachment); @@ -209,7 +212,7 @@ void AttachmentPanel::updateAttachmentData() { } // save the attachment data under the model URL (if any) if (!_modelURL->text().isEmpty()) { - Application::getInstance()->getAvatar()->saveAttachmentData(getAttachmentData()); + DependencyManager::get()->getMyAvatar()->saveAttachmentData(getAttachmentData()); } _dialog->updateAttachmentData(); } diff --git a/interface/src/ui/MetavoxelEditor.cpp b/interface/src/ui/MetavoxelEditor.cpp index 41a7c90fc9..55c1e8ce49 100644 --- a/interface/src/ui/MetavoxelEditor.cpp +++ b/interface/src/ui/MetavoxelEditor.cpp @@ -33,13 +33,13 @@ #include #include +#include #include #include #include #include #include "Application.h" -#include "MainWindow.h" #include "MetavoxelEditor.h" using namespace std; @@ -267,7 +267,7 @@ void MetavoxelEditor::deleteSelectedAttribute() { void MetavoxelEditor::centerGridPosition() { const float CENTER_OFFSET = 0.625f; float eyePosition = (glm::inverse(getGridRotation()) * Application::getInstance()->getCamera()->getPosition()).z - - Application::getInstance()->getAvatar()->getScale() * CENTER_OFFSET; + DependencyManager::get()->getMyAvatar()->getScale() * CENTER_OFFSET; double step = getGridSpacing(); _gridPosition->setValue(step * floor(eyePosition / step)); } diff --git a/interface/src/ui/PreferencesDialog.cpp b/interface/src/ui/PreferencesDialog.cpp index 7039c8242d..c7b5004234 100644 --- a/interface/src/ui/PreferencesDialog.cpp +++ b/interface/src/ui/PreferencesDialog.cpp @@ -12,6 +12,7 @@ #include #include +#include #include #include @@ -107,7 +108,7 @@ void PreferencesDialog::resizeEvent(QResizeEvent *resizeEvent) { void PreferencesDialog::loadPreferences() { - MyAvatar* myAvatar = Application::getInstance()->getAvatar(); + MyAvatar* myAvatar = DependencyManager::get()->getMyAvatar(); Menu* menuInstance = Menu::getInstance(); _displayNameString = myAvatar->getDisplayName(); @@ -173,7 +174,7 @@ void PreferencesDialog::loadPreferences() { void PreferencesDialog::savePreferences() { - MyAvatar* myAvatar = Application::getInstance()->getAvatar(); + MyAvatar* myAvatar = DependencyManager::get()->getMyAvatar(); bool shouldDispatchIdentityPacket = false; QString displayNameStr(ui.displayNameEdit->text()); diff --git a/interface/src/ui/Snapshot.cpp b/interface/src/ui/Snapshot.cpp index 5669c5d401..ff852b3d83 100644 --- a/interface/src/ui/Snapshot.cpp +++ b/interface/src/ui/Snapshot.cpp @@ -17,8 +17,11 @@ #include #include -#include +#include +#include #include +#include +#include #include "Snapshot.h" @@ -90,7 +93,7 @@ QFile* Snapshot::savedFileForSnapshot(bool isTemporary) { auto glCanvas = DependencyManager::get(); QImage shot = glCanvas->grabFrameBuffer(); - Avatar* avatar = qApp->getAvatar(); + Avatar* avatar = DependencyManager::get()->getMyAvatar(); glm::vec3 location = avatar->getPosition(); glm::quat orientation = avatar->getHead()->getOrientation(); diff --git a/interface/src/ui/Snapshot.h b/interface/src/ui/Snapshot.h index 415d155847..e8e8133823 100644 --- a/interface/src/ui/Snapshot.h +++ b/interface/src/ui/Snapshot.h @@ -15,6 +15,7 @@ #include #include +#include #include diff --git a/interface/src/ui/Stats.cpp b/interface/src/ui/Stats.cpp index d2d14c9fa8..176f1511d5 100644 --- a/interface/src/ui/Stats.cpp +++ b/interface/src/ui/Stats.cpp @@ -399,7 +399,7 @@ void Stats::display( horizontalOffset = _lastHorizontalOffset + _generalStatsWidth + _pingStatsWidth + 2; } - MyAvatar* myAvatar = Application::getInstance()->getAvatar(); + MyAvatar* myAvatar = DependencyManager::get()->getMyAvatar(); glm::vec3 avatarPos = myAvatar->getPosition(); lines = _expanded ? 8 : 3; diff --git a/interface/src/ui/overlays/Overlays.cpp b/interface/src/ui/overlays/Overlays.cpp index c07f249aa0..8ba7ddea00 100644 --- a/interface/src/ui/overlays/Overlays.cpp +++ b/interface/src/ui/overlays/Overlays.cpp @@ -14,6 +14,7 @@ #include #include +#include #include #include @@ -114,7 +115,7 @@ void Overlays::renderWorld(bool drawFront, RenderArgs::RenderMode renderMode, Re return; } bool myAvatarComputed = false; - MyAvatar* avatar = NULL; + MyAvatar* avatar = DependencyManager::get()->getMyAvatar(); glm::quat myAvatarRotation; glm::vec3 myAvatarPosition(0.0f); float angle = 0.0f; @@ -138,7 +139,6 @@ void Overlays::renderWorld(bool drawFront, RenderArgs::RenderMode renderMode, Re switch (thisOverlay->getAnchor()) { case Overlay::MY_AVATAR: if (!myAvatarComputed) { - avatar = Application::getInstance()->getAvatar(); myAvatarRotation = avatar->getOrientation(); myAvatarPosition = avatar->getPosition(); angle = glm::degrees(glm::angle(myAvatarRotation));