Showing the changes to interface/src/Application.cpp (1 of 68 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" |
| @@ -500,7 +500,7 @@ void Application::controlledBroadcastToNodes(unsigned char* broadcastData, size_ · 439 unmodified lines | ||
| 500 | 500 | if (nodeTypes[i] == NODE_TYPE_VOXEL_SERVER && !Menu::getInstance()->isOptionChecked(MenuOption::Voxels)) { |
| 501 | 501 | continue; |
| 502 | 502 | } |
| 503 | − | |
| 503 | + | |
| 504 | 504 | // Perform the broadcast for one type |
| 505 | 505 | int nReceivingNodes = NodeList::getInstance()->broadcastToNodes(broadcastData, dataBytes, & nodeTypes[i], 1); |
| 506 | 506 | |
| @@ -1160,8 +1160,9 @@ void Application::sendAvatarFaceVideoMessage(int frameCount, const QByteArray& d · 653 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 | } |
| @@ -1393,13 +1395,13 @@ void Application::increaseVoxelSize() { · 86 unmodified lines | ||
| 1393 | 1395 | |
| 1394 | 1396 | const int MAXIMUM_EDIT_VOXEL_MESSAGE_SIZE = 1500; |
| 1395 | 1397 | struct SendVoxelsOperationArgs { |
| 1396 | − unsigned char* newBaseOctCode; | |
| 1398 | + const unsigned char* newBaseOctCode; | |
| 1397 | 1399 | }; |
| 1398 | 1400 | |
| 1399 | 1401 | bool Application::sendVoxelsOperation(VoxelNode* node, void* extraData) { |
| 1400 | 1402 | SendVoxelsOperationArgs* args = (SendVoxelsOperationArgs*)extraData; |
| 1401 | 1403 | if (node->isColored()) { |
| 1402 | − unsigned char* nodeOctalCode = node->getOctalCode(); | |
| 1404 | + const unsigned char* nodeOctalCode = node->getOctalCode(); | |
| 1403 | 1405 | |
| 1404 | 1406 | unsigned char* codeColorBuffer = NULL; |
| 1405 | 1407 | int codeLength = 0; |
| @@ -1561,29 +1563,6 @@ void Application::deleteVoxels() { · 155 unmodified lines | ||
| 1561 | 1563 | deleteVoxelUnderCursor(); |
| 1562 | 1564 | } |
| 1563 | 1565 | |
| 1564 | −void Application::setListenModeNormal() { | |
| 1565 | − _audio.setListenMode(AudioRingBuffer::NORMAL); | |
| 1566 | −} | |
| 1567 | − | |
| 1568 | −void Application::setListenModePoint() { | |
| 1569 | − _audio.setListenMode(AudioRingBuffer::OMNI_DIRECTIONAL_POINT); | |
| 1570 | − _audio.setListenRadius(1.0); | |
| 1571 | −} | |
| 1572 | − | |
| 1573 | −void Application::setListenModeSingleSource() { | |
| 1574 | − _audio.setListenMode(AudioRingBuffer::SELECTED_SOURCES); | |
| 1575 | − _audio.clearListenSources(); | |
| 1576 | − | |
| 1577 | − glm::vec3 mouseRayOrigin = _myAvatar.getMouseRayOrigin(); | |
| 1578 | − glm::vec3 mouseRayDirection = _myAvatar.getMouseRayDirection(); | |
| 1579 | − glm::vec3 eyePositionIgnored; | |
| 1580 | − uint16_t nodeID; | |
| 1581 | − | |
| 1582 | − if (findLookatTargetAvatar(mouseRayOrigin, mouseRayDirection, eyePositionIgnored, nodeID)) { | |
| 1583 | − _audio.addListenSource(nodeID); | |
| 1584 | − } | |
| 1585 | −} | |
| 1586 | − | |
| 1587 | 1566 | void Application::initDisplay() { |
| 1588 | 1567 | glEnable(GL_BLEND); |
| 1589 | 1568 | glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_CONSTANT_ALPHA, GL_ONE); |
| @@ -1690,7 +1669,7 @@ const float MAX_AVATAR_EDIT_VELOCITY = 1.0f; · 100 unmodified lines | ||
| 1690 | 1669 | const float MAX_VOXEL_EDIT_DISTANCE = 20.0f; |
| 1691 | 1670 | const float HEAD_SPHERE_RADIUS = 0.07; |
| 1692 | 1671 | |
| 1693 | −static uint16_t DEFAULT_NODE_ID_REF = 1; | |
| 1672 | +static QUuid DEFAULT_NODE_ID_REF; | |
| 1694 | 1673 | |
| 1695 | 1674 | void Application::updateLookatTargetAvatar(const glm::vec3& mouseRayOrigin, const glm::vec3& mouseRayDirection, |
| 1696 | 1675 | glm::vec3& eyePosition) { |
| @@ -1699,7 +1678,7 @@ void Application::updateLookatTargetAvatar(const glm::vec3& mouseRayOrigin, cons · 2 unmodified lines | ||
| 1699 | 1678 | } |
| 1700 | 1679 | |
| 1701 | 1680 | Avatar* Application::findLookatTargetAvatar(const glm::vec3& mouseRayOrigin, const glm::vec3& mouseRayDirection, |
| 1702 | − glm::vec3& eyePosition, uint16_t& nodeID = DEFAULT_NODE_ID_REF) { | |
| 1681 | + glm::vec3& eyePosition, QUuid& nodeUUID = DEFAULT_NODE_ID_REF) { | |
| 1703 | 1682 | |
| 1704 | 1683 | NodeList* nodeList = NodeList::getInstance(); |
| 1705 | 1684 | for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) { |
| @@ -1712,7 +1691,7 @@ Avatar* Application::findLookatTargetAvatar(const glm::vec3& mouseRayOrigin, con · 6 unmodified lines | ||
| 1712 | 1691 | eyePosition = avatar->getHead().getEyePosition(); |
| 1713 | 1692 | _lookatIndicatorScale = avatar->getHead().getScale(); |
| 1714 | 1693 | _lookatOtherPosition = headPosition; |
| 1715 | − nodeID = avatar->getOwningNode()->getNodeID(); | |
| 1694 | + nodeUUID = avatar->getOwningNode()->getUUID(); | |
| 1716 | 1695 | return avatar; |
| 1717 | 1696 | } |
| 1718 | 1697 | } |
| @@ -1761,12 +1740,12 @@ void Application::renderFollowIndicator() { · 42 unmodified lines | ||
| 1761 | 1740 | Avatar* avatar = (Avatar *) node->getLinkedData(); |
| 1762 | 1741 | Avatar* leader = NULL; |
| 1763 | 1742 | |
| 1764 | − if (avatar->getLeaderID() != UNKNOWN_NODE_ID) { | |
| 1765 | − if (avatar->getLeaderID() == NodeList::getInstance()->getOwnerID()) { | |
| 1743 | + if (!avatar->getLeaderUUID().isNull()) { | |
| 1744 | + if (avatar->getLeaderUUID() == NodeList::getInstance()->getOwnerUUID()) { | |
| 1766 | 1745 | leader = &_myAvatar; |
| 1767 | 1746 | } else { |
| 1768 | 1747 | for (NodeList::iterator it = nodeList->begin(); it != nodeList->end(); ++it) { |
| 1769 | − if(it->getNodeID() == avatar->getLeaderID() | |
| 1748 | + if(it->getUUID() == avatar->getLeaderUUID() | |
| 1770 | 1749 | && it->getType() == NODE_TYPE_AGENT) { |
| 1771 | 1750 | leader = (Avatar*) it->getLinkedData(); |
| 1772 | 1751 | } |
| @@ -2246,26 +2225,27 @@ void Application::updateAvatar(float deltaTime) { · 473 unmodified lines | ||
| 2246 | 2225 | _myAvatar.setCameraEyeOffsetPosition(_viewFrustum.getEyeOffsetPosition()); |
| 2247 | 2226 | |
| 2248 | 2227 | NodeList* nodeList = NodeList::getInstance(); |
| 2249 | − if (nodeList->getOwnerID() != UNKNOWN_NODE_ID) { | |
| 2250 | − // if I know my ID, send head/hand data to the avatar mixer and voxel server | |
| 2251 | − unsigned char broadcastString[MAX_PACKET_SIZE]; | |
| 2252 | − unsigned char* endOfBroadcastStringWrite = broadcastString; | |
| 2253 | − | |
| 2254 | − endOfBroadcastStringWrite += populateTypeAndVersion(endOfBroadcastStringWrite, PACKET_TYPE_HEAD_DATA); | |
| 2255 | − | |
| 2256 | − endOfBroadcastStringWrite += packNodeId(endOfBroadcastStringWrite, nodeList->getOwnerID()); | |
| 2257 | − | |
| 2258 | − endOfBroadcastStringWrite += _myAvatar.getBroadcastData(endOfBroadcastStringWrite); | |
| 2259 | − | |
| 2260 | − const char nodeTypesOfInterest[] = { NODE_TYPE_VOXEL_SERVER, NODE_TYPE_AVATAR_MIXER }; | |
| 2261 | − controlledBroadcastToNodes(broadcastString, endOfBroadcastStringWrite - broadcastString, | |
| 2262 | − nodeTypesOfInterest, sizeof(nodeTypesOfInterest)); | |
| 2263 | − | |
| 2264 | − // once in a while, send my urls | |
| 2265 | − const float AVATAR_URLS_SEND_INTERVAL = 1.0f; // seconds | |
| 2266 | − if (shouldDo(AVATAR_URLS_SEND_INTERVAL, deltaTime)) { | |
| 2267 | − Avatar::sendAvatarURLsMessage(_myAvatar.getVoxels()->getVoxelURL()); | |
| 2268 | − } | |
| 2228 | + | |
| 2229 | + // send head/hand data to the avatar mixer and voxel server | |
| 2230 | + unsigned char broadcastString[MAX_PACKET_SIZE]; | |
| 2231 | + unsigned char* endOfBroadcastStringWrite = broadcastString; | |
| 2232 | + | |
| 2233 | + endOfBroadcastStringWrite += populateTypeAndVersion(endOfBroadcastStringWrite, PACKET_TYPE_HEAD_DATA); | |
| 2234 | + | |
| 2235 | + QByteArray ownerUUID = nodeList->getOwnerUUID().toRfc4122(); | |
| 2236 | + memcpy(endOfBroadcastStringWrite, ownerUUID.constData(), ownerUUID.size()); | |
| 2237 | + endOfBroadcastStringWrite += ownerUUID.size(); | |
| 2238 | + | |
| 2239 | + endOfBroadcastStringWrite += _myAvatar.getBroadcastData(endOfBroadcastStringWrite); | |
| 2240 | + | |
| 2241 | + const char nodeTypesOfInterest[] = { NODE_TYPE_VOXEL_SERVER, NODE_TYPE_AVATAR_MIXER }; | |
| 2242 | + controlledBroadcastToNodes(broadcastString, endOfBroadcastStringWrite - broadcastString, | |
| 2243 | + nodeTypesOfInterest, sizeof(nodeTypesOfInterest)); | |
| 2244 | + | |
| 2245 | + // once in a while, send my urls | |
| 2246 | + const float AVATAR_URLS_SEND_INTERVAL = 1.0f; // seconds | |
| 2247 | + if (shouldDo(AVATAR_URLS_SEND_INTERVAL, deltaTime)) { | |
| 2248 | + Avatar::sendAvatarURLsMessage(_myAvatar.getVoxels()->getVoxelURL()); | |
| 2269 | 2249 | } |
| 2270 | 2250 | } |
| 2271 | 2251 | |
| @@ -2806,24 +2786,40 @@ void Application::displayOverlay() { · 534 unmodified lines | ||
| 2806 | 2786 | if (Menu::getInstance()->isOptionChecked(MenuOption::HeadMouse) |
| 2807 | 2787 | && !Menu::getInstance()->isOptionChecked(MenuOption::Mirror) |
| 2808 | 2788 | && USING_INVENSENSE_MPU9150) { |
| 2809 | − // Display small target box at center or head mouse target that can also be used to measure LOD | |
| 2810 | − glColor3f(1.0, 1.0, 1.0); | |
| 2789 | + // Display small target box at center or head mouse target that can also be used to measure LOD | |
| 2790 | + glColor3f(1.0, 1.0, 1.0); | |
| 2791 | + glDisable(GL_LINE_SMOOTH); | |
| 2792 | + const int PIXEL_BOX = 16; | |
| 2793 | + glBegin(GL_LINES); | |
| 2794 | + glVertex2f(_headMouseX - PIXEL_BOX/2, _headMouseY); | |
| 2795 | + glVertex2f(_headMouseX + PIXEL_BOX/2, _headMouseY); | |
| 2796 | + glVertex2f(_headMouseX, _headMouseY - PIXEL_BOX/2); | |
| 2797 | + glVertex2f(_headMouseX, _headMouseY + PIXEL_BOX/2); | |
| 2798 | + glEnd(); | |
| 2799 | + glEnable(GL_LINE_SMOOTH); | |
| 2800 | + glColor3f(1.f, 0.f, 0.f); | |
| 2801 | + glPointSize(3.0f); | |
| 2802 | + glDisable(GL_POINT_SMOOTH); | |
| 2803 | + glBegin(GL_POINTS); | |
| 2804 | + glVertex2f(_headMouseX - 1, _headMouseY + 1); | |
| 2805 | + glEnd(); | |
| 2806 | + // If Faceshift is active, show eye pitch and yaw as separate pointer | |
| 2807 | + if (_faceshift.isActive()) { | |
| 2808 | + const float EYE_TARGET_PIXELS_PER_DEGREE = 40.0; | |
| 2809 | + int eyeTargetX = (_glWidget->width() / 2) - _faceshift.getEstimatedEyeYaw() * EYE_TARGET_PIXELS_PER_DEGREE; | |
| 2810 | + int eyeTargetY = (_glWidget->height() / 2) - _faceshift.getEstimatedEyePitch() * EYE_TARGET_PIXELS_PER_DEGREE; | |
| 2811 | + | |
| 2812 | + glColor3f(0.0, 1.0, 1.0); | |
| 2811 | 2813 | glDisable(GL_LINE_SMOOTH); |
| 2812 | − const int PIXEL_BOX = 16; | |
| 2813 | 2814 | glBegin(GL_LINES); |
| 2814 | − glVertex2f(_headMouseX - PIXEL_BOX/2, _headMouseY); | |
| 2815 | − glVertex2f(_headMouseX + PIXEL_BOX/2, _headMouseY); | |
| 2816 | − glVertex2f(_headMouseX, _headMouseY - PIXEL_BOX/2); | |
| 2817 | − glVertex2f(_headMouseX, _headMouseY + PIXEL_BOX/2); | |
| 2818 | − glEnd(); | |
| 2819 | − glEnable(GL_LINE_SMOOTH); | |
| 2820 | − glColor3f(1.f, 0.f, 0.f); | |
| 2821 | − glPointSize(3.0f); | |
| 2822 | − glDisable(GL_POINT_SMOOTH); | |
| 2823 | − glBegin(GL_POINTS); | |
| 2824 | − glVertex2f(_headMouseX - 1, _headMouseY + 1); | |
| 2815 | + glVertex2f(eyeTargetX - PIXEL_BOX/2, eyeTargetY); | |
| 2816 | + glVertex2f(eyeTargetX + PIXEL_BOX/2, eyeTargetY); | |
| 2817 | + glVertex2f(eyeTargetX, eyeTargetY - PIXEL_BOX/2); | |
| 2818 | + glVertex2f(eyeTargetX, eyeTargetY + PIXEL_BOX/2); | |
| 2825 | 2819 | glEnd(); |
| 2820 | + | |
| 2826 | 2821 | } |
| 2822 | + } | |
| 2827 | 2823 | |
| 2828 | 2824 | // Show detected levels from the serial I/O ADC channel sensors |
| 2829 | 2825 | if (_displayLevels) _serialHeadSensor.renderLevels(_glWidget->width(), _glWidget->height()); |
| @@ -3559,8 +3555,8 @@ void Application::toggleFollowMode() { · 729 unmodified lines | ||
| 3559 | 3555 | _pieMenu.getY() / (float)_glWidget->height(), |
| 3560 | 3556 | mouseRayOrigin, mouseRayDirection); |
| 3561 | 3557 | glm::vec3 eyePositionIgnored; |
| 3562 | − uint16_t nodeIDIgnored; | |
| 3563 | − Avatar* leadingAvatar = findLookatTargetAvatar(mouseRayOrigin, mouseRayDirection, eyePositionIgnored, nodeIDIgnored); | |
| 3558 | + QUuid nodeUUIDIgnored; | |
| 3559 | + Avatar* leadingAvatar = findLookatTargetAvatar(mouseRayOrigin, mouseRayDirection, eyePositionIgnored, nodeUUIDIgnored); | |
| 3564 | 3560 | |
| 3565 | 3561 | _myAvatar.follow(leadingAvatar); |
| 3566 | 3562 | } |
| @@ -3628,10 +3624,10 @@ void Application::nodeAdded(Node* node) { · 61 unmodified lines | ||
| 3628 | 3624 | |
| 3629 | 3625 | void Application::nodeKilled(Node* node) { |
| 3630 | 3626 | if (node->getType() == NODE_TYPE_VOXEL_SERVER) { |
| 3631 | − uint16_t nodeID = node->getNodeID(); | |
| 3627 | + QUuid nodeUUID = node->getUUID(); | |
| 3632 | 3628 | // see if this is the first we've heard of this node... |
| 3633 | − if (_voxelServerJurisdictions.find(nodeID) != _voxelServerJurisdictions.end()) { | |
| 3634 | − unsigned char* rootCode = _voxelServerJurisdictions[nodeID].getRootOctalCode(); | |
| 3629 | + if (_voxelServerJurisdictions.find(nodeUUID) != _voxelServerJurisdictions.end()) { | |
| 3630 | + unsigned char* rootCode = _voxelServerJurisdictions[nodeUUID].getRootOctalCode(); | |
| 3635 | 3631 | VoxelPositionSize rootDetails; |
| 3636 | 3632 | voxelDetailsForCode(rootCode, rootDetails); |
| 3637 | 3633 | |
| @@ -3661,13 +3657,13 @@ int Application::parseVoxelStats(unsigned char* messageData, ssize_t messageLeng · 23 unmodified lines | ||
| 3661 | 3657 | |
| 3662 | 3658 | // quick fix for crash... why would voxelServer be NULL? |
| 3663 | 3659 | if (voxelServer) { |
| 3664 | − uint16_t nodeID = voxelServer->getNodeID(); | |
| 3660 | + QUuid nodeUUID = voxelServer->getUUID(); | |
| 3665 | 3661 | |
| 3666 | 3662 | VoxelPositionSize rootDetails; |
| 3667 | 3663 | voxelDetailsForCode(_voxelSceneStats.getJurisdictionRoot(), rootDetails); |
| 3668 | 3664 | |
| 3669 | 3665 | // see if this is the first we've heard of this node... |
| 3670 | − if (_voxelServerJurisdictions.find(nodeID) == _voxelServerJurisdictions.end()) { | |
| 3666 | + if (_voxelServerJurisdictions.find(nodeUUID) == _voxelServerJurisdictions.end()) { | |
| 3671 | 3667 | printf("stats from new voxel server... v[%f, %f, %f, %f]\n", |
| 3672 | 3668 | rootDetails.x, rootDetails.y, rootDetails.z, rootDetails.s); |
| 3673 | 3669 | |
| @@ -3684,7 +3680,7 @@ int Application::parseVoxelStats(unsigned char* messageData, ssize_t messageLeng · 10 unmodified lines | ||
| 3684 | 3680 | // details from the VoxelSceneStats to construct the JurisdictionMap |
| 3685 | 3681 | JurisdictionMap jurisdictionMap; |
| 3686 | 3682 | jurisdictionMap.copyContents(_voxelSceneStats.getJurisdictionRoot(), _voxelSceneStats.getJurisdictionEndNodes()); |
| 3687 | − _voxelServerJurisdictions[nodeID] = jurisdictionMap; | |
| 3683 | + _voxelServerJurisdictions[nodeUUID] = jurisdictionMap; | |
| 3688 | 3684 | } |
| 3689 | 3685 | return statsMessageLength; |
| 3690 | 3686 | } |