History

Merge branch 'master' into plugins

Brad Davis committed 11 years ago

Commit 031b2942 parents 2fa92af 5e76e01285 files · +12660 −3922Browse files

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

Unified · Split

interface/src/Application.cpp+254−94
@@ -35,7 +35,6 @@ · 34 unmodified lines
3535 #include <QMouseEvent>
3636 #include <QNetworkReply>
3737 #include <QNetworkDiskCache>
38−#include <QOpenGLFramebufferObject>
3938 #include <QObject>
4039 #include <QWheelEvent>
4140 #include <QScreen>
@@ -64,6 +63,7 @@ · 22 unmodified lines
6463 #include <GlowEffect.h>
6564 #include <HFActionEvent.h>
6665 #include <HFBackEvent.h>
66+#include <VrMenu.h>
6767 #include <LogHandler.h>
6868 #include <MainWindow.h>
6969 #include <ModelEntityItem.h>
@@ -83,6 +83,7 @@ · 13 unmodified lines
8383 #include <TextRenderer.h>
8484 #include <UserActivityLogger.h>
8585 #include <UUID.h>
86+#include <MessageDialog.h>
8687
8788 #include <SceneScriptingInterface.h>
8889
@@ -109,7 +110,6 @@ · 20 unmodified lines
109110 #include "devices/MIDIManager.h"
110111 #include "devices/OculusManager.h"
111112 #include "devices/TV3DManager.h"
112−#include "devices/Visage.h"
113113
114114 #include "gpu/Batch.h"
115115 #include "gpu/GLBackend.h"
@@ -137,6 +137,7 @@ · 21 unmodified lines
137137 #include "ui/Snapshot.h"
138138 #include "ui/StandAloneJSConsole.h"
139139 #include "ui/Stats.h"
140+#include "ui/AddressBarDialog.h"
140141
141142 // ON WIndows PC, NVidia Optimus laptop, we want to enable NVIDIA GPU
142143 #if defined(Q_OS_WIN)
@@ -145,6 +146,23 @@ extern "C" { · 2 unmodified lines
145146 }
146147 #endif
147148
149+enum CustomEventTypes {
150+ Lambda = QEvent::User + 1
151+};
152+
153+class LambdaEvent : public QEvent {
154+ std::function<void()> _fun;
155+public:
156+ LambdaEvent(const std::function<void()> & fun) :
157+ QEvent(static_cast<QEvent::Type>(Lambda)), _fun(fun) {
158+ }
159+ LambdaEvent(std::function<void()> && fun) :
160+ QEvent(static_cast<QEvent::Type>(Lambda)), _fun(fun) {
161+ }
162+ void call() { _fun(); }
163+};
164+
165+
148166 using namespace std;
149167
150168 // Starfield information
@@ -165,8 +183,6 @@ const QString SKIP_FILENAME = QStandardPaths::writableLocation(QStandardPaths::D · 14 unmodified lines
165183
166184 const QString DEFAULT_SCRIPTS_JS_URL = "http://s3.amazonaws.com/hifi-public/scripts/defaultScripts.js";
167185
168−bool renderCollisionHulls = false;
169−
170186 #ifdef Q_OS_WIN
171187 class MyNativeEventFilter : public QAbstractNativeEventFilter {
172188 public:
@@ -209,8 +225,12 @@ public: · 36 unmodified lines
209225
210226 void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& message) {
211227 QString logMessage = LogHandler::getInstance().printMessage((LogMsgType) type, context, message);
212−
228+
213229 if (!logMessage.isEmpty()) {
230+#ifdef Q_OS_WIN
231+ OutputDebugStringA(logMessage.toLocal8Bit().constData());
232+ OutputDebugStringA("\n");
233+#endif
214234 Application::getInstance()->getLogger()->addMessage(qPrintable(logMessage + "\n"));
215235 }
216236 }
@@ -243,7 +263,6 @@ bool setupEssentials(int& argc, char** argv) { · 26 unmodified lines
243263 auto ambientOcclusionEffect = DependencyManager::set<AmbientOcclusionEffect>();
244264 auto textureCache = DependencyManager::set<TextureCache>();
245265 auto animationCache = DependencyManager::set<AnimationCache>();
246− auto visage = DependencyManager::set<Visage>();
247266 auto ddeFaceTracker = DependencyManager::set<DdeFaceTracker>();
248267 auto modelBlender = DependencyManager::set<ModelBlender>();
249268 auto audioToolBox = DependencyManager::set<AudioToolBox>();
@@ -260,6 +279,7 @@ bool setupEssentials(int& argc, char** argv) { · 10 unmodified lines
260279 #endif
261280 auto discoverabilityManager = DependencyManager::set<DiscoverabilityManager>();
262281 auto sceneScriptingInterface = DependencyManager::set<SceneScriptingInterface>();
282+ auto offscreenUi = DependencyManager::set<OffscreenUi>();
263283
264284 return true;
265285 }
@@ -317,8 +337,10 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 51 unmodified lines
317337 #ifdef Q_OS_WIN
318338 installNativeEventFilter(&MyNativeEventFilter::getInstance());
319339 #endif
340+
320341
321342 _logger = new FileLogger(this); // After setting organization name in order to get correct directory
343+
322344 qInstallMessageHandler(messageHandler);
323345
324346 QFontDatabase::addApplicationFont(PathUtils::resourcesPath() + "styles/Inconsolata.otf");
@@ -336,9 +358,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 11 unmodified lines
336358
337359 _bookmarks = new Bookmarks(); // Before setting up the menu
338360
339− // call Menu getInstance static method to set up the menu
340− _window->setMenuBar(Menu::getInstance());
341−
342361 _runningScriptsWidget = new RunningScriptsWidget(_window);
343362
344363 // start the nodeThread so its event loop is running
@@ -445,6 +464,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 100 unmodified lines
445464 addressManager->setOrientationGetter(getOrientationForPath);
446465
447466 connect(addressManager.data(), &AddressManager::rootPlaceNameChanged, this, &Application::updateWindowTitle);
467+ connect(this, &QCoreApplication::aboutToQuit, addressManager.data(), &AddressManager::storeCurrentAddress);
448468
449469 #ifdef _WIN32
450470 WSADATA WsaData;
@@ -562,8 +582,12 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 111 unmodified lines
562582 #endif
563583
564584 this->installEventFilter(this);
585+ // The offscreen UI needs to intercept the mouse and keyboard
586+ // events coming from the onscreen window
587+ _glWidget->installEventFilter(DependencyManager::get<OffscreenUi>().data());
565588 }
566589
590+
567591 void Application::aboutToQuit() {
568592 emit beforeAboutToQuit();
569593
@@ -612,6 +636,10 @@ void Application::cleanupBeforeQuit() { · 42 unmodified lines
612636
613637 // destroy the AudioClient so it and its thread have a chance to go down safely
614638 DependencyManager::destroy<AudioClient>();
639+
640+#ifdef HAVE_DDE
641+ DependencyManager::destroy<DdeFaceTracker>();
642+#endif
615643 }
616644
617645 Application::~Application() {
@@ -632,6 +660,7 @@ Application::~Application() { · 14 unmodified lines
632660
633661 getActiveRenderPlugin()->deactivate();
634662
663+ DependencyManager::destroy<OffscreenUi>();
635664 DependencyManager::destroy<AvatarManager>();
636665 DependencyManager::destroy<AnimationCache>();
637666 DependencyManager::destroy<TextureCache>();
@@ -692,6 +721,17 @@ void Application::initializeGL() { · 54 unmodified lines
692721 initDisplay();
693722 qCDebug(interfaceapp, "Initialized Display.");
694723
724+ // The UI can't be created until the primary OpenGL
725+ // context is created, because it needs to share
726+ // texture resources
727+ initializeUi();
728+ qCDebug(interfaceapp, "Initialized Offscreen UI.");
729+ _glWidget->makeCurrent();
730+
731+ // call Menu getInstance static method to set up the menu
732+ // Needs to happen AFTER the QML UI initialization
733+ _window->setMenuBar(Menu::getInstance());
734+
695735 init();
696736 qCDebug(interfaceapp, "init() complete.");
697737
@@ -719,10 +759,45 @@ void Application::initializeGL() { · 21 unmodified lines
719759
720760 // update before the first render
721761 update(1.0f / _fps);
722−
762+
723763 InfoView::showFirstTime(INFO_HELP_PATH);
724764 }
725765
766+void Application::initializeUi() {
767+ AddressBarDialog::registerType();
768+ LoginDialog::registerType();
769+ MessageDialog::registerType();
770+ VrMenu::registerType();
771+
772+ auto offscreenUi = DependencyManager::get<OffscreenUi>();
773+ offscreenUi->create(_glWidget->context()->contextHandle());
774+ offscreenUi->resize(_glWidget->size());
775+ offscreenUi->setProxyWindow(_window->windowHandle());
776+ offscreenUi->setBaseUrl(QUrl::fromLocalFile(PathUtils::resourcesPath() + "/qml/"));
777+ offscreenUi->load("Root.qml");
778+ offscreenUi->load("RootMenu.qml");
779+ VrMenu::load();
780+ VrMenu::executeQueuedLambdas();
781+ offscreenUi->setMouseTranslator([this](const QPointF& p){
782+ if (OculusManager::isConnected()) {
783+ glm::vec2 pos = _applicationOverlay.screenToOverlay(toGlm(p));
784+ return QPointF(pos.x, pos.y);
785+ }
786+ return QPointF(p);
787+ });
788+ offscreenUi->resume();
789+ connect(_window, &MainWindow::windowGeometryChanged, [this](const QRect & r){
790+ static qreal oldDevicePixelRatio = 0;
791+ qreal devicePixelRatio = _glWidget->devicePixelRatio();
792+ if (devicePixelRatio != oldDevicePixelRatio) {
793+ oldDevicePixelRatio = devicePixelRatio;
794+ qDebug() << "Device pixel ratio changed, triggering GL resize";
795+ resizeGL(_glWidget->width(),
796+ _glWidget->height());
797+ }
798+ });
799+}
800+
726801 void Application::paintGL() {
727802 PROFILE_RANGE(__FUNCTION__);
728803 PerformanceTimer perfTimer("paintGL");
@@ -777,7 +852,7 @@ void Application::paintGL() { · 48 unmodified lines
777852 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
778853
779854 // Viewport is assigned to the size of the framebuffer
780− QSize size = DependencyManager::get<TextureCache>()->getPrimaryFramebufferObject()->size();
855+ QSize size = DependencyManager::get<TextureCache>()->getFrameBufferSize();
781856 glViewport(0, 0, size.width(), size.height());
782857
783858 glMatrixMode(GL_MODELVIEW);
@@ -789,7 +864,19 @@ void Application::paintGL() { · 5 unmodified lines
789864 if (Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror)) {
790865 _rearMirrorTools->render(true);
791866 } else if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) {
867+<<<<<<< HEAD
792868 renderRearViewMirror(_mirrorViewRect);
869+=======
870+ renderRearViewMirror(_mirrorViewRect);
871+ }
872+
873+ DependencyManager::get<GlowEffect>()->render();
874+
875+ {
876+ PerformanceTimer perfTimer("renderOverlay");
877+ _applicationOverlay.renderOverlay();
878+ _applicationOverlay.displayOverlayTexture();
879+>>>>>>> master
793880 }
794881 }
795882 primaryFbo->release();
@@ -864,6 +951,9 @@ void Application::resizeGL(int width, int height) { · 68 unmodified lines
864951 updateProjectionMatrix();
865952 glLoadIdentity();
866953
954+ auto offscreenUi = DependencyManager::get<OffscreenUi>();
955+ offscreenUi->resize(_glWidget->size());
956+
867957 // update Stats width
868958 // let's set horizontal offset to give stats some margin to mirror
869959 int horizontalOffset = MIRROR_VIEW_WIDTH + MIRROR_VIEW_LEFT_PADDING * 2;
@@ -913,6 +1003,7 @@ bool Application::importSVOFromURL(const QString& urlString) { · 43 unmodified lines
9131003
9141004 bool Application::event(QEvent* event) {
9151005 switch (event->type()) {
1006+<<<<<<< HEAD
9161007 case QEvent::MouseMove:
9171008 mouseMoveEvent((QMouseEvent*)event);
9181009 return true;
@@ -948,6 +1039,48 @@ bool Application::event(QEvent* event) { · 29 unmodified lines
9481039
9491040 default:
9501041 break;
1042+=======
1043+ case Lambda:
1044+ ((LambdaEvent*)event)->call();
1045+ return true;
1046+
1047+ case QEvent::MouseMove:
1048+ mouseMoveEvent((QMouseEvent*)event);
1049+ return true;
1050+ case QEvent::MouseButtonPress:
1051+ mousePressEvent((QMouseEvent*)event);
1052+ return true;
1053+ case QEvent::MouseButtonRelease:
1054+ mouseReleaseEvent((QMouseEvent*)event);
1055+ return true;
1056+ case QEvent::KeyPress:
1057+ keyPressEvent((QKeyEvent*)event);
1058+ return true;
1059+ case QEvent::KeyRelease:
1060+ keyReleaseEvent((QKeyEvent*)event);
1061+ return true;
1062+ case QEvent::FocusOut:
1063+ focusOutEvent((QFocusEvent*)event);
1064+ return true;
1065+ case QEvent::TouchBegin:
1066+ touchBeginEvent(static_cast<QTouchEvent*>(event));
1067+ event->accept();
1068+ return true;
1069+ case QEvent::TouchEnd:
1070+ touchEndEvent(static_cast<QTouchEvent*>(event));
1071+ return true;
1072+ case QEvent::TouchUpdate:
1073+ touchUpdateEvent(static_cast<QTouchEvent*>(event));
1074+ return true;
1075+ case QEvent::Wheel:
1076+ wheelEvent(static_cast<QWheelEvent*>(event));
1077+ return true;
1078+ case QEvent::Drop:
1079+ dropEvent(static_cast<QDropEvent*>(event));
1080+ return true;
1081+ default:
1082+ break;
1083+>>>>>>> master
9511084 }
9521085
9531086 // handle custom URL
@@ -969,13 +1102,18 @@ bool Application::event(QEvent* event) { · 15 unmodified lines
9691102 if (HFActionEvent::types().contains(event->type())) {
9701103 _controllerScriptingInterface.handleMetaEvent(static_cast<HFMetaEvent*>(event));
9711104 }
972−
1105+
9731106 return QApplication::event(event);
9741107 }
9751108
9761109 bool Application::eventFilter(QObject* object, QEvent* event) {
9771110
9781111 if (event->type() == QEvent::ShortcutOverride) {
1112+ if (DependencyManager::get<OffscreenUi>()->shouldSwallowShortcut(event)) {
1113+ event->accept();
1114+ return true;
1115+ }
1116+
9791117 // Filter out captured keys before they're used for shortcut actions.
9801118 if (_controllerScriptingInterface.isKeyCaptured(static_cast<QKeyEvent*>(event))) {
9811119 event->accept();
@@ -986,8 +1124,10 @@ bool Application::eventFilter(QObject* object, QEvent* event) { · 4 unmodified lines
9861124 return false;
9871125 }
9881126
989−void Application::keyPressEvent(QKeyEvent* event) {
1127+static bool _altPressed{ false };
9901128
1129+void Application::keyPressEvent(QKeyEvent* event) {
1130+ _altPressed = event->key() == Qt::Key_Alt;
9911131 _keysPressed.insert(event->key());
9921132
9931133 _controllerScriptingInterface.emitKeyPressEvent(event); // send events to any registered scripts
@@ -1003,12 +1143,19 @@ void Application::keyPressEvent(QKeyEvent* event) { · 9 unmodified lines
10031143 bool isOption = event->modifiers().testFlag(Qt::AltModifier);
10041144 switch (event->key()) {
10051145 break;
1146+ case Qt::Key_Enter:
1147+ case Qt::Key_Return:
1148+ Menu::getInstance()->triggerOption(MenuOption::AddressBar);
1149+ break;
1150+
10061151 case Qt::Key_L:
1007− if (isShifted) {
1008− Menu::getInstance()->triggerOption(MenuOption::LodTools);
1009− } else if (isMeta) {
1152+ if (isShifted && isMeta) {
10101153 Menu::getInstance()->triggerOption(MenuOption::Log);
1011− }
1154+ } else if (isMeta) {
1155+ Menu::getInstance()->triggerOption(MenuOption::AddressBar);
1156+ } else if (isShifted) {
1157+ Menu::getInstance()->triggerOption(MenuOption::LodTools);
1158+ }
10121159 break;
10131160
10141161 case Qt::Key_E:
@@ -1068,11 +1215,6 @@ void Application::keyPressEvent(QKeyEvent* event) { · 53 unmodified lines
10681215 }
10691216 break;
10701217
1071− case Qt::Key_Return:
1072− case Qt::Key_Enter:
1073− Menu::getInstance()->triggerOption(MenuOption::AddressBar);
1074− break;
1075−
10761218 case Qt::Key_Backslash:
10771219 Menu::getInstance()->triggerOption(MenuOption::Chat);
10781220 break;
@@ -1226,11 +1368,6 @@ void Application::keyPressEvent(QKeyEvent* event) { · 147 unmodified lines
12261368 break;
12271369 }
12281370
1229− case Qt::Key_Comma: {
1230− renderCollisionHulls = !renderCollisionHulls;
1231− break;
1232− }
1233−
12341371 default:
12351372 event->ignore();
12361373 break;
@@ -1238,7 +1375,19 @@ void Application::keyPressEvent(QKeyEvent* event) { · 1 unmodified line
12381375 }
12391376 }
12401377
1378+
1379+//#define VR_MENU_ONLY_IN_HMD
1380+
12411381 void Application::keyReleaseEvent(QKeyEvent* event) {
1382+ if (event->key() == Qt::Key_Alt && _altPressed && _window->isActiveWindow()) {
1383+#ifdef VR_MENU_ONLY_IN_HMD
1384+ if (OculusManager::isConnected()) {
1385+#endif
1386+ VrMenu::toggle();
1387+#ifdef VR_MENU_ONLY_IN_HMD
1388+ }
1389+#endif
1390+ }
12421391
12431392 _keysPressed.remove(event->key());
12441393
@@ -1249,6 +1398,7 @@ void Application::keyReleaseEvent(QKeyEvent* event) { · 4 unmodified lines
12491398 return;
12501399 }
12511400
1401+
12521402 switch (event->key()) {
12531403 case Qt::Key_E:
12541404 case Qt::Key_PageUp:
@@ -1440,9 +1590,11 @@ void Application::mouseReleaseEvent(QMouseEvent* event, unsigned int deviceID) { · 185 unmodified lines
14401590 }
14411591
14421592 void Application::touchUpdateEvent(QTouchEvent* event) {
1443− TouchEvent thisEvent(*event, _lastTouchEvent);
1444− _controllerScriptingInterface.emitTouchUpdateEvent(thisEvent); // send events to any registered scripts
1445− _lastTouchEvent = thisEvent;
1593+ if (event->type() == QEvent::TouchUpdate) {
1594+ TouchEvent thisEvent(*event, _lastTouchEvent);
1595+ _controllerScriptingInterface.emitTouchUpdateEvent(thisEvent); // send events to any registered scripts
1596+ _lastTouchEvent = thisEvent;
1597+ }
14461598
14471599 // if one of our scripts have asked to capture this event, then stop processing it
14481600 if (_controllerScriptingInterface.isTouchCaptured()) {
@@ -1530,6 +1682,17 @@ void Application::dropEvent(QDropEvent *event) { · 81 unmodified lines
15301682 }
15311683 }
15321684
1685+void Application::dragEnterEvent(QDragEnterEvent* event) {
1686+ const QMimeData* mimeData = event->mimeData();
1687+ foreach(QUrl url, mimeData->urls()) {
1688+ auto urlString = url.toString();
1689+ if (canAcceptURL(urlString)) {
1690+ event->acceptProposedAction();
1691+ break;
1692+ }
1693+ }
1694+}
1695+
15331696 bool Application::acceptSnapshot(const QString& urlString) {
15341697 QUrl url(urlString);
15351698 QString snapshotPath = url.toLocalFile();
@@ -1767,21 +1930,21 @@ int Application::getMouseDragStartedY() const { · 231 unmodified lines
17671930
17681931 FaceTracker* Application::getActiveFaceTracker() {
17691932 auto faceshift = DependencyManager::get<Faceshift>();
1770− auto visage = DependencyManager::get<Visage>();
17711933 auto dde = DependencyManager::get<DdeFaceTracker>();
17721934
17731935 return (dde->isActive() ? static_cast<FaceTracker*>(dde.data()) :
1774− (faceshift->isActive() ? static_cast<FaceTracker*>(faceshift.data()) :
1775− (visage->isActive() ? static_cast<FaceTracker*>(visage.data()) : NULL)));
1936+ (faceshift->isActive() ? static_cast<FaceTracker*>(faceshift.data()) : NULL));
17761937 }
17771938
17781939 void Application::setActiveFaceTracker() {
17791940 #ifdef HAVE_FACESHIFT
17801941 DependencyManager::get<Faceshift>()->setTCPEnabled(Menu::getInstance()->isOptionChecked(MenuOption::Faceshift));
1781−#endif
1782− DependencyManager::get<DdeFaceTracker>()->setEnabled(Menu::getInstance()->isOptionChecked(MenuOption::DDEFaceRegression));
1783−#ifdef HAVE_VISAGE
1784− DependencyManager::get<Visage>()->updateEnabled();
1942+#endif
1943+#ifdef HAVE_DDE
1944+ bool isUsingDDE = Menu::getInstance()->isOptionChecked(MenuOption::UseCamera);
1945+ Menu::getInstance()->getActionForOption(MenuOption::UseAudioForMouth)->setVisible(isUsingDDE);
1946+ Menu::getInstance()->getActionForOption(MenuOption::VelocityFilter)->setVisible(isUsingDDE);
1947+ DependencyManager::get<DdeFaceTracker>()->setEnabled(isUsingDDE);
17851948 #endif
17861949 }
17871950
@@ -1958,7 +2121,6 @@ void Application::init() { · 170 unmodified lines
19582121 // initialize our face trackers after loading the menu settings
19592122 DependencyManager::get<Faceshift>()->init();
19602123 DependencyManager::get<DdeFaceTracker>()->init();
1961− DependencyManager::get<Visage>()->init();
19622124
19632125 Leapmotion::init();
19642126 RealSense::init();
@@ -2268,6 +2430,7 @@ void Application::update(float deltaTime) { · 303 unmodified lines
22682430 PerformanceTimer perfTimer("physics");
22692431 _myAvatar->relayDriveKeysToCharacterController();
22702432 _physicsEngine.stepSimulation();
2433+ _physicsEngine.dumpStatsIfNecessary();
22712434 }
22722435
22732436 if (!_aboutToQuit) {
@@ -2675,8 +2838,9 @@ void Application::updateShadowMap() { · 401 unmodified lines
26752838 activeRenderingThread = QThread::currentThread();
26762839
26772840 PerformanceTimer perfTimer("shadowMap");
2678− QOpenGLFramebufferObject* fbo = DependencyManager::get<TextureCache>()->getShadowFramebufferObject();
2679− fbo->bind();
2841+ auto shadowFramebuffer = DependencyManager::get<TextureCache>()->getShadowFramebuffer();
2842+ glBindFramebuffer(GL_FRAMEBUFFER, gpu::GLBackend::getFramebufferID(shadowFramebuffer));
2843+
26802844 glEnable(GL_DEPTH_TEST);
26812845 glClear(GL_DEPTH_BUFFER_BIT);
26822846
@@ -2692,16 +2856,18 @@ void Application::updateShadowMap() { · 9 unmodified lines
26922856 loadViewFrustum(_myCamera, _viewFrustum);
26932857
26942858 int matrixCount = 1;
2695− int targetSize = fbo->width();
2859+ //int targetSize = fbo->width();
2860+ int sourceSize = shadowFramebuffer->getWidth();
2861+ int targetSize = shadowFramebuffer->getWidth();
26962862 float targetScale = 1.0f;
26972863 if (Menu::getInstance()->isOptionChecked(MenuOption::CascadedShadows)) {
26982864 matrixCount = CASCADED_SHADOW_MATRIX_COUNT;
2699− targetSize = fbo->width() / 2;
2865+ targetSize = sourceSize / 2;
27002866 targetScale = 0.5f;
27012867 }
27022868 for (int i = 0; i < matrixCount; i++) {
27032869 const glm::vec2& coord = MAP_COORDS[i];
2704− glViewport(coord.s * fbo->width(), coord.t * fbo->height(), targetSize, targetSize);
2870+ glViewport(coord.s * sourceSize, coord.t * sourceSize, targetSize, targetSize);
27052871
27062872 // if simple shadow then since the resolution is twice as much as with cascaded, cover 2 regions with the map, not just one
27072873 int regionIncrement = (matrixCount == 1 ? 2 : 1);
@@ -2824,7 +2990,13 @@ void Application::updateShadowMap() { · 116 unmodified lines
28242990 glMatrixMode(GL_MODELVIEW);
28252991 }
28262992
2993+<<<<<<< HEAD
28272994 fbo->release();
2995+=======
2996+ // fbo->release();
2997+
2998+ glViewport(0, 0, _glWidget->getDeviceWidth(), _glWidget->getDeviceHeight());
2999+>>>>>>> master
28283000 activeRenderingThread = nullptr;
28293001 }
28303002
@@ -2864,7 +3036,8 @@ int Application::getBoundaryLevelAdjust() const { · 33 unmodified lines
28643036 }
28653037
28663038 QImage Application::renderAvatarBillboard() {
2867− DependencyManager::get<TextureCache>()->getPrimaryFramebufferObject()->bind();
3039+ auto primaryFramebuffer = DependencyManager::get<TextureCache>()->getPrimaryFramebuffer();
3040+ glBindFramebuffer(GL_FRAMEBUFFER, gpu::GLBackend::getFramebufferID(primaryFramebuffer));
28683041
28693042 // the "glow" here causes an alpha of one
28703043 Glower glower;
@@ -2879,7 +3052,7 @@ QImage Application::renderAvatarBillboard() { · 8 unmodified lines
28793052 QImage image(BILLBOARD_SIZE, BILLBOARD_SIZE, QImage::Format_ARGB32);
28803053 glReadPixels(0, 0, BILLBOARD_SIZE, BILLBOARD_SIZE, GL_BGRA, GL_UNSIGNED_BYTE, image.bits());
28813054
2882− DependencyManager::get<TextureCache>()->getPrimaryFramebufferObject()->release();
3055+ glBindFramebuffer(GL_FRAMEBUFFER, 0);
28833056
28843057 return image;
28853058 }
@@ -3036,13 +3209,21 @@ void Application::displaySide(Camera& theCamera, bool selfAvatarOnly, RenderArgs · 150 unmodified lines
30363209 PerformanceTimer perfTimer("entities");
30373210 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
30383211 "Application::displaySide() ... entities...");
3039− if (renderCollisionHulls) {
3040− _entities.render(RenderArgs::DEBUG_RENDER_MODE, renderSide);
3041− } else if (theCamera.getMode() == CAMERA_MODE_MIRROR) {
3042− _entities.render(RenderArgs::MIRROR_RENDER_MODE, renderSide);
3043− } else {
3044− _entities.render(RenderArgs::DEFAULT_RENDER_MODE, renderSide);
3212+
3213+ RenderArgs::DebugFlags renderDebugFlags = RenderArgs::RENDER_DEBUG_NONE;
3214+ RenderArgs::RenderMode renderMode = RenderArgs::DEFAULT_RENDER_MODE;
3215+
3216+ if (Menu::getInstance()->isOptionChecked(MenuOption::PhysicsShowHulls)) {
3217+ renderDebugFlags = (RenderArgs::DebugFlags) (renderDebugFlags | (int) RenderArgs::RENDER_DEBUG_HULLS);
3218+ }
3219+ if (Menu::getInstance()->isOptionChecked(MenuOption::PhysicsShowOwned)) {
3220+ renderDebugFlags =
3221+ (RenderArgs::DebugFlags) (renderDebugFlags | (int) RenderArgs::RENDER_DEBUG_SIMULATION_OWNERSHIP);
30453222 }
3223+ if (theCamera.getMode() == CAMERA_MODE_MIRROR) {
3224+ renderMode = RenderArgs::MIRROR_RENDER_MODE;
3225+ }
3226+ _entities.render(renderMode, renderSide, renderDebugFlags);
30463227 }
30473228
30483229 // render JS/scriptable overlays
@@ -3071,7 +3252,7 @@ void Application::displaySide(Camera& theCamera, bool selfAvatarOnly, RenderArgs · 22 unmodified lines
30713252 {
30723253 DependencyManager::get<DeferredLightingEffect>()->setAmbientLightMode(getRenderAmbientLight());
30733254 auto skyStage = DependencyManager::get<SceneScriptingInterface>()->getSkyStage();
3074− DependencyManager::get<DeferredLightingEffect>()->setGlobalLight(skyStage->getSunLight()->getDirection(), skyStage->getSunLight()->getColor(), skyStage->getSunLight()->getIntensity());
3255+ DependencyManager::get<DeferredLightingEffect>()->setGlobalLight(skyStage->getSunLight()->getDirection(), skyStage->getSunLight()->getColor(), skyStage->getSunLight()->getIntensity(), skyStage->getSunLight()->getAmbientIntensity());
30753256 DependencyManager::get<DeferredLightingEffect>()->setGlobalAtmosphere(skyStage->getAtmosphere());
30763257
30773258 PROFILE_RANGE("DeferredLighting");
@@ -3253,7 +3434,6 @@ void Application::renderRearViewMirror(const QRect& region, bool billboard) { · 175 unmodified lines
32533434
32543435 void Application::resetSensors() {
32553436 DependencyManager::get<Faceshift>()->reset();
3256− DependencyManager::get<Visage>()->reset();
32573437 DependencyManager::get<DdeFaceTracker>()->reset();
32583438
32593439 getActiveRenderPlugin()->resetSensors();
@@ -3715,17 +3895,7 @@ bool Application::askToSetAvatarUrl(const QString& url) { · 455 unmodified lines
37153895 }
37163896
37173897 // Download the FST file, to attempt to determine its model type
3718− QNetworkAccessManager& networkAccessManager = NetworkAccessManager::getInstance();
3719− QNetworkRequest networkRequest = QNetworkRequest(url);
3720− networkRequest.setHeader(QNetworkRequest::UserAgentHeader, HIGH_FIDELITY_USER_AGENT);
3721− QNetworkReply* reply = networkAccessManager.get(networkRequest);
3722− qCDebug(interfaceapp) << "Downloading avatar file at " << url;
3723− QEventLoop loop;
3724− QObject::connect(reply, &QNetworkReply::finished, &loop, &QEventLoop::quit);
3725− loop.exec();
3726− QByteArray fstContents = reply->readAll();
3727− delete reply;
3728− QVariantHash fstMapping = FSTReader::readMapping(fstContents);
3898+ QVariantHash fstMapping = FSTReader::downloadMapping(url);
37293899
37303900 FSTReader::ModelType modelType = FSTReader::predictModelType(fstMapping);
37313901
@@ -3736,26 +3906,27 @@ bool Application::askToSetAvatarUrl(const QString& url) { · 4 unmodified lines
37363906 QPushButton* bodyButton = NULL;
37373907 QPushButton* bodyAndHeadButton = NULL;
37383908
3909+ QString modelName = fstMapping["name"].toString();
37393910 QString message;
37403911 QString typeInfo;
37413912 switch (modelType) {
37423913 case FSTReader::HEAD_MODEL:
3743− message = QString("Would you like to use '") + fstMapping["name"].toString() + QString("' for your avatar head?");
3914+ message = QString("Would you like to use '") + modelName + QString("' for your avatar head?");
37443915 headButton = msgBox.addButton(tr("Yes"), QMessageBox::ActionRole);
37453916 break;
37463917
37473918 case FSTReader::BODY_ONLY_MODEL:
3748− message = QString("Would you like to use '") + fstMapping["name"].toString() + QString("' for your avatar body?");
3919+ message = QString("Would you like to use '") + modelName + QString("' for your avatar body?");
37493920 bodyButton = msgBox.addButton(tr("Yes"), QMessageBox::ActionRole);
37503921 break;
37513922
37523923 case FSTReader::HEAD_AND_BODY_MODEL:
3753− message = QString("Would you like to use '") + fstMapping["name"].toString() + QString("' for your avatar?");
3924+ message = QString("Would you like to use '") + modelName + QString("' for your avatar?");
37543925 bodyAndHeadButton = msgBox.addButton(tr("Yes"), QMessageBox::ActionRole);
37553926 break;
37563927
37573928 default:
3758− message = QString("Would you like to use '") + fstMapping["name"].toString() + QString("' for some part of your avatar head?");
3929+ message = QString("Would you like to use '") + modelName + QString("' for some part of your avatar head?");
37593930 headButton = msgBox.addButton(tr("Use for Head"), QMessageBox::ActionRole);
37603931 bodyButton = msgBox.addButton(tr("Use for Body"), QMessageBox::ActionRole);
37613932 bodyAndHeadButton = msgBox.addButton(tr("Use for Body and Head"), QMessageBox::ActionRole);
@@ -3768,34 +3939,18 @@ bool Application::askToSetAvatarUrl(const QString& url) { · 6 unmodified lines
37683939 msgBox.exec();
37693940
37703941 if (msgBox.clickedButton() == headButton) {
3771− qCDebug(interfaceapp) << "Chose to use for head: " << url;
3772− _myAvatar->setFaceModelURL(url);
3773− UserActivityLogger::getInstance().changedModel("head", url);
3774− _myAvatar->sendIdentityPacket();
3775− emit faceURLChanged(url);
3942+ _myAvatar->useHeadURL(url, modelName);
3943+ emit headURLChanged(url, modelName);
37763944 } else if (msgBox.clickedButton() == bodyButton) {
3777− qCDebug(interfaceapp) << "Chose to use for body: " << url;
3778− _myAvatar->setSkeletonModelURL(url);
3779− // if the head is empty, reset it to the default head.
3780− if (_myAvatar->getFaceModelURLString().isEmpty()) {
3781− _myAvatar->setFaceModelURL(DEFAULT_HEAD_MODEL_URL);
3782− emit faceURLChanged(DEFAULT_HEAD_MODEL_URL.toString());
3783− UserActivityLogger::getInstance().changedModel("head", DEFAULT_HEAD_MODEL_URL.toString());
3784− }
3785− UserActivityLogger::getInstance().changedModel("skeleton", url);
3786− _myAvatar->sendIdentityPacket();
3787− emit skeletonURLChanged(url);
3945+ _myAvatar->useBodyURL(url, modelName);
3946+ emit bodyURLChanged(url, modelName);
37883947 } else if (msgBox.clickedButton() == bodyAndHeadButton) {
3789− qCDebug(interfaceapp) << "Chose to use for body + head: " << url;
3790− _myAvatar->setFaceModelURL(QString());
3791− _myAvatar->setSkeletonModelURL(url);
3792− UserActivityLogger::getInstance().changedModel("skeleton", url);
3793− _myAvatar->sendIdentityPacket();
3794− emit faceURLChanged(QString());
3795− emit skeletonURLChanged(url);
3948+ _myAvatar->useFullAvatarURL(url, modelName);
3949+ emit fullAvatarURLChanged(url, modelName);
37963950 } else {
37973951 qCDebug(interfaceapp) << "Declined to use the avatar: " << url;
37983952 }
3953+
37993954 return true;
38003955 }
38013956
@@ -3885,6 +4040,9 @@ void Application::stopAllScripts(bool restart) { · 83 unmodified lines
38854040 // stops all current running scripts
38864041 for (QHash<QString, ScriptEngine*>::const_iterator it = _scriptEnginesHash.constBegin();
38874042 it != _scriptEnginesHash.constEnd(); it++) {
4043+ if (it.value()->isFinished()) {
4044+ continue;
4045+ }
38884046 if (restart && it.value()->isUserLoaded()) {
38894047 connect(it.value(), SIGNAL(finished(const QString&)), SLOT(loadScript(const QString&)));
38904048 }
@@ -4307,10 +4465,8 @@ void Application::checkSkeleton() { · 416 unmodified lines
43074465 msgBox.setIcon(QMessageBox::Warning);
43084466 msgBox.exec();
43094467
4310− _myAvatar->setSkeletonModelURL(DEFAULT_BODY_MODEL_URL);
4311− _myAvatar->sendIdentityPacket();
4468+ _myAvatar->useBodyURL(DEFAULT_BODY_MODEL_URL, "Default");
43124469 } else {
4313− _myAvatar->updateCharacterController();
43144470 _physicsEngine.setCharacterController(_myAvatar->getCharacterController());
43154471 }
43164472 }
@@ -4334,6 +4490,10 @@ void Application::friendsWindowClosed() { · 17 unmodified lines
43344490 }
43354491
43364492
4493+void Application::postLambdaEvent(std::function<void()> f) {
4494+ QCoreApplication::postEvent(this, new LambdaEvent(f));
4495+}
4496+
43374497 PickRay Application::computePickRay() const {
43384498 return computePickRay(getTrueMouseX(), getTrueMouseY());
43394499 }

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