History

Avatars look at your camera, not your avatar. Improvements to lookAt code

Philip Rosedale committed 12 years ago

Commit 75e53621 parent 729d3cf10 files · +44 −50Browse files

Showing the changes to interface/src/Application.cpp (1 of 10 files). Show all

Unified · Split

interface/src/Application.cpp+8−7
@@ -1890,10 +1890,9 @@ void Application::shrinkMirrorView() { · 1889 unmodified lines
18901890 const float HEAD_SPHERE_RADIUS = 0.1f;
18911891
18921892 bool Application::isLookingAtMyAvatar(Avatar* avatar) {
1893− glm::vec3 theirLookat = avatar->getHead()->getLookAtPosition();
1893+ glm::vec3 theirLookAt = avatar->getHead()->getLookAtPosition();
18941894 glm::vec3 myEyePosition = _myAvatar->getHead()->getEyePosition();
1895−
1896− if (pointInSphere(theirLookat, myEyePosition, HEAD_SPHERE_RADIUS * _myAvatar->getScale())) {
1895+ if (pointInSphere(theirLookAt, myEyePosition, HEAD_SPHERE_RADIUS * _myAvatar->getScale())) {
18971896 return true;
18981897 }
18991898 return false;
@@ -1999,21 +1998,23 @@ void Application::updateMyAvatarLookAtPosition() { · 99 unmodified lines
19991998 lookAtSpot = _myCamera.getPosition();
20001999
20012000 } else {
2002− if (_myAvatar->getLookAtTargetAvatar() && _myAvatar != _myAvatar->getLookAtTargetAvatar()) {
2001+ AvatarSharedPointer lookingAt = _myAvatar->getLookAtTargetAvatar().toStrongRef();
2002+ if (lookingAt && _myAvatar != lookingAt.data()) {
2003+
20032004 isLookingAtSomeone = true;
20042005 // If I am looking at someone else, look directly at one of their eyes
20052006 if (tracker) {
20062007 // If tracker active, look at the eye for the side my gaze is biased toward
20072008 if (tracker->getEstimatedEyeYaw() > _myAvatar->getHead()->getFinalYaw()) {
20082009 // Look at their right eye
2009− lookAtSpot = static_cast<Avatar*>(_myAvatar->getLookAtTargetAvatar())->getHead()->getRightEyePosition();
2010+ lookAtSpot = static_cast<Avatar*>(lookingAt.data())->getHead()->getRightEyePosition();
20102011 } else {
20112012 // Look at their left eye
2012− lookAtSpot = static_cast<Avatar*>(_myAvatar->getLookAtTargetAvatar())->getHead()->getLeftEyePosition();
2013+ lookAtSpot = static_cast<Avatar*>(lookingAt.data())->getHead()->getLeftEyePosition();
20132014 }
20142015 } else {
20152016 // Need to add randomly looking back and forth between left and right eye for case with no tracker
2016− lookAtSpot = static_cast<Avatar*>(_myAvatar->getLookAtTargetAvatar())->getHead()->getEyePosition();
2017+ lookAtSpot = static_cast<Avatar*>(lookingAt.data())->getHead()->getEyePosition();
20172018 }
20182019 } else {
20192020 // I am not looking at anyone else, so just look forward

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t