Showing the changes to interface/src/Application.cpp (1 of 3 files). Show all
Unified · Split
| @@ -165,7 +165,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 164 unmodified lines | ||
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | NodeList* nodeList = NodeList::createInstance(NODE_TYPE_AGENT, listenPort); |
| 168 | − | |
| 168 | + | |
| 169 | 169 | // connect our processDatagrams slot to the QUDPSocket readyRead() signal |
| 170 | 170 | connect(&nodeList->getNodeSocket(), SIGNAL(readyRead()), SLOT(processDatagrams())); |
| 171 | 171 | |
| @@ -176,7 +176,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 4 unmodified lines | ||
| 176 | 176 | connect(audioThread, SIGNAL(started()), &_audio, SLOT(start())); |
| 177 | 177 | |
| 178 | 178 | audioThread->start(); |
| 179 | − | |
| 179 | + | |
| 180 | 180 | connect(nodeList, SIGNAL(domainChanged(const QString&)), SLOT(domainChanged(const QString&))); |
| 181 | 181 | |
| 182 | 182 | connect(nodeList, SIGNAL(nodeKilled(SharedNodePointer)), SLOT(nodeKilled(SharedNodePointer))); |
| @@ -209,7 +209,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 26 unmodified lines | ||
| 209 | 209 | #endif |
| 210 | 210 | |
| 211 | 211 | // 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, | |
| 213 | 213 | NODE_TYPE_PARTICLE_SERVER, NODE_TYPE_METAVOXEL_SERVER}; |
| 214 | 214 | nodeList->setNodeTypesOfInterest(nodeTypesOfInterest, sizeof(nodeTypesOfInterest)); |
| 215 | 215 | |
| @@ -1416,8 +1416,10 @@ void Application::terminate() { · 1200 unmodified lines | ||
| 1416 | 1416 | _voxelHideShowThread.terminate(); |
| 1417 | 1417 | _voxelEditSender.terminate(); |
| 1418 | 1418 | _particleEditSender.terminate(); |
| 1419 | − _persistThread->terminate(); | |
| 1420 | − _persistThread = NULL; | |
| 1419 | + if (_persistThread) { | |
| 1420 | + _persistThread->terminate(); | |
| 1421 | + _persistThread = NULL; | |
| 1422 | + } | |
| 1421 | 1423 | } |
| 1422 | 1424 | |
| 1423 | 1425 | static Avatar* processAvatarMessageHeader(unsigned char*& packetData, size_t& dataBytes) { |
| @@ -1966,12 +1968,12 @@ Avatar* Application::findLookatTargetAvatar(const glm::vec3& mouseRayOrigin, con · 542 unmodified lines | ||
| 1966 | 1968 | if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) { |
| 1967 | 1969 | Avatar* avatar = (Avatar*)node->getLinkedData(); |
| 1968 | 1970 | float distance; |
| 1969 | − | |
| 1971 | + | |
| 1970 | 1972 | if (avatar->findRayIntersection(mouseRayOrigin, mouseRayDirection, distance)) { |
| 1971 | 1973 | // rescale to compensate for head embiggening |
| 1972 | 1974 | eyePosition = (avatar->getHead().calculateAverageEyePosition() - avatar->getHead().getScalePivot()) * |
| 1973 | 1975 | (avatar->getScale() / avatar->getHead().getScale()) + avatar->getHead().getScalePivot(); |
| 1974 | − | |
| 1976 | + | |
| 1975 | 1977 | _lookatIndicatorScale = avatar->getHead().getScale(); |
| 1976 | 1978 | _lookatOtherPosition = avatar->getHead().getPosition(); |
| 1977 | 1979 | nodeUUID = avatar->getOwningNode()->getUUID(); |
| @@ -1979,7 +1981,7 @@ Avatar* Application::findLookatTargetAvatar(const glm::vec3& mouseRayOrigin, con · 1 unmodified line | ||
| 1979 | 1981 | } |
| 1980 | 1982 | } |
| 1981 | 1983 | } |
| 1982 | − | |
| 1984 | + | |
| 1983 | 1985 | return NULL; |
| 1984 | 1986 | } |
| 1985 | 1987 | |
| @@ -2021,7 +2023,7 @@ void Application::renderHighlightVoxel(VoxelDetail voxel) { · 35 unmodified lines | ||
| 2021 | 2023 | void Application::updateAvatars(float deltaTime, glm::vec3 mouseRayOrigin, glm::vec3 mouseRayDirection) { |
| 2022 | 2024 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); |
| 2023 | 2025 | PerformanceWarning warn(showWarnings, "Application::updateAvatars()"); |
| 2024 | − | |
| 2026 | + | |
| 2025 | 2027 | foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) { |
| 2026 | 2028 | QMutexLocker(&node->getMutex()); |
| 2027 | 2029 | if (node->getLinkedData()) { |
| @@ -2038,11 +2040,11 @@ void Application::updateAvatars(float deltaTime, glm::vec3 mouseRayOrigin, glm:: · 10 unmodified lines | ||
| 2038 | 2040 | for (vector<Avatar*>::iterator fade = _avatarFades.begin(); fade != _avatarFades.end(); fade++) { |
| 2039 | 2041 | Avatar* avatar = *fade; |
| 2040 | 2042 | const float SHRINK_RATE = 0.9f; |
| 2041 | − | |
| 2043 | + | |
| 2042 | 2044 | avatar->setTargetScale(avatar->getScale() * SHRINK_RATE); |
| 2043 | − | |
| 2045 | + | |
| 2044 | 2046 | const float MIN_FADE_SCALE = 0.001; |
| 2045 | − | |
| 2047 | + | |
| 2046 | 2048 | if (avatar->getTargetScale() < MIN_FADE_SCALE) { |
| 2047 | 2049 | delete avatar; |
| 2048 | 2050 | _avatarFades.erase(fade--); |
| @@ -2260,6 +2262,7 @@ void Application::updateMouseVoxels(float deltaTime, glm::vec3& mouseRayOrigin, · 211 unmodified lines | ||
| 2260 | 2262 | } |
| 2261 | 2263 | } |
| 2262 | 2264 | |
| 2265 | + | |
| 2263 | 2266 | void Application::updateHandAndTouch(float deltaTime) { |
| 2264 | 2267 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); |
| 2265 | 2268 | PerformanceWarning warn(showWarnings, "Application::updateHandAndTouch()"); |
| @@ -2303,7 +2306,9 @@ void Application::updateThreads(float deltaTime) { · 37 unmodified lines | ||
| 2303 | 2306 | _voxelHideShowThread.threadRoutine(); |
| 2304 | 2307 | _voxelEditSender.threadRoutine(); |
| 2305 | 2308 | _particleEditSender.threadRoutine(); |
| 2306 | − _persistThread->threadRoutine(); | |
| 2309 | + if (_persistThread) { | |
| 2310 | + _persistThread->threadRoutine(); | |
| 2311 | + } | |
| 2307 | 2312 | } |
| 2308 | 2313 | } |
| 2309 | 2314 | |
| @@ -2613,32 +2618,32 @@ void Application::queryOctree(NODE_TYPE serverType, PACKET_TYPE packetType, Node · 303 unmodified lines | ||
| 2613 | 2618 | int totalServers = 0; |
| 2614 | 2619 | int inViewServers = 0; |
| 2615 | 2620 | int unknownJurisdictionServers = 0; |
| 2616 | − | |
| 2621 | + | |
| 2617 | 2622 | foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) { |
| 2618 | 2623 | // only send to the NodeTypes that are serverType |
| 2619 | 2624 | if (node->getActiveSocket() != NULL && node->getType() == serverType) { |
| 2620 | 2625 | totalServers++; |
| 2621 | − | |
| 2626 | + | |
| 2622 | 2627 | // get the server bounds for this server |
| 2623 | 2628 | QUuid nodeUUID = node->getUUID(); |
| 2624 | − | |
| 2629 | + | |
| 2625 | 2630 | // if we haven't heard from this voxel server, go ahead and send it a query, so we |
| 2626 | 2631 | // can get the jurisdiction... |
| 2627 | 2632 | if (jurisdictions.find(nodeUUID) == jurisdictions.end()) { |
| 2628 | 2633 | unknownJurisdictionServers++; |
| 2629 | 2634 | } else { |
| 2630 | 2635 | const JurisdictionMap& map = (jurisdictions)[nodeUUID]; |
| 2631 | − | |
| 2636 | + | |
| 2632 | 2637 | unsigned char* rootCode = map.getRootOctalCode(); |
| 2633 | − | |
| 2638 | + | |
| 2634 | 2639 | if (rootCode) { |
| 2635 | 2640 | VoxelPositionSize rootDetails; |
| 2636 | 2641 | voxelDetailsForCode(rootCode, rootDetails); |
| 2637 | 2642 | AABox serverBounds(glm::vec3(rootDetails.x, rootDetails.y, rootDetails.z), rootDetails.s); |
| 2638 | 2643 | serverBounds.scale(TREE_SCALE); |
| 2639 | − | |
| 2644 | + | |
| 2640 | 2645 | ViewFrustum::location serverFrustumLocation = _viewFrustum.boxInFrustum(serverBounds); |
| 2641 | − | |
| 2646 | + | |
| 2642 | 2647 | if (serverFrustumLocation != ViewFrustum::OUTSIDE) { |
| 2643 | 2648 | inViewServers++; |
| 2644 | 2649 | } |
| @@ -2671,20 +2676,20 @@ void Application::queryOctree(NODE_TYPE serverType, PACKET_TYPE packetType, Node · 26 unmodified lines | ||
| 2671 | 2676 | if (wantExtraDebugging && unknownJurisdictionServers > 0) { |
| 2672 | 2677 | qDebug("perServerPPS: %d perUnknownServer: %d", perServerPPS, perUnknownServer); |
| 2673 | 2678 | } |
| 2674 | − | |
| 2679 | + | |
| 2675 | 2680 | NodeList* nodeList = NodeList::getInstance(); |
| 2676 | − | |
| 2681 | + | |
| 2677 | 2682 | foreach (const SharedNodePointer& node, nodeList->getNodeHash()) { |
| 2678 | 2683 | // only send to the NodeTypes that are serverType |
| 2679 | 2684 | if (node->getActiveSocket() != NULL && node->getType() == serverType) { |
| 2680 | − | |
| 2681 | − | |
| 2685 | + | |
| 2686 | + | |
| 2682 | 2687 | // get the server bounds for this server |
| 2683 | 2688 | QUuid nodeUUID = node->getUUID(); |
| 2684 | − | |
| 2689 | + | |
| 2685 | 2690 | bool inView = false; |
| 2686 | 2691 | bool unknownView = false; |
| 2687 | − | |
| 2692 | + | |
| 2688 | 2693 | // if we haven't heard from this voxel server, go ahead and send it a query, so we |
| 2689 | 2694 | // can get the jurisdiction... |
| 2690 | 2695 | if (jurisdictions.find(nodeUUID) == jurisdictions.end()) { |
| @@ -2694,15 +2699,15 @@ void Application::queryOctree(NODE_TYPE serverType, PACKET_TYPE packetType, Node · 3 unmodified lines | ||
| 2694 | 2699 | } |
| 2695 | 2700 | } else { |
| 2696 | 2701 | const JurisdictionMap& map = (jurisdictions)[nodeUUID]; |
| 2697 | − | |
| 2702 | + | |
| 2698 | 2703 | unsigned char* rootCode = map.getRootOctalCode(); |
| 2699 | − | |
| 2704 | + | |
| 2700 | 2705 | if (rootCode) { |
| 2701 | 2706 | VoxelPositionSize rootDetails; |
| 2702 | 2707 | voxelDetailsForCode(rootCode, rootDetails); |
| 2703 | 2708 | AABox serverBounds(glm::vec3(rootDetails.x, rootDetails.y, rootDetails.z), rootDetails.s); |
| 2704 | 2709 | serverBounds.scale(TREE_SCALE); |
| 2705 | − | |
| 2710 | + | |
| 2706 | 2711 | ViewFrustum::location serverFrustumLocation = _viewFrustum.boxInFrustum(serverBounds); |
| 2707 | 2712 | if (serverFrustumLocation != ViewFrustum::OUTSIDE) { |
| 2708 | 2713 | inView = true; |
| @@ -2715,7 +2720,7 @@ void Application::queryOctree(NODE_TYPE serverType, PACKET_TYPE packetType, Node · 6 unmodified lines | ||
| 2715 | 2720 | } |
| 2716 | 2721 | } |
| 2717 | 2722 | } |
| 2718 | − | |
| 2723 | + | |
| 2719 | 2724 | if (inView) { |
| 2720 | 2725 | _voxelQuery.setMaxOctreePacketsPerSecond(perServerPPS); |
| 2721 | 2726 | } else if (unknownView) { |
| @@ -2723,7 +2728,7 @@ void Application::queryOctree(NODE_TYPE serverType, PACKET_TYPE packetType, Node · 1 unmodified line | ||
| 2723 | 2728 | qDebug() << "no known jurisdiction for node " << *node << ", give it budget of " |
| 2724 | 2729 | << perUnknownServer << " to send us jurisdiction."; |
| 2725 | 2730 | } |
| 2726 | − | |
| 2731 | + | |
| 2727 | 2732 | // set the query's position/orientation to be degenerate in a manner that will get the scene quickly |
| 2728 | 2733 | // If there's only one server, then don't do this, and just let the normal voxel query pass through |
| 2729 | 2734 | // 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 | ||
| 2747 | 2752 | } |
| 2748 | 2753 | // set up the packet for sending... |
| 2749 | 2754 | unsigned char* endOfVoxelQueryPacket = voxelQueryPacket; |
| 2750 | − | |
| 2755 | + | |
| 2751 | 2756 | // insert packet type/version and node UUID |
| 2752 | 2757 | endOfVoxelQueryPacket += populateTypeAndVersion(endOfVoxelQueryPacket, packetType); |
| 2753 | 2758 | QByteArray ownerUUID = nodeList->getOwnerUUID().toRfc4122(); |
| 2754 | 2759 | memcpy(endOfVoxelQueryPacket, ownerUUID.constData(), ownerUUID.size()); |
| 2755 | 2760 | endOfVoxelQueryPacket += ownerUUID.size(); |
| 2756 | − | |
| 2761 | + | |
| 2757 | 2762 | // encode the query data... |
| 2758 | 2763 | endOfVoxelQueryPacket += _voxelQuery.getBroadcastData(endOfVoxelQueryPacket); |
| 2759 | − | |
| 2764 | + | |
| 2760 | 2765 | int packetLength = endOfVoxelQueryPacket - voxelQueryPacket; |
| 2761 | − | |
| 2766 | + | |
| 2762 | 2767 | // make sure we still have an active socket |
| 2763 | 2768 | if (node->getActiveSocket()) { |
| 2764 | 2769 | nodeList->getNodeSocket().writeDatagram((char*) voxelQueryPacket, packetLength, |
| 2765 | 2770 | node->getActiveSocket()->getAddress(), node->getActiveSocket()->getPort()); |
| 2766 | 2771 | } |
| 2767 | − | |
| 2772 | + | |
| 2768 | 2773 | // Feed number of bytes to corresponding channel of the bandwidth meter |
| 2769 | 2774 | _bandwidthMeter.outputStream(BandwidthMeter::VOXELS).updateValue(packetLength); |
| 2770 | 2775 | } |
| @@ -3244,7 +3249,7 @@ void Application::displayOverlay() { · 473 unmodified lines | ||
| 3244 | 3249 | char nodes[100]; |
| 3245 | 3250 | |
| 3246 | 3251 | int totalAvatars = 0, totalServers = 0; |
| 3247 | − | |
| 3252 | + | |
| 3248 | 3253 | foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) { |
| 3249 | 3254 | node->getType() == NODE_TYPE_AGENT ? totalAvatars++ : totalServers++; |
| 3250 | 3255 | } |
| @@ -3358,7 +3363,7 @@ void Application::displayStats() { · 107 unmodified lines | ||
| 3358 | 3363 | // Now handle voxel servers, since there could be more than one, we average their ping times |
| 3359 | 3364 | unsigned long totalPingVoxel = 0; |
| 3360 | 3365 | int voxelServerCount = 0; |
| 3361 | − | |
| 3366 | + | |
| 3362 | 3367 | foreach (const SharedNodePointer& node, nodeList->getNodeHash()) { |
| 3363 | 3368 | if (node->getType() == NODE_TYPE_VOXEL_SERVER) { |
| 3364 | 3369 | totalPingVoxel += node->getPingMs(); |
| @@ -3368,7 +3373,7 @@ void Application::displayStats() { · 3 unmodified lines | ||
| 3368 | 3373 | } |
| 3369 | 3374 | } |
| 3370 | 3375 | } |
| 3371 | − | |
| 3376 | + | |
| 3372 | 3377 | if (voxelServerCount) { |
| 3373 | 3378 | pingVoxel = totalPingVoxel/voxelServerCount; |
| 3374 | 3379 | } |
| @@ -3704,10 +3709,10 @@ void Application::renderAvatars(bool forceRenderHead, bool selfAvatarOnly) { · 329 unmodified lines | ||
| 3704 | 3709 | if (!selfAvatarOnly) { |
| 3705 | 3710 | // Render avatars of other nodes |
| 3706 | 3711 | NodeList* nodeList = NodeList::getInstance(); |
| 3707 | − | |
| 3712 | + | |
| 3708 | 3713 | foreach (const SharedNodePointer& node, nodeList->getNodeHash()) { |
| 3709 | 3714 | QMutexLocker(&node->getMutex()); |
| 3710 | − | |
| 3715 | + | |
| 3711 | 3716 | if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) { |
| 3712 | 3717 | Avatar *avatar = (Avatar *)node->getLinkedData(); |
| 3713 | 3718 | if (!avatar->isInitialized()) { |
| @@ -4205,28 +4210,28 @@ void Application::processDatagrams() { · 491 unmodified lines | ||
| 4205 | 4210 | MAX_PACKET_SIZE, |
| 4206 | 4211 | senderSockAddr.getAddressPointer(), |
| 4207 | 4212 | senderSockAddr.getPortPointer()))) { |
| 4208 | − | |
| 4213 | + | |
| 4209 | 4214 | _packetCount++; |
| 4210 | 4215 | _bytesCount += bytesReceived; |
| 4211 | − | |
| 4216 | + | |
| 4212 | 4217 | if (packetVersionMatch(_incomingPacket)) { |
| 4213 | 4218 | // only process this packet if we have a match on the packet version |
| 4214 | 4219 | switch (_incomingPacket[0]) { |
| 4215 | 4220 | case PACKET_TYPE_TRANSMITTER_DATA_V2: |
| 4216 | 4221 | // V2 = IOS transmitter app |
| 4217 | 4222 | _myTransmitter.processIncomingData(_incomingPacket, bytesReceived); |
| 4218 | − | |
| 4223 | + | |
| 4219 | 4224 | break; |
| 4220 | 4225 | case PACKET_TYPE_MIXED_AUDIO: |
| 4221 | 4226 | QMetaObject::invokeMethod(&_audio, "addReceivedAudioToBuffer", Qt::QueuedConnection, |
| 4222 | 4227 | Q_ARG(QByteArray, QByteArray((char*) _incomingPacket, bytesReceived))); |
| 4223 | 4228 | break; |
| 4224 | − | |
| 4229 | + | |
| 4225 | 4230 | case PACKET_TYPE_PARTICLE_ADD_RESPONSE: |
| 4226 | 4231 | // look up our ParticleEditHanders.... |
| 4227 | 4232 | ParticleEditHandle::handleAddResponse(_incomingPacket, bytesReceived); |
| 4228 | 4233 | break; |
| 4229 | − | |
| 4234 | + | |
| 4230 | 4235 | case PACKET_TYPE_PARTICLE_DATA: |
| 4231 | 4236 | case PACKET_TYPE_VOXEL_DATA: |
| 4232 | 4237 | case PACKET_TYPE_VOXEL_ERASE: |
| @@ -4234,7 +4239,7 @@ void Application::processDatagrams() { · 1 unmodified line | ||
| 4234 | 4239 | case PACKET_TYPE_ENVIRONMENT_DATA: { |
| 4235 | 4240 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), |
| 4236 | 4241 | "Application::networkReceive()... _voxelProcessor.queueReceivedPacket()"); |
| 4237 | − | |
| 4242 | + | |
| 4238 | 4243 | bool wantExtraDebugging = getLogger()->extraDebugging(); |
| 4239 | 4244 | if (wantExtraDebugging && _incomingPacket[0] == PACKET_TYPE_VOXEL_DATA) { |
| 4240 | 4245 | int numBytesPacketHeader = numBytesForPacketHeader(_incomingPacket); |
| @@ -4246,10 +4251,10 @@ void Application::processDatagrams() { · 5 unmodified lines | ||
| 4246 | 4251 | dataAt += sizeof(VOXEL_PACKET_SENT_TIME); |
| 4247 | 4252 | VOXEL_PACKET_SENT_TIME arrivedAt = usecTimestampNow(); |
| 4248 | 4253 | int flightTime = arrivedAt - sentAt; |
| 4249 | − | |
| 4254 | + | |
| 4250 | 4255 | printf("got PACKET_TYPE_VOXEL_DATA, sequence:%d flightTime:%d\n", sequence, flightTime); |
| 4251 | 4256 | } |
| 4252 | − | |
| 4257 | + | |
| 4253 | 4258 | // add this packet to our list of voxel packets and process them on the voxel processing |
| 4254 | 4259 | _voxelProcessor.queueReceivedPacket(senderSockAddr, _incomingPacket, bytesReceived); |
| 4255 | 4260 | break; |
| @@ -4392,10 +4397,13 @@ void Application::updateLocalOctreeCache(bool firstTime) { · 136 unmodified lines | ||
| 4392 | 4397 | |
| 4393 | 4398 | QString localVoxelCacheFileName = getLocalVoxelCacheFileName(); |
| 4394 | 4399 | 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); | |
| 4397 | 4400 | |
| 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 | + } | |
| 4399 | 4407 | |
| 4400 | 4408 | if (_persistThread) { |
| 4401 | 4409 | _voxels.beginLoadingLocalVoxelCache(); // while local voxels are importing, don't do individual node VBO updates |