History

Merge branch 'master' of https://github.com/worklist/hifi into ossome

Andrzej Kapolka committed 13 years ago

Commit 778e4322 parents c8b2ed0 2cf762d68 files · +2191 −1383Browse files

Showing the changes to interface/src/Application.cpp (1 of 68 files). Show all

Unified · Split

interface/src/Application.cpp+77−81
@@ -54,7 +54,7 @@ · 53 unmodified lines
5454 #include <PacketHeaders.h>
5555 #include <PairingHandler.h>
5656 #include <PerfStat.h>
57−
57+#include <UUID.h>
5858 #include <VoxelSceneStats.h>
5959
6060 #include "Application.h"
@@ -500,7 +500,7 @@ void Application::controlledBroadcastToNodes(unsigned char* broadcastData, size_ · 439 unmodified lines
500500 if (nodeTypes[i] == NODE_TYPE_VOXEL_SERVER && !Menu::getInstance()->isOptionChecked(MenuOption::Voxels)) {
501501 continue;
502502 }
503−
503+
504504 // Perform the broadcast for one type
505505 int nReceivingNodes = NodeList::getInstance()->broadcastToNodes(broadcastData, dataBytes, & nodeTypes[i], 1);
506506
@@ -1160,8 +1160,9 @@ void Application::sendAvatarFaceVideoMessage(int frameCount, const QByteArray& d · 653 unmodified lines
11601160
11611161 packetPosition += populateTypeAndVersion(packetPosition, PACKET_TYPE_AVATAR_FACE_VIDEO);
11621162
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();
11651166
11661167 *(uint32_t*)packetPosition = frameCount;
11671168 packetPosition += sizeof(uint32_t);
@@ -1295,12 +1296,13 @@ static Avatar* processAvatarMessageHeader(unsigned char*& packetData, size_t& da · 127 unmodified lines
12951296 dataBytes -= numBytesPacketHeader;
12961297
12971298 // 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;
13011303
13021304 // make sure the node exists
1303− Node* node = NodeList::getInstance()->nodeWithID(nodeID);
1305+ Node* node = NodeList::getInstance()->nodeWithUUID(nodeUUID);
13041306 if (!node || !node->getLinkedData()) {
13051307 return NULL;
13061308 }
@@ -1393,13 +1395,13 @@ void Application::increaseVoxelSize() { · 86 unmodified lines
13931395
13941396 const int MAXIMUM_EDIT_VOXEL_MESSAGE_SIZE = 1500;
13951397 struct SendVoxelsOperationArgs {
1396− unsigned char* newBaseOctCode;
1398+ const unsigned char* newBaseOctCode;
13971399 };
13981400
13991401 bool Application::sendVoxelsOperation(VoxelNode* node, void* extraData) {
14001402 SendVoxelsOperationArgs* args = (SendVoxelsOperationArgs*)extraData;
14011403 if (node->isColored()) {
1402− unsigned char* nodeOctalCode = node->getOctalCode();
1404+ const unsigned char* nodeOctalCode = node->getOctalCode();
14031405
14041406 unsigned char* codeColorBuffer = NULL;
14051407 int codeLength = 0;
@@ -1561,29 +1563,6 @@ void Application::deleteVoxels() { · 155 unmodified lines
15611563 deleteVoxelUnderCursor();
15621564 }
15631565
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−
15871566 void Application::initDisplay() {
15881567 glEnable(GL_BLEND);
15891568 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
16901669 const float MAX_VOXEL_EDIT_DISTANCE = 20.0f;
16911670 const float HEAD_SPHERE_RADIUS = 0.07;
16921671
1693−static uint16_t DEFAULT_NODE_ID_REF = 1;
1672+static QUuid DEFAULT_NODE_ID_REF;
16941673
16951674 void Application::updateLookatTargetAvatar(const glm::vec3& mouseRayOrigin, const glm::vec3& mouseRayDirection,
16961675 glm::vec3& eyePosition) {
@@ -1699,7 +1678,7 @@ void Application::updateLookatTargetAvatar(const glm::vec3& mouseRayOrigin, cons · 2 unmodified lines
16991678 }
17001679
17011680 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) {
17031682
17041683 NodeList* nodeList = NodeList::getInstance();
17051684 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
17121691 eyePosition = avatar->getHead().getEyePosition();
17131692 _lookatIndicatorScale = avatar->getHead().getScale();
17141693 _lookatOtherPosition = headPosition;
1715− nodeID = avatar->getOwningNode()->getNodeID();
1694+ nodeUUID = avatar->getOwningNode()->getUUID();
17161695 return avatar;
17171696 }
17181697 }
@@ -1761,12 +1740,12 @@ void Application::renderFollowIndicator() { · 42 unmodified lines
17611740 Avatar* avatar = (Avatar *) node->getLinkedData();
17621741 Avatar* leader = NULL;
17631742
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()) {
17661745 leader = &_myAvatar;
17671746 } else {
17681747 for (NodeList::iterator it = nodeList->begin(); it != nodeList->end(); ++it) {
1769− if(it->getNodeID() == avatar->getLeaderID()
1748+ if(it->getUUID() == avatar->getLeaderUUID()
17701749 && it->getType() == NODE_TYPE_AGENT) {
17711750 leader = (Avatar*) it->getLinkedData();
17721751 }
@@ -2246,26 +2225,27 @@ void Application::updateAvatar(float deltaTime) { · 473 unmodified lines
22462225 _myAvatar.setCameraEyeOffsetPosition(_viewFrustum.getEyeOffsetPosition());
22472226
22482227 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());
22692249 }
22702250 }
22712251
@@ -2806,24 +2786,40 @@ void Application::displayOverlay() { · 534 unmodified lines
28062786 if (Menu::getInstance()->isOptionChecked(MenuOption::HeadMouse)
28072787 && !Menu::getInstance()->isOptionChecked(MenuOption::Mirror)
28082788 && 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);
28112813 glDisable(GL_LINE_SMOOTH);
2812− const int PIXEL_BOX = 16;
28132814 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);
28252819 glEnd();
2820+
28262821 }
2822+ }
28272823
28282824 // Show detected levels from the serial I/O ADC channel sensors
28292825 if (_displayLevels) _serialHeadSensor.renderLevels(_glWidget->width(), _glWidget->height());
@@ -3559,8 +3555,8 @@ void Application::toggleFollowMode() { · 729 unmodified lines
35593555 _pieMenu.getY() / (float)_glWidget->height(),
35603556 mouseRayOrigin, mouseRayDirection);
35613557 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);
35643560
35653561 _myAvatar.follow(leadingAvatar);
35663562 }
@@ -3628,10 +3624,10 @@ void Application::nodeAdded(Node* node) { · 61 unmodified lines
36283624
36293625 void Application::nodeKilled(Node* node) {
36303626 if (node->getType() == NODE_TYPE_VOXEL_SERVER) {
3631− uint16_t nodeID = node->getNodeID();
3627+ QUuid nodeUUID = node->getUUID();
36323628 // 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();
36353631 VoxelPositionSize rootDetails;
36363632 voxelDetailsForCode(rootCode, rootDetails);
36373633
@@ -3661,13 +3657,13 @@ int Application::parseVoxelStats(unsigned char* messageData, ssize_t messageLeng · 23 unmodified lines
36613657
36623658 // quick fix for crash... why would voxelServer be NULL?
36633659 if (voxelServer) {
3664− uint16_t nodeID = voxelServer->getNodeID();
3660+ QUuid nodeUUID = voxelServer->getUUID();
36653661
36663662 VoxelPositionSize rootDetails;
36673663 voxelDetailsForCode(_voxelSceneStats.getJurisdictionRoot(), rootDetails);
36683664
36693665 // 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()) {
36713667 printf("stats from new voxel server... v[%f, %f, %f, %f]\n",
36723668 rootDetails.x, rootDetails.y, rootDetails.z, rootDetails.s);
36733669
@@ -3684,7 +3680,7 @@ int Application::parseVoxelStats(unsigned char* messageData, ssize_t messageLeng · 10 unmodified lines
36843680 // details from the VoxelSceneStats to construct the JurisdictionMap
36853681 JurisdictionMap jurisdictionMap;
36863682 jurisdictionMap.copyContents(_voxelSceneStats.getJurisdictionRoot(), _voxelSceneStats.getJurisdictionEndNodes());
3687− _voxelServerJurisdictions[nodeID] = jurisdictionMap;
3683+ _voxelServerJurisdictions[nodeUUID] = jurisdictionMap;
36883684 }
36893685 return statsMessageLength;
36903686 }

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