Showing the changes to interface/src/Application.cpp (1 of 107 files). Show all
Unified · Split
| @@ -92,15 +92,15 @@ const float MIRROR_REARVIEW_BODY_DISTANCE = 2.3f; · 91 unmodified lines | |||
| 92 | const QString CHECK_VERSION_URL = "http://highfidelity.io/latestVersion.xml"; | 92 | const QString CHECK_VERSION_URL = "http://highfidelity.io/latestVersion.xml"; |
| 93 | 93 | ||
| 94 | void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString &message) { | 94 | void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString &message) { |
| 95 | fprintf(stdout, "%s", message.toLocal8Bit().constData()); | 95 | QString messageWithNewLine = message + "\n"; |
| 96 | Application::getInstance()->getLogger()->addMessage(message.toLocal8Bit().constData()); | 96 | fprintf(stdout, "%s", messageWithNewLine.toLocal8Bit().constData()); |
| 97 | Application::getInstance()->getLogger()->addMessage(messageWithNewLine.toLocal8Bit().constData()); | ||
| 97 | } | 98 | } |
| 98 | 99 | ||
| 99 | Application::Application(int& argc, char** argv, timeval &startup_time) : | 100 | Application::Application(int& argc, char** argv, timeval &startup_time) : |
| 100 | QApplication(argc, argv), | 101 | QApplication(argc, argv), |
| 101 | _window(new QMainWindow(desktop())), | 102 | _window(new QMainWindow(desktop())), |
| 102 | _glWidget(new GLCanvas()), | 103 | _glWidget(new GLCanvas()), |
| 103 | _displayLevels(false), | ||
| 104 | _frameCount(0), | 104 | _frameCount(0), |
| 105 | _fps(120.0f), | 105 | _fps(120.0f), |
| 106 | _justStarted(true), | 106 | _justStarted(true), |
| @@ -134,7 +134,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 27 unmodified lines | |||
| 134 | _perfStatsOn(false), | 134 | _perfStatsOn(false), |
| 135 | _chatEntryOn(false), | 135 | _chatEntryOn(false), |
| 136 | _audio(&_audioScope, STARTUP_JITTER_SAMPLES), | 136 | _audio(&_audioScope, STARTUP_JITTER_SAMPLES), |
| 137 | _stopNetworkReceiveThread(false), | 137 | _enableProcessVoxelsThread(true), |
| 138 | _voxelProcessor(), | 138 | _voxelProcessor(), |
| 139 | _voxelHideShowThread(&_voxels), | 139 | _voxelHideShowThread(&_voxels), |
| 140 | _voxelEditSender(this), | 140 | _voxelEditSender(this), |
| @@ -169,6 +169,9 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 28 unmodified lines | |||
| 169 | } | 169 | } |
| 170 | 170 | ||
| 171 | NodeList* nodeList = NodeList::createInstance(NODE_TYPE_AGENT, listenPort); | 171 | NodeList* nodeList = NodeList::createInstance(NODE_TYPE_AGENT, listenPort); |
| 172 | |||
| 173 | // connect our processDatagrams slot to the QUDPSocket readyRead() signal | ||
| 174 | connect(&nodeList->getNodeSocket(), SIGNAL(readyRead()), SLOT(processDatagrams())); | ||
| 172 | 175 | ||
| 173 | // put the audio processing on a separate thread | 176 | // put the audio processing on a separate thread |
| 174 | QThread* audioThread = new QThread(this); | 177 | QThread* audioThread = new QThread(this); |
| @@ -177,13 +180,12 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 2 unmodified lines | |||
| 177 | connect(audioThread, SIGNAL(started()), &_audio, SLOT(start())); | 180 | connect(audioThread, SIGNAL(started()), &_audio, SLOT(start())); |
| 178 | 181 | ||
| 179 | audioThread->start(); | 182 | audioThread->start(); |
| 183 | |||
| 184 | connect(nodeList, SIGNAL(domainChanged(const QString&)), SLOT(domainChanged(const QString&))); | ||
| 180 | 185 | ||
| 181 | nodeList->addHook(&_voxels); | 186 | connect(nodeList, SIGNAL(nodeKilled(SharedNodePointer)), SLOT(nodeKilled(SharedNodePointer))); |
| 182 | nodeList->addHook(this); | 187 | connect(nodeList, SIGNAL(nodeAdded(SharedNodePointer)), &_voxels, SLOT(nodeAdded(SharedNodePointer))); |
| 183 | nodeList->addDomainListener(this); | 188 | connect(nodeList, SIGNAL(nodeKilled(SharedNodePointer)), &_voxels, SLOT(nodeKilled(SharedNodePointer))); |
| 184 | |||
| 185 | // network receive thread and voxel parsing thread are both controlled by the --nonblocking command line | ||
| 186 | _enableProcessVoxelsThread = _enableNetworkThread = !cmdOptionExists(argc, constArgv, "--nonblocking"); | ||
| 187 | 189 | ||
| 188 | // read the ApplicationInfo.ini file for Name/Version/Domain information | 190 | // read the ApplicationInfo.ini file for Name/Version/Domain information |
| 189 | QSettings applicationInfo("resources/info/ApplicationInfo.ini", QSettings::IniFormat); | 191 | QSettings applicationInfo("resources/info/ApplicationInfo.ini", QSettings::IniFormat); |
| @@ -279,9 +281,6 @@ Application::~Application() { · 89 unmodified lines | |||
| 279 | _audio.thread()->wait(); | 281 | _audio.thread()->wait(); |
| 280 | 282 | ||
| 281 | storeSizeAndPosition(); | 283 | storeSizeAndPosition(); |
| 282 | NodeList::getInstance()->removeHook(&_voxels); | ||
| 283 | NodeList::getInstance()->removeHook(this); | ||
| 284 | NodeList::getInstance()->removeDomainListener(this); | ||
| 285 | 284 | ||
| 286 | _sharedVoxelSystem.changeTree(new VoxelTree); | 285 | _sharedVoxelSystem.changeTree(new VoxelTree); |
| 287 | 286 | ||
| @@ -290,7 +289,6 @@ Application::~Application() { · 2 unmodified lines | |||
| 290 | 289 | ||
| 291 | delete _logger; | 290 | delete _logger; |
| 292 | delete _settings; | 291 | delete _settings; |
| 293 | delete _followMode; | ||
| 294 | delete _glWidget; | 292 | delete _glWidget; |
| 295 | } | 293 | } |
| 296 | 294 | ||
| @@ -326,7 +324,7 @@ void Application::storeSizeAndPosition() { · 29 unmodified lines | |||
| 326 | } | 324 | } |
| 327 | 325 | ||
| 328 | void Application::initializeGL() { | 326 | void Application::initializeGL() { |
| 329 | qDebug( "Created Display Window.\n" ); | 327 | qDebug( "Created Display Window."); |
| 330 | 328 | ||
| 331 | // initialize glut for shape drawing; Qt apparently initializes it on OS X | 329 | // initialize glut for shape drawing; Qt apparently initializes it on OS X |
| 332 | #ifndef __APPLE__ | 330 | #ifndef __APPLE__ |
| @@ -341,16 +339,10 @@ void Application::initializeGL() { · 8 unmodified lines | |||
| 341 | _viewFrustumOffsetCamera.setFarClip(500.0 * TREE_SCALE); | 339 | _viewFrustumOffsetCamera.setFarClip(500.0 * TREE_SCALE); |
| 342 | 340 | ||
| 343 | initDisplay(); | 341 | initDisplay(); |
| 344 | qDebug( "Initialized Display.\n" ); | 342 | qDebug( "Initialized Display."); |
| 345 | 343 | ||
| 346 | init(); | 344 | init(); |
| 347 | qDebug( "Init() complete.\n" ); | 345 | qDebug( "init() complete."); |
| 348 | |||
| 349 | // create thread for receipt of data via UDP | ||
| 350 | if (_enableNetworkThread) { | ||
| 351 | pthread_create(&_networkReceiveThread, NULL, networkReceive, NULL); | ||
| 352 | qDebug("Network receive thread created.\n"); | ||
| 353 | } | ||
| 354 | 346 | ||
| 355 | // create thread for parsing of voxel data independent of the main network and rendering threads | 347 | // create thread for parsing of voxel data independent of the main network and rendering threads |
| 356 | _voxelProcessor.initialize(_enableProcessVoxelsThread); | 348 | _voxelProcessor.initialize(_enableProcessVoxelsThread); |
| @@ -358,7 +350,7 @@ void Application::initializeGL() { · 1 unmodified line | |||
| 358 | _voxelHideShowThread.initialize(_enableProcessVoxelsThread); | 350 | _voxelHideShowThread.initialize(_enableProcessVoxelsThread); |
| 359 | _particleEditSender.initialize(_enableProcessVoxelsThread); | 351 | _particleEditSender.initialize(_enableProcessVoxelsThread); |
| 360 | if (_enableProcessVoxelsThread) { | 352 | if (_enableProcessVoxelsThread) { |
| 361 | qDebug("Voxel parsing thread created.\n"); | 353 | qDebug("Voxel parsing thread created."); |
| 362 | } | 354 | } |
| 363 | 355 | ||
| 364 | // call terminate before exiting | 356 | // call terminate before exiting |
| @@ -378,9 +370,7 @@ void Application::initializeGL() { · 13 unmodified lines | |||
| 378 | if (_justStarted) { | 370 | if (_justStarted) { |
| 379 | float startupTime = (usecTimestampNow() - usecTimestamp(&_applicationStartupTime)) / 1000000.0; | 371 | float startupTime = (usecTimestampNow() - usecTimestamp(&_applicationStartupTime)) / 1000000.0; |
| 380 | _justStarted = false; | 372 | _justStarted = false; |
| 381 | char title[50]; | 373 | qDebug("Startup time: %4.2f seconds.", startupTime); |
| 382 | sprintf(title, "Interface: %4.2f seconds\n", startupTime); | ||
| 383 | qDebug("%s", title); | ||
| 384 | const char LOGSTASH_INTERFACE_START_TIME_KEY[] = "interface-start-time"; | 374 | const char LOGSTASH_INTERFACE_START_TIME_KEY[] = "interface-start-time"; |
| 385 | 375 | ||
| 386 | // ask the Logstash class to record the startup time | 376 | // ask the Logstash class to record the startup time |
| @@ -687,9 +677,7 @@ void Application::keyPressEvent(QKeyEvent* event) { · 300 unmodified lines | |||
| 687 | _audioScope.inputPaused = !_audioScope.inputPaused; | 677 | _audioScope.inputPaused = !_audioScope.inputPaused; |
| 688 | break; | 678 | break; |
| 689 | case Qt::Key_L: | 679 | case Qt::Key_L: |
| 690 | if (!isShifted && !isMeta) { | 680 | if (isShifted) { |
| 691 | _displayLevels = !_displayLevels; | ||
| 692 | } else if (isShifted) { | ||
| 693 | Menu::getInstance()->triggerOption(MenuOption::LodTools); | 681 | Menu::getInstance()->triggerOption(MenuOption::LodTools); |
| 694 | } else if (isMeta) { | 682 | } else if (isMeta) { |
| 695 | Menu::getInstance()->triggerOption(MenuOption::Log); | 683 | Menu::getInstance()->triggerOption(MenuOption::Log); |
| @@ -1355,11 +1343,6 @@ void Application::timer() { · 659 unmodified lines | |||
| 1355 | 1343 | ||
| 1356 | gettimeofday(&_timerStart, NULL); | 1344 | gettimeofday(&_timerStart, NULL); |
| 1357 | 1345 | ||
| 1358 | // if we haven't detected gyros, check for them now | ||
| 1359 | if (!_serialHeadSensor.isActive()) { | ||
| 1360 | _serialHeadSensor.pair(); | ||
| 1361 | } | ||
| 1362 | |||
| 1363 | // ask the node list to check in with the domain server | 1346 | // ask the node list to check in with the domain server |
| 1364 | NodeList::getInstance()->sendDomainServerCheckIn(); | 1347 | NodeList::getInstance()->sendDomainServerCheckIn(); |
| 1365 | 1348 | ||
| @@ -1442,11 +1425,6 @@ void Application::terminate() { · 76 unmodified lines | |||
| 1442 | // let the avatar mixer know we're out | 1425 | // let the avatar mixer know we're out |
| 1443 | NodeList::getInstance()->sendKillNode(&NODE_TYPE_AVATAR_MIXER, 1); | 1426 | NodeList::getInstance()->sendKillNode(&NODE_TYPE_AVATAR_MIXER, 1); |
| 1444 | 1427 | ||
| 1445 | if (_enableNetworkThread) { | ||
| 1446 | _stopNetworkReceiveThread = true; | ||
| 1447 | pthread_join(_networkReceiveThread, NULL); | ||
| 1448 | } | ||
| 1449 | |||
| 1450 | printf(""); | 1428 | printf(""); |
| 1451 | _voxelProcessor.terminate(); | 1429 | _voxelProcessor.terminate(); |
| 1452 | _voxelHideShowThread.terminate(); | 1430 | _voxelHideShowThread.terminate(); |
| @@ -1459,7 +1437,7 @@ void Application::terminate() { · 6 unmodified lines | |||
| 1459 | static Avatar* processAvatarMessageHeader(unsigned char*& packetData, size_t& dataBytes) { | 1437 | static Avatar* processAvatarMessageHeader(unsigned char*& packetData, size_t& dataBytes) { |
| 1460 | // record the packet for stats-tracking | 1438 | // record the packet for stats-tracking |
| 1461 | Application::getInstance()->getBandwidthMeter()->inputStream(BandwidthMeter::AVATARS).updateValue(dataBytes); | 1439 | Application::getInstance()->getBandwidthMeter()->inputStream(BandwidthMeter::AVATARS).updateValue(dataBytes); |
| 1462 | Node* avatarMixerNode = NodeList::getInstance()->soloNodeOfType(NODE_TYPE_AVATAR_MIXER); | 1440 | SharedNodePointer avatarMixerNode = NodeList::getInstance()->soloNodeOfType(NODE_TYPE_AVATAR_MIXER); |
| 1463 | if (avatarMixerNode) { | 1441 | if (avatarMixerNode) { |
| 1464 | avatarMixerNode->recordBytesReceived(dataBytes); | 1442 | avatarMixerNode->recordBytesReceived(dataBytes); |
| 1465 | } | 1443 | } |
| @@ -1476,7 +1454,7 @@ static Avatar* processAvatarMessageHeader(unsigned char*& packetData, size_t& da · 10 unmodified lines | |||
| 1476 | dataBytes -= NUM_BYTES_RFC4122_UUID; | 1454 | dataBytes -= NUM_BYTES_RFC4122_UUID; |
| 1477 | 1455 | ||
| 1478 | // make sure the node exists | 1456 | // make sure the node exists |
| 1479 | Node* node = NodeList::getInstance()->nodeWithUUID(nodeUUID); | 1457 | SharedNodePointer node = NodeList::getInstance()->nodeWithUUID(nodeUUID); |
| 1480 | if (!node || !node->getLinkedData()) { | 1458 | if (!node || !node->getLinkedData()) { |
| 1481 | return NULL; | 1459 | return NULL; |
| 1482 | } | 1460 | } |
| @@ -1724,9 +1702,9 @@ void Application::exportVoxels() { · 241 unmodified lines | |||
| 1724 | 1702 | ||
| 1725 | void Application::importVoxels() { | 1703 | void Application::importVoxels() { |
| 1726 | if (_voxelImporter.exec()) { | 1704 | if (_voxelImporter.exec()) { |
| 1727 | qDebug("[DEBUG] Import succedded.\n"); | 1705 | qDebug("[DEBUG] Import succeeded."); |
| 1728 | } else { | 1706 | } else { |
| 1729 | qDebug("[DEBUG] Import failed.\n"); | 1707 | qDebug("[DEBUG] Import failed."); |
| 1730 | } | 1708 | } |
| 1731 | 1709 | ||
| 1732 | // restore the main window's active state | 1710 | // restore the main window's active state |
| @@ -1907,7 +1885,7 @@ void Application::init() { · 174 unmodified lines | |||
| 1907 | if (Menu::getInstance()->getAudioJitterBufferSamples() != 0) { | 1885 | if (Menu::getInstance()->getAudioJitterBufferSamples() != 0) { |
| 1908 | _audio.setJitterBufferSamples(Menu::getInstance()->getAudioJitterBufferSamples()); | 1886 | _audio.setJitterBufferSamples(Menu::getInstance()->getAudioJitterBufferSamples()); |
| 1909 | } | 1887 | } |
| 1910 | qDebug("Loaded settings.\n"); | 1888 | qDebug("Loaded settings"); |
| 1911 | 1889 | ||
| 1912 | if (!_profile.getUsername().isEmpty()) { | 1890 | if (!_profile.getUsername().isEmpty()) { |
| 1913 | // we have a username for this avatar, ask the data-server for the mesh URL for this avatar | 1891 | // we have a username for this avatar, ask the data-server for the mesh URL for this avatar |
| @@ -1941,10 +1919,6 @@ void Application::init() { · 27 unmodified lines | |||
| 1941 | _glWidget->width(), | 1919 | _glWidget->width(), |
| 1942 | _glWidget->height()); | 1920 | _glWidget->height()); |
| 1943 | 1921 | ||
| 1944 | _followMode = new QAction(this); | ||
| 1945 | connect(_followMode, SIGNAL(triggered()), this, SLOT(toggleFollowMode())); | ||
| 1946 | _pieMenu.addAction(_followMode); | ||
| 1947 | |||
| 1948 | _audio.init(_glWidget); | 1922 | _audio.init(_glWidget); |
| 1949 | 1923 | ||
| 1950 | _rearMirrorTools = new RearMirrorTools(_glWidget, _mirrorViewRect, _settings); | 1924 | _rearMirrorTools = new RearMirrorTools(_glWidget, _mirrorViewRect, _settings); |
| @@ -2002,16 +1976,16 @@ void Application::updateLookatTargetAvatar(const glm::vec3& mouseRayOrigin, cons · 51 unmodified lines | |||
| 2002 | Avatar* Application::findLookatTargetAvatar(const glm::vec3& mouseRayOrigin, const glm::vec3& mouseRayDirection, | 1976 | Avatar* Application::findLookatTargetAvatar(const glm::vec3& mouseRayOrigin, const glm::vec3& mouseRayDirection, |
| 2003 | glm::vec3& eyePosition, QUuid& nodeUUID = DEFAULT_NODE_ID_REF) { | 1977 | glm::vec3& eyePosition, QUuid& nodeUUID = DEFAULT_NODE_ID_REF) { |
| 2004 | 1978 | ||
| 2005 | NodeList* nodeList = NodeList::getInstance(); | 1979 | foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) { |
| 2006 | for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) { | ||
| 2007 | if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) { | 1980 | if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) { |
| 2008 | Avatar* avatar = (Avatar*)node->getLinkedData(); | 1981 | Avatar* avatar = (Avatar*)node->getLinkedData(); |
| 2009 | float distance; | 1982 | float distance; |
| 1983 | |||
| 2010 | if (avatar->findRayIntersection(mouseRayOrigin, mouseRayDirection, distance)) { | 1984 | if (avatar->findRayIntersection(mouseRayOrigin, mouseRayDirection, distance)) { |
| 2011 | // rescale to compensate for head embiggening | 1985 | // rescale to compensate for head embiggening |
| 2012 | eyePosition = (avatar->getHead().calculateAverageEyePosition() - avatar->getHead().getScalePivot()) * | 1986 | eyePosition = (avatar->getHead().calculateAverageEyePosition() - avatar->getHead().getScalePivot()) * |
| 2013 | (avatar->getScale() / avatar->getHead().getScale()) + avatar->getHead().getScalePivot(); | 1987 | (avatar->getScale() / avatar->getHead().getScale()) + avatar->getHead().getScalePivot(); |
| 2014 | 1988 | ||
| 2015 | _lookatIndicatorScale = avatar->getHead().getScale(); | 1989 | _lookatIndicatorScale = avatar->getHead().getScale(); |
| 2016 | _lookatOtherPosition = avatar->getHead().getPosition(); | 1990 | _lookatOtherPosition = avatar->getHead().getPosition(); |
| 2017 | nodeUUID = avatar->getOwningNode()->getUUID(); | 1991 | nodeUUID = avatar->getOwningNode()->getUUID(); |
| @@ -2019,6 +1993,7 @@ Avatar* Application::findLookatTargetAvatar(const glm::vec3& mouseRayOrigin, con · 1 unmodified line | |||
| 2019 | } | 1993 | } |
| 2020 | } | 1994 | } |
| 2021 | } | 1995 | } |
| 1996 | |||
| 2022 | return NULL; | 1997 | return NULL; |
| 2023 | } | 1998 | } |
| 2024 | 1999 | ||
| @@ -2043,71 +2018,6 @@ void Application::renderLookatIndicator(glm::vec3 pointOfInterest) { · 18 unmodified lines | |||
| 2043 | renderCircle(haloOrigin, INDICATOR_RADIUS, IDENTITY_UP, NUM_SEGMENTS); | 2018 | renderCircle(haloOrigin, INDICATOR_RADIUS, IDENTITY_UP, NUM_SEGMENTS); |
| 2044 | } | 2019 | } |
| 2045 | 2020 | ||
| 2046 | void maybeBeginFollowIndicator(bool& began) { | ||
| 2047 | if (!began) { | ||
| 2048 | Application::getInstance()->getGlowEffect()->begin(); | ||
| 2049 | glLineWidth(5); | ||
| 2050 | glBegin(GL_LINES); | ||
| 2051 | began = true; | ||
| 2052 | } | ||
| 2053 | } | ||
| 2054 | |||
| 2055 | void Application::renderFollowIndicator() { | ||
| 2056 | NodeList* nodeList = NodeList::getInstance(); | ||
| 2057 | |||
| 2058 | // initialize lazily so that we don't enable the glow effect unnecessarily | ||
| 2059 | bool began = false; | ||
| 2060 | |||
| 2061 | for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); ++node) { | ||
| 2062 | if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) { | ||
| 2063 | Avatar* avatar = (Avatar *) node->getLinkedData(); | ||
| 2064 | Avatar* leader = NULL; | ||
| 2065 | |||
| 2066 | if (!avatar->getLeaderUUID().isNull()) { | ||
| 2067 | if (avatar->getLeaderUUID() == NodeList::getInstance()->getOwnerUUID()) { | ||
| 2068 | leader = &_myAvatar; | ||
| 2069 | } else { | ||
| 2070 | for (NodeList::iterator it = nodeList->begin(); it != nodeList->end(); ++it) { | ||
| 2071 | if(it->getUUID() == avatar->getLeaderUUID() | ||
| 2072 | && it->getType() == NODE_TYPE_AGENT) { | ||
| 2073 | leader = (Avatar*) it->getLinkedData(); | ||
| 2074 | } | ||
| 2075 | } | ||
| 2076 | } | ||
| 2077 | |||
| 2078 | if (leader != NULL) { | ||
| 2079 | maybeBeginFollowIndicator(began); | ||
| 2080 | glColor3f(1.f, 0.f, 0.f); | ||
| 2081 | glVertex3f((avatar->getHead().getPosition().x + avatar->getPosition().x) / 2.f, | ||
| 2082 | (avatar->getHead().getPosition().y + avatar->getPosition().y) / 2.f, | ||
| 2083 | (avatar->getHead().getPosition().z + avatar->getPosition().z) / 2.f); | ||
| 2084 | glColor3f(0.f, 1.f, 0.f); | ||
| 2085 | glVertex3f((leader->getHead().getPosition().x + leader->getPosition().x) / 2.f, | ||
| 2086 | (leader->getHead().getPosition().y + leader->getPosition().y) / 2.f, | ||
| 2087 | (leader->getHead().getPosition().z + leader->getPosition().z) / 2.f); | ||
| 2088 | } | ||
| 2089 | } | ||
| 2090 | } | ||
| 2091 | } | ||
| 2092 | |||
| 2093 | if (_myAvatar.getLeadingAvatar() != NULL) { | ||
| 2094 | maybeBeginFollowIndicator(began); | ||
| 2095 | glColor3f(1.f, 0.f, 0.f); | ||
| 2096 | glVertex3f((_myAvatar.getHead().getPosition().x + _myAvatar.getPosition().x) / 2.f, | ||
| 2097 | (_myAvatar.getHead().getPosition().y + _myAvatar.getPosition().y) / 2.f, | ||
| 2098 | (_myAvatar.getHead().getPosition().z + _myAvatar.getPosition().z) / 2.f); | ||
| 2099 | glColor3f(0.f, 1.f, 0.f); | ||
| 2100 | glVertex3f((_myAvatar.getLeadingAvatar()->getHead().getPosition().x + _myAvatar.getLeadingAvatar()->getPosition().x) / 2.f, | ||
| 2101 | (_myAvatar.getLeadingAvatar()->getHead().getPosition().y + _myAvatar.getLeadingAvatar()->getPosition().y) / 2.f, | ||
| 2102 | (_myAvatar.getLeadingAvatar()->getHead().getPosition().z + _myAvatar.getLeadingAvatar()->getPosition().z) / 2.f); | ||
| 2103 | } | ||
| 2104 | |||
| 2105 | if (began) { | ||
| 2106 | glEnd(); | ||
| 2107 | _glowEffect.end(); | ||
| 2108 | } | ||
| 2109 | } | ||
| 2110 | |||
| 2111 | void Application::renderHighlightVoxel(VoxelDetail voxel) { | 2021 | void Application::renderHighlightVoxel(VoxelDetail voxel) { |
| 2112 | glDisable(GL_LIGHTING); | 2022 | glDisable(GL_LIGHTING); |
| 2113 | glPushMatrix(); | 2023 | glPushMatrix(); |
| @@ -2125,10 +2035,9 @@ void Application::renderHighlightVoxel(VoxelDetail voxel) { · 11 unmodified lines | |||
| 2125 | void Application::updateAvatars(float deltaTime, glm::vec3 mouseRayOrigin, glm::vec3 mouseRayDirection) { | 2035 | void Application::updateAvatars(float deltaTime, glm::vec3 mouseRayOrigin, glm::vec3 mouseRayDirection) { |
| 2126 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); | 2036 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); |
| 2127 | PerformanceWarning warn(showWarnings, "Application::updateAvatars()"); | 2037 | PerformanceWarning warn(showWarnings, "Application::updateAvatars()"); |
| 2128 | NodeList* nodeList = NodeList::getInstance(); | 2038 | |
| 2129 | 2039 | foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) { | |
| 2130 | for(NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) { | 2040 | QMutexLocker(&node->getMutex()); |
| 2131 | node->lock(); | ||
| 2132 | if (node->getLinkedData()) { | 2041 | if (node->getLinkedData()) { |
| 2133 | Avatar *avatar = (Avatar *)node->getLinkedData(); | 2042 | Avatar *avatar = (Avatar *)node->getLinkedData(); |
| 2134 | if (!avatar->isInitialized()) { | 2043 | if (!avatar->isInitialized()) { |
| @@ -2137,7 +2046,6 @@ void Application::updateAvatars(float deltaTime, glm::vec3 mouseRayOrigin, glm:: · 2 unmodified lines | |||
| 2137 | avatar->simulate(deltaTime, NULL); | 2046 | avatar->simulate(deltaTime, NULL); |
| 2138 | avatar->setMouseRay(mouseRayOrigin, mouseRayDirection); | 2047 | avatar->setMouseRay(mouseRayOrigin, mouseRayDirection); |
| 2139 | } | 2048 | } |
| 2140 | node->unlock(); | ||
| 2141 | } | 2049 | } |
| 2142 | 2050 | ||
| 2143 | // simulate avatar fades | 2051 | // simulate avatar fades |
| @@ -2397,21 +2305,12 @@ void Application::updateSixense(float deltaTime) { · 253 unmodified lines | |||
| 2397 | void Application::updateSerialDevices(float deltaTime) { | 2305 | void Application::updateSerialDevices(float deltaTime) { |
| 2398 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); | 2306 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); |
| 2399 | PerformanceWarning warn(showWarnings, "Application::updateSerialDevices()"); | 2307 | PerformanceWarning warn(showWarnings, "Application::updateSerialDevices()"); |
| 2400 | |||
| 2401 | if (_serialHeadSensor.isActive()) { | ||
| 2402 | _serialHeadSensor.readData(deltaTime); | ||
| 2403 | } | ||
| 2404 | } | 2308 | } |
| 2405 | 2309 | ||
| 2406 | void Application::updateThreads(float deltaTime) { | 2310 | void Application::updateThreads(float deltaTime) { |
| 2407 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); | 2311 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); |
| 2408 | PerformanceWarning warn(showWarnings, "Application::updateThreads()"); | 2312 | PerformanceWarning warn(showWarnings, "Application::updateThreads()"); |
| 2409 | 2313 | ||
| 2410 | // read incoming packets from network | ||
| 2411 | if (!_enableNetworkThread) { | ||
| 2412 | networkReceive(0); | ||
| 2413 | } | ||
| 2414 | |||
| 2415 | // parse voxel packets | 2314 | // parse voxel packets |
| 2416 | if (!_enableProcessVoxelsThread) { | 2315 | if (!_enableProcessVoxelsThread) { |
| 2417 | _voxelProcessor.threadRoutine(); | 2316 | _voxelProcessor.threadRoutine(); |
| @@ -2644,41 +2543,6 @@ void Application::updateAvatar(float deltaTime) { · 226 unmodified lines | |||
| 2644 | _headMouseY -= headVelocity.x * HEADMOUSE_FACESHIFT_PITCH_SCALE; | 2543 | _headMouseY -= headVelocity.x * HEADMOUSE_FACESHIFT_PITCH_SCALE; |
| 2645 | } | 2544 | } |
| 2646 | 2545 | ||
| 2647 | if (_serialHeadSensor.isActive()) { | ||
| 2648 | |||
| 2649 | // Grab latest readings from the gyros | ||
| 2650 | float measuredPitchRate = _serialHeadSensor.getLastPitchRate(); | ||
| 2651 | float measuredYawRate = _serialHeadSensor.getLastYawRate(); | ||
| 2652 | |||
| 2653 | // Update gyro-based mouse (X,Y on screen) | ||
| 2654 | const float MIN_MOUSE_RATE = 3.0; | ||
| 2655 | const float HORIZONTAL_PIXELS_PER_DEGREE = 2880.f / 45.f; | ||
| 2656 | const float VERTICAL_PIXELS_PER_DEGREE = 1800.f / 30.f; | ||
| 2657 | if (powf(measuredYawRate * measuredYawRate + | ||
| 2658 | measuredPitchRate * measuredPitchRate, 0.5) > MIN_MOUSE_RATE) { | ||
| 2659 | _headMouseX -= measuredYawRate * HORIZONTAL_PIXELS_PER_DEGREE * deltaTime; | ||
| 2660 | _headMouseY -= measuredPitchRate * VERTICAL_PIXELS_PER_DEGREE * deltaTime; | ||
| 2661 | } | ||
| 2662 | |||
| 2663 | const float MIDPOINT_OF_SCREEN = 0.5; | ||
| 2664 | |||
| 2665 | // Only use gyro to set lookAt if mouse hasn't selected an avatar | ||
| 2666 | if (!_lookatTargetAvatar) { | ||
| 2667 | |||
| 2668 | // Set lookAtPosition if an avatar is at the center of the screen | ||
| 2669 | glm::vec3 screenCenterRayOrigin, screenCenterRayDirection; | ||
| 2670 | _viewFrustum.computePickRay(MIDPOINT_OF_SCREEN, MIDPOINT_OF_SCREEN, screenCenterRayOrigin, screenCenterRayDirection); | ||
| 2671 | |||
| 2672 | glm::vec3 eyePosition; | ||
| 2673 | updateLookatTargetAvatar(screenCenterRayOrigin, screenCenterRayDirection, eyePosition); | ||
| 2674 | if (_lookatTargetAvatar) { | ||
| 2675 | glm::vec3 myLookAtFromMouse(eyePosition); | ||
| 2676 | _myAvatar.getHead().setLookAtPosition(myLookAtFromMouse); | ||
| 2677 | } | ||
| 2678 | } | ||
| 2679 | |||
| 2680 | } | ||
| 2681 | |||
| 2682 | // Constrain head-driven mouse to edges of screen | 2546 | // Constrain head-driven mouse to edges of screen |
| 2683 | _headMouseX = glm::clamp(_headMouseX, 0, _glWidget->width()); | 2547 | _headMouseX = glm::clamp(_headMouseX, 0, _glWidget->width()); |
| 2684 | _headMouseY = glm::clamp(_headMouseY, 0, _glWidget->height()); | 2548 | _headMouseY = glm::clamp(_headMouseY, 0, _glWidget->height()); |
| @@ -2759,39 +2623,36 @@ void Application::queryOctree(NODE_TYPE serverType, PACKET_TYPE packetType, Node · 74 unmodified lines | |||
| 2759 | 2623 | ||
| 2760 | unsigned char voxelQueryPacket[MAX_PACKET_SIZE]; | 2624 | unsigned char voxelQueryPacket[MAX_PACKET_SIZE]; |
| 2761 | 2625 | ||
| 2762 | NodeList* nodeList = NodeList::getInstance(); | ||
| 2763 | |||
| 2764 | // Iterate all of the nodes, and get a count of how many voxel servers we have... | 2626 | // Iterate all of the nodes, and get a count of how many voxel servers we have... |
| 2765 | int totalServers = 0; | 2627 | int totalServers = 0; |
| 2766 | int inViewServers = 0; | 2628 | int inViewServers = 0; |
| 2767 | int unknownJurisdictionServers = 0; | 2629 | int unknownJurisdictionServers = 0; |
| 2768 | 2630 | ||
| 2769 | for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) { | 2631 | foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) { |
| 2770 | |||
| 2771 | // only send to the NodeTypes that are serverType | 2632 | // only send to the NodeTypes that are serverType |
| 2772 | if (node->getActiveSocket() != NULL && node->getType() == serverType) { | 2633 | if (node->getActiveSocket() != NULL && node->getType() == serverType) { |
| 2773 | totalServers++; | 2634 | totalServers++; |
| 2774 | 2635 | ||
| 2775 | // get the server bounds for this server | 2636 | // get the server bounds for this server |
| 2776 | QUuid nodeUUID = node->getUUID(); | 2637 | QUuid nodeUUID = node->getUUID(); |
| 2777 | 2638 | ||
| 2778 | // if we haven't heard from this voxel server, go ahead and send it a query, so we | 2639 | // if we haven't heard from this voxel server, go ahead and send it a query, so we |
| 2779 | // can get the jurisdiction... | 2640 | // can get the jurisdiction... |
| 2780 | if (jurisdictions.find(nodeUUID) == jurisdictions.end()) { | 2641 | if (jurisdictions.find(nodeUUID) == jurisdictions.end()) { |
| 2781 | unknownJurisdictionServers++; | 2642 | unknownJurisdictionServers++; |
| 2782 | } else { | 2643 | } else { |
| 2783 | const JurisdictionMap& map = (jurisdictions)[nodeUUID]; | 2644 | const JurisdictionMap& map = (jurisdictions)[nodeUUID]; |
| 2784 | 2645 | ||
| 2785 | unsigned char* rootCode = map.getRootOctalCode(); | 2646 | unsigned char* rootCode = map.getRootOctalCode(); |
| 2786 | 2647 | ||
| 2787 | if (rootCode) { | 2648 | if (rootCode) { |
| 2788 | VoxelPositionSize rootDetails; | 2649 | VoxelPositionSize rootDetails; |
| 2789 | voxelDetailsForCode(rootCode, rootDetails); | 2650 | voxelDetailsForCode(rootCode, rootDetails); |
| 2790 | AABox serverBounds(glm::vec3(rootDetails.x, rootDetails.y, rootDetails.z), rootDetails.s); | 2651 | AABox serverBounds(glm::vec3(rootDetails.x, rootDetails.y, rootDetails.z), rootDetails.s); |
| 2791 | serverBounds.scale(TREE_SCALE); | 2652 | serverBounds.scale(TREE_SCALE); |
| 2792 | 2653 | ||
| 2793 | ViewFrustum::location serverFrustumLocation = _viewFrustum.boxInFrustum(serverBounds); | 2654 | ViewFrustum::location serverFrustumLocation = _viewFrustum.boxInFrustum(serverBounds); |
| 2794 | 2655 | ||
| 2795 | if (serverFrustumLocation != ViewFrustum::OUTSIDE) { | 2656 | if (serverFrustumLocation != ViewFrustum::OUTSIDE) { |
| 2796 | inViewServers++; | 2657 | inViewServers++; |
| 2797 | } | 2658 | } |
| @@ -2801,7 +2662,7 @@ void Application::queryOctree(NODE_TYPE serverType, PACKET_TYPE packetType, Node · 3 unmodified lines | |||
| 2801 | } | 2662 | } |
| 2802 | 2663 | ||
| 2803 | if (wantExtraDebugging && unknownJurisdictionServers > 0) { | 2664 | if (wantExtraDebugging && unknownJurisdictionServers > 0) { |
| 2804 | qDebug("Servers: total %d, in view %d, unknown jurisdiction %d \n", | 2665 | qDebug("Servers: total %d, in view %d, unknown jurisdiction %d", |
| 2805 | totalServers, inViewServers, unknownJurisdictionServers); | 2666 | totalServers, inViewServers, unknownJurisdictionServers); |
| 2806 | } | 2667 | } |
| 2807 | 2668 | ||
| @@ -2822,38 +2683,40 @@ void Application::queryOctree(NODE_TYPE serverType, PACKET_TYPE packetType, Node · 14 unmodified lines | |||
| 2822 | } | 2683 | } |
| 2823 | 2684 | ||
| 2824 | if (wantExtraDebugging && unknownJurisdictionServers > 0) { | 2685 | if (wantExtraDebugging && unknownJurisdictionServers > 0) { |
| 2825 | qDebug("perServerPPS: %d perUnknownServer: %d\n", perServerPPS, perUnknownServer); | 2686 | qDebug("perServerPPS: %d perUnknownServer: %d", perServerPPS, perUnknownServer); |
| 2826 | } | 2687 | } |
| 2827 | 2688 | ||
| 2828 | for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) { | 2689 | NodeList* nodeList = NodeList::getInstance(); |
| 2690 | |||
| 2691 | foreach (const SharedNodePointer& node, nodeList->getNodeHash()) { | ||
| 2829 | // only send to the NodeTypes that are serverType | 2692 | // only send to the NodeTypes that are serverType |
| 2830 | if (node->getActiveSocket() != NULL && node->getType() == serverType) { | 2693 | if (node->getActiveSocket() != NULL && node->getType() == serverType) { |
| 2831 | 2694 | ||
| 2832 | 2695 | ||
| 2833 | // get the server bounds for this server | 2696 | // get the server bounds for this server |
| 2834 | QUuid nodeUUID = node->getUUID(); | 2697 | QUuid nodeUUID = node->getUUID(); |
| 2835 | 2698 | ||
| 2836 | bool inView = false; | 2699 | bool inView = false; |
| 2837 | bool unknownView = false; | 2700 | bool unknownView = false; |
| 2838 | 2701 | ||
| 2839 | // if we haven't heard from this voxel server, go ahead and send it a query, so we | 2702 | // if we haven't heard from this voxel server, go ahead and send it a query, so we |
| 2840 | // can get the jurisdiction... | 2703 | // can get the jurisdiction... |
| 2841 | if (jurisdictions.find(nodeUUID) == jurisdictions.end()) { | 2704 | if (jurisdictions.find(nodeUUID) == jurisdictions.end()) { |
| 2842 | unknownView = true; // assume it's in view | 2705 | unknownView = true; // assume it's in view |
| 2843 | if (wantExtraDebugging) { | 2706 | if (wantExtraDebugging) { |
| 2844 | qDebug() << "no known jurisdiction for node " << *node << ", assume it's visible.\n"; | 2707 | qDebug() << "no known jurisdiction for node " << *node << ", assume it's visible."; |
| 2845 | } | 2708 | } |
| 2846 | } else { | 2709 | } else { |
| 2847 | const JurisdictionMap& map = (jurisdictions)[nodeUUID]; | 2710 | const JurisdictionMap& map = (jurisdictions)[nodeUUID]; |
| 2848 | 2711 | ||
| 2849 | unsigned char* rootCode = map.getRootOctalCode(); | 2712 | unsigned char* rootCode = map.getRootOctalCode(); |
| 2850 | 2713 | ||
| 2851 | if (rootCode) { | 2714 | if (rootCode) { |
| 2852 | VoxelPositionSize rootDetails; | 2715 | VoxelPositionSize rootDetails; |
| 2853 | voxelDetailsForCode(rootCode, rootDetails); | 2716 | voxelDetailsForCode(rootCode, rootDetails); |
| 2854 | AABox serverBounds(glm::vec3(rootDetails.x, rootDetails.y, rootDetails.z), rootDetails.s); | 2717 | AABox serverBounds(glm::vec3(rootDetails.x, rootDetails.y, rootDetails.z), rootDetails.s); |
| 2855 | serverBounds.scale(TREE_SCALE); | 2718 | serverBounds.scale(TREE_SCALE); |
| 2856 | 2719 | ||
| 2857 | ViewFrustum::location serverFrustumLocation = _viewFrustum.boxInFrustum(serverBounds); | 2720 | ViewFrustum::location serverFrustumLocation = _viewFrustum.boxInFrustum(serverBounds); |
| 2858 | if (serverFrustumLocation != ViewFrustum::OUTSIDE) { | 2721 | if (serverFrustumLocation != ViewFrustum::OUTSIDE) { |
| 2859 | inView = true; | 2722 | inView = true; |
| @@ -2862,19 +2725,19 @@ void Application::queryOctree(NODE_TYPE serverType, PACKET_TYPE packetType, Node · 2 unmodified lines | |||
| 2862 | } | 2725 | } |
| 2863 | } else { | 2726 | } else { |
| 2864 | if (wantExtraDebugging) { | 2727 | if (wantExtraDebugging) { |
| 2865 | qDebug() << "Jurisdiction without RootCode for node " << *node << ". That's unusual!\n"; | 2728 | qDebug() << "Jurisdiction without RootCode for node " << *node << ". That's unusual!"; |
| 2866 | } | 2729 | } |
| 2867 | } | 2730 | } |
| 2868 | } | 2731 | } |
| 2869 | 2732 | ||
| 2870 | if (inView) { | 2733 | if (inView) { |
| 2871 | _voxelQuery.setMaxOctreePacketsPerSecond(perServerPPS); | 2734 | _voxelQuery.setMaxOctreePacketsPerSecond(perServerPPS); |
| 2872 | } else if (unknownView) { | 2735 | } else if (unknownView) { |
| 2873 | if (wantExtraDebugging) { | 2736 | if (wantExtraDebugging) { |
| 2874 | qDebug() << "no known jurisdiction for node " << *node << ", give it budget of " | 2737 | qDebug() << "no known jurisdiction for node " << *node << ", give it budget of " |
| 2875 | << perUnknownServer << " to send us jurisdiction.\n"; | 2738 | << perUnknownServer << " to send us jurisdiction."; |
| 2876 | } | 2739 | } |
| 2877 | 2740 | ||
| 2878 | // set the query's position/orientation to be degenerate in a manner that will get the scene quickly | 2741 | // set the query's position/orientation to be degenerate in a manner that will get the scene quickly |
| 2879 | // If there's only one server, then don't do this, and just let the normal voxel query pass through | 2742 | // If there's only one server, then don't do this, and just let the normal voxel query pass through |
| 2880 | // as expected... this way, we will actually get a valid scene if there is one to be seen | 2743 | // as expected... this way, we will actually get a valid scene if there is one to be seen |
| @@ -2885,11 +2748,11 @@ void Application::queryOctree(NODE_TYPE serverType, PACKET_TYPE packetType, Node · 4 unmodified lines | |||
| 2885 | _voxelQuery.setCameraNearClip(0.1); | 2748 | _voxelQuery.setCameraNearClip(0.1); |
| 2886 | _voxelQuery.setCameraFarClip(0.1); | 2749 | _voxelQuery.setCameraFarClip(0.1); |
| 2887 | if (wantExtraDebugging) { | 2750 | if (wantExtraDebugging) { |
| 2888 | qDebug() << "Using 'minimal' camera position for node " << *node << "\n"; | 2751 | qDebug() << "Using 'minimal' camera position for node" << *node; |
| 2889 | } | 2752 | } |
| 2890 | } else { | 2753 | } else { |
| 2891 | if (wantExtraDebugging) { | 2754 | if (wantExtraDebugging) { |
| 2892 | qDebug() << "Using regular camera position for node " << *node << "\n"; | 2755 | qDebug() << "Using regular camera position for node" << *node; |
| 2893 | } | 2756 | } |
| 2894 | } | 2757 | } |
| 2895 | _voxelQuery.setMaxOctreePacketsPerSecond(perUnknownServer); | 2758 | _voxelQuery.setMaxOctreePacketsPerSecond(perUnknownServer); |
| @@ -2898,24 +2761,24 @@ void Application::queryOctree(NODE_TYPE serverType, PACKET_TYPE packetType, Node · 2 unmodified lines | |||
| 2898 | } | 2761 | } |
| 2899 | // set up the packet for sending... | 2762 | // set up the packet for sending... |
| 2900 | unsigned char* endOfVoxelQueryPacket = voxelQueryPacket; | 2763 | unsigned char* endOfVoxelQueryPacket = voxelQueryPacket; |
| 2901 | 2764 | ||
| 2902 | // insert packet type/version and node UUID | 2765 | // insert packet type/version and node UUID |
| 2903 | endOfVoxelQueryPacket += populateTypeAndVersion(endOfVoxelQueryPacket, packetType); | 2766 | endOfVoxelQueryPacket += populateTypeAndVersion(endOfVoxelQueryPacket, packetType); |
| 2904 | QByteArray ownerUUID = nodeList->getOwnerUUID().toRfc4122(); | 2767 | QByteArray ownerUUID = nodeList->getOwnerUUID().toRfc4122(); |
| 2905 | memcpy(endOfVoxelQueryPacket, ownerUUID.constData(), ownerUUID.size()); | 2768 | memcpy(endOfVoxelQueryPacket, ownerUUID.constData(), ownerUUID.size()); |
| 2906 | endOfVoxelQueryPacket += ownerUUID.size(); | 2769 | endOfVoxelQueryPacket += ownerUUID.size(); |
| 2907 | 2770 | ||
| 2908 | // encode the query data... | 2771 | // encode the query data... |
| 2909 | endOfVoxelQueryPacket += _voxelQuery.getBroadcastData(endOfVoxelQueryPacket); | 2772 | endOfVoxelQueryPacket += _voxelQuery.getBroadcastData(endOfVoxelQueryPacket); |
| 2910 | 2773 | ||
| 2911 | int packetLength = endOfVoxelQueryPacket - voxelQueryPacket; | 2774 | int packetLength = endOfVoxelQueryPacket - voxelQueryPacket; |
| 2912 | 2775 | ||
| 2913 | // make sure we still have an active socket | 2776 | // make sure we still have an active socket |
| 2914 | if (node->getActiveSocket()) { | 2777 | if (node->getActiveSocket()) { |
| 2915 | nodeList->getNodeSocket().writeDatagram((char*) voxelQueryPacket, packetLength, | 2778 | nodeList->getNodeSocket().writeDatagram((char*) voxelQueryPacket, packetLength, |
| 2916 | node->getActiveSocket()->getAddress(), node->getActiveSocket()->getPort()); | 2779 | node->getActiveSocket()->getAddress(), node->getActiveSocket()->getPort()); |
| 2917 | } | 2780 | } |
| 2918 | 2781 | ||
| 2919 | // Feed number of bytes to corresponding channel of the bandwidth meter | 2782 | // Feed number of bytes to corresponding channel of the bandwidth meter |
| 2920 | _bandwidthMeter.outputStream(BandwidthMeter::VOXELS).updateValue(packetLength); | 2783 | _bandwidthMeter.outputStream(BandwidthMeter::VOXELS).updateValue(packetLength); |
| 2921 | } | 2784 | } |
| @@ -3272,12 +3135,6 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 350 unmodified lines | |||
| 3272 | } | 3135 | } |
| 3273 | } | 3136 | } |
| 3274 | 3137 | ||
| 3275 | { | ||
| 3276 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), | ||
| 3277 | "Application::displaySide() ... renderFollowIndicator..."); | ||
| 3278 | renderFollowIndicator(); | ||
| 3279 | } | ||
| 3280 | |||
| 3281 | // render transmitter pick ray, if non-empty | 3138 | // render transmitter pick ray, if non-empty |
| 3282 | if (_transmitterPickStart != _transmitterPickEnd) { | 3139 | if (_transmitterPickStart != _transmitterPickEnd) { |
| 3283 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), | 3140 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), |
| @@ -3345,8 +3202,7 @@ void Application::displayOverlay() { · 61 unmodified lines | |||
| 3345 | 3202 | ||
| 3346 | //noiseTest(_glWidget->width(), _glWidget->height()); | 3203 | //noiseTest(_glWidget->width(), _glWidget->height()); |
| 3347 | 3204 | ||
| 3348 | if (Menu::getInstance()->isOptionChecked(MenuOption::HeadMouse) | 3205 | if (Menu::getInstance()->isOptionChecked(MenuOption::HeadMouse)) { |
| 3349 | && USING_INVENSENSE_MPU9150) { | ||
| 3350 | // Display small target box at center or head mouse target that can also be used to measure LOD | 3206 | // Display small target box at center or head mouse target that can also be used to measure LOD |
| 3351 | glColor3f(1.0, 1.0, 1.0); | 3207 | glColor3f(1.0, 1.0, 1.0); |
| 3352 | glDisable(GL_LINE_SMOOTH); | 3208 | glDisable(GL_LINE_SMOOTH); |
| @@ -3382,9 +3238,6 @@ void Application::displayOverlay() { · 29 unmodified lines | |||
| 3382 | } | 3238 | } |
| 3383 | } | 3239 | } |
| 3384 | 3240 | ||
| 3385 | // Show detected levels from the serial I/O ADC channel sensors | ||
| 3386 | if (_displayLevels) _serialHeadSensor.renderLevels(_glWidget->width(), _glWidget->height()); | ||
| 3387 | |||
| 3388 | // Show hand transmitter data if detected | 3241 | // Show hand transmitter data if detected |
| 3389 | if (_myTransmitter.isConnected()) { | 3242 | if (_myTransmitter.isConnected()) { |
| 3390 | _myTransmitter.renderLevels(_glWidget->width(), _glWidget->height()); | 3243 | _myTransmitter.renderLevels(_glWidget->width(), _glWidget->height()); |
| @@ -3404,12 +3257,12 @@ void Application::displayOverlay() { · 13 unmodified lines | |||
| 3404 | glPointSize(1.0f); | 3257 | glPointSize(1.0f); |
| 3405 | char nodes[100]; | 3258 | char nodes[100]; |
| 3406 | 3259 | ||
| 3407 | NodeList* nodeList = NodeList::getInstance(); | ||
| 3408 | int totalAvatars = 0, totalServers = 0; | 3260 | int totalAvatars = 0, totalServers = 0; |
| 3409 | 3261 | ||
| 3410 | for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) { | 3262 | foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) { |
| 3411 | node->getType() == NODE_TYPE_AGENT ? totalAvatars++ : totalServers++; | 3263 | node->getType() == NODE_TYPE_AGENT ? totalAvatars++ : totalServers++; |
| 3412 | } | 3264 | } |
| 3265 | |||
| 3413 | sprintf(nodes, "Servers: %d, Avatars: %d\n", totalServers, totalAvatars); | 3266 | sprintf(nodes, "Servers: %d, Avatars: %d\n", totalServers, totalAvatars); |
| 3414 | drawtext(_glWidget->width() - 150, 20, 0.10, 0, 1.0, 0, nodes, 1, 0, 0); | 3267 | drawtext(_glWidget->width() - 150, 20, 0.10, 0, 1.0, 0, nodes, 1, 0, 0); |
| 3415 | } | 3268 | } |
| @@ -3509,8 +3362,8 @@ void Application::displayStats() { · 93 unmodified lines | |||
| 3509 | int pingAudio = 0, pingAvatar = 0, pingVoxel = 0, pingVoxelMax = 0; | 3362 | int pingAudio = 0, pingAvatar = 0, pingVoxel = 0, pingVoxelMax = 0; |
| 3510 | 3363 | ||
| 3511 | NodeList* nodeList = NodeList::getInstance(); | 3364 | NodeList* nodeList = NodeList::getInstance(); |
| 3512 | Node* audioMixerNode = nodeList->soloNodeOfType(NODE_TYPE_AUDIO_MIXER); | 3365 | SharedNodePointer audioMixerNode = nodeList->soloNodeOfType(NODE_TYPE_AUDIO_MIXER); |
| 3513 | Node* avatarMixerNode = nodeList->soloNodeOfType(NODE_TYPE_AVATAR_MIXER); | 3366 | SharedNodePointer avatarMixerNode = nodeList->soloNodeOfType(NODE_TYPE_AVATAR_MIXER); |
| 3514 | 3367 | ||
| 3515 | pingAudio = audioMixerNode ? audioMixerNode->getPingMs() : 0; | 3368 | pingAudio = audioMixerNode ? audioMixerNode->getPingMs() : 0; |
| 3516 | pingAvatar = avatarMixerNode ? avatarMixerNode->getPingMs() : 0; | 3369 | pingAvatar = avatarMixerNode ? avatarMixerNode->getPingMs() : 0; |
| @@ -3519,7 +3372,8 @@ void Application::displayStats() { · 2 unmodified lines | |||
| 3519 | // Now handle voxel servers, since there could be more than one, we average their ping times | 3372 | // Now handle voxel servers, since there could be more than one, we average their ping times |
| 3520 | unsigned long totalPingVoxel = 0; | 3373 | unsigned long totalPingVoxel = 0; |
| 3521 | int voxelServerCount = 0; | 3374 | int voxelServerCount = 0; |
| 3522 | for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) { | 3375 | |
| 3376 | foreach (const SharedNodePointer& node, nodeList->getNodeHash()) { | ||
| 3523 | if (node->getType() == NODE_TYPE_VOXEL_SERVER) { | 3377 | if (node->getType() == NODE_TYPE_VOXEL_SERVER) { |
| 3524 | totalPingVoxel += node->getPingMs(); | 3378 | totalPingVoxel += node->getPingMs(); |
| 3525 | voxelServerCount++; | 3379 | voxelServerCount++; |
| @@ -3528,6 +3382,7 @@ void Application::displayStats() { · 2 unmodified lines | |||
| 3528 | } | 3382 | } |
| 3529 | } | 3383 | } |
| 3530 | } | 3384 | } |
| 3385 | |||
| 3531 | if (voxelServerCount) { | 3386 | if (voxelServerCount) { |
| 3532 | pingVoxel = totalPingVoxel/voxelServerCount; | 3387 | pingVoxel = totalPingVoxel/voxelServerCount; |
| 3533 | } | 3388 | } |
| @@ -3544,7 +3399,7 @@ void Application::displayStats() { · 10 unmodified lines | |||
| 3544 | sprintf(avatarStats, "Avatar: pos %.3f, %.3f, %.3f, vel %.1f, yaw = %.2f", avatarPos.x, avatarPos.y, avatarPos.z, glm::length(_myAvatar.getVelocity()), _myAvatar.getBodyYaw()); | 3399 | sprintf(avatarStats, "Avatar: pos %.3f, %.3f, %.3f, vel %.1f, yaw = %.2f", avatarPos.x, avatarPos.y, avatarPos.z, glm::length(_myAvatar.getVelocity()), _myAvatar.getBodyYaw()); |
| 3545 | drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, avatarStats); | 3400 | drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, avatarStats); |
| 3546 | 3401 | ||
| 3547 | Node* avatarMixer = NodeList::getInstance()->soloNodeOfType(NODE_TYPE_AVATAR_MIXER); | 3402 | SharedNodePointer avatarMixer = NodeList::getInstance()->soloNodeOfType(NODE_TYPE_AVATAR_MIXER); |
| 3548 | char avatarMixerStats[200]; | 3403 | char avatarMixerStats[200]; |
| 3549 | if (avatarMixer) { | 3404 | if (avatarMixer) { |
| 3550 | sprintf(avatarMixerStats, "Avatar Mixer: %.f kbps, %.f pps", | 3405 | sprintf(avatarMixerStats, "Avatar Mixer: %.f kbps, %.f pps", |
| @@ -3746,9 +3601,6 @@ glm::vec2 Application::getScaledScreenPoint(glm::vec2 projectedPoint) { · 195 unmodified lines | |||
| 3746 | 3601 | ||
| 3747 | // render the coverage map on screen | 3602 | // render the coverage map on screen |
| 3748 | void Application::renderCoverageMapV2() { | 3603 | void Application::renderCoverageMapV2() { |
| 3749 | |||
| 3750 | //qDebug("renderCoverageMap()\n"); | ||
| 3751 | |||
| 3752 | glDisable(GL_LIGHTING); | 3604 | glDisable(GL_LIGHTING); |
| 3753 | glLineWidth(2.0); | 3605 | glLineWidth(2.0); |
| 3754 | glBegin(GL_LINES); | 3606 | glBegin(GL_LINES); |
| @@ -3792,8 +3644,6 @@ void Application::renderCoverageMapsV2Recursively(CoverageMapV2* map) { · 37 unmodified lines | |||
| 3792 | // render the coverage map on screen | 3644 | // render the coverage map on screen |
| 3793 | void Application::renderCoverageMap() { | 3645 | void Application::renderCoverageMap() { |
| 3794 | 3646 | ||
| 3795 | //qDebug("renderCoverageMap()\n"); | ||
| 3796 | |||
| 3797 | glDisable(GL_LIGHTING); | 3647 | glDisable(GL_LIGHTING); |
| 3798 | glLineWidth(2.0); | 3648 | glLineWidth(2.0); |
| 3799 | glBegin(GL_LINES); | 3649 | glBegin(GL_LINES); |
| @@ -3868,10 +3718,10 @@ void Application::renderAvatars(bool forceRenderHead, bool selfAvatarOnly) { · 68 unmodified lines | |||
| 3868 | if (!selfAvatarOnly) { | 3718 | if (!selfAvatarOnly) { |
| 3869 | // Render avatars of other nodes | 3719 | // Render avatars of other nodes |
| 3870 | NodeList* nodeList = NodeList::getInstance(); | 3720 | NodeList* nodeList = NodeList::getInstance(); |
| 3871 | 3721 | ||
| 3872 | for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) { | 3722 | foreach (const SharedNodePointer& node, nodeList->getNodeHash()) { |
| 3873 | node->lock(); | 3723 | QMutexLocker(&node->getMutex()); |
| 3874 | 3724 | ||
| 3875 | if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) { | 3725 | if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) { |
| 3876 | Avatar *avatar = (Avatar *)node->getLinkedData(); | 3726 | Avatar *avatar = (Avatar *)node->getLinkedData(); |
| 3877 | if (!avatar->isInitialized()) { | 3727 | if (!avatar->isInitialized()) { |
| @@ -3880,8 +3730,6 @@ void Application::renderAvatars(bool forceRenderHead, bool selfAvatarOnly) { · 2 unmodified lines | |||
| 3880 | avatar->render(false); | 3730 | avatar->render(false); |
| 3881 | avatar->setDisplayingLookatVectors(Menu::getInstance()->isOptionChecked(MenuOption::LookAtVectors)); | 3731 | avatar->setDisplayingLookatVectors(Menu::getInstance()->isOptionChecked(MenuOption::LookAtVectors)); |
| 3882 | } | 3732 | } |
| 3883 | |||
| 3884 | node->unlock(); | ||
| 3885 | } | 3733 | } |
| 3886 | 3734 | ||
| 3887 | // render avatar fades | 3735 | // render avatar fades |
| @@ -4126,25 +3974,10 @@ void Application::eyedropperVoxelUnderCursor() { · 238 unmodified lines | |||
| 4126 | } | 3974 | } |
| 4127 | } | 3975 | } |
| 4128 | 3976 | ||
| 4129 | void Application::toggleFollowMode() { | ||
| 4130 | glm::vec3 mouseRayOrigin, mouseRayDirection; | ||
| 4131 | _viewFrustum.computePickRay(_pieMenu.getX() / (float)_glWidget->width(), | ||
| 4132 | _pieMenu.getY() / (float)_glWidget->height(), | ||
| 4133 | mouseRayOrigin, mouseRayDirection); | ||
| 4134 | glm::vec3 eyePositionIgnored; | ||
| 4135 | QUuid nodeUUIDIgnored; | ||
| 4136 | Avatar* leadingAvatar = findLookatTargetAvatar(mouseRayOrigin, mouseRayDirection, eyePositionIgnored, nodeUUIDIgnored); | ||
| 4137 | |||
| 4138 | _myAvatar.follow(leadingAvatar); | ||
| 4139 | } | ||
| 4140 | |||
| 4141 | void Application::resetSensors() { | 3977 | void Application::resetSensors() { |
| 4142 | _headMouseX = _mouseX = _glWidget->width() / 2; | 3978 | _headMouseX = _mouseX = _glWidget->width() / 2; |
| 4143 | _headMouseY = _mouseY = _glWidget->height() / 2; | 3979 | _headMouseY = _mouseY = _glWidget->height() / 2; |
| 4144 | 3980 | ||
| 4145 | if (_serialHeadSensor.isActive()) { | ||
| 4146 | _serialHeadSensor.resetAverages(); | ||
| 4147 | } | ||
| 4148 | _webcam.reset(); | 3981 | _webcam.reset(); |
| 4149 | _faceshift.reset(); | 3982 | _faceshift.reset(); |
| 4150 | 3983 | ||
| @@ -4197,13 +4030,13 @@ void Application::updateWindowTitle(){ · 46 unmodified lines | |||
| 4197 | title += _profile.getLastDomain(); | 4030 | title += _profile.getLastDomain(); |
| 4198 | title += buildVersion; | 4031 | title += buildVersion; |
| 4199 | 4032 | ||
| 4200 | qDebug("Application title set to: %s.\n", title.toStdString().c_str()); | 4033 | qDebug("Application title set to: %s", title.toStdString().c_str()); |
| 4201 | _window->setWindowTitle(title); | 4034 | _window->setWindowTitle(title); |
| 4202 | } | 4035 | } |
| 4203 | 4036 | ||
| 4204 | void Application::domainChanged(QString domain) { | 4037 | void Application::domainChanged(const QString& domainHostname) { |
| 4205 | // update the user's last domain in their Profile (which will propagate to data-server) | 4038 | // update the user's last domain in their Profile (which will propagate to data-server) |
| 4206 | _profile.updateDomain(domain); | 4039 | _profile.updateDomain(domainHostname); |
| 4207 | 4040 | ||
| 4208 | updateWindowTitle(); | 4041 | updateWindowTitle(); |
| 4209 | 4042 | ||
| @@ -4216,15 +4049,11 @@ void Application::domainChanged(QString domain) { · 6 unmodified lines | |||
| 4216 | _particleServerJurisdictions.clear(); | 4049 | _particleServerJurisdictions.clear(); |
| 4217 | 4050 | ||
| 4218 | // reset our persist thread | 4051 | // reset our persist thread |
| 4219 | qDebug() << "domainChanged()... domain=" << domain << " swapping persist cache\n"; | 4052 | qDebug() << "Domain changed to" << domainHostname << ". Swapping persist cache."; |
| 4220 | updateLocalOctreeCache(); | 4053 | updateLocalOctreeCache(); |
| 4221 | } | 4054 | } |
| 4222 | 4055 | ||
| 4223 | void Application::nodeAdded(Node* node) { | 4056 | void Application::nodeKilled(SharedNodePointer node) { |
| 4224 | |||
| 4225 | } | ||
| 4226 | |||
| 4227 | void Application::nodeKilled(Node* node) { | ||
| 4228 | if (node->getType() == NODE_TYPE_VOXEL_SERVER) { | 4057 | if (node->getType() == NODE_TYPE_VOXEL_SERVER) { |
| 4229 | QUuid nodeUUID = node->getUUID(); | 4058 | QUuid nodeUUID = node->getUUID(); |
| 4230 | // see if this is the first we've heard of this node... | 4059 | // see if this is the first we've heard of this node... |
| @@ -4304,7 +4133,7 @@ void Application::trackIncomingVoxelPacket(unsigned char* messageData, ssize_t m · 73 unmodified lines | |||
| 4304 | const HifiSockAddr& senderSockAddr, bool wasStatsPacket) { | 4133 | const HifiSockAddr& senderSockAddr, bool wasStatsPacket) { |
| 4305 | 4134 | ||
| 4306 | // Attempt to identify the sender from it's address. | 4135 | // Attempt to identify the sender from it's address. |
| 4307 | Node* serverNode = NodeList::getInstance()->nodeWithAddress(senderSockAddr); | 4136 | SharedNodePointer serverNode = NodeList::getInstance()->nodeWithAddress(senderSockAddr); |
| 4308 | if (serverNode) { | 4137 | if (serverNode) { |
| 4309 | QUuid nodeUUID = serverNode->getUUID(); | 4138 | QUuid nodeUUID = serverNode->getUUID(); |
| 4310 | 4139 | ||
| @@ -4321,7 +4150,7 @@ void Application::trackIncomingVoxelPacket(unsigned char* messageData, ssize_t m · 10 unmodified lines | |||
| 4321 | int Application::parseOctreeStats(unsigned char* messageData, ssize_t messageLength, const HifiSockAddr& senderSockAddr) { | 4150 | int Application::parseOctreeStats(unsigned char* messageData, ssize_t messageLength, const HifiSockAddr& senderSockAddr) { |
| 4322 | 4151 | ||
| 4323 | // But, also identify the sender, and keep track of the contained jurisdiction root for this server | 4152 | // But, also identify the sender, and keep track of the contained jurisdiction root for this server |
| 4324 | Node* server = NodeList::getInstance()->nodeWithAddress(senderSockAddr); | 4153 | SharedNodePointer server = NodeList::getInstance()->nodeWithAddress(senderSockAddr); |
| 4325 | 4154 | ||
| 4326 | // parse the incoming stats datas stick it in a temporary object for now, while we | 4155 | // parse the incoming stats datas stick it in a temporary object for now, while we |
| 4327 | // determine which server it belongs to | 4156 | // determine which server it belongs to |
| @@ -4378,105 +4207,95 @@ int Application::parseOctreeStats(unsigned char* messageData, ssize_t messageLen · 50 unmodified lines | |||
| 4378 | } | 4207 | } |
| 4379 | 4208 | ||
| 4380 | // Receive packets from other nodes/servers and decide what to do with them! | 4209 | // Receive packets from other nodes/servers and decide what to do with them! |
| 4381 | void* Application::networkReceive(void* args) { | 4210 | void Application::processDatagrams() { |
| 4382 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), | 4211 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), |
| 4383 | "Application::networkReceive()"); | 4212 | "Application::networkReceive()"); |
| 4384 | 4213 | ||
| 4385 | HifiSockAddr senderSockAddr; | 4214 | HifiSockAddr senderSockAddr; |
| 4386 | ssize_t bytesReceived; | 4215 | ssize_t bytesReceived; |
| 4387 | 4216 | ||
| 4388 | Application* app = Application::getInstance(); | 4217 | while (NodeList::getInstance()->getNodeSocket().hasPendingDatagrams() && |
| 4389 | while (!app->_stopNetworkReceiveThread) { | 4218 | (bytesReceived = NodeList::getInstance()->getNodeSocket().readDatagram((char*) _incomingPacket, |
| 4390 | if (NodeList::getInstance()->getNodeSocket().hasPendingDatagrams() && | 4219 | MAX_PACKET_SIZE, |
| 4391 | (bytesReceived = NodeList::getInstance()->getNodeSocket().readDatagram((char*) app->_incomingPacket, | 4220 | senderSockAddr.getAddressPointer(), |
| 4392 | MAX_PACKET_SIZE, | 4221 | senderSockAddr.getPortPointer()))) { |
| 4393 | senderSockAddr.getAddressPointer(), | 4222 | |
| 4394 | senderSockAddr.getPortPointer()))) { | 4223 | _packetCount++; |
| 4395 | 4224 | _bytesCount += bytesReceived; | |
| 4396 | app->_packetCount++; | 4225 | |
| 4397 | app->_bytesCount += bytesReceived; | 4226 | if (packetVersionMatch(_incomingPacket)) { |
| 4398 | 4227 | // only process this packet if we have a match on the packet version | |
| 4399 | if (packetVersionMatch(app->_incomingPacket)) { | 4228 | switch (_incomingPacket[0]) { |
| 4400 | // only process this packet if we have a match on the packet version | 4229 | case PACKET_TYPE_TRANSMITTER_DATA_V2: |
| 4401 | switch (app->_incomingPacket[0]) { | 4230 | // V2 = IOS transmitter app |
| 4402 | case PACKET_TYPE_TRANSMITTER_DATA_V2: | 4231 | _myTransmitter.processIncomingData(_incomingPacket, bytesReceived); |
| 4403 | // V2 = IOS transmitter app | 4232 | |
| 4404 | app->_myTransmitter.processIncomingData(app->_incomingPacket, bytesReceived); | 4233 | break; |
| 4405 | 4234 | case PACKET_TYPE_MIXED_AUDIO: | |
| 4406 | break; | 4235 | QMetaObject::invokeMethod(&_audio, "addReceivedAudioToBuffer", Qt::QueuedConnection, |
| 4407 | case PACKET_TYPE_MIXED_AUDIO: | 4236 | Q_ARG(QByteArray, QByteArray((char*) _incomingPacket, bytesReceived))); |
| 4408 | QMetaObject::invokeMethod(&app->_audio, "addReceivedAudioToBuffer", Qt::QueuedConnection, | 4237 | break; |
| 4409 | Q_ARG(QByteArray, QByteArray((char*) app->_incomingPacket, bytesReceived))); | 4238 | |
| 4410 | break; | 4239 | case PACKET_TYPE_PARTICLE_ADD_RESPONSE: |
| 4411 | 4240 | // look up our ParticleEditHanders.... | |
| 4412 | case PACKET_TYPE_PARTICLE_ADD_RESPONSE: | 4241 | ParticleEditHandle::handleAddResponse(_incomingPacket, bytesReceived); |
| 4413 | // look up our ParticleEditHanders.... | 4242 | break; |
| 4414 | ParticleEditHandle::handleAddResponse(app->_incomingPacket, bytesReceived); | 4243 | |
| 4415 | break; | 4244 | case PACKET_TYPE_PARTICLE_DATA: |
| 4416 | 4245 | case PACKET_TYPE_VOXEL_DATA: | |
| 4417 | case PACKET_TYPE_PARTICLE_DATA: | 4246 | case PACKET_TYPE_VOXEL_ERASE: |
| 4418 | case PACKET_TYPE_VOXEL_DATA: | 4247 | case PACKET_TYPE_OCTREE_STATS: |
| 4419 | case PACKET_TYPE_VOXEL_ERASE: | 4248 | case PACKET_TYPE_ENVIRONMENT_DATA: { |
| 4420 | case PACKET_TYPE_OCTREE_STATS: | 4249 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), |
| 4421 | case PACKET_TYPE_ENVIRONMENT_DATA: { | 4250 | "Application::networkReceive()... _voxelProcessor.queueReceivedPacket()"); |
| 4422 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), | 4251 | |
| 4423 | "Application::networkReceive()... _voxelProcessor.queueReceivedPacket()"); | 4252 | bool wantExtraDebugging = getLogger()->extraDebugging(); |
| 4424 | 4253 | if (wantExtraDebugging && _incomingPacket[0] == PACKET_TYPE_VOXEL_DATA) { | |
| 4425 | bool wantExtraDebugging = app->getLogger()->extraDebugging(); | 4254 | int numBytesPacketHeader = numBytesForPacketHeader(_incomingPacket); |
| 4426 | if (wantExtraDebugging && app->_incomingPacket[0] == PACKET_TYPE_VOXEL_DATA) { | 4255 | unsigned char* dataAt = _incomingPacket + numBytesPacketHeader; |
| 4427 | int numBytesPacketHeader = numBytesForPacketHeader(app->_incomingPacket); | 4256 | dataAt += sizeof(VOXEL_PACKET_FLAGS); |
| 4428 | unsigned char* dataAt = app->_incomingPacket + numBytesPacketHeader; | 4257 | VOXEL_PACKET_SEQUENCE sequence = (*(VOXEL_PACKET_SEQUENCE*)dataAt); |
| 4429 | dataAt += sizeof(VOXEL_PACKET_FLAGS); | 4258 | dataAt += sizeof(VOXEL_PACKET_SEQUENCE); |
| 4430 | VOXEL_PACKET_SEQUENCE sequence = (*(VOXEL_PACKET_SEQUENCE*)dataAt); | 4259 | VOXEL_PACKET_SENT_TIME sentAt = (*(VOXEL_PACKET_SENT_TIME*)dataAt); |
| 4431 | dataAt += sizeof(VOXEL_PACKET_SEQUENCE); | 4260 | dataAt += sizeof(VOXEL_PACKET_SENT_TIME); |
| 4432 | VOXEL_PACKET_SENT_TIME sentAt = (*(VOXEL_PACKET_SENT_TIME*)dataAt); | 4261 | VOXEL_PACKET_SENT_TIME arrivedAt = usecTimestampNow(); |
| 4433 | dataAt += sizeof(VOXEL_PACKET_SENT_TIME); | 4262 | int flightTime = arrivedAt - sentAt; |
| 4434 | VOXEL_PACKET_SENT_TIME arrivedAt = usecTimestampNow(); | 4263 | |
| 4435 | int flightTime = arrivedAt - sentAt; | 4264 | printf("got PACKET_TYPE_VOXEL_DATA, sequence:%d flightTime:%d\n", sequence, flightTime); |
| 4436 | |||
| 4437 | printf("got PACKET_TYPE_VOXEL_DATA, sequence:%d flightTime:%d\n", sequence, flightTime); | ||
| 4438 | } | ||
| 4439 | |||
| 4440 | // add this packet to our list of voxel packets and process them on the voxel processing | ||
| 4441 | app->_voxelProcessor.queueReceivedPacket(senderSockAddr, app->_incomingPacket, bytesReceived); | ||
| 4442 | break; | ||
| 4443 | } | 4265 | } |
| 4444 | case PACKET_TYPE_METAVOXEL_DATA: | 4266 | |
| 4445 | app->_metavoxels.processData(QByteArray((const char*)app->_incomingPacket, bytesReceived), | 4267 | // add this packet to our list of voxel packets and process them on the voxel processing |
| 4446 | senderSockAddr); | 4268 | _voxelProcessor.queueReceivedPacket(senderSockAddr, _incomingPacket, bytesReceived); |
| 4447 | break; | 4269 | break; |
| 4448 | case PACKET_TYPE_BULK_AVATAR_DATA: | ||
| 4449 | NodeList::getInstance()->processBulkNodeData(senderSockAddr, | ||
| 4450 | app->_incomingPacket, | ||
| 4451 | bytesReceived); | ||
| 4452 | getInstance()->_bandwidthMeter.inputStream(BandwidthMeter::AVATARS).updateValue(bytesReceived); | ||
| 4453 | break; | ||
| 4454 | case PACKET_TYPE_AVATAR_URLS: | ||
| 4455 | processAvatarURLsMessage(app->_incomingPacket, bytesReceived); | ||
| 4456 | break; | ||
| 4457 | case PACKET_TYPE_AVATAR_FACE_VIDEO: | ||
| 4458 | processAvatarFaceVideoMessage(app->_incomingPacket, bytesReceived); | ||
| 4459 | break; | ||
| 4460 | case PACKET_TYPE_DATA_SERVER_GET: | ||
| 4461 | case PACKET_TYPE_DATA_SERVER_PUT: | ||
| 4462 | case PACKET_TYPE_DATA_SERVER_SEND: | ||
| 4463 | case PACKET_TYPE_DATA_SERVER_CONFIRM: | ||
| 4464 | DataServerClient::processMessageFromDataServer(app->_incomingPacket, bytesReceived); | ||
| 4465 | break; | ||
| 4466 | default: | ||
| 4467 | NodeList::getInstance()->processNodeData(senderSockAddr, app->_incomingPacket, bytesReceived); | ||
| 4468 | break; | ||
| 4469 | } | 4270 | } |
| 4271 | case PACKET_TYPE_METAVOXEL_DATA: | ||
| 4272 | _metavoxels.processData(QByteArray((const char*) _incomingPacket, bytesReceived), | ||
| 4273 | senderSockAddr); | ||
| 4274 | break; | ||
| 4275 | case PACKET_TYPE_BULK_AVATAR_DATA: | ||
| 4276 | NodeList::getInstance()->processBulkNodeData(senderSockAddr, | ||
| 4277 | _incomingPacket, | ||
| 4278 | bytesReceived); | ||
| 4279 | getInstance()->_bandwidthMeter.inputStream(BandwidthMeter::AVATARS).updateValue(bytesReceived); | ||
| 4280 | break; | ||
| 4281 | case PACKET_TYPE_AVATAR_URLS: | ||
| 4282 | processAvatarURLsMessage(_incomingPacket, bytesReceived); | ||
| 4283 | break; | ||
| 4284 | case PACKET_TYPE_AVATAR_FACE_VIDEO: | ||
| 4285 | processAvatarFaceVideoMessage(_incomingPacket, bytesReceived); | ||
| 4286 | break; | ||
| 4287 | case PACKET_TYPE_DATA_SERVER_GET: | ||
| 4288 | case PACKET_TYPE_DATA_SERVER_PUT: | ||
| 4289 | case PACKET_TYPE_DATA_SERVER_SEND: | ||
| 4290 | case PACKET_TYPE_DATA_SERVER_CONFIRM: | ||
| 4291 | DataServerClient::processMessageFromDataServer(_incomingPacket, bytesReceived); | ||
| 4292 | break; | ||
| 4293 | default: | ||
| 4294 | NodeList::getInstance()->processNodeData(senderSockAddr, _incomingPacket, bytesReceived); | ||
| 4295 | break; | ||
| 4470 | } | 4296 | } |
| 4471 | } else if (!app->_enableNetworkThread) { | ||
| 4472 | break; | ||
| 4473 | } | 4297 | } |
| 4474 | } | 4298 | } |
| 4475 | |||
| 4476 | if (app->_enableNetworkThread) { | ||
| 4477 | pthread_exit(0); | ||
| 4478 | } | ||
| 4479 | return NULL; | ||
| 4480 | } | 4299 | } |
| 4481 | 4300 | ||
| 4482 | void Application::packetSentNotification(ssize_t length) { | 4301 | void Application::packetSentNotification(ssize_t length) { |
| @@ -4493,14 +4312,12 @@ void Application::loadScript() { · 10 unmodified lines | |||
| 4493 | QByteArray fileNameAscii = fileNameString.toLocal8Bit(); | 4312 | QByteArray fileNameAscii = fileNameString.toLocal8Bit(); |
| 4494 | const char* fileName = fileNameAscii.data(); | 4313 | const char* fileName = fileNameAscii.data(); |
| 4495 | 4314 | ||
| 4496 | printf("fileName:%s\n",fileName); | ||
| 4497 | |||
| 4498 | std::ifstream file(fileName, std::ios::in|std::ios::binary|std::ios::ate); | 4315 | std::ifstream file(fileName, std::ios::in|std::ios::binary|std::ios::ate); |
| 4499 | if(!file.is_open()) { | 4316 | if(!file.is_open()) { |
| 4500 | printf("error loading file\n"); | 4317 | qDebug("Error loading file %s", fileName); |
| 4501 | return; | 4318 | return; |
| 4502 | } | 4319 | } |
| 4503 | qDebug("loading file %s...\n", fileName); | 4320 | qDebug("Loading file %s...", fileName); |
| 4504 | 4321 | ||
| 4505 | // get file length.... | 4322 | // get file length.... |
| 4506 | unsigned long fileLength = file.tellg(); | 4323 | unsigned long fileLength = file.tellg(); |
| @@ -4591,7 +4408,7 @@ void Application::updateLocalOctreeCache(bool firstTime) { · 84 unmodified lines | |||
| 4591 | _persistThread = new OctreePersistThread(_voxels.getTree(), | 4408 | _persistThread = new OctreePersistThread(_voxels.getTree(), |
| 4592 | localVoxelCacheFileName.toLocal8Bit().constData(),LOCAL_CACHE_PERSIST_INTERVAL); | 4409 | localVoxelCacheFileName.toLocal8Bit().constData(),LOCAL_CACHE_PERSIST_INTERVAL); |
| 4593 | 4410 | ||
| 4594 | qDebug() << "updateLocalOctreeCache()... localVoxelCacheFileName=" << localVoxelCacheFileName << "\n"; | 4411 | qDebug() << "updateLocalOctreeCache()... localVoxelCacheFileName=" << localVoxelCacheFileName; |
| 4595 | 4412 | ||
| 4596 | if (_persistThread) { | 4413 | if (_persistThread) { |
| 4597 | _voxels.beginLoadingLocalVoxelCache(); // while local voxels are importing, don't do individual node VBO updates | 4414 | _voxels.beginLoadingLocalVoxelCache(); // while local voxels are importing, don't do individual node VBO updates |
| @@ -4667,4 +4484,4 @@ void Application::skipVersion() { · 69 unmodified lines | |||
| 4667 | skipFile->seek(0); | 4484 | skipFile->seek(0); |
| 4668 | skipFile->write(_latestVersion->toStdString().c_str()); | 4485 | skipFile->write(_latestVersion->toStdString().c_str()); |
| 4669 | skipFile->close(); | 4486 | skipFile->close(); |
| 4670 | } | 4487 | } |