diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index 0b2cfa5427..9dbed9a6ee 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -44,7 +44,7 @@ macro(GroupSources curdir) GroupSources(${curdir}/${child}) else() string(REPLACE "/" "\\" groupname ${curdir}) - source_group(${groupname} FILES ${PROJECT_SOURCE_DIR}/${curdir}/${child}) + source_group(${groupname} FILES ${PROJECT_SOURCE_DIR}/${curdir}/${child}) endif() endforeach() endmacro() diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 567e50df23..e6695dafd7 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -114,7 +114,7 @@ #include "gpu/Batch.h" #include "gpu/GLBackend.h" -#include "plugins/render/RenderPlugin.h" +#include "plugins/render/DisplayPlugin.h" #include "scripting/AccountScriptingInterface.h" #include "scripting/AudioDeviceScriptingInterface.h" @@ -660,7 +660,7 @@ Application::~Application() { ModelEntityItem::cleanupLoadedAnimations(); - getActiveRenderPlugin()->deactivate(); + getActiveDisplayPlugin()->deactivate(); DependencyManager::destroy(); DependencyManager::destroy(); @@ -773,22 +773,22 @@ void Application::initializeUi() { auto offscreenUi = DependencyManager::get(); offscreenUi->create(_offscreenContext->getContext()); - offscreenUi->resize(fromGlm(getActiveRenderPlugin()->getCanvasSize())); + offscreenUi->resize(fromGlm(getActiveDisplayPlugin()->getCanvasSize())); offscreenUi->setProxyWindow(_window->windowHandle()); offscreenUi->setBaseUrl(QUrl::fromLocalFile(PathUtils::resourcesPath() + "/qml/")); offscreenUi->load("Root.qml"); offscreenUi->load("RootMenu.qml"); VrMenu::load(); VrMenu::executeQueuedLambdas(); - offscreenUi->setMouseTranslator(getActiveRenderPlugin()->getMouseTranslator()); + offscreenUi->setMouseTranslator(getActiveDisplayPlugin()->getMouseTranslator()); offscreenUi->resume(); connect(_window, &MainWindow::windowGeometryChanged, [this](const QRect & r){ static qreal oldDevicePixelRatio = 0; - qreal devicePixelRatio = getActiveRenderPlugin()->devicePixelRatio(); + qreal devicePixelRatio = getActiveDisplayPlugin()->devicePixelRatio(); if (devicePixelRatio != oldDevicePixelRatio) { oldDevicePixelRatio = devicePixelRatio; qDebug() << "Device pixel ratio changed, triggering GL resize"; - auto canvasSize = getActiveRenderPlugin()->getCanvasSize(); + auto canvasSize = getActiveDisplayPlugin()->getCanvasSize(); resizeGL(canvasSize.x, canvasSize.y); } }); @@ -803,18 +803,18 @@ void Application::paintGL() { PerformanceWarning warn(showWarnings, "Application::paintGL()"); _offscreenContext->makeCurrent(); - QSize fbSize = getActiveRenderPlugin()->getRecommendedFramebufferSize() * getRenderResolutionScale(); + QSize fbSize = getActiveDisplayPlugin()->getRecommendedFramebufferSize() * getRenderResolutionScale(); DependencyManager::get()->setFrameBufferSize(fbSize); glEnable(GL_LINE_SMOOTH); if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON) { - if (!getActiveRenderPlugin()->isHmd()) { - // If there isn't an HMD, match exactly to avatar's head + if (getActiveDisplayPlugin()->isHmd()) { + // For an HMD, set the base position and orientation to that of the avatar body _myCamera.setPosition(_myAvatar->getHead()->getEyePosition()); _myCamera.setRotation(_myAvatar->getHead()->getCameraOrientation()); } else { - // For an HMD, set the base position and orientation to that of the avatar body + // If there isn't an HMD, match exactly to avatar's head _myCamera.setPosition(_myAvatar->getDefaultEyePosition()); _myCamera.setRotation(_myAvatar->getWorldAlignedOrientation()); } @@ -822,7 +822,7 @@ void Application::paintGL() { static const float THIRD_PERSON_CAMERA_DISTANCE = 1.5f; _myCamera.setPosition(_myAvatar->getDefaultEyePosition() + _myAvatar->getOrientation() * glm::vec3(0.0f, 0.0f, 1.0f) * THIRD_PERSON_CAMERA_DISTANCE * _myAvatar->getScale()); - if (getActiveRenderPlugin()->isHmd()) { + if (getActiveDisplayPlugin()->isHmd()) { _myCamera.setRotation(_myAvatar->getWorldAlignedOrientation()); } else { _myCamera.setRotation(_myAvatar->getHead()->getOrientation()); @@ -882,7 +882,7 @@ void Application::paintGL() { _offscreenContext->doneCurrent(); Q_ASSERT(!QOpenGLContext::currentContext()); - getActiveRenderPlugin()->render(gpu::GLBackend::getTextureID(finalFbo->getRenderBuffer(0))); + getActiveDisplayPlugin()->render(gpu::GLBackend::getTextureID(finalFbo->getRenderBuffer(0))); Q_ASSERT(!QOpenGLContext::currentContext()); _offscreenContext->makeCurrent(); _frameCount++; @@ -934,7 +934,7 @@ void Application::resizeGL(int width, int height) { updateProjectionMatrix(); glLoadIdentity(); - auto canvasSize = getActiveRenderPlugin()->getCanvasSize(); + auto canvasSize = getActiveDisplayPlugin()->getCanvasSize(); auto offscreenUi = DependencyManager::get(); offscreenUi->resize(fromGlm(canvasSize)); @@ -1306,7 +1306,7 @@ void Application::keyPressEvent(QKeyEvent* event) { break; } case Qt::Key_Escape: { - getActiveRenderPlugin()->abandonCalibration(); + getActiveDisplayPlugin()->abandonCalibration(); if (!event->isAutoRepeat()) { // this starts the HFCancelEvent HFBackEvent startBackEvent(HFBackEvent::startType()); @@ -1441,8 +1441,8 @@ void Application::mouseMoveEvent(QMouseEvent* event, unsigned int deviceID) { return; } - if (Menu::getInstance()->isOptionChecked(MenuOption::Fullscreen) - && !Menu::getInstance()->isOptionChecked(MenuOption::EnableVRMode)) { + + if (Menu::getInstance()->isOptionChecked(MenuOption::Fullscreen)) { // Show/hide menu bar in fullscreen if (event->globalY() > _menuBarHeight) { _fullscreenMenuWidget->setFixedHeight(0); @@ -1720,7 +1720,7 @@ void Application::idle() { { PerformanceTimer perfTimer("updateGL"); PerformanceWarning warn(showWarnings, "Application::idle()... updateGL()"); - getActiveRenderPlugin()->idle(); + getActiveDisplayPlugin()->idle(); } { @@ -1753,7 +1753,7 @@ void Application::setFullscreen(bool fullscreen) { // app menu in a fullscreen window. However the OSX mechanism hides the // application menu for fullscreen apps, so the check is not required. #ifndef Q_OS_MAC - if (Menu::getInstance()->isOptionChecked(MenuOption::EnableVRMode)) { + if (getActiveDisplayPlugin()->isHmd()) { if (fullscreen) { // Menu hide() disables menu commands, and show() after hide() doesn't work with Rift VR display. // So set height instead. @@ -1843,15 +1843,15 @@ void Application::setLowVelocityFilter(bool lowVelocityFilter) { } bool Application::mouseOnScreen() const { - return getActiveRenderPlugin()->isMouseOnScreen(); + return getActiveDisplayPlugin()->isMouseOnScreen(); } int Application::getMouseX() const { - return getActiveRenderPlugin()->getUiMousePosition().x; + return getActiveDisplayPlugin()->getUiMousePosition().x; } int Application::getMouseY() const { - return getActiveRenderPlugin()->getUiMousePosition().x; + return getActiveDisplayPlugin()->getUiMousePosition().x; } int Application::getMouseDragStartedX() const { @@ -2332,9 +2332,7 @@ void Application::updateCursor(float deltaTime) { } void Application::updateCursorVisibility() { - if (!_cursorVisible || - Menu::getInstance()->isOptionChecked(MenuOption::EnableVRMode) || - Menu::getInstance()->isOptionChecked(MenuOption::Enable3DTVMode)) { + if (!_cursorVisible || getActiveDisplayPlugin()->isStereo()) { _window->setCursor(Qt::BlankCursor); } else { _window->unsetCursor(); @@ -2714,7 +2712,7 @@ void Application::queryOctree(NodeType_t serverType, PacketType packetType, Node } bool Application::isHMDMode() const { - return getActiveRenderPlugin()->isHmd(); + return getActiveDisplayPlugin()->isHmd(); } QRect Application::getDesirableApplicationGeometry() { @@ -3287,7 +3285,7 @@ void Application::computeOffAxisFrustum(float& left, float& right, float& bottom float& farVal, glm::vec4& nearClipPlane, glm::vec4& farClipPlane) const { _displayViewFrustum.computeOffAxisFrustum(left, right, bottom, top, nearVal, farVal, nearClipPlane, farClipPlane); // allow 3DTV/Oculus to override parameters from camera - getActiveRenderPlugin()->overrideOffAxisFrustum(left, right, bottom, top, nearVal, farVal, nearClipPlane, farClipPlane); + getActiveDisplayPlugin()->overrideOffAxisFrustum(left, right, bottom, top, nearVal, farVal, nearClipPlane, farClipPlane); } bool Application::getShadowsEnabled() { @@ -3378,7 +3376,7 @@ void Application::resetSensors() { DependencyManager::get()->reset(); DependencyManager::get()->reset(); - getActiveRenderPlugin()->resetSensors(); + getActiveDisplayPlugin()->resetSensors(); //_leapmotion.reset(); #if 0 @@ -4461,12 +4459,12 @@ PickRay Application::computePickRay(float x, float y) const { return computeViewPickRay(x, y); } -glm::ivec2 Application::getCanvasSize() const { - return getActiveRenderPlugin()->getCanvasSize(); +glm::uvec2 Application::getCanvasSize() const { + return getActiveDisplayPlugin()->getCanvasSize(); } QSize Application::getDeviceSize() const { - return getActiveRenderPlugin()->getRecommendedFramebufferSize(); // _glWidget->getDeviceSize(); + return getActiveDisplayPlugin()->getRecommendedFramebufferSize(); // _glWidget->getDeviceSize(); } void Application::resizeGL() { @@ -4475,49 +4473,150 @@ void Application::resizeGL() { } bool Application::hasFocus() const { - return getActiveRenderPlugin()->hasFocus(); + return getActiveDisplayPlugin()->hasFocus(); } glm::vec2 Application::getViewportDimensions() const { return toGlm(getDeviceSize()); } + +glm::ivec2 Application::getTrueMousePosition() const { + return getActiveDisplayPlugin()->getTrueMousePosition(); +} +glm::quat Application::getHeadOrientation() const { + return getActiveDisplayPlugin()->headOrientation(); +} +glm::vec3 Application::getHeadPosition() const { + return getActiveDisplayPlugin()->headTranslation(); +} + int Application::getTrueMouseX() const { - return getActiveRenderPlugin()->getTrueMousePosition().x; + return getActiveDisplayPlugin()->getTrueMousePosition().x; } int Application::getTrueMouseY() const { - return getActiveRenderPlugin()->getTrueMousePosition().y; + return getActiveDisplayPlugin()->getTrueMousePosition().y; } bool Application::isThrottleRendering() const { - return getActiveRenderPlugin()->isThrottled(); + return getActiveDisplayPlugin()->isThrottled(); } -#include "plugins/render/NullRenderPlugin.h" -#include "plugins/render/WindowRenderPlugin.h" -#include "plugins/render/LegacyRenderPlugin.h" -static RenderPlugin * renderPlugin = nullptr; +using DisplayPluginPointer = QSharedPointer; -RenderPlugin * Application::getActiveRenderPlugin() { - if (nullptr == renderPlugin) { - //renderPlugin = new WindowRenderPlugin(); - renderPlugin = new LegacyRenderPlugin(); - renderPlugin->init(); - renderPlugin->activate(); - connect(renderPlugin, &RenderPlugin::requestRender, this, [&] { - this->paintGL(); - }); - connect(renderPlugin, &RenderPlugin::recommendedFramebufferSizeChanged, this, [&](const QSize & size) { - DependencyManager::get()->setFrameBufferSize(size * getRenderResolutionScale()); - this->resizeGL(size.width(), size.height()); - }); +#include "plugins/render/NullDisplayPlugin.h" +#include "plugins/render/WindowDisplayPlugin.h" +#include "plugins/render/LegacyDisplayPlugin.h" +#include "plugins/render/OculusDirectD3DDisplayPlugin.h" + +static DisplayPluginPointer _displayPlugin{ nullptr }; + +DisplayPlugin * Application::getActiveDisplayPlugin() { + if (nullptr == _displayPlugin) { + updateDisplayMode(); + Q_ASSERT(_displayPlugin); + } + return _displayPlugin.data(); +} + +const DisplayPlugin * Application::getActiveDisplayPlugin() const { + return ((Application*)this)->getActiveDisplayPlugin(); +} + + +/* + +QAction* action = NULL; +QAction* actionBefore = NULL; + +if (menuItemLocation >= 0 && destinationMenu->actions().size() > menuItemLocation) { +actionBefore = destinationMenu->actions()[menuItemLocation]; +} + +if (!actionBefore) { +if (receiver && member) { +action = destinationMenu->addAction(actionName, receiver, member, shortcut); +} else { +action = destinationMenu->addAction(actionName); +action->setShortcut(shortcut); +} +} else { +action = new QAction(actionName, destinationMenu); +action->setShortcut(shortcut); +destinationMenu->insertAction(actionBefore, action); + +if (receiver && member) { +connect(action, SIGNAL(triggered()), receiver, member); +} +} +action->setMenuRole(role); + +*/ +static void addDisplayPluginToMenu(DisplayPluginPointer displayPlugin, bool active = false) { + auto menu = Menu::getInstance(); + MenuItemProperties item(MenuOption::OutputMenu, displayPlugin->getName(), "", true, active); + item.isSeparator = false; + Q_ASSERT(!menu->menuItemExists(MenuOption::OutputMenu, item.menuItemName)); + menu->addMenuItem(item); + Q_ASSERT(menu->menuItemExists(MenuOption::OutputMenu, item.menuItemName)); +} + +using DisplayPluginList = QVector; + +// FIXME move to a plugin manager class +static const DisplayPluginList & getDisplayPlugins() { + static DisplayPluginList RENDER_PLUGINS; + static bool init = false; + if (!init) { + DisplayPluginPointer displayPlugin = DisplayPluginPointer(new LegacyDisplayPlugin()); // new WindowDisplayPlugin(); + if (displayPlugin->isSupported()) { + displayPlugin->init(); + RENDER_PLUGINS.push_back(DisplayPluginPointer(displayPlugin)); + QObject::connect(displayPlugin.data(), &DisplayPlugin::requestRender, [] { + qApp->paintGL(); + }); + QObject::connect(displayPlugin.data(), &DisplayPlugin::recommendedFramebufferSizeChanged, [](const QSize & size) { + DependencyManager::get()->setFrameBufferSize(size * qApp->getRenderResolutionScale()); + qApp->resizeGL(size.width(), size.height()); + }); + addDisplayPluginToMenu(displayPlugin, true); + } + + displayPlugin = DisplayPluginPointer(new NullDisplayPlugin()); + if (displayPlugin->isSupported()) { +#ifdef DEBUG + addDisplayPluginToMenu(displayPlugin); +#endif + displayPlugin->init(); + RENDER_PLUGINS.push_back(DisplayPluginPointer(displayPlugin)); + } + } + return RENDER_PLUGINS; +} + +void Application::updateDisplayMode() { + auto menu = Menu::getInstance(); + DisplayPluginPointer newDisplayPlugin; + foreach(DisplayPluginPointer displayPlugin, getDisplayPlugins()) { + QString name = displayPlugin->getName(); + QAction* action = menu->getActionForOption(name); + if (action->isChecked()) { + newDisplayPlugin = displayPlugin; + break; + } + } + if (_displayPlugin != newDisplayPlugin) { + if (_displayPlugin) { + _displayPlugin->deactivate(); + } + _offscreenContext->makeCurrent(); + _displayPlugin = newDisplayPlugin; + if (_displayPlugin) { + _displayPlugin->activate(); + } _offscreenContext->makeCurrent(); } - return renderPlugin; -} - -const RenderPlugin * Application::getActiveRenderPlugin() const { - return ((Application*)this)->getActiveRenderPlugin(); + Q_ASSERT_X(_displayPlugin, "Application::updateDisplayMode", "could not find an activated display plugin"); } diff --git a/interface/src/Application.h b/interface/src/Application.h index 6e4cb524e6..e55f61e832 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -75,7 +75,7 @@ #include "octree/OctreePacketProcessor.h" #include "UndoStackScriptingInterface.h" -class RenderPlugin; +class DisplayPlugin; class QGLWidget; class QKeyEvent; class QMouseEvent; @@ -184,7 +184,7 @@ public: bool event(QEvent* event); bool eventFilter(QObject* object, QEvent* event); - glm::ivec2 getCanvasSize() const; + glm::uvec2 getCanvasSize() const; QSize getDeviceSize() const; bool hasFocus() const; PickRay computePickRay() const; @@ -217,6 +217,7 @@ public: bool mouseOnScreen() const; int getMouseX() const; int getMouseY() const; + glm::ivec2 getTrueMousePosition() const; int getTrueMouseX() const; int getTrueMouseY() const; int getMouseDragStartedX() const; @@ -290,8 +291,11 @@ public: virtual int getBoundaryLevelAdjust() const; virtual PickRay computePickRay(float x, float y) const; virtual const glm::vec3& getAvatarPosition() const { return _myAvatar->getPosition(); } - RenderPlugin * getActiveRenderPlugin(); - const RenderPlugin * getActiveRenderPlugin() const; + + private: + DisplayPlugin * getActiveDisplayPlugin(); + const DisplayPlugin * getActiveDisplayPlugin() const; + public: NodeBounds& getNodeBoundsDisplay() { return _nodeBoundsDisplay; } @@ -320,7 +324,9 @@ public: // rendering of several elements depend on that // TODO: carry that information on the Camera as a setting bool isHMDMode() const; - + glm::quat getHeadOrientation() const; + glm::vec3 getHeadPosition() const; + QRect getDesirableApplicationGeometry(); RunningScriptsWidget* getRunningScriptsWidget() { return _runningScriptsWidget; } @@ -366,6 +372,7 @@ public slots: void nodeAdded(SharedNodePointer node); void nodeKilled(SharedNodePointer node); void packetSent(quint64 length); + void updateDisplayMode(); QVector pasteEntities(float x, float y, float z); bool exportEntities(const QString& filename, const QVector& entityIDs); diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index 90a9d3b22c..cfacbc3fd1 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -233,6 +233,11 @@ Menu::Menu() { avatar, SLOT(updateMotionBehavior())); MenuWrapper* viewMenu = addMenu("View"); + { + MenuWrapper* displayModeMenu = addMenu(MenuOption::OutputMenu); + QActionGroup* displayModeGroup = new QActionGroup(displayModeMenu); + displayModeGroup->setExclusive(true); + } addCheckableActionToQMenuAndActionHash(viewMenu, MenuOption::Fullscreen, @@ -265,16 +270,9 @@ Menu::Menu() { dialogsManager.data(), SLOT(hmdTools(bool))); - addCheckableActionToQMenuAndActionHash(viewMenu, MenuOption::EnableVRMode, 0, - false, - qApp, - SLOT(setEnableVRMode(bool))); - - addCheckableActionToQMenuAndActionHash(viewMenu, MenuOption::Enable3DTVMode, 0, - false, - qApp, - SLOT(setEnable3DTVMode(bool))); - + addActionToQMenuAndActionHash(editMenu, MenuOption::Attachments, 0, + dialogsManager.data(), SLOT(editAttachments())); + MenuWrapper* nodeBordersMenu = viewMenu->addMenu("Server Borders"); NodeBounds& nodeBounds = qApp->getNodeBoundsDisplay(); diff --git a/interface/src/Menu.h b/interface/src/Menu.h index 7d105687ab..20e2d7e428 100644 --- a/interface/src/Menu.h +++ b/interface/src/Menu.h @@ -181,8 +181,7 @@ namespace MenuOption { const QString EditEntitiesHelp = "Edit Entities Help..."; const QString Enable3DTVMode = "Enable 3DTV Mode"; const QString EnableCharacterController = "Enable avatar collisions"; - const QString EnableGlowEffect = "Enable Glow Effect (Warning: Poor Oculus Performance)"; - const QString EnableVRMode = "Enable VR Mode"; + const QString EnableGlowEffect = "Enable Glow Effect"; const QString ExpandMyAvatarSimulateTiming = "Expand /myAvatar/simulation"; const QString ExpandMyAvatarTiming = "Expand /myAvatar"; const QString ExpandOtherAvatarTiming = "Expand /otherAvatar"; @@ -215,6 +214,7 @@ namespace MenuOption { const QString OctreeStats = "Entity Statistics"; const QString OffAxisProjection = "Off-Axis Projection"; const QString OnlyDisplayTopTen = "Only Display Top Ten"; + const QString OutputMenu = "View>Display Mode"; const QString PackageModel = "Package Model..."; const QString Pair = "Pair"; const QString PhysicsShowOwned = "Highlight Simulation Ownership"; diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index 2c772c76b7..424882712c 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -34,7 +34,7 @@ #include #include "Application.h" -#include "plugins/render/RenderPlugin.h" +#include "plugins/render/DisplayPlugin.h" #include "AvatarManager.h" #include "Environment.h" #include "Menu.h" @@ -231,15 +231,14 @@ void MyAvatar::simulate(float deltaTime) { void MyAvatar::updateFromTrackers(float deltaTime) { glm::vec3 estimatedPosition, estimatedRotation; - auto renderPlugin = qApp->getActiveRenderPlugin(); - bool inHmd = renderPlugin->isHmd(); + bool inHmd = qApp->isHMDMode(); if (isPlaying() && inHmd) { return; } if (inHmd) { - estimatedPosition = renderPlugin->headTranslation(); + estimatedPosition = qApp->getHeadPosition(); estimatedPosition.x *= -1.0f; _trackedHeadPosition = estimatedPosition; @@ -886,15 +885,13 @@ void MyAvatar::updateLookAtTargetAvatar() { howManyLookingAtMe++; // Have that avatar look directly at my camera // Philip TODO: correct to look at left/right eye -#if 0 - if (OculusManager::isConnected()) { - avatar->getHead()->setCorrectedLookAtPosition(OculusManager::getLeftEyePosition()); - } else { -#endif + if (qApp->isHMDMode()) { + avatar->getHead()->setCorrectedLookAtPosition(Application::getInstance()->getViewFrustum()->getPosition()); + // FIXME what is the point of this? + // avatar->getHead()->setCorrectedLookAtPosition(OculusManager::getLeftEyePosition()); + } else { avatar->getHead()->setCorrectedLookAtPosition(Application::getInstance()->getViewFrustum()->getPosition()); -#if 0 } -#endif } else { avatar->getHead()->clearCorrectedLookAtPosition(); } @@ -1185,8 +1182,7 @@ void MyAvatar::renderBody(ViewFrustum* renderFrustum, RenderArgs::RenderMode ren renderFrustum->setNearClip(DEFAULT_NEAR_CLIP); } else { float clipDistance = _skeletonModel.getHeadClipDistance(); -#if 0 - if (OculusManager::isConnected()) { + if (qApp->isHMDMode()) { // If avatar is horizontally in front of camera, increase clip distance by the amount it is in front. glm::vec3 cameraToAvatar = _position - cameraPos; cameraToAvatar.y = 0.0f; @@ -1196,7 +1192,6 @@ void MyAvatar::renderBody(ViewFrustum* renderFrustum, RenderArgs::RenderMode ren clipDistance += headOffset; } } -#endif renderFrustum->setNearClip(clipDistance); } } @@ -1231,13 +1226,11 @@ void MyAvatar::updateOrientation(float deltaTime) { // Gather rotation information from keyboard const float TIME_BETWEEN_HMD_TURNS = 0.5f; const float HMD_TURN_DEGREES = 22.5f; -#if 0 - if (!OculusManager::isConnected()) { + if (!qApp->isHMDMode()) { // Smoothly rotate body with arrow keys if not in HMD _bodyYawDelta -= _driveKeys[ROT_RIGHT] * YAW_SPEED * deltaTime; _bodyYawDelta += _driveKeys[ROT_LEFT] * YAW_SPEED * deltaTime; } else { -#endif // Jump turns if in HMD if (_driveKeys[ROT_RIGHT] || _driveKeys[ROT_LEFT]) { if (_turningKeyPressTime == 0.0f) { @@ -1251,9 +1244,7 @@ void MyAvatar::updateOrientation(float deltaTime) { } else { _turningKeyPressTime = 0.0f; } -#if 0 } -#endif getHead()->setBasePitch(getHead()->getBasePitch() + (_driveKeys[ROT_UP] - _driveKeys[ROT_DOWN]) * PITCH_SPEED * deltaTime); // update body orientation by movement inputs @@ -1269,30 +1260,23 @@ void MyAvatar::updateOrientation(float deltaTime) { float MINIMUM_ROTATION_RATE = 2.0f; if (fabs(_bodyYawDelta) < MINIMUM_ROTATION_RATE) { _bodyYawDelta = 0.0f; } -#if 0 - if (OculusManager::isConnected()) { + if (qApp->isHMDMode()) { // these angles will be in radians - float yaw, pitch, roll; - OculusManager::getEulerAngles(yaw, pitch, roll); + glm::quat orientation = qApp->getHeadOrientation(); // ... so they need to be converted to degrees before we do math... - yaw *= DEGREES_PER_RADIAN; - pitch *= DEGREES_PER_RADIAN; - roll *= DEGREES_PER_RADIAN; - + glm::vec3 euler = glm::eulerAngles(orientation) * DEGREES_PER_RADIAN; + //Invert yaw and roll when in mirror mode - Head* head = getHead(); if (Application::getInstance()->getCamera()->getMode() == CAMERA_MODE_MIRROR) { - head->setBaseYaw(-yaw); - head->setBasePitch(pitch); - head->setBaseRoll(-roll); - } else { - head->setBaseYaw(yaw); - head->setBasePitch(pitch); - head->setBaseRoll(roll); + YAW(euler) *= -1.0; + ROLL(euler) *= -1.0; } + Head* head = getHead(); + head->setBaseYaw(YAW(euler)); + head->setBasePitch(PITCH(euler)); + head->setBaseRoll(ROLL(euler)); } -#endif } glm::vec3 MyAvatar::applyKeyboardMotor(float deltaTime, const glm::vec3& localVelocity, bool isHovering) { diff --git a/interface/src/plugins/PluginManager.h b/interface/src/plugins/PluginManager.h index 96cb777235..2d8ab9a9f4 100644 --- a/interface/src/plugins/PluginManager.h +++ b/interface/src/plugins/PluginManager.h @@ -1,12 +1,12 @@ #pragma once #include "plugins/Plugin.h" -#include "plugins/render/RenderPlugin.h" +#include "plugins/render/DisplayPlugin.h" #include #include class PluginManager : public QObject { public: static PluginManager * getInstance(); - const QList> getRenderPlugins(); + const QList> getDisplayPlugins(); }; diff --git a/interface/src/plugins/render/RenderPlugin.cpp b/interface/src/plugins/render/DisplayPlugin.cpp similarity index 82% rename from interface/src/plugins/render/RenderPlugin.cpp rename to interface/src/plugins/render/DisplayPlugin.cpp index 11052aca11..d9d649019f 100644 --- a/interface/src/plugins/render/RenderPlugin.cpp +++ b/interface/src/plugins/render/DisplayPlugin.cpp @@ -1,5 +1,5 @@ // -// RenderPlugin.cpp +// DisplayPlugin.cpp // // Created by Bradley Austin Davis on 2014/04/13. // Copyright 2015 High Fidelity, Inc. @@ -7,9 +7,9 @@ // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include "RenderPlugin.h" +#include "DisplayPlugin.h" -bool RenderPlugin::isMouseOnScreen() const { +bool DisplayPlugin::isMouseOnScreen() const { glm::ivec2 mousePosition = getTrueMousePosition(); return (glm::all(glm::greaterThanEqual(mousePosition, glm::ivec2(0))) && glm::all(glm::lessThanEqual(mousePosition, glm::ivec2(getCanvasSize())))); diff --git a/interface/src/plugins/render/RenderPlugin.h b/interface/src/plugins/render/DisplayPlugin.h similarity index 97% rename from interface/src/plugins/render/RenderPlugin.h rename to interface/src/plugins/render/DisplayPlugin.h index 6a8328ee48..399f12b244 100644 --- a/interface/src/plugins/render/RenderPlugin.h +++ b/interface/src/plugins/render/DisplayPlugin.h @@ -1,5 +1,5 @@ // -// RenderPlugin.h +// DisplayPlugin.h // // Created by Bradley Austin Davis on 2014/04/13. // Copyright 2015 High Fidelity, Inc. @@ -19,7 +19,7 @@ #include #include -class RenderPlugin : public Plugin { +class DisplayPlugin : public Plugin { Q_OBJECT public: virtual bool isHmd() const { return false; } diff --git a/interface/src/plugins/render/HmdRenderPlugin.cpp b/interface/src/plugins/render/HmdDisplayPlugin.cpp similarity index 81% rename from interface/src/plugins/render/HmdRenderPlugin.cpp rename to interface/src/plugins/render/HmdDisplayPlugin.cpp index eb2efcc8a8..bfe4a088fa 100644 --- a/interface/src/plugins/render/HmdRenderPlugin.cpp +++ b/interface/src/plugins/render/HmdDisplayPlugin.cpp @@ -1,5 +1,5 @@ // -// HmdRenderPlugin.cpp +// HmdDisplayPlugin.cpp // // Created by Bradley Austin Davis on 2014/04/13. // Copyright 2015 High Fidelity, Inc. @@ -8,4 +8,4 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include "HmdRenderPlugin.h" +#include "HmdDisplayPlugin.h" diff --git a/interface/src/plugins/render/HmdRenderPlugin.h b/interface/src/plugins/render/HmdDisplayPlugin.h similarity index 74% rename from interface/src/plugins/render/HmdRenderPlugin.h rename to interface/src/plugins/render/HmdDisplayPlugin.h index aa158a1f52..1156bafcda 100644 --- a/interface/src/plugins/render/HmdRenderPlugin.h +++ b/interface/src/plugins/render/HmdDisplayPlugin.h @@ -1,5 +1,5 @@ // -// HmdRenderPlugin.h +// HmdDisplayPlugin.h // // Created by Bradley Austin Davis on 2014/04/13. // Copyright 2015 High Fidelity, Inc. @@ -8,8 +8,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #pragma once -#include "StereoRenderPlugin.h" +#include "StereoDisplayPlugin.h" -class HmdRenderPlugin : public StereoRenderPlugin { +class HmdDisplayPlugin : public StereoDisplayPlugin { virtual bool isHmd() const final { return true; } }; diff --git a/interface/src/plugins/render/LegacyRenderPlugin.cpp b/interface/src/plugins/render/LegacyDisplayPlugin.cpp similarity index 71% rename from interface/src/plugins/render/LegacyRenderPlugin.cpp rename to interface/src/plugins/render/LegacyDisplayPlugin.cpp index 93170517b3..79cc433543 100644 --- a/interface/src/plugins/render/LegacyRenderPlugin.cpp +++ b/interface/src/plugins/render/LegacyDisplayPlugin.cpp @@ -1,5 +1,5 @@ // -// LegacyRenderPlugin.cpp +// LegacyDisplayPlugin.cpp // // Created by Bradley Austin Davis on 2014/04/13. // Copyright 2015 High Fidelity, Inc. @@ -8,19 +8,19 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include "Application.h" -#include "LegacyRenderPlugin.h" +#include "LegacyDisplayPlugin.h" #include "MainWindow.h" #include -const QString LegacyRenderPlugin::NAME("LegacyRenderPlugin"); +const QString LegacyDisplayPlugin::NAME("2D Monitor (GL Windgets)"); -const QString & LegacyRenderPlugin::getName() { +const QString & LegacyDisplayPlugin::getName() { return NAME; } static QWidget * oldWidget = nullptr; -void LegacyRenderPlugin::activate() { +void LegacyDisplayPlugin::activate() { _window = new GLCanvas(); QGLFormat format(QGL::NoDepthBuffer | QGL::NoStencilBuffer); _window->setContext(new QGLContext(format), @@ -37,7 +37,7 @@ void LegacyRenderPlugin::activate() { _window->installEventFilter(DependencyManager::get().data()); } -void LegacyRenderPlugin::deactivate() { +void LegacyDisplayPlugin::deactivate() { _window->removeEventFilter(DependencyManager::get().data()); _window->removeEventFilter(qApp); qApp->getWindow()->setCentralWidget(oldWidget); @@ -48,38 +48,38 @@ void LegacyRenderPlugin::deactivate() { _window = nullptr; } -QSize LegacyRenderPlugin::getRecommendedFramebufferSize() const { +QSize LegacyDisplayPlugin::getRecommendedFramebufferSize() const { return _window->getDeviceSize(); } -void LegacyRenderPlugin::makeCurrent() { +void LegacyDisplayPlugin::makeCurrent() { _window->makeCurrent(); QSize windowSize = _window->size(); glViewport(0, 0, windowSize.width(), windowSize.height()); } -void LegacyRenderPlugin::doneCurrent() { +void LegacyDisplayPlugin::doneCurrent() { _window->doneCurrent(); } -void LegacyRenderPlugin::swapBuffers() { +void LegacyDisplayPlugin::swapBuffers() { _window->swapBuffers(); glFinish(); } -void LegacyRenderPlugin::idle() { +void LegacyDisplayPlugin::idle() { _window->updateGL(); } -glm::ivec2 LegacyRenderPlugin::getCanvasSize() const { +glm::ivec2 LegacyDisplayPlugin::getCanvasSize() const { return toGlm(_window->size()); } -bool LegacyRenderPlugin::hasFocus() const { +bool LegacyDisplayPlugin::hasFocus() const { return _window->hasFocus(); } -PickRay LegacyRenderPlugin::computePickRay(const glm::vec2 & pos) const { +PickRay LegacyDisplayPlugin::computePickRay(const glm::vec2 & pos) const { return PickRay(); } @@ -87,6 +87,6 @@ bool isMouseOnScreen() { return false; } -bool LegacyRenderPlugin::isThrottled() { +bool LegacyDisplayPlugin::isThrottled() { return _window->isThrottleRendering(); } \ No newline at end of file diff --git a/interface/src/plugins/render/LegacyRenderPlugin.h b/interface/src/plugins/render/LegacyDisplayPlugin.h similarity index 87% rename from interface/src/plugins/render/LegacyRenderPlugin.h rename to interface/src/plugins/render/LegacyDisplayPlugin.h index 68161f6c7d..9654278dcd 100644 --- a/interface/src/plugins/render/LegacyRenderPlugin.h +++ b/interface/src/plugins/render/LegacyDisplayPlugin.h @@ -1,5 +1,5 @@ // -// LegacyRenderPlugin.h +// LegacyDisplayPlugin.h // // Created by Bradley Austin Davis on 2014/04/13. // Copyright 2015 High Fidelity, Inc. @@ -9,10 +9,10 @@ // #pragma once -#include "SimpleRenderPlugin.h" +#include "SimpleDisplayPlugin.h" #include "GLCanvas.h" -class LegacyRenderPlugin : public SimpleRenderPlugin { +class LegacyDisplayPlugin : public SimpleDisplayPlugin { Q_OBJECT public: static const QString NAME; diff --git a/interface/src/plugins/render/NullDisplayPlugin.cpp b/interface/src/plugins/render/NullDisplayPlugin.cpp new file mode 100644 index 0000000000..97683a1100 --- /dev/null +++ b/interface/src/plugins/render/NullDisplayPlugin.cpp @@ -0,0 +1,44 @@ +// +// NullDisplayPlugin.cpp +// +// Created by Bradley Austin Davis on 2014/04/13. +// Copyright 2015 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// +#include "NullDisplayPlugin.h" + +const QString NullDisplayPlugin::NAME("NullDisplayPlugin"); + +const QString & NullDisplayPlugin::getName() { + return NAME; +} + +QSize NullDisplayPlugin::getRecommendedFramebufferSize() const { + return QSize(100, 100); +} + +glm::ivec2 NullDisplayPlugin::getCanvasSize() const { + return glm::ivec2(100, 100); +} + +bool NullDisplayPlugin::hasFocus() const { + return false; +} + +glm::ivec2 NullDisplayPlugin::getRelativeMousePosition() const { + return glm::ivec2(); +} + +glm::ivec2 NullDisplayPlugin::getTrueMousePosition() const { + return glm::ivec2(); +} + +PickRay NullDisplayPlugin::computePickRay(const glm::vec2 & pos) const { + return PickRay(); +} + +bool NullDisplayPlugin::isMouseOnScreen() { + return false; +} diff --git a/interface/src/plugins/render/NullRenderPlugin.h b/interface/src/plugins/render/NullDisplayPlugin.h similarity index 83% rename from interface/src/plugins/render/NullRenderPlugin.h rename to interface/src/plugins/render/NullDisplayPlugin.h index dfe0e5a0bf..c434ddd3f5 100644 --- a/interface/src/plugins/render/NullRenderPlugin.h +++ b/interface/src/plugins/render/NullDisplayPlugin.h @@ -1,5 +1,5 @@ // -// NullRenderPlugin.h +// NullDisplayPlugin.h // // Created by Bradley Austin Davis on 2014/04/13. // Copyright 2015 High Fidelity, Inc. @@ -9,13 +9,13 @@ // #pragma once -#include "RenderPlugin.h" +#include "DisplayPlugin.h" -class NullRenderPlugin : public RenderPlugin { +class NullDisplayPlugin : public DisplayPlugin { public: static const QString NAME; - virtual ~NullRenderPlugin() final {} + virtual ~NullDisplayPlugin() final {} virtual const QString & getName(); virtual QSize getRecommendedFramebufferSize() const; diff --git a/interface/src/plugins/render/NullRenderPlugin.cpp b/interface/src/plugins/render/NullRenderPlugin.cpp deleted file mode 100644 index f2221a5767..0000000000 --- a/interface/src/plugins/render/NullRenderPlugin.cpp +++ /dev/null @@ -1,44 +0,0 @@ -// -// NullRenderPlugin.cpp -// -// Created by Bradley Austin Davis on 2014/04/13. -// Copyright 2015 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// -#include "NullRenderPlugin.h" - -const QString NullRenderPlugin::NAME("NullRenderPlugin"); - -const QString & NullRenderPlugin::getName() { - return NAME; -} - -QSize NullRenderPlugin::getRecommendedFramebufferSize() const { - return QSize(100, 100); -} - -glm::ivec2 NullRenderPlugin::getCanvasSize() const { - return glm::ivec2(100, 100); -} - -bool NullRenderPlugin::hasFocus() const { - return false; -} - -glm::ivec2 NullRenderPlugin::getRelativeMousePosition() const { - return glm::ivec2(); -} - -glm::ivec2 NullRenderPlugin::getTrueMousePosition() const { - return glm::ivec2(); -} - -PickRay NullRenderPlugin::computePickRay(const glm::vec2 & pos) const { - return PickRay(); -} - -bool NullRenderPlugin::isMouseOnScreen() { - return false; -} diff --git a/interface/src/plugins/render/OculusBaseRenderPlugin.cpp b/interface/src/plugins/render/OculusBaseDisplayPlugin.cpp similarity index 84% rename from interface/src/plugins/render/OculusBaseRenderPlugin.cpp rename to interface/src/plugins/render/OculusBaseDisplayPlugin.cpp index fd1bdfb6af..2d423424eb 100644 --- a/interface/src/plugins/render/OculusBaseRenderPlugin.cpp +++ b/interface/src/plugins/render/OculusBaseDisplayPlugin.cpp @@ -1,5 +1,5 @@ // -// OculusBaseRenderPlugin.cpp +// OculusBaseDisplayPlugin.cpp // // Created by Bradley Austin Davis on 2014/04/13. // Copyright 2015 High Fidelity, Inc. @@ -7,23 +7,23 @@ // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include "OculusBaseRenderPlugin.h" +#include "OculusBaseDisplayPlugin.h" #include -bool OculusBaseRenderPlugin::sdkInitialized = false; +bool OculusBaseDisplayPlugin::sdkInitialized = false; -bool OculusBaseRenderPlugin::enableSdk() { +bool OculusBaseDisplayPlugin::enableSdk() { sdkInitialized = ovr_Initialize(); return sdkInitialized; } -void OculusBaseRenderPlugin::disableSdk() { +void OculusBaseDisplayPlugin::disableSdk() { ovr_Shutdown(); sdkInitialized = false; } -void OculusBaseRenderPlugin::withSdkActive(std::function f) { +void OculusBaseDisplayPlugin::withSdkActive(std::function f) { bool activateSdk = !sdkInitialized; if (activateSdk && !enableSdk()) { return; @@ -34,7 +34,7 @@ void OculusBaseRenderPlugin::withSdkActive(std::function f) { } } -bool OculusBaseRenderPlugin::isSupported() { +bool OculusBaseDisplayPlugin::isSupported() { bool attached = false; withSdkActive([&] { attached = ovrHmd_Detect(); @@ -42,11 +42,11 @@ bool OculusBaseRenderPlugin::isSupported() { return attached; } -void OculusBaseRenderPlugin::activate() { +void OculusBaseDisplayPlugin::activate() { enableSdk(); } -void OculusBaseRenderPlugin::deactivate() { +void OculusBaseDisplayPlugin::deactivate() { disableSdk(); } diff --git a/interface/src/plugins/render/OculusBaseRenderPlugin.h b/interface/src/plugins/render/OculusBaseDisplayPlugin.h similarity index 88% rename from interface/src/plugins/render/OculusBaseRenderPlugin.h rename to interface/src/plugins/render/OculusBaseDisplayPlugin.h index aa937bf12a..7eb0a42a19 100644 --- a/interface/src/plugins/render/OculusBaseRenderPlugin.h +++ b/interface/src/plugins/render/OculusBaseDisplayPlugin.h @@ -1,5 +1,5 @@ // -// OculusBaseRenderPlugin.h +// OculusBaseDisplayPlugin.h // // Created by Bradley Austin Davis on 2014/04/13. // Copyright 2015 High Fidelity, Inc. @@ -9,10 +9,10 @@ // #pragma once -#include "HmdRenderPlugin.h" +#include "HmdDisplayPlugin.h" #include -class OculusBaseRenderPlugin : public HmdRenderPlugin { +class OculusBaseDisplayPlugin : public HmdDisplayPlugin { public: virtual bool isSupported(); diff --git a/interface/src/plugins/render/OculusExtendedRenderPlugin.cpp b/interface/src/plugins/render/OculusDirectD3DDisplayPlugin.cpp similarity index 75% rename from interface/src/plugins/render/OculusExtendedRenderPlugin.cpp rename to interface/src/plugins/render/OculusDirectD3DDisplayPlugin.cpp index 5ed0c5cacf..ec1b9a1986 100644 --- a/interface/src/plugins/render/OculusExtendedRenderPlugin.cpp +++ b/interface/src/plugins/render/OculusDirectD3DDisplayPlugin.cpp @@ -1,5 +1,5 @@ // -// OculusExtendedRenderPlugin.cpp +// OculusDirectD3DDisplayPlugin.cpp // // Created by Bradley Austin Davis on 2014/04/13. // Copyright 2015 High Fidelity, Inc. @@ -7,4 +7,4 @@ // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include "OculusExtendedRenderPlugin.h" +#include "OculusDirectD3DDisplayPlugin.h" diff --git a/interface/src/plugins/render/OculusDirectD3DRenderPlugin.h b/interface/src/plugins/render/OculusDirectD3DDisplayPlugin.h similarity index 78% rename from interface/src/plugins/render/OculusDirectD3DRenderPlugin.h rename to interface/src/plugins/render/OculusDirectD3DDisplayPlugin.h index 3874481e69..531e779a3b 100644 --- a/interface/src/plugins/render/OculusDirectD3DRenderPlugin.h +++ b/interface/src/plugins/render/OculusDirectD3DDisplayPlugin.h @@ -1,5 +1,5 @@ // -// OculusDirectD3DRenderPlugin.h +// OculusDirectD3DDisplayPlugin.h // // Created by Bradley Austin Davis on 2014/04/13. // Copyright 2015 High Fidelity, Inc. @@ -9,4 +9,4 @@ // #pragma once -#include "OculusBaseRenderPlugin.h" +#include "OculusBaseDisplayPlugin.h" diff --git a/interface/src/plugins/render/OculusDirectRenderPlugin.cpp b/interface/src/plugins/render/OculusDirectDisplayPlugin.cpp similarity index 77% rename from interface/src/plugins/render/OculusDirectRenderPlugin.cpp rename to interface/src/plugins/render/OculusDirectDisplayPlugin.cpp index cd96ff0fad..569597f2cc 100644 --- a/interface/src/plugins/render/OculusDirectRenderPlugin.cpp +++ b/interface/src/plugins/render/OculusDirectDisplayPlugin.cpp @@ -1,5 +1,5 @@ // -// OculusDirectRenderPlugin.cpp +// OculusDirectDisplayPlugin.cpp // // Created by Bradley Austin Davis on 2014/04/13. // Copyright 2015 High Fidelity, Inc. @@ -7,4 +7,4 @@ // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include "OculusDirectRenderPlugin.h" +#include "OculusDirectDisplayPlugin.h" diff --git a/interface/src/plugins/render/OculusDirectRenderPlugin.h b/interface/src/plugins/render/OculusDirectDisplayPlugin.h similarity index 79% rename from interface/src/plugins/render/OculusDirectRenderPlugin.h rename to interface/src/plugins/render/OculusDirectDisplayPlugin.h index afa72cb92e..5f3fc911c7 100644 --- a/interface/src/plugins/render/OculusDirectRenderPlugin.h +++ b/interface/src/plugins/render/OculusDirectDisplayPlugin.h @@ -1,5 +1,5 @@ // -// OculusDirectRenderPlugin.h +// OculusDirectDisplayPlugin.h // // Created by Bradley Austin Davis on 2014/04/13. // Copyright 2015 High Fidelity, Inc. @@ -9,4 +9,4 @@ // #pragma once -#include "OculusBaseRenderPlugin.h" +#include "OculusBaseDisplayPlugin.h" diff --git a/interface/src/plugins/render/OculusDirectD3DRenderPlugin.cpp b/interface/src/plugins/render/OculusExtendedDisplayPlugin.cpp similarity index 76% rename from interface/src/plugins/render/OculusDirectD3DRenderPlugin.cpp rename to interface/src/plugins/render/OculusExtendedDisplayPlugin.cpp index fab4fd104f..cbef7d11f3 100644 --- a/interface/src/plugins/render/OculusDirectD3DRenderPlugin.cpp +++ b/interface/src/plugins/render/OculusExtendedDisplayPlugin.cpp @@ -1,5 +1,5 @@ // -// OculusDirectD3DRenderPlugin.cpp +// OculusExtendedDisplayPlugin.cpp // // Created by Bradley Austin Davis on 2014/04/13. // Copyright 2015 High Fidelity, Inc. @@ -7,4 +7,4 @@ // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include "OculusDirectD3DRenderPlugin.h" +#include "OculusExtendedDisplayPlugin.h" diff --git a/interface/src/plugins/render/OculusExtendedRenderPlugin.h b/interface/src/plugins/render/OculusExtendedDisplayPlugin.h similarity index 78% rename from interface/src/plugins/render/OculusExtendedRenderPlugin.h rename to interface/src/plugins/render/OculusExtendedDisplayPlugin.h index a9e9a51f0c..674a79bd5a 100644 --- a/interface/src/plugins/render/OculusExtendedRenderPlugin.h +++ b/interface/src/plugins/render/OculusExtendedDisplayPlugin.h @@ -1,5 +1,5 @@ // -// OculusExtendedRenderPlugin.h +// OculusExtendedDisplayPlugin.h // // Created by Bradley Austin Davis on 2014/04/13. // Copyright 2015 High Fidelity, Inc. @@ -9,4 +9,4 @@ // #pragma once -#include "OculusBaseRenderPlugin.h" +#include "OculusBaseDisplayPlugin.h" diff --git a/interface/src/plugins/render/SimpleRenderPlugin.cpp b/interface/src/plugins/render/SimpleDisplayPlugin.cpp similarity index 82% rename from interface/src/plugins/render/SimpleRenderPlugin.cpp rename to interface/src/plugins/render/SimpleDisplayPlugin.cpp index 40c80f48d6..d68a32b1ea 100644 --- a/interface/src/plugins/render/SimpleRenderPlugin.cpp +++ b/interface/src/plugins/render/SimpleDisplayPlugin.cpp @@ -1,5 +1,5 @@ // -// SimpleRenderPlugin.cpp +// SimpleDisplayPlugin.cpp // // Created by Bradley Austin Davis on 2014/04/13. // Copyright 2015 High Fidelity, Inc. @@ -7,7 +7,7 @@ // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include "SimpleRenderPlugin.h" +#include "SimpleDisplayPlugin.h" #include #include diff --git a/interface/src/plugins/render/SimpleRenderPlugin.h b/interface/src/plugins/render/SimpleDisplayPlugin.h similarity index 92% rename from interface/src/plugins/render/SimpleRenderPlugin.h rename to interface/src/plugins/render/SimpleDisplayPlugin.h index 8a8ee7edd4..55ce69b323 100644 --- a/interface/src/plugins/render/SimpleRenderPlugin.h +++ b/interface/src/plugins/render/SimpleDisplayPlugin.h @@ -1,5 +1,5 @@ // -// SimpleRenderPlugin.h +// SimpleDisplayPlugin.h // // Created by Bradley Austin Davis on 2014/04/13. // Copyright 2015 High Fidelity, Inc. @@ -9,13 +9,13 @@ // #pragma once -#include "RenderPlugin.h" +#include "DisplayPlugin.h" #include #include #include template -class SimpleRenderPlugin : public RenderPlugin { +class SimpleDisplayPlugin : public DisplayPlugin { public: virtual void render(int finalSceneTexture) { makeCurrent(); diff --git a/interface/src/plugins/render/StereoRenderPlugin.cpp b/interface/src/plugins/render/StereoDisplayPlugin.cpp similarity index 80% rename from interface/src/plugins/render/StereoRenderPlugin.cpp rename to interface/src/plugins/render/StereoDisplayPlugin.cpp index 705133dcc4..25070a4967 100644 --- a/interface/src/plugins/render/StereoRenderPlugin.cpp +++ b/interface/src/plugins/render/StereoDisplayPlugin.cpp @@ -1,5 +1,5 @@ // -// StereoRenderPlugin.cpp +// StereoDisplayPlugin.cpp // // Created by Bradley Austin Davis on 2014/04/13. // Copyright 2015 High Fidelity, Inc. @@ -7,4 +7,4 @@ // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include "StereoRenderPlugin.h" +#include "StereoDisplayPlugin.h" diff --git a/interface/src/plugins/render/StereoRenderPlugin.h b/interface/src/plugins/render/StereoDisplayPlugin.h similarity index 75% rename from interface/src/plugins/render/StereoRenderPlugin.h rename to interface/src/plugins/render/StereoDisplayPlugin.h index 69504e2ccf..e3944ff878 100644 --- a/interface/src/plugins/render/StereoRenderPlugin.h +++ b/interface/src/plugins/render/StereoDisplayPlugin.h @@ -1,5 +1,5 @@ // -// StereoRenderPlugin.h +// StereoDisplayPlugin.h // // Created by Bradley Austin Davis on 2014/04/13. // Copyright 2015 High Fidelity, Inc. @@ -9,9 +9,9 @@ // #pragma once -#include "RenderPlugin.h" +#include "DisplayPlugin.h" -class StereoRenderPlugin : public RenderPlugin { +class StereoDisplayPlugin : public DisplayPlugin { virtual bool isStereo() const final { return true; } }; diff --git a/interface/src/plugins/render/Tv3dRenderPlugin.cpp b/interface/src/plugins/render/Tv3dDisplayPlugin.cpp similarity index 77% rename from interface/src/plugins/render/Tv3dRenderPlugin.cpp rename to interface/src/plugins/render/Tv3dDisplayPlugin.cpp index 750d1a1743..b86e20831f 100644 --- a/interface/src/plugins/render/Tv3dRenderPlugin.cpp +++ b/interface/src/plugins/render/Tv3dDisplayPlugin.cpp @@ -1,5 +1,5 @@ // -// Tv3dRenderPlugin.cpp +// Tv3dDisplayPlugin.cpp // // Created by Bradley Austin Davis on 2014/04/13. // Copyright 2015 High Fidelity, Inc. @@ -8,16 +8,16 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include "Tv3dRenderPlugin.h" +#include "Tv3dDisplayPlugin.h" -const QString Tv3dRenderPlugin::NAME("Tv3dRenderPlugin"); +const QString Tv3dDisplayPlugin::NAME("Tv3dDisplayPlugin"); -const QString & Tv3dRenderPlugin::getName() { +const QString & Tv3dDisplayPlugin::getName() { return NAME; } -void Tv3dRenderPlugin::overrideOffAxisFrustum( +void Tv3dDisplayPlugin::overrideOffAxisFrustum( float& left, float& right, float& bottom, float& top, float& nearVal, float& farVal, glm::vec4& nearClipPlane, glm::vec4& farClipPlane) const { diff --git a/interface/src/plugins/render/Tv3dRenderPlugin.h b/interface/src/plugins/render/Tv3dDisplayPlugin.h similarity index 83% rename from interface/src/plugins/render/Tv3dRenderPlugin.h rename to interface/src/plugins/render/Tv3dDisplayPlugin.h index ba25526f6c..5c178b7260 100644 --- a/interface/src/plugins/render/Tv3dRenderPlugin.h +++ b/interface/src/plugins/render/Tv3dDisplayPlugin.h @@ -1,5 +1,5 @@ // -// Tv3dRenderPlugin.h +// Tv3dDisplayPlugin.h // // Created by Bradley Austin Davis on 2014/04/13. // Copyright 2015 High Fidelity, Inc. @@ -10,9 +10,9 @@ #pragma once -#include "StereoRenderPlugin.h" +#include "StereoDisplayPlugin.h" -class Tv3dRenderPlugin : public StereoRenderPlugin { +class Tv3dDisplayPlugin : public StereoDisplayPlugin { Q_OBJECT public: static const QString NAME; diff --git a/interface/src/plugins/render/WindowRenderPlugin.cpp b/interface/src/plugins/render/WindowDisplayPlugin.cpp similarity index 95% rename from interface/src/plugins/render/WindowRenderPlugin.cpp rename to interface/src/plugins/render/WindowDisplayPlugin.cpp index 78a0849bba..4c786d9f63 100644 --- a/interface/src/plugins/render/WindowRenderPlugin.cpp +++ b/interface/src/plugins/render/WindowDisplayPlugin.cpp @@ -1,5 +1,5 @@ // -// WindowRenderPlugin.cpp +// WindowDisplayPlugin.cpp // // Created by Bradley Austin Davis on 2014/04/13. // Copyright 2015 High Fidelity, Inc. @@ -7,24 +7,24 @@ // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include "WindowRenderPlugin.h" +#include "WindowDisplayPlugin.h" #include "RenderUtil.h" #include -WindowRenderPlugin::WindowRenderPlugin() { +WindowDisplayPlugin::WindowDisplayPlugin() { connect(&_timer, &QTimer::timeout, this, [&] { emit requestRender(); }); } -const QString WindowRenderPlugin::NAME("WindowRenderPlugin"); +const QString WindowDisplayPlugin::NAME("WindowDisplayPlugin"); -const QString & WindowRenderPlugin::getName() { +const QString & WindowDisplayPlugin::getName() { return NAME; } -void WindowRenderPlugin::activate() { +void WindowDisplayPlugin::activate() { Q_ASSERT(nullptr == _window); _context = new QOpenGLContext; @@ -52,7 +52,7 @@ void WindowRenderPlugin::activate() { _timer.start(8); } -void WindowRenderPlugin::deactivate() { +void WindowDisplayPlugin::deactivate() { _timer.stop(); _context->doneCurrent(); _context->deleteLater(); @@ -62,7 +62,7 @@ void WindowRenderPlugin::deactivate() { _window = nullptr; } -bool WindowRenderPlugin::eventFilter(QObject* object, QEvent* event) { +bool WindowDisplayPlugin::eventFilter(QObject* object, QEvent* event) { switch (event->type()) { case QEvent::MouseButtonPress: case QEvent::MouseButtonRelease: @@ -80,21 +80,21 @@ bool WindowRenderPlugin::eventFilter(QObject* object, QEvent* event) { return false; } -QSize WindowRenderPlugin::getRecommendedFramebufferSize() const { +QSize WindowDisplayPlugin::getRecommendedFramebufferSize() const { return _window->size(); } -void WindowRenderPlugin::makeCurrent() { +void WindowDisplayPlugin::makeCurrent() { _context->makeCurrent(_window); QSize windowSize = _window->size(); glViewport(0, 0, windowSize.width(), windowSize.height()); } -void WindowRenderPlugin::doneCurrent() { +void WindowDisplayPlugin::doneCurrent() { _context->doneCurrent(); } -void WindowRenderPlugin::swapBuffers() { +void WindowDisplayPlugin::swapBuffers() { _context->swapBuffers(_window); } diff --git a/interface/src/plugins/render/WindowRenderPlugin.h b/interface/src/plugins/render/WindowDisplayPlugin.h similarity index 83% rename from interface/src/plugins/render/WindowRenderPlugin.h rename to interface/src/plugins/render/WindowDisplayPlugin.h index ec485e4d6e..9fc28c77d9 100644 --- a/interface/src/plugins/render/WindowRenderPlugin.h +++ b/interface/src/plugins/render/WindowDisplayPlugin.h @@ -1,5 +1,5 @@ // -// WindowRenderPlugin.h +// WindowDisplayPlugin.h // // Created by Bradley Austin Davis on 2014/04/13. // Copyright 2015 High Fidelity, Inc. @@ -9,18 +9,18 @@ // #pragma once -#include "SimpleRenderPlugin.h" +#include "SimpleDisplayPlugin.h" #include #include #include -class WindowRenderPlugin : public SimpleRenderPlugin { +class WindowDisplayPlugin : public SimpleDisplayPlugin { Q_OBJECT public: static const QString NAME; - WindowRenderPlugin(); + WindowDisplayPlugin(); virtual const QString & getName(); diff --git a/interface/src/ui/ApplicationOverlay.cpp b/interface/src/ui/ApplicationOverlay.cpp index adb6492964..81ad9cbc2c 100644 --- a/interface/src/ui/ApplicationOverlay.cpp +++ b/interface/src/ui/ApplicationOverlay.cpp @@ -27,7 +27,7 @@ #include "Application.h" #include "ApplicationOverlay.h" #include "devices/OculusManager.h" -#include "plugins/render/RenderPlugin.h" +#include "plugins/render/DisplayPlugin.h" #include "Util.h" #include "ui/Stats.h" @@ -478,7 +478,7 @@ QPoint ApplicationOverlay::getPalmClickLocation(const PalmData *palm) const { glm::vec3 tipPos = invOrientation * (tip - eyePos); QPoint rv; - if (qApp->getActiveRenderPlugin()->isHmd()) { + if (qApp->isHMDMode()) { float t; //We back the ray up by dir to ensure that it will not start inside the UI. @@ -496,7 +496,7 @@ QPoint ApplicationOverlay::getPalmClickLocation(const PalmData *palm) const { float u = asin(collisionPos.x) / (_textureFov)+0.5f; float v = 1.0 - (asin(collisionPos.y) / (_textureFov)+0.5f); - auto size = qApp->getActiveRenderPlugin()->getCanvasSize(); + auto size = qApp->getCanvasSize(); rv.setX(u * size.x); rv.setY(v * size.y); @@ -553,8 +553,8 @@ void ApplicationOverlay::renderPointers() { glActiveTexture(GL_TEXTURE0); _crosshairTexture->bind(); - if (qApp->getActiveRenderPlugin()->isHmd() && !qApp->getLastMouseMoveWasSimulated() && !qApp->isMouseHidden()) { - glm::ivec2 trueMouse = qApp->getActiveRenderPlugin()->getTrueMousePosition(); + if (qApp->isHMDMode() && !qApp->getLastMouseMoveWasSimulated() && !qApp->isMouseHidden()) { + glm::ivec2 trueMouse = qApp->getTrueMousePosition(); //If we are in oculus, render reticle later if (_lastMouseMove == 0) { _lastMouseMove = usecTimestampNow(); @@ -966,7 +966,7 @@ void ApplicationOverlay::renderStatsAndLogs() { (Menu::getInstance()->isOptionChecked(MenuOption::Stats)) ? 80 : 20; - auto size = qApp->getActiveRenderPlugin()->getCanvasSize(); + auto size = qApp->getCanvasSize(); // auto glCanvas = Application::getInstance()->getGLWidget(); drawText(size.x - 100, size.y - timerBottom, 0.30f, 0.0f, 0, frameTimer.toUtf8().constData(), WHITE_TEXT); diff --git a/libraries/script-engine/src/MenuItemProperties.cpp b/libraries/script-engine/src/MenuItemProperties.cpp index 97fbdef1fa..48670e314d 100644 --- a/libraries/script-engine/src/MenuItemProperties.cpp +++ b/libraries/script-engine/src/MenuItemProperties.cpp @@ -23,7 +23,8 @@ MenuItemProperties::MenuItemProperties() : beforeItem(""), afterItem(""), isCheckable(false), - isChecked(false) + isChecked(false), + isSeparator(false) { }; @@ -38,7 +39,8 @@ MenuItemProperties::MenuItemProperties(const QString& menuName, const QString& m beforeItem(""), afterItem(""), isCheckable(checkable), - isChecked(checked) + isChecked(checked), + isSeparator(false) { } @@ -53,7 +55,8 @@ MenuItemProperties::MenuItemProperties(const QString& menuName, const QString& m beforeItem(""), afterItem(""), isCheckable(checkable), - isChecked(checked) + isChecked(checked), + isSeparator(false) { } diff --git a/libraries/shared/src/GLMHelpers.h b/libraries/shared/src/GLMHelpers.h index a710ba759b..a06f6f26cf 100644 --- a/libraries/shared/src/GLMHelpers.h +++ b/libraries/shared/src/GLMHelpers.h @@ -117,4 +117,8 @@ QMatrix4x4 fromGlm(const glm::mat4 & m); QRectF glmToRect(const glm::vec2 & pos, const glm::vec2 & size); +#define YAW(euler) euler.y +#define PITCH(euler) euler.x +#define ROLL(euler) euler.z + #endif // hifi_GLMHelpers_h