mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 16:41:02 +02:00
handle case where a location should be faced
This commit is contained in:
parent
0033dfe5af
commit
866f2005bd
3 changed files with 8 additions and 5 deletions
|
@ -1783,6 +1783,7 @@ void MyAvatar::goToLocation(const glm::vec3& newPosition,
|
||||||
glm::quat quatOrientation = newOrientation;
|
glm::quat quatOrientation = newOrientation;
|
||||||
|
|
||||||
if (shouldFaceLocation) {
|
if (shouldFaceLocation) {
|
||||||
|
|
||||||
quatOrientation = newOrientation * glm::angleAxis(PI, glm::vec3(0.0f, 1.0f, 0.0f));
|
quatOrientation = newOrientation * glm::angleAxis(PI, glm::vec3(0.0f, 1.0f, 0.0f));
|
||||||
|
|
||||||
// move the user a couple units away
|
// move the user a couple units away
|
||||||
|
|
|
@ -132,9 +132,11 @@ void AddressManager::handleAPIResponse(const QJsonObject &jsonObject) {
|
||||||
returnedPath = domainObject[LOCATION_KEY].toObject()[LOCATION_PATH_KEY].toString();
|
returnedPath = domainObject[LOCATION_KEY].toObject()[LOCATION_PATH_KEY].toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool shouldFaceViewpoint = dataObject.contains(ADDRESS_API_ONLINE_KEY);
|
||||||
|
|
||||||
if (!returnedPath.isEmpty()) {
|
if (!returnedPath.isEmpty()) {
|
||||||
// try to parse this returned path as a viewpoint, that's the only thing it could be for now
|
// try to parse this returned path as a viewpoint, that's the only thing it could be for now
|
||||||
if (!handleRelativeViewpoint(returnedPath)) {
|
if (!handleRelativeViewpoint(returnedPath, shouldFaceViewpoint)) {
|
||||||
qDebug() << "Received a location path that was could not be handled as a viewpoint -" << returnedPath;
|
qDebug() << "Received a location path that was could not be handled as a viewpoint -" << returnedPath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -191,7 +193,7 @@ bool AddressManager::handleNetworkAddress(const QString& lookupString) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AddressManager::handleRelativeViewpoint(const QString& lookupString) {
|
bool AddressManager::handleRelativeViewpoint(const QString& lookupString, bool shouldFace) {
|
||||||
const QString FLOAT_REGEX_STRING = "([-+]?[0-9]*\\.?[0-9]+(?:[eE][-+]?[0-9]+)?)";
|
const QString FLOAT_REGEX_STRING = "([-+]?[0-9]*\\.?[0-9]+(?:[eE][-+]?[0-9]+)?)";
|
||||||
const QString SPACED_COMMA_REGEX_STRING = "\\s*,\\s*";
|
const QString SPACED_COMMA_REGEX_STRING = "\\s*,\\s*";
|
||||||
const QString POSITION_REGEX_STRING = QString("\\/") + FLOAT_REGEX_STRING + SPACED_COMMA_REGEX_STRING +
|
const QString POSITION_REGEX_STRING = QString("\\/") + FLOAT_REGEX_STRING + SPACED_COMMA_REGEX_STRING +
|
||||||
|
@ -224,14 +226,14 @@ bool AddressManager::handleRelativeViewpoint(const QString& lookupString) {
|
||||||
|
|
||||||
if (!isNaN(newOrientation.x) && !isNaN(newOrientation.y) && !isNaN(newOrientation.z)
|
if (!isNaN(newOrientation.x) && !isNaN(newOrientation.y) && !isNaN(newOrientation.z)
|
||||||
&& !isNaN(newOrientation.w)) {
|
&& !isNaN(newOrientation.w)) {
|
||||||
emit locationChangeRequired(newPosition, true, newOrientation, false);
|
emit locationChangeRequired(newPosition, true, newOrientation, shouldFace);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "Orientation parsed from lookup string is invalid. Will not use for location change.";
|
qDebug() << "Orientation parsed from lookup string is invalid. Will not use for location change.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
emit locationChangeRequired(newPosition, false, newOrientation, false);
|
emit locationChangeRequired(newPosition, false, newOrientation, shouldFace);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "Could not jump to position from lookup string because it has an invalid value.";
|
qDebug() << "Could not jump to position from lookup string because it has an invalid value.";
|
||||||
|
|
|
@ -49,7 +49,7 @@ private:
|
||||||
bool handleUrl(const QUrl& lookupUrl);
|
bool handleUrl(const QUrl& lookupUrl);
|
||||||
|
|
||||||
bool handleNetworkAddress(const QString& lookupString);
|
bool handleNetworkAddress(const QString& lookupString);
|
||||||
bool handleRelativeViewpoint(const QString& pathSubsection);
|
bool handleRelativeViewpoint(const QString& pathSubsection, bool shouldFace = false);
|
||||||
bool handleUsername(const QString& lookupString);
|
bool handleUsername(const QString& lookupString);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue