From 6b659101d583c3d64fbcf7be8e28d5c1397d5082 Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Fri, 16 Jun 2017 15:09:13 -0700 Subject: [PATCH 1/3] Fix teleporting to another user from the PAL --- interface/resources/qml/hifi/NameCard.qml | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/interface/resources/qml/hifi/NameCard.qml b/interface/resources/qml/hifi/NameCard.qml index a86defdfd7..a9b5e7f858 100644 --- a/interface/resources/qml/hifi/NameCard.qml +++ b/interface/resources/qml/hifi/NameCard.qml @@ -243,7 +243,7 @@ Item { enabled: selected && pal.activeTab == "nearbyTab" && thisNameCard.userName !== "" && isPresent; hoverEnabled: enabled onClicked: { - goToUserInDomain(thisNameCard.uuid); + AddressManager.goToUser(thisNameCard.userName); UserActivityLogger.palAction("go_to_user_in_domain", thisNameCard.uuid); } onEntered: { @@ -338,7 +338,7 @@ Item { enabled: selected && pal.activeTab == "nearbyTab" && thisNameCard.userName !== "" && isPresent; hoverEnabled: enabled onClicked: { - goToUserInDomain(thisNameCard.uuid); + AddressManager.goToUser(thisNameCard.userName); UserActivityLogger.palAction("go_to_user_in_domain", thisNameCard.uuid); } onEntered: { @@ -582,22 +582,4 @@ Item { UserActivityLogger.palAction("avatar_gain_changed", avatarUuid); } } - - // Function body by Howard Stearns 2017-01-08 - function goToUserInDomain(avatarUuid) { - var avatar = AvatarList.getAvatar(avatarUuid); - if (!avatar) { - console.log("This avatar is no longer present. goToUserInDomain() failed."); - return; - } - var vector = Vec3.subtract(avatar.position, MyAvatar.position); - var distance = Vec3.length(vector); - var target = Vec3.multiply(Vec3.normalize(vector), distance - 2.0); - // FIXME: We would like the avatar to recompute the avatar's "maybe fly" test at the new position, so that if high enough up, - // 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. - MyAvatar.orientation = Quat.lookAtSimple(MyAvatar.position, avatar.position); - MyAvatar.position = Vec3.sum(MyAvatar.position, target); - } } From 74fde8efd702b2fc6e8ce06e19ec08c5f29df8bf Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Fri, 16 Jun 2017 15:33:47 -0700 Subject: [PATCH 2/3] Revert "Fix teleporting to another user from the PAL" This reverts commit 6b659101d583c3d64fbcf7be8e28d5c1397d5082. --- interface/resources/qml/hifi/NameCard.qml | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/interface/resources/qml/hifi/NameCard.qml b/interface/resources/qml/hifi/NameCard.qml index a9b5e7f858..a86defdfd7 100644 --- a/interface/resources/qml/hifi/NameCard.qml +++ b/interface/resources/qml/hifi/NameCard.qml @@ -243,7 +243,7 @@ Item { enabled: selected && pal.activeTab == "nearbyTab" && thisNameCard.userName !== "" && isPresent; hoverEnabled: enabled onClicked: { - AddressManager.goToUser(thisNameCard.userName); + goToUserInDomain(thisNameCard.uuid); UserActivityLogger.palAction("go_to_user_in_domain", thisNameCard.uuid); } onEntered: { @@ -338,7 +338,7 @@ Item { enabled: selected && pal.activeTab == "nearbyTab" && thisNameCard.userName !== "" && isPresent; hoverEnabled: enabled onClicked: { - AddressManager.goToUser(thisNameCard.userName); + goToUserInDomain(thisNameCard.uuid); UserActivityLogger.palAction("go_to_user_in_domain", thisNameCard.uuid); } onEntered: { @@ -582,4 +582,22 @@ Item { UserActivityLogger.palAction("avatar_gain_changed", avatarUuid); } } + + // Function body by Howard Stearns 2017-01-08 + function goToUserInDomain(avatarUuid) { + var avatar = AvatarList.getAvatar(avatarUuid); + if (!avatar) { + console.log("This avatar is no longer present. goToUserInDomain() failed."); + return; + } + var vector = Vec3.subtract(avatar.position, MyAvatar.position); + var distance = Vec3.length(vector); + var target = Vec3.multiply(Vec3.normalize(vector), distance - 2.0); + // FIXME: We would like the avatar to recompute the avatar's "maybe fly" test at the new position, so that if high enough up, + // 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. + MyAvatar.orientation = Quat.lookAtSimple(MyAvatar.position, avatar.position); + MyAvatar.position = Vec3.sum(MyAvatar.position, target); + } } From 6230dcf93ddd2d818757941880deee953d7df40b Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Fri, 16 Jun 2017 16:34:35 -0700 Subject: [PATCH 3/3] Thanks to Thoys! --- interface/resources/qml/hifi/NameCard.qml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/interface/resources/qml/hifi/NameCard.qml b/interface/resources/qml/hifi/NameCard.qml index a86defdfd7..91c1d99cf5 100644 --- a/interface/resources/qml/hifi/NameCard.qml +++ b/interface/resources/qml/hifi/NameCard.qml @@ -590,14 +590,11 @@ Item { console.log("This avatar is no longer present. goToUserInDomain() failed."); return; } - var vector = Vec3.subtract(avatar.position, MyAvatar.position); - var distance = Vec3.length(vector); - var target = Vec3.multiply(Vec3.normalize(vector), distance - 2.0); // FIXME: We would like the avatar to recompute the avatar's "maybe fly" test at the new position, so that if high enough up, // 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. - MyAvatar.orientation = Quat.lookAtSimple(MyAvatar.position, avatar.position); - MyAvatar.position = Vec3.sum(MyAvatar.position, target); + MyAvatar.position = Vec3.sum(avatar.position, Vec3.multiplyQbyV(avatar.orientation, {x: 0, y: 0, z: -2})); + MyAvatar.orientation = Quat.multiply(avatar.orientation, {y: 1}); } }