History

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

Brad Hefta-Gaub committed 12 years ago

Commit d4331db2 parents 43da1ed bb41fe6386 files · +11197 −98919Browse files

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

Unified · Split

interface/src/Application.cpp+269−448
@@ -5,10 +5,16 @@ · 4 unmodified lines
55 // Created by Andrzej Kapolka on 5/10/13.
66 // Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
77
8+#ifdef WIN32
9+#include <Systime.h>
10+#endif
11+
812 #include <sstream>
913
1014 #include <stdlib.h>
1115 #include <cmath>
16+#include <math.h>
17+
1218
1319 #include <glm/gtx/component_wise.hpp>
1420 #include <glm/gtx/quaternion.hpp>
@@ -55,7 +61,6 @@ · 40 unmodified lines
5561 #include "Menu.h"
5662 #include "Swatch.h"
5763 #include "Util.h"
58−#include "devices/LeapManager.h"
5964 #include "devices/OculusManager.h"
6065 #include "devices/TV3DManager.h"
6166 #include "renderer/ProgramObject.h"
@@ -86,17 +91,16 @@ const float MIRROR_FULLSCREEN_DISTANCE = 0.35f; · 24 unmodified lines
8691 const float MIRROR_REARVIEW_DISTANCE = 0.65f;
8792 const float MIRROR_REARVIEW_BODY_DISTANCE = 2.3f;
8893
89−
9094 void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString &message) {
91− fprintf(stdout, "%s", message.toLocal8Bit().constData());
92− Application::getInstance()->getLogger()->addMessage(message.toLocal8Bit().constData());
95+ QString messageWithNewLine = message + "\n";
96+ fprintf(stdout, "%s", messageWithNewLine.toLocal8Bit().constData());
97+ Application::getInstance()->getLogger()->addMessage(messageWithNewLine.toLocal8Bit().constData());
9398 }
9499
95100 Application::Application(int& argc, char** argv, timeval &startup_time) :
96101 QApplication(argc, argv),
97102 _window(new QMainWindow(desktop())),
98103 _glWidget(new GLCanvas()),
99− _displayLevels(false),
100104 _frameCount(0),
101105 _fps(120.0f),
102106 _justStarted(true),
@@ -127,10 +131,9 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 24 unmodified lines
127131 _lookingAwayFromOrigin(true),
128132 _lookatTargetAvatar(NULL),
129133 _lookatIndicatorScale(1.0f),
130− _perfStatsOn(false),
131134 _chatEntryOn(false),
132135 _audio(&_audioScope, STARTUP_JITTER_SAMPLES),
133− _stopNetworkReceiveThread(false),
136+ _enableProcessVoxelsThread(true),
134137 _voxelProcessor(),
135138 _voxelHideShowThread(&_voxels),
136139 _voxelEditSender(this),
@@ -143,7 +146,8 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 6 unmodified lines
143146 _resetRecentMaxPacketsSoon(true),
144147 _swatch(NULL),
145148 _pasteMode(false),
146− _logger(new FileLogger())
149+ _logger(new FileLogger()),
150+ _persistThread(NULL)
147151 {
148152 _applicationStartupTime = startup_time;
149153
@@ -156,7 +160,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 6 unmodified lines
156160 // call Menu getInstance static method to set up the menu
157161 _window->setMenuBar(Menu::getInstance());
158162
159− qDebug("[VERSION] Build sequence: %i\n", BUILD_VERSION);
163+ qDebug("[VERSION] Build sequence: %i", BUILD_VERSION);
160164
161165 unsigned int listenPort = 0; // bind to an ephemeral port by default
162166 const char** constArgv = const_cast<const char**>(argv);
@@ -167,6 +171,9 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 4 unmodified lines
167171
168172 NodeList* nodeList = NodeList::createInstance(NODE_TYPE_AGENT, listenPort);
169173
174+ // connect our processDatagrams slot to the QUDPSocket readyRead() signal
175+ connect(&nodeList->getNodeSocket(), SIGNAL(readyRead()), SLOT(processDatagrams()));
176+
170177 // put the audio processing on a separate thread
171178 QThread* audioThread = new QThread(this);
172179
@@ -175,13 +182,11 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 2 unmodified lines
175182
176183 audioThread->start();
177184
178− nodeList->addHook(&_voxels);
179− nodeList->addHook(this);
180− nodeList->addDomainListener(this);
181− nodeList->addDomainListener(&_voxels);
185+ connect(nodeList, SIGNAL(domainChanged(const QString&)), SLOT(domainChanged(const QString&)));
182186
183− // network receive thread and voxel parsing thread are both controlled by the --nonblocking command line
184− _enableProcessVoxelsThread = _enableNetworkThread = !cmdOptionExists(argc, constArgv, "--nonblocking");
187+ connect(nodeList, SIGNAL(nodeKilled(SharedNodePointer)), SLOT(nodeKilled(SharedNodePointer)));
188+ connect(nodeList, SIGNAL(nodeAdded(SharedNodePointer)), &_voxels, SLOT(nodeAdded(SharedNodePointer)));
189+ connect(nodeList, SIGNAL(nodeKilled(SharedNodePointer)), &_voxels, SLOT(nodeKilled(SharedNodePointer)));
185190
186191 // read the ApplicationInfo.ini file for Name/Version/Domain information
187192 QSettings applicationInfo("resources/info/ApplicationInfo.ini", QSettings::IniFormat);
@@ -210,7 +215,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 22 unmodified lines
210215
211216 // tell the NodeList instance who to tell the domain server we care about
212217 const char nodeTypesOfInterest[] = {NODE_TYPE_AUDIO_MIXER, NODE_TYPE_AVATAR_MIXER, NODE_TYPE_VOXEL_SERVER,
213− NODE_TYPE_PARTICLE_SERVER};
218+ NODE_TYPE_PARTICLE_SERVER, NODE_TYPE_METAVOXEL_SERVER};
214219 nodeList->setNodeTypesOfInterest(nodeTypesOfInterest, sizeof(nodeTypesOfInterest));
215220
216221 QTimer* silentNodeTimer = new QTimer(this);
@@ -250,6 +255,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 33 unmodified lines
250255
251256 // Set the sixense filtering
252257 _sixenseManager.setFilter(Menu::getInstance()->isOptionChecked(MenuOption::FilterSixense));
258+
253259 }
254260
255261 Application::~Application() {
@@ -264,9 +270,6 @@ Application::~Application() { · 8 unmodified lines
264270 _audio.thread()->wait();
265271
266272 storeSizeAndPosition();
267− NodeList::getInstance()->removeHook(&_voxels);
268− NodeList::getInstance()->removeHook(this);
269− NodeList::getInstance()->removeDomainListener(this);
270273
271274 _sharedVoxelSystem.changeTree(new VoxelTree);
272275
@@ -275,7 +278,6 @@ Application::~Application() { · 2 unmodified lines
275278
276279 delete _logger;
277280 delete _settings;
278− delete _followMode;
279281 delete _glWidget;
280282 }
281283
@@ -311,7 +313,7 @@ void Application::storeSizeAndPosition() { · 29 unmodified lines
311313 }
312314
313315 void Application::initializeGL() {
314− qDebug( "Created Display Window.\n" );
316+ qDebug( "Created Display Window.");
315317
316318 // initialize glut for shape drawing; Qt apparently initializes it on OS X
317319 #ifndef __APPLE__
@@ -319,23 +321,27 @@ void Application::initializeGL() { · 1 unmodified line
319321 glutInit(&argc, 0);
320322 #endif
321323
324+ #ifdef WIN32
325+ GLenum err = glewInit();
326+ if (GLEW_OK != err) {
327+ /* Problem: glewInit failed, something is seriously wrong. */
328+ qDebug("Error: %s\n", glewGetErrorString(err));
329+ }
330+ qDebug("Status: Using GLEW %s\n", glewGetString(GLEW_VERSION));
331+ #endif
332+
333+
322334 // Before we render anything, let's set up our viewFrustumOffsetCamera with a sufficiently large
323335 // field of view and near and far clip to make it interesting.
324336 //viewFrustumOffsetCamera.setFieldOfView(90.0);
325− _viewFrustumOffsetCamera.setNearClip(0.1);
326− _viewFrustumOffsetCamera.setFarClip(500.0 * TREE_SCALE);
337+ _viewFrustumOffsetCamera.setNearClip(0.1f);
338+ _viewFrustumOffsetCamera.setFarClip(500.0f * TREE_SCALE);
327339
328340 initDisplay();
329− qDebug( "Initialized Display.\n" );
341+ qDebug( "Initialized Display.");
330342
331343 init();
332− qDebug( "Init() complete.\n" );
333−
334− // create thread for receipt of data via UDP
335− if (_enableNetworkThread) {
336− pthread_create(&_networkReceiveThread, NULL, networkReceive, NULL);
337− qDebug("Network receive thread created.\n");
338− }
344+ qDebug( "init() complete.");
339345
340346 // create thread for parsing of voxel data independent of the main network and rendering threads
341347 _voxelProcessor.initialize(_enableProcessVoxelsThread);
@@ -343,7 +349,7 @@ void Application::initializeGL() { · 1 unmodified line
343349 _voxelHideShowThread.initialize(_enableProcessVoxelsThread);
344350 _particleEditSender.initialize(_enableProcessVoxelsThread);
345351 if (_enableProcessVoxelsThread) {
346− qDebug("Voxel parsing thread created.\n");
352+ qDebug("Voxel parsing thread created.");
347353 }
348354
349355 // call terminate before exiting
@@ -363,9 +369,7 @@ void Application::initializeGL() { · 13 unmodified lines
363369 if (_justStarted) {
364370 float startupTime = (usecTimestampNow() - usecTimestamp(&_applicationStartupTime)) / 1000000.0;
365371 _justStarted = false;
366− char title[50];
367− sprintf(title, "Interface: %4.2f seconds\n", startupTime);
368− qDebug("%s", title);
372+ qDebug("Startup time: %4.2f seconds.", startupTime);
369373 const char LOGSTASH_INTERFACE_START_TIME_KEY[] = "interface-start-time";
370374
371375 // ask the Logstash class to record the startup time
@@ -465,7 +469,7 @@ void Application::paintGL() { · 93 unmodified lines
465469 bool eyeRelativeCamera = false;
466470 if (_rearMirrorTools->getZoomLevel() == BODY) {
467471 _mirrorCamera.setDistance(MIRROR_REARVIEW_BODY_DISTANCE * _myAvatar.getScale());
468− _mirrorCamera.setTargetPosition(_myAvatar.getChestJointPosition());
472+ _mirrorCamera.setTargetPosition(_myAvatar.getChestPosition());
469473 } else { // HEAD zoom level
470474 _mirrorCamera.setDistance(MIRROR_REARVIEW_DISTANCE * _myAvatar.getScale());
471475 if (_myAvatar.getSkeletonModel().isActive() && _myAvatar.getHead().getFaceModel().isActive()) {
@@ -672,9 +676,7 @@ void Application::keyPressEvent(QKeyEvent* event) { · 200 unmodified lines
672676 _audioScope.inputPaused = !_audioScope.inputPaused;
673677 break;
674678 case Qt::Key_L:
675− if (!isShifted && !isMeta) {
676− _displayLevels = !_displayLevels;
677− } else if (isShifted) {
679+ if (isShifted) {
678680 Menu::getInstance()->triggerOption(MenuOption::LodTools);
679681 } else if (isMeta) {
680682 Menu::getInstance()->triggerOption(MenuOption::Log);
@@ -1017,6 +1019,9 @@ void Application::keyPressEvent(QKeyEvent* event) { · 336 unmodified lines
10171019 case Qt::Key_Minus:
10181020 _myAvatar.decreaseSize();
10191021 break;
1022+ case Qt::Key_Equal:
1023+ _myAvatar.resetSize();
1024+ break;
10201025
10211026 case Qt::Key_1:
10221027 case Qt::Key_2:
@@ -1122,7 +1127,7 @@ void Application::mouseMoveEvent(QMouseEvent* event) { · 99 unmodified lines
11221127 return;
11231128 }
11241129 if (_isHoverVoxel) {
1125− _myAvatar.orbit(glm::vec3(_hoverVoxel.x, _hoverVoxel.y, _hoverVoxel.z) * (float)TREE_SCALE, deltaX, deltaY);
1130+ _myAvatar.orbit(getMouseVoxelWorldCoordinates(_hoverVoxel), deltaX, deltaY);
11261131 return;
11271132 }
11281133 }
@@ -1282,7 +1287,7 @@ void Application::wheelEvent(QWheelEvent* event) { · 153 unmodified lines
12821287 void Application::sendPingPackets() {
12831288
12841289 const char nodesToPing[] = {NODE_TYPE_VOXEL_SERVER, NODE_TYPE_PARTICLE_SERVER,
1285− NODE_TYPE_AUDIO_MIXER, NODE_TYPE_AVATAR_MIXER};
1290+ NODE_TYPE_AUDIO_MIXER, NODE_TYPE_AVATAR_MIXER, NODE_TYPE_METAVOXEL_SERVER};
12861291
12871292 unsigned char pingPacket[MAX_PACKET_SIZE];
12881293 int length = NodeList::getInstance()->fillPingPacket(pingPacket);
@@ -1291,38 +1296,6 @@ void Application::sendPingPackets() { · 2 unmodified lines
12911296 nodesToPing, sizeof(nodesToPing));
12921297 }
12931298
1294−void Application::sendAvatarFaceVideoMessage(int frameCount, const QByteArray& data) {
1295− unsigned char packet[MAX_PACKET_SIZE];
1296− unsigned char* packetPosition = packet;
1297−
1298− packetPosition += populateTypeAndVersion(packetPosition, PACKET_TYPE_AVATAR_FACE_VIDEO);
1299−
1300− QByteArray rfcUUID = NodeList::getInstance()->getOwnerUUID().toRfc4122();
1301− memcpy(packetPosition, rfcUUID.constData(), rfcUUID.size());
1302− packetPosition += rfcUUID.size();
1303−
1304− *(uint32_t*)packetPosition = frameCount;
1305− packetPosition += sizeof(uint32_t);
1306−
1307− *(uint32_t*)packetPosition = data.size();
1308− packetPosition += sizeof(uint32_t);
1309−
1310− uint32_t* offsetPosition = (uint32_t*)packetPosition;
1311− packetPosition += sizeof(uint32_t);
1312−
1313− int headerSize = packetPosition - packet;
1314−
1315− // break the data up into submessages of the maximum size (at least one, for zero-length packets)
1316− *offsetPosition = 0;
1317− do {
1318− int payloadSize = min(data.size() - (int)*offsetPosition, MAX_PACKET_SIZE - headerSize);
1319− memcpy(packetPosition, data.constData() + *offsetPosition, payloadSize);
1320− getInstance()->controlledBroadcastToNodes(packet, headerSize + payloadSize, &NODE_TYPE_AVATAR_MIXER, 1);
1321− *offsetPosition += payloadSize;
1322−
1323− } while (*offsetPosition < data.size());
1324−}
1325−
13261299 // Every second, check the frame rates and other stuff
13271300 void Application::timer() {
13281301 gettimeofday(&_timerEnd, NULL);
@@ -1340,16 +1313,12 @@ void Application::timer() { · 11 unmodified lines
13401313
13411314 gettimeofday(&_timerStart, NULL);
13421315
1343− // if we haven't detected gyros, check for them now
1344− if (!_serialHeadSensor.isActive()) {
1345− _serialHeadSensor.pair();
1346− }
1347−
13481316 // ask the node list to check in with the domain server
13491317 NodeList::getInstance()->sendDomainServerCheckIn();
13501318
1351− // give the MyAvatar object position to the Profile so it can propagate to the data-server
1319+ // give the MyAvatar object position, orientation to the Profile so it can propagate to the data-server
13521320 _profile.updatePosition(_myAvatar.getPosition());
1321+ _profile.updateOrientation(_myAvatar.getOrientation());
13531322 }
13541323
13551324 static glm::vec3 getFaceVector(BoxFace face) {
@@ -1369,6 +1338,7 @@ static glm::vec3 getFaceVector(BoxFace face) { · 13 unmodified lines
13691338 case MIN_Z_FACE:
13701339 return glm::vec3(0, 0, -1);
13711340
1341+ default: // quiet windows warnings
13721342 case MAX_Z_FACE:
13731343 return glm::vec3(0, 0, 1);
13741344 }
@@ -1418,7 +1388,6 @@ void Application::terminate() { · 43 unmodified lines
14181388 // Close serial port
14191389 // close(serial_fd);
14201390
1421− LeapManager::terminate();
14221391 Menu::getInstance()->saveSettings();
14231392 _rearMirrorTools->saveSettings(_settings);
14241393 _settings->sync();
@@ -1426,22 +1395,21 @@ void Application::terminate() { · 1 unmodified line
14261395 // let the avatar mixer know we're out
14271396 NodeList::getInstance()->sendKillNode(&NODE_TYPE_AVATAR_MIXER, 1);
14281397
1429− if (_enableNetworkThread) {
1430− _stopNetworkReceiveThread = true;
1431− pthread_join(_networkReceiveThread, NULL);
1432− }
1433−
1434− printf("");
14351398 _voxelProcessor.terminate();
14361399 _voxelHideShowThread.terminate();
14371400 _voxelEditSender.terminate();
14381401 _particleEditSender.terminate();
1402+ if (_persistThread) {
1403+ _persistThread->terminate();
1404+ _persistThread->deleteLater();
1405+ _persistThread = NULL;
1406+ }
14391407 }
14401408
14411409 static Avatar* processAvatarMessageHeader(unsigned char*& packetData, size_t& dataBytes) {
14421410 // record the packet for stats-tracking
14431411 Application::getInstance()->getBandwidthMeter()->inputStream(BandwidthMeter::AVATARS).updateValue(dataBytes);
1444− Node* avatarMixerNode = NodeList::getInstance()->soloNodeOfType(NODE_TYPE_AVATAR_MIXER);
1412+ SharedNodePointer avatarMixerNode = NodeList::getInstance()->soloNodeOfType(NODE_TYPE_AVATAR_MIXER);
14451413 if (avatarMixerNode) {
14461414 avatarMixerNode->recordBytesReceived(dataBytes);
14471415 }
@@ -1458,7 +1426,7 @@ static Avatar* processAvatarMessageHeader(unsigned char*& packetData, size_t& da · 10 unmodified lines
14581426 dataBytes -= NUM_BYTES_RFC4122_UUID;
14591427
14601428 // make sure the node exists
1461− Node* node = NodeList::getInstance()->nodeWithUUID(nodeUUID);
1429+ SharedNodePointer node = NodeList::getInstance()->nodeWithUUID(nodeUUID);
14621430 if (!node || !node->getLinkedData()) {
14631431 return NULL;
14641432 }
@@ -1487,14 +1455,6 @@ void Application::processAvatarURLsMessage(unsigned char* packetData, size_t dat · 22 unmodified lines
14871455 avatar->getUUID());
14881456 }
14891457
1490−void Application::processAvatarFaceVideoMessage(unsigned char* packetData, size_t dataBytes) {
1491− Avatar* avatar = processAvatarMessageHeader(packetData, dataBytes);
1492− if (!avatar) {
1493− return;
1494− }
1495− avatar->getHead().getVideoFace().processVideoMessage(packetData, dataBytes);
1496−}
1497−
14981458 void Application::checkBandwidthMeterClick() {
14991459 // ... to be called upon button release
15001460
@@ -1514,6 +1474,11 @@ void Application::setFullscreen(bool fullscreen) { · 13 unmodified lines
15141474 (_window->windowState() & ~Qt::WindowFullScreen));
15151475 }
15161476
1477+void Application::setEnable3DTVMode(bool enable3DTVMode) {
1478+ resizeGL(_glWidget->width(),_glWidget->height());
1479+}
1480+
1481+
15171482 void Application::setRenderVoxels(bool voxelRender) {
15181483 _voxelEditSender.setShouldSend(voxelRender);
15191484 if (!voxelRender) {
@@ -1617,10 +1582,9 @@ void Application::makeVoxel(glm::vec3 position, · 97 unmodified lines
16171582 isDestructive);
16181583 }
16191584
1620−const glm::vec3 Application::getMouseVoxelWorldCoordinates(const VoxelDetail _mouseVoxel) {
1621− return glm::vec3((_mouseVoxel.x + _mouseVoxel.s / 2.f) * TREE_SCALE,
1622− (_mouseVoxel.y + _mouseVoxel.s / 2.f) * TREE_SCALE,
1623− (_mouseVoxel.z + _mouseVoxel.s / 2.f) * TREE_SCALE);
1585+glm::vec3 Application::getMouseVoxelWorldCoordinates(const VoxelDetail& mouseVoxel) {
1586+ return glm::vec3((mouseVoxel.x + mouseVoxel.s / 2.f) * TREE_SCALE, (mouseVoxel.y + mouseVoxel.s / 2.f) * TREE_SCALE,
1587+ (mouseVoxel.z + mouseVoxel.s / 2.f) * TREE_SCALE);
16241588 }
16251589
16261590 const float NUDGE_PRECISION_MIN = 1 / pow(2.0, 12.0);
@@ -1707,9 +1671,9 @@ void Application::exportVoxels() { · 80 unmodified lines
17071671
17081672 void Application::importVoxels() {
17091673 if (_voxelImporter.exec()) {
1710− qDebug("[DEBUG] Import succedded.\n");
1674+ qDebug("[DEBUG] Import succeeded.");
17111675 } else {
1712− qDebug("[DEBUG] Import failed.\n");
1676+ qDebug("[DEBUG] Import failed.");
17131677 }
17141678
17151679 // restore the main window's active state
@@ -1883,8 +1847,6 @@ void Application::init() { · 167 unmodified lines
18831847 Qt::QueuedConnection);
18841848 }
18851849
1886− LeapManager::initialize();
1887−
18881850 gettimeofday(&_timerStart, NULL);
18891851 gettimeofday(&_lastTimeUpdated, NULL);
18901852
@@ -1892,7 +1854,7 @@ void Application::init() { · 1 unmodified line
18921854 if (Menu::getInstance()->getAudioJitterBufferSamples() != 0) {
18931855 _audio.setJitterBufferSamples(Menu::getInstance()->getAudioJitterBufferSamples());
18941856 }
1895− qDebug("Loaded settings.\n");
1857+ qDebug("Loaded settings");
18961858
18971859 if (!_profile.getUsername().isEmpty()) {
18981860 // we have a username for this avatar, ask the data-server for the mesh URL for this avatar
@@ -1926,10 +1888,6 @@ void Application::init() { · 27 unmodified lines
19261888 _glWidget->width(),
19271889 _glWidget->height());
19281890
1929− _followMode = new QAction(this);
1930− connect(_followMode, SIGNAL(triggered()), this, SLOT(toggleFollowMode()));
1931− _pieMenu.addAction(_followMode);
1932−
19331891 _audio.init(_glWidget);
19341892
19351893 _rearMirrorTools = new RearMirrorTools(_glWidget, _mirrorViewRect, _settings);
@@ -1937,6 +1895,9 @@ void Application::init() { · 1 unmodified line
19371895 connect(_rearMirrorTools, SIGNAL(restoreView()), SLOT(restoreMirrorView()));
19381896 connect(_rearMirrorTools, SIGNAL(shrinkView()), SLOT(shrinkMirrorView()));
19391897 connect(_rearMirrorTools, SIGNAL(resetView()), SLOT(resetSensors()));
1898+
1899+
1900+ updateLocalOctreeCache(true);
19401901 }
19411902
19421903 void Application::closeMirrorView() {
@@ -1967,7 +1928,7 @@ void Application::shrinkMirrorView() { · 24 unmodified lines
19671928
19681929 const float MAX_AVATAR_EDIT_VELOCITY = 1.0f;
19691930 const float MAX_VOXEL_EDIT_DISTANCE = 50.0f;
1970−const float HEAD_SPHERE_RADIUS = 0.07;
1931+const float HEAD_SPHERE_RADIUS = 0.07f;
19711932
19721933 static QUuid DEFAULT_NODE_ID_REF;
19731934
@@ -1984,15 +1945,15 @@ void Application::updateLookatTargetAvatar(const glm::vec3& mouseRayOrigin, cons · 10 unmodified lines
19841945 Avatar* Application::findLookatTargetAvatar(const glm::vec3& mouseRayOrigin, const glm::vec3& mouseRayDirection,
19851946 glm::vec3& eyePosition, QUuid& nodeUUID = DEFAULT_NODE_ID_REF) {
19861947
1987− NodeList* nodeList = NodeList::getInstance();
1988− for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
1948+ foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) {
19891949 if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) {
19901950 Avatar* avatar = (Avatar*)node->getLinkedData();
19911951 float distance;
1952+
19921953 if (avatar->findRayIntersection(mouseRayOrigin, mouseRayDirection, distance)) {
19931954 // rescale to compensate for head embiggening
19941955 eyePosition = (avatar->getHead().calculateAverageEyePosition() - avatar->getHead().getScalePivot()) *
1995− (avatar->getScale() / avatar->getHead().getScale()) + avatar->getHead().getScalePivot();
1956+ (avatar->getScale() / avatar->getHead().getScale()) + avatar->getHead().getScalePivot();
19961957
19971958 _lookatIndicatorScale = avatar->getHead().getScale();
19981959 _lookatOtherPosition = avatar->getHead().getPosition();
@@ -2001,6 +1962,7 @@ Avatar* Application::findLookatTargetAvatar(const glm::vec3& mouseRayOrigin, con · 2 unmodified lines
20011962 }
20021963 }
20031964 }
1965+
20041966 return NULL;
20051967 }
20061968
@@ -2025,71 +1987,6 @@ void Application::renderLookatIndicator(glm::vec3 pointOfInterest) { · 18 unmodified lines
20251987 renderCircle(haloOrigin, INDICATOR_RADIUS, IDENTITY_UP, NUM_SEGMENTS);
20261988 }
20271989
2028−void maybeBeginFollowIndicator(bool& began) {
2029− if (!began) {
2030− Application::getInstance()->getGlowEffect()->begin();
2031− glLineWidth(5);
2032− glBegin(GL_LINES);
2033− began = true;
2034− }
2035−}
2036−
2037−void Application::renderFollowIndicator() {
2038− NodeList* nodeList = NodeList::getInstance();
2039−
2040− // initialize lazily so that we don't enable the glow effect unnecessarily
2041− bool began = false;
2042−
2043− for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); ++node) {
2044− if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) {
2045− Avatar* avatar = (Avatar *) node->getLinkedData();
2046− Avatar* leader = NULL;
2047−
2048− if (!avatar->getLeaderUUID().isNull()) {
2049− if (avatar->getLeaderUUID() == NodeList::getInstance()->getOwnerUUID()) {
2050− leader = &_myAvatar;
2051− } else {
2052− for (NodeList::iterator it = nodeList->begin(); it != nodeList->end(); ++it) {
2053− if(it->getUUID() == avatar->getLeaderUUID()
2054− && it->getType() == NODE_TYPE_AGENT) {
2055− leader = (Avatar*) it->getLinkedData();
2056− }
2057− }
2058− }
2059−
2060− if (leader != NULL) {
2061− maybeBeginFollowIndicator(began);
2062− glColor3f(1.f, 0.f, 0.f);
2063− glVertex3f((avatar->getHead().getPosition().x + avatar->getPosition().x) / 2.f,
2064− (avatar->getHead().getPosition().y + avatar->getPosition().y) / 2.f,
2065− (avatar->getHead().getPosition().z + avatar->getPosition().z) / 2.f);
2066− glColor3f(0.f, 1.f, 0.f);
2067− glVertex3f((leader->getHead().getPosition().x + leader->getPosition().x) / 2.f,
2068− (leader->getHead().getPosition().y + leader->getPosition().y) / 2.f,
2069− (leader->getHead().getPosition().z + leader->getPosition().z) / 2.f);
2070− }
2071− }
2072− }
2073− }
2074−
2075− if (_myAvatar.getLeadingAvatar() != NULL) {
2076− maybeBeginFollowIndicator(began);
2077− glColor3f(1.f, 0.f, 0.f);
2078− glVertex3f((_myAvatar.getHead().getPosition().x + _myAvatar.getPosition().x) / 2.f,
2079− (_myAvatar.getHead().getPosition().y + _myAvatar.getPosition().y) / 2.f,
2080− (_myAvatar.getHead().getPosition().z + _myAvatar.getPosition().z) / 2.f);
2081− glColor3f(0.f, 1.f, 0.f);
2082− glVertex3f((_myAvatar.getLeadingAvatar()->getHead().getPosition().x + _myAvatar.getLeadingAvatar()->getPosition().x) / 2.f,
2083− (_myAvatar.getLeadingAvatar()->getHead().getPosition().y + _myAvatar.getLeadingAvatar()->getPosition().y) / 2.f,
2084− (_myAvatar.getLeadingAvatar()->getHead().getPosition().z + _myAvatar.getLeadingAvatar()->getPosition().z) / 2.f);
2085− }
2086−
2087− if (began) {
2088− glEnd();
2089− _glowEffect.end();
2090− }
2091−}
2092−
20931990 void Application::renderHighlightVoxel(VoxelDetail voxel) {
20941991 glDisable(GL_LIGHTING);
20951992 glPushMatrix();
@@ -2107,10 +2004,9 @@ void Application::renderHighlightVoxel(VoxelDetail voxel) { · 11 unmodified lines
21072004 void Application::updateAvatars(float deltaTime, glm::vec3 mouseRayOrigin, glm::vec3 mouseRayDirection) {
21082005 bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
21092006 PerformanceWarning warn(showWarnings, "Application::updateAvatars()");
2110− NodeList* nodeList = NodeList::getInstance();
21112007
2112− for(NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
2113− node->lock();
2008+ foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) {
2009+ QMutexLocker(&node->getMutex());
21142010 if (node->getLinkedData()) {
21152011 Avatar *avatar = (Avatar *)node->getLinkedData();
21162012 if (!avatar->isInitialized()) {
@@ -2119,16 +2015,18 @@ void Application::updateAvatars(float deltaTime, glm::vec3 mouseRayOrigin, glm:: · 2 unmodified lines
21192015 avatar->simulate(deltaTime, NULL);
21202016 avatar->setMouseRay(mouseRayOrigin, mouseRayDirection);
21212017 }
2122− node->unlock();
21232018 }
21242019
21252020 // simulate avatar fades
21262021 for (vector<Avatar*>::iterator fade = _avatarFades.begin(); fade != _avatarFades.end(); fade++) {
21272022 Avatar* avatar = *fade;
21282023 const float SHRINK_RATE = 0.9f;
2129− avatar->setNewScale(avatar->getNewScale() * SHRINK_RATE);
2130− const float MINIMUM_SCALE = 0.001f;
2131− if (avatar->getNewScale() < MINIMUM_SCALE) {
2024+
2025+ avatar->setTargetScale(avatar->getScale() * SHRINK_RATE);
2026+
2027+ const float MIN_FADE_SCALE = 0.001f;
2028+
2029+ if (avatar->getTargetScale() < MIN_FADE_SCALE) {
21322030 delete avatar;
21332031 _avatarFades.erase(fade--);
21342032
@@ -2182,17 +2080,23 @@ void Application::updateMyAvatarLookAtPosition(glm::vec3& lookAtSpot, glm::vec3& · 47 unmodified lines
21822080 bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
21832081 PerformanceWarning warn(showWarnings, "Application::updateMyAvatarLookAtPosition()");
21842082
2083+ const float FAR_AWAY_STARE = TREE_SCALE;
21852084 if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
21862085 lookAtSpot = _myCamera.getPosition();
21872086
2087+ } else if (_mouseHidden) {
2088+ // if the mouse cursor is hidden, just look straight ahead
2089+ glm::vec3 rayOrigin, rayDirection;
2090+ _viewFrustum.computePickRay(0.5f, 0.5f, rayOrigin, rayDirection);
2091+ lookAtSpot = rayOrigin + rayDirection * FAR_AWAY_STARE;
2092+
21882093 } else if (!_lookatTargetAvatar) {
21892094 if (_isHoverVoxel) {
21902095 // Look at the hovered voxel
21912096 lookAtSpot = getMouseVoxelWorldCoordinates(_hoverVoxel);
21922097
21932098 } else {
2194− // Just look in direction of the mouse ray
2195− const float FAR_AWAY_STARE = TREE_SCALE;
2099+ // Just look in direction of the mouse ray
21962100 lookAtSpot = lookAtRayOrigin + lookAtRayDirection * FAR_AWAY_STARE;
21972101 }
21982102 }
@@ -2264,7 +2168,6 @@ void Application::updateMouseVoxels(float deltaTime, glm::vec3& mouseRayOrigin, · 65 unmodified lines
22642168
22652169 _mouseVoxel.s = 0.0f;
22662170 bool wasInitialized = _mouseVoxelScaleInitialized;
2267− _mouseVoxelScaleInitialized = false;
22682171 if (Menu::getInstance()->isVoxelModeActionChecked() &&
22692172 (fabs(_myAvatar.getVelocity().x) +
22702173 fabs(_myAvatar.getVelocity().y) +
@@ -2345,6 +2248,7 @@ void Application::updateMouseVoxels(float deltaTime, glm::vec3& mouseRayOrigin, · 74 unmodified lines
23452248 }
23462249 }
23472250
2251+
23482252 void Application::updateHandAndTouch(float deltaTime) {
23492253 bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
23502254 PerformanceWarning warn(showWarnings, "Application::updateHandAndTouch()");
@@ -2364,9 +2268,6 @@ void Application::updateHandAndTouch(float deltaTime) { · 13 unmodified lines
23642268 void Application::updateLeap(float deltaTime) {
23652269 bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
23662270 PerformanceWarning warn(showWarnings, "Application::updateLeap()");
2367−
2368− LeapManager::enableFakeFingers(Menu::getInstance()->isOptionChecked(MenuOption::SimulateLeapHand));
2369− LeapManager::nextFrame();
23702271 }
23712272
23722273 void Application::updateSixense(float deltaTime) {
@@ -2379,27 +2280,21 @@ void Application::updateSixense(float deltaTime) { · 6 unmodified lines
23792280 void Application::updateSerialDevices(float deltaTime) {
23802281 bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
23812282 PerformanceWarning warn(showWarnings, "Application::updateSerialDevices()");
2382−
2383− if (_serialHeadSensor.isActive()) {
2384− _serialHeadSensor.readData(deltaTime);
2385− }
23862283 }
23872284
23882285 void Application::updateThreads(float deltaTime) {
23892286 bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
23902287 PerformanceWarning warn(showWarnings, "Application::updateThreads()");
23912288
2392− // read incoming packets from network
2393− if (!_enableNetworkThread) {
2394− networkReceive(0);
2395− }
2396−
23972289 // parse voxel packets
23982290 if (!_enableProcessVoxelsThread) {
23992291 _voxelProcessor.threadRoutine();
24002292 _voxelHideShowThread.threadRoutine();
24012293 _voxelEditSender.threadRoutine();
24022294 _particleEditSender.threadRoutine();
2295+ if (_persistThread) {
2296+ _persistThread->threadRoutine();
2297+ }
24032298 }
24042299 }
24052300
@@ -2445,7 +2340,7 @@ void Application::updateTransmitter(float deltaTime) { · 39 unmodified lines
24452340
24462341 // no transmitter drive implies transmitter pick
24472342 if (!Menu::getInstance()->isOptionChecked(MenuOption::TransmitterDrive) && _myTransmitter.isConnected()) {
2448− _transmitterPickStart = _myAvatar.getSkeleton().joint[AVATAR_JOINT_CHEST].position;
2343+ _transmitterPickStart = _myAvatar.getChestPosition();
24492344 glm::vec3 direction = _myAvatar.getOrientation() *
24502345 glm::quat(glm::radians(_myTransmitter.getEstimatedRotation())) * IDENTITY_FRONT;
24512346
@@ -2494,12 +2389,6 @@ void Application::updateCamera(float deltaTime) { · 42 unmodified lines
24942389 glm::vec3 position = _faceshift.getHeadTranslation() * EYE_OFFSET_SCALE;
24952390 _myCamera.setEyeOffsetPosition(glm::vec3(position.x * xSign, position.y, -position.z));
24962391 updateProjectionMatrix();
2497−
2498− } else if (_webcam.isActive()) {
2499− const float EYE_OFFSET_SCALE = 0.5f;
2500− glm::vec3 position = _webcam.getEstimatedPosition() * EYE_OFFSET_SCALE;
2501− _myCamera.setEyeOffsetPosition(glm::vec3(position.x * xSign, -position.y, position.z));
2502− updateProjectionMatrix();
25032392 }
25042393 }
25052394 }
@@ -2611,8 +2500,8 @@ void Application::updateAvatar(float deltaTime) { · 105 unmodified lines
26112500 _myAvatar.getHand().setPitchUpdate(0.f);
26122501 _pitchFromTouch = 0.0f;
26132502
2614− // Update my avatar's state from gyros and/or webcam
2615− _myAvatar.updateFromGyrosAndOrWebcam(Menu::getInstance()->isOptionChecked(MenuOption::TurnWithHead));
2503+ // Update my avatar's state from gyros
2504+ _myAvatar.updateFromGyros(Menu::getInstance()->isOptionChecked(MenuOption::TurnWithHead));
26162505
26172506 // Update head mouse from faceshift if active
26182507 if (_faceshift.isActive()) {
@@ -2625,41 +2514,6 @@ void Application::updateAvatar(float deltaTime) { · 6 unmodified lines
26252514 _headMouseY -= headVelocity.x * HEADMOUSE_FACESHIFT_PITCH_SCALE;
26262515 }
26272516
2628− if (_serialHeadSensor.isActive()) {
2629−
2630− // Grab latest readings from the gyros
2631− float measuredPitchRate = _serialHeadSensor.getLastPitchRate();
2632− float measuredYawRate = _serialHeadSensor.getLastYawRate();
2633−
2634− // Update gyro-based mouse (X,Y on screen)
2635− const float MIN_MOUSE_RATE = 3.0;
2636− const float HORIZONTAL_PIXELS_PER_DEGREE = 2880.f / 45.f;
2637− const float VERTICAL_PIXELS_PER_DEGREE = 1800.f / 30.f;
2638− if (powf(measuredYawRate * measuredYawRate +
2639− measuredPitchRate * measuredPitchRate, 0.5) > MIN_MOUSE_RATE) {
2640− _headMouseX -= measuredYawRate * HORIZONTAL_PIXELS_PER_DEGREE * deltaTime;
2641− _headMouseY -= measuredPitchRate * VERTICAL_PIXELS_PER_DEGREE * deltaTime;
2642− }
2643−
2644− const float MIDPOINT_OF_SCREEN = 0.5;
2645−
2646− // Only use gyro to set lookAt if mouse hasn't selected an avatar
2647− if (!_lookatTargetAvatar) {
2648−
2649− // Set lookAtPosition if an avatar is at the center of the screen
2650− glm::vec3 screenCenterRayOrigin, screenCenterRayDirection;
2651− _viewFrustum.computePickRay(MIDPOINT_OF_SCREEN, MIDPOINT_OF_SCREEN, screenCenterRayOrigin, screenCenterRayDirection);
2652−
2653− glm::vec3 eyePosition;
2654− updateLookatTargetAvatar(screenCenterRayOrigin, screenCenterRayDirection, eyePosition);
2655− if (_lookatTargetAvatar) {
2656− glm::vec3 myLookAtFromMouse(eyePosition);
2657− _myAvatar.getHead().setLookAtPosition(myLookAtFromMouse);
2658− }
2659− }
2660−
2661− }
2662−
26632517 // Constrain head-driven mouse to edges of screen
26642518 _headMouseX = glm::clamp(_headMouseX, 0, _glWidget->width());
26652519 _headMouseY = glm::clamp(_headMouseY, 0, _glWidget->height());
@@ -2740,15 +2594,12 @@ void Application::queryOctree(NODE_TYPE serverType, PACKET_TYPE packetType, Node · 74 unmodified lines
27402594
27412595 unsigned char voxelQueryPacket[MAX_PACKET_SIZE];
27422596
2743− NodeList* nodeList = NodeList::getInstance();
2744−
27452597 // Iterate all of the nodes, and get a count of how many voxel servers we have...
27462598 int totalServers = 0;
27472599 int inViewServers = 0;
27482600 int unknownJurisdictionServers = 0;
27492601
2750− for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
2751−
2602+ foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) {
27522603 // only send to the NodeTypes that are serverType
27532604 if (node->getActiveSocket() != NULL && node->getType() == serverType) {
27542605 totalServers++;
@@ -2782,7 +2633,7 @@ void Application::queryOctree(NODE_TYPE serverType, PACKET_TYPE packetType, Node · 27 unmodified lines
27822633 }
27832634
27842635 if (wantExtraDebugging && unknownJurisdictionServers > 0) {
2785− qDebug("Servers: total %d, in view %d, unknown jurisdiction %d \n",
2636+ qDebug("Servers: total %d, in view %d, unknown jurisdiction %d",
27862637 totalServers, inViewServers, unknownJurisdictionServers);
27872638 }
27882639
@@ -2803,10 +2654,12 @@ void Application::queryOctree(NODE_TYPE serverType, PACKET_TYPE packetType, Node · 14 unmodified lines
28032654 }
28042655
28052656 if (wantExtraDebugging && unknownJurisdictionServers > 0) {
2806− qDebug("perServerPPS: %d perUnknownServer: %d\n", perServerPPS, perUnknownServer);
2657+ qDebug("perServerPPS: %d perUnknownServer: %d", perServerPPS, perUnknownServer);
28072658 }
28082659
2809− for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
2660+ NodeList* nodeList = NodeList::getInstance();
2661+
2662+ foreach (const SharedNodePointer& node, nodeList->getNodeHash()) {
28102663 // only send to the NodeTypes that are serverType
28112664 if (node->getActiveSocket() != NULL && node->getType() == serverType) {
28122665
@@ -2822,7 +2675,7 @@ void Application::queryOctree(NODE_TYPE serverType, PACKET_TYPE packetType, Node · 9 unmodified lines
28222675 if (jurisdictions.find(nodeUUID) == jurisdictions.end()) {
28232676 unknownView = true; // assume it's in view
28242677 if (wantExtraDebugging) {
2825− qDebug() << "no known jurisdiction for node " << *node << ", assume it's visible.\n";
2678+ qDebug() << "no known jurisdiction for node " << *node << ", assume it's visible.";
28262679 }
28272680 } else {
28282681 const JurisdictionMap& map = (jurisdictions)[nodeUUID];
@@ -2843,7 +2696,7 @@ void Application::queryOctree(NODE_TYPE serverType, PACKET_TYPE packetType, Node · 14 unmodified lines
28432696 }
28442697 } else {
28452698 if (wantExtraDebugging) {
2846− qDebug() << "Jurisdiction without RootCode for node " << *node << ". That's unusual!\n";
2699+ qDebug() << "Jurisdiction without RootCode for node " << *node << ". That's unusual!";
28472700 }
28482701 }
28492702 }
@@ -2853,7 +2706,7 @@ void Application::queryOctree(NODE_TYPE serverType, PACKET_TYPE packetType, Node · 3 unmodified lines
28532706 } else if (unknownView) {
28542707 if (wantExtraDebugging) {
28552708 qDebug() << "no known jurisdiction for node " << *node << ", give it budget of "
2856− << perUnknownServer << " to send us jurisdiction.\n";
2709+ << perUnknownServer << " to send us jurisdiction.";
28572710 }
28582711
28592712 // set the query's position/orientation to be degenerate in a manner that will get the scene quickly
@@ -2863,14 +2716,14 @@ void Application::queryOctree(NODE_TYPE serverType, PACKET_TYPE packetType, Node · 3 unmodified lines
28632716 _voxelQuery.setCameraPosition(glm::vec3(-0.1,-0.1,-0.1));
28642717 const glm::quat OFF_IN_NEGATIVE_SPACE = glm::quat(-0.5, 0, -0.5, 1.0);
28652718 _voxelQuery.setCameraOrientation(OFF_IN_NEGATIVE_SPACE);
2866− _voxelQuery.setCameraNearClip(0.1);
2867− _voxelQuery.setCameraFarClip(0.1);
2719+ _voxelQuery.setCameraNearClip(0.1f);
2720+ _voxelQuery.setCameraFarClip(0.1f);
28682721 if (wantExtraDebugging) {
2869− qDebug() << "Using 'minimal' camera position for node " << *node << "\n";
2722+ qDebug() << "Using 'minimal' camera position for node" << *node;
28702723 }
28712724 } else {
28722725 if (wantExtraDebugging) {
2873− qDebug() << "Using regular camera position for node " << *node << "\n";
2726+ qDebug() << "Using regular camera position for node" << *node;
28742727 }
28752728 }
28762729 _voxelQuery.setMaxOctreePacketsPerSecond(perUnknownServer);
@@ -2894,7 +2747,7 @@ void Application::queryOctree(NODE_TYPE serverType, PACKET_TYPE packetType, Node · 17 unmodified lines
28942747 // make sure we still have an active socket
28952748 if (node->getActiveSocket()) {
28962749 nodeList->getNodeSocket().writeDatagram((char*) voxelQueryPacket, packetLength,
2897− node->getActiveSocket()->getAddress(), node->getActiveSocket()->getPort());
2750+ node->getActiveSocket()->getAddress(), node->getActiveSocket()->getPort());
28982751 }
28992752
29002753 // Feed number of bytes to corresponding channel of the bandwidth meter
@@ -3022,9 +2875,9 @@ void Application::setupWorldLight() { · 121 unmodified lines
30222875 glm::vec3 sunDirection = getSunDirection();
30232876 GLfloat light_position0[] = { sunDirection.x, sunDirection.y, sunDirection.z, 0.0 };
30242877 glLightfv(GL_LIGHT0, GL_POSITION, light_position0);
3025− GLfloat ambient_color[] = { 0.7, 0.7, 0.8 };
2878+ GLfloat ambient_color[] = { 0.7f, 0.7f, 0.8f };
30262879 glLightfv(GL_LIGHT0, GL_AMBIENT, ambient_color);
3027− GLfloat diffuse_color[] = { 0.8, 0.7, 0.7 };
2880+ GLfloat diffuse_color[] = { 0.8f, 0.7f, 0.7f };
30282881 glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse_color);
30292882
30302883 glLightfv(GL_LIGHT0, GL_SPECULAR, WHITE_SPECULAR_COLOR);
@@ -3105,7 +2958,6 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 74 unmodified lines
31052958 glEnable(GL_DEPTH_TEST);
31062959
31072960 // Enable to show line from me to the voxel I am touching
3108− //renderLineToTouchedVoxel();
31092961 //renderThrustAtVoxel(_voxelThrust);
31102962
31112963 if (!selfAvatarOnly) {
@@ -3253,12 +3105,6 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 141 unmodified lines
32533105 }
32543106 }
32553107
3256− {
3257− PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
3258− "Application::displaySide() ... renderFollowIndicator...");
3259− renderFollowIndicator();
3260− }
3261−
32623108 // render transmitter pick ray, if non-empty
32633109 if (_transmitterPickStart != _transmitterPickEnd) {
32643110 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
@@ -3291,10 +3137,10 @@ void Application::loadTranslatedViewMatrix(const glm::vec3& translation) { · 26 unmodified lines
32913137 translation.z + _viewMatrixTranslation.z);
32923138 }
32933139
3294−void Application::computeOffAxisFrustum(float& left, float& right, float& bottom, float& top, float& near,
3295− float& far, glm::vec4& nearClipPlane, glm::vec4& farClipPlane) const {
3140+void Application::computeOffAxisFrustum(float& left, float& right, float& bottom, float& top, float& nearVal,
3141+ float& farVal, glm::vec4& nearClipPlane, glm::vec4& farClipPlane) const {
32963142
3297− _viewFrustum.computeOffAxisFrustum(left, right, bottom, top, near, far, nearClipPlane, farClipPlane);
3143+ _viewFrustum.computeOffAxisFrustum(left, right, bottom, top, nearVal, farVal, nearClipPlane, farClipPlane);
32983144 }
32993145
33003146 void Application::displayOverlay() {
@@ -3326,8 +3172,7 @@ void Application::displayOverlay() { · 25 unmodified lines
33263172
33273173 //noiseTest(_glWidget->width(), _glWidget->height());
33283174
3329− if (Menu::getInstance()->isOptionChecked(MenuOption::HeadMouse)
3330− && USING_INVENSENSE_MPU9150) {
3175+ if (Menu::getInstance()->isOptionChecked(MenuOption::HeadMouse)) {
33313176 // Display small target box at center or head mouse target that can also be used to measure LOD
33323177 glColor3f(1.0, 1.0, 1.0);
33333178 glDisable(GL_LINE_SMOOTH);
@@ -3363,9 +3208,6 @@ void Application::displayOverlay() { · 29 unmodified lines
33633208 }
33643209 }
33653210
3366− // Show detected levels from the serial I/O ADC channel sensors
3367− if (_displayLevels) _serialHeadSensor.renderLevels(_glWidget->width(), _glWidget->height());
3368−
33693211 // Show hand transmitter data if detected
33703212 if (_myTransmitter.isConnected()) {
33713213 _myTransmitter.renderLevels(_glWidget->width(), _glWidget->height());
@@ -3385,14 +3227,14 @@ void Application::displayOverlay() { · 13 unmodified lines
33853227 glPointSize(1.0f);
33863228 char nodes[100];
33873229
3388− NodeList* nodeList = NodeList::getInstance();
33893230 int totalAvatars = 0, totalServers = 0;
33903231
3391− for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
3232+ foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) {
33923233 node->getType() == NODE_TYPE_AGENT ? totalAvatars++ : totalServers++;
33933234 }
3235+
33943236 sprintf(nodes, "Servers: %d, Avatars: %d\n", totalServers, totalAvatars);
3395− drawtext(_glWidget->width() - 150, 20, 0.10, 0, 1.0, 0, nodes, 1, 0, 0);
3237+ drawtext(_glWidget->width() - 150, 20, 0.10f, 0, 1.0f, 0, nodes, 1, 0, 0);
33963238 }
33973239
33983240 // testing rendering coverage map
@@ -3414,14 +3256,10 @@ void Application::displayOverlay() { · 15 unmodified lines
34143256 char frameTimer[10];
34153257 uint64_t mSecsNow = floor(usecTimestampNow() / 1000.0 + 0.5);
34163258 sprintf(frameTimer, "%d\n", (int)(mSecsNow % 1000));
3417− drawtext(_glWidget->width() - 100, _glWidget->height() - 20, 0.30, 0, 1.0, 0, frameTimer, 0, 0, 0);
3418− drawtext(_glWidget->width() - 102, _glWidget->height() - 22, 0.30, 0, 1.0, 0, frameTimer, 1, 1, 1);
3259+ drawtext(_glWidget->width() - 100, _glWidget->height() - 20, 0.30f, 0, 1.0f, 0, frameTimer, 0, 0, 0);
3260+ drawtext(_glWidget->width() - 102, _glWidget->height() - 22, 0.30f, 0, 1.0f, 0, frameTimer, 1, 1, 1);
34193261 }
34203262
3421−
3422− // render the webcam input frame
3423− _webcam.renderPreview(_glWidget->width(), _glWidget->height());
3424−
34253263 _palette.render(_glWidget->width(), _glWidget->height());
34263264
34273265 QAction* paintColorAction = NULL;
@@ -3477,6 +3315,7 @@ void Application::displayOverlay() { · 49 unmodified lines
34773315 glPopMatrix();
34783316 }
34793317
3318+
34803319 void Application::displayStats() {
34813320 int statsVerticalOffset = 8;
34823321 const int PELS_PER_LINE = 15;
@@ -3490,8 +3329,8 @@ void Application::displayStats() { · 7 unmodified lines
34903329 int pingAudio = 0, pingAvatar = 0, pingVoxel = 0, pingVoxelMax = 0;
34913330
34923331 NodeList* nodeList = NodeList::getInstance();
3493− Node* audioMixerNode = nodeList->soloNodeOfType(NODE_TYPE_AUDIO_MIXER);
3494− Node* avatarMixerNode = nodeList->soloNodeOfType(NODE_TYPE_AVATAR_MIXER);
3332+ SharedNodePointer audioMixerNode = nodeList->soloNodeOfType(NODE_TYPE_AUDIO_MIXER);
3333+ SharedNodePointer avatarMixerNode = nodeList->soloNodeOfType(NODE_TYPE_AVATAR_MIXER);
34953334
34963335 pingAudio = audioMixerNode ? audioMixerNode->getPingMs() : 0;
34973336 pingAvatar = avatarMixerNode ? avatarMixerNode->getPingMs() : 0;
@@ -3500,7 +3339,8 @@ void Application::displayStats() { · 2 unmodified lines
35003339 // Now handle voxel servers, since there could be more than one, we average their ping times
35013340 unsigned long totalPingVoxel = 0;
35023341 int voxelServerCount = 0;
3503− for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
3342+
3343+ foreach (const SharedNodePointer& node, nodeList->getNodeHash()) {
35043344 if (node->getType() == NODE_TYPE_VOXEL_SERVER) {
35053345 totalPingVoxel += node->getPingMs();
35063346 voxelServerCount++;
@@ -3509,6 +3349,7 @@ void Application::displayStats() { · 2 unmodified lines
35093349 }
35103350 }
35113351 }
3352+
35123353 if (voxelServerCount) {
35133354 pingVoxel = totalPingVoxel/voxelServerCount;
35143355 }
@@ -3525,7 +3366,7 @@ void Application::displayStats() { · 10 unmodified lines
35253366 sprintf(avatarStats, "Avatar: pos %.3f, %.3f, %.3f, vel %.1f, yaw = %.2f", avatarPos.x, avatarPos.y, avatarPos.z, glm::length(_myAvatar.getVelocity()), _myAvatar.getBodyYaw());
35263367 drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, avatarStats);
35273368
3528− Node* avatarMixer = NodeList::getInstance()->soloNodeOfType(NODE_TYPE_AVATAR_MIXER);
3369+ SharedNodePointer avatarMixer = NodeList::getInstance()->soloNodeOfType(NODE_TYPE_AVATAR_MIXER);
35293370 char avatarMixerStats[200];
35303371 if (avatarMixer) {
35313372 sprintf(avatarMixerStats, "Avatar Mixer: %.f kbps, %.f pps",
@@ -3656,25 +3497,6 @@ void Application::displayStats() { · 124 unmodified lines
36563497 }
36573498 statsVerticalOffset += PELS_PER_LINE;
36583499 drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, (char*)voxelStats.str().c_str());
3659−
3660−
3661− // Leap data
3662− statsVerticalOffset += PELS_PER_LINE;
3663− drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, (char*)LeapManager::statusString().c_str());
3664−
3665− if (_perfStatsOn) {
3666− // Get the PerfStats group details. We need to allocate and array of char* long enough to hold 1+groups
3667− char** perfStatLinesArray = new char*[PerfStat::getGroupCount()+1];
3668− int lines = PerfStat::DumpStats(perfStatLinesArray);
3669−
3670− for (int line=0; line < lines; line++) {
3671− statsVerticalOffset += PELS_PER_LINE;
3672− drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, perfStatLinesArray[line]);
3673− delete perfStatLinesArray[line]; // we're responsible for cleanup
3674− perfStatLinesArray[line]=NULL;
3675− }
3676− delete []perfStatLinesArray; // we're responsible for cleanup
3677− }
36783500 }
36793501
36803502 void Application::renderThrustAtVoxel(const glm::vec3& thrust) {
@@ -3689,20 +3511,6 @@ void Application::renderThrustAtVoxel(const glm::vec3& thrust) { · 8 unmodified lines
36893511 }
36903512 }
36913513
3692−void Application::renderLineToTouchedVoxel() {
3693− // Draw a teal line to the voxel I am currently dragging on
3694− if (_mousePressed) {
3695− glColor3f(0, 1, 1);
3696− glLineWidth(2.0f);
3697− glBegin(GL_LINES);
3698− glm::vec3 voxelTouched = getMouseVoxelWorldCoordinates(_mouseVoxelDragging);
3699− glVertex3f(voxelTouched.x, voxelTouched.y, voxelTouched.z);
3700− glm::vec3 headPosition = _myAvatar.getHeadJointPosition();
3701− glVertex3fv(&headPosition.x);
3702− glEnd();
3703− }
3704−}
3705−
37063514
37073515 glm::vec2 Application::getScaledScreenPoint(glm::vec2 projectedPoint) {
37083516 float horizontalScale = _glWidget->width() / 2.0f;
@@ -3732,9 +3540,6 @@ glm::vec2 Application::getScaledScreenPoint(glm::vec2 projectedPoint) { · 23 unmodified lines
37323540
37333541 // render the coverage map on screen
37343542 void Application::renderCoverageMapV2() {
3735−
3736− //qDebug("renderCoverageMap()\n");
3737−
37383543 glDisable(GL_LIGHTING);
37393544 glLineWidth(2.0);
37403545 glBegin(GL_LINES);
@@ -3778,8 +3583,6 @@ void Application::renderCoverageMapsV2Recursively(CoverageMapV2* map) { · 37 unmodified lines
37783583 // render the coverage map on screen
37793584 void Application::renderCoverageMap() {
37803585
3781− //qDebug("renderCoverageMap()\n");
3782−
37833586 glDisable(GL_LIGHTING);
37843587 glLineWidth(2.0);
37853588 glBegin(GL_LINES);
@@ -3855,8 +3658,8 @@ void Application::renderAvatars(bool forceRenderHead, bool selfAvatarOnly) { · 69 unmodified lines
38553658 // Render avatars of other nodes
38563659 NodeList* nodeList = NodeList::getInstance();
38573660
3858− for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
3859− node->lock();
3661+ foreach (const SharedNodePointer& node, nodeList->getNodeHash()) {
3662+ QMutexLocker(&node->getMutex());
38603663
38613664 if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) {
38623665 Avatar *avatar = (Avatar *)node->getLinkedData();
@@ -3866,8 +3669,6 @@ void Application::renderAvatars(bool forceRenderHead, bool selfAvatarOnly) { · 3 unmodified lines
38663669 avatar->render(false);
38673670 avatar->setDisplayingLookatVectors(Menu::getInstance()->isOptionChecked(MenuOption::LookAtVectors));
38683671 }
3869−
3870− node->unlock();
38713672 }
38723673
38733674 // render avatar fades
@@ -4112,28 +3913,11 @@ void Application::eyedropperVoxelUnderCursor() { · 238 unmodified lines
41123913 }
41133914 }
41143915
4115−void Application::toggleFollowMode() {
4116− glm::vec3 mouseRayOrigin, mouseRayDirection;
4117− _viewFrustum.computePickRay(_pieMenu.getX() / (float)_glWidget->width(),
4118− _pieMenu.getY() / (float)_glWidget->height(),
4119− mouseRayOrigin, mouseRayDirection);
4120− glm::vec3 eyePositionIgnored;
4121− QUuid nodeUUIDIgnored;
4122− Avatar* leadingAvatar = findLookatTargetAvatar(mouseRayOrigin, mouseRayDirection, eyePositionIgnored, nodeUUIDIgnored);
4123−
4124− _myAvatar.follow(leadingAvatar);
4125−}
4126−
41273916 void Application::resetSensors() {
41283917 _headMouseX = _mouseX = _glWidget->width() / 2;
41293918 _headMouseY = _mouseY = _glWidget->height() / 2;
41303919
4131− if (_serialHeadSensor.isActive()) {
4132− _serialHeadSensor.resetAverages();
4133− }
4134− _webcam.reset();
41353920 _faceshift.reset();
4136− LeapManager::reset();
41373921
41383922 if (OculusManager::isConnected()) {
41393923 OculusManager::reset();
@@ -4184,13 +3968,13 @@ void Application::updateWindowTitle(){ · 44 unmodified lines
41843968 title += _profile.getLastDomain();
41853969 title += buildVersion;
41863970
4187− qDebug("Application title set to: %s.\n", title.toStdString().c_str());
3971+ qDebug("Application title set to: %s", title.toStdString().c_str());
41883972 _window->setWindowTitle(title);
41893973 }
41903974
4191−void Application::domainChanged(QString domain) {
3975+void Application::domainChanged(const QString& domainHostname) {
41923976 // update the user's last domain in their Profile (which will propagate to data-server)
4193− _profile.updateDomain(domain);
3977+ _profile.updateDomain(domainHostname);
41943978
41953979 updateWindowTitle();
41963980
@@ -4201,13 +3985,13 @@ void Application::domainChanged(QString domain) { · 4 unmodified lines
42013985 _voxelServerJurisdictions.clear();
42023986 _octreeServerSceneStats.clear();
42033987 _particleServerJurisdictions.clear();
4204−}
4205−
4206−void Application::nodeAdded(Node* node) {
42073988
3989+ // reset our persist thread
3990+ qDebug() << "Domain changed to" << domainHostname << ". Swapping persist cache.";
3991+ updateLocalOctreeCache();
42083992 }
42093993
4210−void Application::nodeKilled(Node* node) {
3994+void Application::nodeKilled(SharedNodePointer node) {
42113995 if (node->getType() == NODE_TYPE_VOXEL_SERVER) {
42123996 QUuid nodeUUID = node->getUUID();
42133997 // see if this is the first we've heard of this node...
@@ -4223,7 +4007,7 @@ void Application::nodeKilled(Node* node) { · 9 unmodified lines
42234007 if (!Menu::getInstance()->isOptionChecked(MenuOption::DontFadeOnVoxelServerChanges)) {
42244008 VoxelFade fade(VoxelFade::FADE_OUT, NODE_KILLED_RED, NODE_KILLED_GREEN, NODE_KILLED_BLUE);
42254009 fade.voxelDetails = rootDetails;
4226− const float slightly_smaller = 0.99;
4010+ const float slightly_smaller = 0.99f;
42274011 fade.voxelDetails.s = fade.voxelDetails.s * slightly_smaller;
42284012 _voxelFades.push_back(fade);
42294013 }
@@ -4254,7 +4038,7 @@ void Application::nodeKilled(Node* node) { · 24 unmodified lines
42544038 if (!Menu::getInstance()->isOptionChecked(MenuOption::DontFadeOnVoxelServerChanges)) {
42554039 VoxelFade fade(VoxelFade::FADE_OUT, NODE_KILLED_RED, NODE_KILLED_GREEN, NODE_KILLED_BLUE);
42564040 fade.voxelDetails = rootDetails;
4257− const float slightly_smaller = 0.99;
4041+ const float slightly_smaller = 0.99f;
42584042 fade.voxelDetails.s = fade.voxelDetails.s * slightly_smaller;
42594043 _voxelFades.push_back(fade);
42604044 }
@@ -4287,7 +4071,7 @@ void Application::trackIncomingVoxelPacket(unsigned char* messageData, ssize_t m · 26 unmodified lines
42874071 const HifiSockAddr& senderSockAddr, bool wasStatsPacket) {
42884072
42894073 // Attempt to identify the sender from it's address.
4290− Node* serverNode = NodeList::getInstance()->nodeWithAddress(senderSockAddr);
4074+ SharedNodePointer serverNode = NodeList::getInstance()->nodeWithAddress(senderSockAddr);
42914075 if (serverNode) {
42924076 QUuid nodeUUID = serverNode->getUUID();
42934077
@@ -4304,7 +4088,7 @@ void Application::trackIncomingVoxelPacket(unsigned char* messageData, ssize_t m · 10 unmodified lines
43044088 int Application::parseOctreeStats(unsigned char* messageData, ssize_t messageLength, const HifiSockAddr& senderSockAddr) {
43054089
43064090 // But, also identify the sender, and keep track of the contained jurisdiction root for this server
4307− Node* server = NodeList::getInstance()->nodeWithAddress(senderSockAddr);
4091+ SharedNodePointer server = NodeList::getInstance()->nodeWithAddress(senderSockAddr);
43084092
43094093 // parse the incoming stats datas stick it in a temporary object for now, while we
43104094 // determine which server it belongs to
@@ -4344,7 +4128,7 @@ int Application::parseOctreeStats(unsigned char* messageData, ssize_t messageLen · 33 unmodified lines
43444128 if (!Menu::getInstance()->isOptionChecked(MenuOption::DontFadeOnVoxelServerChanges)) {
43454129 VoxelFade fade(VoxelFade::FADE_OUT, NODE_ADDED_RED, NODE_ADDED_GREEN, NODE_ADDED_BLUE);
43464130 fade.voxelDetails = rootDetails;
4347− const float slightly_smaller = 0.99;
4131+ const float slightly_smaller = 0.99f;
43484132 fade.voxelDetails.s = fade.voxelDetails.s * slightly_smaller;
43494133 _voxelFades.push_back(fade);
43504134 }
@@ -4361,101 +4145,92 @@ int Application::parseOctreeStats(unsigned char* messageData, ssize_t messageLen · 10 unmodified lines
43614145 }
43624146
43634147 // Receive packets from other nodes/servers and decide what to do with them!
4364−void* Application::networkReceive(void* args) {
4148+void Application::processDatagrams() {
43654149 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
43664150 "Application::networkReceive()");
43674151
43684152 HifiSockAddr senderSockAddr;
43694153 ssize_t bytesReceived;
43704154
4371− Application* app = Application::getInstance();
4372− while (!app->_stopNetworkReceiveThread) {
4373− if (NodeList::getInstance()->getNodeSocket().hasPendingDatagrams() &&
4374− (bytesReceived = NodeList::getInstance()->getNodeSocket().readDatagram((char*) app->_incomingPacket,
4375− MAX_PACKET_SIZE,
4376− senderSockAddr.getAddressPointer(),
4377− senderSockAddr.getPortPointer()))) {
4378−
4379− app->_packetCount++;
4380− app->_bytesCount += bytesReceived;
4381−
4382− if (packetVersionMatch(app->_incomingPacket)) {
4383− // only process this packet if we have a match on the packet version
4384− switch (app->_incomingPacket[0]) {
4385− case PACKET_TYPE_TRANSMITTER_DATA_V2:
4386− // V2 = IOS transmitter app
4387− app->_myTransmitter.processIncomingData(app->_incomingPacket, bytesReceived);
4388−
4389− break;
4390− case PACKET_TYPE_MIXED_AUDIO:
4391− QMetaObject::invokeMethod(&app->_audio, "addReceivedAudioToBuffer", Qt::QueuedConnection,
4392− Q_ARG(QByteArray, QByteArray((char*) app->_incomingPacket, bytesReceived)));
4393− break;
4394−
4395− case PACKET_TYPE_PARTICLE_ADD_RESPONSE:
4396− // look up our ParticleEditHanders....
4397− ParticleEditHandle::handleAddResponse(app->_incomingPacket, bytesReceived);
4398− break;
4399−
4400− case PACKET_TYPE_PARTICLE_DATA:
4401− case PACKET_TYPE_VOXEL_DATA:
4402− case PACKET_TYPE_VOXEL_ERASE:
4403− case PACKET_TYPE_OCTREE_STATS:
4404− case PACKET_TYPE_ENVIRONMENT_DATA: {
4405− PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
4406− "Application::networkReceive()... _voxelProcessor.queueReceivedPacket()");
4407−
4408− bool wantExtraDebugging = app->getLogger()->extraDebugging();
4409− if (wantExtraDebugging && app->_incomingPacket[0] == PACKET_TYPE_VOXEL_DATA) {
4410− int numBytesPacketHeader = numBytesForPacketHeader(app->_incomingPacket);
4411− unsigned char* dataAt = app->_incomingPacket + numBytesPacketHeader;
4412− dataAt += sizeof(VOXEL_PACKET_FLAGS);
4413− VOXEL_PACKET_SEQUENCE sequence = (*(VOXEL_PACKET_SEQUENCE*)dataAt);
4414− dataAt += sizeof(VOXEL_PACKET_SEQUENCE);
4415− VOXEL_PACKET_SENT_TIME sentAt = (*(VOXEL_PACKET_SENT_TIME*)dataAt);
4416− dataAt += sizeof(VOXEL_PACKET_SENT_TIME);
4417− VOXEL_PACKET_SENT_TIME arrivedAt = usecTimestampNow();
4418− int flightTime = arrivedAt - sentAt;
4419−
4420− printf("got PACKET_TYPE_VOXEL_DATA, sequence:%d flightTime:%d\n", sequence, flightTime);
4421− }
4422−
4423− // add this packet to our list of voxel packets and process them on the voxel processing
4424− app->_voxelProcessor.queueReceivedPacket(senderSockAddr, app->_incomingPacket, bytesReceived);
4425− break;
4155+ while (NodeList::getInstance()->getNodeSocket().hasPendingDatagrams() &&
4156+ (bytesReceived = NodeList::getInstance()->getNodeSocket().readDatagram((char*) _incomingPacket,
4157+ MAX_PACKET_SIZE,
4158+ senderSockAddr.getAddressPointer(),
4159+ senderSockAddr.getPortPointer()))) {
4160+
4161+ _packetCount++;
4162+ _bytesCount += bytesReceived;
4163+
4164+ if (packetVersionMatch(_incomingPacket)) {
4165+ // only process this packet if we have a match on the packet version
4166+ switch (_incomingPacket[0]) {
4167+ case PACKET_TYPE_TRANSMITTER_DATA_V2:
4168+ // V2 = IOS transmitter app
4169+ _myTransmitter.processIncomingData(_incomingPacket, bytesReceived);
4170+
4171+ break;
4172+ case PACKET_TYPE_MIXED_AUDIO:
4173+ QMetaObject::invokeMethod(&_audio, "addReceivedAudioToBuffer", Qt::QueuedConnection,
4174+ Q_ARG(QByteArray, QByteArray((char*) _incomingPacket, bytesReceived)));
4175+ break;
4176+
4177+ case PACKET_TYPE_PARTICLE_ADD_RESPONSE:
4178+ // look up our ParticleEditHanders....
4179+ ParticleEditHandle::handleAddResponse(_incomingPacket, bytesReceived);
4180+ break;
4181+
4182+ case PACKET_TYPE_PARTICLE_DATA:
4183+ case PACKET_TYPE_VOXEL_DATA:
4184+ case PACKET_TYPE_VOXEL_ERASE:
4185+ case PACKET_TYPE_OCTREE_STATS:
4186+ case PACKET_TYPE_ENVIRONMENT_DATA: {
4187+ PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
4188+ "Application::networkReceive()... _voxelProcessor.queueReceivedPacket()");
4189+
4190+ bool wantExtraDebugging = getLogger()->extraDebugging();
4191+ if (wantExtraDebugging && _incomingPacket[0] == PACKET_TYPE_VOXEL_DATA) {
4192+ int numBytesPacketHeader = numBytesForPacketHeader(_incomingPacket);
4193+ unsigned char* dataAt = _incomingPacket + numBytesPacketHeader;
4194+ dataAt += sizeof(VOXEL_PACKET_FLAGS);
4195+ VOXEL_PACKET_SEQUENCE sequence = (*(VOXEL_PACKET_SEQUENCE*)dataAt);
4196+ dataAt += sizeof(VOXEL_PACKET_SEQUENCE);
4197+ VOXEL_PACKET_SENT_TIME sentAt = (*(VOXEL_PACKET_SENT_TIME*)dataAt);
4198+ dataAt += sizeof(VOXEL_PACKET_SENT_TIME);
4199+ VOXEL_PACKET_SENT_TIME arrivedAt = usecTimestampNow();
4200+ int flightTime = arrivedAt - sentAt;
4201+
4202+ printf("got PACKET_TYPE_VOXEL_DATA, sequence:%d flightTime:%d\n", sequence, flightTime);
44264203 }
4427− case PACKET_TYPE_BULK_AVATAR_DATA:
4428− NodeList::getInstance()->processBulkNodeData(senderSockAddr,
4429− app->_incomingPacket,
4430− bytesReceived);
4431− getInstance()->_bandwidthMeter.inputStream(BandwidthMeter::AVATARS).updateValue(bytesReceived);
4432− break;
4433− case PACKET_TYPE_AVATAR_URLS:
4434− processAvatarURLsMessage(app->_incomingPacket, bytesReceived);
4435− break;
4436− case PACKET_TYPE_AVATAR_FACE_VIDEO:
4437− processAvatarFaceVideoMessage(app->_incomingPacket, bytesReceived);
4438− break;
4439− case PACKET_TYPE_DATA_SERVER_GET:
4440− case PACKET_TYPE_DATA_SERVER_PUT:
4441− case PACKET_TYPE_DATA_SERVER_SEND:
4442− case PACKET_TYPE_DATA_SERVER_CONFIRM:
4443− DataServerClient::processMessageFromDataServer(app->_incomingPacket, bytesReceived);
4444− break;
4445− default:
4446− NodeList::getInstance()->processNodeData(senderSockAddr, app->_incomingPacket, bytesReceived);
4447− break;
4204+
4205+ // add this packet to our list of voxel packets and process them on the voxel processing
4206+ _voxelProcessor.queueReceivedPacket(senderSockAddr, _incomingPacket, bytesReceived);
4207+ break;
44484208 }
4209+ case PACKET_TYPE_METAVOXEL_DATA:
4210+ _metavoxels.processData(QByteArray((const char*) _incomingPacket, bytesReceived),
4211+ senderSockAddr);
4212+ break;
4213+ case PACKET_TYPE_BULK_AVATAR_DATA:
4214+ NodeList::getInstance()->processBulkNodeData(senderSockAddr,
4215+ _incomingPacket,
4216+ bytesReceived);
4217+ getInstance()->_bandwidthMeter.inputStream(BandwidthMeter::AVATARS).updateValue(bytesReceived);
4218+ break;
4219+ case PACKET_TYPE_AVATAR_URLS:
4220+ processAvatarURLsMessage(_incomingPacket, bytesReceived);
4221+ break;
4222+ case PACKET_TYPE_DATA_SERVER_GET:
4223+ case PACKET_TYPE_DATA_SERVER_PUT:
4224+ case PACKET_TYPE_DATA_SERVER_SEND:
4225+ case PACKET_TYPE_DATA_SERVER_CONFIRM:
4226+ DataServerClient::processMessageFromDataServer(_incomingPacket, bytesReceived);
4227+ break;
4228+ default:
4229+ NodeList::getInstance()->processNodeData(senderSockAddr, _incomingPacket, bytesReceived);
4230+ break;
44494231 }
4450− } else if (!app->_enableNetworkThread) {
4451− break;
44524232 }
44534233 }
4454−
4455− if (app->_enableNetworkThread) {
4456− pthread_exit(0);
4457− }
4458− return NULL;
44594234 }
44604235
44614236 void Application::packetSentNotification(ssize_t length) {
@@ -4472,14 +4247,12 @@ void Application::loadScript() { · 10 unmodified lines
44724247 QByteArray fileNameAscii = fileNameString.toLocal8Bit();
44734248 const char* fileName = fileNameAscii.data();
44744249
4475− printf("fileName:%s\n",fileName);
4476−
44774250 std::ifstream file(fileName, std::ios::in|std::ios::binary|std::ios::ate);
44784251 if(!file.is_open()) {
4479− printf("error loading file\n");
4252+ qDebug("Error loading file %s", fileName);
44804253 return;
44814254 }
4482− qDebug("loading file %s...\n", fileName);
4255+ qDebug("Loading file %s...", fileName);
44834256
44844257 // get file length....
44854258 unsigned long fileLength = file.tellg();
@@ -4536,3 +4309,51 @@ void Application::toggleLogDialog() { · 50 unmodified lines
45364309 _logDialog->close();
45374310 }
45384311 }
4312+
4313+
4314+void Application::initAvatarAndViewFrustum() {
4315+ updateAvatar(0.f);
4316+}
4317+
4318+QString Application::getLocalVoxelCacheFileName() {
4319+ QString fileName = QStandardPaths::writableLocation(QStandardPaths::DataLocation);
4320+ QDir logDir(fileName);
4321+ if (!logDir.exists(fileName)) {
4322+ logDir.mkdir(fileName);
4323+ }
4324+
4325+ fileName.append(QString("/hifi.voxelscache."));
4326+ fileName.append(_profile.getLastDomain());
4327+ fileName.append(QString(".svo"));
4328+
4329+ return fileName;
4330+}
4331+
4332+
4333+void Application::updateLocalOctreeCache(bool firstTime) {
4334+ // only do this if we've already got a persistThread or we're told this is the first time
4335+ if (firstTime || _persistThread) {
4336+
4337+ if (_persistThread) {
4338+ _persistThread->terminate();
4339+ _persistThread->deleteLater();
4340+ _persistThread = NULL;
4341+ }
4342+
4343+ QString localVoxelCacheFileName = getLocalVoxelCacheFileName();
4344+ const int LOCAL_CACHE_PERSIST_INTERVAL = 1000 * 10; // every 10 seconds
4345+
4346+ if (!Menu::getInstance()->isOptionChecked(MenuOption::DisableLocalVoxelCache)) {
4347+ _persistThread = new OctreePersistThread(_voxels.getTree(),
4348+ localVoxelCacheFileName.toLocal8Bit().constData(),LOCAL_CACHE_PERSIST_INTERVAL);
4349+
4350+ qDebug() << "updateLocalOctreeCache()... localVoxelCacheFileName=" << localVoxelCacheFileName;
4351+ }
4352+
4353+ if (_persistThread) {
4354+ _voxels.beginLoadingLocalVoxelCache(); // while local voxels are importing, don't do individual node VBO updates
4355+ connect(_persistThread, SIGNAL(loadCompleted()), &_voxels, SLOT(localVoxelCacheLoaded()));
4356+ _persistThread->initialize(true);
4357+ }
4358+ }
4359+}

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