Merge pull request #11138 from Nex-Pro/21466

Fix Avatar Rotation upon Teleporting Using PAL
This commit is contained in:
Melissa Brown 2017-11-03 11:58:15 -07:00 committed by GitHub
commit a14e98053e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 13 deletions

View file

@ -432,7 +432,8 @@ Item {
anchors.verticalCenter: nameCardRemoveConnectionImage.verticalCenter anchors.verticalCenter: nameCardRemoveConnectionImage.verticalCenter
x: 240 x: 240
onClicked: { onClicked: {
AddressManager.goToUser(thisNameCard.userName); console.log("Vist user button clicked."); // Remove after debugging.
AddressManager.goToUser(thisNameCard.userName, false);
UserActivityLogger.palAction("go_to_user", thisNameCard.userName); UserActivityLogger.palAction("go_to_user", thisNameCard.userName);
} }
} }
@ -594,7 +595,10 @@ Item {
// the avatar goes into fly mode rather than falling. However, that is not exposed to Javascript right now. // 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. // 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. // 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})); MyAvatar.position = Vec3.sum(avatar.position, Vec3.multiplyQbyV(avatar.orientation, {x: 0, y: 0, z: -2}));
MyAvatar.orientation = Quat.multiply(avatar.orientation, {y: 1});
// Rotate avatar on Y axis to face target avatar and cancel out any inherited roll and pitch.
MyAvatar.orientation = Quat.cancelOutRollAndPitch(Quat.multiply(avatar.orientation, {y: 1}));
} }
} }

View file

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

View file

@ -667,8 +667,11 @@ bool AddressManager::handleViewpoint(const QString& viewpointString, bool should
qCDebug(networking) << "Orientation parsed from lookup string is invalid. Will not use for location change."; qCDebug(networking) << "Orientation parsed from lookup string is invalid. Will not use for location change.";
} }
} }
emit locationChangeRequired(newPosition, orientationChanged, newOrientation, shouldFace); emit locationChangeRequired(newPosition, orientationChanged,
LookupTrigger::VisitUserFromPAL ? cancelOutRollAndPitch(newOrientation): newOrientation,
shouldFace
);
} else { } else {
qCDebug(networking) << "Could not jump to position from lookup string because it has an invalid value."; qCDebug(networking) << "Could not jump to position from lookup string because it has an invalid value.";
@ -732,13 +735,14 @@ bool AddressManager::setDomainInfo(const QString& hostname, quint16 port, Lookup
return hostChanged; return hostChanged;
} }
void AddressManager::goToUser(const QString& username) { void AddressManager::goToUser(const QString& username, bool shouldMatchOrientation) {
QString formattedUsername = QUrl::toPercentEncoding(username); 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; 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 // this is a username - pull the captured name and lookup that user's location
DependencyManager::get<AccountManager>()->sendRequest(GET_USER_LOCATION.arg(formattedUsername), DependencyManager::get<AccountManager>()->sendRequest(GET_USER_LOCATION.arg(formattedUsername),
AccountManagerAuth::Optional, AccountManagerAuth::Optional,
@ -840,8 +844,8 @@ void AddressManager::addCurrentAddressToHistory(LookupTrigger trigger) {
// and do not but it into the back stack // and do not but it into the back stack
_forwardStack.push(currentAddress()); _forwardStack.push(currentAddress());
} else { } else {
if (trigger == LookupTrigger::UserInput) { if (trigger == LookupTrigger::UserInput || trigger == LookupTrigger::VisitUserFromPAL) {
// anyime the user has manually looked up an address we know we should clear the forward stack // anyime the user has actively triggered an address we know we should clear the forward stack
_forwardStack.clear(); _forwardStack.clear();
emit goForwardPossible(false); emit goForwardPossible(false);

View file

@ -54,7 +54,8 @@ public:
DomainPathResponse, DomainPathResponse,
Internal, Internal,
AttemptedRefresh, AttemptedRefresh,
Suggestions Suggestions,
VisitUserFromPAL
}; };
bool isConnected(); bool isConnected();
@ -93,7 +94,7 @@ public slots:
void goToLocalSandbox(QString path = "", LookupTrigger trigger = LookupTrigger::StartupFromSettings) { handleUrl(SANDBOX_HIFI_ADDRESS + path, trigger); } 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 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(); void refreshPreviousLookup();