Fixed avatar rotation upon teleportation using Pal

Added "VisitUserFromPAL" to LookupTrigger enum
and bool "shouldMatchOrientation" to goToUser()
This commit is contained in:
Gerard Maguire 2017-08-08 05:08:20 +01:00
parent bec7f7c644
commit 6f81dd53f2
4 changed files with 19 additions and 10 deletions

View file

@ -433,7 +433,7 @@ Item {
anchors.verticalCenter: nameCardRemoveConnectionImage.verticalCenter
x: 240
onClicked: {
AddressManager.goToUser(thisNameCard.userName);
AddressManager.goToUser(thisNameCard.userName, false);
UserActivityLogger.palAction("go_to_user", thisNameCard.userName);
}
}
@ -595,7 +595,9 @@ Item {
// the avatar goes into fly mode rather than falling. However, that is not exposed to Javascript right now.
// FIXME: it would be nice if this used the same teleport steps and smoothing as in the teleport.js script.
// Note, however, that this script allows teleporting to a person in the air, while teleport.js is going to a grounded target.
// Position avatar 2 metres from the target in the direction that target avatar was facing.
MyAvatar.position = Vec3.sum(avatar.position, Vec3.multiplyQbyV(avatar.orientation, {x: 0, y: 0, z: -2}));
// Rotate avatar on Y axis to face target avatar.
MyAvatar.orientation = Quat.multiply(avatar.orientation, {y: 1});
}
}

View file

@ -830,7 +830,7 @@ Rectangle {
hoverEnabled: enabled
enabled: connectionsNameCard.selected && pal.activeTab == "connectionsTab"
onClicked: {
AddressManager.goToUser(model.userName);
AddressManager.goToUser(model.userName, false);
UserActivityLogger.palAction("go_to_user", model.userName);
}
onEntered: connectionsLocationData.color = hifi.colors.blueHighlight;

View file

@ -665,6 +665,11 @@ bool AddressManager::handleViewpoint(const QString& viewpointString, bool should
}
}
if (trigger == LookupTrigger::VisitUserFromPAL) {
qCDebug(networking) << "trigger is VisitUserFromPAL -- applying Quat.cancelOutRollAndPitch";
newOrientation = cancelOutRollAndPitch(newOrientation);
}
emit locationChangeRequired(newPosition, orientationChanged, newOrientation, shouldFace);
} else {
@ -729,13 +734,14 @@ bool AddressManager::setDomainInfo(const QString& hostname, quint16 port, Lookup
return hostChanged;
}
void AddressManager::goToUser(const QString& username) {
void AddressManager::goToUser(const QString& username, bool shouldMatchOrientation) {
QString formattedUsername = QUrl::toPercentEncoding(username);
// for history storage handling we remember how this lookup was trigged - for a username it's always user input
// for history storage handling we remember how this lookup was triggered - for a username it's always user input
QVariantMap requestParams;
requestParams.insert(LOOKUP_TRIGGER_KEY, static_cast<int>(LookupTrigger::UserInput));
requestParams.insert(LOOKUP_TRIGGER_KEY, static_cast<int>(
shouldMatchOrientation ? LookupTrigger::UserInput : LookupTrigger::VisitUserFromPAL
));
// this is a username - pull the captured name and lookup that user's location
DependencyManager::get<AccountManager>()->sendRequest(GET_USER_LOCATION.arg(formattedUsername),
AccountManagerAuth::Optional,
@ -841,8 +847,8 @@ void AddressManager::addCurrentAddressToHistory(LookupTrigger trigger) {
// and do not but it into the back stack
_forwardStack.push(currentAddress());
} else {
if (trigger == LookupTrigger::UserInput) {
// anyime the user has manually looked up an address we know we should clear the forward stack
if (trigger == LookupTrigger::UserInput || trigger == LookupTrigger::VisitUserFromPAL) {
// anyime the user has actively triggered an address we know we should clear the forward stack
_forwardStack.clear();
emit goForwardPossible(false);

View file

@ -55,7 +55,8 @@ public:
DomainPathResponse,
Internal,
AttemptedRefresh,
Suggestions
Suggestions,
VisitUserFromPAL
};
bool isConnected();
@ -95,7 +96,7 @@ public slots:
void goToLocalSandbox(QString path = "", LookupTrigger trigger = LookupTrigger::StartupFromSettings) { handleUrl(SANDBOX_HIFI_ADDRESS + path, trigger); }
void goToEntry(LookupTrigger trigger = LookupTrigger::StartupFromSettings) { handleUrl(DEFAULT_HIFI_ADDRESS, trigger); }
void goToUser(const QString& username);
void goToUser(const QString& username, bool shouldMatchOrientation = true);
void refreshPreviousLookup();