- resolve conflicts on GeometryCache
Showing the changes to interface/src/Application.cpp (1 of 64 files). Show all
Unified · Split
| @@ -108,6 +108,8 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 107 unmodified lines | |||
| 108 | QApplication(argc, argv), | 108 | QApplication(argc, argv), |
| 109 | _window(new QMainWindow(desktop())), | 109 | _window(new QMainWindow(desktop())), |
| 110 | _glWidget(new GLCanvas()), | 110 | _glWidget(new GLCanvas()), |
| 111 | _nodeThread(new QThread(this)), | ||
| 112 | _datagramProcessor(), | ||
| 111 | _frameCount(0), | 113 | _frameCount(0), |
| 112 | _fps(120.0f), | 114 | _fps(120.0f), |
| 113 | _justStarted(true), | 115 | _justStarted(true), |
| @@ -143,12 +145,8 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 29 unmodified lines | |||
| 143 | _enableProcessVoxelsThread(true), | 145 | _enableProcessVoxelsThread(true), |
| 144 | _voxelProcessor(), | 146 | _voxelProcessor(), |
| 145 | _voxelHideShowThread(&_voxels), | 147 | _voxelHideShowThread(&_voxels), |
| 146 | _voxelEditSender(this), | ||
| 147 | _particleEditSender(this), | ||
| 148 | _packetCount(0), | ||
| 149 | _packetsPerSecond(0), | 148 | _packetsPerSecond(0), |
| 150 | _bytesPerSecond(0), | 149 | _bytesPerSecond(0), |
| 151 | _bytesCount(0), | ||
| 152 | _recentMaxPackets(0), | 150 | _recentMaxPackets(0), |
| 153 | _resetRecentMaxPacketsSoon(true), | 151 | _resetRecentMaxPacketsSoon(true), |
| 154 | _swatch(NULL), | 152 | _swatch(NULL), |
| @@ -173,11 +171,21 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 18 unmodified lines | |||
| 173 | if (portStr) { | 171 | if (portStr) { |
| 174 | listenPort = atoi(portStr); | 172 | listenPort = atoi(portStr); |
| 175 | } | 173 | } |
| 176 | 174 | ||
| 175 | // start the nodeThread so its event loop is running | ||
| 176 | _nodeThread->start(); | ||
| 177 | |||
| 178 | // make sure the node thread is given highest priority | ||
| 179 | _nodeThread->setPriority(QThread::TimeCriticalPriority); | ||
| 180 | |||
| 181 | // put the NodeList and datagram processing on the node thread | ||
| 177 | NodeList* nodeList = NodeList::createInstance(NODE_TYPE_AGENT, listenPort); | 182 | NodeList* nodeList = NodeList::createInstance(NODE_TYPE_AGENT, listenPort); |
| 178 | 183 | ||
| 179 | // connect our processDatagrams slot to the QUDPSocket readyRead() signal | 184 | nodeList->moveToThread(_nodeThread); |
| 180 | connect(&nodeList->getNodeSocket(), SIGNAL(readyRead()), SLOT(processDatagrams())); | 185 | _datagramProcessor.moveToThread(_nodeThread); |
| 186 | |||
| 187 | // connect the DataProcessor processDatagrams slot to the QUDPSocket readyRead() signal | ||
| 188 | connect(&nodeList->getNodeSocket(), SIGNAL(readyRead()), &_datagramProcessor, SLOT(processDatagrams())); | ||
| 181 | 189 | ||
| 182 | // put the audio processing on a separate thread | 190 | // put the audio processing on a separate thread |
| 183 | QThread* audioThread = new QThread(this); | 191 | QThread* audioThread = new QThread(this); |
| @@ -192,7 +200,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 8 unmodified lines | |||
| 192 | connect(nodeList, SIGNAL(nodeKilled(SharedNodePointer)), SLOT(nodeKilled(SharedNodePointer))); | 200 | connect(nodeList, SIGNAL(nodeKilled(SharedNodePointer)), SLOT(nodeKilled(SharedNodePointer))); |
| 193 | connect(nodeList, SIGNAL(nodeAdded(SharedNodePointer)), &_voxels, SLOT(nodeAdded(SharedNodePointer))); | 201 | connect(nodeList, SIGNAL(nodeAdded(SharedNodePointer)), &_voxels, SLOT(nodeAdded(SharedNodePointer))); |
| 194 | connect(nodeList, SIGNAL(nodeKilled(SharedNodePointer)), &_voxels, SLOT(nodeKilled(SharedNodePointer))); | 202 | connect(nodeList, SIGNAL(nodeKilled(SharedNodePointer)), &_voxels, SLOT(nodeKilled(SharedNodePointer))); |
| 195 | 203 | ||
| 196 | // read the ApplicationInfo.ini file for Name/Version/Domain information | 204 | // read the ApplicationInfo.ini file for Name/Version/Domain information |
| 197 | QSettings applicationInfo("resources/info/ApplicationInfo.ini", QSettings::IniFormat); | 205 | QSettings applicationInfo("resources/info/ApplicationInfo.ini", QSettings::IniFormat); |
| 198 | 206 | ||
| @@ -221,12 +229,18 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 22 unmodified lines | |||
| 221 | #endif | 229 | #endif |
| 222 | 230 | ||
| 223 | // tell the NodeList instance who to tell the domain server we care about | 231 | // tell the NodeList instance who to tell the domain server we care about |
| 224 | const char nodeTypesOfInterest[] = {NODE_TYPE_AUDIO_MIXER, NODE_TYPE_AVATAR_MIXER, NODE_TYPE_VOXEL_SERVER, | 232 | nodeList->addSetOfNodeTypesToNodeInterestSet(QSet<NODE_TYPE>() << NODE_TYPE_AUDIO_MIXER << NODE_TYPE_AVATAR_MIXER |
| 225 | NODE_TYPE_PARTICLE_SERVER, NODE_TYPE_METAVOXEL_SERVER}; | 233 | << NODE_TYPE_VOXEL_SERVER << NODE_TYPE_PARTICLE_SERVER |
| 226 | nodeList->setNodeTypesOfInterest(nodeTypesOfInterest, sizeof(nodeTypesOfInterest)); | 234 | << NODE_TYPE_METAVOXEL_SERVER); |
| 235 | |||
| 236 | // connect to the packet sent signal of the _voxelEditSender and the _particleEditSender | ||
| 237 | connect(&_voxelEditSender, &VoxelEditPacketSender::packetSent, this, &Application::packetSent); | ||
| 238 | connect(&_particleEditSender, &ParticleEditPacketSender::packetSent, this, &Application::packetSent); | ||
| 227 | 239 | ||
| 228 | QTimer* silentNodeTimer = new QTimer(this); | 240 | // move the silentNodeTimer to the _nodeThread |
| 241 | QTimer* silentNodeTimer = new QTimer(); | ||
| 229 | connect(silentNodeTimer, SIGNAL(timeout()), nodeList, SLOT(removeSilentNodes())); | 242 | connect(silentNodeTimer, SIGNAL(timeout()), nodeList, SLOT(removeSilentNodes())); |
| 243 | silentNodeTimer->moveToThread(_nodeThread); | ||
| 230 | silentNodeTimer->start(NODE_SILENCE_THRESHOLD_USECS / 1000); | 244 | silentNodeTimer->start(NODE_SILENCE_THRESHOLD_USECS / 1000); |
| 231 | 245 | ||
| 232 | QString cachePath = QStandardPaths::writableLocation(QStandardPaths::DataLocation); | 246 | QString cachePath = QStandardPaths::writableLocation(QStandardPaths::DataLocation); |
| @@ -270,13 +284,35 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 37 unmodified lines | |||
| 270 | Application::~Application() { | 284 | Application::~Application() { |
| 271 | 285 | ||
| 272 | qInstallMessageHandler(NULL); | 286 | qInstallMessageHandler(NULL); |
| 273 | 287 | ||
| 274 | // make sure we don't call the idle timer any more | 288 | // make sure we don't call the idle timer any more |
| 275 | delete idleTimer; | 289 | delete idleTimer; |
| 276 | 290 | ||
| 291 | Menu::getInstance()->saveSettings(); | ||
| 292 | |||
| 293 | _rearMirrorTools->saveSettings(_settings); | ||
| 294 | _settings->sync(); | ||
| 295 | |||
| 296 | // let the avatar mixer know we're out | ||
| 297 | NodeList::getInstance()->sendKillNode(QSet<NODE_TYPE>() << NODE_TYPE_AVATAR_MIXER); | ||
| 298 | |||
| 299 | // ask the datagram processing thread to quit and wait until it is done | ||
| 300 | _nodeThread->quit(); | ||
| 301 | _nodeThread->wait(); | ||
| 302 | |||
| 277 | // ask the audio thread to quit and wait until it is done | 303 | // ask the audio thread to quit and wait until it is done |
| 278 | _audio.thread()->quit(); | 304 | _audio.thread()->quit(); |
| 279 | _audio.thread()->wait(); | 305 | _audio.thread()->wait(); |
| 306 | |||
| 307 | _voxelProcessor.terminate(); | ||
| 308 | _voxelHideShowThread.terminate(); | ||
| 309 | _voxelEditSender.terminate(); | ||
| 310 | _particleEditSender.terminate(); | ||
| 311 | if (_persistThread) { | ||
| 312 | _persistThread->terminate(); | ||
| 313 | _persistThread->deleteLater(); | ||
| 314 | _persistThread = NULL; | ||
| 315 | } | ||
| 280 | 316 | ||
| 281 | storeSizeAndPosition(); | 317 | storeSizeAndPosition(); |
| 282 | saveScripts(); | 318 | saveScripts(); |
| @@ -361,9 +397,6 @@ void Application::initializeGL() { · 78 unmodified lines | |||
| 361 | qDebug("Voxel parsing thread created."); | 397 | qDebug("Voxel parsing thread created."); |
| 362 | } | 398 | } |
| 363 | 399 | ||
| 364 | // call terminate before exiting | ||
| 365 | connect(this, SIGNAL(aboutToQuit()), SLOT(terminate())); | ||
| 366 | |||
| 367 | // call our timer function every second | 400 | // call our timer function every second |
| 368 | QTimer* timer = new QTimer(this); | 401 | QTimer* timer = new QTimer(this); |
| 369 | connect(timer, SIGNAL(timeout()), SLOT(timer())); | 402 | connect(timer, SIGNAL(timeout()), SLOT(timer())); |
| @@ -612,21 +645,20 @@ void Application::resetProfile(const QString& username) { · 242 unmodified lines | |||
| 612 | } | 645 | } |
| 613 | 646 | ||
| 614 | void Application::controlledBroadcastToNodes(unsigned char* broadcastData, size_t dataBytes, | 647 | void Application::controlledBroadcastToNodes(unsigned char* broadcastData, size_t dataBytes, |
| 615 | const char* nodeTypes, int numNodeTypes) { | 648 | const QSet<NODE_TYPE>& destinationNodeTypes) { |
| 616 | Application* self = getInstance(); | 649 | foreach(NODE_TYPE type, destinationNodeTypes) { |
| 617 | for (int i = 0; i < numNodeTypes; ++i) { | ||
| 618 | |||
| 619 | // Intercept data to voxel server when voxels are disabled | 650 | // Intercept data to voxel server when voxels are disabled |
| 620 | if (nodeTypes[i] == NODE_TYPE_VOXEL_SERVER && !Menu::getInstance()->isOptionChecked(MenuOption::Voxels)) { | 651 | if (type == NODE_TYPE_VOXEL_SERVER && !Menu::getInstance()->isOptionChecked(MenuOption::Voxels)) { |
| 621 | continue; | 652 | continue; |
| 622 | } | 653 | } |
| 623 | 654 | ||
| 624 | // Perform the broadcast for one type | 655 | // Perform the broadcast for one type |
| 625 | int nReceivingNodes = NodeList::getInstance()->broadcastToNodes(broadcastData, dataBytes, & nodeTypes[i], 1); | 656 | int nReceivingNodes = NodeList::getInstance()->broadcastToNodes(broadcastData, dataBytes, |
| 626 | 657 | QSet<NODE_TYPE>() << type); | |
| 658 | |||
| 627 | // Feed number of bytes to corresponding channel of the bandwidth meter, if any (done otherwise) | 659 | // Feed number of bytes to corresponding channel of the bandwidth meter, if any (done otherwise) |
| 628 | BandwidthMeter::ChannelIndex channel; | 660 | BandwidthMeter::ChannelIndex channel; |
| 629 | switch (nodeTypes[i]) { | 661 | switch (type) { |
| 630 | case NODE_TYPE_AGENT: | 662 | case NODE_TYPE_AGENT: |
| 631 | case NODE_TYPE_AVATAR_MIXER: | 663 | case NODE_TYPE_AVATAR_MIXER: |
| 632 | channel = BandwidthMeter::AVATARS; | 664 | channel = BandwidthMeter::AVATARS; |
| @@ -637,7 +669,7 @@ void Application::controlledBroadcastToNodes(unsigned char* broadcastData, size_ · 4 unmodified lines | |||
| 637 | default: | 669 | default: |
| 638 | continue; | 670 | continue; |
| 639 | } | 671 | } |
| 640 | self->_bandwidthMeter.outputStream(channel).updateValue(nReceivingNodes * dataBytes); | 672 | _bandwidthMeter.outputStream(channel).updateValue(nReceivingNodes * dataBytes); |
| 641 | } | 673 | } |
| 642 | } | 674 | } |
| 643 | 675 | ||
| @@ -1120,13 +1152,12 @@ void Application::mouseMoveEvent(QMouseEvent* event) { · 476 unmodified lines | |||
| 1120 | _seenMouseMove = true; | 1152 | _seenMouseMove = true; |
| 1121 | } | 1153 | } |
| 1122 | 1154 | ||
| 1155 | int deltaX = event->x() - _mouseX; | ||
| 1156 | int deltaY = event->y() - _mouseY; | ||
| 1157 | _mouseX = event->x(); | ||
| 1158 | _mouseY = event->y(); | ||
| 1159 | |||
| 1123 | if (activeWindow() == _window) { | 1160 | if (activeWindow() == _window) { |
| 1124 | int deltaX = event->x() - _mouseX; | ||
| 1125 | int deltaY = event->y() - _mouseY; | ||
| 1126 | |||
| 1127 | _mouseX = event->x(); | ||
| 1128 | _mouseY = event->y(); | ||
| 1129 | |||
| 1130 | // orbit behavior | 1161 | // orbit behavior |
| 1131 | if (_mousePressed && !Menu::getInstance()->isVoxelModeActionChecked()) { | 1162 | if (_mousePressed && !Menu::getInstance()->isVoxelModeActionChecked()) { |
| 1132 | if (_lookatTargetAvatar) { | 1163 | if (_lookatTargetAvatar) { |
| @@ -1292,15 +1323,13 @@ void Application::wheelEvent(QWheelEvent* event) { · 159 unmodified lines | |||
| 1292 | } | 1323 | } |
| 1293 | 1324 | ||
| 1294 | void Application::sendPingPackets() { | 1325 | void Application::sendPingPackets() { |
| 1295 | |||
| 1296 | const char nodesToPing[] = {NODE_TYPE_VOXEL_SERVER, NODE_TYPE_PARTICLE_SERVER, | ||
| 1297 | NODE_TYPE_AUDIO_MIXER, NODE_TYPE_AVATAR_MIXER, NODE_TYPE_METAVOXEL_SERVER}; | ||
| 1298 | |||
| 1299 | unsigned char pingPacket[MAX_PACKET_SIZE]; | 1326 | unsigned char pingPacket[MAX_PACKET_SIZE]; |
| 1300 | int length = NodeList::getInstance()->fillPingPacket(pingPacket); | 1327 | int length = NodeList::getInstance()->fillPingPacket(pingPacket); |
| 1301 | 1328 | ||
| 1302 | getInstance()->controlledBroadcastToNodes(pingPacket, length, | 1329 | getInstance()->controlledBroadcastToNodes(pingPacket, length, QSet<NODE_TYPE>() |
| 1303 | nodesToPing, sizeof(nodesToPing)); | 1330 | << NODE_TYPE_VOXEL_SERVER << NODE_TYPE_PARTICLE_SERVER |
| 1331 | << NODE_TYPE_AUDIO_MIXER << NODE_TYPE_AVATAR_MIXER | ||
| 1332 | << NODE_TYPE_METAVOXEL_SERVER); | ||
| 1304 | } | 1333 | } |
| 1305 | 1334 | ||
| 1306 | // Every second, check the frame rates and other stuff | 1335 | // Every second, check the frame rates and other stuff |
| @@ -1312,11 +1341,12 @@ void Application::timer() { · 5 unmodified lines | |||
| 1312 | } | 1341 | } |
| 1313 | 1342 | ||
| 1314 | _fps = (float)_frameCount / ((float)diffclock(&_timerStart, &_timerEnd) / 1000.f); | 1343 | _fps = (float)_frameCount / ((float)diffclock(&_timerStart, &_timerEnd) / 1000.f); |
| 1315 | _packetsPerSecond = (float)_packetCount / ((float)diffclock(&_timerStart, &_timerEnd) / 1000.f); | 1344 | |
| 1316 | _bytesPerSecond = (float)_bytesCount / ((float)diffclock(&_timerStart, &_timerEnd) / 1000.f); | 1345 | _packetsPerSecond = (float) _datagramProcessor.getPacketCount() / ((float)diffclock(&_timerStart, &_timerEnd) / 1000.f); |
| 1346 | _bytesPerSecond = (float) _datagramProcessor.getByteCount() / ((float)diffclock(&_timerStart, &_timerEnd) / 1000.f); | ||
| 1317 | _frameCount = 0; | 1347 | _frameCount = 0; |
| 1318 | _packetCount = 0; | 1348 | |
| 1319 | _bytesCount = 0; | 1349 | _datagramProcessor.resetCounters(); |
| 1320 | 1350 | ||
| 1321 | gettimeofday(&_timerStart, NULL); | 1351 | gettimeofday(&_timerStart, NULL); |
| 1322 | 1352 | ||
| @@ -1395,28 +1425,6 @@ void Application::idle() { · 72 unmodified lines | |||
| 1395 | } | 1425 | } |
| 1396 | } | 1426 | } |
| 1397 | 1427 | ||
| 1398 | void Application::terminate() { | ||
| 1399 | // Close serial port | ||
| 1400 | // close(serial_fd); | ||
| 1401 | |||
| 1402 | Menu::getInstance()->saveSettings(); | ||
| 1403 | _rearMirrorTools->saveSettings(_settings); | ||
| 1404 | _settings->sync(); | ||
| 1405 | |||
| 1406 | // let the avatar mixer know we're out | ||
| 1407 | NodeList::getInstance()->sendKillNode(&NODE_TYPE_AVATAR_MIXER, 1); | ||
| 1408 | |||
| 1409 | _voxelProcessor.terminate(); | ||
| 1410 | _voxelHideShowThread.terminate(); | ||
| 1411 | _voxelEditSender.terminate(); | ||
| 1412 | _particleEditSender.terminate(); | ||
| 1413 | if (_persistThread) { | ||
| 1414 | _persistThread->terminate(); | ||
| 1415 | _persistThread->deleteLater(); | ||
| 1416 | _persistThread = NULL; | ||
| 1417 | } | ||
| 1418 | } | ||
| 1419 | |||
| 1420 | void Application::checkBandwidthMeterClick() { | 1428 | void Application::checkBandwidthMeterClick() { |
| 1421 | // ... to be called upon button release | 1429 | // ... to be called upon button release |
| 1422 | 1430 | ||
| @@ -1840,25 +1848,23 @@ const float HEAD_SPHERE_RADIUS = 0.07f; · 417 unmodified lines | |||
| 1840 | 1848 | ||
| 1841 | static QUuid DEFAULT_NODE_ID_REF; | 1849 | static QUuid DEFAULT_NODE_ID_REF; |
| 1842 | 1850 | ||
| 1843 | void Application::updateLookatTargetAvatar(const glm::vec3& mouseRayOrigin, const glm::vec3& mouseRayDirection, | 1851 | void Application::updateLookatTargetAvatar(glm::vec3& eyePosition) { |
| 1844 | glm::vec3& eyePosition) { | ||
| 1845 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); | 1852 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); |
| 1846 | PerformanceWarning warn(showWarnings, "Application::updateLookatTargetAvatar()"); | 1853 | PerformanceWarning warn(showWarnings, "Application::updateLookatTargetAvatar()"); |
| 1847 | 1854 | ||
| 1848 | if (!_mousePressed) { | 1855 | if (!_mousePressed) { |
| 1849 | _lookatTargetAvatar = findLookatTargetAvatar(mouseRayOrigin, mouseRayDirection, eyePosition, DEFAULT_NODE_ID_REF); | 1856 | _lookatTargetAvatar = findLookatTargetAvatar(eyePosition, DEFAULT_NODE_ID_REF); |
| 1850 | } | 1857 | } |
| 1851 | } | 1858 | } |
| 1852 | 1859 | ||
| 1853 | Avatar* Application::findLookatTargetAvatar(const glm::vec3& mouseRayOrigin, const glm::vec3& mouseRayDirection, | 1860 | Avatar* Application::findLookatTargetAvatar(glm::vec3& eyePosition, QUuid& nodeUUID = DEFAULT_NODE_ID_REF) { |
| 1854 | glm::vec3& eyePosition, QUuid& nodeUUID = DEFAULT_NODE_ID_REF) { | ||
| 1855 | 1861 | ||
| 1856 | foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) { | 1862 | foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) { |
| 1857 | if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) { | 1863 | if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) { |
| 1858 | Avatar* avatar = (Avatar*)node->getLinkedData(); | 1864 | Avatar* avatar = (Avatar*)node->getLinkedData(); |
| 1859 | float distance; | 1865 | float distance; |
| 1860 | 1866 | ||
| 1861 | if (avatar->findRayIntersection(mouseRayOrigin, mouseRayDirection, distance)) { | 1867 | if (avatar->findRayIntersection(_mouseRayOrigin, _mouseRayDirection, distance)) { |
| 1862 | // rescale to compensate for head embiggening | 1868 | // rescale to compensate for head embiggening |
| 1863 | eyePosition = (avatar->getHead().calculateAverageEyePosition() - avatar->getHead().getScalePivot()) * | 1869 | eyePosition = (avatar->getHead().calculateAverageEyePosition() - avatar->getHead().getScalePivot()) * |
| 1864 | (avatar->getScale() / avatar->getHead().getScale()) + avatar->getHead().getScalePivot(); | 1870 | (avatar->getScale() / avatar->getHead().getScale()) + avatar->getHead().getScalePivot(); |
| @@ -1909,7 +1915,7 @@ void Application::renderHighlightVoxel(VoxelDetail voxel) { · 44 unmodified lines | |||
| 1909 | glPopMatrix(); | 1915 | glPopMatrix(); |
| 1910 | } | 1916 | } |
| 1911 | 1917 | ||
| 1912 | void Application::updateAvatars(float deltaTime, glm::vec3 mouseRayOrigin, glm::vec3 mouseRayDirection) { | 1918 | void Application::updateAvatars(float deltaTime) { |
| 1913 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); | 1919 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); |
| 1914 | PerformanceWarning warn(showWarnings, "Application::updateAvatars()"); | 1920 | PerformanceWarning warn(showWarnings, "Application::updateAvatars()"); |
| 1915 | 1921 | ||
| @@ -1921,7 +1927,7 @@ void Application::updateAvatars(float deltaTime, glm::vec3 mouseRayOrigin, glm:: · 5 unmodified lines | |||
| 1921 | avatar->init(); | 1927 | avatar->init(); |
| 1922 | } | 1928 | } |
| 1923 | avatar->simulate(deltaTime, NULL); | 1929 | avatar->simulate(deltaTime, NULL); |
| 1924 | avatar->setMouseRay(mouseRayOrigin, mouseRayDirection); | 1930 | avatar->setMouseRay(_mouseRayOrigin, _mouseRayDirection); |
| 1925 | } | 1931 | } |
| 1926 | } | 1932 | } |
| 1927 | 1933 | ||
| @@ -1944,28 +1950,28 @@ void Application::updateAvatars(float deltaTime, glm::vec3 mouseRayOrigin, glm:: · 16 unmodified lines | |||
| 1944 | } | 1950 | } |
| 1945 | } | 1951 | } |
| 1946 | 1952 | ||
| 1947 | void Application::updateMouseRay(float deltaTime, glm::vec3& mouseRayOrigin, glm::vec3& mouseRayDirection) { | 1953 | void Application::updateMouseRay() { |
| 1948 | 1954 | ||
| 1949 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); | 1955 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); |
| 1950 | PerformanceWarning warn(showWarnings, "Application::updateMouseRay()"); | 1956 | PerformanceWarning warn(showWarnings, "Application::updateMouseRay()"); |
| 1951 | 1957 | ||
| 1952 | _viewFrustum.computePickRay(_mouseX / (float)_glWidget->width(), _mouseY / (float)_glWidget->height(), | 1958 | _viewFrustum.computePickRay(_mouseX / (float)_glWidget->width(), _mouseY / (float)_glWidget->height(), |
| 1953 | mouseRayOrigin, mouseRayDirection); | 1959 | _mouseRayOrigin, _mouseRayDirection); |
| 1954 | 1960 | ||
| 1955 | // adjust for mirroring | 1961 | // adjust for mirroring |
| 1956 | if (_myCamera.getMode() == CAMERA_MODE_MIRROR) { | 1962 | if (_myCamera.getMode() == CAMERA_MODE_MIRROR) { |
| 1957 | glm::vec3 mouseRayOffset = mouseRayOrigin - _viewFrustum.getPosition(); | 1963 | glm::vec3 mouseRayOffset = _mouseRayOrigin - _viewFrustum.getPosition(); |
| 1958 | mouseRayOrigin -= 2.0f * (_viewFrustum.getDirection() * glm::dot(_viewFrustum.getDirection(), mouseRayOffset) + | 1964 | _mouseRayOrigin -= 2.0f * (_viewFrustum.getDirection() * glm::dot(_viewFrustum.getDirection(), mouseRayOffset) + |
| 1959 | _viewFrustum.getRight() * glm::dot(_viewFrustum.getRight(), mouseRayOffset)); | 1965 | _viewFrustum.getRight() * glm::dot(_viewFrustum.getRight(), mouseRayOffset)); |
| 1960 | mouseRayDirection -= 2.0f * (_viewFrustum.getDirection() * glm::dot(_viewFrustum.getDirection(), mouseRayDirection) + | 1966 | _mouseRayDirection -= 2.0f * (_viewFrustum.getDirection() * glm::dot(_viewFrustum.getDirection(), _mouseRayDirection) + |
| 1961 | _viewFrustum.getRight() * glm::dot(_viewFrustum.getRight(), mouseRayDirection)); | 1967 | _viewFrustum.getRight() * glm::dot(_viewFrustum.getRight(), _mouseRayDirection)); |
| 1962 | } | 1968 | } |
| 1963 | 1969 | ||
| 1964 | // tell my avatar if the mouse is being pressed... | 1970 | // tell my avatar if the mouse is being pressed... |
| 1965 | _myAvatar.setMousePressed(_mousePressed); | 1971 | _myAvatar.setMousePressed(_mousePressed); |
| 1966 | 1972 | ||
| 1967 | // tell my avatar the posiion and direction of the ray projected ino the world based on the mouse position | 1973 | // tell my avatar the posiion and direction of the ray projected ino the world based on the mouse position |
| 1968 | _myAvatar.setMouseRay(mouseRayOrigin, mouseRayDirection); | 1974 | _myAvatar.setMouseRay(_mouseRayOrigin, _mouseRayDirection); |
| 1969 | } | 1975 | } |
| 1970 | 1976 | ||
| 1971 | void Application::updateFaceshift() { | 1977 | void Application::updateFaceshift() { |
| @@ -1982,8 +1988,7 @@ void Application::updateFaceshift() { · 10 unmodified lines | |||
| 1982 | } | 1988 | } |
| 1983 | } | 1989 | } |
| 1984 | 1990 | ||
| 1985 | void Application::updateMyAvatarLookAtPosition(glm::vec3& lookAtSpot, glm::vec3& lookAtRayOrigin, | 1991 | void Application::updateMyAvatarLookAtPosition(glm::vec3& lookAtSpot) { |
| 1986 | glm::vec3& lookAtRayDirection) { | ||
| 1987 | 1992 | ||
| 1988 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); | 1993 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); |
| 1989 | PerformanceWarning warn(showWarnings, "Application::updateMyAvatarLookAtPosition()"); | 1994 | PerformanceWarning warn(showWarnings, "Application::updateMyAvatarLookAtPosition()"); |
| @@ -1998,15 +2003,9 @@ void Application::updateMyAvatarLookAtPosition(glm::vec3& lookAtSpot, glm::vec3& · 8 unmodified lines | |||
| 1998 | _viewFrustum.computePickRay(0.5f, 0.5f, rayOrigin, rayDirection); | 2003 | _viewFrustum.computePickRay(0.5f, 0.5f, rayOrigin, rayDirection); |
| 1999 | lookAtSpot = rayOrigin + rayDirection * FAR_AWAY_STARE; | 2004 | lookAtSpot = rayOrigin + rayDirection * FAR_AWAY_STARE; |
| 2000 | 2005 | ||
| 2001 | } else if (!_lookatTargetAvatar) { | 2006 | } else { |
| 2002 | if (_isHoverVoxel) { | 2007 | // just look in direction of the mouse ray |
| 2003 | // Look at the hovered voxel | 2008 | lookAtSpot = _mouseRayOrigin + _mouseRayDirection * FAR_AWAY_STARE; |
| 2004 | lookAtSpot = getMouseVoxelWorldCoordinates(_hoverVoxel); | ||
| 2005 | |||
| 2006 | } else { | ||
| 2007 | // Just look in direction of the mouse ray | ||
| 2008 | lookAtSpot = lookAtRayOrigin + lookAtRayDirection * FAR_AWAY_STARE; | ||
| 2009 | } | ||
| 2010 | } | 2009 | } |
| 2011 | if (_faceshift.isActive()) { | 2010 | if (_faceshift.isActive()) { |
| 2012 | // deflect using Faceshift gaze data | 2011 | // deflect using Faceshift gaze data |
| @@ -2020,8 +2019,7 @@ void Application::updateMyAvatarLookAtPosition(glm::vec3& lookAtSpot, glm::vec3& · 7 unmodified lines | |||
| 2020 | _myAvatar.getHead().setLookAtPosition(lookAtSpot); | 2019 | _myAvatar.getHead().setLookAtPosition(lookAtSpot); |
| 2021 | } | 2020 | } |
| 2022 | 2021 | ||
| 2023 | void Application::updateHoverVoxels(float deltaTime, glm::vec3& mouseRayOrigin, glm::vec3& mouseRayDirection, | 2022 | void Application::updateHoverVoxels(float deltaTime, float& distance, BoxFace& face) { |
| 2024 | float& distance, BoxFace& face) { | ||
| 2025 | 2023 | ||
| 2026 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); | 2024 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); |
| 2027 | PerformanceWarning warn(showWarnings, "Application::updateHoverVoxels()"); | 2025 | PerformanceWarning warn(showWarnings, "Application::updateHoverVoxels()"); |
| @@ -2052,7 +2050,7 @@ void Application::updateHoverVoxels(float deltaTime, glm::vec3& mouseRayOrigin, · 24 unmodified lines | |||
| 2052 | if (!(_voxels.treeIsBusy() || _mousePressed)) { | 2050 | if (!(_voxels.treeIsBusy() || _mousePressed)) { |
| 2053 | { | 2051 | { |
| 2054 | PerformanceWarning warn(showWarnings, "Application::updateHoverVoxels() _voxels.findRayIntersection()"); | 2052 | PerformanceWarning warn(showWarnings, "Application::updateHoverVoxels() _voxels.findRayIntersection()"); |
| 2055 | _isHoverVoxel = _voxels.findRayIntersection(mouseRayOrigin, mouseRayDirection, _hoverVoxel, distance, face); | 2053 | _isHoverVoxel = _voxels.findRayIntersection(_mouseRayOrigin, _mouseRayDirection, _hoverVoxel, distance, face); |
| 2056 | } | 2054 | } |
| 2057 | if (MAKE_SOUND_ON_VOXEL_HOVER && _isHoverVoxel && | 2055 | if (MAKE_SOUND_ON_VOXEL_HOVER && _isHoverVoxel && |
| 2058 | glm::vec4(_hoverVoxel.x, _hoverVoxel.y, _hoverVoxel.z, _hoverVoxel.s) != oldVoxel) { | 2056 | glm::vec4(_hoverVoxel.x, _hoverVoxel.y, _hoverVoxel.z, _hoverVoxel.s) != oldVoxel) { |
| @@ -2068,8 +2066,7 @@ void Application::updateHoverVoxels(float deltaTime, glm::vec3& mouseRayOrigin, · 9 unmodified lines | |||
| 2068 | } | 2066 | } |
| 2069 | } | 2067 | } |
| 2070 | 2068 | ||
| 2071 | void Application::updateMouseVoxels(float deltaTime, glm::vec3& mouseRayOrigin, glm::vec3& mouseRayDirection, | 2069 | void Application::updateMouseVoxels(float deltaTime, float& distance, BoxFace& face) { |
| 2072 | float& distance, BoxFace& face) { | ||
| 2073 | 2070 | ||
| 2074 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); | 2071 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); |
| 2075 | PerformanceWarning warn(showWarnings, "Application::updateMouseVoxels()"); | 2072 | PerformanceWarning warn(showWarnings, "Application::updateMouseVoxels()"); |
| @@ -2081,7 +2078,7 @@ void Application::updateMouseVoxels(float deltaTime, glm::vec3& mouseRayOrigin, · 5 unmodified lines | |||
| 2081 | fabs(_myAvatar.getVelocity().y) + | 2078 | fabs(_myAvatar.getVelocity().y) + |
| 2082 | fabs(_myAvatar.getVelocity().z)) / 3 < MAX_AVATAR_EDIT_VELOCITY) { | 2079 | fabs(_myAvatar.getVelocity().z)) / 3 < MAX_AVATAR_EDIT_VELOCITY) { |
| 2083 | 2080 | ||
| 2084 | if (_voxels.findRayIntersection(mouseRayOrigin, mouseRayDirection, _mouseVoxel, distance, face)) { | 2081 | if (_voxels.findRayIntersection(_mouseRayOrigin, _mouseRayDirection, _mouseVoxel, distance, face)) { |
| 2085 | if (distance < MAX_VOXEL_EDIT_DISTANCE) { | 2082 | if (distance < MAX_VOXEL_EDIT_DISTANCE) { |
| 2086 | // set the voxel scale to that of the first moused-over voxel | 2083 | // set the voxel scale to that of the first moused-over voxel |
| 2087 | if (!wasInitialized) { | 2084 | if (!wasInitialized) { |
| @@ -2101,7 +2098,7 @@ void Application::updateMouseVoxels(float deltaTime, glm::vec3& mouseRayOrigin, · 13 unmodified lines | |||
| 2101 | glm::vec3 faceVector = getFaceVector(face); | 2098 | glm::vec3 faceVector = getFaceVector(face); |
| 2102 | if (_mouseVoxelScale < _mouseVoxel.s) { | 2099 | if (_mouseVoxelScale < _mouseVoxel.s) { |
| 2103 | // find the closest contained voxel | 2100 | // find the closest contained voxel |
| 2104 | glm::vec3 pt = (mouseRayOrigin + mouseRayDirection * distance) / (float)TREE_SCALE - | 2101 | glm::vec3 pt = (_mouseRayOrigin + _mouseRayDirection * distance) / (float)TREE_SCALE - |
| 2105 | faceVector * (_mouseVoxelScale * 0.5f); | 2102 | faceVector * (_mouseVoxelScale * 0.5f); |
| 2106 | _mouseVoxel.x = _mouseVoxelScale * floorf(pt.x / _mouseVoxelScale); | 2103 | _mouseVoxel.x = _mouseVoxelScale * floorf(pt.x / _mouseVoxelScale); |
| 2107 | _mouseVoxel.y = _mouseVoxelScale * floorf(pt.y / _mouseVoxelScale); | 2104 | _mouseVoxel.y = _mouseVoxelScale * floorf(pt.y / _mouseVoxelScale); |
| @@ -2122,7 +2119,7 @@ void Application::updateMouseVoxels(float deltaTime, glm::vec3& mouseRayOrigin, · 14 unmodified lines | |||
| 2122 | || Menu::getInstance()->isOptionChecked(MenuOption::VoxelSelectMode)) { | 2119 | || Menu::getInstance()->isOptionChecked(MenuOption::VoxelSelectMode)) { |
| 2123 | // place the voxel a fixed distance away | 2120 | // place the voxel a fixed distance away |
| 2124 | float worldMouseVoxelScale = _mouseVoxelScale * TREE_SCALE; | 2121 | float worldMouseVoxelScale = _mouseVoxelScale * TREE_SCALE; |
| 2125 | glm::vec3 pt = mouseRayOrigin + mouseRayDirection * (2.0f + worldMouseVoxelScale * 0.5f); | 2122 | glm::vec3 pt = _mouseRayOrigin + _mouseRayDirection * (2.0f + worldMouseVoxelScale * 0.5f); |
| 2126 | _mouseVoxel.x = _mouseVoxelScale * floorf(pt.x / worldMouseVoxelScale); | 2123 | _mouseVoxel.x = _mouseVoxelScale * floorf(pt.x / worldMouseVoxelScale); |
| 2127 | _mouseVoxel.y = _mouseVoxelScale * floorf(pt.y / worldMouseVoxelScale); | 2124 | _mouseVoxel.y = _mouseVoxelScale * floorf(pt.y / worldMouseVoxelScale); |
| 2128 | _mouseVoxel.z = _mouseVoxelScale * floorf(pt.z / worldMouseVoxelScale); | 2125 | _mouseVoxel.z = _mouseVoxelScale * floorf(pt.z / worldMouseVoxelScale); |
| @@ -2356,29 +2353,28 @@ void Application::update(float deltaTime) { · 227 unmodified lines | |||
| 2356 | PerformanceWarning warn(showWarnings, "Application::update()"); | 2353 | PerformanceWarning warn(showWarnings, "Application::update()"); |
| 2357 | 2354 | ||
| 2358 | // check what's under the mouse and update the mouse voxel | 2355 | // check what's under the mouse and update the mouse voxel |
| 2359 | glm::vec3 mouseRayOrigin, mouseRayDirection; | 2356 | updateMouseRay(); |
| 2360 | updateMouseRay(deltaTime, mouseRayOrigin, mouseRayDirection); | ||
| 2361 | 2357 | ||
| 2362 | // Set where I am looking based on my mouse ray (so that other people can see) | 2358 | // Set where I am looking based on my mouse ray (so that other people can see) |
| 2363 | glm::vec3 lookAtSpot; | 2359 | glm::vec3 lookAtSpot; |
| 2364 | 2360 | ||
| 2365 | updateFaceshift(); | 2361 | updateFaceshift(); |
| 2366 | updateLookatTargetAvatar(mouseRayOrigin, mouseRayDirection, lookAtSpot); | 2362 | updateLookatTargetAvatar(lookAtSpot); |
| 2367 | updateMyAvatarLookAtPosition(lookAtSpot, mouseRayOrigin, mouseRayDirection); | 2363 | updateMyAvatarLookAtPosition(lookAtSpot); |
| 2368 | 2364 | ||
| 2369 | // Find the voxel we are hovering over, and respond if clicked | 2365 | // Find the voxel we are hovering over, and respond if clicked |
| 2370 | float distance; | 2366 | float distance; |
| 2371 | BoxFace face; | 2367 | BoxFace face; |
| 2372 | 2368 | ||
| 2373 | updateHoverVoxels(deltaTime, mouseRayOrigin, mouseRayDirection, distance, face); // clicking on voxels and making sounds | 2369 | updateHoverVoxels(deltaTime, distance, face); // clicking on voxels and making sounds |
| 2374 | updateMouseVoxels(deltaTime, mouseRayOrigin, mouseRayDirection, distance, face); // UI/UX related to voxels | 2370 | updateMouseVoxels(deltaTime, distance, face); // UI/UX related to voxels |
| 2375 | updateHandAndTouch(deltaTime); // Update state for touch sensors | 2371 | updateHandAndTouch(deltaTime); // Update state for touch sensors |
| 2376 | updateLeap(deltaTime); // Leap finger-sensing device | 2372 | updateLeap(deltaTime); // Leap finger-sensing device |
| 2377 | updateSixense(deltaTime); // Razer Hydra controllers | 2373 | updateSixense(deltaTime); // Razer Hydra controllers |
| 2378 | updateSerialDevices(deltaTime); // Read serial port interface devices | 2374 | updateSerialDevices(deltaTime); // Read serial port interface devices |
| 2379 | updateAvatar(deltaTime); // Sample hardware, update view frustum if needed, and send avatar data to mixer/nodes | 2375 | updateAvatar(deltaTime); // Sample hardware, update view frustum if needed, and send avatar data to mixer/nodes |
| 2380 | updateThreads(deltaTime); // If running non-threaded, then give the threads some time to process... | 2376 | updateThreads(deltaTime); // If running non-threaded, then give the threads some time to process... |
| 2381 | updateAvatars(deltaTime, mouseRayOrigin, mouseRayDirection); //loop through all the other avatars and simulate them... | 2377 | updateAvatars(deltaTime); //loop through all the other avatars and simulate them... |
| 2382 | updateMyAvatarSimulation(deltaTime); // Simulate myself | 2378 | updateMyAvatarSimulation(deltaTime); // Simulate myself |
| 2383 | updateParticles(deltaTime); // Simulate particle cloud movements | 2379 | updateParticles(deltaTime); // Simulate particle cloud movements |
| 2384 | updateMetavoxels(deltaTime); // update metavoxels | 2380 | updateMetavoxels(deltaTime); // update metavoxels |
| @@ -2449,9 +2445,8 @@ void Application::updateAvatar(float deltaTime) { · 64 unmodified lines | |||
| 2449 | 2445 | ||
| 2450 | endOfBroadcastStringWrite += _myAvatar.getBroadcastData(endOfBroadcastStringWrite); | 2446 | endOfBroadcastStringWrite += _myAvatar.getBroadcastData(endOfBroadcastStringWrite); |
| 2451 | 2447 | ||
| 2452 | const char nodeTypesOfInterest[] = { NODE_TYPE_AVATAR_MIXER }; | ||
| 2453 | controlledBroadcastToNodes(broadcastString, endOfBroadcastStringWrite - broadcastString, | 2448 | controlledBroadcastToNodes(broadcastString, endOfBroadcastStringWrite - broadcastString, |
| 2454 | nodeTypesOfInterest, sizeof(nodeTypesOfInterest)); | 2449 | QSet<NODE_TYPE>() << NODE_TYPE_AVATAR_MIXER); |
| 2455 | 2450 | ||
| 2456 | // Update _viewFrustum with latest camera and view frustum data... | 2451 | // Update _viewFrustum with latest camera and view frustum data... |
| 2457 | // NOTE: we get this from the view frustum, to make it simpler, since the | 2452 | // NOTE: we get this from the view frustum, to make it simpler, since the |
| @@ -2862,10 +2857,10 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 404 unmodified lines | |||
| 2862 | 2857 | ||
| 2863 | if (!selfAvatarOnly) { | 2858 | if (!selfAvatarOnly) { |
| 2864 | // draw a red sphere | 2859 | // draw a red sphere |
| 2865 | float sphereRadius = 0.25f; | 2860 | float originSphereRadius = 0.05f; |
| 2866 | glColor3f(1,0,0); | 2861 | glColor3f(1,0,0); |
| 2867 | glPushMatrix(); | 2862 | glPushMatrix(); |
| 2868 | glutSolidSphere(sphereRadius, 15, 15); | 2863 | glutSolidSphere(originSphereRadius, 15, 15); |
| 2869 | glPopMatrix(); | 2864 | glPopMatrix(); |
| 2870 | 2865 | ||
| 2871 | // disable specular lighting for ground and voxels | 2866 | // disable specular lighting for ground and voxels |
| @@ -3028,6 +3023,9 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 156 unmodified lines | |||
| 3028 | 3023 | ||
| 3029 | glPopMatrix(); | 3024 | glPopMatrix(); |
| 3030 | } | 3025 | } |
| 3026 | |||
| 3027 | // give external parties a change to hook in | ||
| 3028 | emit renderingInWorldInterface(); | ||
| 3031 | } | 3029 | } |
| 3032 | } | 3030 | } |
| 3033 | 3031 | ||
| @@ -4052,94 +4050,7 @@ int Application::parseOctreeStats(unsigned char* messageData, ssize_t messageLen · 1018 unmodified lines | |||
| 4052 | return statsMessageLength; | 4050 | return statsMessageLength; |
| 4053 | } | 4051 | } |
| 4054 | 4052 | ||
| 4055 | // Receive packets from other nodes/servers and decide what to do with them! | 4053 | void Application::packetSent(quint64 length) { |
| 4056 | void Application::processDatagrams() { | ||
| 4057 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), | ||
| 4058 | "Application::networkReceive()"); | ||
| 4059 | |||
| 4060 | HifiSockAddr senderSockAddr; | ||
| 4061 | ssize_t bytesReceived; | ||
| 4062 | |||
| 4063 | while (NodeList::getInstance()->getNodeSocket().hasPendingDatagrams() && | ||
| 4064 | (bytesReceived = NodeList::getInstance()->getNodeSocket().readDatagram((char*) _incomingPacket, | ||
| 4065 | MAX_PACKET_SIZE, | ||
| 4066 | senderSockAddr.getAddressPointer(), | ||
| 4067 | senderSockAddr.getPortPointer()))) { | ||
| 4068 | |||
| 4069 | _packetCount++; | ||
| 4070 | _bytesCount += bytesReceived; | ||
| 4071 | |||
| 4072 | if (packetVersionMatch(_incomingPacket)) { | ||
| 4073 | // only process this packet if we have a match on the packet version | ||
| 4074 | switch (_incomingPacket[0]) { | ||
| 4075 | case PACKET_TYPE_TRANSMITTER_DATA_V2: | ||
| 4076 | // V2 = IOS transmitter app | ||
| 4077 | _myTransmitter.processIncomingData(_incomingPacket, bytesReceived); | ||
| 4078 | |||
| 4079 | break; | ||
| 4080 | case PACKET_TYPE_MIXED_AUDIO: | ||
| 4081 | QMetaObject::invokeMethod(&_audio, "addReceivedAudioToBuffer", Qt::QueuedConnection, | ||
| 4082 | Q_ARG(QByteArray, QByteArray((char*) _incomingPacket, bytesReceived))); | ||
| 4083 | break; | ||
| 4084 | |||
| 4085 | case PACKET_TYPE_PARTICLE_ADD_RESPONSE: | ||
| 4086 | // this will keep creatorTokenIDs to IDs mapped correctly | ||
| 4087 | Particle::handleAddParticleResponse(_incomingPacket, bytesReceived); | ||
| 4088 | break; | ||
| 4089 | |||
| 4090 | case PACKET_TYPE_PARTICLE_DATA: | ||
| 4091 | case PACKET_TYPE_PARTICLE_ERASE: | ||
| 4092 | case PACKET_TYPE_VOXEL_DATA: | ||
| 4093 | case PACKET_TYPE_VOXEL_ERASE: | ||
| 4094 | case PACKET_TYPE_OCTREE_STATS: | ||
| 4095 | case PACKET_TYPE_ENVIRONMENT_DATA: { | ||
| 4096 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), | ||
| 4097 | "Application::networkReceive()... _voxelProcessor.queueReceivedPacket()"); | ||
| 4098 | |||
| 4099 | bool wantExtraDebugging = getLogger()->extraDebugging(); | ||
| 4100 | if (wantExtraDebugging && _incomingPacket[0] == PACKET_TYPE_VOXEL_DATA) { | ||
| 4101 | int numBytesPacketHeader = numBytesForPacketHeader(_incomingPacket); | ||
| 4102 | unsigned char* dataAt = _incomingPacket + numBytesPacketHeader; | ||
| 4103 | dataAt += sizeof(VOXEL_PACKET_FLAGS); | ||
| 4104 | VOXEL_PACKET_SEQUENCE sequence = (*(VOXEL_PACKET_SEQUENCE*)dataAt); | ||
| 4105 | dataAt += sizeof(VOXEL_PACKET_SEQUENCE); | ||
| 4106 | VOXEL_PACKET_SENT_TIME sentAt = (*(VOXEL_PACKET_SENT_TIME*)dataAt); | ||
| 4107 | dataAt += sizeof(VOXEL_PACKET_SENT_TIME); | ||
| 4108 | VOXEL_PACKET_SENT_TIME arrivedAt = usecTimestampNow(); | ||
| 4109 | int flightTime = arrivedAt - sentAt; | ||
| 4110 | |||
| 4111 | printf("got PACKET_TYPE_VOXEL_DATA, sequence:%d flightTime:%d\n", sequence, flightTime); | ||
| 4112 | } | ||
| 4113 | |||
| 4114 | // add this packet to our list of voxel packets and process them on the voxel processing | ||
| 4115 | _voxelProcessor.queueReceivedPacket(senderSockAddr, _incomingPacket, bytesReceived); | ||
| 4116 | break; | ||
| 4117 | } | ||
| 4118 | case PACKET_TYPE_METAVOXEL_DATA: | ||
| 4119 | _metavoxels.processData(QByteArray((const char*) _incomingPacket, bytesReceived), | ||
| 4120 | senderSockAddr); | ||
| 4121 | break; | ||
| 4122 | case PACKET_TYPE_BULK_AVATAR_DATA: | ||
| 4123 | NodeList::getInstance()->processBulkNodeData(senderSockAddr, | ||
| 4124 | _incomingPacket, | ||
| 4125 | bytesReceived); | ||
| 4126 | getInstance()->_bandwidthMeter.inputStream(BandwidthMeter::AVATARS).updateValue(bytesReceived); | ||
| 4127 | break; | ||
| 4128 | case PACKET_TYPE_DATA_SERVER_GET: | ||
| 4129 | case PACKET_TYPE_DATA_SERVER_PUT: | ||
| 4130 | case PACKET_TYPE_DATA_SERVER_SEND: | ||
| 4131 | case PACKET_TYPE_DATA_SERVER_CONFIRM: | ||
| 4132 | DataServerClient::processMessageFromDataServer(_incomingPacket, bytesReceived); | ||
| 4133 | break; | ||
| 4134 | default: | ||
| 4135 | NodeList::getInstance()->processNodeData(senderSockAddr, _incomingPacket, bytesReceived); | ||
| 4136 | break; | ||
| 4137 | } | ||
| 4138 | } | ||
| 4139 | } | ||
| 4140 | } | ||
| 4141 | |||
| 4142 | void Application::packetSentNotification(ssize_t length) { | ||
| 4143 | _bandwidthMeter.outputStream(BandwidthMeter::VOXELS).updateValue(length); | 4054 | _bandwidthMeter.outputStream(BandwidthMeter::VOXELS).updateValue(length); |
| 4144 | } | 4055 | } |
| 4145 | 4056 | ||