Showing the changes to interface/src/Application.cpp (1 of 50 files). Show all
Unified · Split
| @@ -109,7 +109,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 108 unmodified lines | ||
| 109 | 109 | _window(new QMainWindow(desktop())), |
| 110 | 110 | _glWidget(new GLCanvas()), |
| 111 | 111 | _nodeThread(new QThread(this)), |
| 112 | − _datagramProcessor(new DatagramProcessor()), | |
| 112 | + _datagramProcessor(), | |
| 113 | 113 | _frameCount(0), |
| 114 | 114 | _fps(120.0f), |
| 115 | 115 | _justStarted(true), |
| @@ -145,8 +145,6 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 29 unmodified lines | ||
| 145 | 145 | _enableProcessVoxelsThread(true), |
| 146 | 146 | _voxelProcessor(), |
| 147 | 147 | _voxelHideShowThread(&_voxels), |
| 148 | − _voxelEditSender(this), | |
| 149 | − _particleEditSender(this), | |
| 150 | 148 | _packetsPerSecond(0), |
| 151 | 149 | _bytesPerSecond(0), |
| 152 | 150 | _recentMaxPackets(0), |
| @@ -174,20 +172,20 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 21 unmodified lines | ||
| 174 | 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 | + | |
| 177 | 181 | // put the NodeList and datagram processing on the node thread |
| 178 | 182 | NodeList* nodeList = NodeList::createInstance(NODE_TYPE_AGENT, listenPort); |
| 179 | 183 | |
| 180 | 184 | nodeList->moveToThread(_nodeThread); |
| 181 | − _datagramProcessor->moveToThread(_nodeThread); | |
| 185 | + _datagramProcessor.moveToThread(_nodeThread); | |
| 182 | 186 | |
| 183 | 187 | // connect the DataProcessor processDatagrams slot to the QUDPSocket readyRead() signal |
| 184 | − connect(&nodeList->getNodeSocket(), SIGNAL(readyRead()), _datagramProcessor, SLOT(processDatagrams())); | |
| 185 | − | |
| 186 | − // make sure the node thread is given highest priority | |
| 187 | − _nodeThread->setPriority(QThread::TimeCriticalPriority); | |
| 188 | − | |
| 189 | − // start the nodeThread so its event loop is running | |
| 190 | − _nodeThread->start(); | |
| 188 | + connect(&nodeList->getNodeSocket(), SIGNAL(readyRead()), &_datagramProcessor, SLOT(processDatagrams())); | |
| 191 | 189 | |
| 192 | 190 | // put the audio processing on a separate thread |
| 193 | 191 | QThread* audioThread = new QThread(this); |
| @@ -231,12 +229,16 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 37 unmodified lines | ||
| 231 | 229 | #endif |
| 232 | 230 | |
| 233 | 231 | // tell the NodeList instance who to tell the domain server we care about |
| 234 | − const char nodeTypesOfInterest[] = {NODE_TYPE_AUDIO_MIXER, NODE_TYPE_AVATAR_MIXER, NODE_TYPE_VOXEL_SERVER, | |
| 235 | − NODE_TYPE_PARTICLE_SERVER, NODE_TYPE_METAVOXEL_SERVER}; | |
| 236 | − nodeList->setNodeTypesOfInterest(nodeTypesOfInterest, sizeof(nodeTypesOfInterest)); | |
| 232 | + nodeList->addSetOfNodeTypesToNodeInterestSet(QSet<NODE_TYPE>() << NODE_TYPE_AUDIO_MIXER << NODE_TYPE_AVATAR_MIXER | |
| 233 | + << NODE_TYPE_VOXEL_SERVER << NODE_TYPE_PARTICLE_SERVER | |
| 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); | |
| 237 | 239 | |
| 238 | 240 | // move the silentNodeTimer to the _nodeThread |
| 239 | − QTimer* silentNodeTimer = new QTimer(this); | |
| 241 | + QTimer* silentNodeTimer = new QTimer(); | |
| 240 | 242 | connect(silentNodeTimer, SIGNAL(timeout()), nodeList, SLOT(removeSilentNodes())); |
| 241 | 243 | silentNodeTimer->moveToThread(_nodeThread); |
| 242 | 244 | silentNodeTimer->start(NODE_SILENCE_THRESHOLD_USECS / 1000); |
| @@ -282,17 +284,35 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 39 unmodified lines | ||
| 282 | 284 | Application::~Application() { |
| 283 | 285 | |
| 284 | 286 | qInstallMessageHandler(NULL); |
| 285 | − | |
| 287 | + | |
| 286 | 288 | // make sure we don't call the idle timer any more |
| 287 | 289 | delete idleTimer; |
| 288 | 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 | + | |
| 289 | 299 | // ask the datagram processing thread to quit and wait until it is done |
| 290 | − _nodeThread->thread()->quit(); | |
| 291 | − _nodeThread->thread()->wait(); | |
| 292 | − | |
| 300 | + _nodeThread->quit(); | |
| 301 | + _nodeThread->wait(); | |
| 302 | + | |
| 293 | 303 | // ask the audio thread to quit and wait until it is done |
| 294 | 304 | _audio.thread()->quit(); |
| 295 | 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 | + } | |
| 296 | 316 | |
| 297 | 317 | storeSizeAndPosition(); |
| 298 | 318 | saveScripts(); |
| @@ -377,9 +397,6 @@ void Application::initializeGL() { · 78 unmodified lines | ||
| 377 | 397 | qDebug("Voxel parsing thread created."); |
| 378 | 398 | } |
| 379 | 399 | |
| 380 | − // call terminate before exiting | |
| 381 | − connect(this, SIGNAL(aboutToQuit()), SLOT(terminate())); | |
| 382 | − | |
| 383 | 400 | // call our timer function every second |
| 384 | 401 | QTimer* timer = new QTimer(this); |
| 385 | 402 | connect(timer, SIGNAL(timeout()), SLOT(timer())); |
| @@ -628,21 +645,20 @@ void Application::resetProfile(const QString& username) { · 242 unmodified lines | ||
| 628 | 645 | } |
| 629 | 646 | |
| 630 | 647 | void Application::controlledBroadcastToNodes(unsigned char* broadcastData, size_t dataBytes, |
| 631 | − const char* nodeTypes, int numNodeTypes) { | |
| 632 | − Application* self = getInstance(); | |
| 633 | − for (int i = 0; i < numNodeTypes; ++i) { | |
| 634 | − | |
| 648 | + const QSet<NODE_TYPE>& destinationNodeTypes) { | |
| 649 | + foreach(NODE_TYPE type, destinationNodeTypes) { | |
| 635 | 650 | // Intercept data to voxel server when voxels are disabled |
| 636 | − if (nodeTypes[i] == NODE_TYPE_VOXEL_SERVER && !Menu::getInstance()->isOptionChecked(MenuOption::Voxels)) { | |
| 651 | + if (type == NODE_TYPE_VOXEL_SERVER && !Menu::getInstance()->isOptionChecked(MenuOption::Voxels)) { | |
| 637 | 652 | continue; |
| 638 | 653 | } |
| 639 | − | |
| 654 | + | |
| 640 | 655 | // Perform the broadcast for one type |
| 641 | − int nReceivingNodes = NodeList::getInstance()->broadcastToNodes(broadcastData, dataBytes, & nodeTypes[i], 1); | |
| 642 | − | |
| 656 | + int nReceivingNodes = NodeList::getInstance()->broadcastToNodes(broadcastData, dataBytes, | |
| 657 | + QSet<NODE_TYPE>() << type); | |
| 658 | + | |
| 643 | 659 | // Feed number of bytes to corresponding channel of the bandwidth meter, if any (done otherwise) |
| 644 | 660 | BandwidthMeter::ChannelIndex channel; |
| 645 | − switch (nodeTypes[i]) { | |
| 661 | + switch (type) { | |
| 646 | 662 | case NODE_TYPE_AGENT: |
| 647 | 663 | case NODE_TYPE_AVATAR_MIXER: |
| 648 | 664 | channel = BandwidthMeter::AVATARS; |
| @@ -653,7 +669,7 @@ void Application::controlledBroadcastToNodes(unsigned char* broadcastData, size_ · 4 unmodified lines | ||
| 653 | 669 | default: |
| 654 | 670 | continue; |
| 655 | 671 | } |
| 656 | − self->_bandwidthMeter.outputStream(channel).updateValue(nReceivingNodes * dataBytes); | |
| 672 | + _bandwidthMeter.outputStream(channel).updateValue(nReceivingNodes * dataBytes); | |
| 657 | 673 | } |
| 658 | 674 | } |
| 659 | 675 | |
| @@ -1136,13 +1152,12 @@ void Application::mouseMoveEvent(QMouseEvent* event) { · 476 unmodified lines | ||
| 1136 | 1152 | _seenMouseMove = true; |
| 1137 | 1153 | } |
| 1138 | 1154 | |
| 1155 | + int deltaX = event->x() - _mouseX; | |
| 1156 | + int deltaY = event->y() - _mouseY; | |
| 1157 | + _mouseX = event->x(); | |
| 1158 | + _mouseY = event->y(); | |
| 1159 | + | |
| 1139 | 1160 | if (activeWindow() == _window) { |
| 1140 | − int deltaX = event->x() - _mouseX; | |
| 1141 | − int deltaY = event->y() - _mouseY; | |
| 1142 | − | |
| 1143 | − _mouseX = event->x(); | |
| 1144 | − _mouseY = event->y(); | |
| 1145 | − | |
| 1146 | 1161 | // orbit behavior |
| 1147 | 1162 | if (_mousePressed && !Menu::getInstance()->isVoxelModeActionChecked()) { |
| 1148 | 1163 | if (_lookatTargetAvatar) { |
| @@ -1308,15 +1323,13 @@ void Application::wheelEvent(QWheelEvent* event) { · 159 unmodified lines | ||
| 1308 | 1323 | } |
| 1309 | 1324 | |
| 1310 | 1325 | void Application::sendPingPackets() { |
| 1311 | − | |
| 1312 | − const char nodesToPing[] = {NODE_TYPE_VOXEL_SERVER, NODE_TYPE_PARTICLE_SERVER, | |
| 1313 | − NODE_TYPE_AUDIO_MIXER, NODE_TYPE_AVATAR_MIXER, NODE_TYPE_METAVOXEL_SERVER}; | |
| 1314 | − | |
| 1315 | 1326 | unsigned char pingPacket[MAX_PACKET_SIZE]; |
| 1316 | 1327 | int length = NodeList::getInstance()->fillPingPacket(pingPacket); |
| 1317 | 1328 | |
| 1318 | − getInstance()->controlledBroadcastToNodes(pingPacket, length, | |
| 1319 | − nodesToPing, sizeof(nodesToPing)); | |
| 1329 | + getInstance()->controlledBroadcastToNodes(pingPacket, length, QSet<NODE_TYPE>() | |
| 1330 | + << NODE_TYPE_VOXEL_SERVER << NODE_TYPE_PARTICLE_SERVER | |
| 1331 | + << NODE_TYPE_AUDIO_MIXER << NODE_TYPE_AVATAR_MIXER | |
| 1332 | + << NODE_TYPE_METAVOXEL_SERVER); | |
| 1320 | 1333 | } |
| 1321 | 1334 | |
| 1322 | 1335 | // Every second, check the frame rates and other stuff |
| @@ -1329,11 +1342,11 @@ void Application::timer() { · 6 unmodified lines | ||
| 1329 | 1342 | |
| 1330 | 1343 | _fps = (float)_frameCount / ((float)diffclock(&_timerStart, &_timerEnd) / 1000.f); |
| 1331 | 1344 | |
| 1332 | − _packetsPerSecond = (float) _datagramProcessor->getPacketCount() / ((float)diffclock(&_timerStart, &_timerEnd) / 1000.f); | |
| 1333 | − _bytesPerSecond = (float) _datagramProcessor->getByteCount() / ((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); | |
| 1334 | 1347 | _frameCount = 0; |
| 1335 | 1348 | |
| 1336 | − _datagramProcessor->resetCounters(); | |
| 1349 | + _datagramProcessor.resetCounters(); | |
| 1337 | 1350 | |
| 1338 | 1351 | gettimeofday(&_timerStart, NULL); |
| 1339 | 1352 | |
| @@ -1412,28 +1425,6 @@ void Application::idle() { · 72 unmodified lines | ||
| 1412 | 1425 | } |
| 1413 | 1426 | } |
| 1414 | 1427 | |
| 1415 | −void Application::terminate() { | |
| 1416 | − // Close serial port | |
| 1417 | − // close(serial_fd); | |
| 1418 | − | |
| 1419 | − Menu::getInstance()->saveSettings(); | |
| 1420 | − _rearMirrorTools->saveSettings(_settings); | |
| 1421 | − _settings->sync(); | |
| 1422 | − | |
| 1423 | − // let the avatar mixer know we're out | |
| 1424 | − NodeList::getInstance()->sendKillNode(&NODE_TYPE_AVATAR_MIXER, 1); | |
| 1425 | − | |
| 1426 | − _voxelProcessor.terminate(); | |
| 1427 | − _voxelHideShowThread.terminate(); | |
| 1428 | − _voxelEditSender.terminate(); | |
| 1429 | − _particleEditSender.terminate(); | |
| 1430 | − if (_persistThread) { | |
| 1431 | − _persistThread->terminate(); | |
| 1432 | − _persistThread->deleteLater(); | |
| 1433 | − _persistThread = NULL; | |
| 1434 | − } | |
| 1435 | −} | |
| 1436 | − | |
| 1437 | 1428 | void Application::checkBandwidthMeterClick() { |
| 1438 | 1429 | // ... to be called upon button release |
| 1439 | 1430 | |
| @@ -1857,25 +1848,23 @@ const float HEAD_SPHERE_RADIUS = 0.07f; · 417 unmodified lines | ||
| 1857 | 1848 | |
| 1858 | 1849 | static QUuid DEFAULT_NODE_ID_REF; |
| 1859 | 1850 | |
| 1860 | −void Application::updateLookatTargetAvatar(const glm::vec3& mouseRayOrigin, const glm::vec3& mouseRayDirection, | |
| 1861 | − glm::vec3& eyePosition) { | |
| 1851 | +void Application::updateLookatTargetAvatar(glm::vec3& eyePosition) { | |
| 1862 | 1852 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); |
| 1863 | 1853 | PerformanceWarning warn(showWarnings, "Application::updateLookatTargetAvatar()"); |
| 1864 | 1854 | |
| 1865 | 1855 | if (!_mousePressed) { |
| 1866 | − _lookatTargetAvatar = findLookatTargetAvatar(mouseRayOrigin, mouseRayDirection, eyePosition, DEFAULT_NODE_ID_REF); | |
| 1856 | + _lookatTargetAvatar = findLookatTargetAvatar(eyePosition, DEFAULT_NODE_ID_REF); | |
| 1867 | 1857 | } |
| 1868 | 1858 | } |
| 1869 | 1859 | |
| 1870 | −Avatar* Application::findLookatTargetAvatar(const glm::vec3& mouseRayOrigin, const glm::vec3& mouseRayDirection, | |
| 1871 | − glm::vec3& eyePosition, QUuid& nodeUUID = DEFAULT_NODE_ID_REF) { | |
| 1860 | +Avatar* Application::findLookatTargetAvatar(glm::vec3& eyePosition, QUuid& nodeUUID = DEFAULT_NODE_ID_REF) { | |
| 1872 | 1861 | |
| 1873 | 1862 | foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) { |
| 1874 | 1863 | if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) { |
| 1875 | 1864 | Avatar* avatar = (Avatar*)node->getLinkedData(); |
| 1876 | 1865 | float distance; |
| 1877 | 1866 | |
| 1878 | − if (avatar->findRayIntersection(mouseRayOrigin, mouseRayDirection, distance)) { | |
| 1867 | + if (avatar->findRayIntersection(_mouseRayOrigin, _mouseRayDirection, distance)) { | |
| 1879 | 1868 | // rescale to compensate for head embiggening |
| 1880 | 1869 | eyePosition = (avatar->getHead().calculateAverageEyePosition() - avatar->getHead().getScalePivot()) * |
| 1881 | 1870 | (avatar->getScale() / avatar->getHead().getScale()) + avatar->getHead().getScalePivot(); |
| @@ -1926,7 +1915,7 @@ void Application::renderHighlightVoxel(VoxelDetail voxel) { · 44 unmodified lines | ||
| 1926 | 1915 | glPopMatrix(); |
| 1927 | 1916 | } |
| 1928 | 1917 | |
| 1929 | −void Application::updateAvatars(float deltaTime, glm::vec3 mouseRayOrigin, glm::vec3 mouseRayDirection) { | |
| 1918 | +void Application::updateAvatars(float deltaTime) { | |
| 1930 | 1919 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); |
| 1931 | 1920 | PerformanceWarning warn(showWarnings, "Application::updateAvatars()"); |
| 1932 | 1921 | |
| @@ -1938,7 +1927,7 @@ void Application::updateAvatars(float deltaTime, glm::vec3 mouseRayOrigin, glm:: · 5 unmodified lines | ||
| 1938 | 1927 | avatar->init(); |
| 1939 | 1928 | } |
| 1940 | 1929 | avatar->simulate(deltaTime, NULL); |
| 1941 | − avatar->setMouseRay(mouseRayOrigin, mouseRayDirection); | |
| 1930 | + avatar->setMouseRay(_mouseRayOrigin, _mouseRayDirection); | |
| 1942 | 1931 | } |
| 1943 | 1932 | } |
| 1944 | 1933 | |
| @@ -1961,28 +1950,28 @@ void Application::updateAvatars(float deltaTime, glm::vec3 mouseRayOrigin, glm:: · 16 unmodified lines | ||
| 1961 | 1950 | } |
| 1962 | 1951 | } |
| 1963 | 1952 | |
| 1964 | −void Application::updateMouseRay(float deltaTime, glm::vec3& mouseRayOrigin, glm::vec3& mouseRayDirection) { | |
| 1953 | +void Application::updateMouseRay() { | |
| 1965 | 1954 | |
| 1966 | 1955 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); |
| 1967 | 1956 | PerformanceWarning warn(showWarnings, "Application::updateMouseRay()"); |
| 1968 | 1957 | |
| 1969 | 1958 | _viewFrustum.computePickRay(_mouseX / (float)_glWidget->width(), _mouseY / (float)_glWidget->height(), |
| 1970 | − mouseRayOrigin, mouseRayDirection); | |
| 1959 | + _mouseRayOrigin, _mouseRayDirection); | |
| 1971 | 1960 | |
| 1972 | 1961 | // adjust for mirroring |
| 1973 | 1962 | if (_myCamera.getMode() == CAMERA_MODE_MIRROR) { |
| 1974 | − glm::vec3 mouseRayOffset = mouseRayOrigin - _viewFrustum.getPosition(); | |
| 1975 | − mouseRayOrigin -= 2.0f * (_viewFrustum.getDirection() * glm::dot(_viewFrustum.getDirection(), mouseRayOffset) + | |
| 1963 | + glm::vec3 mouseRayOffset = _mouseRayOrigin - _viewFrustum.getPosition(); | |
| 1964 | + _mouseRayOrigin -= 2.0f * (_viewFrustum.getDirection() * glm::dot(_viewFrustum.getDirection(), mouseRayOffset) + | |
| 1976 | 1965 | _viewFrustum.getRight() * glm::dot(_viewFrustum.getRight(), mouseRayOffset)); |
| 1977 | − mouseRayDirection -= 2.0f * (_viewFrustum.getDirection() * glm::dot(_viewFrustum.getDirection(), mouseRayDirection) + | |
| 1978 | − _viewFrustum.getRight() * glm::dot(_viewFrustum.getRight(), mouseRayDirection)); | |
| 1966 | + _mouseRayDirection -= 2.0f * (_viewFrustum.getDirection() * glm::dot(_viewFrustum.getDirection(), _mouseRayDirection) + | |
| 1967 | + _viewFrustum.getRight() * glm::dot(_viewFrustum.getRight(), _mouseRayDirection)); | |
| 1979 | 1968 | } |
| 1980 | 1969 | |
| 1981 | 1970 | // tell my avatar if the mouse is being pressed... |
| 1982 | 1971 | _myAvatar.setMousePressed(_mousePressed); |
| 1983 | 1972 | |
| 1984 | 1973 | // tell my avatar the posiion and direction of the ray projected ino the world based on the mouse position |
| 1985 | − _myAvatar.setMouseRay(mouseRayOrigin, mouseRayDirection); | |
| 1974 | + _myAvatar.setMouseRay(_mouseRayOrigin, _mouseRayDirection); | |
| 1986 | 1975 | } |
| 1987 | 1976 | |
| 1988 | 1977 | void Application::updateFaceshift() { |
| @@ -1999,8 +1988,7 @@ void Application::updateFaceshift() { · 10 unmodified lines | ||
| 1999 | 1988 | } |
| 2000 | 1989 | } |
| 2001 | 1990 | |
| 2002 | −void Application::updateMyAvatarLookAtPosition(glm::vec3& lookAtSpot, glm::vec3& lookAtRayOrigin, | |
| 2003 | − glm::vec3& lookAtRayDirection) { | |
| 1991 | +void Application::updateMyAvatarLookAtPosition(glm::vec3& lookAtSpot) { | |
| 2004 | 1992 | |
| 2005 | 1993 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); |
| 2006 | 1994 | PerformanceWarning warn(showWarnings, "Application::updateMyAvatarLookAtPosition()"); |
| @@ -2015,15 +2003,9 @@ void Application::updateMyAvatarLookAtPosition(glm::vec3& lookAtSpot, glm::vec3& · 8 unmodified lines | ||
| 2015 | 2003 | _viewFrustum.computePickRay(0.5f, 0.5f, rayOrigin, rayDirection); |
| 2016 | 2004 | lookAtSpot = rayOrigin + rayDirection * FAR_AWAY_STARE; |
| 2017 | 2005 | |
| 2018 | − } else if (!_lookatTargetAvatar) { | |
| 2019 | − if (_isHoverVoxel) { | |
| 2020 | − // Look at the hovered voxel | |
| 2021 | − lookAtSpot = getMouseVoxelWorldCoordinates(_hoverVoxel); | |
| 2022 | − | |
| 2023 | − } else { | |
| 2024 | − // Just look in direction of the mouse ray | |
| 2025 | − lookAtSpot = lookAtRayOrigin + lookAtRayDirection * FAR_AWAY_STARE; | |
| 2026 | − } | |
| 2006 | + } else { | |
| 2007 | + // just look in direction of the mouse ray | |
| 2008 | + lookAtSpot = _mouseRayOrigin + _mouseRayDirection * FAR_AWAY_STARE; | |
| 2027 | 2009 | } |
| 2028 | 2010 | if (_faceshift.isActive()) { |
| 2029 | 2011 | // deflect using Faceshift gaze data |
| @@ -2037,8 +2019,7 @@ void Application::updateMyAvatarLookAtPosition(glm::vec3& lookAtSpot, glm::vec3& · 7 unmodified lines | ||
| 2037 | 2019 | _myAvatar.getHead().setLookAtPosition(lookAtSpot); |
| 2038 | 2020 | } |
| 2039 | 2021 | |
| 2040 | −void Application::updateHoverVoxels(float deltaTime, glm::vec3& mouseRayOrigin, glm::vec3& mouseRayDirection, | |
| 2041 | − float& distance, BoxFace& face) { | |
| 2022 | +void Application::updateHoverVoxels(float deltaTime, float& distance, BoxFace& face) { | |
| 2042 | 2023 | |
| 2043 | 2024 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); |
| 2044 | 2025 | PerformanceWarning warn(showWarnings, "Application::updateHoverVoxels()"); |
| @@ -2069,7 +2050,7 @@ void Application::updateHoverVoxels(float deltaTime, glm::vec3& mouseRayOrigin, · 24 unmodified lines | ||
| 2069 | 2050 | if (!(_voxels.treeIsBusy() || _mousePressed)) { |
| 2070 | 2051 | { |
| 2071 | 2052 | PerformanceWarning warn(showWarnings, "Application::updateHoverVoxels() _voxels.findRayIntersection()"); |
| 2072 | − _isHoverVoxel = _voxels.findRayIntersection(mouseRayOrigin, mouseRayDirection, _hoverVoxel, distance, face); | |
| 2053 | + _isHoverVoxel = _voxels.findRayIntersection(_mouseRayOrigin, _mouseRayDirection, _hoverVoxel, distance, face); | |
| 2073 | 2054 | } |
| 2074 | 2055 | if (MAKE_SOUND_ON_VOXEL_HOVER && _isHoverVoxel && |
| 2075 | 2056 | glm::vec4(_hoverVoxel.x, _hoverVoxel.y, _hoverVoxel.z, _hoverVoxel.s) != oldVoxel) { |
| @@ -2085,8 +2066,7 @@ void Application::updateHoverVoxels(float deltaTime, glm::vec3& mouseRayOrigin, · 9 unmodified lines | ||
| 2085 | 2066 | } |
| 2086 | 2067 | } |
| 2087 | 2068 | |
| 2088 | −void Application::updateMouseVoxels(float deltaTime, glm::vec3& mouseRayOrigin, glm::vec3& mouseRayDirection, | |
| 2089 | − float& distance, BoxFace& face) { | |
| 2069 | +void Application::updateMouseVoxels(float deltaTime, float& distance, BoxFace& face) { | |
| 2090 | 2070 | |
| 2091 | 2071 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); |
| 2092 | 2072 | PerformanceWarning warn(showWarnings, "Application::updateMouseVoxels()"); |
| @@ -2098,7 +2078,7 @@ void Application::updateMouseVoxels(float deltaTime, glm::vec3& mouseRayOrigin, · 5 unmodified lines | ||
| 2098 | 2078 | fabs(_myAvatar.getVelocity().y) + |
| 2099 | 2079 | fabs(_myAvatar.getVelocity().z)) / 3 < MAX_AVATAR_EDIT_VELOCITY) { |
| 2100 | 2080 | |
| 2101 | − if (_voxels.findRayIntersection(mouseRayOrigin, mouseRayDirection, _mouseVoxel, distance, face)) { | |
| 2081 | + if (_voxels.findRayIntersection(_mouseRayOrigin, _mouseRayDirection, _mouseVoxel, distance, face)) { | |
| 2102 | 2082 | if (distance < MAX_VOXEL_EDIT_DISTANCE) { |
| 2103 | 2083 | // set the voxel scale to that of the first moused-over voxel |
| 2104 | 2084 | if (!wasInitialized) { |
| @@ -2118,7 +2098,7 @@ void Application::updateMouseVoxels(float deltaTime, glm::vec3& mouseRayOrigin, · 13 unmodified lines | ||
| 2118 | 2098 | glm::vec3 faceVector = getFaceVector(face); |
| 2119 | 2099 | if (_mouseVoxelScale < _mouseVoxel.s) { |
| 2120 | 2100 | // find the closest contained voxel |
| 2121 | − glm::vec3 pt = (mouseRayOrigin + mouseRayDirection * distance) / (float)TREE_SCALE - | |
| 2101 | + glm::vec3 pt = (_mouseRayOrigin + _mouseRayDirection * distance) / (float)TREE_SCALE - | |
| 2122 | 2102 | faceVector * (_mouseVoxelScale * 0.5f); |
| 2123 | 2103 | _mouseVoxel.x = _mouseVoxelScale * floorf(pt.x / _mouseVoxelScale); |
| 2124 | 2104 | _mouseVoxel.y = _mouseVoxelScale * floorf(pt.y / _mouseVoxelScale); |
| @@ -2139,7 +2119,7 @@ void Application::updateMouseVoxels(float deltaTime, glm::vec3& mouseRayOrigin, · 14 unmodified lines | ||
| 2139 | 2119 | || Menu::getInstance()->isOptionChecked(MenuOption::VoxelSelectMode)) { |
| 2140 | 2120 | // place the voxel a fixed distance away |
| 2141 | 2121 | float worldMouseVoxelScale = _mouseVoxelScale * TREE_SCALE; |
| 2142 | − glm::vec3 pt = mouseRayOrigin + mouseRayDirection * (2.0f + worldMouseVoxelScale * 0.5f); | |
| 2122 | + glm::vec3 pt = _mouseRayOrigin + _mouseRayDirection * (2.0f + worldMouseVoxelScale * 0.5f); | |
| 2143 | 2123 | _mouseVoxel.x = _mouseVoxelScale * floorf(pt.x / worldMouseVoxelScale); |
| 2144 | 2124 | _mouseVoxel.y = _mouseVoxelScale * floorf(pt.y / worldMouseVoxelScale); |
| 2145 | 2125 | _mouseVoxel.z = _mouseVoxelScale * floorf(pt.z / worldMouseVoxelScale); |
| @@ -2373,29 +2353,28 @@ void Application::update(float deltaTime) { · 227 unmodified lines | ||
| 2373 | 2353 | PerformanceWarning warn(showWarnings, "Application::update()"); |
| 2374 | 2354 | |
| 2375 | 2355 | // check what's under the mouse and update the mouse voxel |
| 2376 | − glm::vec3 mouseRayOrigin, mouseRayDirection; | |
| 2377 | − updateMouseRay(deltaTime, mouseRayOrigin, mouseRayDirection); | |
| 2356 | + updateMouseRay(); | |
| 2378 | 2357 | |
| 2379 | 2358 | // Set where I am looking based on my mouse ray (so that other people can see) |
| 2380 | 2359 | glm::vec3 lookAtSpot; |
| 2381 | 2360 | |
| 2382 | 2361 | updateFaceshift(); |
| 2383 | − updateLookatTargetAvatar(mouseRayOrigin, mouseRayDirection, lookAtSpot); | |
| 2384 | − updateMyAvatarLookAtPosition(lookAtSpot, mouseRayOrigin, mouseRayDirection); | |
| 2362 | + updateLookatTargetAvatar(lookAtSpot); | |
| 2363 | + updateMyAvatarLookAtPosition(lookAtSpot); | |
| 2385 | 2364 | |
| 2386 | 2365 | // Find the voxel we are hovering over, and respond if clicked |
| 2387 | 2366 | float distance; |
| 2388 | 2367 | BoxFace face; |
| 2389 | 2368 | |
| 2390 | − updateHoverVoxels(deltaTime, mouseRayOrigin, mouseRayDirection, distance, face); // clicking on voxels and making sounds | |
| 2391 | − updateMouseVoxels(deltaTime, mouseRayOrigin, mouseRayDirection, distance, face); // UI/UX related to voxels | |
| 2369 | + updateHoverVoxels(deltaTime, distance, face); // clicking on voxels and making sounds | |
| 2370 | + updateMouseVoxels(deltaTime, distance, face); // UI/UX related to voxels | |
| 2392 | 2371 | updateHandAndTouch(deltaTime); // Update state for touch sensors |
| 2393 | 2372 | updateLeap(deltaTime); // Leap finger-sensing device |
| 2394 | 2373 | updateSixense(deltaTime); // Razer Hydra controllers |
| 2395 | 2374 | updateSerialDevices(deltaTime); // Read serial port interface devices |
| 2396 | 2375 | updateAvatar(deltaTime); // Sample hardware, update view frustum if needed, and send avatar data to mixer/nodes |
| 2397 | 2376 | updateThreads(deltaTime); // If running non-threaded, then give the threads some time to process... |
| 2398 | − 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... | |
| 2399 | 2378 | updateMyAvatarSimulation(deltaTime); // Simulate myself |
| 2400 | 2379 | updateParticles(deltaTime); // Simulate particle cloud movements |
| 2401 | 2380 | updateMetavoxels(deltaTime); // update metavoxels |
| @@ -2466,9 +2445,8 @@ void Application::updateAvatar(float deltaTime) { · 64 unmodified lines | ||
| 2466 | 2445 | |
| 2467 | 2446 | endOfBroadcastStringWrite += _myAvatar.getBroadcastData(endOfBroadcastStringWrite); |
| 2468 | 2447 | |
| 2469 | − const char nodeTypesOfInterest[] = { NODE_TYPE_AVATAR_MIXER }; | |
| 2470 | 2448 | controlledBroadcastToNodes(broadcastString, endOfBroadcastStringWrite - broadcastString, |
| 2471 | − nodeTypesOfInterest, sizeof(nodeTypesOfInterest)); | |
| 2449 | + QSet<NODE_TYPE>() << NODE_TYPE_AVATAR_MIXER); | |
| 2472 | 2450 | |
| 2473 | 2451 | // Update _viewFrustum with latest camera and view frustum data... |
| 2474 | 2452 | // NOTE: we get this from the view frustum, to make it simpler, since the |
| @@ -2879,10 +2857,10 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 404 unmodified lines | ||
| 2879 | 2857 | |
| 2880 | 2858 | if (!selfAvatarOnly) { |
| 2881 | 2859 | // draw a red sphere |
| 2882 | − float sphereRadius = 0.25f; | |
| 2860 | + float originSphereRadius = 0.05f; | |
| 2883 | 2861 | glColor3f(1,0,0); |
| 2884 | 2862 | glPushMatrix(); |
| 2885 | − glutSolidSphere(sphereRadius, 15, 15); | |
| 2863 | + glutSolidSphere(originSphereRadius, 15, 15); | |
| 2886 | 2864 | glPopMatrix(); |
| 2887 | 2865 | |
| 2888 | 2866 | // disable specular lighting for ground and voxels |
| @@ -3045,6 +3023,9 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 156 unmodified lines | ||
| 3045 | 3023 | |
| 3046 | 3024 | glPopMatrix(); |
| 3047 | 3025 | } |
| 3026 | + | |
| 3027 | + // give external parties a change to hook in | |
| 3028 | + emit renderingInWorldInterface(); | |
| 3048 | 3029 | } |
| 3049 | 3030 | } |
| 3050 | 3031 | |
| @@ -4153,7 +4134,7 @@ int Application::parseOctreeStats(unsigned char* messageData, ssize_t messageLen · 1102 unmodified lines | ||
| 4153 | 4134 | return statsMessageLength; |
| 4154 | 4135 | } |
| 4155 | 4136 | |
| 4156 | −void Application::packetSentNotification(ssize_t length) { | |
| 4137 | +void Application::packetSent(quint64 length) { | |
| 4157 | 4138 | _bandwidthMeter.outputStream(BandwidthMeter::VOXELS).updateValue(length); |
| 4158 | 4139 | } |
| 4159 | 4140 | |