Showing the changes to interface/src/Application.cpp (1 of 2 files). Show all
Unified · Split
| @@ -1864,20 +1864,13 @@ void Application::setListenModeSingleSource() { · 1863 unmodified lines | ||
| 1864 | 1864 | _audio.setListenMode(AudioRingBuffer::SELECTED_SOURCES); |
| 1865 | 1865 | _audio.clearListenSources(); |
| 1866 | 1866 | |
| 1867 | − NodeList* nodeList = NodeList::getInstance(); | |
| 1868 | − for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) { | |
| 1869 | − if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) { | |
| 1870 | − Avatar* avatar = (Avatar *) node->getLinkedData(); | |
| 1871 | − glm::vec3 headPosition = avatar->getHead().getPosition(); | |
| 1872 | − glm::vec3 mouseRayOrigin = _myAvatar.getMouseRayOrigin(); | |
| 1873 | − glm::vec3 mouseRayDirection = _myAvatar.getMouseRayDirection(); | |
| 1874 | − const float HEAD_SPHERE_RADIUS = 0.07; | |
| 1867 | + glm::vec3 mouseRayOrigin = _myAvatar.getMouseRayOrigin(); | |
| 1868 | + glm::vec3 mouseRayDirection = _myAvatar.getMouseRayDirection(); | |
| 1869 | + glm::vec3 eyePositionIgnored; | |
| 1870 | + uint16_t nodeID; | |
| 1875 | 1871 | |
| 1876 | − if (rayIntersectsSphere(mouseRayOrigin, mouseRayDirection, headPosition, HEAD_SPHERE_RADIUS)) { | |
| 1877 | − int sourceID = avatar->getOwningNode()->getNodeID(); | |
| 1878 | − _audio.addListenSource(sourceID); | |
| 1879 | − } | |
| 1880 | − } | |
| 1872 | + if (isLookingAtOtherAvatar(mouseRayOrigin, mouseRayDirection, eyePositionIgnored, nodeID)) { | |
| 1873 | + _audio.addListenSource(nodeID); | |
| 1881 | 1874 | } |
| 1882 | 1875 | } |
| 1883 | 1876 | |
| @@ -1970,7 +1963,10 @@ const float MAX_AVATAR_EDIT_VELOCITY = 1.0f; · 86 unmodified lines | ||
| 1970 | 1963 | const float MAX_VOXEL_EDIT_DISTANCE = 20.0f; |
| 1971 | 1964 | const float HEAD_SPHERE_RADIUS = 0.07; |
| 1972 | 1965 | |
| 1973 | −bool Application::isLookingAtOtherAvatar(glm::vec3& mouseRayOrigin, glm::vec3& mouseRayDirection, glm::vec3& eyePosition) { | |
| 1966 | + | |
| 1967 | +bool Application::isLookingAtOtherAvatar(glm::vec3& mouseRayOrigin, glm::vec3& mouseRayDirection, | |
| 1968 | + glm::vec3& eyePosition, uint16_t& nodeID) { | |
| 1969 | + | |
| 1974 | 1970 | NodeList* nodeList = NodeList::getInstance(); |
| 1975 | 1971 | for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) { |
| 1976 | 1972 | if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) { |
| @@ -1979,6 +1975,7 @@ bool Application::isLookingAtOtherAvatar(glm::vec3& mouseRayOrigin, glm::vec3& m · 2 unmodified lines | ||
| 1979 | 1975 | if (rayIntersectsSphere(mouseRayOrigin, mouseRayDirection, headPosition, HEAD_SPHERE_RADIUS)) { |
| 1980 | 1976 | eyePosition = avatar->getHead().getEyeLevelPosition(); |
| 1981 | 1977 | _lookatOtherPosition = headPosition; |
| 1978 | + nodeID = avatar->getOwningNode()->getNodeID(); | |
| 1982 | 1979 | return true; |
| 1983 | 1980 | } |
| 1984 | 1981 | } |
| @@ -2022,7 +2019,9 @@ void Application::update(float deltaTime) { · 37 unmodified lines | ||
| 2022 | 2019 | |
| 2023 | 2020 | // Set where I am looking based on my mouse ray (so that other people can see) |
| 2024 | 2021 | glm::vec3 eyePosition; |
| 2025 | − if (_isLookingAtOtherAvatar = isLookingAtOtherAvatar(mouseRayOrigin, mouseRayDirection, eyePosition)) { | |
| 2022 | + uint16_t ignored; | |
| 2023 | + _isLookingAtOtherAvatar = isLookingAtOtherAvatar(mouseRayOrigin, mouseRayDirection, eyePosition, ignored); | |
| 2024 | + if (_isLookingAtOtherAvatar) { | |
| 2026 | 2025 | // If the mouse is over another avatar's head... |
| 2027 | 2026 | glm::vec3 myLookAtFromMouse(eyePosition); |
| 2028 | 2027 | _myAvatar.getHead().setLookAtPosition(myLookAtFromMouse); |
| @@ -2284,7 +2283,9 @@ void Application::updateAvatar(float deltaTime) { · 255 unmodified lines | ||
| 2284 | 2283 | _viewFrustum.computePickRay(MIDPOINT_OF_SCREEN, MIDPOINT_OF_SCREEN, screenCenterRayOrigin, screenCenterRayDirection); |
| 2285 | 2284 | |
| 2286 | 2285 | glm::vec3 eyePosition; |
| 2287 | − if (_isLookingAtOtherAvatar = isLookingAtOtherAvatar(screenCenterRayOrigin, screenCenterRayDirection, eyePosition)) { | |
| 2286 | + uint16_t ignored; | |
| 2287 | + _isLookingAtOtherAvatar = isLookingAtOtherAvatar(screenCenterRayOrigin, screenCenterRayDirection, eyePosition, ignored); | |
| 2288 | + if (_isLookingAtOtherAvatar) { | |
| 2288 | 2289 | glm::vec3 myLookAtFromMouse(eyePosition); |
| 2289 | 2290 | _myAvatar.getHead().setLookAtPosition(myLookAtFromMouse); |
| 2290 | 2291 | } |