History

Merging with master

- resolve conflicts on GeometryCache

stojce committed 12 years ago

Commit 0c2e55a2 parents becbd4c 4296e5e64 files · +1440 −794Browse files

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

Unified · Split

interface/src/Application.cpp+110−199
@@ -108,6 +108,8 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 107 unmodified lines
108108 QApplication(argc, argv),
109109 _window(new QMainWindow(desktop())),
110110 _glWidget(new GLCanvas()),
111+ _nodeThread(new QThread(this)),
112+ _datagramProcessor(),
111113 _frameCount(0),
112114 _fps(120.0f),
113115 _justStarted(true),
@@ -143,12 +145,8 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 29 unmodified lines
143145 _enableProcessVoxelsThread(true),
144146 _voxelProcessor(),
145147 _voxelHideShowThread(&_voxels),
146− _voxelEditSender(this),
147− _particleEditSender(this),
148− _packetCount(0),
149148 _packetsPerSecond(0),
150149 _bytesPerSecond(0),
151− _bytesCount(0),
152150 _recentMaxPackets(0),
153151 _resetRecentMaxPacketsSoon(true),
154152 _swatch(NULL),
@@ -173,11 +171,21 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 18 unmodified lines
173171 if (portStr) {
174172 listenPort = atoi(portStr);
175173 }
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
177182 NodeList* nodeList = NodeList::createInstance(NODE_TYPE_AGENT, listenPort);
178−
179− // connect our processDatagrams slot to the QUDPSocket readyRead() signal
180− connect(&nodeList->getNodeSocket(), SIGNAL(readyRead()), SLOT(processDatagrams()));
183+
184+ nodeList->moveToThread(_nodeThread);
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()));
181189
182190 // put the audio processing on a separate thread
183191 QThread* audioThread = new QThread(this);
@@ -192,7 +200,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 8 unmodified lines
192200 connect(nodeList, SIGNAL(nodeKilled(SharedNodePointer)), SLOT(nodeKilled(SharedNodePointer)));
193201 connect(nodeList, SIGNAL(nodeAdded(SharedNodePointer)), &_voxels, SLOT(nodeAdded(SharedNodePointer)));
194202 connect(nodeList, SIGNAL(nodeKilled(SharedNodePointer)), &_voxels, SLOT(nodeKilled(SharedNodePointer)));
195−
203+
196204 // read the ApplicationInfo.ini file for Name/Version/Domain information
197205 QSettings applicationInfo("resources/info/ApplicationInfo.ini", QSettings::IniFormat);
198206
@@ -221,12 +229,18 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 22 unmodified lines
221229 #endif
222230
223231 // 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,
225− NODE_TYPE_PARTICLE_SERVER, NODE_TYPE_METAVOXEL_SERVER};
226− 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);
227239
228− QTimer* silentNodeTimer = new QTimer(this);
240+ // move the silentNodeTimer to the _nodeThread
241+ QTimer* silentNodeTimer = new QTimer();
229242 connect(silentNodeTimer, SIGNAL(timeout()), nodeList, SLOT(removeSilentNodes()));
243+ silentNodeTimer->moveToThread(_nodeThread);
230244 silentNodeTimer->start(NODE_SILENCE_THRESHOLD_USECS / 1000);
231245
232246 QString cachePath = QStandardPaths::writableLocation(QStandardPaths::DataLocation);
@@ -270,13 +284,35 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 37 unmodified lines
270284 Application::~Application() {
271285
272286 qInstallMessageHandler(NULL);
273−
287+
274288 // make sure we don't call the idle timer any more
275289 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+
277303 // ask the audio thread to quit and wait until it is done
278304 _audio.thread()->quit();
279305 _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+ }
280316
281317 storeSizeAndPosition();
282318 saveScripts();
@@ -361,9 +397,6 @@ void Application::initializeGL() { · 78 unmodified lines
361397 qDebug("Voxel parsing thread created.");
362398 }
363399
364− // call terminate before exiting
365− connect(this, SIGNAL(aboutToQuit()), SLOT(terminate()));
366−
367400 // call our timer function every second
368401 QTimer* timer = new QTimer(this);
369402 connect(timer, SIGNAL(timeout()), SLOT(timer()));
@@ -612,21 +645,20 @@ void Application::resetProfile(const QString& username) { · 242 unmodified lines
612645 }
613646
614647 void Application::controlledBroadcastToNodes(unsigned char* broadcastData, size_t dataBytes,
615− const char* nodeTypes, int numNodeTypes) {
616− Application* self = getInstance();
617− for (int i = 0; i < numNodeTypes; ++i) {
618−
648+ const QSet<NODE_TYPE>& destinationNodeTypes) {
649+ foreach(NODE_TYPE type, destinationNodeTypes) {
619650 // 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)) {
621652 continue;
622653 }
623−
654+
624655 // Perform the broadcast for one type
625− int nReceivingNodes = NodeList::getInstance()->broadcastToNodes(broadcastData, dataBytes, & nodeTypes[i], 1);
626−
656+ int nReceivingNodes = NodeList::getInstance()->broadcastToNodes(broadcastData, dataBytes,
657+ QSet<NODE_TYPE>() << type);
658+
627659 // Feed number of bytes to corresponding channel of the bandwidth meter, if any (done otherwise)
628660 BandwidthMeter::ChannelIndex channel;
629− switch (nodeTypes[i]) {
661+ switch (type) {
630662 case NODE_TYPE_AGENT:
631663 case NODE_TYPE_AVATAR_MIXER:
632664 channel = BandwidthMeter::AVATARS;
@@ -637,7 +669,7 @@ void Application::controlledBroadcastToNodes(unsigned char* broadcastData, size_ · 4 unmodified lines
637669 default:
638670 continue;
639671 }
640− self->_bandwidthMeter.outputStream(channel).updateValue(nReceivingNodes * dataBytes);
672+ _bandwidthMeter.outputStream(channel).updateValue(nReceivingNodes * dataBytes);
641673 }
642674 }
643675
@@ -1120,13 +1152,12 @@ void Application::mouseMoveEvent(QMouseEvent* event) { · 476 unmodified lines
11201152 _seenMouseMove = true;
11211153 }
11221154
1155+ int deltaX = event->x() - _mouseX;
1156+ int deltaY = event->y() - _mouseY;
1157+ _mouseX = event->x();
1158+ _mouseY = event->y();
1159+
11231160 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−
11301161 // orbit behavior
11311162 if (_mousePressed && !Menu::getInstance()->isVoxelModeActionChecked()) {
11321163 if (_lookatTargetAvatar) {
@@ -1292,15 +1323,13 @@ void Application::wheelEvent(QWheelEvent* event) { · 159 unmodified lines
12921323 }
12931324
12941325 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−
12991326 unsigned char pingPacket[MAX_PACKET_SIZE];
13001327 int length = NodeList::getInstance()->fillPingPacket(pingPacket);
13011328
1302− getInstance()->controlledBroadcastToNodes(pingPacket, length,
1303− 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);
13041333 }
13051334
13061335 // Every second, check the frame rates and other stuff
@@ -1312,11 +1341,12 @@ void Application::timer() { · 5 unmodified lines
13121341 }
13131342
13141343 _fps = (float)_frameCount / ((float)diffclock(&_timerStart, &_timerEnd) / 1000.f);
1315− _packetsPerSecond = (float)_packetCount / ((float)diffclock(&_timerStart, &_timerEnd) / 1000.f);
1316− _bytesPerSecond = (float)_bytesCount / ((float)diffclock(&_timerStart, &_timerEnd) / 1000.f);
1344+
1345+ _packetsPerSecond = (float) _datagramProcessor.getPacketCount() / ((float)diffclock(&_timerStart, &_timerEnd) / 1000.f);
1346+ _bytesPerSecond = (float) _datagramProcessor.getByteCount() / ((float)diffclock(&_timerStart, &_timerEnd) / 1000.f);
13171347 _frameCount = 0;
1318− _packetCount = 0;
1319− _bytesCount = 0;
1348+
1349+ _datagramProcessor.resetCounters();
13201350
13211351 gettimeofday(&_timerStart, NULL);
13221352
@@ -1395,28 +1425,6 @@ void Application::idle() { · 72 unmodified lines
13951425 }
13961426 }
13971427
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−
14201428 void Application::checkBandwidthMeterClick() {
14211429 // ... to be called upon button release
14221430
@@ -1840,25 +1848,23 @@ const float HEAD_SPHERE_RADIUS = 0.07f; · 417 unmodified lines
18401848
18411849 static QUuid DEFAULT_NODE_ID_REF;
18421850
1843−void Application::updateLookatTargetAvatar(const glm::vec3& mouseRayOrigin, const glm::vec3& mouseRayDirection,
1844− glm::vec3& eyePosition) {
1851+void Application::updateLookatTargetAvatar(glm::vec3& eyePosition) {
18451852 bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
18461853 PerformanceWarning warn(showWarnings, "Application::updateLookatTargetAvatar()");
18471854
18481855 if (!_mousePressed) {
1849− _lookatTargetAvatar = findLookatTargetAvatar(mouseRayOrigin, mouseRayDirection, eyePosition, DEFAULT_NODE_ID_REF);
1856+ _lookatTargetAvatar = findLookatTargetAvatar(eyePosition, DEFAULT_NODE_ID_REF);
18501857 }
18511858 }
18521859
1853−Avatar* Application::findLookatTargetAvatar(const glm::vec3& mouseRayOrigin, const glm::vec3& mouseRayDirection,
1854− glm::vec3& eyePosition, QUuid& nodeUUID = DEFAULT_NODE_ID_REF) {
1860+Avatar* Application::findLookatTargetAvatar(glm::vec3& eyePosition, QUuid& nodeUUID = DEFAULT_NODE_ID_REF) {
18551861
18561862 foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) {
18571863 if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) {
18581864 Avatar* avatar = (Avatar*)node->getLinkedData();
18591865 float distance;
18601866
1861− if (avatar->findRayIntersection(mouseRayOrigin, mouseRayDirection, distance)) {
1867+ if (avatar->findRayIntersection(_mouseRayOrigin, _mouseRayDirection, distance)) {
18621868 // rescale to compensate for head embiggening
18631869 eyePosition = (avatar->getHead().calculateAverageEyePosition() - avatar->getHead().getScalePivot()) *
18641870 (avatar->getScale() / avatar->getHead().getScale()) + avatar->getHead().getScalePivot();
@@ -1909,7 +1915,7 @@ void Application::renderHighlightVoxel(VoxelDetail voxel) { · 44 unmodified lines
19091915 glPopMatrix();
19101916 }
19111917
1912−void Application::updateAvatars(float deltaTime, glm::vec3 mouseRayOrigin, glm::vec3 mouseRayDirection) {
1918+void Application::updateAvatars(float deltaTime) {
19131919 bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
19141920 PerformanceWarning warn(showWarnings, "Application::updateAvatars()");
19151921
@@ -1921,7 +1927,7 @@ void Application::updateAvatars(float deltaTime, glm::vec3 mouseRayOrigin, glm:: · 5 unmodified lines
19211927 avatar->init();
19221928 }
19231929 avatar->simulate(deltaTime, NULL);
1924− avatar->setMouseRay(mouseRayOrigin, mouseRayDirection);
1930+ avatar->setMouseRay(_mouseRayOrigin, _mouseRayDirection);
19251931 }
19261932 }
19271933
@@ -1944,28 +1950,28 @@ void Application::updateAvatars(float deltaTime, glm::vec3 mouseRayOrigin, glm:: · 16 unmodified lines
19441950 }
19451951 }
19461952
1947−void Application::updateMouseRay(float deltaTime, glm::vec3& mouseRayOrigin, glm::vec3& mouseRayDirection) {
1953+void Application::updateMouseRay() {
19481954
19491955 bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
19501956 PerformanceWarning warn(showWarnings, "Application::updateMouseRay()");
19511957
19521958 _viewFrustum.computePickRay(_mouseX / (float)_glWidget->width(), _mouseY / (float)_glWidget->height(),
1953− mouseRayOrigin, mouseRayDirection);
1959+ _mouseRayOrigin, _mouseRayDirection);
19541960
19551961 // adjust for mirroring
19561962 if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
1957− glm::vec3 mouseRayOffset = mouseRayOrigin - _viewFrustum.getPosition();
1958− 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) +
19591965 _viewFrustum.getRight() * glm::dot(_viewFrustum.getRight(), mouseRayOffset));
1960− mouseRayDirection -= 2.0f * (_viewFrustum.getDirection() * glm::dot(_viewFrustum.getDirection(), mouseRayDirection) +
1961− _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));
19621968 }
19631969
19641970 // tell my avatar if the mouse is being pressed...
19651971 _myAvatar.setMousePressed(_mousePressed);
19661972
19671973 // 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);
19691975 }
19701976
19711977 void Application::updateFaceshift() {
@@ -1982,8 +1988,7 @@ void Application::updateFaceshift() { · 10 unmodified lines
19821988 }
19831989 }
19841990
1985−void Application::updateMyAvatarLookAtPosition(glm::vec3& lookAtSpot, glm::vec3& lookAtRayOrigin,
1986− glm::vec3& lookAtRayDirection) {
1991+void Application::updateMyAvatarLookAtPosition(glm::vec3& lookAtSpot) {
19871992
19881993 bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
19891994 PerformanceWarning warn(showWarnings, "Application::updateMyAvatarLookAtPosition()");
@@ -1998,15 +2003,9 @@ void Application::updateMyAvatarLookAtPosition(glm::vec3& lookAtSpot, glm::vec3& · 8 unmodified lines
19982003 _viewFrustum.computePickRay(0.5f, 0.5f, rayOrigin, rayDirection);
19992004 lookAtSpot = rayOrigin + rayDirection * FAR_AWAY_STARE;
20002005
2001− } else if (!_lookatTargetAvatar) {
2002− if (_isHoverVoxel) {
2003− // Look at the hovered voxel
2004− lookAtSpot = getMouseVoxelWorldCoordinates(_hoverVoxel);
2005−
2006− } else {
2007− // Just look in direction of the mouse ray
2008− lookAtSpot = lookAtRayOrigin + lookAtRayDirection * FAR_AWAY_STARE;
2009− }
2006+ } else {
2007+ // just look in direction of the mouse ray
2008+ lookAtSpot = _mouseRayOrigin + _mouseRayDirection * FAR_AWAY_STARE;
20102009 }
20112010 if (_faceshift.isActive()) {
20122011 // deflect using Faceshift gaze data
@@ -2020,8 +2019,7 @@ void Application::updateMyAvatarLookAtPosition(glm::vec3& lookAtSpot, glm::vec3& · 7 unmodified lines
20202019 _myAvatar.getHead().setLookAtPosition(lookAtSpot);
20212020 }
20222021
2023−void Application::updateHoverVoxels(float deltaTime, glm::vec3& mouseRayOrigin, glm::vec3& mouseRayDirection,
2024− float& distance, BoxFace& face) {
2022+void Application::updateHoverVoxels(float deltaTime, float& distance, BoxFace& face) {
20252023
20262024 bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
20272025 PerformanceWarning warn(showWarnings, "Application::updateHoverVoxels()");
@@ -2052,7 +2050,7 @@ void Application::updateHoverVoxels(float deltaTime, glm::vec3& mouseRayOrigin, · 24 unmodified lines
20522050 if (!(_voxels.treeIsBusy() || _mousePressed)) {
20532051 {
20542052 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);
20562054 }
20572055 if (MAKE_SOUND_ON_VOXEL_HOVER && _isHoverVoxel &&
20582056 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
20682066 }
20692067 }
20702068
2071−void Application::updateMouseVoxels(float deltaTime, glm::vec3& mouseRayOrigin, glm::vec3& mouseRayDirection,
2072− float& distance, BoxFace& face) {
2069+void Application::updateMouseVoxels(float deltaTime, float& distance, BoxFace& face) {
20732070
20742071 bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
20752072 PerformanceWarning warn(showWarnings, "Application::updateMouseVoxels()");
@@ -2081,7 +2078,7 @@ void Application::updateMouseVoxels(float deltaTime, glm::vec3& mouseRayOrigin, · 5 unmodified lines
20812078 fabs(_myAvatar.getVelocity().y) +
20822079 fabs(_myAvatar.getVelocity().z)) / 3 < MAX_AVATAR_EDIT_VELOCITY) {
20832080
2084− if (_voxels.findRayIntersection(mouseRayOrigin, mouseRayDirection, _mouseVoxel, distance, face)) {
2081+ if (_voxels.findRayIntersection(_mouseRayOrigin, _mouseRayDirection, _mouseVoxel, distance, face)) {
20852082 if (distance < MAX_VOXEL_EDIT_DISTANCE) {
20862083 // set the voxel scale to that of the first moused-over voxel
20872084 if (!wasInitialized) {
@@ -2101,7 +2098,7 @@ void Application::updateMouseVoxels(float deltaTime, glm::vec3& mouseRayOrigin, · 13 unmodified lines
21012098 glm::vec3 faceVector = getFaceVector(face);
21022099 if (_mouseVoxelScale < _mouseVoxel.s) {
21032100 // 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 -
21052102 faceVector * (_mouseVoxelScale * 0.5f);
21062103 _mouseVoxel.x = _mouseVoxelScale * floorf(pt.x / _mouseVoxelScale);
21072104 _mouseVoxel.y = _mouseVoxelScale * floorf(pt.y / _mouseVoxelScale);
@@ -2122,7 +2119,7 @@ void Application::updateMouseVoxels(float deltaTime, glm::vec3& mouseRayOrigin, · 14 unmodified lines
21222119 || Menu::getInstance()->isOptionChecked(MenuOption::VoxelSelectMode)) {
21232120 // place the voxel a fixed distance away
21242121 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);
21262123 _mouseVoxel.x = _mouseVoxelScale * floorf(pt.x / worldMouseVoxelScale);
21272124 _mouseVoxel.y = _mouseVoxelScale * floorf(pt.y / worldMouseVoxelScale);
21282125 _mouseVoxel.z = _mouseVoxelScale * floorf(pt.z / worldMouseVoxelScale);
@@ -2356,29 +2353,28 @@ void Application::update(float deltaTime) { · 227 unmodified lines
23562353 PerformanceWarning warn(showWarnings, "Application::update()");
23572354
23582355 // check what's under the mouse and update the mouse voxel
2359− glm::vec3 mouseRayOrigin, mouseRayDirection;
2360− updateMouseRay(deltaTime, mouseRayOrigin, mouseRayDirection);
2356+ updateMouseRay();
23612357
23622358 // Set where I am looking based on my mouse ray (so that other people can see)
23632359 glm::vec3 lookAtSpot;
23642360
23652361 updateFaceshift();
2366− updateLookatTargetAvatar(mouseRayOrigin, mouseRayDirection, lookAtSpot);
2367− updateMyAvatarLookAtPosition(lookAtSpot, mouseRayOrigin, mouseRayDirection);
2362+ updateLookatTargetAvatar(lookAtSpot);
2363+ updateMyAvatarLookAtPosition(lookAtSpot);
23682364
23692365 // Find the voxel we are hovering over, and respond if clicked
23702366 float distance;
23712367 BoxFace face;
23722368
2373− updateHoverVoxels(deltaTime, mouseRayOrigin, mouseRayDirection, distance, face); // clicking on voxels and making sounds
2374− 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
23752371 updateHandAndTouch(deltaTime); // Update state for touch sensors
23762372 updateLeap(deltaTime); // Leap finger-sensing device
23772373 updateSixense(deltaTime); // Razer Hydra controllers
23782374 updateSerialDevices(deltaTime); // Read serial port interface devices
23792375 updateAvatar(deltaTime); // Sample hardware, update view frustum if needed, and send avatar data to mixer/nodes
23802376 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...
23822378 updateMyAvatarSimulation(deltaTime); // Simulate myself
23832379 updateParticles(deltaTime); // Simulate particle cloud movements
23842380 updateMetavoxels(deltaTime); // update metavoxels
@@ -2449,9 +2445,8 @@ void Application::updateAvatar(float deltaTime) { · 64 unmodified lines
24492445
24502446 endOfBroadcastStringWrite += _myAvatar.getBroadcastData(endOfBroadcastStringWrite);
24512447
2452− const char nodeTypesOfInterest[] = { NODE_TYPE_AVATAR_MIXER };
24532448 controlledBroadcastToNodes(broadcastString, endOfBroadcastStringWrite - broadcastString,
2454− nodeTypesOfInterest, sizeof(nodeTypesOfInterest));
2449+ QSet<NODE_TYPE>() << NODE_TYPE_AVATAR_MIXER);
24552450
24562451 // Update _viewFrustum with latest camera and view frustum data...
24572452 // 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
28622857
28632858 if (!selfAvatarOnly) {
28642859 // draw a red sphere
2865− float sphereRadius = 0.25f;
2860+ float originSphereRadius = 0.05f;
28662861 glColor3f(1,0,0);
28672862 glPushMatrix();
2868− glutSolidSphere(sphereRadius, 15, 15);
2863+ glutSolidSphere(originSphereRadius, 15, 15);
28692864 glPopMatrix();
28702865
28712866 // disable specular lighting for ground and voxels
@@ -3028,6 +3023,9 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 156 unmodified lines
30283023
30293024 glPopMatrix();
30303025 }
3026+
3027+ // give external parties a change to hook in
3028+ emit renderingInWorldInterface();
30313029 }
30323030 }
30333031
@@ -4052,94 +4050,7 @@ int Application::parseOctreeStats(unsigned char* messageData, ssize_t messageLen · 1018 unmodified lines
40524050 return statsMessageLength;
40534051 }
40544052
4055−// Receive packets from other nodes/servers and decide what to do with them!
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) {
4053+void Application::packetSent(quint64 length) {
41434054 _bandwidthMeter.outputStream(BandwidthMeter::VOXELS).updateValue(length);
41444055 }
41454056

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