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

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