History

Working on plugin architecture

Bradley Austin Davis committed 11 years ago

Commit b73ce811 parent 28c873b8 files · +56 −114Browse files

Showing the changes to interface/src/Application.cpp (1 of 8 files). Show all

Unified · Split

interface/src/Application.cpp+34−93
@@ -290,7 +290,6 @@ bool setupEssentials(int& argc, char** argv) { · 289 unmodified lines
290Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :290Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
291 QApplication(argc, argv),291 QApplication(argc, argv),
292 _dependencyManagerIsSetup(setupEssentials(argc, argv)),292 _dependencyManagerIsSetup(setupEssentials(argc, argv)),
293 _offscreenContext(new OffscreenGlContext()),
294 _window(new MainWindow(desktop())),293 _window(new MainWindow(desktop())),
295 _toolWindow(NULL),294 _toolWindow(NULL),
296 _friendsWindow(NULL),295 _friendsWindow(NULL),
@@ -319,8 +318,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 22 unmodified lines
319 _cursorVisible(true),318 _cursorVisible(true),
320 _lastMouseMove(usecTimestampNow()),319 _lastMouseMove(usecTimestampNow()),
321 _lastMouseMoveWasSimulated(false),320 _lastMouseMoveWasSimulated(false),
322 _touchAvgX(0.0f),
323 _touchAvgY(0.0f),
324 _isTouchPressed(false),321 _isTouchPressed(false),
325 _mousePressed(false),322 _mousePressed(false),
326 _enableProcessOctreeThread(true),323 _enableProcessOctreeThread(true),
@@ -501,7 +498,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 174 unmodified lines
501 ResourceCache::setRequestLimit(3);498 ResourceCache::setRequestLimit(3);
502 499
503 _window->setCentralWidget(new QWidget());500 _window->setCentralWidget(new QWidget());
501
504 _window->restoreGeometry();502 _window->restoreGeometry();
503
505 _window->setVisible(true);504 _window->setVisible(true);
506 505
507#if 0506#if 0
@@ -592,7 +591,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 84 unmodified lines
592 this->installEventFilter(this);591 this->installEventFilter(this);
593 // The offscreen UI needs to intercept the mouse and keyboard 592 // The offscreen UI needs to intercept the mouse and keyboard
594 // events coming from the onscreen window593 // events coming from the onscreen window
595 _glWidget->installEventFilter(DependencyManager::get<OffscreenUi>().data());594 this->installEventFilter(DependencyManager::get<OffscreenUi>().data());
596 595
597 // initialize our face trackers after loading the menu settings596 // initialize our face trackers after loading the menu settings
598 auto faceshiftTracker = DependencyManager::get<Faceshift>();597 auto faceshiftTracker = DependencyManager::get<Faceshift>();
@@ -810,18 +809,14 @@ void Application::initializeUi() { · 211 unmodified lines
810 809
811void Application::paintGL() {810void Application::paintGL() {
812 PROFILE_RANGE(__FUNCTION__);811 PROFILE_RANGE(__FUNCTION__);
813 _glWidget->makeCurrent();812 _offscreenContext->makeCurrent();
814 PerformanceTimer perfTimer("paintGL");813 PerformanceTimer perfTimer("paintGL");
815 //Need accurate frame timing for the oculus rift814 getActiveDisplayPlugin()->preDisplay();
816 if (OculusManager::isConnected()) {
817 OculusManager::beginFrameTiming();
818 }
819 815
820 PerformanceWarning::setSuppressShortTimings(Menu::getInstance()->isOptionChecked(MenuOption::SuppressShortTimings));816 PerformanceWarning::setSuppressShortTimings(Menu::getInstance()->isOptionChecked(MenuOption::SuppressShortTimings));
821 bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);817 bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
822 PerformanceWarning warn(showWarnings, "Application::paintGL()");818 PerformanceWarning warn(showWarnings, "Application::paintGL()");
823 819
824 _offscreenContext->makeCurrent();
825 QSize fbSize = getActiveDisplayPlugin()->getRecommendedFramebufferSize() * getRenderResolutionScale();820 QSize fbSize = getActiveDisplayPlugin()->getRecommendedFramebufferSize() * getRenderResolutionScale();
826 DependencyManager::get<TextureCache>()->setFrameBufferSize(fbSize);821 DependencyManager::get<TextureCache>()->setFrameBufferSize(fbSize);
827 822
@@ -888,7 +883,8 @@ void Application::paintGL() { · 60 unmodified lines
888 glPopMatrix();883 glPopMatrix();
889 884
890 if (Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror)) {885 if (Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror)) {
891 _rearMirrorTools->render(true, _glWidget->mapFromGlobal(QCursor::pos()));886 glm::vec2 mpos = getActiveDisplayPlugin()->getUiMousePosition();
887 _rearMirrorTools->render(true, QPoint(mpos.x, mpos.y));
892 } else if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) {888 } else if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) {
893 renderRearViewMirror(_mirrorViewRect);889 renderRearViewMirror(_mirrorViewRect);
894 }890 }
@@ -1460,8 +1456,7 @@ void Application::mousePressEvent(QMouseEvent* event, unsigned int deviceID) { · 565 unmodified lines
1460 _keyboardMouseDevice.mousePressEvent(event);1456 _keyboardMouseDevice.mousePressEvent(event);
1461 1457
1462 if (event->button() == Qt::LeftButton) {1458 if (event->button() == Qt::LeftButton) {
1463 _mouseDragStartedX = getTrueMouseX();1459 _mouseDragStarted = getTrueMousePosition();
1464 _mouseDragStartedY = getTrueMouseY();
1465 _mousePressed = true;1460 _mousePressed = true;
1466 1461
1467 if (mouseOnScreen()) {1462 if (mouseOnScreen()) {
@@ -1563,22 +1558,18 @@ void Application::touchUpdateEvent(QTouchEvent* event) { · 95 unmodified lines
1563 bool validTouch = false;1558 bool validTouch = false;
1564 if (activeWindow() == _window) {1559 if (activeWindow() == _window) {
1565 const QList<QTouchEvent::TouchPoint>& tPoints = event->touchPoints();1560 const QList<QTouchEvent::TouchPoint>& tPoints = event->touchPoints();
1566 _touchAvgX = 0.0f;1561 _touchAvg = glm::vec2(0);
1567 _touchAvgY = 0.0f;
1568 int numTouches = tPoints.count();1562 int numTouches = tPoints.count();
1569 if (numTouches > 1) {1563 if (numTouches > 1) {
1570 for (int i = 0; i < numTouches; ++i) {1564 for (int i = 0; i < numTouches; ++i) {
1571 _touchAvgX += tPoints[i].pos().x();1565 _touchAvg += toGlm(tPoints[i].pos());
1572 _touchAvgY += tPoints[i].pos().y();
1573 }1566 }
1574 _touchAvgX /= (float)(numTouches);1567 _touchAvg /= numTouches;
1575 _touchAvgY /= (float)(numTouches);
1576 validTouch = true;1568 validTouch = true;
1577 }1569 }
1578 }1570 }
1579 if (!_isTouchPressed) {1571 if (!_isTouchPressed) {
1580 _touchDragStartedAvgX = _touchAvgX;1572 _touchDragStartedAvg = _touchAvg;
1581 _touchDragStartedAvgY = _touchAvgY;
1582 }1573 }
1583 _isTouchPressed = validTouch;1574 _isTouchPressed = validTouch;
1584}1575}
@@ -1614,8 +1605,7 @@ void Application::touchEndEvent(QTouchEvent* event) { · 29 unmodified lines
1614 _keyboardMouseDevice.touchEndEvent(event);1605 _keyboardMouseDevice.touchEndEvent(event);
1615 1606
1616 // put any application specific touch behavior below here..1607 // put any application specific touch behavior below here..
1617 _touchDragStartedAvgX = _touchAvgX;1608 _touchDragStartedAvg = _touchAvg;
1618 _touchDragStartedAvgY = _touchAvgY;
1619 _isTouchPressed = false;1609 _isTouchPressed = false;
1620 1610
1621}1611}
@@ -1736,13 +1726,11 @@ void Application::idle() { · 114 unmodified lines
1736 const float BIGGEST_DELTA_TIME_SECS = 0.25f;1726 const float BIGGEST_DELTA_TIME_SECS = 0.25f;
1737 update(glm::clamp((float)timeSinceLastUpdate / 1000.0f, 0.0f, BIGGEST_DELTA_TIME_SECS));1727 update(glm::clamp((float)timeSinceLastUpdate / 1000.0f, 0.0f, BIGGEST_DELTA_TIME_SECS));
1738 }1728 }
1739
1740 {1729 {
1741 PerformanceTimer perfTimer("updateGL");1730 PerformanceTimer perfTimer("updateGL");
1742 PerformanceWarning warn(showWarnings, "Application::idle()... updateGL()");1731 PerformanceWarning warn(showWarnings, "Application::idle()... updateGL()");
1743 getActiveDisplayPlugin()->idle();1732 getActiveDisplayPlugin()->idle();
1744 }1733 }
1745
1746 {1734 {
1747 PerformanceTimer perfTimer("rest");1735 PerformanceTimer perfTimer("rest");
1748 PerformanceWarning warn(showWarnings, "Application::idle()... rest of it");1736 PerformanceWarning warn(showWarnings, "Application::idle()... rest of it");
@@ -1822,15 +1810,12 @@ void Application::setFullscreen(bool fullscreen) { · 73 unmodified lines
1822 }1810 }
1823}1811}
1824 1812
1825
1826void Application::setEnable3DTVMode(bool enable3DTVMode) {
1827#if 01813#if 0
1814void Application::setEnable3DTVMode(bool enable3DTVMode) {
1828 resizeGL(_glWidget->getDeviceWidth(), _glWidget->getDeviceHeight());1815 resizeGL(_glWidget->getDeviceWidth(), _glWidget->getDeviceHeight());
1829#endif
1830}1816}
1831 1817
1832void Application::setEnableVRMode(bool enableVRMode) {1818void Application::setEnableVRMode(bool enableVRMode) {
1833#if 0
1834 if (Menu::getInstance()->isOptionChecked(MenuOption::EnableVRMode) != enableVRMode) {1819 if (Menu::getInstance()->isOptionChecked(MenuOption::EnableVRMode) != enableVRMode) {
1835 Menu::getInstance()->getActionForOption(MenuOption::EnableVRMode)->setChecked(enableVRMode);1820 Menu::getInstance()->getActionForOption(MenuOption::EnableVRMode)->setChecked(enableVRMode);
1836 }1821 }
@@ -1855,8 +1840,8 @@ void Application::setEnableVRMode(bool enableVRMode) { · 18 unmodified lines
1855 resizeGL(_glWidget->getDeviceWidth(), _glWidget->getDeviceHeight());1840 resizeGL(_glWidget->getDeviceWidth(), _glWidget->getDeviceHeight());
1856 1841
1857 updateCursorVisibility();1842 updateCursorVisibility();
1858#endif
1859}1843}
1844#endif
1860 1845
1861void Application::setLowVelocityFilter(bool lowVelocityFilter) {1846void Application::setLowVelocityFilter(bool lowVelocityFilter) {
1862 SixenseManager::getInstance().setLowVelocityFilter(lowVelocityFilter);1847 SixenseManager::getInstance().setLowVelocityFilter(lowVelocityFilter);
@@ -1875,16 +1860,15 @@ int Application::getMouseY() const { · 12 unmodified lines
1875}1860}
1876 1861
1877ivec2 Application::getMouseDragStarted() const {1862ivec2 Application::getMouseDragStarted() const {
1878 return getActiveDisplaylugin()->trueMouseToUiMouse(1863 return getActiveDisplayPlugin()->trueMouseToUiMouse(getTrueMouseDragStarted());
1879 glm::ivec2(getTrueMouseDragStartedX(), getTrueMouseDragStartedY()));
1880}1864}
1881 1865
1882int Application::getMouseDragStartedX() const {1866int Application::getMouseDragStartedX() const {
1883 return getMouseDragStarted().x;1867 return getMouseDragStarted().x;
1884}1868}
1885 1869
1886int Application::getMouseDragStartedY() const {1870int Application::getMouseDragStartedY() const {
1887 return getMouseDragStarted().y;1871 return getMouseDragStarted().y;
1888}1872}
1889 1873
1890FaceTracker* Application::getActiveFaceTracker() {1874FaceTracker* Application::getActiveFaceTracker() {
@@ -2221,9 +2205,8 @@ void Application::updateMyAvatarLookAtPosition() { · 330 unmodified lines
2221 bool isLookingAtSomeone = false;2205 bool isLookingAtSomeone = false;
2222 glm::vec3 lookAtSpot;2206 glm::vec3 lookAtSpot;
2223 if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {2207 if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
2224#if 0
2225 // When I am in mirror mode, just look right at the camera (myself)2208 // When I am in mirror mode, just look right at the camera (myself)
2226 if (!OculusManager::isConnected()) {2209 if (!isHMDMode()) {
2227 lookAtSpot = _myCamera.getPosition();2210 lookAtSpot = _myCamera.getPosition();
2228 } else {2211 } else {
2229 if (_myAvatar->isLookingAtLeftEye()) {2212 if (_myAvatar->isLookingAtLeftEye()) {
@@ -2232,7 +2215,7 @@ void Application::updateMyAvatarLookAtPosition() { · 2 unmodified lines
2232 lookAtSpot = OculusManager::getRightEyePosition();2215 lookAtSpot = OculusManager::getRightEyePosition();
2233 }2216 }
2234 }2217 }
2235#endif 2218
2236 } else {2219 } else {
2237 AvatarSharedPointer lookingAt = _myAvatar->getLookAtTargetAvatar().toStrongRef();2220 AvatarSharedPointer lookingAt = _myAvatar->getLookAtTargetAvatar().toStrongRef();
2238 if (lookingAt && _myAvatar != lookingAt.data()) {2221 if (lookingAt && _myAvatar != lookingAt.data()) {
@@ -3190,12 +3173,12 @@ void Application::displaySide(Camera& theCamera, bool selfAvatarOnly, RenderArgs · 951 unmodified lines
3190 _stars.render(theCamera.getFieldOfView(), theCamera.getAspectRatio(), theCamera.getNearClip(), alpha);3173 _stars.render(theCamera.getFieldOfView(), theCamera.getAspectRatio(), theCamera.getNearClip(), alpha);
3191 }3174 }
3192 3175
3193 // draw the sky dome3176 // draw the sky dome
3194 if (!selfAvatarOnly && Menu::getInstance()->isOptionChecked(MenuOption::Atmosphere)) {3177 if (!selfAvatarOnly && Menu::getInstance()->isOptionChecked(MenuOption::Atmosphere)) {
3195 PerformanceTimer perfTimer("atmosphere");3178 PerformanceTimer perfTimer("atmosphere");
3196 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),3179 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
3197 "Application::displaySide() ... atmosphere...");3180 "Application::displaySide() ... atmosphere...");
3198 _environment.renderAtmospheres(theCamera);3181 _environment.renderAtmospheres(theCamera);
3199 }3182 }
3200 3183
3201 }3184 }
@@ -3444,7 +3427,8 @@ void Application::renderRearViewMirror(const QRect& region, bool billboard) { · 242 unmodified lines
3444 glPopMatrix();3427 glPopMatrix();
3445 3428
3446 if (!billboard) {3429 if (!billboard) {
3447 _rearMirrorTools->render(false, _glWidget->mapFromGlobal(QCursor::pos()));3430 glm::vec2 mpos = getActiveDisplayPlugin()->getUiMousePosition();
3431 _rearMirrorTools->render(false, QPoint(mpos.x, mpos.y));
3448 }3432 }
3449 3433
3450 // reset Viewport and projection matrix3434 // reset Viewport and projection matrix
@@ -4320,6 +4304,7 @@ void Application::skipVersion(QString latestVersion) { · 869 unmodified lines
4320}4304}
4321 4305
4322void Application::takeSnapshot() {4306void Application::takeSnapshot() {
4307#if 0
4323 QMediaPlayer* player = new QMediaPlayer();4308 QMediaPlayer* player = new QMediaPlayer();
4324 QFileInfo inf = QFileInfo(PathUtils::resourcesPath() + "sounds/snap.wav");4309 QFileInfo inf = QFileInfo(PathUtils::resourcesPath() + "sounds/snap.wav");
4325 player->setMedia(QUrl::fromLocalFile(inf.absoluteFilePath()));4310 player->setMedia(QUrl::fromLocalFile(inf.absoluteFilePath()));
@@ -4336,6 +4321,8 @@ void Application::takeSnapshot() { · 10 unmodified lines
4336 _snapshotShareDialog = new SnapshotShareDialog(fileName, desktop());4321 _snapshotShareDialog = new SnapshotShareDialog(fileName, desktop());
4337 }4322 }
4338 _snapshotShareDialog->show();4323 _snapshotShareDialog->show();
4324#endif
4325
4339}4326}
4340 4327
4341void Application::setVSyncEnabled() {4328void Application::setVSyncEnabled() {
@@ -4524,7 +4511,7 @@ glm::uvec2 Application::getCanvasSize() const { · 182 unmodified lines
4524}4511}
4525 4512
4526QSize Application::getDeviceSize() const {4513QSize Application::getDeviceSize() const {
4527 return getActiveDisplayPlugin()->getRecommendedFramebufferSize(); // _glWidget->getDeviceSize();4514 return getActiveDisplayPlugin()->getDeviceSize();
4528}4515}
4529 4516
4530void Application::resizeGL() {4517void Application::resizeGL() {
@@ -4544,21 +4531,15 @@ glm::vec2 Application::getViewportDimensions() const { · 13 unmodified lines
4544glm::ivec2 Application::getTrueMousePosition() const {4531glm::ivec2 Application::getTrueMousePosition() const {
4545 return getActiveDisplayPlugin()->getTrueMousePosition();4532 return getActiveDisplayPlugin()->getTrueMousePosition();
4546}4533}
4534
4547glm::quat Application::getHeadOrientation() const {4535glm::quat Application::getHeadOrientation() const {
4548 return getActiveDisplayPlugin()->headOrientation();4536 return getActiveDisplayPlugin()->headOrientation();
4549}4537}
4538
4550glm::vec3 Application::getHeadPosition() const {4539glm::vec3 Application::getHeadPosition() const {
4551 return getActiveDisplayPlugin()->headTranslation();4540 return getActiveDisplayPlugin()->headTranslation();
4552}4541}
4553 4542
4554int Application::getTrueMouseX() const {
4555 return getActiveDisplayPlugin()->getTrueMousePosition().x;
4556}
4557
4558int Application::getTrueMouseY() const {
4559 return getActiveDisplayPlugin()->getTrueMousePosition().y;
4560}
4561
4562bool Application::isThrottleRendering() const {4543bool Application::isThrottleRendering() const {
4563 return getActiveDisplayPlugin()->isThrottled();4544 return getActiveDisplayPlugin()->isThrottled();
4564}4545}
@@ -4659,43 +4640,3 @@ void Application::initPlugins() { · 94 unmodified lines
4659void Application::shutdownPlugins() {4640void Application::shutdownPlugins() {
4660 OculusManager::deinit();4641 OculusManager::deinit();
4661}4642}
4662
4663glm::vec3 Application::getHeadPosition() const {
4664 return OculusManager::getRelativePosition();
4665}
4666
4667glm::quat Application::getHeadOrientation() const {
4668 return OculusManager::getOrientation();
4669}
4670
4671glm::uvec2 Application::getCanvasSize() const {
4672 return glm::uvec2(_glWidget->width(), _glWidget->height());
4673}
4674
4675QSize Application::getDeviceSize() const {
4676 return _glWidget->getDeviceSize();
4677}
4678
4679int Application::getTrueMouseX() const {
4680 return _glWidget->mapFromGlobal(QCursor::pos()).x();
4681}
4682
4683int Application::getTrueMouseY() const {
4684 return _glWidget->mapFromGlobal(QCursor::pos()).y();
4685}
4686
4687bool Application::isThrottleRendering() const {
4688 return _glWidget->isThrottleRendering();
4689}
4690
4691PickRay Application::computePickRay() const {
4692 return computePickRay(getTrueMouseX(), getTrueMouseY());
4693}
4694
4695bool Application::hasFocus() const {
4696 return _glWidget->hasFocus();
4697}
4698
4699void Application::resizeGL() {
4700 this->resizeGL(_glWidget->getDeviceWidth(), _glWidget->getDeviceHeight());
4701}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t