mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 19:36:45 +02:00
got the overlay to start recentering
This commit is contained in:
parent
bf731f32b9
commit
02248e77e4
5 changed files with 86 additions and 66 deletions
|
@ -2268,23 +2268,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
||||||
|
|
||||||
_snapshotSound = DependencyManager::get<SoundCache>()->getSound(PathUtils::resourcesUrl("sounds/snapshot/snap.wav"));
|
_snapshotSound = DependencyManager::get<SoundCache>()->getSound(PathUtils::resourcesUrl("sounds/snapshot/snap.wav"));
|
||||||
|
|
||||||
QVariant testProperty = property(hifi::properties::TEST);
|
|
||||||
qDebug() << testProperty;
|
|
||||||
if (testProperty.isValid()) {
|
|
||||||
const auto testScript = property(hifi::properties::TEST).toUrl();
|
|
||||||
// Set last parameter to exit interface when the test script finishes, if so requested
|
|
||||||
DependencyManager::get<ScriptEngines>()->loadScript(testScript, false, false, false, false, quitWhenFinished);
|
|
||||||
// This is done so we don't get a "connection time-out" message when we haven't passed in a URL.
|
|
||||||
if (arguments().contains("--url")) {
|
|
||||||
auto reply = SandboxUtils::getStatus();
|
|
||||||
connect(reply, &QNetworkReply::finished, this, [this, reply] { handleSandboxStatus(reply); });
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
PROFILE_RANGE(render, "GetSandboxStatus");
|
|
||||||
auto reply = SandboxUtils::getStatus();
|
|
||||||
connect(reply, &QNetworkReply::finished, this, [this, reply] { handleSandboxStatus(reply); });
|
|
||||||
}
|
|
||||||
|
|
||||||
// Monitor model assets (e.g., from Clara.io) added to the world that may need resizing.
|
// Monitor model assets (e.g., from Clara.io) added to the world that may need resizing.
|
||||||
static const int ADD_ASSET_TO_WORLD_TIMER_INTERVAL_MS = 1000;
|
static const int ADD_ASSET_TO_WORLD_TIMER_INTERVAL_MS = 1000;
|
||||||
_addAssetToWorldResizeTimer.setInterval(ADD_ASSET_TO_WORLD_TIMER_INTERVAL_MS); // 1s, Qt::CoarseTimer acceptable
|
_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
|
||||||
DependencyManager::get<TabletScriptingInterface>()->preloadSounds();
|
DependencyManager::get<TabletScriptingInterface>()->preloadSounds();
|
||||||
DependencyManager::get<Keyboard>()->createKeyboard();
|
DependencyManager::get<Keyboard>()->createKeyboard();
|
||||||
|
|
||||||
|
connect(DependencyManager::get<Keyboard>().data(), SIGNAL(keyboardRaisedChanged(bool)), this, SLOT(onKeyboardRaisedChanged(bool)));
|
||||||
|
|
||||||
_pendingIdleEvent = false;
|
_pendingIdleEvent = false;
|
||||||
_pendingRenderEvent = false;
|
_pendingRenderEvent = false;
|
||||||
|
|
||||||
|
@ -5266,8 +5251,7 @@ void Application::pauseUntilLoginDetermined() {
|
||||||
// save interstitial mode setting until resuming.
|
// save interstitial mode setting until resuming.
|
||||||
_interstitialModeEnabled = nodeList->getDomainHandler().getInterstitialModeEnabled();
|
_interstitialModeEnabled = nodeList->getDomainHandler().getInterstitialModeEnabled();
|
||||||
nodeList->getDomainHandler().setInterstitialModeEnabled(false);
|
nodeList->getDomainHandler().setInterstitialModeEnabled(false);
|
||||||
// disconnect domain handler.
|
|
||||||
nodeList->getDomainHandler().disconnect();
|
|
||||||
auto menu = Menu::getInstance();
|
auto menu = Menu::getInstance();
|
||||||
menu->getMenu("Edit")->setVisible(false);
|
menu->getMenu("Edit")->setVisible(false);
|
||||||
menu->getMenu("View")->setVisible(false);
|
menu->getMenu("View")->setVisible(false);
|
||||||
|
@ -5280,6 +5264,9 @@ void Application::pauseUntilLoginDetermined() {
|
||||||
_previousCameraMode = _myCamera.getMode();
|
_previousCameraMode = _myCamera.getMode();
|
||||||
_myCamera.setMode(CAMERA_MODE_FIRST_PERSON);
|
_myCamera.setMode(CAMERA_MODE_FIRST_PERSON);
|
||||||
cameraModeChanged();
|
cameraModeChanged();
|
||||||
|
|
||||||
|
// disconnect domain handler.
|
||||||
|
nodeList->getDomainHandler().disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::resumeAfterLoginDialogActionTaken() {
|
void Application::resumeAfterLoginDialogActionTaken() {
|
||||||
|
@ -5314,7 +5301,20 @@ void Application::resumeAfterLoginDialogActionTaken() {
|
||||||
if (!accountManager->isLoggedIn()) {
|
if (!accountManager->isLoggedIn()) {
|
||||||
addressManager->goToEntry();
|
addressManager->goToEntry();
|
||||||
} else {
|
} else {
|
||||||
addressManager->loadSettings();
|
QVariant testProperty = property(hifi::properties::TEST);
|
||||||
|
qDebug() << testProperty;
|
||||||
|
if (testProperty.isValid()) {
|
||||||
|
const auto testScript = property(hifi::properties::TEST).toUrl();
|
||||||
|
// Set last parameter to exit interface when the test script finishes, if so requested
|
||||||
|
DependencyManager::get<ScriptEngines>()->loadScript(testScript, false, false, false, false, quitWhenFinished);
|
||||||
|
// This is done so we don't get a "connection time-out" message when we haven't passed in a URL.
|
||||||
|
if (arguments().contains("--url")) {
|
||||||
|
auto reply = SandboxUtils::getStatus();
|
||||||
|
connect(reply, &QNetworkReply::finished, this, [this, reply] { handleSandboxStatus(reply); });
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
addressManager->loadSettings();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto menu = Menu::getInstance();
|
auto menu = Menu::getInstance();
|
||||||
|
@ -5935,10 +5935,6 @@ void Application::update(float deltaTime) {
|
||||||
if (keyboardMousePlugin && keyboardMousePlugin->isActive()) {
|
if (keyboardMousePlugin && keyboardMousePlugin->isActive()) {
|
||||||
keyboardMousePlugin->pluginUpdate(deltaTime, calibrationData);
|
keyboardMousePlugin->pluginUpdate(deltaTime, calibrationData);
|
||||||
}
|
}
|
||||||
if (!_loginDialogOverlayID.isNull()) {
|
|
||||||
_loginPointerManager.update();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Transfer the user inputs to the driveKeys
|
// Transfer the user inputs to the driveKeys
|
||||||
// FIXME can we drop drive keys and just have the avatar read the action states directly?
|
// FIXME can we drop drive keys and just have the avatar read the action states directly?
|
||||||
myAvatar->clearDriveKeys();
|
myAvatar->clearDriveKeys();
|
||||||
|
@ -6231,6 +6227,36 @@ void Application::update(float deltaTime) {
|
||||||
PerformanceTimer perfTimer("overlays");
|
PerformanceTimer perfTimer("overlays");
|
||||||
_overlays.update(deltaTime);
|
_overlays.update(deltaTime);
|
||||||
}
|
}
|
||||||
|
if (!_loginDialogOverlayID.isNull()) {
|
||||||
|
_loginPointerManager.update();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!_loginDialogOverlayID.isNull()) {
|
||||||
|
auto overlayPosition = getOverlays().getProperty(_loginDialogOverlayID, "position");
|
||||||
|
auto overlayPositionVec = vec3FromVariant(overlayPosition.value);
|
||||||
|
//auto avatarHeadPosition = myAvatar->getHeadPosition();
|
||||||
|
//auto avatarHeadOrientation = myAvatar->getHeadOrientation();
|
||||||
|
//auto headLookVec = avatarHeadOrientation * Vectors::FRONT;
|
||||||
|
//auto overlayToHeadVec = positionVec - avatarHeadPosition;
|
||||||
|
auto cameraPositionVec = _myCamera.getPosition();
|
||||||
|
auto cameraOrientation = _myCamera.getOrientation();
|
||||||
|
auto headLookVec = (cameraOrientation * Vectors::FRONT);
|
||||||
|
auto overlayToHeadVec = overlayPositionVec - cameraPositionVec;
|
||||||
|
//auto lookAtQuat = glm::inverse(glm::quat_cast(glm::lookAt(positionVec, avatarHeadPosition, avatarHeadOrientation * Vectors::UNIT_Y)));
|
||||||
|
auto pointAngle = (glm::acos(glm::dot(glm::normalize(overlayToHeadVec), glm::normalize(headLookVec))) * 180.0f / PI);
|
||||||
|
auto upVec = myAvatar->getWorldOrientation() * Vectors::UNIT_Y;
|
||||||
|
auto offset = headLookVec * 1.0f;
|
||||||
|
auto newOverlayPositionVec = (cameraPositionVec + offset) + (upVec * -0.1f);
|
||||||
|
auto newOverlayOrientation = glm::inverse(glm::quat_cast(glm::lookAt(newOverlayPositionVec, cameraPositionVec, upVec))) * Quaternions::Y_180;
|
||||||
|
|
||||||
|
if (pointAngle > 30.0f) {
|
||||||
|
QVariantMap properties {
|
||||||
|
{"position", vec3toVariant(newOverlayPositionVec)},
|
||||||
|
{"orientation", quatToVariant(newOverlayOrientation)}
|
||||||
|
};
|
||||||
|
getOverlays().editOverlay(_loginDialogOverlayID, properties);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Update _viewFrustum with latest camera and view frustum data...
|
// Update _viewFrustum with latest camera and view frustum data...
|
||||||
// NOTE: we get this from the view frustum, to make it simpler, since the
|
// NOTE: we get this from the view frustum, to make it simpler, since the
|
||||||
|
@ -6340,26 +6366,6 @@ void Application::update(float deltaTime) {
|
||||||
PerformanceTimer perfTimer("enqueueFrame");
|
PerformanceTimer perfTimer("enqueueFrame");
|
||||||
getMain3DScene()->enqueueFrame();
|
getMain3DScene()->enqueueFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_loginDialogOverlayID.isNull()) {
|
|
||||||
auto position = getOverlays().getProperty(_loginDialogOverlayID, "position");
|
|
||||||
auto positionVec = vec3FromVariant(position.value);
|
|
||||||
auto avatarHeadPosition = myAvatar->getHeadPosition();
|
|
||||||
auto avatarHeadOrientation = myAvatar->getHeadOrientation();
|
|
||||||
auto headLookVec = avatarHeadOrientation * Vectors::FRONT;
|
|
||||||
auto overlayToHeadVec = positionVec - avatarHeadPosition;
|
|
||||||
//auto lookAtQuat = glm::inverse(glm::quat_cast(glm::lookAt(positionVec, avatarHeadPosition, avatarHeadOrientation * Vectors::UNIT_Y)));
|
|
||||||
QVariantMap properties;
|
|
||||||
if (glm::all(glm::greaterThan(glm::abs(vec3FromVariant(position.value) - avatarHeadPosition), Vectors::ONE * 0.1f))) {
|
|
||||||
properties["position"] = vec3toVariant(getCamera().getPosition() - glm::vec3(0.0f, -0.1f, 1.0f));
|
|
||||||
}
|
|
||||||
if (fabs(angleBetween(headLookVec, overlayToHeadVec) * 180.0f / PI) > 30.0f) {
|
|
||||||
properties["orientation"] = quatToVariant(avatarHeadOrientation);
|
|
||||||
}
|
|
||||||
if (!properties.isEmpty()) {
|
|
||||||
getOverlays().editOverlay(_loginDialogOverlayID, properties);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::updateRenderArgs(float deltaTime) {
|
void Application::updateRenderArgs(float deltaTime) {
|
||||||
|
@ -6693,6 +6699,18 @@ void Application::hmdVisibleChanged(bool visible) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Application::onKeyboardRaisedChanged(bool raised) {
|
||||||
|
auto keyboard = DependencyManager::get<Keyboard>().data();
|
||||||
|
auto keyboardParentID = getOverlays().getProperty(keyboard->getAnchorID(), "parentID");
|
||||||
|
if (raised && !_loginDialogOverlayID.isNull()) {
|
||||||
|
QVariantMap properties {
|
||||||
|
{ "parentID", _loginDialogOverlayID },
|
||||||
|
{ "localPosition", vec3toVariant(glm::vec3(0.0f, 1.0f, -0.2f)) }
|
||||||
|
};
|
||||||
|
getOverlays().editOverlay(keyboard->getAnchorID(), properties);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Application::updateWindowTitle() const {
|
void Application::updateWindowTitle() const {
|
||||||
|
|
||||||
auto nodeList = DependencyManager::get<NodeList>();
|
auto nodeList = DependencyManager::get<NodeList>();
|
||||||
|
@ -8062,9 +8080,9 @@ void Application::loadDomainConnectionDialog() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::toggleLogDialog() {
|
void Application::toggleLogDialog() {
|
||||||
if (getLoginDialogPoppedUp()) {
|
//if (getLoginDialogPoppedUp()) {
|
||||||
return;
|
// return;
|
||||||
}
|
//}
|
||||||
if (! _logDialog) {
|
if (! _logDialog) {
|
||||||
_logDialog = new LogDialog(nullptr, getLogger());
|
_logDialog = new LogDialog(nullptr, getLogger());
|
||||||
}
|
}
|
||||||
|
@ -8593,31 +8611,21 @@ void Application::setShowBulletConstraintLimits(bool value) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::createLoginDialogOverlay() {
|
void Application::createLoginDialogOverlay() {
|
||||||
auto HMD = DependencyManager::get<HMDScriptingInterface>();
|
auto cameraPosition = _myCamera.getPosition();
|
||||||
auto headInt = _controllerScriptingInterface->getActions()["Head"].toInt();
|
auto cameraOrientation = _myCamera.getOrientation();
|
||||||
auto headPose = _controllerScriptingInterface->getPoseValue(headInt);
|
auto upVec = getMyAvatar()->getWorldOrientation() * Vectors::UNIT_Y;
|
||||||
// reference vector for overlay to spawn.
|
auto headLookVec = (cameraOrientation * Vectors::FRONT);
|
||||||
glm::vec3 refOverlayVec;
|
|
||||||
// DEFAULT_DPI / tablet scale percentage
|
// DEFAULT_DPI / tablet scale percentage
|
||||||
float overlayDpi = 31.0f / (75.0f / 100.0f);
|
float overlayDpi = 31.0f / (75.0f / 100.0f);
|
||||||
glm::quat refRotation = getMyAvatar()->getWorldOrientation();
|
auto offset = headLookVec * 1.0f;
|
||||||
if (headPose.isValid()) {
|
auto overlayPosition = (cameraPosition + offset) + (upVec * -0.1f);
|
||||||
refOverlayVec = headPose.translation;
|
|
||||||
} else if (HMD->getPosition() != glm::vec3()) {
|
|
||||||
refOverlayVec = HMD->getPosition();
|
|
||||||
} else {
|
|
||||||
refOverlayVec = getMyAvatar()->getHeadPosition();
|
|
||||||
}
|
|
||||||
//for non-play area position.
|
|
||||||
refOverlayVec -= glm::vec3(0.0f, -0.1f, 1.0f);
|
|
||||||
|
|
||||||
auto playArea = _displayPlugin->getPlayAreaRect();
|
|
||||||
const glm::vec2 LOGIN_OVERLAY_DIMENSIONS{ 0.5f, 0.5f };
|
const glm::vec2 LOGIN_OVERLAY_DIMENSIONS{ 0.5f, 0.5f };
|
||||||
QVariantMap overlayProperties = {
|
QVariantMap overlayProperties = {
|
||||||
{ "name", "LoginDialogOverlay" },
|
{ "name", "LoginDialogOverlay" },
|
||||||
{ "url", OVERLAY_LOGIN_DIALOG_URL },
|
{ "url", OVERLAY_LOGIN_DIALOG_URL },
|
||||||
{ "position", vec3toVariant(refOverlayVec) },
|
{ "position", vec3toVariant(overlayPosition) },
|
||||||
{ "orientation", quatToVariant(refRotation) },
|
{ "orientation", quatToVariant(cameraOrientation) },
|
||||||
{ "isSolid", true },
|
{ "isSolid", true },
|
||||||
{ "grabbable", false },
|
{ "grabbable", false },
|
||||||
{ "ignorePickIntersection", false },
|
{ "ignorePickIntersection", false },
|
||||||
|
@ -8636,7 +8644,12 @@ void Application::createLoginDialogOverlay() {
|
||||||
void Application::onDismissedLoginDialog() {
|
void Application::onDismissedLoginDialog() {
|
||||||
_loginDialogPoppedUp = false;
|
_loginDialogPoppedUp = false;
|
||||||
loginDialogPoppedUp.set(false);
|
loginDialogPoppedUp.set(false);
|
||||||
|
auto keyboard = DependencyManager::get<Keyboard>().data();
|
||||||
if (!_loginDialogOverlayID.isNull()) {
|
if (!_loginDialogOverlayID.isNull()) {
|
||||||
|
QVariantMap properties{
|
||||||
|
{ "parentID", QUuid() }
|
||||||
|
};
|
||||||
|
getOverlays().editOverlay(keyboard->getAnchorID(), properties);
|
||||||
// deleting overlay.
|
// deleting overlay.
|
||||||
qDebug() << "Deleting overlay";
|
qDebug() << "Deleting overlay";
|
||||||
getOverlays().deleteOverlay(_loginDialogOverlayID);
|
getOverlays().deleteOverlay(_loginDialogOverlayID);
|
||||||
|
|
|
@ -392,6 +392,8 @@ public slots:
|
||||||
|
|
||||||
void hmdVisibleChanged(bool visible);
|
void hmdVisibleChanged(bool visible);
|
||||||
|
|
||||||
|
void onKeyboardRaisedChanged(bool raised);
|
||||||
|
|
||||||
#if (PR_BUILD || DEV_BUILD)
|
#if (PR_BUILD || DEV_BUILD)
|
||||||
void sendWrongProtocolVersionsSignature(bool checked) { ::sendWrongProtocolVersionsSignature(checked); }
|
void sendWrongProtocolVersionsSignature(bool checked) { ::sendWrongProtocolVersionsSignature(checked); }
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -292,6 +292,7 @@ void Keyboard::setRaised(bool raised) {
|
||||||
_capsEnabled = false;
|
_capsEnabled = false;
|
||||||
_typedCharacters.clear();
|
_typedCharacters.clear();
|
||||||
});
|
});
|
||||||
|
emit keyboardRaisedChanged(raised);
|
||||||
|
|
||||||
updateTextDisplay();
|
updateTextDisplay();
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,6 +101,9 @@ public:
|
||||||
QVector<OverlayID> getKeysID();
|
QVector<OverlayID> getKeysID();
|
||||||
OverlayID getAnchorID();
|
OverlayID getAnchorID();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void keyboardRaisedChanged(bool raised);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void handleTriggerBegin(const OverlayID& overlayID, const PointerEvent& event);
|
void handleTriggerBegin(const OverlayID& overlayID, const PointerEvent& event);
|
||||||
void handleTriggerEnd(const OverlayID& overlayID, const PointerEvent& event);
|
void handleTriggerEnd(const OverlayID& overlayID, const PointerEvent& event);
|
||||||
|
|
|
@ -20,7 +20,8 @@
|
||||||
|
|
||||||
void StandAloneJSConsole::toggleConsole() {
|
void StandAloneJSConsole::toggleConsole() {
|
||||||
QMainWindow* mainWindow = qApp->getWindow();
|
QMainWindow* mainWindow = qApp->getWindow();
|
||||||
if (!_jsConsole && !qApp->getLoginDialogPoppedUp()) {
|
//if (!_jsConsole && !qApp->getLoginDialogPoppedUp()) {
|
||||||
|
if (!_jsConsole) {
|
||||||
QDialog* dialog = new QDialog(mainWindow, Qt::WindowStaysOnTopHint);
|
QDialog* dialog = new QDialog(mainWindow, Qt::WindowStaysOnTopHint);
|
||||||
QVBoxLayout* layout = new QVBoxLayout(dialog);
|
QVBoxLayout* layout = new QVBoxLayout(dialog);
|
||||||
dialog->setLayout(layout);
|
dialog->setLayout(layout);
|
||||||
|
|
Loading…
Reference in a new issue