Showing the changes to interface/src/Application.cpp (1 of 158 files). Show all
Unified · Split
| @@ -55,7 +55,6 @@ · 54 unmodified lines | |||
| 55 | #include "Menu.h" | 55 | #include "Menu.h" |
| 56 | #include "Swatch.h" | 56 | #include "Swatch.h" |
| 57 | #include "Util.h" | 57 | #include "Util.h" |
| 58 | #include "devices/LeapManager.h" | ||
| 59 | #include "devices/OculusManager.h" | 58 | #include "devices/OculusManager.h" |
| 60 | #include "devices/TV3DManager.h" | 59 | #include "devices/TV3DManager.h" |
| 61 | #include "renderer/ProgramObject.h" | 60 | #include "renderer/ProgramObject.h" |
| @@ -86,17 +85,16 @@ const float MIRROR_FULLSCREEN_DISTANCE = 0.35f; · 24 unmodified lines | |||
| 86 | const float MIRROR_REARVIEW_DISTANCE = 0.65f; | 85 | const float MIRROR_REARVIEW_DISTANCE = 0.65f; |
| 87 | const float MIRROR_REARVIEW_BODY_DISTANCE = 2.3f; | 86 | const float MIRROR_REARVIEW_BODY_DISTANCE = 2.3f; |
| 88 | 87 | ||
| 89 | |||
| 90 | void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString &message) { | 88 | void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString &message) { |
| 91 | fprintf(stdout, "%s", message.toLocal8Bit().constData()); | 89 | QString messageWithNewLine = message + "\n"; |
| 92 | Application::getInstance()->getLogger()->addMessage(message.toLocal8Bit().constData()); | 90 | fprintf(stdout, "%s", messageWithNewLine.toLocal8Bit().constData()); |
| 91 | Application::getInstance()->getLogger()->addMessage(messageWithNewLine.toLocal8Bit().constData()); | ||
| 93 | } | 92 | } |
| 94 | 93 | ||
| 95 | Application::Application(int& argc, char** argv, timeval &startup_time) : | 94 | Application::Application(int& argc, char** argv, timeval &startup_time) : |
| 96 | QApplication(argc, argv), | 95 | QApplication(argc, argv), |
| 97 | _window(new QMainWindow(desktop())), | 96 | _window(new QMainWindow(desktop())), |
| 98 | _glWidget(new GLCanvas()), | 97 | _glWidget(new GLCanvas()), |
| 99 | _displayLevels(false), | ||
| 100 | _frameCount(0), | 98 | _frameCount(0), |
| 101 | _fps(120.0f), | 99 | _fps(120.0f), |
| 102 | _justStarted(true), | 100 | _justStarted(true), |
| @@ -130,7 +128,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 27 unmodified lines | |||
| 130 | _perfStatsOn(false), | 128 | _perfStatsOn(false), |
| 131 | _chatEntryOn(false), | 129 | _chatEntryOn(false), |
| 132 | _audio(&_audioScope, STARTUP_JITTER_SAMPLES), | 130 | _audio(&_audioScope, STARTUP_JITTER_SAMPLES), |
| 133 | _stopNetworkReceiveThread(false), | 131 | _enableProcessVoxelsThread(true), |
| 134 | _voxelProcessor(), | 132 | _voxelProcessor(), |
| 135 | _voxelHideShowThread(&_voxels), | 133 | _voxelHideShowThread(&_voxels), |
| 136 | _voxelEditSender(this), | 134 | _voxelEditSender(this), |
| @@ -143,7 +141,8 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 6 unmodified lines | |||
| 143 | _resetRecentMaxPacketsSoon(true), | 141 | _resetRecentMaxPacketsSoon(true), |
| 144 | _swatch(NULL), | 142 | _swatch(NULL), |
| 145 | _pasteMode(false), | 143 | _pasteMode(false), |
| 146 | _logger(new FileLogger()) | 144 | _logger(new FileLogger()), |
| 145 | _persistThread(NULL) | ||
| 147 | { | 146 | { |
| 148 | _applicationStartupTime = startup_time; | 147 | _applicationStartupTime = startup_time; |
| 149 | 148 | ||
| @@ -156,7 +155,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 6 unmodified lines | |||
| 156 | // call Menu getInstance static method to set up the menu | 155 | // call Menu getInstance static method to set up the menu |
| 157 | _window->setMenuBar(Menu::getInstance()); | 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 | unsigned int listenPort = 0; // bind to an ephemeral port by default | 160 | unsigned int listenPort = 0; // bind to an ephemeral port by default |
| 162 | const char** constArgv = const_cast<const char**>(argv); | 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 | NodeList* nodeList = NodeList::createInstance(NODE_TYPE_AGENT, listenPort); | 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 | // put the audio processing on a separate thread | 172 | // put the audio processing on a separate thread |
| 171 | QThread* audioThread = new QThread(this); | 173 | QThread* audioThread = new QThread(this); |
| @@ -174,14 +176,12 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 2 unmodified lines | |||
| 174 | connect(audioThread, SIGNAL(started()), &_audio, SLOT(start())); | 176 | connect(audioThread, SIGNAL(started()), &_audio, SLOT(start())); |
| 175 | 177 | ||
| 176 | audioThread->start(); | 178 | audioThread->start(); |
| 179 | |||
| 180 | connect(nodeList, SIGNAL(domainChanged(const QString&)), SLOT(domainChanged(const QString&))); | ||
| 177 | 181 | ||
| 178 | nodeList->addHook(&_voxels); | 182 | connect(nodeList, SIGNAL(nodeKilled(SharedNodePointer)), SLOT(nodeKilled(SharedNodePointer))); |
| 179 | nodeList->addHook(this); | 183 | connect(nodeList, SIGNAL(nodeAdded(SharedNodePointer)), &_voxels, SLOT(nodeAdded(SharedNodePointer))); |
| 180 | nodeList->addDomainListener(this); | 184 | connect(nodeList, SIGNAL(nodeKilled(SharedNodePointer)), &_voxels, SLOT(nodeKilled(SharedNodePointer))); |
| 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"); | ||
| 185 | 185 | ||
| 186 | // read the ApplicationInfo.ini file for Name/Version/Domain information | 186 | // read the ApplicationInfo.ini file for Name/Version/Domain information |
| 187 | QSettings applicationInfo("resources/info/ApplicationInfo.ini", QSettings::IniFormat); | 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 | #endif | 209 | #endif |
| 210 | 210 | ||
| 211 | // tell the NodeList instance who to tell the domain server we care about | 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, | 212 | const char nodeTypesOfInterest[] = {NODE_TYPE_AUDIO_MIXER, NODE_TYPE_AVATAR_MIXER, NODE_TYPE_VOXEL_SERVER, |
| 213 | NODE_TYPE_PARTICLE_SERVER}; | 213 | NODE_TYPE_PARTICLE_SERVER, NODE_TYPE_METAVOXEL_SERVER}; |
| 214 | nodeList->setNodeTypesOfInterest(nodeTypesOfInterest, sizeof(nodeTypesOfInterest)); | 214 | nodeList->setNodeTypesOfInterest(nodeTypesOfInterest, sizeof(nodeTypesOfInterest)); |
| 215 | 215 | ||
| 216 | QTimer* silentNodeTimer = new QTimer(this); | 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 | // Set the sixense filtering | 251 | // Set the sixense filtering |
| 252 | _sixenseManager.setFilter(Menu::getInstance()->isOptionChecked(MenuOption::FilterSixense)); | 252 | _sixenseManager.setFilter(Menu::getInstance()->isOptionChecked(MenuOption::FilterSixense)); |
| 253 | |||
| 253 | } | 254 | } |
| 254 | 255 | ||
| 255 | Application::~Application() { | 256 | Application::~Application() { |
| @@ -264,9 +265,6 @@ Application::~Application() { · 8 unmodified lines | |||
| 264 | _audio.thread()->wait(); | 265 | _audio.thread()->wait(); |
| 265 | 266 | ||
| 266 | storeSizeAndPosition(); | 267 | storeSizeAndPosition(); |
| 267 | NodeList::getInstance()->removeHook(&_voxels); | ||
| 268 | NodeList::getInstance()->removeHook(this); | ||
| 269 | NodeList::getInstance()->removeDomainListener(this); | ||
| 270 | 268 | ||
| 271 | _sharedVoxelSystem.changeTree(new VoxelTree); | 269 | _sharedVoxelSystem.changeTree(new VoxelTree); |
| 272 | 270 | ||
| @@ -275,7 +273,6 @@ Application::~Application() { · 2 unmodified lines | |||
| 275 | 273 | ||
| 276 | delete _logger; | 274 | delete _logger; |
| 277 | delete _settings; | 275 | delete _settings; |
| 278 | delete _followMode; | ||
| 279 | delete _glWidget; | 276 | delete _glWidget; |
| 280 | } | 277 | } |
| 281 | 278 | ||
| @@ -311,7 +308,7 @@ void Application::storeSizeAndPosition() { · 29 unmodified lines | |||
| 311 | } | 308 | } |
| 312 | 309 | ||
| 313 | void Application::initializeGL() { | 310 | void Application::initializeGL() { |
| 314 | qDebug( "Created Display Window.\n" ); | 311 | qDebug( "Created Display Window."); |
| 315 | 312 | ||
| 316 | // initialize glut for shape drawing; Qt apparently initializes it on OS X | 313 | // initialize glut for shape drawing; Qt apparently initializes it on OS X |
| 317 | #ifndef __APPLE__ | 314 | #ifndef __APPLE__ |
| @@ -326,16 +323,10 @@ void Application::initializeGL() { · 8 unmodified lines | |||
| 326 | _viewFrustumOffsetCamera.setFarClip(500.0 * TREE_SCALE); | 323 | _viewFrustumOffsetCamera.setFarClip(500.0 * TREE_SCALE); |
| 327 | 324 | ||
| 328 | initDisplay(); | 325 | initDisplay(); |
| 329 | qDebug( "Initialized Display.\n" ); | 326 | qDebug( "Initialized Display."); |
| 330 | 327 | ||
| 331 | init(); | 328 | init(); |
| 332 | qDebug( "Init() complete.\n" ); | 329 | qDebug( "init() complete."); |
| 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 | } | ||
| 339 | 330 | ||
| 340 | // create thread for parsing of voxel data independent of the main network and rendering threads | 331 | // create thread for parsing of voxel data independent of the main network and rendering threads |
| 341 | _voxelProcessor.initialize(_enableProcessVoxelsThread); | 332 | _voxelProcessor.initialize(_enableProcessVoxelsThread); |
| @@ -343,7 +334,7 @@ void Application::initializeGL() { · 1 unmodified line | |||
| 343 | _voxelHideShowThread.initialize(_enableProcessVoxelsThread); | 334 | _voxelHideShowThread.initialize(_enableProcessVoxelsThread); |
| 344 | _particleEditSender.initialize(_enableProcessVoxelsThread); | 335 | _particleEditSender.initialize(_enableProcessVoxelsThread); |
| 345 | if (_enableProcessVoxelsThread) { | 336 | if (_enableProcessVoxelsThread) { |
| 346 | qDebug("Voxel parsing thread created.\n"); | 337 | qDebug("Voxel parsing thread created."); |
| 347 | } | 338 | } |
| 348 | 339 | ||
| 349 | // call terminate before exiting | 340 | // call terminate before exiting |
| @@ -363,9 +354,7 @@ void Application::initializeGL() { · 13 unmodified lines | |||
| 363 | if (_justStarted) { | 354 | if (_justStarted) { |
| 364 | float startupTime = (usecTimestampNow() - usecTimestamp(&_applicationStartupTime)) / 1000000.0; | 355 | float startupTime = (usecTimestampNow() - usecTimestamp(&_applicationStartupTime)) / 1000000.0; |
| 365 | _justStarted = false; | 356 | _justStarted = false; |
| 366 | char title[50]; | 357 | qDebug("Startup time: %4.2f seconds.", startupTime); |
| 367 | sprintf(title, "Interface: %4.2f seconds\n", startupTime); | ||
| 368 | qDebug("%s", title); | ||
| 369 | const char LOGSTASH_INTERFACE_START_TIME_KEY[] = "interface-start-time"; | 358 | const char LOGSTASH_INTERFACE_START_TIME_KEY[] = "interface-start-time"; |
| 370 | 359 | ||
| 371 | // ask the Logstash class to record the startup time | 360 | // ask the Logstash class to record the startup time |
| @@ -672,9 +661,7 @@ void Application::keyPressEvent(QKeyEvent* event) { · 300 unmodified lines | |||
| 672 | _audioScope.inputPaused = !_audioScope.inputPaused; | 661 | _audioScope.inputPaused = !_audioScope.inputPaused; |
| 673 | break; | 662 | break; |
| 674 | case Qt::Key_L: | 663 | case Qt::Key_L: |
| 675 | if (!isShifted && !isMeta) { | 664 | if (isShifted) { |
| 676 | _displayLevels = !_displayLevels; | ||
| 677 | } else if (isShifted) { | ||
| 678 | Menu::getInstance()->triggerOption(MenuOption::LodTools); | 665 | Menu::getInstance()->triggerOption(MenuOption::LodTools); |
| 679 | } else if (isMeta) { | 666 | } else if (isMeta) { |
| 680 | Menu::getInstance()->triggerOption(MenuOption::Log); | 667 | Menu::getInstance()->triggerOption(MenuOption::Log); |
| @@ -1125,7 +1112,7 @@ void Application::mouseMoveEvent(QMouseEvent* event) { · 444 unmodified lines | |||
| 1125 | return; | 1112 | return; |
| 1126 | } | 1113 | } |
| 1127 | if (_isHoverVoxel) { | 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 | return; | 1116 | return; |
| 1130 | } | 1117 | } |
| 1131 | } | 1118 | } |
| @@ -1285,7 +1272,7 @@ void Application::wheelEvent(QWheelEvent* event) { · 153 unmodified lines | |||
| 1285 | void Application::sendPingPackets() { | 1272 | void Application::sendPingPackets() { |
| 1286 | 1273 | ||
| 1287 | const char nodesToPing[] = {NODE_TYPE_VOXEL_SERVER, NODE_TYPE_PARTICLE_SERVER, | 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 | unsigned char pingPacket[MAX_PACKET_SIZE]; | 1277 | unsigned char pingPacket[MAX_PACKET_SIZE]; |
| 1291 | int length = NodeList::getInstance()->fillPingPacket(pingPacket); | 1278 | int length = NodeList::getInstance()->fillPingPacket(pingPacket); |
| @@ -1343,16 +1330,12 @@ void Application::timer() { · 51 unmodified lines | |||
| 1343 | 1330 | ||
| 1344 | gettimeofday(&_timerStart, NULL); | 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 | // ask the node list to check in with the domain server | 1333 | // ask the node list to check in with the domain server |
| 1352 | NodeList::getInstance()->sendDomainServerCheckIn(); | 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 | _profile.updatePosition(_myAvatar.getPosition()); | 1337 | _profile.updatePosition(_myAvatar.getPosition()); |
| 1338 | _profile.updateOrientation(_myAvatar.getOrientation()); | ||
| 1356 | } | 1339 | } |
| 1357 | 1340 | ||
| 1358 | static glm::vec3 getFaceVector(BoxFace face) { | 1341 | static glm::vec3 getFaceVector(BoxFace face) { |
| @@ -1421,7 +1404,6 @@ void Application::terminate() { · 62 unmodified lines | |||
| 1421 | // Close serial port | 1404 | // Close serial port |
| 1422 | // close(serial_fd); | 1405 | // close(serial_fd); |
| 1423 | 1406 | ||
| 1424 | LeapManager::terminate(); | ||
| 1425 | Menu::getInstance()->saveSettings(); | 1407 | Menu::getInstance()->saveSettings(); |
| 1426 | _rearMirrorTools->saveSettings(_settings); | 1408 | _rearMirrorTools->saveSettings(_settings); |
| 1427 | _settings->sync(); | 1409 | _settings->sync(); |
| @@ -1429,22 +1411,19 @@ void Application::terminate() { · 1 unmodified line | |||
| 1429 | // let the avatar mixer know we're out | 1411 | // let the avatar mixer know we're out |
| 1430 | NodeList::getInstance()->sendKillNode(&NODE_TYPE_AVATAR_MIXER, 1); | 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 | printf(""); | 1414 | printf(""); |
| 1438 | _voxelProcessor.terminate(); | 1415 | _voxelProcessor.terminate(); |
| 1439 | _voxelHideShowThread.terminate(); | 1416 | _voxelHideShowThread.terminate(); |
| 1440 | _voxelEditSender.terminate(); | 1417 | _voxelEditSender.terminate(); |
| 1441 | _particleEditSender.terminate(); | 1418 | _particleEditSender.terminate(); |
| 1419 | _persistThread->terminate(); | ||
| 1420 | _persistThread = NULL; | ||
| 1442 | } | 1421 | } |
| 1443 | 1422 | ||
| 1444 | static Avatar* processAvatarMessageHeader(unsigned char*& packetData, size_t& dataBytes) { | 1423 | static Avatar* processAvatarMessageHeader(unsigned char*& packetData, size_t& dataBytes) { |
| 1445 | // record the packet for stats-tracking | 1424 | // record the packet for stats-tracking |
| 1446 | Application::getInstance()->getBandwidthMeter()->inputStream(BandwidthMeter::AVATARS).updateValue(dataBytes); | 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 | if (avatarMixerNode) { | 1427 | if (avatarMixerNode) { |
| 1449 | avatarMixerNode->recordBytesReceived(dataBytes); | 1428 | avatarMixerNode->recordBytesReceived(dataBytes); |
| 1450 | } | 1429 | } |
| @@ -1461,7 +1440,7 @@ static Avatar* processAvatarMessageHeader(unsigned char*& packetData, size_t& da · 10 unmodified lines | |||
| 1461 | dataBytes -= NUM_BYTES_RFC4122_UUID; | 1440 | dataBytes -= NUM_BYTES_RFC4122_UUID; |
| 1462 | 1441 | ||
| 1463 | // make sure the node exists | 1442 | // make sure the node exists |
| 1464 | Node* node = NodeList::getInstance()->nodeWithUUID(nodeUUID); | 1443 | SharedNodePointer node = NodeList::getInstance()->nodeWithUUID(nodeUUID); |
| 1465 | if (!node || !node->getLinkedData()) { | 1444 | if (!node || !node->getLinkedData()) { |
| 1466 | return NULL; | 1445 | return NULL; |
| 1467 | } | 1446 | } |
| @@ -1620,10 +1599,9 @@ void Application::makeVoxel(glm::vec3 position, · 152 unmodified lines | |||
| 1620 | isDestructive); | 1599 | isDestructive); |
| 1621 | } | 1600 | } |
| 1622 | 1601 | ||
| 1623 | const glm::vec3 Application::getMouseVoxelWorldCoordinates(const VoxelDetail _mouseVoxel) { | 1602 | glm::vec3 Application::getMouseVoxelWorldCoordinates(const VoxelDetail& mouseVoxel) { |
| 1624 | return glm::vec3((_mouseVoxel.x + _mouseVoxel.s / 2.f) * TREE_SCALE, | 1603 | return glm::vec3((mouseVoxel.x + mouseVoxel.s / 2.f) * TREE_SCALE, (mouseVoxel.y + mouseVoxel.s / 2.f) * TREE_SCALE, |
| 1625 | (_mouseVoxel.y + _mouseVoxel.s / 2.f) * TREE_SCALE, | 1604 | (mouseVoxel.z + mouseVoxel.s / 2.f) * TREE_SCALE); |
| 1626 | (_mouseVoxel.z + _mouseVoxel.s / 2.f) * TREE_SCALE); | ||
| 1627 | } | 1605 | } |
| 1628 | 1606 | ||
| 1629 | const float NUDGE_PRECISION_MIN = 1 / pow(2.0, 12.0); | 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 | void Application::importVoxels() { | 1689 | void Application::importVoxels() { |
| 1712 | if (_voxelImporter.exec()) { | 1690 | if (_voxelImporter.exec()) { |
| 1713 | qDebug("[DEBUG] Import succedded.\n"); | 1691 | qDebug("[DEBUG] Import succeeded."); |
| 1714 | } else { | 1692 | } else { |
| 1715 | qDebug("[DEBUG] Import failed.\n"); | 1693 | qDebug("[DEBUG] Import failed."); |
| 1716 | } | 1694 | } |
| 1717 | 1695 | ||
| 1718 | // restore the main window's active state | 1696 | // restore the main window's active state |
| @@ -1886,8 +1864,6 @@ void Application::init() { · 167 unmodified lines | |||
| 1886 | Qt::QueuedConnection); | 1864 | Qt::QueuedConnection); |
| 1887 | } | 1865 | } |
| 1888 | 1866 | ||
| 1889 | LeapManager::initialize(); | ||
| 1890 | |||
| 1891 | gettimeofday(&_timerStart, NULL); | 1867 | gettimeofday(&_timerStart, NULL); |
| 1892 | gettimeofday(&_lastTimeUpdated, NULL); | 1868 | gettimeofday(&_lastTimeUpdated, NULL); |
| 1893 | 1869 | ||
| @@ -1895,7 +1871,7 @@ void Application::init() { · 1 unmodified line | |||
| 1895 | if (Menu::getInstance()->getAudioJitterBufferSamples() != 0) { | 1871 | if (Menu::getInstance()->getAudioJitterBufferSamples() != 0) { |
| 1896 | _audio.setJitterBufferSamples(Menu::getInstance()->getAudioJitterBufferSamples()); | 1872 | _audio.setJitterBufferSamples(Menu::getInstance()->getAudioJitterBufferSamples()); |
| 1897 | } | 1873 | } |
| 1898 | qDebug("Loaded settings.\n"); | 1874 | qDebug("Loaded settings"); |
| 1899 | 1875 | ||
| 1900 | if (!_profile.getUsername().isEmpty()) { | 1876 | if (!_profile.getUsername().isEmpty()) { |
| 1901 | // we have a username for this avatar, ask the data-server for the mesh URL for this avatar | 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 | _glWidget->width(), | 1905 | _glWidget->width(), |
| 1930 | _glWidget->height()); | 1906 | _glWidget->height()); |
| 1931 | 1907 | ||
| 1932 | _followMode = new QAction(this); | ||
| 1933 | connect(_followMode, SIGNAL(triggered()), this, SLOT(toggleFollowMode())); | ||
| 1934 | _pieMenu.addAction(_followMode); | ||
| 1935 | |||
| 1936 | _audio.init(_glWidget); | 1908 | _audio.init(_glWidget); |
| 1937 | 1909 | ||
| 1938 | _rearMirrorTools = new RearMirrorTools(_glWidget, _mirrorViewRect, _settings); | 1910 | _rearMirrorTools = new RearMirrorTools(_glWidget, _mirrorViewRect, _settings); |
| @@ -1940,6 +1912,9 @@ void Application::init() { · 1 unmodified line | |||
| 1940 | connect(_rearMirrorTools, SIGNAL(restoreView()), SLOT(restoreMirrorView())); | 1912 | connect(_rearMirrorTools, SIGNAL(restoreView()), SLOT(restoreMirrorView())); |
| 1941 | connect(_rearMirrorTools, SIGNAL(shrinkView()), SLOT(shrinkMirrorView())); | 1913 | connect(_rearMirrorTools, SIGNAL(shrinkView()), SLOT(shrinkMirrorView())); |
| 1942 | connect(_rearMirrorTools, SIGNAL(resetView()), SLOT(resetSensors())); | 1914 | connect(_rearMirrorTools, SIGNAL(resetView()), SLOT(resetSensors())); |
| 1915 | |||
| 1916 | |||
| 1917 | updateLocalOctreeCache(true); | ||
| 1943 | } | 1918 | } |
| 1944 | 1919 | ||
| 1945 | void Application::closeMirrorView() { | 1920 | void Application::closeMirrorView() { |
| @@ -1987,16 +1962,16 @@ void Application::updateLookatTargetAvatar(const glm::vec3& mouseRayOrigin, cons · 41 unmodified lines | |||
| 1987 | Avatar* Application::findLookatTargetAvatar(const glm::vec3& mouseRayOrigin, const glm::vec3& mouseRayDirection, | 1962 | Avatar* Application::findLookatTargetAvatar(const glm::vec3& mouseRayOrigin, const glm::vec3& mouseRayDirection, |
| 1988 | glm::vec3& eyePosition, QUuid& nodeUUID = DEFAULT_NODE_ID_REF) { | 1963 | glm::vec3& eyePosition, QUuid& nodeUUID = DEFAULT_NODE_ID_REF) { |
| 1989 | 1964 | ||
| 1990 | NodeList* nodeList = NodeList::getInstance(); | 1965 | foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) { |
| 1991 | for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) { | ||
| 1992 | if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) { | 1966 | if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) { |
| 1993 | Avatar* avatar = (Avatar*)node->getLinkedData(); | 1967 | Avatar* avatar = (Avatar*)node->getLinkedData(); |
| 1994 | float distance; | 1968 | float distance; |
| 1969 | |||
| 1995 | if (avatar->findRayIntersection(mouseRayOrigin, mouseRayDirection, distance)) { | 1970 | if (avatar->findRayIntersection(mouseRayOrigin, mouseRayDirection, distance)) { |
| 1996 | // rescale to compensate for head embiggening | 1971 | // rescale to compensate for head embiggening |
| 1997 | eyePosition = (avatar->getHead().calculateAverageEyePosition() - avatar->getHead().getScalePivot()) * | 1972 | eyePosition = (avatar->getHead().calculateAverageEyePosition() - avatar->getHead().getScalePivot()) * |
| 1998 | (avatar->getScale() / avatar->getHead().getScale()) + avatar->getHead().getScalePivot(); | 1973 | (avatar->getScale() / avatar->getHead().getScale()) + avatar->getHead().getScalePivot(); |
| 1999 | 1974 | ||
| 2000 | _lookatIndicatorScale = avatar->getHead().getScale(); | 1975 | _lookatIndicatorScale = avatar->getHead().getScale(); |
| 2001 | _lookatOtherPosition = avatar->getHead().getPosition(); | 1976 | _lookatOtherPosition = avatar->getHead().getPosition(); |
| 2002 | nodeUUID = avatar->getOwningNode()->getUUID(); | 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 | return NULL; | 1983 | return NULL; |
| 2008 | } | 1984 | } |
| 2009 | 1985 | ||
| @@ -2028,71 +2004,6 @@ void Application::renderLookatIndicator(glm::vec3 pointOfInterest) { · 18 unmodified lines | |||
| 2028 | renderCircle(haloOrigin, INDICATOR_RADIUS, IDENTITY_UP, NUM_SEGMENTS); | 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 | void Application::renderHighlightVoxel(VoxelDetail voxel) { | 2007 | void Application::renderHighlightVoxel(VoxelDetail voxel) { |
| 2097 | glDisable(GL_LIGHTING); | 2008 | glDisable(GL_LIGHTING); |
| 2098 | glPushMatrix(); | 2009 | glPushMatrix(); |
| @@ -2110,10 +2021,9 @@ void Application::renderHighlightVoxel(VoxelDetail voxel) { · 11 unmodified lines | |||
| 2110 | void Application::updateAvatars(float deltaTime, glm::vec3 mouseRayOrigin, glm::vec3 mouseRayDirection) { | 2021 | void Application::updateAvatars(float deltaTime, glm::vec3 mouseRayOrigin, glm::vec3 mouseRayDirection) { |
| 2111 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); | 2022 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); |
| 2112 | PerformanceWarning warn(showWarnings, "Application::updateAvatars()"); | 2023 | PerformanceWarning warn(showWarnings, "Application::updateAvatars()"); |
| 2113 | NodeList* nodeList = NodeList::getInstance(); | 2024 | |
| 2114 | 2025 | foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) { | |
| 2115 | for(NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) { | 2026 | QMutexLocker(&node->getMutex()); |
| 2116 | node->lock(); | ||
| 2117 | if (node->getLinkedData()) { | 2027 | if (node->getLinkedData()) { |
| 2118 | Avatar *avatar = (Avatar *)node->getLinkedData(); | 2028 | Avatar *avatar = (Avatar *)node->getLinkedData(); |
| 2119 | if (!avatar->isInitialized()) { | 2029 | if (!avatar->isInitialized()) { |
| @@ -2122,16 +2032,18 @@ void Application::updateAvatars(float deltaTime, glm::vec3 mouseRayOrigin, glm:: · 2 unmodified lines | |||
| 2122 | avatar->simulate(deltaTime, NULL); | 2032 | avatar->simulate(deltaTime, NULL); |
| 2123 | avatar->setMouseRay(mouseRayOrigin, mouseRayDirection); | 2033 | avatar->setMouseRay(mouseRayOrigin, mouseRayDirection); |
| 2124 | } | 2034 | } |
| 2125 | node->unlock(); | ||
| 2126 | } | 2035 | } |
| 2127 | 2036 | ||
| 2128 | // simulate avatar fades | 2037 | // simulate avatar fades |
| 2129 | for (vector<Avatar*>::iterator fade = _avatarFades.begin(); fade != _avatarFades.end(); fade++) { | 2038 | for (vector<Avatar*>::iterator fade = _avatarFades.begin(); fade != _avatarFades.end(); fade++) { |
| 2130 | Avatar* avatar = *fade; | 2039 | Avatar* avatar = *fade; |
| 2131 | const float SHRINK_RATE = 0.9f; | 2040 | const float SHRINK_RATE = 0.9f; |
| 2132 | avatar->setNewScale(avatar->getNewScale() * SHRINK_RATE); | 2041 | |
| 2133 | const float MINIMUM_SCALE = 0.001f; | 2042 | avatar->setTargetScale(avatar->getScale() * SHRINK_RATE); |
| 2134 | if (avatar->getNewScale() < MINIMUM_SCALE) { | 2043 | |
| 2044 | const float MIN_FADE_SCALE = 0.001; | ||
| 2045 | |||
| 2046 | if (avatar->getTargetScale() < MIN_FADE_SCALE) { | ||
| 2135 | delete avatar; | 2047 | delete avatar; |
| 2136 | _avatarFades.erase(fade--); | 2048 | _avatarFades.erase(fade--); |
| 2137 | 2049 | ||
| @@ -2367,9 +2279,6 @@ void Application::updateHandAndTouch(float deltaTime) { · 229 unmodified lines | |||
| 2367 | void Application::updateLeap(float deltaTime) { | 2279 | void Application::updateLeap(float deltaTime) { |
| 2368 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); | 2280 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); |
| 2369 | PerformanceWarning warn(showWarnings, "Application::updateLeap()"); | 2281 | PerformanceWarning warn(showWarnings, "Application::updateLeap()"); |
| 2370 | |||
| 2371 | LeapManager::enableFakeFingers(Menu::getInstance()->isOptionChecked(MenuOption::SimulateLeapHand)); | ||
| 2372 | LeapManager::nextFrame(); | ||
| 2373 | } | 2282 | } |
| 2374 | 2283 | ||
| 2375 | void Application::updateSixense(float deltaTime) { | 2284 | void Application::updateSixense(float deltaTime) { |
| @@ -2382,27 +2291,19 @@ void Application::updateSixense(float deltaTime) { · 6 unmodified lines | |||
| 2382 | void Application::updateSerialDevices(float deltaTime) { | 2291 | void Application::updateSerialDevices(float deltaTime) { |
| 2383 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); | 2292 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); |
| 2384 | PerformanceWarning warn(showWarnings, "Application::updateSerialDevices()"); | 2293 | PerformanceWarning warn(showWarnings, "Application::updateSerialDevices()"); |
| 2385 | |||
| 2386 | if (_serialHeadSensor.isActive()) { | ||
| 2387 | _serialHeadSensor.readData(deltaTime); | ||
| 2388 | } | ||
| 2389 | } | 2294 | } |
| 2390 | 2295 | ||
| 2391 | void Application::updateThreads(float deltaTime) { | 2296 | void Application::updateThreads(float deltaTime) { |
| 2392 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); | 2297 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); |
| 2393 | PerformanceWarning warn(showWarnings, "Application::updateThreads()"); | 2298 | PerformanceWarning warn(showWarnings, "Application::updateThreads()"); |
| 2394 | 2299 | ||
| 2395 | // read incoming packets from network | ||
| 2396 | if (!_enableNetworkThread) { | ||
| 2397 | networkReceive(0); | ||
| 2398 | } | ||
| 2399 | |||
| 2400 | // parse voxel packets | 2300 | // parse voxel packets |
| 2401 | if (!_enableProcessVoxelsThread) { | 2301 | if (!_enableProcessVoxelsThread) { |
| 2402 | _voxelProcessor.threadRoutine(); | 2302 | _voxelProcessor.threadRoutine(); |
| 2403 | _voxelHideShowThread.threadRoutine(); | 2303 | _voxelHideShowThread.threadRoutine(); |
| 2404 | _voxelEditSender.threadRoutine(); | 2304 | _voxelEditSender.threadRoutine(); |
| 2405 | _particleEditSender.threadRoutine(); | 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 | _headMouseY -= headVelocity.x * HEADMOUSE_FACESHIFT_PITCH_SCALE; | 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 | // Constrain head-driven mouse to edges of screen | 2532 | // Constrain head-driven mouse to edges of screen |
| 2667 | _headMouseX = glm::clamp(_headMouseX, 0, _glWidget->width()); | 2533 | _headMouseX = glm::clamp(_headMouseX, 0, _glWidget->width()); |
| 2668 | _headMouseY = glm::clamp(_headMouseY, 0, _glWidget->height()); | 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 | unsigned char voxelQueryPacket[MAX_PACKET_SIZE]; | 2610 | unsigned char voxelQueryPacket[MAX_PACKET_SIZE]; |
| 2745 | 2611 | ||
| 2746 | NodeList* nodeList = NodeList::getInstance(); | ||
| 2747 | |||
| 2748 | // Iterate all of the nodes, and get a count of how many voxel servers we have... | 2612 | // Iterate all of the nodes, and get a count of how many voxel servers we have... |
| 2749 | int totalServers = 0; | 2613 | int totalServers = 0; |
| 2750 | int inViewServers = 0; | 2614 | int inViewServers = 0; |
| 2751 | int unknownJurisdictionServers = 0; | 2615 | int unknownJurisdictionServers = 0; |
| 2752 | 2616 | ||
| 2753 | for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) { | 2617 | foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) { |
| 2754 | |||
| 2755 | // only send to the NodeTypes that are serverType | 2618 | // only send to the NodeTypes that are serverType |
| 2756 | if (node->getActiveSocket() != NULL && node->getType() == serverType) { | 2619 | if (node->getActiveSocket() != NULL && node->getType() == serverType) { |
| 2757 | totalServers++; | 2620 | totalServers++; |
| 2758 | 2621 | ||
| 2759 | // get the server bounds for this server | 2622 | // get the server bounds for this server |
| 2760 | QUuid nodeUUID = node->getUUID(); | 2623 | QUuid nodeUUID = node->getUUID(); |
| 2761 | 2624 | ||
| 2762 | // if we haven't heard from this voxel server, go ahead and send it a query, so we | 2625 | // if we haven't heard from this voxel server, go ahead and send it a query, so we |
| 2763 | // can get the jurisdiction... | 2626 | // can get the jurisdiction... |
| 2764 | if (jurisdictions.find(nodeUUID) == jurisdictions.end()) { | 2627 | if (jurisdictions.find(nodeUUID) == jurisdictions.end()) { |
| 2765 | unknownJurisdictionServers++; | 2628 | unknownJurisdictionServers++; |
| 2766 | } else { | 2629 | } else { |
| 2767 | const JurisdictionMap& map = (jurisdictions)[nodeUUID]; | 2630 | const JurisdictionMap& map = (jurisdictions)[nodeUUID]; |
| 2768 | 2631 | ||
| 2769 | unsigned char* rootCode = map.getRootOctalCode(); | 2632 | unsigned char* rootCode = map.getRootOctalCode(); |
| 2770 | 2633 | ||
| 2771 | if (rootCode) { | 2634 | if (rootCode) { |
| 2772 | VoxelPositionSize rootDetails; | 2635 | VoxelPositionSize rootDetails; |
| 2773 | voxelDetailsForCode(rootCode, rootDetails); | 2636 | voxelDetailsForCode(rootCode, rootDetails); |
| 2774 | AABox serverBounds(glm::vec3(rootDetails.x, rootDetails.y, rootDetails.z), rootDetails.s); | 2637 | AABox serverBounds(glm::vec3(rootDetails.x, rootDetails.y, rootDetails.z), rootDetails.s); |
| 2775 | serverBounds.scale(TREE_SCALE); | 2638 | serverBounds.scale(TREE_SCALE); |
| 2776 | 2639 | ||
| 2777 | ViewFrustum::location serverFrustumLocation = _viewFrustum.boxInFrustum(serverBounds); | 2640 | ViewFrustum::location serverFrustumLocation = _viewFrustum.boxInFrustum(serverBounds); |
| 2778 | 2641 | ||
| 2779 | if (serverFrustumLocation != ViewFrustum::OUTSIDE) { | 2642 | if (serverFrustumLocation != ViewFrustum::OUTSIDE) { |
| 2780 | inViewServers++; | 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 | if (wantExtraDebugging && unknownJurisdictionServers > 0) { | 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 | totalServers, inViewServers, unknownJurisdictionServers); | 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 | if (wantExtraDebugging && unknownJurisdictionServers > 0) { | 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 | 2674 | ||
| 2812 | for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) { | 2675 | NodeList* nodeList = NodeList::getInstance(); |
| 2676 | |||
| 2677 | foreach (const SharedNodePointer& node, nodeList->getNodeHash()) { | ||
| 2813 | // only send to the NodeTypes that are serverType | 2678 | // only send to the NodeTypes that are serverType |
| 2814 | if (node->getActiveSocket() != NULL && node->getType() == serverType) { | 2679 | if (node->getActiveSocket() != NULL && node->getType() == serverType) { |
| 2815 | 2680 | ||
| 2816 | 2681 | ||
| 2817 | // get the server bounds for this server | 2682 | // get the server bounds for this server |
| 2818 | QUuid nodeUUID = node->getUUID(); | 2683 | QUuid nodeUUID = node->getUUID(); |
| 2819 | 2684 | ||
| 2820 | bool inView = false; | 2685 | bool inView = false; |
| 2821 | bool unknownView = false; | 2686 | bool unknownView = false; |
| 2822 | 2687 | ||
| 2823 | // if we haven't heard from this voxel server, go ahead and send it a query, so we | 2688 | // if we haven't heard from this voxel server, go ahead and send it a query, so we |
| 2824 | // can get the jurisdiction... | 2689 | // can get the jurisdiction... |
| 2825 | if (jurisdictions.find(nodeUUID) == jurisdictions.end()) { | 2690 | if (jurisdictions.find(nodeUUID) == jurisdictions.end()) { |
| 2826 | unknownView = true; // assume it's in view | 2691 | unknownView = true; // assume it's in view |
| 2827 | if (wantExtraDebugging) { | 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 | } else { | 2695 | } else { |
| 2831 | const JurisdictionMap& map = (jurisdictions)[nodeUUID]; | 2696 | const JurisdictionMap& map = (jurisdictions)[nodeUUID]; |
| 2832 | 2697 | ||
| 2833 | unsigned char* rootCode = map.getRootOctalCode(); | 2698 | unsigned char* rootCode = map.getRootOctalCode(); |
| 2834 | 2699 | ||
| 2835 | if (rootCode) { | 2700 | if (rootCode) { |
| 2836 | VoxelPositionSize rootDetails; | 2701 | VoxelPositionSize rootDetails; |
| 2837 | voxelDetailsForCode(rootCode, rootDetails); | 2702 | voxelDetailsForCode(rootCode, rootDetails); |
| 2838 | AABox serverBounds(glm::vec3(rootDetails.x, rootDetails.y, rootDetails.z), rootDetails.s); | 2703 | AABox serverBounds(glm::vec3(rootDetails.x, rootDetails.y, rootDetails.z), rootDetails.s); |
| 2839 | serverBounds.scale(TREE_SCALE); | 2704 | serverBounds.scale(TREE_SCALE); |
| 2840 | 2705 | ||
| 2841 | ViewFrustum::location serverFrustumLocation = _viewFrustum.boxInFrustum(serverBounds); | 2706 | ViewFrustum::location serverFrustumLocation = _viewFrustum.boxInFrustum(serverBounds); |
| 2842 | if (serverFrustumLocation != ViewFrustum::OUTSIDE) { | 2707 | if (serverFrustumLocation != ViewFrustum::OUTSIDE) { |
| 2843 | inView = true; | 2708 | inView = true; |
| @@ -2846,19 +2711,19 @@ void Application::queryOctree(NODE_TYPE serverType, PACKET_TYPE packetType, Node · 2 unmodified lines | |||
| 2846 | } | 2711 | } |
| 2847 | } else { | 2712 | } else { |
| 2848 | if (wantExtraDebugging) { | 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 | if (inView) { | 2719 | if (inView) { |
| 2855 | _voxelQuery.setMaxOctreePacketsPerSecond(perServerPPS); | 2720 | _voxelQuery.setMaxOctreePacketsPerSecond(perServerPPS); |
| 2856 | } else if (unknownView) { | 2721 | } else if (unknownView) { |
| 2857 | if (wantExtraDebugging) { | 2722 | if (wantExtraDebugging) { |
| 2858 | qDebug() << "no known jurisdiction for node " << *node << ", give it budget of " | 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 | // set the query's position/orientation to be degenerate in a manner that will get the scene quickly | 2727 | // set the query's position/orientation to be degenerate in a manner that will get the scene quickly |
| 2863 | // If there's only one server, then don't do this, and just let the normal voxel query pass through | 2728 | // If there's only one server, then don't do this, and just let the normal voxel query pass through |
| 2864 | // as expected... this way, we will actually get a valid scene if there is one to be seen | 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 | _voxelQuery.setCameraNearClip(0.1); | 2734 | _voxelQuery.setCameraNearClip(0.1); |
| 2870 | _voxelQuery.setCameraFarClip(0.1); | 2735 | _voxelQuery.setCameraFarClip(0.1); |
| 2871 | if (wantExtraDebugging) { | 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 | } else { | 2739 | } else { |
| 2875 | if (wantExtraDebugging) { | 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 | _voxelQuery.setMaxOctreePacketsPerSecond(perUnknownServer); | 2744 | _voxelQuery.setMaxOctreePacketsPerSecond(perUnknownServer); |
| @@ -2882,24 +2747,24 @@ void Application::queryOctree(NODE_TYPE serverType, PACKET_TYPE packetType, Node · 2 unmodified lines | |||
| 2882 | } | 2747 | } |
| 2883 | // set up the packet for sending... | 2748 | // set up the packet for sending... |
| 2884 | unsigned char* endOfVoxelQueryPacket = voxelQueryPacket; | 2749 | unsigned char* endOfVoxelQueryPacket = voxelQueryPacket; |
| 2885 | 2750 | ||
| 2886 | // insert packet type/version and node UUID | 2751 | // insert packet type/version and node UUID |
| 2887 | endOfVoxelQueryPacket += populateTypeAndVersion(endOfVoxelQueryPacket, packetType); | 2752 | endOfVoxelQueryPacket += populateTypeAndVersion(endOfVoxelQueryPacket, packetType); |
| 2888 | QByteArray ownerUUID = nodeList->getOwnerUUID().toRfc4122(); | 2753 | QByteArray ownerUUID = nodeList->getOwnerUUID().toRfc4122(); |
| 2889 | memcpy(endOfVoxelQueryPacket, ownerUUID.constData(), ownerUUID.size()); | 2754 | memcpy(endOfVoxelQueryPacket, ownerUUID.constData(), ownerUUID.size()); |
| 2890 | endOfVoxelQueryPacket += ownerUUID.size(); | 2755 | endOfVoxelQueryPacket += ownerUUID.size(); |
| 2891 | 2756 | ||
| 2892 | // encode the query data... | 2757 | // encode the query data... |
| 2893 | endOfVoxelQueryPacket += _voxelQuery.getBroadcastData(endOfVoxelQueryPacket); | 2758 | endOfVoxelQueryPacket += _voxelQuery.getBroadcastData(endOfVoxelQueryPacket); |
| 2894 | 2759 | ||
| 2895 | int packetLength = endOfVoxelQueryPacket - voxelQueryPacket; | 2760 | int packetLength = endOfVoxelQueryPacket - voxelQueryPacket; |
| 2896 | 2761 | ||
| 2897 | // make sure we still have an active socket | 2762 | // make sure we still have an active socket |
| 2898 | if (node->getActiveSocket()) { | 2763 | if (node->getActiveSocket()) { |
| 2899 | nodeList->getNodeSocket().writeDatagram((char*) voxelQueryPacket, packetLength, | 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 | // Feed number of bytes to corresponding channel of the bandwidth meter | 2768 | // Feed number of bytes to corresponding channel of the bandwidth meter |
| 2904 | _bandwidthMeter.outputStream(BandwidthMeter::VOXELS).updateValue(packetLength); | 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 | // render transmitter pick ray, if non-empty | 3124 | // render transmitter pick ray, if non-empty |
| 3266 | if (_transmitterPickStart != _transmitterPickEnd) { | 3125 | if (_transmitterPickStart != _transmitterPickEnd) { |
| 3267 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), | 3126 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), |
| @@ -3329,8 +3188,7 @@ void Application::displayOverlay() { · 61 unmodified lines | |||
| 3329 | 3188 | ||
| 3330 | //noiseTest(_glWidget->width(), _glWidget->height()); | 3189 | //noiseTest(_glWidget->width(), _glWidget->height()); |
| 3331 | 3190 | ||
| 3332 | if (Menu::getInstance()->isOptionChecked(MenuOption::HeadMouse) | 3191 | if (Menu::getInstance()->isOptionChecked(MenuOption::HeadMouse)) { |
| 3333 | && USING_INVENSENSE_MPU9150) { | ||
| 3334 | // Display small target box at center or head mouse target that can also be used to measure LOD | 3192 | // Display small target box at center or head mouse target that can also be used to measure LOD |
| 3335 | glColor3f(1.0, 1.0, 1.0); | 3193 | glColor3f(1.0, 1.0, 1.0); |
| 3336 | glDisable(GL_LINE_SMOOTH); | 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 | // Show hand transmitter data if detected | 3227 | // Show hand transmitter data if detected |
| 3373 | if (_myTransmitter.isConnected()) { | 3228 | if (_myTransmitter.isConnected()) { |
| 3374 | _myTransmitter.renderLevels(_glWidget->width(), _glWidget->height()); | 3229 | _myTransmitter.renderLevels(_glWidget->width(), _glWidget->height()); |
| @@ -3388,12 +3243,12 @@ void Application::displayOverlay() { · 13 unmodified lines | |||
| 3388 | glPointSize(1.0f); | 3243 | glPointSize(1.0f); |
| 3389 | char nodes[100]; | 3244 | char nodes[100]; |
| 3390 | 3245 | ||
| 3391 | NodeList* nodeList = NodeList::getInstance(); | ||
| 3392 | int totalAvatars = 0, totalServers = 0; | 3246 | int totalAvatars = 0, totalServers = 0; |
| 3393 | 3247 | ||
| 3394 | for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) { | 3248 | foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) { |
| 3395 | node->getType() == NODE_TYPE_AGENT ? totalAvatars++ : totalServers++; | 3249 | node->getType() == NODE_TYPE_AGENT ? totalAvatars++ : totalServers++; |
| 3396 | } | 3250 | } |
| 3251 | |||
| 3397 | sprintf(nodes, "Servers: %d, Avatars: %d\n", totalServers, totalAvatars); | 3252 | sprintf(nodes, "Servers: %d, Avatars: %d\n", totalServers, totalAvatars); |
| 3398 | drawtext(_glWidget->width() - 150, 20, 0.10, 0, 1.0, 0, nodes, 1, 0, 0); | 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 | int pingAudio = 0, pingAvatar = 0, pingVoxel = 0, pingVoxelMax = 0; | 3348 | int pingAudio = 0, pingAvatar = 0, pingVoxel = 0, pingVoxelMax = 0; |
| 3494 | 3349 | ||
| 3495 | NodeList* nodeList = NodeList::getInstance(); | 3350 | NodeList* nodeList = NodeList::getInstance(); |
| 3496 | Node* audioMixerNode = nodeList->soloNodeOfType(NODE_TYPE_AUDIO_MIXER); | 3351 | SharedNodePointer audioMixerNode = nodeList->soloNodeOfType(NODE_TYPE_AUDIO_MIXER); |
| 3497 | Node* avatarMixerNode = nodeList->soloNodeOfType(NODE_TYPE_AVATAR_MIXER); | 3352 | SharedNodePointer avatarMixerNode = nodeList->soloNodeOfType(NODE_TYPE_AVATAR_MIXER); |
| 3498 | 3353 | ||
| 3499 | pingAudio = audioMixerNode ? audioMixerNode->getPingMs() : 0; | 3354 | pingAudio = audioMixerNode ? audioMixerNode->getPingMs() : 0; |
| 3500 | pingAvatar = avatarMixerNode ? avatarMixerNode->getPingMs() : 0; | 3355 | pingAvatar = avatarMixerNode ? avatarMixerNode->getPingMs() : 0; |
| @@ -3503,7 +3358,8 @@ void Application::displayStats() { · 2 unmodified lines | |||
| 3503 | // Now handle voxel servers, since there could be more than one, we average their ping times | 3358 | // Now handle voxel servers, since there could be more than one, we average their ping times |
| 3504 | unsigned long totalPingVoxel = 0; | 3359 | unsigned long totalPingVoxel = 0; |
| 3505 | int voxelServerCount = 0; | 3360 | int voxelServerCount = 0; |
| 3506 | for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) { | 3361 | |
| 3362 | foreach (const SharedNodePointer& node, nodeList->getNodeHash()) { | ||
| 3507 | if (node->getType() == NODE_TYPE_VOXEL_SERVER) { | 3363 | if (node->getType() == NODE_TYPE_VOXEL_SERVER) { |
| 3508 | totalPingVoxel += node->getPingMs(); | 3364 | totalPingVoxel += node->getPingMs(); |
| 3509 | voxelServerCount++; | 3365 | voxelServerCount++; |
| @@ -3512,6 +3368,7 @@ void Application::displayStats() { · 2 unmodified lines | |||
| 3512 | } | 3368 | } |
| 3513 | } | 3369 | } |
| 3514 | } | 3370 | } |
| 3371 | |||
| 3515 | if (voxelServerCount) { | 3372 | if (voxelServerCount) { |
| 3516 | pingVoxel = totalPingVoxel/voxelServerCount; | 3373 | pingVoxel = totalPingVoxel/voxelServerCount; |
| 3517 | } | 3374 | } |
| @@ -3528,7 +3385,7 @@ void Application::displayStats() { · 10 unmodified lines | |||
| 3528 | sprintf(avatarStats, "Avatar: pos %.3f, %.3f, %.3f, vel %.1f, yaw = %.2f", avatarPos.x, avatarPos.y, avatarPos.z, glm::length(_myAvatar.getVelocity()), _myAvatar.getBodyYaw()); | 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 | drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, avatarStats); | 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 | char avatarMixerStats[200]; | 3389 | char avatarMixerStats[200]; |
| 3533 | if (avatarMixer) { | 3390 | if (avatarMixer) { |
| 3534 | sprintf(avatarMixerStats, "Avatar Mixer: %.f kbps, %.f pps", | 3391 | sprintf(avatarMixerStats, "Avatar Mixer: %.f kbps, %.f pps", |
| @@ -3660,11 +3517,6 @@ void Application::displayStats() { · 125 unmodified lines | |||
| 3660 | statsVerticalOffset += PELS_PER_LINE; | 3517 | statsVerticalOffset += PELS_PER_LINE; |
| 3661 | drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, (char*)voxelStats.str().c_str()); | 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 | if (_perfStatsOn) { | 3520 | if (_perfStatsOn) { |
| 3669 | // Get the PerfStats group details. We need to allocate and array of char* long enough to hold 1+groups | 3521 | // Get the PerfStats group details. We need to allocate and array of char* long enough to hold 1+groups |
| 3670 | char** perfStatLinesArray = new char*[PerfStat::getGroupCount()+1]; | 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 | // render the coverage map on screen | 3588 | // render the coverage map on screen |
| 3737 | void Application::renderCoverageMapV2() { | 3589 | void Application::renderCoverageMapV2() { |
| 3738 | |||
| 3739 | //qDebug("renderCoverageMap()\n"); | ||
| 3740 | |||
| 3741 | glDisable(GL_LIGHTING); | 3590 | glDisable(GL_LIGHTING); |
| 3742 | glLineWidth(2.0); | 3591 | glLineWidth(2.0); |
| 3743 | glBegin(GL_LINES); | 3592 | glBegin(GL_LINES); |
| @@ -3781,8 +3630,6 @@ void Application::renderCoverageMapsV2Recursively(CoverageMapV2* map) { · 37 unmodified lines | |||
| 3781 | // render the coverage map on screen | 3630 | // render the coverage map on screen |
| 3782 | void Application::renderCoverageMap() { | 3631 | void Application::renderCoverageMap() { |
| 3783 | 3632 | ||
| 3784 | //qDebug("renderCoverageMap()\n"); | ||
| 3785 | |||
| 3786 | glDisable(GL_LIGHTING); | 3633 | glDisable(GL_LIGHTING); |
| 3787 | glLineWidth(2.0); | 3634 | glLineWidth(2.0); |
| 3788 | glBegin(GL_LINES); | 3635 | glBegin(GL_LINES); |
| @@ -3857,10 +3704,10 @@ void Application::renderAvatars(bool forceRenderHead, bool selfAvatarOnly) { · 68 unmodified lines | |||
| 3857 | if (!selfAvatarOnly) { | 3704 | if (!selfAvatarOnly) { |
| 3858 | // Render avatars of other nodes | 3705 | // Render avatars of other nodes |
| 3859 | NodeList* nodeList = NodeList::getInstance(); | 3706 | NodeList* nodeList = NodeList::getInstance(); |
| 3860 | 3707 | ||
| 3861 | for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) { | 3708 | foreach (const SharedNodePointer& node, nodeList->getNodeHash()) { |
| 3862 | node->lock(); | 3709 | QMutexLocker(&node->getMutex()); |
| 3863 | 3710 | ||
| 3864 | if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) { | 3711 | if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) { |
| 3865 | Avatar *avatar = (Avatar *)node->getLinkedData(); | 3712 | Avatar *avatar = (Avatar *)node->getLinkedData(); |
| 3866 | if (!avatar->isInitialized()) { | 3713 | if (!avatar->isInitialized()) { |
| @@ -3869,8 +3716,6 @@ void Application::renderAvatars(bool forceRenderHead, bool selfAvatarOnly) { · 2 unmodified lines | |||
| 3869 | avatar->render(false); | 3716 | avatar->render(false); |
| 3870 | avatar->setDisplayingLookatVectors(Menu::getInstance()->isOptionChecked(MenuOption::LookAtVectors)); | 3717 | avatar->setDisplayingLookatVectors(Menu::getInstance()->isOptionChecked(MenuOption::LookAtVectors)); |
| 3871 | } | 3718 | } |
| 3872 | |||
| 3873 | node->unlock(); | ||
| 3874 | } | 3719 | } |
| 3875 | 3720 | ||
| 3876 | // render avatar fades | 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 | void Application::resetSensors() { | 3963 | void Application::resetSensors() { |
| 4131 | _headMouseX = _mouseX = _glWidget->width() / 2; | 3964 | _headMouseX = _mouseX = _glWidget->width() / 2; |
| 4132 | _headMouseY = _mouseY = _glWidget->height() / 2; | 3965 | _headMouseY = _mouseY = _glWidget->height() / 2; |
| 4133 | 3966 | ||
| 4134 | if (_serialHeadSensor.isActive()) { | ||
| 4135 | _serialHeadSensor.resetAverages(); | ||
| 4136 | } | ||
| 4137 | _webcam.reset(); | 3967 | _webcam.reset(); |
| 4138 | _faceshift.reset(); | 3968 | _faceshift.reset(); |
| 4139 | LeapManager::reset(); | ||
| 4140 | 3969 | ||
| 4141 | if (OculusManager::isConnected()) { | 3970 | if (OculusManager::isConnected()) { |
| 4142 | OculusManager::reset(); | 3971 | OculusManager::reset(); |
| @@ -4187,13 +4016,13 @@ void Application::updateWindowTitle(){ · 44 unmodified lines | |||
| 4187 | title += _profile.getLastDomain(); | 4016 | title += _profile.getLastDomain(); |
| 4188 | title += buildVersion; | 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 | _window->setWindowTitle(title); | 4020 | _window->setWindowTitle(title); |
| 4192 | } | 4021 | } |
| 4193 | 4022 | ||
| 4194 | void Application::domainChanged(QString domain) { | 4023 | void Application::domainChanged(const QString& domainHostname) { |
| 4195 | // update the user's last domain in their Profile (which will propagate to data-server) | 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 | updateWindowTitle(); | 4027 | updateWindowTitle(); |
| 4199 | 4028 | ||
| @@ -4204,13 +4033,13 @@ void Application::domainChanged(QString domain) { · 4 unmodified lines | |||
| 4204 | _voxelServerJurisdictions.clear(); | 4033 | _voxelServerJurisdictions.clear(); |
| 4205 | _octreeServerSceneStats.clear(); | 4034 | _octreeServerSceneStats.clear(); |
| 4206 | _particleServerJurisdictions.clear(); | 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 | if (node->getType() == NODE_TYPE_VOXEL_SERVER) { | 4043 | if (node->getType() == NODE_TYPE_VOXEL_SERVER) { |
| 4215 | QUuid nodeUUID = node->getUUID(); | 4044 | QUuid nodeUUID = node->getUUID(); |
| 4216 | // see if this is the first we've heard of this node... | 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 | const HifiSockAddr& senderSockAddr, bool wasStatsPacket) { | 4119 | const HifiSockAddr& senderSockAddr, bool wasStatsPacket) { |
| 4291 | 4120 | ||
| 4292 | // Attempt to identify the sender from it's address. | 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 | if (serverNode) { | 4123 | if (serverNode) { |
| 4295 | QUuid nodeUUID = serverNode->getUUID(); | 4124 | QUuid nodeUUID = serverNode->getUUID(); |
| 4296 | 4125 | ||
| @@ -4307,7 +4136,7 @@ void Application::trackIncomingVoxelPacket(unsigned char* messageData, ssize_t m · 10 unmodified lines | |||
| 4307 | int Application::parseOctreeStats(unsigned char* messageData, ssize_t messageLength, const HifiSockAddr& senderSockAddr) { | 4136 | int Application::parseOctreeStats(unsigned char* messageData, ssize_t messageLength, const HifiSockAddr& senderSockAddr) { |
| 4308 | 4137 | ||
| 4309 | // But, also identify the sender, and keep track of the contained jurisdiction root for this server | 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 | // parse the incoming stats datas stick it in a temporary object for now, while we | 4141 | // parse the incoming stats datas stick it in a temporary object for now, while we |
| 4313 | // determine which server it belongs to | 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 | // Receive packets from other nodes/servers and decide what to do with them! | 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 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), | 4197 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), |
| 4369 | "Application::networkReceive()"); | 4198 | "Application::networkReceive()"); |
| 4370 | 4199 | ||
| 4371 | HifiSockAddr senderSockAddr; | 4200 | HifiSockAddr senderSockAddr; |
| 4372 | ssize_t bytesReceived; | 4201 | ssize_t bytesReceived; |
| 4373 | 4202 | ||
| 4374 | Application* app = Application::getInstance(); | 4203 | while (NodeList::getInstance()->getNodeSocket().hasPendingDatagrams() && |
| 4375 | while (!app->_stopNetworkReceiveThread) { | 4204 | (bytesReceived = NodeList::getInstance()->getNodeSocket().readDatagram((char*) _incomingPacket, |
| 4376 | if (NodeList::getInstance()->getNodeSocket().hasPendingDatagrams() && | 4205 | MAX_PACKET_SIZE, |
| 4377 | (bytesReceived = NodeList::getInstance()->getNodeSocket().readDatagram((char*) app->_incomingPacket, | 4206 | senderSockAddr.getAddressPointer(), |
| 4378 | MAX_PACKET_SIZE, | 4207 | senderSockAddr.getPortPointer()))) { |
| 4379 | senderSockAddr.getAddressPointer(), | 4208 | |
| 4380 | senderSockAddr.getPortPointer()))) { | 4209 | _packetCount++; |
| 4381 | 4210 | _bytesCount += bytesReceived; | |
| 4382 | app->_packetCount++; | 4211 | |
| 4383 | app->_bytesCount += bytesReceived; | 4212 | if (packetVersionMatch(_incomingPacket)) { |
| 4384 | 4213 | // only process this packet if we have a match on the packet version | |
| 4385 | if (packetVersionMatch(app->_incomingPacket)) { | 4214 | switch (_incomingPacket[0]) { |
| 4386 | // only process this packet if we have a match on the packet version | 4215 | case PACKET_TYPE_TRANSMITTER_DATA_V2: |
| 4387 | switch (app->_incomingPacket[0]) { | 4216 | // V2 = IOS transmitter app |
| 4388 | case PACKET_TYPE_TRANSMITTER_DATA_V2: | 4217 | _myTransmitter.processIncomingData(_incomingPacket, bytesReceived); |
| 4389 | // V2 = IOS transmitter app | 4218 | |
| 4390 | app->_myTransmitter.processIncomingData(app->_incomingPacket, bytesReceived); | 4219 | break; |
| 4391 | 4220 | case PACKET_TYPE_MIXED_AUDIO: | |
| 4392 | break; | 4221 | QMetaObject::invokeMethod(&_audio, "addReceivedAudioToBuffer", Qt::QueuedConnection, |
| 4393 | case PACKET_TYPE_MIXED_AUDIO: | 4222 | Q_ARG(QByteArray, QByteArray((char*) _incomingPacket, bytesReceived))); |
| 4394 | QMetaObject::invokeMethod(&app->_audio, "addReceivedAudioToBuffer", Qt::QueuedConnection, | 4223 | break; |
| 4395 | Q_ARG(QByteArray, QByteArray((char*) app->_incomingPacket, bytesReceived))); | 4224 | |
| 4396 | break; | 4225 | case PACKET_TYPE_PARTICLE_ADD_RESPONSE: |
| 4397 | 4226 | // look up our ParticleEditHanders.... | |
| 4398 | case PACKET_TYPE_PARTICLE_ADD_RESPONSE: | 4227 | ParticleEditHandle::handleAddResponse(_incomingPacket, bytesReceived); |
| 4399 | // look up our ParticleEditHanders.... | 4228 | break; |
| 4400 | ParticleEditHandle::handleAddResponse(app->_incomingPacket, bytesReceived); | 4229 | |
| 4401 | break; | 4230 | case PACKET_TYPE_PARTICLE_DATA: |
| 4402 | 4231 | case PACKET_TYPE_VOXEL_DATA: | |
| 4403 | case PACKET_TYPE_PARTICLE_DATA: | 4232 | case PACKET_TYPE_VOXEL_ERASE: |
| 4404 | case PACKET_TYPE_VOXEL_DATA: | 4233 | case PACKET_TYPE_OCTREE_STATS: |
| 4405 | case PACKET_TYPE_VOXEL_ERASE: | 4234 | case PACKET_TYPE_ENVIRONMENT_DATA: { |
| 4406 | case PACKET_TYPE_OCTREE_STATS: | 4235 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), |
| 4407 | case PACKET_TYPE_ENVIRONMENT_DATA: { | 4236 | "Application::networkReceive()... _voxelProcessor.queueReceivedPacket()"); |
| 4408 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), | 4237 | |
| 4409 | "Application::networkReceive()... _voxelProcessor.queueReceivedPacket()"); | 4238 | bool wantExtraDebugging = getLogger()->extraDebugging(); |
| 4410 | 4239 | if (wantExtraDebugging && _incomingPacket[0] == PACKET_TYPE_VOXEL_DATA) { | |
| 4411 | bool wantExtraDebugging = app->getLogger()->extraDebugging(); | 4240 | int numBytesPacketHeader = numBytesForPacketHeader(_incomingPacket); |
| 4412 | if (wantExtraDebugging && app->_incomingPacket[0] == PACKET_TYPE_VOXEL_DATA) { | 4241 | unsigned char* dataAt = _incomingPacket + numBytesPacketHeader; |
| 4413 | int numBytesPacketHeader = numBytesForPacketHeader(app->_incomingPacket); | 4242 | dataAt += sizeof(VOXEL_PACKET_FLAGS); |
| 4414 | unsigned char* dataAt = app->_incomingPacket + numBytesPacketHeader; | 4243 | VOXEL_PACKET_SEQUENCE sequence = (*(VOXEL_PACKET_SEQUENCE*)dataAt); |
| 4415 | dataAt += sizeof(VOXEL_PACKET_FLAGS); | 4244 | dataAt += sizeof(VOXEL_PACKET_SEQUENCE); |
| 4416 | VOXEL_PACKET_SEQUENCE sequence = (*(VOXEL_PACKET_SEQUENCE*)dataAt); | 4245 | VOXEL_PACKET_SENT_TIME sentAt = (*(VOXEL_PACKET_SENT_TIME*)dataAt); |
| 4417 | dataAt += sizeof(VOXEL_PACKET_SEQUENCE); | 4246 | dataAt += sizeof(VOXEL_PACKET_SENT_TIME); |
| 4418 | VOXEL_PACKET_SENT_TIME sentAt = (*(VOXEL_PACKET_SENT_TIME*)dataAt); | 4247 | VOXEL_PACKET_SENT_TIME arrivedAt = usecTimestampNow(); |
| 4419 | dataAt += sizeof(VOXEL_PACKET_SENT_TIME); | 4248 | int flightTime = arrivedAt - sentAt; |
| 4420 | VOXEL_PACKET_SENT_TIME arrivedAt = usecTimestampNow(); | 4249 | |
| 4421 | int flightTime = arrivedAt - sentAt; | 4250 | printf("got PACKET_TYPE_VOXEL_DATA, sequence:%d flightTime:%d\n", sequence, flightTime); |
| 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; | ||
| 4429 | } | 4251 | } |
| 4430 | case PACKET_TYPE_BULK_AVATAR_DATA: | 4252 | |
| 4431 | NodeList::getInstance()->processBulkNodeData(senderSockAddr, | 4253 | // add this packet to our list of voxel packets and process them on the voxel processing |
| 4432 | app->_incomingPacket, | 4254 | _voxelProcessor.queueReceivedPacket(senderSockAddr, _incomingPacket, bytesReceived); |
| 4433 | bytesReceived); | 4255 | break; |
| 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; | ||
| 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 | void Application::packetSentNotification(ssize_t length) { | 4287 | void Application::packetSentNotification(ssize_t length) { |
| @@ -4475,14 +4298,12 @@ void Application::loadScript() { · 10 unmodified lines | |||
| 4475 | QByteArray fileNameAscii = fileNameString.toLocal8Bit(); | 4298 | QByteArray fileNameAscii = fileNameString.toLocal8Bit(); |
| 4476 | const char* fileName = fileNameAscii.data(); | 4299 | const char* fileName = fileNameAscii.data(); |
| 4477 | 4300 | ||
| 4478 | printf("fileName:%s\n",fileName); | ||
| 4479 | |||
| 4480 | std::ifstream file(fileName, std::ios::in|std::ios::binary|std::ios::ate); | 4301 | std::ifstream file(fileName, std::ios::in|std::ios::binary|std::ios::ate); |
| 4481 | if(!file.is_open()) { | 4302 | if(!file.is_open()) { |
| 4482 | printf("error loading file\n"); | 4303 | qDebug("Error loading file %s", fileName); |
| 4483 | return; | 4304 | return; |
| 4484 | } | 4305 | } |
| 4485 | qDebug("loading file %s...\n", fileName); | 4306 | qDebug("Loading file %s...", fileName); |
| 4486 | 4307 | ||
| 4487 | // get file length.... | 4308 | // get file length.... |
| 4488 | unsigned long fileLength = file.tellg(); | 4309 | unsigned long fileLength = file.tellg(); |
| @@ -4539,3 +4360,47 @@ void Application::toggleLogDialog() { · 50 unmodified lines | |||
| 4539 | _logDialog->close(); | 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 | } | ||