Showing the changes to interface/src/Application.cpp (1 of 5 files). Show all
Unified · Split
| @@ -2268,23 +2268,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 2267 unmodified lines | ||
| 2268 | 2268 | |
| 2269 | 2269 | _snapshotSound = DependencyManager::get<SoundCache>()->getSound(PathUtils::resourcesUrl("sounds/snapshot/snap.wav")); |
| 2270 | 2270 | |
| 2271 | − QVariant testProperty = property(hifi::properties::TEST); | |
| 2272 | − qDebug() << testProperty; | |
| 2273 | − if (testProperty.isValid()) { | |
| 2274 | − const auto testScript = property(hifi::properties::TEST).toUrl(); | |
| 2275 | − // Set last parameter to exit interface when the test script finishes, if so requested | |
| 2276 | − DependencyManager::get<ScriptEngines>()->loadScript(testScript, false, false, false, false, quitWhenFinished); | |
| 2277 | − // This is done so we don't get a "connection time-out" message when we haven't passed in a URL. | |
| 2278 | − if (arguments().contains("--url")) { | |
| 2279 | − auto reply = SandboxUtils::getStatus(); | |
| 2280 | − connect(reply, &QNetworkReply::finished, this, [this, reply] { handleSandboxStatus(reply); }); | |
| 2281 | − } | |
| 2282 | − } else { | |
| 2283 | − PROFILE_RANGE(render, "GetSandboxStatus"); | |
| 2284 | − auto reply = SandboxUtils::getStatus(); | |
| 2285 | − connect(reply, &QNetworkReply::finished, this, [this, reply] { handleSandboxStatus(reply); }); | |
| 2286 | − } | |
| 2287 | − | |
| 2288 | 2271 | // Monitor model assets (e.g., from Clara.io) added to the world that may need resizing. |
| 2289 | 2272 | static const int ADD_ASSET_TO_WORLD_TIMER_INTERVAL_MS = 1000; |
| 2290 | 2273 | _addAssetToWorldResizeTimer.setInterval(ADD_ASSET_TO_WORLD_TIMER_INTERVAL_MS); // 1s, Qt::CoarseTimer acceptable |
| @@ -2348,6 +2331,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 57 unmodified lines | ||
| 2348 | 2331 | DependencyManager::get<TabletScriptingInterface>()->preloadSounds(); |
| 2349 | 2332 | DependencyManager::get<Keyboard>()->createKeyboard(); |
| 2350 | 2333 | |
| 2334 | + connect(DependencyManager::get<Keyboard>().data(), SIGNAL(keyboardRaisedChanged(bool)), this, SLOT(onKeyboardRaisedChanged(bool))); | |
| 2335 | + | |
| 2351 | 2336 | _pendingIdleEvent = false; |
| 2352 | 2337 | _pendingRenderEvent = false; |
| 2353 | 2338 | |
| @@ -5266,8 +5251,7 @@ void Application::pauseUntilLoginDetermined() { · 2912 unmodified lines | ||
| 5266 | 5251 | // save interstitial mode setting until resuming. |
| 5267 | 5252 | _interstitialModeEnabled = nodeList->getDomainHandler().getInterstitialModeEnabled(); |
| 5268 | 5253 | nodeList->getDomainHandler().setInterstitialModeEnabled(false); |
| 5269 | − // disconnect domain handler. | |
| 5270 | − nodeList->getDomainHandler().disconnect(); | |
| 5254 | + | |
| 5271 | 5255 | auto menu = Menu::getInstance(); |
| 5272 | 5256 | menu->getMenu("Edit")->setVisible(false); |
| 5273 | 5257 | menu->getMenu("View")->setVisible(false); |
| @@ -5280,6 +5264,9 @@ void Application::pauseUntilLoginDetermined() { · 6 unmodified lines | ||
| 5280 | 5264 | _previousCameraMode = _myCamera.getMode(); |
| 5281 | 5265 | _myCamera.setMode(CAMERA_MODE_FIRST_PERSON); |
| 5282 | 5266 | cameraModeChanged(); |
| 5267 | + | |
| 5268 | + // disconnect domain handler. | |
| 5269 | + nodeList->getDomainHandler().disconnect(); | |
| 5283 | 5270 | } |
| 5284 | 5271 | |
| 5285 | 5272 | void Application::resumeAfterLoginDialogActionTaken() { |
| @@ -5314,7 +5301,20 @@ void Application::resumeAfterLoginDialogActionTaken() { · 28 unmodified lines | ||
| 5314 | 5301 | if (!accountManager->isLoggedIn()) { |
| 5315 | 5302 | addressManager->goToEntry(); |
| 5316 | 5303 | } else { |
| 5317 | − addressManager->loadSettings(); | |
| 5304 | + QVariant testProperty = property(hifi::properties::TEST); | |
| 5305 | + qDebug() << testProperty; | |
| 5306 | + if (testProperty.isValid()) { | |
| 5307 | + const auto testScript = property(hifi::properties::TEST).toUrl(); | |
| 5308 | + // Set last parameter to exit interface when the test script finishes, if so requested | |
| 5309 | + DependencyManager::get<ScriptEngines>()->loadScript(testScript, false, false, false, false, quitWhenFinished); | |
| 5310 | + // This is done so we don't get a "connection time-out" message when we haven't passed in a URL. | |
| 5311 | + if (arguments().contains("--url")) { | |
| 5312 | + auto reply = SandboxUtils::getStatus(); | |
| 5313 | + connect(reply, &QNetworkReply::finished, this, [this, reply] { handleSandboxStatus(reply); }); | |
| 5314 | + } | |
| 5315 | + } else { | |
| 5316 | + addressManager->loadSettings(); | |
| 5317 | + } | |
| 5318 | 5318 | } |
| 5319 | 5319 | |
| 5320 | 5320 | auto menu = Menu::getInstance(); |
| @@ -5935,10 +5935,6 @@ void Application::update(float deltaTime) { · 614 unmodified lines | ||
| 5935 | 5935 | if (keyboardMousePlugin && keyboardMousePlugin->isActive()) { |
| 5936 | 5936 | keyboardMousePlugin->pluginUpdate(deltaTime, calibrationData); |
| 5937 | 5937 | } |
| 5938 | − if (!_loginDialogOverlayID.isNull()) { | |
| 5939 | − _loginPointerManager.update(); | |
| 5940 | − } | |
| 5941 | − | |
| 5942 | 5938 | // Transfer the user inputs to the driveKeys |
| 5943 | 5939 | // FIXME can we drop drive keys and just have the avatar read the action states directly? |
| 5944 | 5940 | myAvatar->clearDriveKeys(); |
| @@ -6231,6 +6227,36 @@ void Application::update(float deltaTime) { · 286 unmodified lines | ||
| 6231 | 6227 | PerformanceTimer perfTimer("overlays"); |
| 6232 | 6228 | _overlays.update(deltaTime); |
| 6233 | 6229 | } |
| 6230 | + if (!_loginDialogOverlayID.isNull()) { | |
| 6231 | + _loginPointerManager.update(); | |
| 6232 | + } | |
| 6233 | + | |
| 6234 | + if (!_loginDialogOverlayID.isNull()) { | |
| 6235 | + auto overlayPosition = getOverlays().getProperty(_loginDialogOverlayID, "position"); | |
| 6236 | + auto overlayPositionVec = vec3FromVariant(overlayPosition.value); | |
| 6237 | + //auto avatarHeadPosition = myAvatar->getHeadPosition(); | |
| 6238 | + //auto avatarHeadOrientation = myAvatar->getHeadOrientation(); | |
| 6239 | + //auto headLookVec = avatarHeadOrientation * Vectors::FRONT; | |
| 6240 | + //auto overlayToHeadVec = positionVec - avatarHeadPosition; | |
| 6241 | + auto cameraPositionVec = _myCamera.getPosition(); | |
| 6242 | + auto cameraOrientation = _myCamera.getOrientation(); | |
| 6243 | + auto headLookVec = (cameraOrientation * Vectors::FRONT); | |
| 6244 | + auto overlayToHeadVec = overlayPositionVec - cameraPositionVec; | |
| 6245 | + //auto lookAtQuat = glm::inverse(glm::quat_cast(glm::lookAt(positionVec, avatarHeadPosition, avatarHeadOrientation * Vectors::UNIT_Y))); | |
| 6246 | + auto pointAngle = (glm::acos(glm::dot(glm::normalize(overlayToHeadVec), glm::normalize(headLookVec))) * 180.0f / PI); | |
| 6247 | + auto upVec = myAvatar->getWorldOrientation() * Vectors::UNIT_Y; | |
| 6248 | + auto offset = headLookVec * 1.0f; | |
| 6249 | + auto newOverlayPositionVec = (cameraPositionVec + offset) + (upVec * -0.1f); | |
| 6250 | + auto newOverlayOrientation = glm::inverse(glm::quat_cast(glm::lookAt(newOverlayPositionVec, cameraPositionVec, upVec))) * Quaternions::Y_180; | |
| 6251 | + | |
| 6252 | + if (pointAngle > 30.0f) { | |
| 6253 | + QVariantMap properties { | |
| 6254 | + {"position", vec3toVariant(newOverlayPositionVec)}, | |
| 6255 | + {"orientation", quatToVariant(newOverlayOrientation)} | |
| 6256 | + }; | |
| 6257 | + getOverlays().editOverlay(_loginDialogOverlayID, properties); | |
| 6258 | + } | |
| 6259 | + } | |
| 6234 | 6260 | |
| 6235 | 6261 | // Update _viewFrustum with latest camera and view frustum data... |
| 6236 | 6262 | // NOTE: we get this from the view frustum, to make it simpler, since the |
| @@ -6340,26 +6366,6 @@ void Application::update(float deltaTime) { · 103 unmodified lines | ||
| 6340 | 6366 | PerformanceTimer perfTimer("enqueueFrame"); |
| 6341 | 6367 | getMain3DScene()->enqueueFrame(); |
| 6342 | 6368 | } |
| 6343 | − | |
| 6344 | − if (!_loginDialogOverlayID.isNull()) { | |
| 6345 | − auto position = getOverlays().getProperty(_loginDialogOverlayID, "position"); | |
| 6346 | − auto positionVec = vec3FromVariant(position.value); | |
| 6347 | − auto avatarHeadPosition = myAvatar->getHeadPosition(); | |
| 6348 | − auto avatarHeadOrientation = myAvatar->getHeadOrientation(); | |
| 6349 | − auto headLookVec = avatarHeadOrientation * Vectors::FRONT; | |
| 6350 | − auto overlayToHeadVec = positionVec - avatarHeadPosition; | |
| 6351 | − //auto lookAtQuat = glm::inverse(glm::quat_cast(glm::lookAt(positionVec, avatarHeadPosition, avatarHeadOrientation * Vectors::UNIT_Y))); | |
| 6352 | − QVariantMap properties; | |
| 6353 | − if (glm::all(glm::greaterThan(glm::abs(vec3FromVariant(position.value) - avatarHeadPosition), Vectors::ONE * 0.1f))) { | |
| 6354 | − properties["position"] = vec3toVariant(getCamera().getPosition() - glm::vec3(0.0f, -0.1f, 1.0f)); | |
| 6355 | − } | |
| 6356 | − if (fabs(angleBetween(headLookVec, overlayToHeadVec) * 180.0f / PI) > 30.0f) { | |
| 6357 | − properties["orientation"] = quatToVariant(avatarHeadOrientation); | |
| 6358 | − } | |
| 6359 | − if (!properties.isEmpty()) { | |
| 6360 | − getOverlays().editOverlay(_loginDialogOverlayID, properties); | |
| 6361 | − } | |
| 6362 | − } | |
| 6363 | 6369 | } |
| 6364 | 6370 | |
| 6365 | 6371 | void Application::updateRenderArgs(float deltaTime) { |
| @@ -6693,6 +6699,18 @@ void Application::hmdVisibleChanged(bool visible) { · 327 unmodified lines | ||
| 6693 | 6699 | } |
| 6694 | 6700 | } |
| 6695 | 6701 | |
| 6702 | +void Application::onKeyboardRaisedChanged(bool raised) { | |
| 6703 | + auto keyboard = DependencyManager::get<Keyboard>().data(); | |
| 6704 | + auto keyboardParentID = getOverlays().getProperty(keyboard->getAnchorID(), "parentID"); | |
| 6705 | + if (raised && !_loginDialogOverlayID.isNull()) { | |
| 6706 | + QVariantMap properties { | |
| 6707 | + { "parentID", _loginDialogOverlayID }, | |
| 6708 | + { "localPosition", vec3toVariant(glm::vec3(0.0f, 1.0f, -0.2f)) } | |
| 6709 | + }; | |
| 6710 | + getOverlays().editOverlay(keyboard->getAnchorID(), properties); | |
| 6711 | + } | |
| 6712 | +} | |
| 6713 | + | |
| 6696 | 6714 | void Application::updateWindowTitle() const { |
| 6697 | 6715 | |
| 6698 | 6716 | auto nodeList = DependencyManager::get<NodeList>(); |
| @@ -8062,9 +8080,9 @@ void Application::loadDomainConnectionDialog() { · 1363 unmodified lines | ||
| 8062 | 8080 | } |
| 8063 | 8081 | |
| 8064 | 8082 | void Application::toggleLogDialog() { |
| 8065 | − if (getLoginDialogPoppedUp()) { | |
| 8066 | − return; | |
| 8067 | − } | |
| 8083 | + //if (getLoginDialogPoppedUp()) { | |
| 8084 | + // return; | |
| 8085 | + //} | |
| 8068 | 8086 | if (! _logDialog) { |
| 8069 | 8087 | _logDialog = new LogDialog(nullptr, getLogger()); |
| 8070 | 8088 | } |
| @@ -8593,31 +8611,21 @@ void Application::setShowBulletConstraintLimits(bool value) { · 522 unmodified lines | ||
| 8593 | 8611 | } |
| 8594 | 8612 | |
| 8595 | 8613 | void Application::createLoginDialogOverlay() { |
| 8596 | − auto HMD = DependencyManager::get<HMDScriptingInterface>(); | |
| 8597 | − auto headInt = _controllerScriptingInterface->getActions()["Head"].toInt(); | |
| 8598 | − auto headPose = _controllerScriptingInterface->getPoseValue(headInt); | |
| 8599 | − // reference vector for overlay to spawn. | |
| 8600 | − glm::vec3 refOverlayVec; | |
| 8614 | + auto cameraPosition = _myCamera.getPosition(); | |
| 8615 | + auto cameraOrientation = _myCamera.getOrientation(); | |
| 8616 | + auto upVec = getMyAvatar()->getWorldOrientation() * Vectors::UNIT_Y; | |
| 8617 | + auto headLookVec = (cameraOrientation * Vectors::FRONT); | |
| 8601 | 8618 | // DEFAULT_DPI / tablet scale percentage |
| 8602 | 8619 | float overlayDpi = 31.0f / (75.0f / 100.0f); |
| 8603 | − glm::quat refRotation = getMyAvatar()->getWorldOrientation(); | |
| 8604 | − if (headPose.isValid()) { | |
| 8605 | − refOverlayVec = headPose.translation; | |
| 8606 | − } else if (HMD->getPosition() != glm::vec3()) { | |
| 8607 | − refOverlayVec = HMD->getPosition(); | |
| 8608 | − } else { | |
| 8609 | − refOverlayVec = getMyAvatar()->getHeadPosition(); | |
| 8610 | − } | |
| 8611 | − //for non-play area position. | |
| 8612 | − refOverlayVec -= glm::vec3(0.0f, -0.1f, 1.0f); | |
| 8620 | + auto offset = headLookVec * 1.0f; | |
| 8621 | + auto overlayPosition = (cameraPosition + offset) + (upVec * -0.1f); | |
| 8613 | 8622 | |
| 8614 | − auto playArea = _displayPlugin->getPlayAreaRect(); | |
| 8615 | 8623 | const glm::vec2 LOGIN_OVERLAY_DIMENSIONS{ 0.5f, 0.5f }; |
| 8616 | 8624 | QVariantMap overlayProperties = { |
| 8617 | 8625 | { "name", "LoginDialogOverlay" }, |
| 8618 | 8626 | { "url", OVERLAY_LOGIN_DIALOG_URL }, |
| 8619 | − { "position", vec3toVariant(refOverlayVec) }, | |
| 8620 | − { "orientation", quatToVariant(refRotation) }, | |
| 8627 | + { "position", vec3toVariant(overlayPosition) }, | |
| 8628 | + { "orientation", quatToVariant(cameraOrientation) }, | |
| 8621 | 8629 | { "isSolid", true }, |
| 8622 | 8630 | { "grabbable", false }, |
| 8623 | 8631 | { "ignorePickIntersection", false }, |
| @@ -8636,7 +8644,12 @@ void Application::createLoginDialogOverlay() { · 12 unmodified lines | ||
| 8636 | 8644 | void Application::onDismissedLoginDialog() { |
| 8637 | 8645 | _loginDialogPoppedUp = false; |
| 8638 | 8646 | loginDialogPoppedUp.set(false); |
| 8647 | + auto keyboard = DependencyManager::get<Keyboard>().data(); | |
| 8639 | 8648 | if (!_loginDialogOverlayID.isNull()) { |
| 8649 | + QVariantMap properties{ | |
| 8650 | + { "parentID", QUuid() } | |
| 8651 | + }; | |
| 8652 | + getOverlays().editOverlay(keyboard->getAnchorID(), properties); | |
| 8640 | 8653 | // deleting overlay. |
| 8641 | 8654 | qDebug() << "Deleting overlay"; |
| 8642 | 8655 | getOverlays().deleteOverlay(_loginDialogOverlayID); |