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
1890const float HEAD_SPHERE_RADIUS = 0.1f;1890const float HEAD_SPHERE_RADIUS = 0.1f;
1891 1891
1892bool Application::isLookingAtMyAvatar(Avatar* avatar) {1892bool Application::isLookingAtMyAvatar(Avatar* avatar) {
1893 glm::vec3 theirLookat = avatar->getHead()->getLookAtPosition();1893 glm::vec3 theirLookAt = avatar->getHead()->getLookAtPosition();
1894 glm::vec3 myEyePosition = _myAvatar->getHead()->getEyePosition();1894 glm::vec3 myEyePosition = _myAvatar->getHead()->getEyePosition();
1895 1895 if (pointInSphere(theirLookAt, myEyePosition, HEAD_SPHERE_RADIUS * _myAvatar->getScale())) {
1896 if (pointInSphere(theirLookat, myEyePosition, HEAD_SPHERE_RADIUS * _myAvatar->getScale())) {
1897 return true;1896 return true;
1898 }1897 }
1899 return false;1898 return false;
@@ -1999,21 +1998,23 @@ void Application::updateMyAvatarLookAtPosition() { · 99 unmodified lines
1999 lookAtSpot = _myCamera.getPosition();1998 lookAtSpot = _myCamera.getPosition();
2000 1999
2001 } else {2000 } else {
2002 if (_myAvatar->getLookAtTargetAvatar() && _myAvatar != _myAvatar->getLookAtTargetAvatar()) {2001 AvatarSharedPointer lookingAt = _myAvatar->getLookAtTargetAvatar().toStrongRef();
2002 if (lookingAt && _myAvatar != lookingAt.data()) {
2003
2003 isLookingAtSomeone = true;2004 isLookingAtSomeone = true;
2004 // If I am looking at someone else, look directly at one of their eyes2005 // If I am looking at someone else, look directly at one of their eyes
2005 if (tracker) {2006 if (tracker) {
2006 // If tracker active, look at the eye for the side my gaze is biased toward2007 // If tracker active, look at the eye for the side my gaze is biased toward
2007 if (tracker->getEstimatedEyeYaw() > _myAvatar->getHead()->getFinalYaw()) {2008 if (tracker->getEstimatedEyeYaw() > _myAvatar->getHead()->getFinalYaw()) {
2008 // Look at their right eye2009 // Look at their right eye
2009 lookAtSpot = static_cast<Avatar*>(_myAvatar->getLookAtTargetAvatar())->getHead()->getRightEyePosition();2010 lookAtSpot = static_cast<Avatar*>(lookingAt.data())->getHead()->getRightEyePosition();
2010 } else {2011 } else {
2011 // Look at their left eye2012 // Look at their left eye
2012 lookAtSpot = static_cast<Avatar*>(_myAvatar->getLookAtTargetAvatar())->getHead()->getLeftEyePosition();2013 lookAtSpot = static_cast<Avatar*>(lookingAt.data())->getHead()->getLeftEyePosition();
2013 }2014 }
2014 } else {2015 } else {
2015 // Need to add randomly looking back and forth between left and right eye for case with no tracker2016 // 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();
2017 }2018 }
2018 } else {2019 } else {
2019 // I am not looking at anyone else, so just look forward2020 // 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