Showing the changes to interface/src/Application.cpp (1 of 128 files). Show all
Unified · Split
| @@ -896,8 +896,11 @@ void Application::paintGL() { · 895 unmodified lines | ||
| 896 | 896 | |
| 897 | 897 | glEnable(GL_LINE_SMOOTH); |
| 898 | 898 | |
| 899 | − Menu::getInstance()->setIsOptionChecked("First Person", _myAvatar->getBoomLength() <= MyAvatar::ZOOM_MIN); | |
| 900 | − Application::getInstance()->cameraMenuChanged(); | |
| 899 | + if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON || _myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) { | |
| 900 | + Menu::getInstance()->setIsOptionChecked(MenuOption::FirstPerson, _myAvatar->getBoomLength() <= MyAvatar::ZOOM_MIN); | |
| 901 | + Menu::getInstance()->setIsOptionChecked(MenuOption::ThirdPerson, !(_myAvatar->getBoomLength() <= MyAvatar::ZOOM_MIN)); | |
| 902 | + Application::getInstance()->cameraMenuChanged(); | |
| 903 | + } | |
| 901 | 904 | |
| 902 | 905 | if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON) { |
| 903 | 906 | // Always use the default eye position, not the actual head eye position. |
| @@ -1014,7 +1017,7 @@ void Application::paintGL() { · 110 unmodified lines | ||
| 1014 | 1017 | glBindFramebuffer(GL_READ_FRAMEBUFFER, gpu::GLBackend::getFramebufferID(finalFbo)); |
| 1015 | 1018 | glBlitFramebuffer(0, 0, _renderResolution.x, _renderResolution.y, |
| 1016 | 1019 | 0, 0, _glWidget->getDeviceSize().width(), _glWidget->getDeviceSize().height(), |
| 1017 | − GL_COLOR_BUFFER_BIT, GL_NEAREST); | |
| 1020 | + GL_COLOR_BUFFER_BIT, GL_LINEAR); | |
| 1018 | 1021 | glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); |
| 1019 | 1022 | |
| 1020 | 1023 | _compositor.displayOverlayTexture(&renderArgs); |
| @@ -1401,11 +1404,17 @@ void Application::keyPressEvent(QKeyEvent* event) { · 380 unmodified lines | ||
| 1401 | 1404 | if (isShifted) { |
| 1402 | 1405 | Menu::getInstance()->triggerOption(MenuOption::Mirror); |
| 1403 | 1406 | } else { |
| 1404 | − Menu::getInstance()->triggerOption(MenuOption::FullscreenMirror); | |
| 1407 | + Menu::getInstance()->setIsOptionChecked(MenuOption::FullscreenMirror, !Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror)); | |
| 1408 | + if (!Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror)) { | |
| 1409 | + Menu::getInstance()->setIsOptionChecked(MenuOption::ThirdPerson, true); | |
| 1410 | + } | |
| 1411 | + cameraMenuChanged(); | |
| 1405 | 1412 | } |
| 1406 | 1413 | break; |
| 1407 | 1414 | case Qt::Key_P: |
| 1408 | − Menu::getInstance()->triggerOption(MenuOption::FirstPerson); | |
| 1415 | + Menu::getInstance()->setIsOptionChecked(MenuOption::FirstPerson, !Menu::getInstance()->isOptionChecked(MenuOption::FirstPerson)); | |
| 1416 | + Menu::getInstance()->setIsOptionChecked(MenuOption::ThirdPerson, !Menu::getInstance()->isOptionChecked(MenuOption::FirstPerson)); | |
| 1417 | + cameraMenuChanged(); | |
| 1409 | 1418 | break; |
| 1410 | 1419 | case Qt::Key_Slash: |
| 1411 | 1420 | Menu::getInstance()->triggerOption(MenuOption::Stats); |
| @@ -2358,13 +2367,17 @@ void Application::cameraMenuChanged() { · 946 unmodified lines | ||
| 2358 | 2367 | _myCamera.setMode(CAMERA_MODE_FIRST_PERSON); |
| 2359 | 2368 | _myAvatar->setBoomLength(MyAvatar::ZOOM_MIN); |
| 2360 | 2369 | } |
| 2361 | − } else { | |
| 2370 | + } else if (Menu::getInstance()->isOptionChecked(MenuOption::ThirdPerson)) { | |
| 2362 | 2371 | if (_myCamera.getMode() != CAMERA_MODE_THIRD_PERSON) { |
| 2363 | 2372 | _myCamera.setMode(CAMERA_MODE_THIRD_PERSON); |
| 2364 | 2373 | if (_myAvatar->getBoomLength() == MyAvatar::ZOOM_MIN) { |
| 2365 | 2374 | _myAvatar->setBoomLength(MyAvatar::ZOOM_DEFAULT); |
| 2366 | 2375 | } |
| 2367 | 2376 | } |
| 2377 | + } else if (Menu::getInstance()->isOptionChecked(MenuOption::IndependentMode)) { | |
| 2378 | + if (_myCamera.getMode() != CAMERA_MODE_INDEPENDENT) { | |
| 2379 | + _myCamera.setMode(CAMERA_MODE_INDEPENDENT); | |
| 2380 | + } | |
| 2368 | 2381 | } |
| 2369 | 2382 | } |
| 2370 | 2383 | |
| @@ -2458,18 +2471,22 @@ void Application::update(float deltaTime) { · 87 unmodified lines | ||
| 2458 | 2471 | |
| 2459 | 2472 | // Transfer the user inputs to the driveKeys |
| 2460 | 2473 | _myAvatar->clearDriveKeys(); |
| 2461 | − _myAvatar->setDriveKeys(FWD, _userInputMapper.getActionState(UserInputMapper::LONGITUDINAL_FORWARD)); | |
| 2462 | − _myAvatar->setDriveKeys(BACK, _userInputMapper.getActionState(UserInputMapper::LONGITUDINAL_BACKWARD)); | |
| 2463 | − _myAvatar->setDriveKeys(UP, _userInputMapper.getActionState(UserInputMapper::VERTICAL_UP)); | |
| 2464 | − _myAvatar->setDriveKeys(DOWN, _userInputMapper.getActionState(UserInputMapper::VERTICAL_DOWN)); | |
| 2465 | − _myAvatar->setDriveKeys(LEFT, _userInputMapper.getActionState(UserInputMapper::LATERAL_LEFT)); | |
| 2466 | − _myAvatar->setDriveKeys(RIGHT, _userInputMapper.getActionState(UserInputMapper::LATERAL_RIGHT)); | |
| 2467 | − _myAvatar->setDriveKeys(ROT_UP, _userInputMapper.getActionState(UserInputMapper::PITCH_UP)); | |
| 2468 | − _myAvatar->setDriveKeys(ROT_DOWN, _userInputMapper.getActionState(UserInputMapper::PITCH_DOWN)); | |
| 2469 | − _myAvatar->setDriveKeys(ROT_LEFT, _userInputMapper.getActionState(UserInputMapper::YAW_LEFT)); | |
| 2470 | − _myAvatar->setDriveKeys(ROT_RIGHT, _userInputMapper.getActionState(UserInputMapper::YAW_RIGHT)); | |
| 2471 | − _myAvatar->setDriveKeys(BOOM_IN, _userInputMapper.getActionState(UserInputMapper::BOOM_IN)); | |
| 2472 | − _myAvatar->setDriveKeys(BOOM_OUT, _userInputMapper.getActionState(UserInputMapper::BOOM_OUT)); | |
| 2474 | + if (_myCamera.getMode() != CAMERA_MODE_INDEPENDENT) { | |
| 2475 | + if (!_controllerScriptingInterface.areActionsCaptured()) { | |
| 2476 | + _myAvatar->setDriveKeys(FWD, _userInputMapper.getActionState(UserInputMapper::LONGITUDINAL_FORWARD)); | |
| 2477 | + _myAvatar->setDriveKeys(BACK, _userInputMapper.getActionState(UserInputMapper::LONGITUDINAL_BACKWARD)); | |
| 2478 | + _myAvatar->setDriveKeys(UP, _userInputMapper.getActionState(UserInputMapper::VERTICAL_UP)); | |
| 2479 | + _myAvatar->setDriveKeys(DOWN, _userInputMapper.getActionState(UserInputMapper::VERTICAL_DOWN)); | |
| 2480 | + _myAvatar->setDriveKeys(LEFT, _userInputMapper.getActionState(UserInputMapper::LATERAL_LEFT)); | |
| 2481 | + _myAvatar->setDriveKeys(RIGHT, _userInputMapper.getActionState(UserInputMapper::LATERAL_RIGHT)); | |
| 2482 | + _myAvatar->setDriveKeys(ROT_UP, _userInputMapper.getActionState(UserInputMapper::PITCH_UP)); | |
| 2483 | + _myAvatar->setDriveKeys(ROT_DOWN, _userInputMapper.getActionState(UserInputMapper::PITCH_DOWN)); | |
| 2484 | + _myAvatar->setDriveKeys(ROT_LEFT, _userInputMapper.getActionState(UserInputMapper::YAW_LEFT)); | |
| 2485 | + _myAvatar->setDriveKeys(ROT_RIGHT, _userInputMapper.getActionState(UserInputMapper::YAW_RIGHT)); | |
| 2486 | + } | |
| 2487 | + _myAvatar->setDriveKeys(BOOM_IN, _userInputMapper.getActionState(UserInputMapper::BOOM_IN)); | |
| 2488 | + _myAvatar->setDriveKeys(BOOM_OUT, _userInputMapper.getActionState(UserInputMapper::BOOM_OUT)); | |
| 2489 | + } | |
| 2473 | 2490 | |
| 2474 | 2491 | updateThreads(deltaTime); // If running non-threaded, then give the threads some time to process... |
| 2475 | 2492 | |
| @@ -2486,24 +2503,45 @@ void Application::update(float deltaTime) { · 10 unmodified lines | ||
| 2486 | 2503 | |
| 2487 | 2504 | _entitySimulation.lock(); |
| 2488 | 2505 | _physicsEngine.deleteObjects(_entitySimulation.getObjectsToDelete()); |
| 2506 | + _entitySimulation.unlock(); | |
| 2507 | + | |
| 2508 | + _entities.getTree()->lockForWrite(); | |
| 2509 | + _entitySimulation.lock(); | |
| 2489 | 2510 | _physicsEngine.addObjects(_entitySimulation.getObjectsToAdd()); |
| 2511 | + _entitySimulation.unlock(); | |
| 2512 | + _entities.getTree()->unlock(); | |
| 2513 | + | |
| 2514 | + _entities.getTree()->lockForWrite(); | |
| 2515 | + _entitySimulation.lock(); | |
| 2490 | 2516 | _physicsEngine.changeObjects(_entitySimulation.getObjectsToChange()); |
| 2517 | + _entitySimulation.unlock(); | |
| 2518 | + _entities.getTree()->unlock(); | |
| 2519 | + | |
| 2520 | + _entitySimulation.lock(); | |
| 2491 | 2521 | _entitySimulation.applyActionChanges(); |
| 2492 | 2522 | _entitySimulation.unlock(); |
| 2493 | 2523 | |
| 2524 | + | |
| 2494 | 2525 | AvatarManager* avatarManager = DependencyManager::get<AvatarManager>().data(); |
| 2495 | 2526 | _physicsEngine.deleteObjects(avatarManager->getObjectsToDelete()); |
| 2496 | 2527 | _physicsEngine.addObjects(avatarManager->getObjectsToAdd()); |
| 2497 | 2528 | _physicsEngine.changeObjects(avatarManager->getObjectsToChange()); |
| 2498 | 2529 | |
| 2530 | + _entities.getTree()->lockForWrite(); | |
| 2499 | 2531 | _physicsEngine.stepSimulation(); |
| 2532 | + _entities.getTree()->unlock(); | |
| 2500 | 2533 | |
| 2501 | 2534 | if (_physicsEngine.hasOutgoingChanges()) { |
| 2535 | + _entities.getTree()->lockForWrite(); | |
| 2502 | 2536 | _entitySimulation.lock(); |
| 2503 | 2537 | _entitySimulation.handleOutgoingChanges(_physicsEngine.getOutgoingChanges(), _physicsEngine.getSessionID()); |
| 2504 | 2538 | _entitySimulation.unlock(); |
| 2539 | + _entities.getTree()->unlock(); | |
| 2505 | 2540 | |
| 2541 | + _entities.getTree()->lockForWrite(); | |
| 2506 | 2542 | avatarManager->handleOutgoingChanges(_physicsEngine.getOutgoingChanges()); |
| 2543 | + _entities.getTree()->unlock(); | |
| 2544 | + | |
| 2507 | 2545 | auto collisionEvents = _physicsEngine.getCollisionEvents(); |
| 2508 | 2546 | avatarManager->handleCollisionEvents(collisionEvents); |
| 2509 | 2547 | |
| @@ -3280,6 +3318,11 @@ namespace render { · 770 unmodified lines | ||
| 3280 | 3318 | } |
| 3281 | 3319 | |
| 3282 | 3320 | void Application::displaySide(RenderArgs* renderArgs, Camera& theCamera, bool selfAvatarOnly, bool billboard) { |
| 3321 | + | |
| 3322 | + // FIXME: This preRender call is temporary until we create a separate render::scene for the mirror rendering. | |
| 3323 | + // Then we can move this logic into the Avatar::simulate call. | |
| 3324 | + _myAvatar->preRender(renderArgs); | |
| 3325 | + | |
| 3283 | 3326 | activeRenderingThread = QThread::currentThread(); |
| 3284 | 3327 | PROFILE_RANGE(__FUNCTION__); |
| 3285 | 3328 | PerformanceTimer perfTimer("display"); |
| @@ -3934,6 +3977,7 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri · 648 unmodified lines | ||
| 3934 | 3977 | connect(scriptEngine, SIGNAL(finished(const QString&)), this, SLOT(scriptFinished(const QString&))); |
| 3935 | 3978 | |
| 3936 | 3979 | connect(scriptEngine, SIGNAL(loadScript(const QString&, bool)), this, SLOT(loadScript(const QString&, bool))); |
| 3980 | + connect(scriptEngine, SIGNAL(reloadScript(const QString&, bool)), this, SLOT(reloadScript(const QString&, bool))); | |
| 3937 | 3981 | |
| 3938 | 3982 | scriptEngine->registerGlobalObject("Overlays", &_overlays); |
| 3939 | 3983 | qScriptRegisterMetaType(scriptEngine, OverlayPropertyResultToScriptValue, OverlayPropertyResultFromScriptValue); |
| @@ -4149,7 +4193,7 @@ bool Application::askToLoadScript(const QString& scriptFilenameOrURL) { · 209 unmodified lines | ||
| 4149 | 4193 | } |
| 4150 | 4194 | |
| 4151 | 4195 | ScriptEngine* Application::loadScript(const QString& scriptFilename, bool isUserLoaded, |
| 4152 | − bool loadScriptFromEditor, bool activateMainWindow) { | |
| 4196 | + bool loadScriptFromEditor, bool activateMainWindow, bool reload) { | |
| 4153 | 4197 | |
| 4154 | 4198 | if (isAboutToQuit()) { |
| 4155 | 4199 | return NULL; |
| @@ -4178,7 +4222,7 @@ ScriptEngine* Application::loadScript(const QString& scriptFilename, bool isUser · 22 unmodified lines | ||
| 4178 | 4222 | connect(scriptEngine, &ScriptEngine::errorLoadingScript, this, &Application::handleScriptLoadError); |
| 4179 | 4223 | |
| 4180 | 4224 | // get the script engine object to load the script at the designated script URL |
| 4181 | − scriptEngine->loadURL(scriptUrl); | |
| 4225 | + scriptEngine->loadURL(scriptUrl, reload); | |
| 4182 | 4226 | } |
| 4183 | 4227 | |
| 4184 | 4228 | // restore the main window's active state |
| @@ -4189,6 +4233,10 @@ ScriptEngine* Application::loadScript(const QString& scriptFilename, bool isUser · 4 unmodified lines | ||
| 4189 | 4233 | return scriptEngine; |
| 4190 | 4234 | } |
| 4191 | 4235 | |
| 4236 | +void Application::reloadScript(const QString& scriptName, bool isUserLoaded) { | |
| 4237 | + loadScript(scriptName, isUserLoaded, false, false, true); | |
| 4238 | +} | |
| 4239 | + | |
| 4192 | 4240 | void Application::handleScriptEngineLoaded(const QString& scriptFilename) { |
| 4193 | 4241 | ScriptEngine* scriptEngine = qobject_cast<ScriptEngine*>(sender()); |
| 4194 | 4242 | |
| @@ -4216,14 +4264,25 @@ void Application::scriptFinished(const QString& scriptName) { · 21 unmodified lines | ||
| 4216 | 4264 | } |
| 4217 | 4265 | |
| 4218 | 4266 | void Application::stopAllScripts(bool restart) { |
| 4219 | − // stops all current running scripts | |
| 4267 | + if (restart) { | |
| 4268 | + // Delete all running scripts from cache so that they are re-downloaded when they are restarted | |
| 4269 | + auto scriptCache = DependencyManager::get<ScriptCache>(); | |
| 4270 | + for (QHash<QString, ScriptEngine*>::const_iterator it = _scriptEnginesHash.constBegin(); | |
| 4271 | + it != _scriptEnginesHash.constEnd(); it++) { | |
| 4272 | + if (!it.value()->isFinished()) { | |
| 4273 | + scriptCache->deleteScript(it.key()); | |
| 4274 | + } | |
| 4275 | + } | |
| 4276 | + } | |
| 4277 | + | |
| 4278 | + // Stop and possibly restart all currently running scripts | |
| 4220 | 4279 | for (QHash<QString, ScriptEngine*>::const_iterator it = _scriptEnginesHash.constBegin(); |
| 4221 | 4280 | it != _scriptEnginesHash.constEnd(); it++) { |
| 4222 | 4281 | if (it.value()->isFinished()) { |
| 4223 | 4282 | continue; |
| 4224 | 4283 | } |
| 4225 | 4284 | if (restart && it.value()->isUserLoaded()) { |
| 4226 | − connect(it.value(), SIGNAL(finished(const QString&)), SLOT(loadScript(const QString&))); | |
| 4285 | + connect(it.value(), SIGNAL(finished(const QString&)), SLOT(reloadScript(const QString&))); | |
| 4227 | 4286 | } |
| 4228 | 4287 | it.value()->stop(); |
| 4229 | 4288 | qCDebug(interfaceapp) << "stopping script..." << it.key(); |
| @@ -4231,13 +4290,20 @@ void Application::stopAllScripts(bool restart) { · 1 unmodified line | ||
| 4231 | 4290 | // HACK: ATM scripts cannot set/get their animation priorities, so we clear priorities |
| 4232 | 4291 | // whenever a script stops in case it happened to have been setting joint rotations. |
| 4233 | 4292 | // TODO: expose animation priorities and provide a layered animation control system. |
| 4293 | + _myAvatar->clearJointAnimationPriorities(); | |
| 4234 | 4294 | _myAvatar->clearScriptableSettings(); |
| 4235 | 4295 | } |
| 4236 | 4296 | |
| 4237 | −void Application::stopScript(const QString &scriptName) { | |
| 4297 | +void Application::stopScript(const QString &scriptName, bool restart) { | |
| 4238 | 4298 | const QString& scriptURLString = QUrl(scriptName).toString(); |
| 4239 | 4299 | if (_scriptEnginesHash.contains(scriptURLString)) { |
| 4240 | − _scriptEnginesHash.value(scriptURLString)->stop(); | |
| 4300 | + ScriptEngine* scriptEngine = _scriptEnginesHash[scriptURLString]; | |
| 4301 | + if (restart) { | |
| 4302 | + auto scriptCache = DependencyManager::get<ScriptCache>(); | |
| 4303 | + scriptCache->deleteScript(scriptName); | |
| 4304 | + connect(scriptEngine, SIGNAL(finished(const QString&)), SLOT(reloadScript(const QString&))); | |
| 4305 | + } | |
| 4306 | + scriptEngine->stop(); | |
| 4241 | 4307 | qCDebug(interfaceapp) << "stopping script..." << scriptName; |
| 4242 | 4308 | // HACK: ATM scripts cannot set/get their animation priorities, so we clear priorities |
| 4243 | 4309 | // whenever a script stops in case it happened to have been setting joint rotations. |
| @@ -4253,6 +4319,10 @@ void Application::reloadAllScripts() { · 9 unmodified lines | ||
| 4253 | 4319 | stopAllScripts(true); |
| 4254 | 4320 | } |
| 4255 | 4321 | |
| 4322 | +void Application::reloadOneScript(const QString& scriptName) { | |
| 4323 | + stopScript(scriptName, true); | |
| 4324 | +} | |
| 4325 | + | |
| 4256 | 4326 | void Application::loadDefaultScripts() { |
| 4257 | 4327 | if (!_scriptEnginesHash.contains(DEFAULT_SCRIPTS_JS_URL)) { |
| 4258 | 4328 | loadScript(DEFAULT_SCRIPTS_JS_URL); |