Showing the changes to interface/src/Application.cpp (1 of 45 files). Show all
Unified · Split
| @@ -54,7 +54,7 @@ · 53 unmodified lines | |||
| 54 | #include <PacketHeaders.h> | 54 | #include <PacketHeaders.h> |
| 55 | #include <PairingHandler.h> | 55 | #include <PairingHandler.h> |
| 56 | #include <PerfStat.h> | 56 | #include <PerfStat.h> |
| 57 | 57 | #include <UUID.h> | |
| 58 | #include <VoxelSceneStats.h> | 58 | #include <VoxelSceneStats.h> |
| 59 | 59 | ||
| 60 | #include "Application.h" | 60 | #include "Application.h" |
| @@ -1160,8 +1160,9 @@ void Application::sendAvatarFaceVideoMessage(int frameCount, const QByteArray& d · 1099 unmodified lines | |||
| 1160 | 1160 | ||
| 1161 | packetPosition += populateTypeAndVersion(packetPosition, PACKET_TYPE_AVATAR_FACE_VIDEO); | 1161 | packetPosition += populateTypeAndVersion(packetPosition, PACKET_TYPE_AVATAR_FACE_VIDEO); |
| 1162 | 1162 | ||
| 1163 | *(uint16_t*)packetPosition = NodeList::getInstance()->getOwnerID(); | 1163 | QByteArray rfcUUID = NodeList::getInstance()->getOwnerUUID().toRfc4122(); |
| 1164 | packetPosition += sizeof(uint16_t); | 1164 | memcpy(packetPosition, rfcUUID.constData(), rfcUUID.size()); |
| 1165 | packetPosition += rfcUUID.size(); | ||
| 1165 | 1166 | ||
| 1166 | *(uint32_t*)packetPosition = frameCount; | 1167 | *(uint32_t*)packetPosition = frameCount; |
| 1167 | packetPosition += sizeof(uint32_t); | 1168 | packetPosition += sizeof(uint32_t); |
| @@ -1295,12 +1296,13 @@ static Avatar* processAvatarMessageHeader(unsigned char*& packetData, size_t& da · 127 unmodified lines | |||
| 1295 | dataBytes -= numBytesPacketHeader; | 1296 | dataBytes -= numBytesPacketHeader; |
| 1296 | 1297 | ||
| 1297 | // read the node id | 1298 | // read the node id |
| 1298 | uint16_t nodeID = *(uint16_t*)packetData; | 1299 | QUuid nodeUUID = QUuid::fromRfc4122(QByteArray((char*) packetData, NUM_BYTES_RFC4122_UUID)); |
| 1299 | packetData += sizeof(nodeID); | 1300 | |
| 1300 | dataBytes -= sizeof(nodeID); | 1301 | packetData += NUM_BYTES_RFC4122_UUID; |
| 1302 | dataBytes -= NUM_BYTES_RFC4122_UUID; | ||
| 1301 | 1303 | ||
| 1302 | // make sure the node exists | 1304 | // make sure the node exists |
| 1303 | Node* node = NodeList::getInstance()->nodeWithID(nodeID); | 1305 | Node* node = NodeList::getInstance()->nodeWithUUID(nodeUUID); |
| 1304 | if (!node || !node->getLinkedData()) { | 1306 | if (!node || !node->getLinkedData()) { |
| 1305 | return NULL; | 1307 | return NULL; |
| 1306 | } | 1308 | } |
| @@ -1560,29 +1562,6 @@ void Application::deleteVoxels() { · 253 unmodified lines | |||
| 1560 | deleteVoxelUnderCursor(); | 1562 | deleteVoxelUnderCursor(); |
| 1561 | } | 1563 | } |
| 1562 | 1564 | ||
| 1563 | void Application::setListenModeNormal() { | ||
| 1564 | _audio.setListenMode(AudioRingBuffer::NORMAL); | ||
| 1565 | } | ||
| 1566 | |||
| 1567 | void Application::setListenModePoint() { | ||
| 1568 | _audio.setListenMode(AudioRingBuffer::OMNI_DIRECTIONAL_POINT); | ||
| 1569 | _audio.setListenRadius(1.0); | ||
| 1570 | } | ||
| 1571 | |||
| 1572 | void Application::setListenModeSingleSource() { | ||
| 1573 | _audio.setListenMode(AudioRingBuffer::SELECTED_SOURCES); | ||
| 1574 | _audio.clearListenSources(); | ||
| 1575 | |||
| 1576 | glm::vec3 mouseRayOrigin = _myAvatar.getMouseRayOrigin(); | ||
| 1577 | glm::vec3 mouseRayDirection = _myAvatar.getMouseRayDirection(); | ||
| 1578 | glm::vec3 eyePositionIgnored; | ||
| 1579 | uint16_t nodeID; | ||
| 1580 | |||
| 1581 | if (findLookatTargetAvatar(mouseRayOrigin, mouseRayDirection, eyePositionIgnored, nodeID)) { | ||
| 1582 | _audio.addListenSource(nodeID); | ||
| 1583 | } | ||
| 1584 | } | ||
| 1585 | |||
| 1586 | void Application::initDisplay() { | 1565 | void Application::initDisplay() { |
| 1587 | glEnable(GL_BLEND); | 1566 | glEnable(GL_BLEND); |
| 1588 | glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_CONSTANT_ALPHA, GL_ONE); | 1567 | glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_CONSTANT_ALPHA, GL_ONE); |
| @@ -1688,7 +1667,7 @@ const float MAX_AVATAR_EDIT_VELOCITY = 1.0f; · 99 unmodified lines | |||
| 1688 | const float MAX_VOXEL_EDIT_DISTANCE = 20.0f; | 1667 | const float MAX_VOXEL_EDIT_DISTANCE = 20.0f; |
| 1689 | const float HEAD_SPHERE_RADIUS = 0.07; | 1668 | const float HEAD_SPHERE_RADIUS = 0.07; |
| 1690 | 1669 | ||
| 1691 | static uint16_t DEFAULT_NODE_ID_REF = 1; | 1670 | static QUuid DEFAULT_NODE_ID_REF; |
| 1692 | 1671 | ||
| 1693 | void Application::updateLookatTargetAvatar(const glm::vec3& mouseRayOrigin, const glm::vec3& mouseRayDirection, | 1672 | void Application::updateLookatTargetAvatar(const glm::vec3& mouseRayOrigin, const glm::vec3& mouseRayDirection, |
| 1694 | glm::vec3& eyePosition) { | 1673 | glm::vec3& eyePosition) { |
| @@ -1697,7 +1676,7 @@ void Application::updateLookatTargetAvatar(const glm::vec3& mouseRayOrigin, cons · 2 unmodified lines | |||
| 1697 | } | 1676 | } |
| 1698 | 1677 | ||
| 1699 | Avatar* Application::findLookatTargetAvatar(const glm::vec3& mouseRayOrigin, const glm::vec3& mouseRayDirection, | 1678 | Avatar* Application::findLookatTargetAvatar(const glm::vec3& mouseRayOrigin, const glm::vec3& mouseRayDirection, |
| 1700 | glm::vec3& eyePosition, uint16_t& nodeID = DEFAULT_NODE_ID_REF) { | 1679 | glm::vec3& eyePosition, QUuid& nodeUUID = DEFAULT_NODE_ID_REF) { |
| 1701 | 1680 | ||
| 1702 | NodeList* nodeList = NodeList::getInstance(); | 1681 | NodeList* nodeList = NodeList::getInstance(); |
| 1703 | for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) { | 1682 | for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) { |
| @@ -1710,7 +1689,7 @@ Avatar* Application::findLookatTargetAvatar(const glm::vec3& mouseRayOrigin, con · 6 unmodified lines | |||
| 1710 | eyePosition = avatar->getHead().getEyePosition(); | 1689 | eyePosition = avatar->getHead().getEyePosition(); |
| 1711 | _lookatIndicatorScale = avatar->getHead().getScale(); | 1690 | _lookatIndicatorScale = avatar->getHead().getScale(); |
| 1712 | _lookatOtherPosition = headPosition; | 1691 | _lookatOtherPosition = headPosition; |
| 1713 | nodeID = avatar->getOwningNode()->getNodeID(); | 1692 | nodeUUID = avatar->getOwningNode()->getUUID(); |
| 1714 | return avatar; | 1693 | return avatar; |
| 1715 | } | 1694 | } |
| 1716 | } | 1695 | } |
| @@ -1759,12 +1738,12 @@ void Application::renderFollowIndicator() { · 42 unmodified lines | |||
| 1759 | Avatar* avatar = (Avatar *) node->getLinkedData(); | 1738 | Avatar* avatar = (Avatar *) node->getLinkedData(); |
| 1760 | Avatar* leader = NULL; | 1739 | Avatar* leader = NULL; |
| 1761 | 1740 | ||
| 1762 | if (avatar->getLeaderID() != UNKNOWN_NODE_ID) { | 1741 | if (!avatar->getLeaderUUID().isNull()) { |
| 1763 | if (avatar->getLeaderID() == NodeList::getInstance()->getOwnerID()) { | 1742 | if (avatar->getLeaderUUID() == NodeList::getInstance()->getOwnerUUID()) { |
| 1764 | leader = &_myAvatar; | 1743 | leader = &_myAvatar; |
| 1765 | } else { | 1744 | } else { |
| 1766 | for (NodeList::iterator it = nodeList->begin(); it != nodeList->end(); ++it) { | 1745 | for (NodeList::iterator it = nodeList->begin(); it != nodeList->end(); ++it) { |
| 1767 | if(it->getNodeID() == avatar->getLeaderID() | 1746 | if(it->getUUID() == avatar->getLeaderUUID() |
| 1768 | && it->getType() == NODE_TYPE_AGENT) { | 1747 | && it->getType() == NODE_TYPE_AGENT) { |
| 1769 | leader = (Avatar*) it->getLinkedData(); | 1748 | leader = (Avatar*) it->getLinkedData(); |
| 1770 | } | 1749 | } |
| @@ -2244,26 +2223,27 @@ void Application::updateAvatar(float deltaTime) { · 473 unmodified lines | |||
| 2244 | _myAvatar.setCameraEyeOffsetPosition(_viewFrustum.getEyeOffsetPosition()); | 2223 | _myAvatar.setCameraEyeOffsetPosition(_viewFrustum.getEyeOffsetPosition()); |
| 2245 | 2224 | ||
| 2246 | NodeList* nodeList = NodeList::getInstance(); | 2225 | NodeList* nodeList = NodeList::getInstance(); |
| 2247 | if (nodeList->getOwnerID() != UNKNOWN_NODE_ID) { | 2226 | |
| 2248 | // if I know my ID, send head/hand data to the avatar mixer and voxel server | 2227 | // send head/hand data to the avatar mixer and voxel server |
| 2249 | unsigned char broadcastString[MAX_PACKET_SIZE]; | 2228 | unsigned char broadcastString[MAX_PACKET_SIZE]; |
| 2250 | unsigned char* endOfBroadcastStringWrite = broadcastString; | 2229 | unsigned char* endOfBroadcastStringWrite = broadcastString; |
| 2251 | 2230 | ||
| 2252 | endOfBroadcastStringWrite += populateTypeAndVersion(endOfBroadcastStringWrite, PACKET_TYPE_HEAD_DATA); | 2231 | endOfBroadcastStringWrite += populateTypeAndVersion(endOfBroadcastStringWrite, PACKET_TYPE_HEAD_DATA); |
| 2253 | 2232 | ||
| 2254 | endOfBroadcastStringWrite += packNodeId(endOfBroadcastStringWrite, nodeList->getOwnerID()); | 2233 | QByteArray ownerUUID = nodeList->getOwnerUUID().toRfc4122(); |
| 2255 | 2234 | memcpy(endOfBroadcastStringWrite, ownerUUID.constData(), ownerUUID.size()); | |
| 2256 | endOfBroadcastStringWrite += _myAvatar.getBroadcastData(endOfBroadcastStringWrite); | 2235 | endOfBroadcastStringWrite += ownerUUID.size(); |
| 2257 | 2236 | ||
| 2258 | const char nodeTypesOfInterest[] = { NODE_TYPE_VOXEL_SERVER, NODE_TYPE_AVATAR_MIXER }; | 2237 | endOfBroadcastStringWrite += _myAvatar.getBroadcastData(endOfBroadcastStringWrite); |
| 2259 | controlledBroadcastToNodes(broadcastString, endOfBroadcastStringWrite - broadcastString, | 2238 | |
| 2260 | nodeTypesOfInterest, sizeof(nodeTypesOfInterest)); | 2239 | const char nodeTypesOfInterest[] = { NODE_TYPE_VOXEL_SERVER, NODE_TYPE_AVATAR_MIXER }; |
| 2261 | 2240 | controlledBroadcastToNodes(broadcastString, endOfBroadcastStringWrite - broadcastString, | |
| 2262 | // once in a while, send my urls | 2241 | nodeTypesOfInterest, sizeof(nodeTypesOfInterest)); |
| 2263 | const float AVATAR_URLS_SEND_INTERVAL = 1.0f; // seconds | 2242 | |
| 2264 | if (shouldDo(AVATAR_URLS_SEND_INTERVAL, deltaTime)) { | 2243 | // once in a while, send my urls |
| 2265 | Avatar::sendAvatarURLsMessage(_myAvatar.getVoxels()->getVoxelURL()); | 2244 | const float AVATAR_URLS_SEND_INTERVAL = 1.0f; // seconds |
| 2266 | } | 2245 | if (shouldDo(AVATAR_URLS_SEND_INTERVAL, deltaTime)) { |
| 2246 | Avatar::sendAvatarURLsMessage(_myAvatar.getVoxels()->getVoxelURL()); | ||
| 2267 | } | 2247 | } |
| 2268 | } | 2248 | } |
| 2269 | 2249 | ||
| @@ -3557,8 +3537,8 @@ void Application::toggleFollowMode() { · 1287 unmodified lines | |||
| 3557 | _pieMenu.getY() / (float)_glWidget->height(), | 3537 | _pieMenu.getY() / (float)_glWidget->height(), |
| 3558 | mouseRayOrigin, mouseRayDirection); | 3538 | mouseRayOrigin, mouseRayDirection); |
| 3559 | glm::vec3 eyePositionIgnored; | 3539 | glm::vec3 eyePositionIgnored; |
| 3560 | uint16_t nodeIDIgnored; | 3540 | QUuid nodeUUIDIgnored; |
| 3561 | Avatar* leadingAvatar = findLookatTargetAvatar(mouseRayOrigin, mouseRayDirection, eyePositionIgnored, nodeIDIgnored); | 3541 | Avatar* leadingAvatar = findLookatTargetAvatar(mouseRayOrigin, mouseRayDirection, eyePositionIgnored, nodeUUIDIgnored); |
| 3562 | 3542 | ||
| 3563 | _myAvatar.follow(leadingAvatar); | 3543 | _myAvatar.follow(leadingAvatar); |
| 3564 | } | 3544 | } |
| @@ -3626,10 +3606,10 @@ void Application::nodeAdded(Node* node) { · 61 unmodified lines | |||
| 3626 | 3606 | ||
| 3627 | void Application::nodeKilled(Node* node) { | 3607 | void Application::nodeKilled(Node* node) { |
| 3628 | if (node->getType() == NODE_TYPE_VOXEL_SERVER) { | 3608 | if (node->getType() == NODE_TYPE_VOXEL_SERVER) { |
| 3629 | uint16_t nodeID = node->getNodeID(); | 3609 | QUuid nodeUUID = node->getUUID(); |
| 3630 | // see if this is the first we've heard of this node... | 3610 | // see if this is the first we've heard of this node... |
| 3631 | if (_voxelServerJurisdictions.find(nodeID) != _voxelServerJurisdictions.end()) { | 3611 | if (_voxelServerJurisdictions.find(nodeUUID) != _voxelServerJurisdictions.end()) { |
| 3632 | unsigned char* rootCode = _voxelServerJurisdictions[nodeID].getRootOctalCode(); | 3612 | unsigned char* rootCode = _voxelServerJurisdictions[nodeUUID].getRootOctalCode(); |
| 3633 | VoxelPositionSize rootDetails; | 3613 | VoxelPositionSize rootDetails; |
| 3634 | voxelDetailsForCode(rootCode, rootDetails); | 3614 | voxelDetailsForCode(rootCode, rootDetails); |
| 3635 | 3615 | ||
| @@ -3659,13 +3639,13 @@ int Application::parseVoxelStats(unsigned char* messageData, ssize_t messageLeng · 23 unmodified lines | |||
| 3659 | 3639 | ||
| 3660 | // quick fix for crash... why would voxelServer be NULL? | 3640 | // quick fix for crash... why would voxelServer be NULL? |
| 3661 | if (voxelServer) { | 3641 | if (voxelServer) { |
| 3662 | uint16_t nodeID = voxelServer->getNodeID(); | 3642 | QUuid nodeUUID = voxelServer->getUUID(); |
| 3663 | 3643 | ||
| 3664 | VoxelPositionSize rootDetails; | 3644 | VoxelPositionSize rootDetails; |
| 3665 | voxelDetailsForCode(_voxelSceneStats.getJurisdictionRoot(), rootDetails); | 3645 | voxelDetailsForCode(_voxelSceneStats.getJurisdictionRoot(), rootDetails); |
| 3666 | 3646 | ||
| 3667 | // see if this is the first we've heard of this node... | 3647 | // see if this is the first we've heard of this node... |
| 3668 | if (_voxelServerJurisdictions.find(nodeID) == _voxelServerJurisdictions.end()) { | 3648 | if (_voxelServerJurisdictions.find(nodeUUID) == _voxelServerJurisdictions.end()) { |
| 3669 | printf("stats from new voxel server... v[%f, %f, %f, %f]\n", | 3649 | printf("stats from new voxel server... v[%f, %f, %f, %f]\n", |
| 3670 | rootDetails.x, rootDetails.y, rootDetails.z, rootDetails.s); | 3650 | rootDetails.x, rootDetails.y, rootDetails.z, rootDetails.s); |
| 3671 | 3651 | ||
| @@ -3682,7 +3662,7 @@ int Application::parseVoxelStats(unsigned char* messageData, ssize_t messageLeng · 10 unmodified lines | |||
| 3682 | // details from the VoxelSceneStats to construct the JurisdictionMap | 3662 | // details from the VoxelSceneStats to construct the JurisdictionMap |
| 3683 | JurisdictionMap jurisdictionMap; | 3663 | JurisdictionMap jurisdictionMap; |
| 3684 | jurisdictionMap.copyContents(_voxelSceneStats.getJurisdictionRoot(), _voxelSceneStats.getJurisdictionEndNodes()); | 3664 | jurisdictionMap.copyContents(_voxelSceneStats.getJurisdictionRoot(), _voxelSceneStats.getJurisdictionEndNodes()); |
| 3685 | _voxelServerJurisdictions[nodeID] = jurisdictionMap; | 3665 | _voxelServerJurisdictions[nodeUUID] = jurisdictionMap; |
| 3686 | } | 3666 | } |
| 3687 | return statsMessageLength; | 3667 | return statsMessageLength; |
| 3688 | } | 3668 | } |