Showing the changes to interface/src/Application.cpp (1 of 98 files). Show all
Unified · Split
| @@ -151,6 +151,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 150 unmodified lines | ||
| 151 | 151 | _lastQueriedTime(usecTimestampNow()), |
| 152 | 152 | _mirrorViewRect(QRect(MIRROR_VIEW_LEFT_PADDING, MIRROR_VIEW_TOP_PADDING, MIRROR_VIEW_WIDTH, MIRROR_VIEW_HEIGHT)), |
| 153 | 153 | _cameraPushback(0.0f), |
| 154 | + _scaleMirror(1.0f), | |
| 155 | + _rotateMirror(0.0f), | |
| 156 | + _raiseMirror(0.0f), | |
| 154 | 157 | _mouseX(0), |
| 155 | 158 | _mouseY(0), |
| 156 | 159 | _lastMouseMove(usecTimestampNow()), |
| @@ -572,9 +575,9 @@ void Application::paintGL() { · 415 unmodified lines | ||
| 572 | 575 | _myCamera.setTightness(0.0f); |
| 573 | 576 | glm::vec3 eyePosition = _myAvatar->getHead()->calculateAverageEyePosition(); |
| 574 | 577 | float headHeight = eyePosition.y - _myAvatar->getPosition().y; |
| 575 | − _myCamera.setDistance(MIRROR_FULLSCREEN_DISTANCE * _myAvatar->getScale()); | |
| 576 | − _myCamera.setTargetPosition(_myAvatar->getPosition() + glm::vec3(0, headHeight, 0)); | |
| 577 | − _myCamera.setTargetRotation(_myAvatar->getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PI, 0.0f))); | |
| 578 | + _myCamera.setDistance(MIRROR_FULLSCREEN_DISTANCE * _myAvatar->getScale() * _scaleMirror); | |
| 579 | + _myCamera.setTargetPosition(_myAvatar->getPosition() + glm::vec3(0, headHeight + (_raiseMirror * _myAvatar->getScale()), 0)); | |
| 580 | + _myCamera.setTargetRotation(_myAvatar->getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f))); | |
| 578 | 581 | |
| 579 | 582 | // if the head would intersect the near clip plane, we must push the camera out |
| 580 | 583 | glm::vec3 relativePosition = glm::inverse(_myCamera.getTargetRotation()) * |
| @@ -685,11 +688,8 @@ void Application::resizeGL(int width, int height) { · 104 unmodified lines | ||
| 685 | 688 | glLoadIdentity(); |
| 686 | 689 | |
| 687 | 690 | // update Stats width |
| 688 | − int horizontalOffset = 0; | |
| 689 | − if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) { | |
| 690 | − // mirror is enabled, let's set horizontal offset to give stats some margin | |
| 691 | − horizontalOffset += MIRROR_VIEW_WIDTH + MIRROR_VIEW_LEFT_PADDING * 2; | |
| 692 | − } | |
| 691 | + // let's set horizontal offset to give stats some margin to mirror | |
| 692 | + int horizontalOffset = MIRROR_VIEW_WIDTH + MIRROR_VIEW_LEFT_PADDING * 2; | |
| 693 | 693 | Stats::getInstance()->resetWidth(width, horizontalOffset); |
| 694 | 694 | } |
| 695 | 695 | |
| @@ -870,19 +870,43 @@ void Application::keyPressEvent(QKeyEvent* event) { · 174 unmodified lines | ||
| 870 | 870 | break; |
| 871 | 871 | |
| 872 | 872 | case Qt::Key_Up: |
| 873 | − _myAvatar->setDriveKeys(isShifted ? UP : FWD, 1.f); | |
| 873 | + if (_myCamera.getMode() == CAMERA_MODE_MIRROR) { | |
| 874 | + if (!isShifted) { | |
| 875 | + _scaleMirror *= 0.95f; | |
| 876 | + } else { | |
| 877 | + _raiseMirror += 0.05f; | |
| 878 | + } | |
| 879 | + } else { | |
| 880 | + _myAvatar->setDriveKeys(isShifted ? UP : FWD, 1.f); | |
| 881 | + } | |
| 874 | 882 | break; |
| 875 | 883 | |
| 876 | 884 | case Qt::Key_Down: |
| 877 | − _myAvatar->setDriveKeys(isShifted ? DOWN : BACK, 1.f); | |
| 885 | + if (_myCamera.getMode() == CAMERA_MODE_MIRROR) { | |
| 886 | + if (!isShifted) { | |
| 887 | + _scaleMirror *= 1.05f; | |
| 888 | + } else { | |
| 889 | + _raiseMirror -= 0.05f; | |
| 890 | + } | |
| 891 | + } else { | |
| 892 | + _myAvatar->setDriveKeys(isShifted ? DOWN : BACK, 1.f); | |
| 893 | + } | |
| 878 | 894 | break; |
| 879 | 895 | |
| 880 | 896 | case Qt::Key_Left: |
| 881 | − _myAvatar->setDriveKeys(isShifted ? LEFT : ROT_LEFT, 1.f); | |
| 897 | + if (_myCamera.getMode() == CAMERA_MODE_MIRROR) { | |
| 898 | + _rotateMirror += PI / 20.f; | |
| 899 | + } else { | |
| 900 | + _myAvatar->setDriveKeys(isShifted ? LEFT : ROT_LEFT, 1.f); | |
| 901 | + } | |
| 882 | 902 | break; |
| 883 | 903 | |
| 884 | 904 | case Qt::Key_Right: |
| 885 | − _myAvatar->setDriveKeys(isShifted ? RIGHT : ROT_RIGHT, 1.f); | |
| 905 | + if (_myCamera.getMode() == CAMERA_MODE_MIRROR) { | |
| 906 | + _rotateMirror -= PI / 20.f; | |
| 907 | + } else { | |
| 908 | + _myAvatar->setDriveKeys(isShifted ? RIGHT : ROT_RIGHT, 1.f); | |
| 909 | + } | |
| 886 | 910 | break; |
| 887 | 911 | |
| 888 | 912 | case Qt::Key_I: |
| @@ -1139,10 +1163,8 @@ void Application::mouseReleaseEvent(QMouseEvent* event) { · 250 unmodified lines | ||
| 1139 | 1163 | _mousePressed = false; |
| 1140 | 1164 | checkBandwidthMeterClick(); |
| 1141 | 1165 | if (Menu::getInstance()->isOptionChecked(MenuOption::Stats)) { |
| 1142 | − int horizontalOffset = 0; | |
| 1143 | − if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) { | |
| 1144 | − horizontalOffset = MIRROR_VIEW_WIDTH; | |
| 1145 | − } | |
| 1166 | + // let's set horizontal offset to give stats some margin to mirror | |
| 1167 | + int horizontalOffset = MIRROR_VIEW_WIDTH; | |
| 1146 | 1168 | Stats::getInstance()->checkClick(_mouseX, _mouseY, _mouseDragStartedX, _mouseDragStartedY, horizontalOffset); |
| 1147 | 1169 | } |
| 1148 | 1170 | } |
| @@ -1194,10 +1216,6 @@ void Application::touchBeginEvent(QTouchEvent* event) { · 45 unmodified lines | ||
| 1194 | 1216 | return; |
| 1195 | 1217 | } |
| 1196 | 1218 | |
| 1197 | − // put any application specific touch behavior below here.. | |
| 1198 | − _lastTouchAvgX = _touchAvgX; | |
| 1199 | − _lastTouchAvgY = _touchAvgY; | |
| 1200 | − | |
| 1201 | 1219 | } |
| 1202 | 1220 | |
| 1203 | 1221 | void Application::touchEndEvent(QTouchEvent* event) { |
| @@ -1852,34 +1870,6 @@ void Application::updateMyAvatarLookAtPosition() { · 648 unmodified lines | ||
| 1852 | 1870 | _myAvatar->getHead()->setLookAtPosition(lookAtSpot); |
| 1853 | 1871 | } |
| 1854 | 1872 | |
| 1855 | −void Application::updateHandAndTouch(float deltaTime) { | |
| 1856 | − bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); | |
| 1857 | − PerformanceWarning warn(showWarnings, "Application::updateHandAndTouch()"); | |
| 1858 | − | |
| 1859 | − // Update from Touch | |
| 1860 | − if (_isTouchPressed) { | |
| 1861 | − _lastTouchAvgX = _touchAvgX; | |
| 1862 | − _lastTouchAvgY = _touchAvgY; | |
| 1863 | − } | |
| 1864 | −} | |
| 1865 | − | |
| 1866 | −void Application::updateLeap(float deltaTime) { | |
| 1867 | − bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); | |
| 1868 | − PerformanceWarning warn(showWarnings, "Application::updateLeap()"); | |
| 1869 | −} | |
| 1870 | − | |
| 1871 | −void Application::updateSixense(float deltaTime) { | |
| 1872 | − bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); | |
| 1873 | − PerformanceWarning warn(showWarnings, "Application::updateSixense()"); | |
| 1874 | − | |
| 1875 | − _sixenseManager.update(deltaTime); | |
| 1876 | −} | |
| 1877 | − | |
| 1878 | −void Application::updateSerialDevices(float deltaTime) { | |
| 1879 | − bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); | |
| 1880 | − PerformanceWarning warn(showWarnings, "Application::updateSerialDevices()"); | |
| 1881 | −} | |
| 1882 | − | |
| 1883 | 1873 | void Application::updateThreads(float deltaTime) { |
| 1884 | 1874 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); |
| 1885 | 1875 | PerformanceWarning warn(showWarnings, "Application::updateThreads()"); |
| @@ -1993,11 +1983,7 @@ void Application::update(float deltaTime) { · 107 unmodified lines | ||
| 1993 | 1983 | updateVisage(); |
| 1994 | 1984 | _myAvatar->updateLookAtTargetAvatar(); |
| 1995 | 1985 | updateMyAvatarLookAtPosition(); |
| 1996 | − | |
| 1997 | − updateHandAndTouch(deltaTime); // Update state for touch sensors | |
| 1998 | − updateLeap(deltaTime); // Leap finger-sensing device | |
| 1999 | − updateSixense(deltaTime); // Razer Hydra controllers | |
| 2000 | − updateSerialDevices(deltaTime); // Read serial port interface devices | |
| 1986 | + _sixenseManager.update(deltaTime); | |
| 2001 | 1987 | updateMyAvatar(deltaTime); // Sample hardware, update view frustum if needed, and send avatar data to mixer/nodes |
| 2002 | 1988 | updateThreads(deltaTime); // If running non-threaded, then give the threads some time to process... |
| 2003 | 1989 | _avatarManager.updateOtherAvatars(deltaTime); //loop through all the other avatars and simulate them... |
| @@ -2350,8 +2336,8 @@ void Application::updateShadowMap() { · 346 unmodified lines | ||
| 2350 | 2336 | updateUntranslatedViewMatrix(); |
| 2351 | 2337 | |
| 2352 | 2338 | _avatarManager.renderAvatars(Avatar::SHADOW_RENDER_MODE); |
| 2353 | − _particles.render(); | |
| 2354 | − _models.render(); | |
| 2339 | + _particles.render(OctreeRenderer::SHADOW_RENDER_MODE); | |
| 2340 | + _models.render(OctreeRenderer::SHADOW_RENDER_MODE); | |
| 2355 | 2341 | |
| 2356 | 2342 | glPopMatrix(); |
| 2357 | 2343 | |
| @@ -2743,11 +2729,8 @@ void Application::displayOverlay() { · 385 unmodified lines | ||
| 2743 | 2729 | glPointSize(1.0f); |
| 2744 | 2730 | |
| 2745 | 2731 | if (Menu::getInstance()->isOptionChecked(MenuOption::Stats)) { |
| 2746 | − int horizontalOffset = 0; | |
| 2747 | − if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) { | |
| 2748 | − // mirror is enabled, let's set horizontal offset to give stats some margin | |
| 2749 | − horizontalOffset += MIRROR_VIEW_WIDTH + MIRROR_VIEW_LEFT_PADDING * 2; | |
| 2750 | − } | |
| 2732 | + // let's set horizontal offset to give stats some margin to mirror | |
| 2733 | + int horizontalOffset = MIRROR_VIEW_WIDTH + MIRROR_VIEW_LEFT_PADDING * 2; | |
| 2751 | 2734 | int voxelPacketsToProcess = _voxelProcessor.packetsToProcessCount(); |
| 2752 | 2735 | // Onscreen text about position, servers, etc |
| 2753 | 2736 | Stats::getInstance()->display(WHITE_TEXT, horizontalOffset, _fps, _packetsPerSecond, _bytesPerSecond, voxelPacketsToProcess); |
| @@ -3387,71 +3370,6 @@ void Application::saveScripts() { · 633 unmodified lines | ||
| 3387 | 3370 | _settings->endArray(); |
| 3388 | 3371 | } |
| 3389 | 3372 | |
| 3390 | −void Application::stopAllScripts() { | |
| 3391 | − // stops all current running scripts | |
| 3392 | − for (int i = 0; i < _scriptEnginesHash.size(); ++i) { | |
| 3393 | − _scriptEnginesHash.values().at(i)->stop(); | |
| 3394 | − qDebug() << "stopping script..." << getRunningScripts().at(i); | |
| 3395 | − } | |
| 3396 | − _scriptEnginesHash.clear(); | |
| 3397 | − _runningScriptsWidget->setRunningScripts(getRunningScripts()); | |
| 3398 | − bumpSettings(); | |
| 3399 | −} | |
| 3400 | − | |
| 3401 | −void Application::stopScript(const QString &scriptName) { | |
| 3402 | − if (_scriptEnginesHash.contains(scriptName)) { | |
| 3403 | − _scriptEnginesHash.value(scriptName)->stop(); | |
| 3404 | − qDebug() << "stopping script..." << scriptName; | |
| 3405 | − _scriptEnginesHash.remove(scriptName); | |
| 3406 | − _runningScriptsWidget->setRunningScripts(getRunningScripts()); | |
| 3407 | − bumpSettings(); | |
| 3408 | − } | |
| 3409 | −} | |
| 3410 | − | |
| 3411 | −void Application::reloadAllScripts() { | |
| 3412 | − // remember all the current scripts so we can reload them | |
| 3413 | − QStringList reloadList = getRunningScripts(); | |
| 3414 | − // reloads all current running scripts | |
| 3415 | − stopAllScripts(); | |
| 3416 | − | |
| 3417 | − foreach (QString scriptName, reloadList){ | |
| 3418 | − qDebug() << "reloading script..." << scriptName; | |
| 3419 | − loadScript(scriptName); | |
| 3420 | − } | |
| 3421 | −} | |
| 3422 | − | |
| 3423 | −void Application::manageRunningScriptsWidgetVisibility(bool shown) { | |
| 3424 | − if (_runningScriptsWidgetWasVisible && shown) { | |
| 3425 | − _runningScriptsWidget->show(); | |
| 3426 | − } else if (_runningScriptsWidgetWasVisible && !shown) { | |
| 3427 | − _runningScriptsWidget->hide(); | |
| 3428 | − } | |
| 3429 | −} | |
| 3430 | − | |
| 3431 | −void Application::toggleRunningScriptsWidget() { | |
| 3432 | − if (_runningScriptsWidgetWasVisible) { | |
| 3433 | − _runningScriptsWidget->hide(); | |
| 3434 | − _runningScriptsWidgetWasVisible = false; | |
| 3435 | − } else { | |
| 3436 | − _runningScriptsWidget->setBoundary(QRect(_window->geometry().topLeft(), | |
| 3437 | − _window->size())); | |
| 3438 | − _runningScriptsWidget->show(); | |
| 3439 | − _runningScriptsWidgetWasVisible = true; | |
| 3440 | − } | |
| 3441 | −} | |
| 3442 | − | |
| 3443 | −void Application::uploadHead() { | |
| 3444 | − uploadModel(HEAD_MODEL); | |
| 3445 | −} | |
| 3446 | − | |
| 3447 | −void Application::uploadSkeleton() { | |
| 3448 | − uploadModel(SKELETON_MODEL); | |
| 3449 | −} | |
| 3450 | − | |
| 3451 | −void Application::uploadAttachment() { | |
| 3452 | − uploadModel(ATTACHMENT_MODEL); | |
| 3453 | −} | |
| 3454 | − | |
| 3455 | 3373 | ScriptEngine* Application::loadScript(const QString& scriptName, bool loadScriptFromEditor) { |
| 3456 | 3374 | if(loadScriptFromEditor && _scriptEnginesHash.contains(scriptName) && !_scriptEnginesHash[scriptName]->isFinished()){ |
| 3457 | 3375 | return _scriptEnginesHash[scriptName]; |
| @@ -3489,6 +3407,8 @@ ScriptEngine* Application::loadScript(const QString& scriptName, bool loadScript · 31 unmodified lines | ||
| 3489 | 3407 | scriptEngine->registerGlobalObject("Clipboard", clipboardScriptable); |
| 3490 | 3408 | connect(scriptEngine, SIGNAL(finished(const QString&)), clipboardScriptable, SLOT(deleteLater())); |
| 3491 | 3409 | |
| 3410 | + connect(scriptEngine, SIGNAL(finished(const QString&)), this, SLOT(scriptFinished(const QString&))); | |
| 3411 | + | |
| 3492 | 3412 | scriptEngine->registerGlobalObject("Overlays", &_overlays); |
| 3493 | 3413 | |
| 3494 | 3414 | QScriptValue windowValue = scriptEngine->registerGlobalObject("Window", WindowScriptingInterface::getInstance()); |
| @@ -3531,6 +3451,69 @@ ScriptEngine* Application::loadScript(const QString& scriptName, bool loadScript · 36 unmodified lines | ||
| 3531 | 3451 | return scriptEngine; |
| 3532 | 3452 | } |
| 3533 | 3453 | |
| 3454 | +void Application::scriptFinished(const QString& scriptName) { | |
| 3455 | + if (_scriptEnginesHash.remove(scriptName)) { | |
| 3456 | + _runningScriptsWidget->scriptStopped(scriptName); | |
| 3457 | + _runningScriptsWidget->setRunningScripts(getRunningScripts()); | |
| 3458 | + bumpSettings(); | |
| 3459 | + } | |
| 3460 | +} | |
| 3461 | + | |
| 3462 | +void Application::stopAllScripts(bool restart) { | |
| 3463 | + // stops all current running scripts | |
| 3464 | + for (QHash<QString, ScriptEngine*>::const_iterator it = _scriptEnginesHash.constBegin(); | |
| 3465 | + it != _scriptEnginesHash.constEnd(); it++) { | |
| 3466 | + if (restart) { | |
| 3467 | + connect(it.value(), SIGNAL(finished(const QString&)), SLOT(loadScript(const QString&))); | |
| 3468 | + } | |
| 3469 | + it.value()->stop(); | |
| 3470 | + qDebug() << "stopping script..." << it.key(); | |
| 3471 | + } | |
| 3472 | +} | |
| 3473 | + | |
| 3474 | +void Application::stopScript(const QString &scriptName) { | |
| 3475 | + if (_scriptEnginesHash.contains(scriptName)) { | |
| 3476 | + _scriptEnginesHash.value(scriptName)->stop(); | |
| 3477 | + qDebug() << "stopping script..." << scriptName; | |
| 3478 | + } | |
| 3479 | +} | |
| 3480 | + | |
| 3481 | +void Application::reloadAllScripts() { | |
| 3482 | + stopAllScripts(true); | |
| 3483 | +} | |
| 3484 | + | |
| 3485 | +void Application::manageRunningScriptsWidgetVisibility(bool shown) { | |
| 3486 | + if (_runningScriptsWidgetWasVisible && shown) { | |
| 3487 | + _runningScriptsWidget->show(); | |
| 3488 | + } else if (_runningScriptsWidgetWasVisible && !shown) { | |
| 3489 | + _runningScriptsWidget->hide(); | |
| 3490 | + } | |
| 3491 | +} | |
| 3492 | + | |
| 3493 | +void Application::toggleRunningScriptsWidget() { | |
| 3494 | + if (_runningScriptsWidgetWasVisible) { | |
| 3495 | + _runningScriptsWidget->hide(); | |
| 3496 | + _runningScriptsWidgetWasVisible = false; | |
| 3497 | + } else { | |
| 3498 | + _runningScriptsWidget->setBoundary(QRect(_window->geometry().topLeft(), | |
| 3499 | + _window->size())); | |
| 3500 | + _runningScriptsWidget->show(); | |
| 3501 | + _runningScriptsWidgetWasVisible = true; | |
| 3502 | + } | |
| 3503 | +} | |
| 3504 | + | |
| 3505 | +void Application::uploadHead() { | |
| 3506 | + uploadModel(HEAD_MODEL); | |
| 3507 | +} | |
| 3508 | + | |
| 3509 | +void Application::uploadSkeleton() { | |
| 3510 | + uploadModel(SKELETON_MODEL); | |
| 3511 | +} | |
| 3512 | + | |
| 3513 | +void Application::uploadAttachment() { | |
| 3514 | + uploadModel(ATTACHMENT_MODEL); | |
| 3515 | +} | |
| 3516 | + | |
| 3534 | 3517 | QString Application::getPreviousScriptLocation() { |
| 3535 | 3518 | QString suggestedName; |
| 3536 | 3519 | if (_previousScriptLocation.isEmpty()) { |
| @@ -3670,7 +3653,17 @@ void Application::takeSnapshot() { · 133 unmodified lines | ||
| 3670 | 3653 | player->setMedia(QUrl::fromLocalFile(inf.absoluteFilePath())); |
| 3671 | 3654 | player->play(); |
| 3672 | 3655 | |
| 3673 | − Snapshot::saveSnapshot(_glWidget, _myAvatar); | |
| 3656 | + QString fileName = Snapshot::saveSnapshot(_glWidget, _myAvatar); | |
| 3657 | + | |
| 3658 | + AccountManager& accountManager = AccountManager::getInstance(); | |
| 3659 | + if (!accountManager.isLoggedIn()) { | |
| 3660 | + return; | |
| 3661 | + } | |
| 3662 | + | |
| 3663 | + if (!_snapshotShareDialog) { | |
| 3664 | + _snapshotShareDialog = new SnapshotShareDialog(fileName, _glWidget); | |
| 3665 | + } | |
| 3666 | + _snapshotShareDialog->show(); | |
| 3674 | 3667 | } |
| 3675 | 3668 | |
| 3676 | 3669 | void Application::urlGoTo(int argc, const char * constArgv[]) { |