History

got the overlay to start recentering

Wayne Chen committed 8 years ago

Commit 02248e71 parent bf731f35 files · +86 −66Browse files

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

Unified · Split

interface/src/Application.cpp+78−65
@@ -2268,23 +2268,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 2267 unmodified lines
22682268
22692269 _snapshotSound = DependencyManager::get<SoundCache>()->getSound(PathUtils::resourcesUrl("sounds/snapshot/snap.wav"));
22702270
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−
22882271 // Monitor model assets (e.g., from Clara.io) added to the world that may need resizing.
22892272 static const int ADD_ASSET_TO_WORLD_TIMER_INTERVAL_MS = 1000;
22902273 _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
23482331 DependencyManager::get<TabletScriptingInterface>()->preloadSounds();
23492332 DependencyManager::get<Keyboard>()->createKeyboard();
23502333
2334+ connect(DependencyManager::get<Keyboard>().data(), SIGNAL(keyboardRaisedChanged(bool)), this, SLOT(onKeyboardRaisedChanged(bool)));
2335+
23512336 _pendingIdleEvent = false;
23522337 _pendingRenderEvent = false;
23532338
@@ -5266,8 +5251,7 @@ void Application::pauseUntilLoginDetermined() { · 2912 unmodified lines
52665251 // save interstitial mode setting until resuming.
52675252 _interstitialModeEnabled = nodeList->getDomainHandler().getInterstitialModeEnabled();
52685253 nodeList->getDomainHandler().setInterstitialModeEnabled(false);
5269− // disconnect domain handler.
5270− nodeList->getDomainHandler().disconnect();
5254+
52715255 auto menu = Menu::getInstance();
52725256 menu->getMenu("Edit")->setVisible(false);
52735257 menu->getMenu("View")->setVisible(false);
@@ -5280,6 +5264,9 @@ void Application::pauseUntilLoginDetermined() { · 6 unmodified lines
52805264 _previousCameraMode = _myCamera.getMode();
52815265 _myCamera.setMode(CAMERA_MODE_FIRST_PERSON);
52825266 cameraModeChanged();
5267+
5268+ // disconnect domain handler.
5269+ nodeList->getDomainHandler().disconnect();
52835270 }
52845271
52855272 void Application::resumeAfterLoginDialogActionTaken() {
@@ -5314,7 +5301,20 @@ void Application::resumeAfterLoginDialogActionTaken() { · 28 unmodified lines
53145301 if (!accountManager->isLoggedIn()) {
53155302 addressManager->goToEntry();
53165303 } 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+ }
53185318 }
53195319
53205320 auto menu = Menu::getInstance();
@@ -5935,10 +5935,6 @@ void Application::update(float deltaTime) { · 614 unmodified lines
59355935 if (keyboardMousePlugin && keyboardMousePlugin->isActive()) {
59365936 keyboardMousePlugin->pluginUpdate(deltaTime, calibrationData);
59375937 }
5938− if (!_loginDialogOverlayID.isNull()) {
5939− _loginPointerManager.update();
5940− }
5941−
59425938 // Transfer the user inputs to the driveKeys
59435939 // FIXME can we drop drive keys and just have the avatar read the action states directly?
59445940 myAvatar->clearDriveKeys();
@@ -6231,6 +6227,36 @@ void Application::update(float deltaTime) { · 286 unmodified lines
62316227 PerformanceTimer perfTimer("overlays");
62326228 _overlays.update(deltaTime);
62336229 }
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+ }
62346260
62356261 // Update _viewFrustum with latest camera and view frustum data...
62366262 // 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
63406366 PerformanceTimer perfTimer("enqueueFrame");
63416367 getMain3DScene()->enqueueFrame();
63426368 }
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− }
63636369 }
63646370
63656371 void Application::updateRenderArgs(float deltaTime) {
@@ -6693,6 +6699,18 @@ void Application::hmdVisibleChanged(bool visible) { · 327 unmodified lines
66936699 }
66946700 }
66956701
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+
66966714 void Application::updateWindowTitle() const {
66976715
66986716 auto nodeList = DependencyManager::get<NodeList>();
@@ -8062,9 +8080,9 @@ void Application::loadDomainConnectionDialog() { · 1363 unmodified lines
80628080 }
80638081
80648082 void Application::toggleLogDialog() {
8065− if (getLoginDialogPoppedUp()) {
8066− return;
8067− }
8083+ //if (getLoginDialogPoppedUp()) {
8084+ // return;
8085+ //}
80688086 if (! _logDialog) {
80698087 _logDialog = new LogDialog(nullptr, getLogger());
80708088 }
@@ -8593,31 +8611,21 @@ void Application::setShowBulletConstraintLimits(bool value) { · 522 unmodified lines
85938611 }
85948612
85958613 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);
86018618 // DEFAULT_DPI / tablet scale percentage
86028619 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);
86138622
8614− auto playArea = _displayPlugin->getPlayAreaRect();
86158623 const glm::vec2 LOGIN_OVERLAY_DIMENSIONS{ 0.5f, 0.5f };
86168624 QVariantMap overlayProperties = {
86178625 { "name", "LoginDialogOverlay" },
86188626 { "url", OVERLAY_LOGIN_DIALOG_URL },
8619− { "position", vec3toVariant(refOverlayVec) },
8620− { "orientation", quatToVariant(refRotation) },
8627+ { "position", vec3toVariant(overlayPosition) },
8628+ { "orientation", quatToVariant(cameraOrientation) },
86218629 { "isSolid", true },
86228630 { "grabbable", false },
86238631 { "ignorePickIntersection", false },
@@ -8636,7 +8644,12 @@ void Application::createLoginDialogOverlay() { · 12 unmodified lines
86368644 void Application::onDismissedLoginDialog() {
86378645 _loginDialogPoppedUp = false;
86388646 loginDialogPoppedUp.set(false);
8647+ auto keyboard = DependencyManager::get<Keyboard>().data();
86398648 if (!_loginDialogOverlayID.isNull()) {
8649+ QVariantMap properties{
8650+ { "parentID", QUuid() }
8651+ };
8652+ getOverlays().editOverlay(keyboard->getAnchorID(), properties);
86408653 // deleting overlay.
86418654 qDebug() << "Deleting overlay";
86428655 getOverlays().deleteOverlay(_loginDialogOverlayID);

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