History

Merge branch 'master' of git://github.com/worklist/hifi into 19487

Lucas Crisman committed 12 years ago

Commit f818b072 parents 95837b8 612041650 files · +1151 −458Browse files

Showing the changes to interface/src/Application.cpp (1 of 50 files). Show all

Unified · Split

interface/src/Application.cpp+96−115
@@ -109,7 +109,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 108 unmodified lines
109 _window(new QMainWindow(desktop())),109 _window(new QMainWindow(desktop())),
110 _glWidget(new GLCanvas()),110 _glWidget(new GLCanvas()),
111 _nodeThread(new QThread(this)),111 _nodeThread(new QThread(this)),
112 _datagramProcessor(new DatagramProcessor()),112 _datagramProcessor(),
113 _frameCount(0),113 _frameCount(0),
114 _fps(120.0f),114 _fps(120.0f),
115 _justStarted(true),115 _justStarted(true),
@@ -145,8 +145,6 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 29 unmodified lines
145 _enableProcessVoxelsThread(true),145 _enableProcessVoxelsThread(true),
146 _voxelProcessor(),146 _voxelProcessor(),
147 _voxelHideShowThread(&_voxels),147 _voxelHideShowThread(&_voxels),
148 _voxelEditSender(this),
149 _particleEditSender(this),
150 _packetsPerSecond(0),148 _packetsPerSecond(0),
151 _bytesPerSecond(0),149 _bytesPerSecond(0),
152 _recentMaxPackets(0),150 _recentMaxPackets(0),
@@ -174,20 +172,20 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 21 unmodified lines
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
177 // put the NodeList and datagram processing on the node thread181 // put the NodeList and datagram processing on the node thread
178 NodeList* nodeList = NodeList::createInstance(NODE_TYPE_AGENT, listenPort);182 NodeList* nodeList = NodeList::createInstance(NODE_TYPE_AGENT, listenPort);
179 183
180 nodeList->moveToThread(_nodeThread);184 nodeList->moveToThread(_nodeThread);
181 _datagramProcessor->moveToThread(_nodeThread);185 _datagramProcessor.moveToThread(_nodeThread);
182 186
183 // connect the DataProcessor processDatagrams slot to the QUDPSocket readyRead() signal187 // connect the DataProcessor processDatagrams slot to the QUDPSocket readyRead() signal
184 connect(&nodeList->getNodeSocket(), SIGNAL(readyRead()), _datagramProcessor, SLOT(processDatagrams()));188 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();
191 189
192 // put the audio processing on a separate thread190 // put the audio processing on a separate thread
193 QThread* audioThread = new QThread(this);191 QThread* audioThread = new QThread(this);
@@ -231,12 +229,16 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 37 unmodified lines
231 #endif229 #endif
232 230
233 // tell the NodeList instance who to tell the domain server we care about231 // 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,232 nodeList->addSetOfNodeTypesToNodeInterestSet(QSet<NODE_TYPE>() << NODE_TYPE_AUDIO_MIXER << NODE_TYPE_AVATAR_MIXER
235 NODE_TYPE_PARTICLE_SERVER, NODE_TYPE_METAVOXEL_SERVER};233 << NODE_TYPE_VOXEL_SERVER << NODE_TYPE_PARTICLE_SERVER
236 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);
237 239
238 // move the silentNodeTimer to the _nodeThread240 // move the silentNodeTimer to the _nodeThread
239 QTimer* silentNodeTimer = new QTimer(this);241 QTimer* silentNodeTimer = new QTimer();
240 connect(silentNodeTimer, SIGNAL(timeout()), nodeList, SLOT(removeSilentNodes()));242 connect(silentNodeTimer, SIGNAL(timeout()), nodeList, SLOT(removeSilentNodes()));
241 silentNodeTimer->moveToThread(_nodeThread);243 silentNodeTimer->moveToThread(_nodeThread);
242 silentNodeTimer->start(NODE_SILENCE_THRESHOLD_USECS / 1000);244 silentNodeTimer->start(NODE_SILENCE_THRESHOLD_USECS / 1000);
@@ -282,17 +284,35 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 39 unmodified lines
282Application::~Application() {284Application::~Application() {
283 285
284 qInstallMessageHandler(NULL);286 qInstallMessageHandler(NULL);
285 287
286 // make sure we don't call the idle timer any more288 // make sure we don't call the idle timer any more
287 delete idleTimer;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 // ask the datagram processing thread to quit and wait until it is done299 // ask the datagram processing thread to quit and wait until it is done
290 _nodeThread->thread()->quit();300 _nodeThread->quit();
291 _nodeThread->thread()->wait();301 _nodeThread->wait();
292 302
293 // ask the audio thread to quit and wait until it is done303 // ask the audio thread to quit and wait until it is done
294 _audio.thread()->quit();304 _audio.thread()->quit();
295 _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 }
296 316
297 storeSizeAndPosition();317 storeSizeAndPosition();
298 saveScripts();318 saveScripts();
@@ -377,9 +397,6 @@ void Application::initializeGL() { · 78 unmodified lines
377 qDebug("Voxel parsing thread created.");397 qDebug("Voxel parsing thread created.");
378 }398 }
379 399
380 // call terminate before exiting
381 connect(this, SIGNAL(aboutToQuit()), SLOT(terminate()));
382
383 // call our timer function every second400 // call our timer function every second
384 QTimer* timer = new QTimer(this);401 QTimer* timer = new QTimer(this);
385 connect(timer, SIGNAL(timeout()), SLOT(timer()));402 connect(timer, SIGNAL(timeout()), SLOT(timer()));
@@ -628,21 +645,20 @@ void Application::resetProfile(const QString& username) { · 242 unmodified lines
628}645}
629 646
630void Application::controlledBroadcastToNodes(unsigned char* broadcastData, size_t dataBytes,647void Application::controlledBroadcastToNodes(unsigned char* broadcastData, size_t dataBytes,
631 const char* nodeTypes, int numNodeTypes) {648 const QSet<NODE_TYPE>& destinationNodeTypes) {
632 Application* self = getInstance();649 foreach(NODE_TYPE type, destinationNodeTypes) {
633 for (int i = 0; i < numNodeTypes; ++i) {
634
635 // Intercept data to voxel server when voxels are disabled650 // 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 continue;652 continue;
638 }653 }
639 654
640 // Perform the broadcast for one type655 // Perform the broadcast for one type
641 int nReceivingNodes = NodeList::getInstance()->broadcastToNodes(broadcastData, dataBytes, & nodeTypes[i], 1);656 int nReceivingNodes = NodeList::getInstance()->broadcastToNodes(broadcastData, dataBytes,
642 657 QSet<NODE_TYPE>() << type);
658
643 // 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)
644 BandwidthMeter::ChannelIndex channel;660 BandwidthMeter::ChannelIndex channel;
645 switch (nodeTypes[i]) {661 switch (type) {
646 case NODE_TYPE_AGENT:662 case NODE_TYPE_AGENT:
647 case NODE_TYPE_AVATAR_MIXER:663 case NODE_TYPE_AVATAR_MIXER:
648 channel = BandwidthMeter::AVATARS;664 channel = BandwidthMeter::AVATARS;
@@ -653,7 +669,7 @@ void Application::controlledBroadcastToNodes(unsigned char* broadcastData, size_ · 4 unmodified lines
653 default:669 default:
654 continue;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 _seenMouseMove = true;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 if (activeWindow() == _window) {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 // orbit behavior1161 // orbit behavior
1147 if (_mousePressed && !Menu::getInstance()->isVoxelModeActionChecked()) {1162 if (_mousePressed && !Menu::getInstance()->isVoxelModeActionChecked()) {
1148 if (_lookatTargetAvatar) {1163 if (_lookatTargetAvatar) {
@@ -1308,15 +1323,13 @@ void Application::wheelEvent(QWheelEvent* event) { · 159 unmodified lines
1308}1323}
1309 1324
1310void Application::sendPingPackets() {1325void 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 unsigned char pingPacket[MAX_PACKET_SIZE];1326 unsigned char pingPacket[MAX_PACKET_SIZE];
1316 int length = NodeList::getInstance()->fillPingPacket(pingPacket);1327 int length = NodeList::getInstance()->fillPingPacket(pingPacket);
1317 1328
1318 getInstance()->controlledBroadcastToNodes(pingPacket, length,1329 getInstance()->controlledBroadcastToNodes(pingPacket, length, QSet<NODE_TYPE>()
1319 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);
1320}1333}
1321 1334
1322// Every second, check the frame rates and other stuff1335// Every second, check the frame rates and other stuff
@@ -1329,11 +1342,11 @@ void Application::timer() { · 6 unmodified lines
1329 1342
1330 _fps = (float)_frameCount / ((float)diffclock(&_timerStart, &_timerEnd) / 1000.f);1343 _fps = (float)_frameCount / ((float)diffclock(&_timerStart, &_timerEnd) / 1000.f);
1331 1344
1332 _packetsPerSecond = (float) _datagramProcessor->getPacketCount() / ((float)diffclock(&_timerStart, &_timerEnd) / 1000.f);1345 _packetsPerSecond = (float) _datagramProcessor.getPacketCount() / ((float)diffclock(&_timerStart, &_timerEnd) / 1000.f);
1333 _bytesPerSecond = (float) _datagramProcessor->getByteCount() / ((float)diffclock(&_timerStart, &_timerEnd) / 1000.f);1346 _bytesPerSecond = (float) _datagramProcessor.getByteCount() / ((float)diffclock(&_timerStart, &_timerEnd) / 1000.f);
1334 _frameCount = 0;1347 _frameCount = 0;
1335 1348
1336 _datagramProcessor->resetCounters();1349 _datagramProcessor.resetCounters();
1337 1350
1338 gettimeofday(&_timerStart, NULL);1351 gettimeofday(&_timerStart, NULL);
1339 1352
@@ -1412,28 +1425,6 @@ void Application::idle() { · 72 unmodified lines
1412 }1425 }
1413}1426}
1414 1427
1415void 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
1437void Application::checkBandwidthMeterClick() {1428void Application::checkBandwidthMeterClick() {
1438 // ... to be called upon button release1429 // ... to be called upon button release
1439 1430
@@ -1857,25 +1848,23 @@ const float HEAD_SPHERE_RADIUS = 0.07f; · 417 unmodified lines
1857 1848
1858static QUuid DEFAULT_NODE_ID_REF;1849static QUuid DEFAULT_NODE_ID_REF;
1859 1850
1860void Application::updateLookatTargetAvatar(const glm::vec3& mouseRayOrigin, const glm::vec3& mouseRayDirection,1851void Application::updateLookatTargetAvatar(glm::vec3& eyePosition) {
1861 glm::vec3& eyePosition) {
1862 bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);1852 bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
1863 PerformanceWarning warn(showWarnings, "Application::updateLookatTargetAvatar()");1853 PerformanceWarning warn(showWarnings, "Application::updateLookatTargetAvatar()");
1864 1854
1865 if (!_mousePressed) {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
1870Avatar* Application::findLookatTargetAvatar(const glm::vec3& mouseRayOrigin, const glm::vec3& mouseRayDirection,1860Avatar* Application::findLookatTargetAvatar(glm::vec3& eyePosition, QUuid& nodeUUID = DEFAULT_NODE_ID_REF) {
1871 glm::vec3& eyePosition, QUuid& nodeUUID = DEFAULT_NODE_ID_REF) {
1872 1861
1873 foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) {1862 foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) {
1874 if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) {1863 if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) {
1875 Avatar* avatar = (Avatar*)node->getLinkedData();1864 Avatar* avatar = (Avatar*)node->getLinkedData();
1876 float distance;1865 float distance;
1877 1866
1878 if (avatar->findRayIntersection(mouseRayOrigin, mouseRayDirection, distance)) {1867 if (avatar->findRayIntersection(_mouseRayOrigin, _mouseRayDirection, distance)) {
1879 // rescale to compensate for head embiggening1868 // rescale to compensate for head embiggening
1880 eyePosition = (avatar->getHead().calculateAverageEyePosition() - avatar->getHead().getScalePivot()) *1869 eyePosition = (avatar->getHead().calculateAverageEyePosition() - avatar->getHead().getScalePivot()) *
1881 (avatar->getScale() / avatar->getHead().getScale()) + avatar->getHead().getScalePivot();1870 (avatar->getScale() / avatar->getHead().getScale()) + avatar->getHead().getScalePivot();
@@ -1926,7 +1915,7 @@ void Application::renderHighlightVoxel(VoxelDetail voxel) { · 44 unmodified lines
1926 glPopMatrix();1915 glPopMatrix();
1927}1916}
1928 1917
1929void Application::updateAvatars(float deltaTime, glm::vec3 mouseRayOrigin, glm::vec3 mouseRayDirection) {1918void Application::updateAvatars(float deltaTime) {
1930 bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);1919 bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
1931 PerformanceWarning warn(showWarnings, "Application::updateAvatars()");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 avatar->init();1927 avatar->init();
1939 }1928 }
1940 avatar->simulate(deltaTime, NULL);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
1964void Application::updateMouseRay(float deltaTime, glm::vec3& mouseRayOrigin, glm::vec3& mouseRayDirection) {1953void Application::updateMouseRay() {
1965 1954
1966 bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);1955 bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
1967 PerformanceWarning warn(showWarnings, "Application::updateMouseRay()");1956 PerformanceWarning warn(showWarnings, "Application::updateMouseRay()");
1968 1957
1969 _viewFrustum.computePickRay(_mouseX / (float)_glWidget->width(), _mouseY / (float)_glWidget->height(),1958 _viewFrustum.computePickRay(_mouseX / (float)_glWidget->width(), _mouseY / (float)_glWidget->height(),
1970 mouseRayOrigin, mouseRayDirection);1959 _mouseRayOrigin, _mouseRayDirection);
1971 1960
1972 // adjust for mirroring1961 // adjust for mirroring
1973 if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {1962 if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
1974 glm::vec3 mouseRayOffset = mouseRayOrigin - _viewFrustum.getPosition();1963 glm::vec3 mouseRayOffset = _mouseRayOrigin - _viewFrustum.getPosition();
1975 mouseRayOrigin -= 2.0f * (_viewFrustum.getDirection() * glm::dot(_viewFrustum.getDirection(), mouseRayOffset) +1964 _mouseRayOrigin -= 2.0f * (_viewFrustum.getDirection() * glm::dot(_viewFrustum.getDirection(), mouseRayOffset) +
1976 _viewFrustum.getRight() * glm::dot(_viewFrustum.getRight(), mouseRayOffset));1965 _viewFrustum.getRight() * glm::dot(_viewFrustum.getRight(), mouseRayOffset));
1977 mouseRayDirection -= 2.0f * (_viewFrustum.getDirection() * glm::dot(_viewFrustum.getDirection(), mouseRayDirection) +1966 _mouseRayDirection -= 2.0f * (_viewFrustum.getDirection() * glm::dot(_viewFrustum.getDirection(), _mouseRayDirection) +
1978 _viewFrustum.getRight() * glm::dot(_viewFrustum.getRight(), mouseRayDirection));1967 _viewFrustum.getRight() * glm::dot(_viewFrustum.getRight(), _mouseRayDirection));
1979 }1968 }
1980 1969
1981 // tell my avatar if the mouse is being pressed...1970 // tell my avatar if the mouse is being pressed...
1982 _myAvatar.setMousePressed(_mousePressed);1971 _myAvatar.setMousePressed(_mousePressed);
1983 1972
1984 // tell my avatar the posiion and direction of the ray projected ino the world based on the mouse position1973 // 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
1988void Application::updateFaceshift() {1977void Application::updateFaceshift() {
@@ -1999,8 +1988,7 @@ void Application::updateFaceshift() { · 10 unmodified lines
1999 }1988 }
2000}1989}
2001 1990
2002void Application::updateMyAvatarLookAtPosition(glm::vec3& lookAtSpot, glm::vec3& lookAtRayOrigin,1991void Application::updateMyAvatarLookAtPosition(glm::vec3& lookAtSpot) {
2003 glm::vec3& lookAtRayDirection) {
2004 1992
2005 bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);1993 bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
2006 PerformanceWarning warn(showWarnings, "Application::updateMyAvatarLookAtPosition()");1994 PerformanceWarning warn(showWarnings, "Application::updateMyAvatarLookAtPosition()");
@@ -2015,15 +2003,9 @@ void Application::updateMyAvatarLookAtPosition(glm::vec3& lookAtSpot, glm::vec3& · 8 unmodified lines
2015 _viewFrustum.computePickRay(0.5f, 0.5f, rayOrigin, rayDirection);2003 _viewFrustum.computePickRay(0.5f, 0.5f, rayOrigin, rayDirection);
2016 lookAtSpot = rayOrigin + rayDirection * FAR_AWAY_STARE;2004 lookAtSpot = rayOrigin + rayDirection * FAR_AWAY_STARE;
2017 2005
2018 } else if (!_lookatTargetAvatar) {2006 } else {
2019 if (_isHoverVoxel) {2007 // just look in direction of the mouse ray
2020 // Look at the hovered voxel2008 lookAtSpot = _mouseRayOrigin + _mouseRayDirection * FAR_AWAY_STARE;
2021 lookAtSpot = getMouseVoxelWorldCoordinates(_hoverVoxel);
2022
2023 } else {
2024 // Just look in direction of the mouse ray
2025 lookAtSpot = lookAtRayOrigin + lookAtRayDirection * FAR_AWAY_STARE;
2026 }
2027 }2009 }
2028 if (_faceshift.isActive()) {2010 if (_faceshift.isActive()) {
2029 // deflect using Faceshift gaze data2011 // deflect using Faceshift gaze data
@@ -2037,8 +2019,7 @@ void Application::updateMyAvatarLookAtPosition(glm::vec3& lookAtSpot, glm::vec3& · 7 unmodified lines
2037 _myAvatar.getHead().setLookAtPosition(lookAtSpot);2019 _myAvatar.getHead().setLookAtPosition(lookAtSpot);
2038}2020}
2039 2021
2040void Application::updateHoverVoxels(float deltaTime, glm::vec3& mouseRayOrigin, glm::vec3& mouseRayDirection,2022void Application::updateHoverVoxels(float deltaTime, float& distance, BoxFace& face) {
2041 float& distance, BoxFace& face) {
2042 2023
2043 bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);2024 bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
2044 PerformanceWarning warn(showWarnings, "Application::updateHoverVoxels()");2025 PerformanceWarning warn(showWarnings, "Application::updateHoverVoxels()");
@@ -2069,7 +2050,7 @@ void Application::updateHoverVoxels(float deltaTime, glm::vec3& mouseRayOrigin, · 24 unmodified lines
2069 if (!(_voxels.treeIsBusy() || _mousePressed)) {2050 if (!(_voxels.treeIsBusy() || _mousePressed)) {
2070 {2051 {
2071 PerformanceWarning warn(showWarnings, "Application::updateHoverVoxels() _voxels.findRayIntersection()");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 if (MAKE_SOUND_ON_VOXEL_HOVER && _isHoverVoxel &&2055 if (MAKE_SOUND_ON_VOXEL_HOVER && _isHoverVoxel &&
2075 glm::vec4(_hoverVoxel.x, _hoverVoxel.y, _hoverVoxel.z, _hoverVoxel.s) != oldVoxel) {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
2088void Application::updateMouseVoxels(float deltaTime, glm::vec3& mouseRayOrigin, glm::vec3& mouseRayDirection,2069void Application::updateMouseVoxels(float deltaTime, float& distance, BoxFace& face) {
2089 float& distance, BoxFace& face) {
2090 2070
2091 bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);2071 bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
2092 PerformanceWarning warn(showWarnings, "Application::updateMouseVoxels()");2072 PerformanceWarning warn(showWarnings, "Application::updateMouseVoxels()");
@@ -2098,7 +2078,7 @@ void Application::updateMouseVoxels(float deltaTime, glm::vec3& mouseRayOrigin, · 5 unmodified lines
2098 fabs(_myAvatar.getVelocity().y) +2078 fabs(_myAvatar.getVelocity().y) +
2099 fabs(_myAvatar.getVelocity().z)) / 3 < MAX_AVATAR_EDIT_VELOCITY) {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 if (distance < MAX_VOXEL_EDIT_DISTANCE) {2082 if (distance < MAX_VOXEL_EDIT_DISTANCE) {
2103 // set the voxel scale to that of the first moused-over voxel2083 // set the voxel scale to that of the first moused-over voxel
2104 if (!wasInitialized) {2084 if (!wasInitialized) {
@@ -2118,7 +2098,7 @@ void Application::updateMouseVoxels(float deltaTime, glm::vec3& mouseRayOrigin, · 13 unmodified lines
2118 glm::vec3 faceVector = getFaceVector(face);2098 glm::vec3 faceVector = getFaceVector(face);
2119 if (_mouseVoxelScale < _mouseVoxel.s) {2099 if (_mouseVoxelScale < _mouseVoxel.s) {
2120 // find the closest contained voxel2100 // 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 faceVector * (_mouseVoxelScale * 0.5f);2102 faceVector * (_mouseVoxelScale * 0.5f);
2123 _mouseVoxel.x = _mouseVoxelScale * floorf(pt.x / _mouseVoxelScale);2103 _mouseVoxel.x = _mouseVoxelScale * floorf(pt.x / _mouseVoxelScale);
2124 _mouseVoxel.y = _mouseVoxelScale * floorf(pt.y / _mouseVoxelScale);2104 _mouseVoxel.y = _mouseVoxelScale * floorf(pt.y / _mouseVoxelScale);
@@ -2139,7 +2119,7 @@ void Application::updateMouseVoxels(float deltaTime, glm::vec3& mouseRayOrigin, · 14 unmodified lines
2139 || Menu::getInstance()->isOptionChecked(MenuOption::VoxelSelectMode)) {2119 || Menu::getInstance()->isOptionChecked(MenuOption::VoxelSelectMode)) {
2140 // place the voxel a fixed distance away2120 // place the voxel a fixed distance away
2141 float worldMouseVoxelScale = _mouseVoxelScale * TREE_SCALE;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 _mouseVoxel.x = _mouseVoxelScale * floorf(pt.x / worldMouseVoxelScale);2123 _mouseVoxel.x = _mouseVoxelScale * floorf(pt.x / worldMouseVoxelScale);
2144 _mouseVoxel.y = _mouseVoxelScale * floorf(pt.y / worldMouseVoxelScale);2124 _mouseVoxel.y = _mouseVoxelScale * floorf(pt.y / worldMouseVoxelScale);
2145 _mouseVoxel.z = _mouseVoxelScale * floorf(pt.z / worldMouseVoxelScale);2125 _mouseVoxel.z = _mouseVoxelScale * floorf(pt.z / worldMouseVoxelScale);
@@ -2373,29 +2353,28 @@ void Application::update(float deltaTime) { · 227 unmodified lines
2373 PerformanceWarning warn(showWarnings, "Application::update()");2353 PerformanceWarning warn(showWarnings, "Application::update()");
2374 2354
2375 // check what's under the mouse and update the mouse voxel2355 // check what's under the mouse and update the mouse voxel
2376 glm::vec3 mouseRayOrigin, mouseRayDirection;2356 updateMouseRay();
2377 updateMouseRay(deltaTime, mouseRayOrigin, mouseRayDirection);
2378 2357
2379 // 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)
2380 glm::vec3 lookAtSpot;2359 glm::vec3 lookAtSpot;
2381 2360
2382 updateFaceshift();2361 updateFaceshift();
2383 updateLookatTargetAvatar(mouseRayOrigin, mouseRayDirection, lookAtSpot);2362 updateLookatTargetAvatar(lookAtSpot);
2384 updateMyAvatarLookAtPosition(lookAtSpot, mouseRayOrigin, mouseRayDirection);2363 updateMyAvatarLookAtPosition(lookAtSpot);
2385 2364
2386 // Find the voxel we are hovering over, and respond if clicked2365 // Find the voxel we are hovering over, and respond if clicked
2387 float distance;2366 float distance;
2388 BoxFace face;2367 BoxFace face;
2389 2368
2390 updateHoverVoxels(deltaTime, mouseRayOrigin, mouseRayDirection, distance, face); // clicking on voxels and making sounds2369 updateHoverVoxels(deltaTime, distance, face); // clicking on voxels and making sounds
2391 updateMouseVoxels(deltaTime, mouseRayOrigin, mouseRayDirection, distance, face); // UI/UX related to voxels2370 updateMouseVoxels(deltaTime, distance, face); // UI/UX related to voxels
2392 updateHandAndTouch(deltaTime); // Update state for touch sensors2371 updateHandAndTouch(deltaTime); // Update state for touch sensors
2393 updateLeap(deltaTime); // Leap finger-sensing device2372 updateLeap(deltaTime); // Leap finger-sensing device
2394 updateSixense(deltaTime); // Razer Hydra controllers2373 updateSixense(deltaTime); // Razer Hydra controllers
2395 updateSerialDevices(deltaTime); // Read serial port interface devices2374 updateSerialDevices(deltaTime); // Read serial port interface devices
2396 updateAvatar(deltaTime); // Sample hardware, update view frustum if needed, and send avatar data to mixer/nodes2375 updateAvatar(deltaTime); // Sample hardware, update view frustum if needed, and send avatar data to mixer/nodes
2397 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...
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 updateMyAvatarSimulation(deltaTime); // Simulate myself2378 updateMyAvatarSimulation(deltaTime); // Simulate myself
2400 updateParticles(deltaTime); // Simulate particle cloud movements2379 updateParticles(deltaTime); // Simulate particle cloud movements
2401 updateMetavoxels(deltaTime); // update metavoxels2380 updateMetavoxels(deltaTime); // update metavoxels
@@ -2466,9 +2445,8 @@ void Application::updateAvatar(float deltaTime) { · 64 unmodified lines
2466 2445
2467 endOfBroadcastStringWrite += _myAvatar.getBroadcastData(endOfBroadcastStringWrite);2446 endOfBroadcastStringWrite += _myAvatar.getBroadcastData(endOfBroadcastStringWrite);
2468 2447
2469 const char nodeTypesOfInterest[] = { NODE_TYPE_AVATAR_MIXER };
2470 controlledBroadcastToNodes(broadcastString, endOfBroadcastStringWrite - broadcastString,2448 controlledBroadcastToNodes(broadcastString, endOfBroadcastStringWrite - broadcastString,
2471 nodeTypesOfInterest, sizeof(nodeTypesOfInterest));2449 QSet<NODE_TYPE>() << NODE_TYPE_AVATAR_MIXER);
2472 2450
2473 // Update _viewFrustum with latest camera and view frustum data...2451 // Update _viewFrustum with latest camera and view frustum data...
2474 // NOTE: we get this from the view frustum, to make it simpler, since the2452 // 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 if (!selfAvatarOnly) {2858 if (!selfAvatarOnly) {
2881 // draw a red sphere2859 // draw a red sphere
2882 float sphereRadius = 0.25f;2860 float originSphereRadius = 0.05f;
2883 glColor3f(1,0,0);2861 glColor3f(1,0,0);
2884 glPushMatrix();2862 glPushMatrix();
2885 glutSolidSphere(sphereRadius, 15, 15);2863 glutSolidSphere(originSphereRadius, 15, 15);
2886 glPopMatrix();2864 glPopMatrix();
2887 2865
2888 // disable specular lighting for ground and voxels2866 // disable specular lighting for ground and voxels
@@ -3045,6 +3023,9 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 156 unmodified lines
3045 3023
3046 glPopMatrix();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 return statsMessageLength;4134 return statsMessageLength;
4154}4135}
4155 4136
4156void Application::packetSentNotification(ssize_t length) {4137void Application::packetSent(quint64 length) {
4157 _bandwidthMeter.outputStream(BandwidthMeter::VOXELS).updateValue(length);4138 _bandwidthMeter.outputStream(BandwidthMeter::VOXELS).updateValue(length);
4158}4139}
4159 4140

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t