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