History

added option to disable local cache file

Brad Hefta-Gaub committed 12 years ago

Commit f1e98721 parent dfb70ee3 files · +226 −216Browse files

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

Unified · Split

interface/src/Application.cpp+60−52
@@ -165,7 +165,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 164 unmodified lines
165165 }
166166
167167 NodeList* nodeList = NodeList::createInstance(NODE_TYPE_AGENT, listenPort);
168−
168+
169169 // connect our processDatagrams slot to the QUDPSocket readyRead() signal
170170 connect(&nodeList->getNodeSocket(), SIGNAL(readyRead()), SLOT(processDatagrams()));
171171
@@ -176,7 +176,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 4 unmodified lines
176176 connect(audioThread, SIGNAL(started()), &_audio, SLOT(start()));
177177
178178 audioThread->start();
179−
179+
180180 connect(nodeList, SIGNAL(domainChanged(const QString&)), SLOT(domainChanged(const QString&)));
181181
182182 connect(nodeList, SIGNAL(nodeKilled(SharedNodePointer)), SLOT(nodeKilled(SharedNodePointer)));
@@ -209,7 +209,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 26 unmodified lines
209209 #endif
210210
211211 // tell the NodeList instance who to tell the domain server we care about
212− const char nodeTypesOfInterest[] = {NODE_TYPE_AUDIO_MIXER, NODE_TYPE_AVATAR_MIXER, NODE_TYPE_VOXEL_SERVER,
212+ const char nodeTypesOfInterest[] = {NODE_TYPE_AUDIO_MIXER, NODE_TYPE_AVATAR_MIXER, NODE_TYPE_VOXEL_SERVER,
213213 NODE_TYPE_PARTICLE_SERVER, NODE_TYPE_METAVOXEL_SERVER};
214214 nodeList->setNodeTypesOfInterest(nodeTypesOfInterest, sizeof(nodeTypesOfInterest));
215215
@@ -1416,8 +1416,10 @@ void Application::terminate() { · 1200 unmodified lines
14161416 _voxelHideShowThread.terminate();
14171417 _voxelEditSender.terminate();
14181418 _particleEditSender.terminate();
1419− _persistThread->terminate();
1420− _persistThread = NULL;
1419+ if (_persistThread) {
1420+ _persistThread->terminate();
1421+ _persistThread = NULL;
1422+ }
14211423 }
14221424
14231425 static Avatar* processAvatarMessageHeader(unsigned char*& packetData, size_t& dataBytes) {
@@ -1966,12 +1968,12 @@ Avatar* Application::findLookatTargetAvatar(const glm::vec3& mouseRayOrigin, con · 542 unmodified lines
19661968 if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) {
19671969 Avatar* avatar = (Avatar*)node->getLinkedData();
19681970 float distance;
1969−
1971+
19701972 if (avatar->findRayIntersection(mouseRayOrigin, mouseRayDirection, distance)) {
19711973 // rescale to compensate for head embiggening
19721974 eyePosition = (avatar->getHead().calculateAverageEyePosition() - avatar->getHead().getScalePivot()) *
19731975 (avatar->getScale() / avatar->getHead().getScale()) + avatar->getHead().getScalePivot();
1974−
1976+
19751977 _lookatIndicatorScale = avatar->getHead().getScale();
19761978 _lookatOtherPosition = avatar->getHead().getPosition();
19771979 nodeUUID = avatar->getOwningNode()->getUUID();
@@ -1979,7 +1981,7 @@ Avatar* Application::findLookatTargetAvatar(const glm::vec3& mouseRayOrigin, con · 1 unmodified line
19791981 }
19801982 }
19811983 }
1982−
1984+
19831985 return NULL;
19841986 }
19851987
@@ -2021,7 +2023,7 @@ void Application::renderHighlightVoxel(VoxelDetail voxel) { · 35 unmodified lines
20212023 void Application::updateAvatars(float deltaTime, glm::vec3 mouseRayOrigin, glm::vec3 mouseRayDirection) {
20222024 bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
20232025 PerformanceWarning warn(showWarnings, "Application::updateAvatars()");
2024−
2026+
20252027 foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) {
20262028 QMutexLocker(&node->getMutex());
20272029 if (node->getLinkedData()) {
@@ -2038,11 +2040,11 @@ void Application::updateAvatars(float deltaTime, glm::vec3 mouseRayOrigin, glm:: · 10 unmodified lines
20382040 for (vector<Avatar*>::iterator fade = _avatarFades.begin(); fade != _avatarFades.end(); fade++) {
20392041 Avatar* avatar = *fade;
20402042 const float SHRINK_RATE = 0.9f;
2041−
2043+
20422044 avatar->setTargetScale(avatar->getScale() * SHRINK_RATE);
2043−
2045+
20442046 const float MIN_FADE_SCALE = 0.001;
2045−
2047+
20462048 if (avatar->getTargetScale() < MIN_FADE_SCALE) {
20472049 delete avatar;
20482050 _avatarFades.erase(fade--);
@@ -2260,6 +2262,7 @@ void Application::updateMouseVoxels(float deltaTime, glm::vec3& mouseRayOrigin, · 211 unmodified lines
22602262 }
22612263 }
22622264
2265+
22632266 void Application::updateHandAndTouch(float deltaTime) {
22642267 bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
22652268 PerformanceWarning warn(showWarnings, "Application::updateHandAndTouch()");
@@ -2303,7 +2306,9 @@ void Application::updateThreads(float deltaTime) { · 37 unmodified lines
23032306 _voxelHideShowThread.threadRoutine();
23042307 _voxelEditSender.threadRoutine();
23052308 _particleEditSender.threadRoutine();
2306− _persistThread->threadRoutine();
2309+ if (_persistThread) {
2310+ _persistThread->threadRoutine();
2311+ }
23072312 }
23082313 }
23092314
@@ -2613,32 +2618,32 @@ void Application::queryOctree(NODE_TYPE serverType, PACKET_TYPE packetType, Node · 303 unmodified lines
26132618 int totalServers = 0;
26142619 int inViewServers = 0;
26152620 int unknownJurisdictionServers = 0;
2616−
2621+
26172622 foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) {
26182623 // only send to the NodeTypes that are serverType
26192624 if (node->getActiveSocket() != NULL && node->getType() == serverType) {
26202625 totalServers++;
2621−
2626+
26222627 // get the server bounds for this server
26232628 QUuid nodeUUID = node->getUUID();
2624−
2629+
26252630 // if we haven't heard from this voxel server, go ahead and send it a query, so we
26262631 // can get the jurisdiction...
26272632 if (jurisdictions.find(nodeUUID) == jurisdictions.end()) {
26282633 unknownJurisdictionServers++;
26292634 } else {
26302635 const JurisdictionMap& map = (jurisdictions)[nodeUUID];
2631−
2636+
26322637 unsigned char* rootCode = map.getRootOctalCode();
2633−
2638+
26342639 if (rootCode) {
26352640 VoxelPositionSize rootDetails;
26362641 voxelDetailsForCode(rootCode, rootDetails);
26372642 AABox serverBounds(glm::vec3(rootDetails.x, rootDetails.y, rootDetails.z), rootDetails.s);
26382643 serverBounds.scale(TREE_SCALE);
2639−
2644+
26402645 ViewFrustum::location serverFrustumLocation = _viewFrustum.boxInFrustum(serverBounds);
2641−
2646+
26422647 if (serverFrustumLocation != ViewFrustum::OUTSIDE) {
26432648 inViewServers++;
26442649 }
@@ -2671,20 +2676,20 @@ void Application::queryOctree(NODE_TYPE serverType, PACKET_TYPE packetType, Node · 26 unmodified lines
26712676 if (wantExtraDebugging && unknownJurisdictionServers > 0) {
26722677 qDebug("perServerPPS: %d perUnknownServer: %d", perServerPPS, perUnknownServer);
26732678 }
2674−
2679+
26752680 NodeList* nodeList = NodeList::getInstance();
2676−
2681+
26772682 foreach (const SharedNodePointer& node, nodeList->getNodeHash()) {
26782683 // only send to the NodeTypes that are serverType
26792684 if (node->getActiveSocket() != NULL && node->getType() == serverType) {
2680−
2681−
2685+
2686+
26822687 // get the server bounds for this server
26832688 QUuid nodeUUID = node->getUUID();
2684−
2689+
26852690 bool inView = false;
26862691 bool unknownView = false;
2687−
2692+
26882693 // if we haven't heard from this voxel server, go ahead and send it a query, so we
26892694 // can get the jurisdiction...
26902695 if (jurisdictions.find(nodeUUID) == jurisdictions.end()) {
@@ -2694,15 +2699,15 @@ void Application::queryOctree(NODE_TYPE serverType, PACKET_TYPE packetType, Node · 3 unmodified lines
26942699 }
26952700 } else {
26962701 const JurisdictionMap& map = (jurisdictions)[nodeUUID];
2697−
2702+
26982703 unsigned char* rootCode = map.getRootOctalCode();
2699−
2704+
27002705 if (rootCode) {
27012706 VoxelPositionSize rootDetails;
27022707 voxelDetailsForCode(rootCode, rootDetails);
27032708 AABox serverBounds(glm::vec3(rootDetails.x, rootDetails.y, rootDetails.z), rootDetails.s);
27042709 serverBounds.scale(TREE_SCALE);
2705−
2710+
27062711 ViewFrustum::location serverFrustumLocation = _viewFrustum.boxInFrustum(serverBounds);
27072712 if (serverFrustumLocation != ViewFrustum::OUTSIDE) {
27082713 inView = true;
@@ -2715,7 +2720,7 @@ void Application::queryOctree(NODE_TYPE serverType, PACKET_TYPE packetType, Node · 6 unmodified lines
27152720 }
27162721 }
27172722 }
2718−
2723+
27192724 if (inView) {
27202725 _voxelQuery.setMaxOctreePacketsPerSecond(perServerPPS);
27212726 } else if (unknownView) {
@@ -2723,7 +2728,7 @@ void Application::queryOctree(NODE_TYPE serverType, PACKET_TYPE packetType, Node · 1 unmodified line
27232728 qDebug() << "no known jurisdiction for node " << *node << ", give it budget of "
27242729 << perUnknownServer << " to send us jurisdiction.";
27252730 }
2726−
2731+
27272732 // set the query's position/orientation to be degenerate in a manner that will get the scene quickly
27282733 // If there's only one server, then don't do this, and just let the normal voxel query pass through
27292734 // as expected... this way, we will actually get a valid scene if there is one to be seen
@@ -2747,24 +2752,24 @@ void Application::queryOctree(NODE_TYPE serverType, PACKET_TYPE packetType, Node · 17 unmodified lines
27472752 }
27482753 // set up the packet for sending...
27492754 unsigned char* endOfVoxelQueryPacket = voxelQueryPacket;
2750−
2755+
27512756 // insert packet type/version and node UUID
27522757 endOfVoxelQueryPacket += populateTypeAndVersion(endOfVoxelQueryPacket, packetType);
27532758 QByteArray ownerUUID = nodeList->getOwnerUUID().toRfc4122();
27542759 memcpy(endOfVoxelQueryPacket, ownerUUID.constData(), ownerUUID.size());
27552760 endOfVoxelQueryPacket += ownerUUID.size();
2756−
2761+
27572762 // encode the query data...
27582763 endOfVoxelQueryPacket += _voxelQuery.getBroadcastData(endOfVoxelQueryPacket);
2759−
2764+
27602765 int packetLength = endOfVoxelQueryPacket - voxelQueryPacket;
2761−
2766+
27622767 // make sure we still have an active socket
27632768 if (node->getActiveSocket()) {
27642769 nodeList->getNodeSocket().writeDatagram((char*) voxelQueryPacket, packetLength,
27652770 node->getActiveSocket()->getAddress(), node->getActiveSocket()->getPort());
27662771 }
2767−
2772+
27682773 // Feed number of bytes to corresponding channel of the bandwidth meter
27692774 _bandwidthMeter.outputStream(BandwidthMeter::VOXELS).updateValue(packetLength);
27702775 }
@@ -3244,7 +3249,7 @@ void Application::displayOverlay() { · 473 unmodified lines
32443249 char nodes[100];
32453250
32463251 int totalAvatars = 0, totalServers = 0;
3247−
3252+
32483253 foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) {
32493254 node->getType() == NODE_TYPE_AGENT ? totalAvatars++ : totalServers++;
32503255 }
@@ -3358,7 +3363,7 @@ void Application::displayStats() { · 107 unmodified lines
33583363 // Now handle voxel servers, since there could be more than one, we average their ping times
33593364 unsigned long totalPingVoxel = 0;
33603365 int voxelServerCount = 0;
3361−
3366+
33623367 foreach (const SharedNodePointer& node, nodeList->getNodeHash()) {
33633368 if (node->getType() == NODE_TYPE_VOXEL_SERVER) {
33643369 totalPingVoxel += node->getPingMs();
@@ -3368,7 +3373,7 @@ void Application::displayStats() { · 3 unmodified lines
33683373 }
33693374 }
33703375 }
3371−
3376+
33723377 if (voxelServerCount) {
33733378 pingVoxel = totalPingVoxel/voxelServerCount;
33743379 }
@@ -3704,10 +3709,10 @@ void Application::renderAvatars(bool forceRenderHead, bool selfAvatarOnly) { · 329 unmodified lines
37043709 if (!selfAvatarOnly) {
37053710 // Render avatars of other nodes
37063711 NodeList* nodeList = NodeList::getInstance();
3707−
3712+
37083713 foreach (const SharedNodePointer& node, nodeList->getNodeHash()) {
37093714 QMutexLocker(&node->getMutex());
3710−
3715+
37113716 if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) {
37123717 Avatar *avatar = (Avatar *)node->getLinkedData();
37133718 if (!avatar->isInitialized()) {
@@ -4205,28 +4210,28 @@ void Application::processDatagrams() { · 491 unmodified lines
42054210 MAX_PACKET_SIZE,
42064211 senderSockAddr.getAddressPointer(),
42074212 senderSockAddr.getPortPointer()))) {
4208−
4213+
42094214 _packetCount++;
42104215 _bytesCount += bytesReceived;
4211−
4216+
42124217 if (packetVersionMatch(_incomingPacket)) {
42134218 // only process this packet if we have a match on the packet version
42144219 switch (_incomingPacket[0]) {
42154220 case PACKET_TYPE_TRANSMITTER_DATA_V2:
42164221 // V2 = IOS transmitter app
42174222 _myTransmitter.processIncomingData(_incomingPacket, bytesReceived);
4218−
4223+
42194224 break;
42204225 case PACKET_TYPE_MIXED_AUDIO:
42214226 QMetaObject::invokeMethod(&_audio, "addReceivedAudioToBuffer", Qt::QueuedConnection,
42224227 Q_ARG(QByteArray, QByteArray((char*) _incomingPacket, bytesReceived)));
42234228 break;
4224−
4229+
42254230 case PACKET_TYPE_PARTICLE_ADD_RESPONSE:
42264231 // look up our ParticleEditHanders....
42274232 ParticleEditHandle::handleAddResponse(_incomingPacket, bytesReceived);
42284233 break;
4229−
4234+
42304235 case PACKET_TYPE_PARTICLE_DATA:
42314236 case PACKET_TYPE_VOXEL_DATA:
42324237 case PACKET_TYPE_VOXEL_ERASE:
@@ -4234,7 +4239,7 @@ void Application::processDatagrams() { · 1 unmodified line
42344239 case PACKET_TYPE_ENVIRONMENT_DATA: {
42354240 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
42364241 "Application::networkReceive()... _voxelProcessor.queueReceivedPacket()");
4237−
4242+
42384243 bool wantExtraDebugging = getLogger()->extraDebugging();
42394244 if (wantExtraDebugging && _incomingPacket[0] == PACKET_TYPE_VOXEL_DATA) {
42404245 int numBytesPacketHeader = numBytesForPacketHeader(_incomingPacket);
@@ -4246,10 +4251,10 @@ void Application::processDatagrams() { · 5 unmodified lines
42464251 dataAt += sizeof(VOXEL_PACKET_SENT_TIME);
42474252 VOXEL_PACKET_SENT_TIME arrivedAt = usecTimestampNow();
42484253 int flightTime = arrivedAt - sentAt;
4249−
4254+
42504255 printf("got PACKET_TYPE_VOXEL_DATA, sequence:%d flightTime:%d\n", sequence, flightTime);
42514256 }
4252−
4257+
42534258 // add this packet to our list of voxel packets and process them on the voxel processing
42544259 _voxelProcessor.queueReceivedPacket(senderSockAddr, _incomingPacket, bytesReceived);
42554260 break;
@@ -4392,10 +4397,13 @@ void Application::updateLocalOctreeCache(bool firstTime) { · 136 unmodified lines
43924397
43934398 QString localVoxelCacheFileName = getLocalVoxelCacheFileName();
43944399 const int LOCAL_CACHE_PERSIST_INTERVAL = 1000 * 10; // every 10 seconds
4395− _persistThread = new OctreePersistThread(_voxels.getTree(),
4396− localVoxelCacheFileName.toLocal8Bit().constData(),LOCAL_CACHE_PERSIST_INTERVAL);
43974400
4398− qDebug() << "updateLocalOctreeCache()... localVoxelCacheFileName=" << localVoxelCacheFileName;
4401+ if (!Menu::getInstance()->isOptionChecked(MenuOption::DisableLocalVoxelCache)) {
4402+ _persistThread = new OctreePersistThread(_voxels.getTree(),
4403+ localVoxelCacheFileName.toLocal8Bit().constData(),LOCAL_CACHE_PERSIST_INTERVAL);
4404+
4405+ qDebug() << "updateLocalOctreeCache()... localVoxelCacheFileName=" << localVoxelCacheFileName;
4406+ }
43994407
44004408 if (_persistThread) {
44014409 _voxels.beginLoadingLocalVoxelCache(); // while local voxels are importing, don't do individual node VBO updates

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