Showing the changes to interface/src/Application.cpp (1 of 158 files). Show all
Unified · Split
| @@ -55,7 +55,6 @@ · 54 unmodified lines | ||
| 55 | 55 | #include "Menu.h" |
| 56 | 56 | #include "Swatch.h" |
| 57 | 57 | #include "Util.h" |
| 58 | −#include "devices/LeapManager.h" | |
| 59 | 58 | #include "devices/OculusManager.h" |
| 60 | 59 | #include "devices/TV3DManager.h" |
| 61 | 60 | #include "renderer/ProgramObject.h" |
| @@ -86,17 +85,16 @@ const float MIRROR_FULLSCREEN_DISTANCE = 0.35f; · 24 unmodified lines | ||
| 86 | 85 | const float MIRROR_REARVIEW_DISTANCE = 0.65f; |
| 87 | 86 | const float MIRROR_REARVIEW_BODY_DISTANCE = 2.3f; |
| 88 | 87 | |
| 89 | − | |
| 90 | 88 | void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString &message) { |
| 91 | − fprintf(stdout, "%s", message.toLocal8Bit().constData()); | |
| 92 | − Application::getInstance()->getLogger()->addMessage(message.toLocal8Bit().constData()); | |
| 89 | + QString messageWithNewLine = message + "\n"; | |
| 90 | + fprintf(stdout, "%s", messageWithNewLine.toLocal8Bit().constData()); | |
| 91 | + Application::getInstance()->getLogger()->addMessage(messageWithNewLine.toLocal8Bit().constData()); | |
| 93 | 92 | } |
| 94 | 93 | |
| 95 | 94 | Application::Application(int& argc, char** argv, timeval &startup_time) : |
| 96 | 95 | QApplication(argc, argv), |
| 97 | 96 | _window(new QMainWindow(desktop())), |
| 98 | 97 | _glWidget(new GLCanvas()), |
| 99 | − _displayLevels(false), | |
| 100 | 98 | _frameCount(0), |
| 101 | 99 | _fps(120.0f), |
| 102 | 100 | _justStarted(true), |
| @@ -130,7 +128,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 27 unmodified lines | ||
| 130 | 128 | _perfStatsOn(false), |
| 131 | 129 | _chatEntryOn(false), |
| 132 | 130 | _audio(&_audioScope, STARTUP_JITTER_SAMPLES), |
| 133 | − _stopNetworkReceiveThread(false), | |
| 131 | + _enableProcessVoxelsThread(true), | |
| 134 | 132 | _voxelProcessor(), |
| 135 | 133 | _voxelHideShowThread(&_voxels), |
| 136 | 134 | _voxelEditSender(this), |
| @@ -143,7 +141,8 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 6 unmodified lines | ||
| 143 | 141 | _resetRecentMaxPacketsSoon(true), |
| 144 | 142 | _swatch(NULL), |
| 145 | 143 | _pasteMode(false), |
| 146 | − _logger(new FileLogger()) | |
| 144 | + _logger(new FileLogger()), | |
| 145 | + _persistThread(NULL) | |
| 147 | 146 | { |
| 148 | 147 | _applicationStartupTime = startup_time; |
| 149 | 148 | |
| @@ -156,7 +155,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 6 unmodified lines | ||
| 156 | 155 | // call Menu getInstance static method to set up the menu |
| 157 | 156 | _window->setMenuBar(Menu::getInstance()); |
| 158 | 157 | |
| 159 | − qDebug("[VERSION] Build sequence: %i\n", BUILD_VERSION); | |
| 158 | + qDebug("[VERSION] Build sequence: %i", BUILD_VERSION); | |
| 160 | 159 | |
| 161 | 160 | unsigned int listenPort = 0; // bind to an ephemeral port by default |
| 162 | 161 | const char** constArgv = const_cast<const char**>(argv); |
| @@ -166,6 +165,9 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 3 unmodified lines | ||
| 166 | 165 | } |
| 167 | 166 | |
| 168 | 167 | NodeList* nodeList = NodeList::createInstance(NODE_TYPE_AGENT, listenPort); |
| 168 | + | |
| 169 | + // connect our processDatagrams slot to the QUDPSocket readyRead() signal | |
| 170 | + connect(&nodeList->getNodeSocket(), SIGNAL(readyRead()), SLOT(processDatagrams())); | |
| 169 | 171 | |
| 170 | 172 | // put the audio processing on a separate thread |
| 171 | 173 | QThread* audioThread = new QThread(this); |
| @@ -174,14 +176,12 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 2 unmodified lines | ||
| 174 | 176 | connect(audioThread, SIGNAL(started()), &_audio, SLOT(start())); |
| 175 | 177 | |
| 176 | 178 | audioThread->start(); |
| 179 | + | |
| 180 | + connect(nodeList, SIGNAL(domainChanged(const QString&)), SLOT(domainChanged(const QString&))); | |
| 177 | 181 | |
| 178 | − nodeList->addHook(&_voxels); | |
| 179 | − nodeList->addHook(this); | |
| 180 | − nodeList->addDomainListener(this); | |
| 181 | − nodeList->addDomainListener(&_voxels); | |
| 182 | − | |
| 183 | − // network receive thread and voxel parsing thread are both controlled by the --nonblocking command line | |
| 184 | − _enableProcessVoxelsThread = _enableNetworkThread = !cmdOptionExists(argc, constArgv, "--nonblocking"); | |
| 182 | + connect(nodeList, SIGNAL(nodeKilled(SharedNodePointer)), SLOT(nodeKilled(SharedNodePointer))); | |
| 183 | + connect(nodeList, SIGNAL(nodeAdded(SharedNodePointer)), &_voxels, SLOT(nodeAdded(SharedNodePointer))); | |
| 184 | + connect(nodeList, SIGNAL(nodeKilled(SharedNodePointer)), &_voxels, SLOT(nodeKilled(SharedNodePointer))); | |
| 185 | 185 | |
| 186 | 186 | // read the ApplicationInfo.ini file for Name/Version/Domain information |
| 187 | 187 | QSettings applicationInfo("resources/info/ApplicationInfo.ini", QSettings::IniFormat); |
| @@ -209,8 +209,8 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 21 unmodified lines | ||
| 209 | 209 | #endif |
| 210 | 210 | |
| 211 | 211 | // tell the NodeList instance who to tell the domain server we care about |
| 212 | − const char nodeTypesOfInterest[] = {NODE_TYPE_AUDIO_MIXER, NODE_TYPE_AVATAR_MIXER, NODE_TYPE_VOXEL_SERVER, | |
| 213 | − NODE_TYPE_PARTICLE_SERVER}; | |
| 212 | + const char nodeTypesOfInterest[] = {NODE_TYPE_AUDIO_MIXER, NODE_TYPE_AVATAR_MIXER, NODE_TYPE_VOXEL_SERVER, | |
| 213 | + NODE_TYPE_PARTICLE_SERVER, NODE_TYPE_METAVOXEL_SERVER}; | |
| 214 | 214 | nodeList->setNodeTypesOfInterest(nodeTypesOfInterest, sizeof(nodeTypesOfInterest)); |
| 215 | 215 | |
| 216 | 216 | QTimer* silentNodeTimer = new QTimer(this); |
| @@ -250,6 +250,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 33 unmodified lines | ||
| 250 | 250 | |
| 251 | 251 | // Set the sixense filtering |
| 252 | 252 | _sixenseManager.setFilter(Menu::getInstance()->isOptionChecked(MenuOption::FilterSixense)); |
| 253 | + | |
| 253 | 254 | } |
| 254 | 255 | |
| 255 | 256 | Application::~Application() { |
| @@ -264,9 +265,6 @@ Application::~Application() { · 8 unmodified lines | ||
| 264 | 265 | _audio.thread()->wait(); |
| 265 | 266 | |
| 266 | 267 | storeSizeAndPosition(); |
| 267 | − NodeList::getInstance()->removeHook(&_voxels); | |
| 268 | − NodeList::getInstance()->removeHook(this); | |
| 269 | − NodeList::getInstance()->removeDomainListener(this); | |
| 270 | 268 | |
| 271 | 269 | _sharedVoxelSystem.changeTree(new VoxelTree); |
| 272 | 270 | |
| @@ -275,7 +273,6 @@ Application::~Application() { · 2 unmodified lines | ||
| 275 | 273 | |
| 276 | 274 | delete _logger; |
| 277 | 275 | delete _settings; |
| 278 | − delete _followMode; | |
| 279 | 276 | delete _glWidget; |
| 280 | 277 | } |
| 281 | 278 | |
| @@ -311,7 +308,7 @@ void Application::storeSizeAndPosition() { · 29 unmodified lines | ||
| 311 | 308 | } |
| 312 | 309 | |
| 313 | 310 | void Application::initializeGL() { |
| 314 | − qDebug( "Created Display Window.\n" ); | |
| 311 | + qDebug( "Created Display Window."); | |
| 315 | 312 | |
| 316 | 313 | // initialize glut for shape drawing; Qt apparently initializes it on OS X |
| 317 | 314 | #ifndef __APPLE__ |
| @@ -326,16 +323,10 @@ void Application::initializeGL() { · 8 unmodified lines | ||
| 326 | 323 | _viewFrustumOffsetCamera.setFarClip(500.0 * TREE_SCALE); |
| 327 | 324 | |
| 328 | 325 | initDisplay(); |
| 329 | − qDebug( "Initialized Display.\n" ); | |
| 326 | + qDebug( "Initialized Display."); | |
| 330 | 327 | |
| 331 | 328 | init(); |
| 332 | − qDebug( "Init() complete.\n" ); | |
| 333 | − | |
| 334 | − // create thread for receipt of data via UDP | |
| 335 | − if (_enableNetworkThread) { | |
| 336 | − pthread_create(&_networkReceiveThread, NULL, networkReceive, NULL); | |
| 337 | − qDebug("Network receive thread created.\n"); | |
| 338 | − } | |
| 329 | + qDebug( "init() complete."); | |
| 339 | 330 | |
| 340 | 331 | // create thread for parsing of voxel data independent of the main network and rendering threads |
| 341 | 332 | _voxelProcessor.initialize(_enableProcessVoxelsThread); |
| @@ -343,7 +334,7 @@ void Application::initializeGL() { · 1 unmodified line | ||
| 343 | 334 | _voxelHideShowThread.initialize(_enableProcessVoxelsThread); |
| 344 | 335 | _particleEditSender.initialize(_enableProcessVoxelsThread); |
| 345 | 336 | if (_enableProcessVoxelsThread) { |
| 346 | − qDebug("Voxel parsing thread created.\n"); | |
| 337 | + qDebug("Voxel parsing thread created."); | |
| 347 | 338 | } |
| 348 | 339 | |
| 349 | 340 | // call terminate before exiting |
| @@ -363,9 +354,7 @@ void Application::initializeGL() { · 13 unmodified lines | ||
| 363 | 354 | if (_justStarted) { |
| 364 | 355 | float startupTime = (usecTimestampNow() - usecTimestamp(&_applicationStartupTime)) / 1000000.0; |
| 365 | 356 | _justStarted = false; |
| 366 | − char title[50]; | |
| 367 | − sprintf(title, "Interface: %4.2f seconds\n", startupTime); | |
| 368 | − qDebug("%s", title); | |
| 357 | + qDebug("Startup time: %4.2f seconds.", startupTime); | |
| 369 | 358 | const char LOGSTASH_INTERFACE_START_TIME_KEY[] = "interface-start-time"; |
| 370 | 359 | |
| 371 | 360 | // ask the Logstash class to record the startup time |
| @@ -672,9 +661,7 @@ void Application::keyPressEvent(QKeyEvent* event) { · 300 unmodified lines | ||
| 672 | 661 | _audioScope.inputPaused = !_audioScope.inputPaused; |
| 673 | 662 | break; |
| 674 | 663 | case Qt::Key_L: |
| 675 | − if (!isShifted && !isMeta) { | |
| 676 | − _displayLevels = !_displayLevels; | |
| 677 | − } else if (isShifted) { | |
| 664 | + if (isShifted) { | |
| 678 | 665 | Menu::getInstance()->triggerOption(MenuOption::LodTools); |
| 679 | 666 | } else if (isMeta) { |
| 680 | 667 | Menu::getInstance()->triggerOption(MenuOption::Log); |
| @@ -1125,7 +1112,7 @@ void Application::mouseMoveEvent(QMouseEvent* event) { · 444 unmodified lines | ||
| 1125 | 1112 | return; |
| 1126 | 1113 | } |
| 1127 | 1114 | if (_isHoverVoxel) { |
| 1128 | − _myAvatar.orbit(glm::vec3(_hoverVoxel.x, _hoverVoxel.y, _hoverVoxel.z) * (float)TREE_SCALE, deltaX, deltaY); | |
| 1115 | + _myAvatar.orbit(getMouseVoxelWorldCoordinates(_hoverVoxel), deltaX, deltaY); | |
| 1129 | 1116 | return; |
| 1130 | 1117 | } |
| 1131 | 1118 | } |
| @@ -1285,7 +1272,7 @@ void Application::wheelEvent(QWheelEvent* event) { · 153 unmodified lines | ||
| 1285 | 1272 | void Application::sendPingPackets() { |
| 1286 | 1273 | |
| 1287 | 1274 | const char nodesToPing[] = {NODE_TYPE_VOXEL_SERVER, NODE_TYPE_PARTICLE_SERVER, |
| 1288 | − NODE_TYPE_AUDIO_MIXER, NODE_TYPE_AVATAR_MIXER}; | |
| 1275 | + NODE_TYPE_AUDIO_MIXER, NODE_TYPE_AVATAR_MIXER, NODE_TYPE_METAVOXEL_SERVER}; | |
| 1289 | 1276 | |
| 1290 | 1277 | unsigned char pingPacket[MAX_PACKET_SIZE]; |
| 1291 | 1278 | int length = NodeList::getInstance()->fillPingPacket(pingPacket); |
| @@ -1343,16 +1330,12 @@ void Application::timer() { · 51 unmodified lines | ||
| 1343 | 1330 | |
| 1344 | 1331 | gettimeofday(&_timerStart, NULL); |
| 1345 | 1332 | |
| 1346 | − // if we haven't detected gyros, check for them now | |
| 1347 | − if (!_serialHeadSensor.isActive()) { | |
| 1348 | − _serialHeadSensor.pair(); | |
| 1349 | − } | |
| 1350 | − | |
| 1351 | 1333 | // ask the node list to check in with the domain server |
| 1352 | 1334 | NodeList::getInstance()->sendDomainServerCheckIn(); |
| 1353 | 1335 | |
| 1354 | − // give the MyAvatar object position to the Profile so it can propagate to the data-server | |
| 1336 | + // give the MyAvatar object position, orientation to the Profile so it can propagate to the data-server | |
| 1355 | 1337 | _profile.updatePosition(_myAvatar.getPosition()); |
| 1338 | + _profile.updateOrientation(_myAvatar.getOrientation()); | |
| 1356 | 1339 | } |
| 1357 | 1340 | |
| 1358 | 1341 | static glm::vec3 getFaceVector(BoxFace face) { |
| @@ -1421,7 +1404,6 @@ void Application::terminate() { · 62 unmodified lines | ||
| 1421 | 1404 | // Close serial port |
| 1422 | 1405 | // close(serial_fd); |
| 1423 | 1406 | |
| 1424 | − LeapManager::terminate(); | |
| 1425 | 1407 | Menu::getInstance()->saveSettings(); |
| 1426 | 1408 | _rearMirrorTools->saveSettings(_settings); |
| 1427 | 1409 | _settings->sync(); |
| @@ -1429,22 +1411,19 @@ void Application::terminate() { · 1 unmodified line | ||
| 1429 | 1411 | // let the avatar mixer know we're out |
| 1430 | 1412 | NodeList::getInstance()->sendKillNode(&NODE_TYPE_AVATAR_MIXER, 1); |
| 1431 | 1413 | |
| 1432 | − if (_enableNetworkThread) { | |
| 1433 | − _stopNetworkReceiveThread = true; | |
| 1434 | − pthread_join(_networkReceiveThread, NULL); | |
| 1435 | − } | |
| 1436 | − | |
| 1437 | 1414 | printf(""); |
| 1438 | 1415 | _voxelProcessor.terminate(); |
| 1439 | 1416 | _voxelHideShowThread.terminate(); |
| 1440 | 1417 | _voxelEditSender.terminate(); |
| 1441 | 1418 | _particleEditSender.terminate(); |
| 1419 | + _persistThread->terminate(); | |
| 1420 | + _persistThread = NULL; | |
| 1442 | 1421 | } |
| 1443 | 1422 | |
| 1444 | 1423 | static Avatar* processAvatarMessageHeader(unsigned char*& packetData, size_t& dataBytes) { |
| 1445 | 1424 | // record the packet for stats-tracking |
| 1446 | 1425 | Application::getInstance()->getBandwidthMeter()->inputStream(BandwidthMeter::AVATARS).updateValue(dataBytes); |
| 1447 | − Node* avatarMixerNode = NodeList::getInstance()->soloNodeOfType(NODE_TYPE_AVATAR_MIXER); | |
| 1426 | + SharedNodePointer avatarMixerNode = NodeList::getInstance()->soloNodeOfType(NODE_TYPE_AVATAR_MIXER); | |
| 1448 | 1427 | if (avatarMixerNode) { |
| 1449 | 1428 | avatarMixerNode->recordBytesReceived(dataBytes); |
| 1450 | 1429 | } |
| @@ -1461,7 +1440,7 @@ static Avatar* processAvatarMessageHeader(unsigned char*& packetData, size_t& da · 10 unmodified lines | ||
| 1461 | 1440 | dataBytes -= NUM_BYTES_RFC4122_UUID; |
| 1462 | 1441 | |
| 1463 | 1442 | // make sure the node exists |
| 1464 | − Node* node = NodeList::getInstance()->nodeWithUUID(nodeUUID); | |
| 1443 | + SharedNodePointer node = NodeList::getInstance()->nodeWithUUID(nodeUUID); | |
| 1465 | 1444 | if (!node || !node->getLinkedData()) { |
| 1466 | 1445 | return NULL; |
| 1467 | 1446 | } |
| @@ -1620,10 +1599,9 @@ void Application::makeVoxel(glm::vec3 position, · 152 unmodified lines | ||
| 1620 | 1599 | isDestructive); |
| 1621 | 1600 | } |
| 1622 | 1601 | |
| 1623 | −const glm::vec3 Application::getMouseVoxelWorldCoordinates(const VoxelDetail _mouseVoxel) { | |
| 1624 | − return glm::vec3((_mouseVoxel.x + _mouseVoxel.s / 2.f) * TREE_SCALE, | |
| 1625 | − (_mouseVoxel.y + _mouseVoxel.s / 2.f) * TREE_SCALE, | |
| 1626 | − (_mouseVoxel.z + _mouseVoxel.s / 2.f) * TREE_SCALE); | |
| 1602 | +glm::vec3 Application::getMouseVoxelWorldCoordinates(const VoxelDetail& mouseVoxel) { | |
| 1603 | + return glm::vec3((mouseVoxel.x + mouseVoxel.s / 2.f) * TREE_SCALE, (mouseVoxel.y + mouseVoxel.s / 2.f) * TREE_SCALE, | |
| 1604 | + (mouseVoxel.z + mouseVoxel.s / 2.f) * TREE_SCALE); | |
| 1627 | 1605 | } |
| 1628 | 1606 | |
| 1629 | 1607 | const float NUDGE_PRECISION_MIN = 1 / pow(2.0, 12.0); |
| @@ -1710,9 +1688,9 @@ void Application::exportVoxels() { · 80 unmodified lines | ||
| 1710 | 1688 | |
| 1711 | 1689 | void Application::importVoxels() { |
| 1712 | 1690 | if (_voxelImporter.exec()) { |
| 1713 | − qDebug("[DEBUG] Import succedded.\n"); | |
| 1691 | + qDebug("[DEBUG] Import succeeded."); | |
| 1714 | 1692 | } else { |
| 1715 | − qDebug("[DEBUG] Import failed.\n"); | |
| 1693 | + qDebug("[DEBUG] Import failed."); | |
| 1716 | 1694 | } |
| 1717 | 1695 | |
| 1718 | 1696 | // restore the main window's active state |
| @@ -1886,8 +1864,6 @@ void Application::init() { · 167 unmodified lines | ||
| 1886 | 1864 | Qt::QueuedConnection); |
| 1887 | 1865 | } |
| 1888 | 1866 | |
| 1889 | − LeapManager::initialize(); | |
| 1890 | − | |
| 1891 | 1867 | gettimeofday(&_timerStart, NULL); |
| 1892 | 1868 | gettimeofday(&_lastTimeUpdated, NULL); |
| 1893 | 1869 | |
| @@ -1895,7 +1871,7 @@ void Application::init() { · 1 unmodified line | ||
| 1895 | 1871 | if (Menu::getInstance()->getAudioJitterBufferSamples() != 0) { |
| 1896 | 1872 | _audio.setJitterBufferSamples(Menu::getInstance()->getAudioJitterBufferSamples()); |
| 1897 | 1873 | } |
| 1898 | − qDebug("Loaded settings.\n"); | |
| 1874 | + qDebug("Loaded settings"); | |
| 1899 | 1875 | |
| 1900 | 1876 | if (!_profile.getUsername().isEmpty()) { |
| 1901 | 1877 | // we have a username for this avatar, ask the data-server for the mesh URL for this avatar |
| @@ -1929,10 +1905,6 @@ void Application::init() { · 27 unmodified lines | ||
| 1929 | 1905 | _glWidget->width(), |
| 1930 | 1906 | _glWidget->height()); |
| 1931 | 1907 | |
| 1932 | − _followMode = new QAction(this); | |
| 1933 | − connect(_followMode, SIGNAL(triggered()), this, SLOT(toggleFollowMode())); | |
| 1934 | − _pieMenu.addAction(_followMode); | |
| 1935 | − | |
| 1936 | 1908 | _audio.init(_glWidget); |
| 1937 | 1909 | |
| 1938 | 1910 | _rearMirrorTools = new RearMirrorTools(_glWidget, _mirrorViewRect, _settings); |
| @@ -1940,6 +1912,9 @@ void Application::init() { · 1 unmodified line | ||
| 1940 | 1912 | connect(_rearMirrorTools, SIGNAL(restoreView()), SLOT(restoreMirrorView())); |
| 1941 | 1913 | connect(_rearMirrorTools, SIGNAL(shrinkView()), SLOT(shrinkMirrorView())); |
| 1942 | 1914 | connect(_rearMirrorTools, SIGNAL(resetView()), SLOT(resetSensors())); |
| 1915 | + | |
| 1916 | + | |
| 1917 | + updateLocalOctreeCache(true); | |
| 1943 | 1918 | } |
| 1944 | 1919 | |
| 1945 | 1920 | void Application::closeMirrorView() { |
| @@ -1987,16 +1962,16 @@ void Application::updateLookatTargetAvatar(const glm::vec3& mouseRayOrigin, cons · 41 unmodified lines | ||
| 1987 | 1962 | Avatar* Application::findLookatTargetAvatar(const glm::vec3& mouseRayOrigin, const glm::vec3& mouseRayDirection, |
| 1988 | 1963 | glm::vec3& eyePosition, QUuid& nodeUUID = DEFAULT_NODE_ID_REF) { |
| 1989 | 1964 | |
| 1990 | − NodeList* nodeList = NodeList::getInstance(); | |
| 1991 | − for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) { | |
| 1965 | + foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) { | |
| 1992 | 1966 | if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) { |
| 1993 | 1967 | Avatar* avatar = (Avatar*)node->getLinkedData(); |
| 1994 | 1968 | float distance; |
| 1969 | + | |
| 1995 | 1970 | if (avatar->findRayIntersection(mouseRayOrigin, mouseRayDirection, distance)) { |
| 1996 | 1971 | // rescale to compensate for head embiggening |
| 1997 | 1972 | eyePosition = (avatar->getHead().calculateAverageEyePosition() - avatar->getHead().getScalePivot()) * |
| 1998 | − (avatar->getScale() / avatar->getHead().getScale()) + avatar->getHead().getScalePivot(); | |
| 1999 | − | |
| 1973 | + (avatar->getScale() / avatar->getHead().getScale()) + avatar->getHead().getScalePivot(); | |
| 1974 | + | |
| 2000 | 1975 | _lookatIndicatorScale = avatar->getHead().getScale(); |
| 2001 | 1976 | _lookatOtherPosition = avatar->getHead().getPosition(); |
| 2002 | 1977 | nodeUUID = avatar->getOwningNode()->getUUID(); |
| @@ -2004,6 +1979,7 @@ Avatar* Application::findLookatTargetAvatar(const glm::vec3& mouseRayOrigin, con · 1 unmodified line | ||
| 2004 | 1979 | } |
| 2005 | 1980 | } |
| 2006 | 1981 | } |
| 1982 | + | |
| 2007 | 1983 | return NULL; |
| 2008 | 1984 | } |
| 2009 | 1985 | |
| @@ -2028,71 +2004,6 @@ void Application::renderLookatIndicator(glm::vec3 pointOfInterest) { · 18 unmodified lines | ||
| 2028 | 2004 | renderCircle(haloOrigin, INDICATOR_RADIUS, IDENTITY_UP, NUM_SEGMENTS); |
| 2029 | 2005 | } |
| 2030 | 2006 | |
| 2031 | −void maybeBeginFollowIndicator(bool& began) { | |
| 2032 | − if (!began) { | |
| 2033 | − Application::getInstance()->getGlowEffect()->begin(); | |
| 2034 | − glLineWidth(5); | |
| 2035 | − glBegin(GL_LINES); | |
| 2036 | − began = true; | |
| 2037 | − } | |
| 2038 | −} | |
| 2039 | − | |
| 2040 | −void Application::renderFollowIndicator() { | |
| 2041 | − NodeList* nodeList = NodeList::getInstance(); | |
| 2042 | − | |
| 2043 | − // initialize lazily so that we don't enable the glow effect unnecessarily | |
| 2044 | − bool began = false; | |
| 2045 | − | |
| 2046 | − for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); ++node) { | |
| 2047 | − if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) { | |
| 2048 | − Avatar* avatar = (Avatar *) node->getLinkedData(); | |
| 2049 | − Avatar* leader = NULL; | |
| 2050 | − | |
| 2051 | − if (!avatar->getLeaderUUID().isNull()) { | |
| 2052 | − if (avatar->getLeaderUUID() == NodeList::getInstance()->getOwnerUUID()) { | |
| 2053 | − leader = &_myAvatar; | |
| 2054 | − } else { | |
| 2055 | − for (NodeList::iterator it = nodeList->begin(); it != nodeList->end(); ++it) { | |
| 2056 | − if(it->getUUID() == avatar->getLeaderUUID() | |
| 2057 | − && it->getType() == NODE_TYPE_AGENT) { | |
| 2058 | − leader = (Avatar*) it->getLinkedData(); | |
| 2059 | − } | |
| 2060 | − } | |
| 2061 | − } | |
| 2062 | − | |
| 2063 | − if (leader != NULL) { | |
| 2064 | − maybeBeginFollowIndicator(began); | |
| 2065 | − glColor3f(1.f, 0.f, 0.f); | |
| 2066 | − glVertex3f((avatar->getHead().getPosition().x + avatar->getPosition().x) / 2.f, | |
| 2067 | − (avatar->getHead().getPosition().y + avatar->getPosition().y) / 2.f, | |
| 2068 | − (avatar->getHead().getPosition().z + avatar->getPosition().z) / 2.f); | |
| 2069 | − glColor3f(0.f, 1.f, 0.f); | |
| 2070 | − glVertex3f((leader->getHead().getPosition().x + leader->getPosition().x) / 2.f, | |
| 2071 | − (leader->getHead().getPosition().y + leader->getPosition().y) / 2.f, | |
| 2072 | − (leader->getHead().getPosition().z + leader->getPosition().z) / 2.f); | |
| 2073 | − } | |
| 2074 | − } | |
| 2075 | − } | |
| 2076 | − } | |
| 2077 | − | |
| 2078 | − if (_myAvatar.getLeadingAvatar() != NULL) { | |
| 2079 | − maybeBeginFollowIndicator(began); | |
| 2080 | − glColor3f(1.f, 0.f, 0.f); | |
| 2081 | − glVertex3f((_myAvatar.getHead().getPosition().x + _myAvatar.getPosition().x) / 2.f, | |
| 2082 | − (_myAvatar.getHead().getPosition().y + _myAvatar.getPosition().y) / 2.f, | |
| 2083 | − (_myAvatar.getHead().getPosition().z + _myAvatar.getPosition().z) / 2.f); | |
| 2084 | − glColor3f(0.f, 1.f, 0.f); | |
| 2085 | − glVertex3f((_myAvatar.getLeadingAvatar()->getHead().getPosition().x + _myAvatar.getLeadingAvatar()->getPosition().x) / 2.f, | |
| 2086 | − (_myAvatar.getLeadingAvatar()->getHead().getPosition().y + _myAvatar.getLeadingAvatar()->getPosition().y) / 2.f, | |
| 2087 | − (_myAvatar.getLeadingAvatar()->getHead().getPosition().z + _myAvatar.getLeadingAvatar()->getPosition().z) / 2.f); | |
| 2088 | − } | |
| 2089 | − | |
| 2090 | − if (began) { | |
| 2091 | − glEnd(); | |
| 2092 | − _glowEffect.end(); | |
| 2093 | − } | |
| 2094 | −} | |
| 2095 | − | |
| 2096 | 2007 | void Application::renderHighlightVoxel(VoxelDetail voxel) { |
| 2097 | 2008 | glDisable(GL_LIGHTING); |
| 2098 | 2009 | glPushMatrix(); |
| @@ -2110,10 +2021,9 @@ void Application::renderHighlightVoxel(VoxelDetail voxel) { · 11 unmodified lines | ||
| 2110 | 2021 | void Application::updateAvatars(float deltaTime, glm::vec3 mouseRayOrigin, glm::vec3 mouseRayDirection) { |
| 2111 | 2022 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); |
| 2112 | 2023 | PerformanceWarning warn(showWarnings, "Application::updateAvatars()"); |
| 2113 | − NodeList* nodeList = NodeList::getInstance(); | |
| 2114 | − | |
| 2115 | − for(NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) { | |
| 2116 | − node->lock(); | |
| 2024 | + | |
| 2025 | + foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) { | |
| 2026 | + QMutexLocker(&node->getMutex()); | |
| 2117 | 2027 | if (node->getLinkedData()) { |
| 2118 | 2028 | Avatar *avatar = (Avatar *)node->getLinkedData(); |
| 2119 | 2029 | if (!avatar->isInitialized()) { |
| @@ -2122,16 +2032,18 @@ void Application::updateAvatars(float deltaTime, glm::vec3 mouseRayOrigin, glm:: · 2 unmodified lines | ||
| 2122 | 2032 | avatar->simulate(deltaTime, NULL); |
| 2123 | 2033 | avatar->setMouseRay(mouseRayOrigin, mouseRayDirection); |
| 2124 | 2034 | } |
| 2125 | − node->unlock(); | |
| 2126 | 2035 | } |
| 2127 | 2036 | |
| 2128 | 2037 | // simulate avatar fades |
| 2129 | 2038 | for (vector<Avatar*>::iterator fade = _avatarFades.begin(); fade != _avatarFades.end(); fade++) { |
| 2130 | 2039 | Avatar* avatar = *fade; |
| 2131 | 2040 | const float SHRINK_RATE = 0.9f; |
| 2132 | − avatar->setNewScale(avatar->getNewScale() * SHRINK_RATE); | |
| 2133 | − const float MINIMUM_SCALE = 0.001f; | |
| 2134 | − if (avatar->getNewScale() < MINIMUM_SCALE) { | |
| 2041 | + | |
| 2042 | + avatar->setTargetScale(avatar->getScale() * SHRINK_RATE); | |
| 2043 | + | |
| 2044 | + const float MIN_FADE_SCALE = 0.001; | |
| 2045 | + | |
| 2046 | + if (avatar->getTargetScale() < MIN_FADE_SCALE) { | |
| 2135 | 2047 | delete avatar; |
| 2136 | 2048 | _avatarFades.erase(fade--); |
| 2137 | 2049 | |
| @@ -2367,9 +2279,6 @@ void Application::updateHandAndTouch(float deltaTime) { · 229 unmodified lines | ||
| 2367 | 2279 | void Application::updateLeap(float deltaTime) { |
| 2368 | 2280 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); |
| 2369 | 2281 | PerformanceWarning warn(showWarnings, "Application::updateLeap()"); |
| 2370 | − | |
| 2371 | − LeapManager::enableFakeFingers(Menu::getInstance()->isOptionChecked(MenuOption::SimulateLeapHand)); | |
| 2372 | − LeapManager::nextFrame(); | |
| 2373 | 2282 | } |
| 2374 | 2283 | |
| 2375 | 2284 | void Application::updateSixense(float deltaTime) { |
| @@ -2382,27 +2291,19 @@ void Application::updateSixense(float deltaTime) { · 6 unmodified lines | ||
| 2382 | 2291 | void Application::updateSerialDevices(float deltaTime) { |
| 2383 | 2292 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); |
| 2384 | 2293 | PerformanceWarning warn(showWarnings, "Application::updateSerialDevices()"); |
| 2385 | − | |
| 2386 | − if (_serialHeadSensor.isActive()) { | |
| 2387 | − _serialHeadSensor.readData(deltaTime); | |
| 2388 | − } | |
| 2389 | 2294 | } |
| 2390 | 2295 | |
| 2391 | 2296 | void Application::updateThreads(float deltaTime) { |
| 2392 | 2297 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); |
| 2393 | 2298 | PerformanceWarning warn(showWarnings, "Application::updateThreads()"); |
| 2394 | 2299 | |
| 2395 | − // read incoming packets from network | |
| 2396 | − if (!_enableNetworkThread) { | |
| 2397 | − networkReceive(0); | |
| 2398 | − } | |
| 2399 | − | |
| 2400 | 2300 | // parse voxel packets |
| 2401 | 2301 | if (!_enableProcessVoxelsThread) { |
| 2402 | 2302 | _voxelProcessor.threadRoutine(); |
| 2403 | 2303 | _voxelHideShowThread.threadRoutine(); |
| 2404 | 2304 | _voxelEditSender.threadRoutine(); |
| 2405 | 2305 | _particleEditSender.threadRoutine(); |
| 2306 | + _persistThread->threadRoutine(); | |
| 2406 | 2307 | } |
| 2407 | 2308 | } |
| 2408 | 2309 | |
| @@ -2628,41 +2529,6 @@ void Application::updateAvatar(float deltaTime) { · 219 unmodified lines | ||
| 2628 | 2529 | _headMouseY -= headVelocity.x * HEADMOUSE_FACESHIFT_PITCH_SCALE; |
| 2629 | 2530 | } |
| 2630 | 2531 | |
| 2631 | − if (_serialHeadSensor.isActive()) { | |
| 2632 | − | |
| 2633 | − // Grab latest readings from the gyros | |
| 2634 | − float measuredPitchRate = _serialHeadSensor.getLastPitchRate(); | |
| 2635 | − float measuredYawRate = _serialHeadSensor.getLastYawRate(); | |
| 2636 | − | |
| 2637 | − // Update gyro-based mouse (X,Y on screen) | |
| 2638 | − const float MIN_MOUSE_RATE = 3.0; | |
| 2639 | − const float HORIZONTAL_PIXELS_PER_DEGREE = 2880.f / 45.f; | |
| 2640 | − const float VERTICAL_PIXELS_PER_DEGREE = 1800.f / 30.f; | |
| 2641 | − if (powf(measuredYawRate * measuredYawRate + | |
| 2642 | − measuredPitchRate * measuredPitchRate, 0.5) > MIN_MOUSE_RATE) { | |
| 2643 | − _headMouseX -= measuredYawRate * HORIZONTAL_PIXELS_PER_DEGREE * deltaTime; | |
| 2644 | − _headMouseY -= measuredPitchRate * VERTICAL_PIXELS_PER_DEGREE * deltaTime; | |
| 2645 | − } | |
| 2646 | − | |
| 2647 | − const float MIDPOINT_OF_SCREEN = 0.5; | |
| 2648 | − | |
| 2649 | − // Only use gyro to set lookAt if mouse hasn't selected an avatar | |
| 2650 | − if (!_lookatTargetAvatar) { | |
| 2651 | − | |
| 2652 | − // Set lookAtPosition if an avatar is at the center of the screen | |
| 2653 | − glm::vec3 screenCenterRayOrigin, screenCenterRayDirection; | |
| 2654 | − _viewFrustum.computePickRay(MIDPOINT_OF_SCREEN, MIDPOINT_OF_SCREEN, screenCenterRayOrigin, screenCenterRayDirection); | |
| 2655 | − | |
| 2656 | − glm::vec3 eyePosition; | |
| 2657 | − updateLookatTargetAvatar(screenCenterRayOrigin, screenCenterRayDirection, eyePosition); | |
| 2658 | − if (_lookatTargetAvatar) { | |
| 2659 | − glm::vec3 myLookAtFromMouse(eyePosition); | |
| 2660 | − _myAvatar.getHead().setLookAtPosition(myLookAtFromMouse); | |
| 2661 | − } | |
| 2662 | − } | |
| 2663 | − | |
| 2664 | − } | |
| 2665 | − | |
| 2666 | 2532 | // Constrain head-driven mouse to edges of screen |
| 2667 | 2533 | _headMouseX = glm::clamp(_headMouseX, 0, _glWidget->width()); |
| 2668 | 2534 | _headMouseY = glm::clamp(_headMouseY, 0, _glWidget->height()); |
| @@ -2743,39 +2609,36 @@ void Application::queryOctree(NODE_TYPE serverType, PACKET_TYPE packetType, Node · 74 unmodified lines | ||
| 2743 | 2609 | |
| 2744 | 2610 | unsigned char voxelQueryPacket[MAX_PACKET_SIZE]; |
| 2745 | 2611 | |
| 2746 | − NodeList* nodeList = NodeList::getInstance(); | |
| 2747 | − | |
| 2748 | 2612 | // Iterate all of the nodes, and get a count of how many voxel servers we have... |
| 2749 | 2613 | int totalServers = 0; |
| 2750 | 2614 | int inViewServers = 0; |
| 2751 | 2615 | int unknownJurisdictionServers = 0; |
| 2752 | − | |
| 2753 | − for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) { | |
| 2754 | − | |
| 2616 | + | |
| 2617 | + foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) { | |
| 2755 | 2618 | // only send to the NodeTypes that are serverType |
| 2756 | 2619 | if (node->getActiveSocket() != NULL && node->getType() == serverType) { |
| 2757 | 2620 | totalServers++; |
| 2758 | − | |
| 2621 | + | |
| 2759 | 2622 | // get the server bounds for this server |
| 2760 | 2623 | QUuid nodeUUID = node->getUUID(); |
| 2761 | − | |
| 2624 | + | |
| 2762 | 2625 | // if we haven't heard from this voxel server, go ahead and send it a query, so we |
| 2763 | 2626 | // can get the jurisdiction... |
| 2764 | 2627 | if (jurisdictions.find(nodeUUID) == jurisdictions.end()) { |
| 2765 | 2628 | unknownJurisdictionServers++; |
| 2766 | 2629 | } else { |
| 2767 | 2630 | const JurisdictionMap& map = (jurisdictions)[nodeUUID]; |
| 2768 | − | |
| 2631 | + | |
| 2769 | 2632 | unsigned char* rootCode = map.getRootOctalCode(); |
| 2770 | − | |
| 2633 | + | |
| 2771 | 2634 | if (rootCode) { |
| 2772 | 2635 | VoxelPositionSize rootDetails; |
| 2773 | 2636 | voxelDetailsForCode(rootCode, rootDetails); |
| 2774 | 2637 | AABox serverBounds(glm::vec3(rootDetails.x, rootDetails.y, rootDetails.z), rootDetails.s); |
| 2775 | 2638 | serverBounds.scale(TREE_SCALE); |
| 2776 | − | |
| 2639 | + | |
| 2777 | 2640 | ViewFrustum::location serverFrustumLocation = _viewFrustum.boxInFrustum(serverBounds); |
| 2778 | − | |
| 2641 | + | |
| 2779 | 2642 | if (serverFrustumLocation != ViewFrustum::OUTSIDE) { |
| 2780 | 2643 | inViewServers++; |
| 2781 | 2644 | } |
| @@ -2785,7 +2648,7 @@ void Application::queryOctree(NODE_TYPE serverType, PACKET_TYPE packetType, Node · 3 unmodified lines | ||
| 2785 | 2648 | } |
| 2786 | 2649 | |
| 2787 | 2650 | if (wantExtraDebugging && unknownJurisdictionServers > 0) { |
| 2788 | − qDebug("Servers: total %d, in view %d, unknown jurisdiction %d \n", | |
| 2651 | + qDebug("Servers: total %d, in view %d, unknown jurisdiction %d", | |
| 2789 | 2652 | totalServers, inViewServers, unknownJurisdictionServers); |
| 2790 | 2653 | } |
| 2791 | 2654 | |
| @@ -2806,38 +2669,40 @@ void Application::queryOctree(NODE_TYPE serverType, PACKET_TYPE packetType, Node · 14 unmodified lines | ||
| 2806 | 2669 | } |
| 2807 | 2670 | |
| 2808 | 2671 | if (wantExtraDebugging && unknownJurisdictionServers > 0) { |
| 2809 | − qDebug("perServerPPS: %d perUnknownServer: %d\n", perServerPPS, perUnknownServer); | |
| 2672 | + qDebug("perServerPPS: %d perUnknownServer: %d", perServerPPS, perUnknownServer); | |
| 2810 | 2673 | } |
| 2811 | − | |
| 2812 | − for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) { | |
| 2674 | + | |
| 2675 | + NodeList* nodeList = NodeList::getInstance(); | |
| 2676 | + | |
| 2677 | + foreach (const SharedNodePointer& node, nodeList->getNodeHash()) { | |
| 2813 | 2678 | // only send to the NodeTypes that are serverType |
| 2814 | 2679 | if (node->getActiveSocket() != NULL && node->getType() == serverType) { |
| 2815 | − | |
| 2816 | − | |
| 2680 | + | |
| 2681 | + | |
| 2817 | 2682 | // get the server bounds for this server |
| 2818 | 2683 | QUuid nodeUUID = node->getUUID(); |
| 2819 | − | |
| 2684 | + | |
| 2820 | 2685 | bool inView = false; |
| 2821 | 2686 | bool unknownView = false; |
| 2822 | − | |
| 2687 | + | |
| 2823 | 2688 | // if we haven't heard from this voxel server, go ahead and send it a query, so we |
| 2824 | 2689 | // can get the jurisdiction... |
| 2825 | 2690 | if (jurisdictions.find(nodeUUID) == jurisdictions.end()) { |
| 2826 | 2691 | unknownView = true; // assume it's in view |
| 2827 | 2692 | if (wantExtraDebugging) { |
| 2828 | − qDebug() << "no known jurisdiction for node " << *node << ", assume it's visible.\n"; | |
| 2693 | + qDebug() << "no known jurisdiction for node " << *node << ", assume it's visible."; | |
| 2829 | 2694 | } |
| 2830 | 2695 | } else { |
| 2831 | 2696 | const JurisdictionMap& map = (jurisdictions)[nodeUUID]; |
| 2832 | − | |
| 2697 | + | |
| 2833 | 2698 | unsigned char* rootCode = map.getRootOctalCode(); |
| 2834 | − | |
| 2699 | + | |
| 2835 | 2700 | if (rootCode) { |
| 2836 | 2701 | VoxelPositionSize rootDetails; |
| 2837 | 2702 | voxelDetailsForCode(rootCode, rootDetails); |
| 2838 | 2703 | AABox serverBounds(glm::vec3(rootDetails.x, rootDetails.y, rootDetails.z), rootDetails.s); |
| 2839 | 2704 | serverBounds.scale(TREE_SCALE); |
| 2840 | − | |
| 2705 | + | |
| 2841 | 2706 | ViewFrustum::location serverFrustumLocation = _viewFrustum.boxInFrustum(serverBounds); |
| 2842 | 2707 | if (serverFrustumLocation != ViewFrustum::OUTSIDE) { |
| 2843 | 2708 | inView = true; |
| @@ -2846,19 +2711,19 @@ void Application::queryOctree(NODE_TYPE serverType, PACKET_TYPE packetType, Node · 2 unmodified lines | ||
| 2846 | 2711 | } |
| 2847 | 2712 | } else { |
| 2848 | 2713 | if (wantExtraDebugging) { |
| 2849 | − qDebug() << "Jurisdiction without RootCode for node " << *node << ". That's unusual!\n"; | |
| 2714 | + qDebug() << "Jurisdiction without RootCode for node " << *node << ". That's unusual!"; | |
| 2850 | 2715 | } |
| 2851 | 2716 | } |
| 2852 | 2717 | } |
| 2853 | − | |
| 2718 | + | |
| 2854 | 2719 | if (inView) { |
| 2855 | 2720 | _voxelQuery.setMaxOctreePacketsPerSecond(perServerPPS); |
| 2856 | 2721 | } else if (unknownView) { |
| 2857 | 2722 | if (wantExtraDebugging) { |
| 2858 | 2723 | qDebug() << "no known jurisdiction for node " << *node << ", give it budget of " |
| 2859 | − << perUnknownServer << " to send us jurisdiction.\n"; | |
| 2724 | + << perUnknownServer << " to send us jurisdiction."; | |
| 2860 | 2725 | } |
| 2861 | − | |
| 2726 | + | |
| 2862 | 2727 | // set the query's position/orientation to be degenerate in a manner that will get the scene quickly |
| 2863 | 2728 | // If there's only one server, then don't do this, and just let the normal voxel query pass through |
| 2864 | 2729 | // as expected... this way, we will actually get a valid scene if there is one to be seen |
| @@ -2869,11 +2734,11 @@ void Application::queryOctree(NODE_TYPE serverType, PACKET_TYPE packetType, Node · 4 unmodified lines | ||
| 2869 | 2734 | _voxelQuery.setCameraNearClip(0.1); |
| 2870 | 2735 | _voxelQuery.setCameraFarClip(0.1); |
| 2871 | 2736 | if (wantExtraDebugging) { |
| 2872 | − qDebug() << "Using 'minimal' camera position for node " << *node << "\n"; | |
| 2737 | + qDebug() << "Using 'minimal' camera position for node" << *node; | |
| 2873 | 2738 | } |
| 2874 | 2739 | } else { |
| 2875 | 2740 | if (wantExtraDebugging) { |
| 2876 | − qDebug() << "Using regular camera position for node " << *node << "\n"; | |
| 2741 | + qDebug() << "Using regular camera position for node" << *node; | |
| 2877 | 2742 | } |
| 2878 | 2743 | } |
| 2879 | 2744 | _voxelQuery.setMaxOctreePacketsPerSecond(perUnknownServer); |
| @@ -2882,24 +2747,24 @@ void Application::queryOctree(NODE_TYPE serverType, PACKET_TYPE packetType, Node · 2 unmodified lines | ||
| 2882 | 2747 | } |
| 2883 | 2748 | // set up the packet for sending... |
| 2884 | 2749 | unsigned char* endOfVoxelQueryPacket = voxelQueryPacket; |
| 2885 | − | |
| 2750 | + | |
| 2886 | 2751 | // insert packet type/version and node UUID |
| 2887 | 2752 | endOfVoxelQueryPacket += populateTypeAndVersion(endOfVoxelQueryPacket, packetType); |
| 2888 | 2753 | QByteArray ownerUUID = nodeList->getOwnerUUID().toRfc4122(); |
| 2889 | 2754 | memcpy(endOfVoxelQueryPacket, ownerUUID.constData(), ownerUUID.size()); |
| 2890 | 2755 | endOfVoxelQueryPacket += ownerUUID.size(); |
| 2891 | − | |
| 2756 | + | |
| 2892 | 2757 | // encode the query data... |
| 2893 | 2758 | endOfVoxelQueryPacket += _voxelQuery.getBroadcastData(endOfVoxelQueryPacket); |
| 2894 | − | |
| 2759 | + | |
| 2895 | 2760 | int packetLength = endOfVoxelQueryPacket - voxelQueryPacket; |
| 2896 | − | |
| 2761 | + | |
| 2897 | 2762 | // make sure we still have an active socket |
| 2898 | 2763 | if (node->getActiveSocket()) { |
| 2899 | 2764 | nodeList->getNodeSocket().writeDatagram((char*) voxelQueryPacket, packetLength, |
| 2900 | − node->getActiveSocket()->getAddress(), node->getActiveSocket()->getPort()); | |
| 2765 | + node->getActiveSocket()->getAddress(), node->getActiveSocket()->getPort()); | |
| 2901 | 2766 | } |
| 2902 | − | |
| 2767 | + | |
| 2903 | 2768 | // Feed number of bytes to corresponding channel of the bandwidth meter |
| 2904 | 2769 | _bandwidthMeter.outputStream(BandwidthMeter::VOXELS).updateValue(packetLength); |
| 2905 | 2770 | } |
| @@ -3256,12 +3121,6 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 350 unmodified lines | ||
| 3256 | 3121 | } |
| 3257 | 3122 | } |
| 3258 | 3123 | |
| 3259 | − { | |
| 3260 | − PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), | |
| 3261 | − "Application::displaySide() ... renderFollowIndicator..."); | |
| 3262 | − renderFollowIndicator(); | |
| 3263 | − } | |
| 3264 | − | |
| 3265 | 3124 | // render transmitter pick ray, if non-empty |
| 3266 | 3125 | if (_transmitterPickStart != _transmitterPickEnd) { |
| 3267 | 3126 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), |
| @@ -3329,8 +3188,7 @@ void Application::displayOverlay() { · 61 unmodified lines | ||
| 3329 | 3188 | |
| 3330 | 3189 | //noiseTest(_glWidget->width(), _glWidget->height()); |
| 3331 | 3190 | |
| 3332 | − if (Menu::getInstance()->isOptionChecked(MenuOption::HeadMouse) | |
| 3333 | − && USING_INVENSENSE_MPU9150) { | |
| 3191 | + if (Menu::getInstance()->isOptionChecked(MenuOption::HeadMouse)) { | |
| 3334 | 3192 | // Display small target box at center or head mouse target that can also be used to measure LOD |
| 3335 | 3193 | glColor3f(1.0, 1.0, 1.0); |
| 3336 | 3194 | glDisable(GL_LINE_SMOOTH); |
| @@ -3366,9 +3224,6 @@ void Application::displayOverlay() { · 29 unmodified lines | ||
| 3366 | 3224 | } |
| 3367 | 3225 | } |
| 3368 | 3226 | |
| 3369 | − // Show detected levels from the serial I/O ADC channel sensors | |
| 3370 | − if (_displayLevels) _serialHeadSensor.renderLevels(_glWidget->width(), _glWidget->height()); | |
| 3371 | − | |
| 3372 | 3227 | // Show hand transmitter data if detected |
| 3373 | 3228 | if (_myTransmitter.isConnected()) { |
| 3374 | 3229 | _myTransmitter.renderLevels(_glWidget->width(), _glWidget->height()); |
| @@ -3388,12 +3243,12 @@ void Application::displayOverlay() { · 13 unmodified lines | ||
| 3388 | 3243 | glPointSize(1.0f); |
| 3389 | 3244 | char nodes[100]; |
| 3390 | 3245 | |
| 3391 | − NodeList* nodeList = NodeList::getInstance(); | |
| 3392 | 3246 | int totalAvatars = 0, totalServers = 0; |
| 3393 | − | |
| 3394 | − for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) { | |
| 3247 | + | |
| 3248 | + foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) { | |
| 3395 | 3249 | node->getType() == NODE_TYPE_AGENT ? totalAvatars++ : totalServers++; |
| 3396 | 3250 | } |
| 3251 | + | |
| 3397 | 3252 | sprintf(nodes, "Servers: %d, Avatars: %d\n", totalServers, totalAvatars); |
| 3398 | 3253 | drawtext(_glWidget->width() - 150, 20, 0.10, 0, 1.0, 0, nodes, 1, 0, 0); |
| 3399 | 3254 | } |
| @@ -3493,8 +3348,8 @@ void Application::displayStats() { · 93 unmodified lines | ||
| 3493 | 3348 | int pingAudio = 0, pingAvatar = 0, pingVoxel = 0, pingVoxelMax = 0; |
| 3494 | 3349 | |
| 3495 | 3350 | NodeList* nodeList = NodeList::getInstance(); |
| 3496 | − Node* audioMixerNode = nodeList->soloNodeOfType(NODE_TYPE_AUDIO_MIXER); | |
| 3497 | − Node* avatarMixerNode = nodeList->soloNodeOfType(NODE_TYPE_AVATAR_MIXER); | |
| 3351 | + SharedNodePointer audioMixerNode = nodeList->soloNodeOfType(NODE_TYPE_AUDIO_MIXER); | |
| 3352 | + SharedNodePointer avatarMixerNode = nodeList->soloNodeOfType(NODE_TYPE_AVATAR_MIXER); | |
| 3498 | 3353 | |
| 3499 | 3354 | pingAudio = audioMixerNode ? audioMixerNode->getPingMs() : 0; |
| 3500 | 3355 | pingAvatar = avatarMixerNode ? avatarMixerNode->getPingMs() : 0; |
| @@ -3503,7 +3358,8 @@ void Application::displayStats() { · 2 unmodified lines | ||
| 3503 | 3358 | // Now handle voxel servers, since there could be more than one, we average their ping times |
| 3504 | 3359 | unsigned long totalPingVoxel = 0; |
| 3505 | 3360 | int voxelServerCount = 0; |
| 3506 | − for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) { | |
| 3361 | + | |
| 3362 | + foreach (const SharedNodePointer& node, nodeList->getNodeHash()) { | |
| 3507 | 3363 | if (node->getType() == NODE_TYPE_VOXEL_SERVER) { |
| 3508 | 3364 | totalPingVoxel += node->getPingMs(); |
| 3509 | 3365 | voxelServerCount++; |
| @@ -3512,6 +3368,7 @@ void Application::displayStats() { · 2 unmodified lines | ||
| 3512 | 3368 | } |
| 3513 | 3369 | } |
| 3514 | 3370 | } |
| 3371 | + | |
| 3515 | 3372 | if (voxelServerCount) { |
| 3516 | 3373 | pingVoxel = totalPingVoxel/voxelServerCount; |
| 3517 | 3374 | } |
| @@ -3528,7 +3385,7 @@ void Application::displayStats() { · 10 unmodified lines | ||
| 3528 | 3385 | sprintf(avatarStats, "Avatar: pos %.3f, %.3f, %.3f, vel %.1f, yaw = %.2f", avatarPos.x, avatarPos.y, avatarPos.z, glm::length(_myAvatar.getVelocity()), _myAvatar.getBodyYaw()); |
| 3529 | 3386 | drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, avatarStats); |
| 3530 | 3387 | |
| 3531 | − Node* avatarMixer = NodeList::getInstance()->soloNodeOfType(NODE_TYPE_AVATAR_MIXER); | |
| 3388 | + SharedNodePointer avatarMixer = NodeList::getInstance()->soloNodeOfType(NODE_TYPE_AVATAR_MIXER); | |
| 3532 | 3389 | char avatarMixerStats[200]; |
| 3533 | 3390 | if (avatarMixer) { |
| 3534 | 3391 | sprintf(avatarMixerStats, "Avatar Mixer: %.f kbps, %.f pps", |
| @@ -3660,11 +3517,6 @@ void Application::displayStats() { · 125 unmodified lines | ||
| 3660 | 3517 | statsVerticalOffset += PELS_PER_LINE; |
| 3661 | 3518 | drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, (char*)voxelStats.str().c_str()); |
| 3662 | 3519 | |
| 3663 | − | |
| 3664 | − // Leap data | |
| 3665 | − statsVerticalOffset += PELS_PER_LINE; | |
| 3666 | − drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, (char*)LeapManager::statusString().c_str()); | |
| 3667 | − | |
| 3668 | 3520 | if (_perfStatsOn) { |
| 3669 | 3521 | // Get the PerfStats group details. We need to allocate and array of char* long enough to hold 1+groups |
| 3670 | 3522 | char** perfStatLinesArray = new char*[PerfStat::getGroupCount()+1]; |
| @@ -3735,9 +3587,6 @@ glm::vec2 Application::getScaledScreenPoint(glm::vec2 projectedPoint) { · 64 unmodified lines | ||
| 3735 | 3587 | |
| 3736 | 3588 | // render the coverage map on screen |
| 3737 | 3589 | void Application::renderCoverageMapV2() { |
| 3738 | − | |
| 3739 | − //qDebug("renderCoverageMap()\n"); | |
| 3740 | − | |
| 3741 | 3590 | glDisable(GL_LIGHTING); |
| 3742 | 3591 | glLineWidth(2.0); |
| 3743 | 3592 | glBegin(GL_LINES); |
| @@ -3781,8 +3630,6 @@ void Application::renderCoverageMapsV2Recursively(CoverageMapV2* map) { · 37 unmodified lines | ||
| 3781 | 3630 | // render the coverage map on screen |
| 3782 | 3631 | void Application::renderCoverageMap() { |
| 3783 | 3632 | |
| 3784 | − //qDebug("renderCoverageMap()\n"); | |
| 3785 | − | |
| 3786 | 3633 | glDisable(GL_LIGHTING); |
| 3787 | 3634 | glLineWidth(2.0); |
| 3788 | 3635 | glBegin(GL_LINES); |
| @@ -3857,10 +3704,10 @@ void Application::renderAvatars(bool forceRenderHead, bool selfAvatarOnly) { · 68 unmodified lines | ||
| 3857 | 3704 | if (!selfAvatarOnly) { |
| 3858 | 3705 | // Render avatars of other nodes |
| 3859 | 3706 | NodeList* nodeList = NodeList::getInstance(); |
| 3860 | − | |
| 3861 | − for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) { | |
| 3862 | − node->lock(); | |
| 3863 | − | |
| 3707 | + | |
| 3708 | + foreach (const SharedNodePointer& node, nodeList->getNodeHash()) { | |
| 3709 | + QMutexLocker(&node->getMutex()); | |
| 3710 | + | |
| 3864 | 3711 | if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) { |
| 3865 | 3712 | Avatar *avatar = (Avatar *)node->getLinkedData(); |
| 3866 | 3713 | if (!avatar->isInitialized()) { |
| @@ -3869,8 +3716,6 @@ void Application::renderAvatars(bool forceRenderHead, bool selfAvatarOnly) { · 2 unmodified lines | ||
| 3869 | 3716 | avatar->render(false); |
| 3870 | 3717 | avatar->setDisplayingLookatVectors(Menu::getInstance()->isOptionChecked(MenuOption::LookAtVectors)); |
| 3871 | 3718 | } |
| 3872 | − | |
| 3873 | − node->unlock(); | |
| 3874 | 3719 | } |
| 3875 | 3720 | |
| 3876 | 3721 | // render avatar fades |
| @@ -4115,28 +3960,12 @@ void Application::eyedropperVoxelUnderCursor() { · 238 unmodified lines | ||
| 4115 | 3960 | } |
| 4116 | 3961 | } |
| 4117 | 3962 | |
| 4118 | −void Application::toggleFollowMode() { | |
| 4119 | − glm::vec3 mouseRayOrigin, mouseRayDirection; | |
| 4120 | − _viewFrustum.computePickRay(_pieMenu.getX() / (float)_glWidget->width(), | |
| 4121 | − _pieMenu.getY() / (float)_glWidget->height(), | |
| 4122 | − mouseRayOrigin, mouseRayDirection); | |
| 4123 | − glm::vec3 eyePositionIgnored; | |
| 4124 | − QUuid nodeUUIDIgnored; | |
| 4125 | − Avatar* leadingAvatar = findLookatTargetAvatar(mouseRayOrigin, mouseRayDirection, eyePositionIgnored, nodeUUIDIgnored); | |
| 4126 | − | |
| 4127 | − _myAvatar.follow(leadingAvatar); | |
| 4128 | −} | |
| 4129 | − | |
| 4130 | 3963 | void Application::resetSensors() { |
| 4131 | 3964 | _headMouseX = _mouseX = _glWidget->width() / 2; |
| 4132 | 3965 | _headMouseY = _mouseY = _glWidget->height() / 2; |
| 4133 | 3966 | |
| 4134 | − if (_serialHeadSensor.isActive()) { | |
| 4135 | − _serialHeadSensor.resetAverages(); | |
| 4136 | − } | |
| 4137 | 3967 | _webcam.reset(); |
| 4138 | 3968 | _faceshift.reset(); |
| 4139 | − LeapManager::reset(); | |
| 4140 | 3969 | |
| 4141 | 3970 | if (OculusManager::isConnected()) { |
| 4142 | 3971 | OculusManager::reset(); |
| @@ -4187,13 +4016,13 @@ void Application::updateWindowTitle(){ · 44 unmodified lines | ||
| 4187 | 4016 | title += _profile.getLastDomain(); |
| 4188 | 4017 | title += buildVersion; |
| 4189 | 4018 | |
| 4190 | − qDebug("Application title set to: %s.\n", title.toStdString().c_str()); | |
| 4019 | + qDebug("Application title set to: %s", title.toStdString().c_str()); | |
| 4191 | 4020 | _window->setWindowTitle(title); |
| 4192 | 4021 | } |
| 4193 | 4022 | |
| 4194 | −void Application::domainChanged(QString domain) { | |
| 4023 | +void Application::domainChanged(const QString& domainHostname) { | |
| 4195 | 4024 | // update the user's last domain in their Profile (which will propagate to data-server) |
| 4196 | − _profile.updateDomain(domain); | |
| 4025 | + _profile.updateDomain(domainHostname); | |
| 4197 | 4026 | |
| 4198 | 4027 | updateWindowTitle(); |
| 4199 | 4028 | |
| @@ -4204,13 +4033,13 @@ void Application::domainChanged(QString domain) { · 4 unmodified lines | ||
| 4204 | 4033 | _voxelServerJurisdictions.clear(); |
| 4205 | 4034 | _octreeServerSceneStats.clear(); |
| 4206 | 4035 | _particleServerJurisdictions.clear(); |
| 4207 | −} | |
| 4208 | − | |
| 4209 | −void Application::nodeAdded(Node* node) { | |
| 4210 | 4036 | |
| 4037 | + // reset our persist thread | |
| 4038 | + qDebug() << "Domain changed to" << domainHostname << ". Swapping persist cache."; | |
| 4039 | + updateLocalOctreeCache(); | |
| 4211 | 4040 | } |
| 4212 | 4041 | |
| 4213 | −void Application::nodeKilled(Node* node) { | |
| 4042 | +void Application::nodeKilled(SharedNodePointer node) { | |
| 4214 | 4043 | if (node->getType() == NODE_TYPE_VOXEL_SERVER) { |
| 4215 | 4044 | QUuid nodeUUID = node->getUUID(); |
| 4216 | 4045 | // see if this is the first we've heard of this node... |
| @@ -4290,7 +4119,7 @@ void Application::trackIncomingVoxelPacket(unsigned char* messageData, ssize_t m · 73 unmodified lines | ||
| 4290 | 4119 | const HifiSockAddr& senderSockAddr, bool wasStatsPacket) { |
| 4291 | 4120 | |
| 4292 | 4121 | // Attempt to identify the sender from it's address. |
| 4293 | − Node* serverNode = NodeList::getInstance()->nodeWithAddress(senderSockAddr); | |
| 4122 | + SharedNodePointer serverNode = NodeList::getInstance()->nodeWithAddress(senderSockAddr); | |
| 4294 | 4123 | if (serverNode) { |
| 4295 | 4124 | QUuid nodeUUID = serverNode->getUUID(); |
| 4296 | 4125 | |
| @@ -4307,7 +4136,7 @@ void Application::trackIncomingVoxelPacket(unsigned char* messageData, ssize_t m · 10 unmodified lines | ||
| 4307 | 4136 | int Application::parseOctreeStats(unsigned char* messageData, ssize_t messageLength, const HifiSockAddr& senderSockAddr) { |
| 4308 | 4137 | |
| 4309 | 4138 | // But, also identify the sender, and keep track of the contained jurisdiction root for this server |
| 4310 | − Node* server = NodeList::getInstance()->nodeWithAddress(senderSockAddr); | |
| 4139 | + SharedNodePointer server = NodeList::getInstance()->nodeWithAddress(senderSockAddr); | |
| 4311 | 4140 | |
| 4312 | 4141 | // parse the incoming stats datas stick it in a temporary object for now, while we |
| 4313 | 4142 | // determine which server it belongs to |
| @@ -4364,101 +4193,95 @@ int Application::parseOctreeStats(unsigned char* messageData, ssize_t messageLen · 50 unmodified lines | ||
| 4364 | 4193 | } |
| 4365 | 4194 | |
| 4366 | 4195 | // Receive packets from other nodes/servers and decide what to do with them! |
| 4367 | −void* Application::networkReceive(void* args) { | |
| 4196 | +void Application::processDatagrams() { | |
| 4368 | 4197 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), |
| 4369 | 4198 | "Application::networkReceive()"); |
| 4370 | 4199 | |
| 4371 | 4200 | HifiSockAddr senderSockAddr; |
| 4372 | 4201 | ssize_t bytesReceived; |
| 4373 | 4202 | |
| 4374 | − Application* app = Application::getInstance(); | |
| 4375 | − while (!app->_stopNetworkReceiveThread) { | |
| 4376 | − if (NodeList::getInstance()->getNodeSocket().hasPendingDatagrams() && | |
| 4377 | − (bytesReceived = NodeList::getInstance()->getNodeSocket().readDatagram((char*) app->_incomingPacket, | |
| 4378 | − MAX_PACKET_SIZE, | |
| 4379 | − senderSockAddr.getAddressPointer(), | |
| 4380 | − senderSockAddr.getPortPointer()))) { | |
| 4381 | − | |
| 4382 | − app->_packetCount++; | |
| 4383 | − app->_bytesCount += bytesReceived; | |
| 4384 | − | |
| 4385 | − if (packetVersionMatch(app->_incomingPacket)) { | |
| 4386 | − // only process this packet if we have a match on the packet version | |
| 4387 | − switch (app->_incomingPacket[0]) { | |
| 4388 | − case PACKET_TYPE_TRANSMITTER_DATA_V2: | |
| 4389 | − // V2 = IOS transmitter app | |
| 4390 | − app->_myTransmitter.processIncomingData(app->_incomingPacket, bytesReceived); | |
| 4391 | − | |
| 4392 | − break; | |
| 4393 | − case PACKET_TYPE_MIXED_AUDIO: | |
| 4394 | − QMetaObject::invokeMethod(&app->_audio, "addReceivedAudioToBuffer", Qt::QueuedConnection, | |
| 4395 | − Q_ARG(QByteArray, QByteArray((char*) app->_incomingPacket, bytesReceived))); | |
| 4396 | − break; | |
| 4397 | − | |
| 4398 | − case PACKET_TYPE_PARTICLE_ADD_RESPONSE: | |
| 4399 | − // look up our ParticleEditHanders.... | |
| 4400 | − ParticleEditHandle::handleAddResponse(app->_incomingPacket, bytesReceived); | |
| 4401 | − break; | |
| 4402 | − | |
| 4403 | − case PACKET_TYPE_PARTICLE_DATA: | |
| 4404 | − case PACKET_TYPE_VOXEL_DATA: | |
| 4405 | − case PACKET_TYPE_VOXEL_ERASE: | |
| 4406 | − case PACKET_TYPE_OCTREE_STATS: | |
| 4407 | − case PACKET_TYPE_ENVIRONMENT_DATA: { | |
| 4408 | − PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), | |
| 4409 | − "Application::networkReceive()... _voxelProcessor.queueReceivedPacket()"); | |
| 4410 | − | |
| 4411 | − bool wantExtraDebugging = app->getLogger()->extraDebugging(); | |
| 4412 | − if (wantExtraDebugging && app->_incomingPacket[0] == PACKET_TYPE_VOXEL_DATA) { | |
| 4413 | − int numBytesPacketHeader = numBytesForPacketHeader(app->_incomingPacket); | |
| 4414 | − unsigned char* dataAt = app->_incomingPacket + numBytesPacketHeader; | |
| 4415 | − dataAt += sizeof(VOXEL_PACKET_FLAGS); | |
| 4416 | − VOXEL_PACKET_SEQUENCE sequence = (*(VOXEL_PACKET_SEQUENCE*)dataAt); | |
| 4417 | − dataAt += sizeof(VOXEL_PACKET_SEQUENCE); | |
| 4418 | − VOXEL_PACKET_SENT_TIME sentAt = (*(VOXEL_PACKET_SENT_TIME*)dataAt); | |
| 4419 | − dataAt += sizeof(VOXEL_PACKET_SENT_TIME); | |
| 4420 | − VOXEL_PACKET_SENT_TIME arrivedAt = usecTimestampNow(); | |
| 4421 | − int flightTime = arrivedAt - sentAt; | |
| 4422 | − | |
| 4423 | − printf("got PACKET_TYPE_VOXEL_DATA, sequence:%d flightTime:%d\n", sequence, flightTime); | |
| 4424 | − } | |
| 4425 | − | |
| 4426 | − // add this packet to our list of voxel packets and process them on the voxel processing | |
| 4427 | − app->_voxelProcessor.queueReceivedPacket(senderSockAddr, app->_incomingPacket, bytesReceived); | |
| 4428 | − break; | |
| 4203 | + while (NodeList::getInstance()->getNodeSocket().hasPendingDatagrams() && | |
| 4204 | + (bytesReceived = NodeList::getInstance()->getNodeSocket().readDatagram((char*) _incomingPacket, | |
| 4205 | + MAX_PACKET_SIZE, | |
| 4206 | + senderSockAddr.getAddressPointer(), | |
| 4207 | + senderSockAddr.getPortPointer()))) { | |
| 4208 | + | |
| 4209 | + _packetCount++; | |
| 4210 | + _bytesCount += bytesReceived; | |
| 4211 | + | |
| 4212 | + if (packetVersionMatch(_incomingPacket)) { | |
| 4213 | + // only process this packet if we have a match on the packet version | |
| 4214 | + switch (_incomingPacket[0]) { | |
| 4215 | + case PACKET_TYPE_TRANSMITTER_DATA_V2: | |
| 4216 | + // V2 = IOS transmitter app | |
| 4217 | + _myTransmitter.processIncomingData(_incomingPacket, bytesReceived); | |
| 4218 | + | |
| 4219 | + break; | |
| 4220 | + case PACKET_TYPE_MIXED_AUDIO: | |
| 4221 | + QMetaObject::invokeMethod(&_audio, "addReceivedAudioToBuffer", Qt::QueuedConnection, | |
| 4222 | + Q_ARG(QByteArray, QByteArray((char*) _incomingPacket, bytesReceived))); | |
| 4223 | + break; | |
| 4224 | + | |
| 4225 | + case PACKET_TYPE_PARTICLE_ADD_RESPONSE: | |
| 4226 | + // look up our ParticleEditHanders.... | |
| 4227 | + ParticleEditHandle::handleAddResponse(_incomingPacket, bytesReceived); | |
| 4228 | + break; | |
| 4229 | + | |
| 4230 | + case PACKET_TYPE_PARTICLE_DATA: | |
| 4231 | + case PACKET_TYPE_VOXEL_DATA: | |
| 4232 | + case PACKET_TYPE_VOXEL_ERASE: | |
| 4233 | + case PACKET_TYPE_OCTREE_STATS: | |
| 4234 | + case PACKET_TYPE_ENVIRONMENT_DATA: { | |
| 4235 | + PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), | |
| 4236 | + "Application::networkReceive()... _voxelProcessor.queueReceivedPacket()"); | |
| 4237 | + | |
| 4238 | + bool wantExtraDebugging = getLogger()->extraDebugging(); | |
| 4239 | + if (wantExtraDebugging && _incomingPacket[0] == PACKET_TYPE_VOXEL_DATA) { | |
| 4240 | + int numBytesPacketHeader = numBytesForPacketHeader(_incomingPacket); | |
| 4241 | + unsigned char* dataAt = _incomingPacket + numBytesPacketHeader; | |
| 4242 | + dataAt += sizeof(VOXEL_PACKET_FLAGS); | |
| 4243 | + VOXEL_PACKET_SEQUENCE sequence = (*(VOXEL_PACKET_SEQUENCE*)dataAt); | |
| 4244 | + dataAt += sizeof(VOXEL_PACKET_SEQUENCE); | |
| 4245 | + VOXEL_PACKET_SENT_TIME sentAt = (*(VOXEL_PACKET_SENT_TIME*)dataAt); | |
| 4246 | + dataAt += sizeof(VOXEL_PACKET_SENT_TIME); | |
| 4247 | + VOXEL_PACKET_SENT_TIME arrivedAt = usecTimestampNow(); | |
| 4248 | + int flightTime = arrivedAt - sentAt; | |
| 4249 | + | |
| 4250 | + printf("got PACKET_TYPE_VOXEL_DATA, sequence:%d flightTime:%d\n", sequence, flightTime); | |
| 4429 | 4251 | } |
| 4430 | − case PACKET_TYPE_BULK_AVATAR_DATA: | |
| 4431 | − NodeList::getInstance()->processBulkNodeData(senderSockAddr, | |
| 4432 | − app->_incomingPacket, | |
| 4433 | − bytesReceived); | |
| 4434 | − getInstance()->_bandwidthMeter.inputStream(BandwidthMeter::AVATARS).updateValue(bytesReceived); | |
| 4435 | − break; | |
| 4436 | − case PACKET_TYPE_AVATAR_URLS: | |
| 4437 | − processAvatarURLsMessage(app->_incomingPacket, bytesReceived); | |
| 4438 | − break; | |
| 4439 | − case PACKET_TYPE_AVATAR_FACE_VIDEO: | |
| 4440 | − processAvatarFaceVideoMessage(app->_incomingPacket, bytesReceived); | |
| 4441 | − break; | |
| 4442 | − case PACKET_TYPE_DATA_SERVER_GET: | |
| 4443 | − case PACKET_TYPE_DATA_SERVER_PUT: | |
| 4444 | − case PACKET_TYPE_DATA_SERVER_SEND: | |
| 4445 | − case PACKET_TYPE_DATA_SERVER_CONFIRM: | |
| 4446 | − DataServerClient::processMessageFromDataServer(app->_incomingPacket, bytesReceived); | |
| 4447 | − break; | |
| 4448 | − default: | |
| 4449 | − NodeList::getInstance()->processNodeData(senderSockAddr, app->_incomingPacket, bytesReceived); | |
| 4450 | − break; | |
| 4252 | + | |
| 4253 | + // add this packet to our list of voxel packets and process them on the voxel processing | |
| 4254 | + _voxelProcessor.queueReceivedPacket(senderSockAddr, _incomingPacket, bytesReceived); | |
| 4255 | + break; | |
| 4451 | 4256 | } |
| 4257 | + case PACKET_TYPE_METAVOXEL_DATA: | |
| 4258 | + _metavoxels.processData(QByteArray((const char*) _incomingPacket, bytesReceived), | |
| 4259 | + senderSockAddr); | |
| 4260 | + break; | |
| 4261 | + case PACKET_TYPE_BULK_AVATAR_DATA: | |
| 4262 | + NodeList::getInstance()->processBulkNodeData(senderSockAddr, | |
| 4263 | + _incomingPacket, | |
| 4264 | + bytesReceived); | |
| 4265 | + getInstance()->_bandwidthMeter.inputStream(BandwidthMeter::AVATARS).updateValue(bytesReceived); | |
| 4266 | + break; | |
| 4267 | + case PACKET_TYPE_AVATAR_URLS: | |
| 4268 | + processAvatarURLsMessage(_incomingPacket, bytesReceived); | |
| 4269 | + break; | |
| 4270 | + case PACKET_TYPE_AVATAR_FACE_VIDEO: | |
| 4271 | + processAvatarFaceVideoMessage(_incomingPacket, bytesReceived); | |
| 4272 | + break; | |
| 4273 | + case PACKET_TYPE_DATA_SERVER_GET: | |
| 4274 | + case PACKET_TYPE_DATA_SERVER_PUT: | |
| 4275 | + case PACKET_TYPE_DATA_SERVER_SEND: | |
| 4276 | + case PACKET_TYPE_DATA_SERVER_CONFIRM: | |
| 4277 | + DataServerClient::processMessageFromDataServer(_incomingPacket, bytesReceived); | |
| 4278 | + break; | |
| 4279 | + default: | |
| 4280 | + NodeList::getInstance()->processNodeData(senderSockAddr, _incomingPacket, bytesReceived); | |
| 4281 | + break; | |
| 4452 | 4282 | } |
| 4453 | − } else if (!app->_enableNetworkThread) { | |
| 4454 | − break; | |
| 4455 | 4283 | } |
| 4456 | 4284 | } |
| 4457 | − | |
| 4458 | − if (app->_enableNetworkThread) { | |
| 4459 | − pthread_exit(0); | |
| 4460 | − } | |
| 4461 | − return NULL; | |
| 4462 | 4285 | } |
| 4463 | 4286 | |
| 4464 | 4287 | void Application::packetSentNotification(ssize_t length) { |
| @@ -4475,14 +4298,12 @@ void Application::loadScript() { · 10 unmodified lines | ||
| 4475 | 4298 | QByteArray fileNameAscii = fileNameString.toLocal8Bit(); |
| 4476 | 4299 | const char* fileName = fileNameAscii.data(); |
| 4477 | 4300 | |
| 4478 | − printf("fileName:%s\n",fileName); | |
| 4479 | − | |
| 4480 | 4301 | std::ifstream file(fileName, std::ios::in|std::ios::binary|std::ios::ate); |
| 4481 | 4302 | if(!file.is_open()) { |
| 4482 | − printf("error loading file\n"); | |
| 4303 | + qDebug("Error loading file %s", fileName); | |
| 4483 | 4304 | return; |
| 4484 | 4305 | } |
| 4485 | − qDebug("loading file %s...\n", fileName); | |
| 4306 | + qDebug("Loading file %s...", fileName); | |
| 4486 | 4307 | |
| 4487 | 4308 | // get file length.... |
| 4488 | 4309 | unsigned long fileLength = file.tellg(); |
| @@ -4539,3 +4360,47 @@ void Application::toggleLogDialog() { · 50 unmodified lines | ||
| 4539 | 4360 | _logDialog->close(); |
| 4540 | 4361 | } |
| 4541 | 4362 | } |
| 4363 | + | |
| 4364 | + | |
| 4365 | +void Application::initAvatarAndViewFrustum() { | |
| 4366 | + updateAvatar(0.f); | |
| 4367 | +} | |
| 4368 | + | |
| 4369 | +QString Application::getLocalVoxelCacheFileName() { | |
| 4370 | + QString fileName = QStandardPaths::writableLocation(QStandardPaths::DataLocation); | |
| 4371 | + QDir logDir(fileName); | |
| 4372 | + if (!logDir.exists(fileName)) { | |
| 4373 | + logDir.mkdir(fileName); | |
| 4374 | + } | |
| 4375 | + | |
| 4376 | + fileName.append(QString("/hifi.voxelscache.")); | |
| 4377 | + fileName.append(_profile.getLastDomain()); | |
| 4378 | + fileName.append(QString(".svo")); | |
| 4379 | + | |
| 4380 | + return fileName; | |
| 4381 | +} | |
| 4382 | + | |
| 4383 | + | |
| 4384 | +void Application::updateLocalOctreeCache(bool firstTime) { | |
| 4385 | + // only do this if we've already got a persistThread or we're told this is the first time | |
| 4386 | + if (firstTime || _persistThread) { | |
| 4387 | + | |
| 4388 | + if (_persistThread) { | |
| 4389 | + _persistThread->terminate(); | |
| 4390 | + _persistThread = NULL; | |
| 4391 | + } | |
| 4392 | + | |
| 4393 | + QString localVoxelCacheFileName = getLocalVoxelCacheFileName(); | |
| 4394 | + const int LOCAL_CACHE_PERSIST_INTERVAL = 1000 * 10; // every 10 seconds | |
| 4395 | + _persistThread = new OctreePersistThread(_voxels.getTree(), | |
| 4396 | + localVoxelCacheFileName.toLocal8Bit().constData(),LOCAL_CACHE_PERSIST_INTERVAL); | |
| 4397 | + | |
| 4398 | + qDebug() << "updateLocalOctreeCache()... localVoxelCacheFileName=" << localVoxelCacheFileName; | |
| 4399 | + | |
| 4400 | + if (_persistThread) { | |
| 4401 | + _voxels.beginLoadingLocalVoxelCache(); // while local voxels are importing, don't do individual node VBO updates | |
| 4402 | + connect(_persistThread, SIGNAL(loadCompleted()), &_voxels, SLOT(localVoxelCacheLoaded())); | |
| 4403 | + _persistThread->initialize(true); | |
| 4404 | + } | |
| 4405 | + } | |
| 4406 | +} | |