From a482fa0a6d27321438464d54bc3087d94af5948a Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Fri, 1 May 2015 10:35:15 -0700 Subject: [PATCH] Working on plugin rendering model: --- interface/src/Application.cpp | 8 +++++--- interface/src/GLCanvas.cpp | 11 +++-------- interface/src/avatar/MyAvatar.cpp | 18 ++++++++++-------- .../src/plugins/render/LegacyRenderPlugin.cpp | 5 +++++ 4 files changed, 23 insertions(+), 19 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index d514ee2837..567e50df23 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1067,6 +1067,8 @@ bool Application::eventFilter(QObject* object, QEvent* event) { } } + // auto offscreenUi = DependencyManager::get(); + // return offscreenUi->eventFilter(object, event); return false; } @@ -1434,7 +1436,7 @@ void Application::mouseMoveEvent(QMouseEvent* event, unsigned int deviceID) { if (!_lastMouseMoveWasSimulated) { _lastMouseMove = usecTimestampNow(); } - + if (_aboutToQuit) { return; } @@ -3001,7 +3003,7 @@ ViewFrustum* Application::getViewFrustum() { #ifdef DEBUG if (QThread::currentThread() == activeRenderingThread) { // FIXME, should this be an assert? - qWarning() << "Calling Application::getViewFrustum() from the active rendering thread, did you mean Application::getDisplayViewFrustum()?"; + //qWarning() << "Calling Application::getViewFrustum() from the active rendering thread, did you mean Application::getDisplayViewFrustum()?"; } #endif return &_viewFrustum; @@ -3011,7 +3013,7 @@ ViewFrustum* Application::getDisplayViewFrustum() { #ifdef DEBUG if (QThread::currentThread() != activeRenderingThread) { // FIXME, should this be an assert? - qWarning() << "Calling Application::getDisplayViewFrustum() from outside the active rendering thread or outside rendering, did you mean Application::getViewFrustum()?"; + //qWarning() << "Calling Application::getDisplayViewFrustum() from outside the active rendering thread or outside rendering, did you mean Application::getViewFrustum()?"; } #endif return &_displayViewFrustum; diff --git a/interface/src/GLCanvas.cpp b/interface/src/GLCanvas.cpp index a5bf009102..c79e726a66 100644 --- a/interface/src/GLCanvas.cpp +++ b/interface/src/GLCanvas.cpp @@ -67,13 +67,10 @@ void GLCanvas::paintGL() { } #endif Application::getInstance()->paintGL(); - + #if 0 if (!OculusManager::isConnected()) { -#endif - swapBuffers(); -#if 0 } else { if (OculusManager::allowSwap()) { swapBuffers(); @@ -121,13 +118,11 @@ void GLCanvas::throttleRender() { if (OculusManager::isConnected()) { OculusManager::beginFrameTiming(); } -#endif - makeCurrent(); +#endif Application::getInstance()->paintGL(); - swapBuffers(); - #if 0 + swapBuffers(); if (OculusManager::isConnected()) { OculusManager::endFrameTiming(); } diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index 7f004970d5..2c772c76b7 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -34,6 +34,7 @@ #include #include "Application.h" +#include "plugins/render/RenderPlugin.h" #include "AvatarManager.h" #include "Environment.h" #include "Menu.h" @@ -230,13 +231,15 @@ void MyAvatar::simulate(float deltaTime) { void MyAvatar::updateFromTrackers(float deltaTime) { glm::vec3 estimatedPosition, estimatedRotation; -#if 0 - if (isPlaying() && !OculusManager::isConnected()) { + auto renderPlugin = qApp->getActiveRenderPlugin(); + bool inHmd = renderPlugin->isHmd(); + + if (isPlaying() && inHmd) { return; } - - if (OculusManager::isConnected()) { - estimatedPosition = OculusManager::getRelativePosition(); + + if (inHmd) { + estimatedPosition = renderPlugin->headTranslation(); estimatedPosition.x *= -1.0f; _trackedHeadPosition = estimatedPosition; @@ -274,7 +277,7 @@ void MyAvatar::updateFromTrackers(float deltaTime) { Head* head = getHead(); - if (OculusManager::isConnected() || isPlaying()) { + if (inHmd || isPlaying()) { head->setDeltaPitch(estimatedRotation.x); head->setDeltaYaw(estimatedRotation.y); } else { @@ -294,7 +297,7 @@ void MyAvatar::updateFromTrackers(float deltaTime) { // NOTE: this is kinda a hack, it's the same hack we use to make the head tilt. But it's not really a mirror // it just makes you feel like you're looking in a mirror because the body movements of the avatar appear to // match your body movements. - if (OculusManager::isConnected() && Application::getInstance()->getCamera()->getMode() == CAMERA_MODE_MIRROR) { + if (inHmd && Application::getInstance()->getCamera()->getMode() == CAMERA_MODE_MIRROR) { relativePosition.x = -relativePosition.x; } @@ -302,7 +305,6 @@ void MyAvatar::updateFromTrackers(float deltaTime) { -MAX_LEAN, MAX_LEAN)); head->setLeanForward(glm::clamp(glm::degrees(atanf(relativePosition.z * _leanScale / TORSO_LENGTH)), -MAX_LEAN, MAX_LEAN)); -#endif } diff --git a/interface/src/plugins/render/LegacyRenderPlugin.cpp b/interface/src/plugins/render/LegacyRenderPlugin.cpp index 6d46c6d3f5..93170517b3 100644 --- a/interface/src/plugins/render/LegacyRenderPlugin.cpp +++ b/interface/src/plugins/render/LegacyRenderPlugin.cpp @@ -32,9 +32,14 @@ void LegacyRenderPlugin::activate() { _window->setFocusPolicy(Qt::StrongFocus); _window->setFocus(); _window->setMouseTracking(true); + + _window->installEventFilter(qApp); + _window->installEventFilter(DependencyManager::get().data()); } void LegacyRenderPlugin::deactivate() { + _window->removeEventFilter(DependencyManager::get().data()); + _window->removeEventFilter(qApp); qApp->getWindow()->setCentralWidget(oldWidget); // stop the glWidget frame timer so it doesn't call paintGL _window->stopFrameTimer();