Showing the changes to interface/src/Application.cpp (1 of 35 files). Show all
Unified · Split
| @@ -173,9 +173,11 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 172 unmodified lines | |||
| 173 | connect(audioThread, SIGNAL(started()), &_audio, SLOT(start())); | 173 | connect(audioThread, SIGNAL(started()), &_audio, SLOT(start())); |
| 174 | 174 | ||
| 175 | audioThread->start(); | 175 | audioThread->start(); |
| 176 | 176 | ||
| 177 | nodeList->addHook(&_voxels); | 177 | connect(nodeList, SIGNAL(nodeKilled(SharedNodePointer)), SLOT(nodeKilled(SharedNodePointer))); |
| 178 | nodeList->addHook(this); | 178 | connect(nodeList, SIGNAL(nodeAdded(SharedNodePointer)), &_voxels, SLOT(nodeAdded(SharedNodePointer))); |
| 179 | connect(nodeList, SIGNAL(nodeKilled(SharedNodePointer)), &_voxels, SLOT(nodeKilled(SharedNodePointer))); | ||
| 180 | |||
| 179 | nodeList->addDomainListener(this); | 181 | nodeList->addDomainListener(this); |
| 180 | 182 | ||
| 181 | // network receive thread and voxel parsing thread are both controlled by the --nonblocking command line | 183 | // network receive thread and voxel parsing thread are both controlled by the --nonblocking command line |
| @@ -263,8 +265,6 @@ Application::~Application() { · 81 unmodified lines | |||
| 263 | _audio.thread()->wait(); | 265 | _audio.thread()->wait(); |
| 264 | 266 | ||
| 265 | storeSizeAndPosition(); | 267 | storeSizeAndPosition(); |
| 266 | NodeList::getInstance()->removeHook(&_voxels); | ||
| 267 | NodeList::getInstance()->removeHook(this); | ||
| 268 | NodeList::getInstance()->removeDomainListener(this); | 268 | NodeList::getInstance()->removeDomainListener(this); |
| 269 | 269 | ||
| 270 | _sharedVoxelSystem.changeTree(new VoxelTree); | 270 | _sharedVoxelSystem.changeTree(new VoxelTree); |
| @@ -1441,7 +1441,7 @@ void Application::terminate() { · 1170 unmodified lines | |||
| 1441 | static Avatar* processAvatarMessageHeader(unsigned char*& packetData, size_t& dataBytes) { | 1441 | static Avatar* processAvatarMessageHeader(unsigned char*& packetData, size_t& dataBytes) { |
| 1442 | // record the packet for stats-tracking | 1442 | // record the packet for stats-tracking |
| 1443 | Application::getInstance()->getBandwidthMeter()->inputStream(BandwidthMeter::AVATARS).updateValue(dataBytes); | 1443 | Application::getInstance()->getBandwidthMeter()->inputStream(BandwidthMeter::AVATARS).updateValue(dataBytes); |
| 1444 | Node* avatarMixerNode = NodeList::getInstance()->soloNodeOfType(NODE_TYPE_AVATAR_MIXER); | 1444 | SharedNodePointer avatarMixerNode = NodeList::getInstance()->soloNodeOfType(NODE_TYPE_AVATAR_MIXER); |
| 1445 | if (avatarMixerNode) { | 1445 | if (avatarMixerNode) { |
| 1446 | avatarMixerNode->recordBytesReceived(dataBytes); | 1446 | avatarMixerNode->recordBytesReceived(dataBytes); |
| 1447 | } | 1447 | } |
| @@ -1458,7 +1458,7 @@ static Avatar* processAvatarMessageHeader(unsigned char*& packetData, size_t& da · 10 unmodified lines | |||
| 1458 | dataBytes -= NUM_BYTES_RFC4122_UUID; | 1458 | dataBytes -= NUM_BYTES_RFC4122_UUID; |
| 1459 | 1459 | ||
| 1460 | // make sure the node exists | 1460 | // make sure the node exists |
| 1461 | Node* node = NodeList::getInstance()->nodeWithUUID(nodeUUID); | 1461 | SharedNodePointer node = NodeList::getInstance()->nodeWithUUID(nodeUUID); |
| 1462 | if (!node || !node->getLinkedData()) { | 1462 | if (!node || !node->getLinkedData()) { |
| 1463 | return NULL; | 1463 | return NULL; |
| 1464 | } | 1464 | } |
| @@ -1985,16 +1985,16 @@ void Application::updateLookatTargetAvatar(const glm::vec3& mouseRayOrigin, cons · 520 unmodified lines | |||
| 1985 | Avatar* Application::findLookatTargetAvatar(const glm::vec3& mouseRayOrigin, const glm::vec3& mouseRayDirection, | 1985 | Avatar* Application::findLookatTargetAvatar(const glm::vec3& mouseRayOrigin, const glm::vec3& mouseRayDirection, |
| 1986 | glm::vec3& eyePosition, QUuid& nodeUUID = DEFAULT_NODE_ID_REF) { | 1986 | glm::vec3& eyePosition, QUuid& nodeUUID = DEFAULT_NODE_ID_REF) { |
| 1987 | 1987 | ||
| 1988 | NodeList* nodeList = NodeList::getInstance(); | 1988 | foreach(SharedNodePointer node, NodeList::getInstance()->getNodeHash()) { |
| 1989 | for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) { | ||
| 1990 | if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) { | 1989 | if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) { |
| 1991 | Avatar* avatar = (Avatar*)node->getLinkedData(); | 1990 | Avatar* avatar = (Avatar*)node->getLinkedData(); |
| 1992 | float distance; | 1991 | float distance; |
| 1992 | |||
| 1993 | if (avatar->findRayIntersection(mouseRayOrigin, mouseRayDirection, distance)) { | 1993 | if (avatar->findRayIntersection(mouseRayOrigin, mouseRayDirection, distance)) { |
| 1994 | // rescale to compensate for head embiggening | 1994 | // rescale to compensate for head embiggening |
| 1995 | eyePosition = (avatar->getHead().calculateAverageEyePosition() - avatar->getHead().getScalePivot()) * | 1995 | eyePosition = (avatar->getHead().calculateAverageEyePosition() - avatar->getHead().getScalePivot()) * |
| 1996 | (avatar->getScale() / avatar->getHead().getScale()) + avatar->getHead().getScalePivot(); | 1996 | (avatar->getScale() / avatar->getHead().getScale()) + avatar->getHead().getScalePivot(); |
| 1997 | 1997 | ||
| 1998 | _lookatIndicatorScale = avatar->getHead().getScale(); | 1998 | _lookatIndicatorScale = avatar->getHead().getScale(); |
| 1999 | _lookatOtherPosition = avatar->getHead().getPosition(); | 1999 | _lookatOtherPosition = avatar->getHead().getPosition(); |
| 2000 | nodeUUID = avatar->getOwningNode()->getUUID(); | 2000 | nodeUUID = avatar->getOwningNode()->getUUID(); |
| @@ -2002,6 +2002,7 @@ Avatar* Application::findLookatTargetAvatar(const glm::vec3& mouseRayOrigin, con · 1 unmodified line | |||
| 2002 | } | 2002 | } |
| 2003 | } | 2003 | } |
| 2004 | } | 2004 | } |
| 2005 | |||
| 2005 | return NULL; | 2006 | return NULL; |
| 2006 | } | 2007 | } |
| 2007 | 2008 | ||
| @@ -2026,71 +2027,6 @@ void Application::renderLookatIndicator(glm::vec3 pointOfInterest) { · 18 unmodified lines | |||
| 2026 | renderCircle(haloOrigin, INDICATOR_RADIUS, IDENTITY_UP, NUM_SEGMENTS); | 2027 | renderCircle(haloOrigin, INDICATOR_RADIUS, IDENTITY_UP, NUM_SEGMENTS); |
| 2027 | } | 2028 | } |
| 2028 | 2029 | ||
| 2029 | void maybeBeginFollowIndicator(bool& began) { | ||
| 2030 | if (!began) { | ||
| 2031 | Application::getInstance()->getGlowEffect()->begin(); | ||
| 2032 | glLineWidth(5); | ||
| 2033 | glBegin(GL_LINES); | ||
| 2034 | began = true; | ||
| 2035 | } | ||
| 2036 | } | ||
| 2037 | |||
| 2038 | void Application::renderFollowIndicator() { | ||
| 2039 | NodeList* nodeList = NodeList::getInstance(); | ||
| 2040 | |||
| 2041 | // initialize lazily so that we don't enable the glow effect unnecessarily | ||
| 2042 | bool began = false; | ||
| 2043 | |||
| 2044 | for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); ++node) { | ||
| 2045 | if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) { | ||
| 2046 | Avatar* avatar = (Avatar *) node->getLinkedData(); | ||
| 2047 | Avatar* leader = NULL; | ||
| 2048 | |||
| 2049 | if (!avatar->getLeaderUUID().isNull()) { | ||
| 2050 | if (avatar->getLeaderUUID() == NodeList::getInstance()->getOwnerUUID()) { | ||
| 2051 | leader = &_myAvatar; | ||
| 2052 | } else { | ||
| 2053 | for (NodeList::iterator it = nodeList->begin(); it != nodeList->end(); ++it) { | ||
| 2054 | if(it->getUUID() == avatar->getLeaderUUID() | ||
| 2055 | && it->getType() == NODE_TYPE_AGENT) { | ||
| 2056 | leader = (Avatar*) it->getLinkedData(); | ||
| 2057 | } | ||
| 2058 | } | ||
| 2059 | } | ||
| 2060 | |||
| 2061 | if (leader != NULL) { | ||
| 2062 | maybeBeginFollowIndicator(began); | ||
| 2063 | glColor3f(1.f, 0.f, 0.f); | ||
| 2064 | glVertex3f((avatar->getHead().getPosition().x + avatar->getPosition().x) / 2.f, | ||
| 2065 | (avatar->getHead().getPosition().y + avatar->getPosition().y) / 2.f, | ||
| 2066 | (avatar->getHead().getPosition().z + avatar->getPosition().z) / 2.f); | ||
| 2067 | glColor3f(0.f, 1.f, 0.f); | ||
| 2068 | glVertex3f((leader->getHead().getPosition().x + leader->getPosition().x) / 2.f, | ||
| 2069 | (leader->getHead().getPosition().y + leader->getPosition().y) / 2.f, | ||
| 2070 | (leader->getHead().getPosition().z + leader->getPosition().z) / 2.f); | ||
| 2071 | } | ||
| 2072 | } | ||
| 2073 | } | ||
| 2074 | } | ||
| 2075 | |||
| 2076 | if (_myAvatar.getLeadingAvatar() != NULL) { | ||
| 2077 | maybeBeginFollowIndicator(began); | ||
| 2078 | glColor3f(1.f, 0.f, 0.f); | ||
| 2079 | glVertex3f((_myAvatar.getHead().getPosition().x + _myAvatar.getPosition().x) / 2.f, | ||
| 2080 | (_myAvatar.getHead().getPosition().y + _myAvatar.getPosition().y) / 2.f, | ||
| 2081 | (_myAvatar.getHead().getPosition().z + _myAvatar.getPosition().z) / 2.f); | ||
| 2082 | glColor3f(0.f, 1.f, 0.f); | ||
| 2083 | glVertex3f((_myAvatar.getLeadingAvatar()->getHead().getPosition().x + _myAvatar.getLeadingAvatar()->getPosition().x) / 2.f, | ||
| 2084 | (_myAvatar.getLeadingAvatar()->getHead().getPosition().y + _myAvatar.getLeadingAvatar()->getPosition().y) / 2.f, | ||
| 2085 | (_myAvatar.getLeadingAvatar()->getHead().getPosition().z + _myAvatar.getLeadingAvatar()->getPosition().z) / 2.f); | ||
| 2086 | } | ||
| 2087 | |||
| 2088 | if (began) { | ||
| 2089 | glEnd(); | ||
| 2090 | _glowEffect.end(); | ||
| 2091 | } | ||
| 2092 | } | ||
| 2093 | |||
| 2094 | void Application::renderHighlightVoxel(VoxelDetail voxel) { | 2030 | void Application::renderHighlightVoxel(VoxelDetail voxel) { |
| 2095 | glDisable(GL_LIGHTING); | 2031 | glDisable(GL_LIGHTING); |
| 2096 | glPushMatrix(); | 2032 | glPushMatrix(); |
| @@ -2108,9 +2044,8 @@ void Application::renderHighlightVoxel(VoxelDetail voxel) { · 11 unmodified lines | |||
| 2108 | void Application::updateAvatars(float deltaTime, glm::vec3 mouseRayOrigin, glm::vec3 mouseRayDirection) { | 2044 | void Application::updateAvatars(float deltaTime, glm::vec3 mouseRayOrigin, glm::vec3 mouseRayDirection) { |
| 2109 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); | 2045 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); |
| 2110 | PerformanceWarning warn(showWarnings, "Application::updateAvatars()"); | 2046 | PerformanceWarning warn(showWarnings, "Application::updateAvatars()"); |
| 2111 | NodeList* nodeList = NodeList::getInstance(); | 2047 | |
| 2112 | 2048 | foreach(SharedNodePointer node, NodeList::getInstance()->getNodeHash()) { | |
| 2113 | for(NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) { | ||
| 2114 | node->lock(); | 2049 | node->lock(); |
| 2115 | if (node->getLinkedData()) { | 2050 | if (node->getLinkedData()) { |
| 2116 | Avatar *avatar = (Avatar *)node->getLinkedData(); | 2051 | Avatar *avatar = (Avatar *)node->getLinkedData(); |
| @@ -2739,39 +2674,36 @@ void Application::queryOctree(NODE_TYPE serverType, PACKET_TYPE packetType, Node · 622 unmodified lines | |||
| 2739 | 2674 | ||
| 2740 | unsigned char voxelQueryPacket[MAX_PACKET_SIZE]; | 2675 | unsigned char voxelQueryPacket[MAX_PACKET_SIZE]; |
| 2741 | 2676 | ||
| 2742 | NodeList* nodeList = NodeList::getInstance(); | ||
| 2743 | |||
| 2744 | // Iterate all of the nodes, and get a count of how many voxel servers we have... | 2677 | // Iterate all of the nodes, and get a count of how many voxel servers we have... |
| 2745 | int totalServers = 0; | 2678 | int totalServers = 0; |
| 2746 | int inViewServers = 0; | 2679 | int inViewServers = 0; |
| 2747 | int unknownJurisdictionServers = 0; | 2680 | int unknownJurisdictionServers = 0; |
| 2748 | 2681 | ||
| 2749 | for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) { | 2682 | foreach(SharedNodePointer node, NodeList::getInstance()->getNodeHash()) { |
| 2750 | |||
| 2751 | // only send to the NodeTypes that are serverType | 2683 | // only send to the NodeTypes that are serverType |
| 2752 | if (node->getActiveSocket() != NULL && node->getType() == serverType) { | 2684 | if (node->getActiveSocket() != NULL && node->getType() == serverType) { |
| 2753 | totalServers++; | 2685 | totalServers++; |
| 2754 | 2686 | ||
| 2755 | // get the server bounds for this server | 2687 | // get the server bounds for this server |
| 2756 | QUuid nodeUUID = node->getUUID(); | 2688 | QUuid nodeUUID = node->getUUID(); |
| 2757 | 2689 | ||
| 2758 | // if we haven't heard from this voxel server, go ahead and send it a query, so we | 2690 | // if we haven't heard from this voxel server, go ahead and send it a query, so we |
| 2759 | // can get the jurisdiction... | 2691 | // can get the jurisdiction... |
| 2760 | if (jurisdictions.find(nodeUUID) == jurisdictions.end()) { | 2692 | if (jurisdictions.find(nodeUUID) == jurisdictions.end()) { |
| 2761 | unknownJurisdictionServers++; | 2693 | unknownJurisdictionServers++; |
| 2762 | } else { | 2694 | } else { |
| 2763 | const JurisdictionMap& map = (jurisdictions)[nodeUUID]; | 2695 | const JurisdictionMap& map = (jurisdictions)[nodeUUID]; |
| 2764 | 2696 | ||
| 2765 | unsigned char* rootCode = map.getRootOctalCode(); | 2697 | unsigned char* rootCode = map.getRootOctalCode(); |
| 2766 | 2698 | ||
| 2767 | if (rootCode) { | 2699 | if (rootCode) { |
| 2768 | VoxelPositionSize rootDetails; | 2700 | VoxelPositionSize rootDetails; |
| 2769 | voxelDetailsForCode(rootCode, rootDetails); | 2701 | voxelDetailsForCode(rootCode, rootDetails); |
| 2770 | AABox serverBounds(glm::vec3(rootDetails.x, rootDetails.y, rootDetails.z), rootDetails.s); | 2702 | AABox serverBounds(glm::vec3(rootDetails.x, rootDetails.y, rootDetails.z), rootDetails.s); |
| 2771 | serverBounds.scale(TREE_SCALE); | 2703 | serverBounds.scale(TREE_SCALE); |
| 2772 | 2704 | ||
| 2773 | ViewFrustum::location serverFrustumLocation = _viewFrustum.boxInFrustum(serverBounds); | 2705 | ViewFrustum::location serverFrustumLocation = _viewFrustum.boxInFrustum(serverBounds); |
| 2774 | 2706 | ||
| 2775 | if (serverFrustumLocation != ViewFrustum::OUTSIDE) { | 2707 | if (serverFrustumLocation != ViewFrustum::OUTSIDE) { |
| 2776 | inViewServers++; | 2708 | inViewServers++; |
| 2777 | } | 2709 | } |
| @@ -2804,18 +2736,20 @@ void Application::queryOctree(NODE_TYPE serverType, PACKET_TYPE packetType, Node · 26 unmodified lines | |||
| 2804 | if (wantExtraDebugging && unknownJurisdictionServers > 0) { | 2736 | if (wantExtraDebugging && unknownJurisdictionServers > 0) { |
| 2805 | qDebug("perServerPPS: %d perUnknownServer: %d\n", perServerPPS, perUnknownServer); | 2737 | qDebug("perServerPPS: %d perUnknownServer: %d\n", perServerPPS, perUnknownServer); |
| 2806 | } | 2738 | } |
| 2807 | 2739 | ||
| 2808 | for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) { | 2740 | NodeList* nodeList = NodeList::getInstance(); |
| 2741 | |||
| 2742 | foreach(SharedNodePointer node, nodeList->getNodeHash()) { | ||
| 2809 | // only send to the NodeTypes that are serverType | 2743 | // only send to the NodeTypes that are serverType |
| 2810 | if (node->getActiveSocket() != NULL && node->getType() == serverType) { | 2744 | if (node->getActiveSocket() != NULL && node->getType() == serverType) { |
| 2811 | 2745 | ||
| 2812 | 2746 | ||
| 2813 | // get the server bounds for this server | 2747 | // get the server bounds for this server |
| 2814 | QUuid nodeUUID = node->getUUID(); | 2748 | QUuid nodeUUID = node->getUUID(); |
| 2815 | 2749 | ||
| 2816 | bool inView = false; | 2750 | bool inView = false; |
| 2817 | bool unknownView = false; | 2751 | bool unknownView = false; |
| 2818 | 2752 | ||
| 2819 | // if we haven't heard from this voxel server, go ahead and send it a query, so we | 2753 | // if we haven't heard from this voxel server, go ahead and send it a query, so we |
| 2820 | // can get the jurisdiction... | 2754 | // can get the jurisdiction... |
| 2821 | if (jurisdictions.find(nodeUUID) == jurisdictions.end()) { | 2755 | if (jurisdictions.find(nodeUUID) == jurisdictions.end()) { |
| @@ -2825,15 +2759,15 @@ void Application::queryOctree(NODE_TYPE serverType, PACKET_TYPE packetType, Node · 3 unmodified lines | |||
| 2825 | } | 2759 | } |
| 2826 | } else { | 2760 | } else { |
| 2827 | const JurisdictionMap& map = (jurisdictions)[nodeUUID]; | 2761 | const JurisdictionMap& map = (jurisdictions)[nodeUUID]; |
| 2828 | 2762 | ||
| 2829 | unsigned char* rootCode = map.getRootOctalCode(); | 2763 | unsigned char* rootCode = map.getRootOctalCode(); |
| 2830 | 2764 | ||
| 2831 | if (rootCode) { | 2765 | if (rootCode) { |
| 2832 | VoxelPositionSize rootDetails; | 2766 | VoxelPositionSize rootDetails; |
| 2833 | voxelDetailsForCode(rootCode, rootDetails); | 2767 | voxelDetailsForCode(rootCode, rootDetails); |
| 2834 | AABox serverBounds(glm::vec3(rootDetails.x, rootDetails.y, rootDetails.z), rootDetails.s); | 2768 | AABox serverBounds(glm::vec3(rootDetails.x, rootDetails.y, rootDetails.z), rootDetails.s); |
| 2835 | serverBounds.scale(TREE_SCALE); | 2769 | serverBounds.scale(TREE_SCALE); |
| 2836 | 2770 | ||
| 2837 | ViewFrustum::location serverFrustumLocation = _viewFrustum.boxInFrustum(serverBounds); | 2771 | ViewFrustum::location serverFrustumLocation = _viewFrustum.boxInFrustum(serverBounds); |
| 2838 | if (serverFrustumLocation != ViewFrustum::OUTSIDE) { | 2772 | if (serverFrustumLocation != ViewFrustum::OUTSIDE) { |
| 2839 | inView = true; | 2773 | inView = true; |
| @@ -2846,15 +2780,15 @@ void Application::queryOctree(NODE_TYPE serverType, PACKET_TYPE packetType, Node · 6 unmodified lines | |||
| 2846 | } | 2780 | } |
| 2847 | } | 2781 | } |
| 2848 | } | 2782 | } |
| 2849 | 2783 | ||
| 2850 | if (inView) { | 2784 | if (inView) { |
| 2851 | _voxelQuery.setMaxOctreePacketsPerSecond(perServerPPS); | 2785 | _voxelQuery.setMaxOctreePacketsPerSecond(perServerPPS); |
| 2852 | } else if (unknownView) { | 2786 | } else if (unknownView) { |
| 2853 | if (wantExtraDebugging) { | 2787 | if (wantExtraDebugging) { |
| 2854 | qDebug() << "no known jurisdiction for node " << *node << ", give it budget of " | 2788 | qDebug() << "no known jurisdiction for node " << *node << ", give it budget of " |
| 2855 | << perUnknownServer << " to send us jurisdiction.\n"; | 2789 | << perUnknownServer << " to send us jurisdiction.\n"; |
| 2856 | } | 2790 | } |
| 2857 | 2791 | ||
| 2858 | // set the query's position/orientation to be degenerate in a manner that will get the scene quickly | 2792 | // set the query's position/orientation to be degenerate in a manner that will get the scene quickly |
| 2859 | // If there's only one server, then don't do this, and just let the normal voxel query pass through | 2793 | // If there's only one server, then don't do this, and just let the normal voxel query pass through |
| 2860 | // as expected... this way, we will actually get a valid scene if there is one to be seen | 2794 | // as expected... this way, we will actually get a valid scene if there is one to be seen |
| @@ -2878,24 +2812,24 @@ void Application::queryOctree(NODE_TYPE serverType, PACKET_TYPE packetType, Node · 17 unmodified lines | |||
| 2878 | } | 2812 | } |
| 2879 | // set up the packet for sending... | 2813 | // set up the packet for sending... |
| 2880 | unsigned char* endOfVoxelQueryPacket = voxelQueryPacket; | 2814 | unsigned char* endOfVoxelQueryPacket = voxelQueryPacket; |
| 2881 | 2815 | ||
| 2882 | // insert packet type/version and node UUID | 2816 | // insert packet type/version and node UUID |
| 2883 | endOfVoxelQueryPacket += populateTypeAndVersion(endOfVoxelQueryPacket, packetType); | 2817 | endOfVoxelQueryPacket += populateTypeAndVersion(endOfVoxelQueryPacket, packetType); |
| 2884 | QByteArray ownerUUID = nodeList->getOwnerUUID().toRfc4122(); | 2818 | QByteArray ownerUUID = nodeList->getOwnerUUID().toRfc4122(); |
| 2885 | memcpy(endOfVoxelQueryPacket, ownerUUID.constData(), ownerUUID.size()); | 2819 | memcpy(endOfVoxelQueryPacket, ownerUUID.constData(), ownerUUID.size()); |
| 2886 | endOfVoxelQueryPacket += ownerUUID.size(); | 2820 | endOfVoxelQueryPacket += ownerUUID.size(); |
| 2887 | 2821 | ||
| 2888 | // encode the query data... | 2822 | // encode the query data... |
| 2889 | endOfVoxelQueryPacket += _voxelQuery.getBroadcastData(endOfVoxelQueryPacket); | 2823 | endOfVoxelQueryPacket += _voxelQuery.getBroadcastData(endOfVoxelQueryPacket); |
| 2890 | 2824 | ||
| 2891 | int packetLength = endOfVoxelQueryPacket - voxelQueryPacket; | 2825 | int packetLength = endOfVoxelQueryPacket - voxelQueryPacket; |
| 2892 | 2826 | ||
| 2893 | // make sure we still have an active socket | 2827 | // make sure we still have an active socket |
| 2894 | if (node->getActiveSocket()) { | 2828 | if (node->getActiveSocket()) { |
| 2895 | nodeList->getNodeSocket().writeDatagram((char*) voxelQueryPacket, packetLength, | 2829 | nodeList->getNodeSocket().writeDatagram((char*) voxelQueryPacket, packetLength, |
| 2896 | node->getActiveSocket()->getAddress(), node->getActiveSocket()->getPort()); | 2830 | node->getActiveSocket()->getAddress(), node->getActiveSocket()->getPort()); |
| 2897 | } | 2831 | } |
| 2898 | 2832 | ||
| 2899 | // Feed number of bytes to corresponding channel of the bandwidth meter | 2833 | // Feed number of bytes to corresponding channel of the bandwidth meter |
| 2900 | _bandwidthMeter.outputStream(BandwidthMeter::VOXELS).updateValue(packetLength); | 2834 | _bandwidthMeter.outputStream(BandwidthMeter::VOXELS).updateValue(packetLength); |
| 2901 | } | 2835 | } |
| @@ -3252,12 +3186,6 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 350 unmodified lines | |||
| 3252 | } | 3186 | } |
| 3253 | } | 3187 | } |
| 3254 | 3188 | ||
| 3255 | { | ||
| 3256 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), | ||
| 3257 | "Application::displaySide() ... renderFollowIndicator..."); | ||
| 3258 | renderFollowIndicator(); | ||
| 3259 | } | ||
| 3260 | |||
| 3261 | // render transmitter pick ray, if non-empty | 3189 | // render transmitter pick ray, if non-empty |
| 3262 | if (_transmitterPickStart != _transmitterPickEnd) { | 3190 | if (_transmitterPickStart != _transmitterPickEnd) { |
| 3263 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), | 3191 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), |
| @@ -3384,12 +3312,12 @@ void Application::displayOverlay() { · 120 unmodified lines | |||
| 3384 | glPointSize(1.0f); | 3312 | glPointSize(1.0f); |
| 3385 | char nodes[100]; | 3313 | char nodes[100]; |
| 3386 | 3314 | ||
| 3387 | NodeList* nodeList = NodeList::getInstance(); | ||
| 3388 | int totalAvatars = 0, totalServers = 0; | 3315 | int totalAvatars = 0, totalServers = 0; |
| 3389 | 3316 | ||
| 3390 | for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) { | 3317 | foreach(SharedNodePointer node, NodeList::getInstance()->getNodeHash()) { |
| 3391 | node->getType() == NODE_TYPE_AGENT ? totalAvatars++ : totalServers++; | 3318 | node->getType() == NODE_TYPE_AGENT ? totalAvatars++ : totalServers++; |
| 3392 | } | 3319 | } |
| 3320 | |||
| 3393 | sprintf(nodes, "Servers: %d, Avatars: %d\n", totalServers, totalAvatars); | 3321 | sprintf(nodes, "Servers: %d, Avatars: %d\n", totalServers, totalAvatars); |
| 3394 | drawtext(_glWidget->width() - 150, 20, 0.10, 0, 1.0, 0, nodes, 1, 0, 0); | 3322 | drawtext(_glWidget->width() - 150, 20, 0.10, 0, 1.0, 0, nodes, 1, 0, 0); |
| 3395 | } | 3323 | } |
| @@ -3489,8 +3417,8 @@ void Application::displayStats() { · 93 unmodified lines | |||
| 3489 | int pingAudio = 0, pingAvatar = 0, pingVoxel = 0, pingVoxelMax = 0; | 3417 | int pingAudio = 0, pingAvatar = 0, pingVoxel = 0, pingVoxelMax = 0; |
| 3490 | 3418 | ||
| 3491 | NodeList* nodeList = NodeList::getInstance(); | 3419 | NodeList* nodeList = NodeList::getInstance(); |
| 3492 | Node* audioMixerNode = nodeList->soloNodeOfType(NODE_TYPE_AUDIO_MIXER); | 3420 | SharedNodePointer audioMixerNode = nodeList->soloNodeOfType(NODE_TYPE_AUDIO_MIXER); |
| 3493 | Node* avatarMixerNode = nodeList->soloNodeOfType(NODE_TYPE_AVATAR_MIXER); | 3421 | SharedNodePointer avatarMixerNode = nodeList->soloNodeOfType(NODE_TYPE_AVATAR_MIXER); |
| 3494 | 3422 | ||
| 3495 | pingAudio = audioMixerNode ? audioMixerNode->getPingMs() : 0; | 3423 | pingAudio = audioMixerNode ? audioMixerNode->getPingMs() : 0; |
| 3496 | pingAvatar = avatarMixerNode ? avatarMixerNode->getPingMs() : 0; | 3424 | pingAvatar = avatarMixerNode ? avatarMixerNode->getPingMs() : 0; |
| @@ -3499,7 +3427,8 @@ void Application::displayStats() { · 2 unmodified lines | |||
| 3499 | // Now handle voxel servers, since there could be more than one, we average their ping times | 3427 | // Now handle voxel servers, since there could be more than one, we average their ping times |
| 3500 | unsigned long totalPingVoxel = 0; | 3428 | unsigned long totalPingVoxel = 0; |
| 3501 | int voxelServerCount = 0; | 3429 | int voxelServerCount = 0; |
| 3502 | for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) { | 3430 | |
| 3431 | foreach(SharedNodePointer node, nodeList->getNodeHash()) { | ||
| 3503 | if (node->getType() == NODE_TYPE_VOXEL_SERVER) { | 3432 | if (node->getType() == NODE_TYPE_VOXEL_SERVER) { |
| 3504 | totalPingVoxel += node->getPingMs(); | 3433 | totalPingVoxel += node->getPingMs(); |
| 3505 | voxelServerCount++; | 3434 | voxelServerCount++; |
| @@ -3508,6 +3437,7 @@ void Application::displayStats() { · 2 unmodified lines | |||
| 3508 | } | 3437 | } |
| 3509 | } | 3438 | } |
| 3510 | } | 3439 | } |
| 3440 | |||
| 3511 | if (voxelServerCount) { | 3441 | if (voxelServerCount) { |
| 3512 | pingVoxel = totalPingVoxel/voxelServerCount; | 3442 | pingVoxel = totalPingVoxel/voxelServerCount; |
| 3513 | } | 3443 | } |
| @@ -3524,7 +3454,7 @@ void Application::displayStats() { · 10 unmodified lines | |||
| 3524 | sprintf(avatarStats, "Avatar: pos %.3f, %.3f, %.3f, vel %.1f, yaw = %.2f", avatarPos.x, avatarPos.y, avatarPos.z, glm::length(_myAvatar.getVelocity()), _myAvatar.getBodyYaw()); | 3454 | sprintf(avatarStats, "Avatar: pos %.3f, %.3f, %.3f, vel %.1f, yaw = %.2f", avatarPos.x, avatarPos.y, avatarPos.z, glm::length(_myAvatar.getVelocity()), _myAvatar.getBodyYaw()); |
| 3525 | drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, avatarStats); | 3455 | drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, avatarStats); |
| 3526 | 3456 | ||
| 3527 | Node* avatarMixer = NodeList::getInstance()->soloNodeOfType(NODE_TYPE_AVATAR_MIXER); | 3457 | SharedNodePointer avatarMixer = NodeList::getInstance()->soloNodeOfType(NODE_TYPE_AVATAR_MIXER); |
| 3528 | char avatarMixerStats[200]; | 3458 | char avatarMixerStats[200]; |
| 3529 | if (avatarMixer) { | 3459 | if (avatarMixer) { |
| 3530 | sprintf(avatarMixerStats, "Avatar Mixer: %.f kbps, %.f pps", | 3460 | sprintf(avatarMixerStats, "Avatar Mixer: %.f kbps, %.f pps", |
| @@ -3848,10 +3778,10 @@ void Application::renderAvatars(bool forceRenderHead, bool selfAvatarOnly) { · 317 unmodified lines | |||
| 3848 | if (!selfAvatarOnly) { | 3778 | if (!selfAvatarOnly) { |
| 3849 | // Render avatars of other nodes | 3779 | // Render avatars of other nodes |
| 3850 | NodeList* nodeList = NodeList::getInstance(); | 3780 | NodeList* nodeList = NodeList::getInstance(); |
| 3851 | 3781 | ||
| 3852 | for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) { | 3782 | foreach(SharedNodePointer node, nodeList->getNodeHash()) { |
| 3853 | node->lock(); | 3783 | node->lock(); |
| 3854 | 3784 | ||
| 3855 | if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) { | 3785 | if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) { |
| 3856 | Avatar *avatar = (Avatar *)node->getLinkedData(); | 3786 | Avatar *avatar = (Avatar *)node->getLinkedData(); |
| 3857 | if (!avatar->isInitialized()) { | 3787 | if (!avatar->isInitialized()) { |
| @@ -3860,7 +3790,7 @@ void Application::renderAvatars(bool forceRenderHead, bool selfAvatarOnly) { · 2 unmodified lines | |||
| 3860 | avatar->render(false); | 3790 | avatar->render(false); |
| 3861 | avatar->setDisplayingLookatVectors(Menu::getInstance()->isOptionChecked(MenuOption::LookAtVectors)); | 3791 | avatar->setDisplayingLookatVectors(Menu::getInstance()->isOptionChecked(MenuOption::LookAtVectors)); |
| 3862 | } | 3792 | } |
| 3863 | 3793 | ||
| 3864 | node->unlock(); | 3794 | node->unlock(); |
| 3865 | } | 3795 | } |
| 3866 | 3796 | ||
| @@ -4106,18 +4036,6 @@ void Application::eyedropperVoxelUnderCursor() { · 239 unmodified lines | |||
| 4106 | } | 4036 | } |
| 4107 | } | 4037 | } |
| 4108 | 4038 | ||
| 4109 | void Application::toggleFollowMode() { | ||
| 4110 | glm::vec3 mouseRayOrigin, mouseRayDirection; | ||
| 4111 | _viewFrustum.computePickRay(_pieMenu.getX() / (float)_glWidget->width(), | ||
| 4112 | _pieMenu.getY() / (float)_glWidget->height(), | ||
| 4113 | mouseRayOrigin, mouseRayDirection); | ||
| 4114 | glm::vec3 eyePositionIgnored; | ||
| 4115 | QUuid nodeUUIDIgnored; | ||
| 4116 | Avatar* leadingAvatar = findLookatTargetAvatar(mouseRayOrigin, mouseRayDirection, eyePositionIgnored, nodeUUIDIgnored); | ||
| 4117 | |||
| 4118 | _myAvatar.follow(leadingAvatar); | ||
| 4119 | } | ||
| 4120 | |||
| 4121 | void Application::resetSensors() { | 4039 | void Application::resetSensors() { |
| 4122 | _headMouseX = _mouseX = _glWidget->width() / 2; | 4040 | _headMouseX = _mouseX = _glWidget->width() / 2; |
| 4123 | _headMouseY = _mouseY = _glWidget->height() / 2; | 4041 | _headMouseY = _mouseY = _glWidget->height() / 2; |
| @@ -4200,11 +4118,7 @@ void Application::domainChanged(QString domain) { · 76 unmodified lines | |||
| 4200 | updateLocalOctreeCache(); | 4118 | updateLocalOctreeCache(); |
| 4201 | } | 4119 | } |
| 4202 | 4120 | ||
| 4203 | void Application::nodeAdded(Node* node) { | 4121 | void Application::nodeKilled(SharedNodePointer node) { |
| 4204 | |||
| 4205 | } | ||
| 4206 | |||
| 4207 | void Application::nodeKilled(Node* node) { | ||
| 4208 | if (node->getType() == NODE_TYPE_VOXEL_SERVER) { | 4122 | if (node->getType() == NODE_TYPE_VOXEL_SERVER) { |
| 4209 | QUuid nodeUUID = node->getUUID(); | 4123 | QUuid nodeUUID = node->getUUID(); |
| 4210 | // see if this is the first we've heard of this node... | 4124 | // see if this is the first we've heard of this node... |
| @@ -4284,7 +4198,7 @@ void Application::trackIncomingVoxelPacket(unsigned char* messageData, ssize_t m · 73 unmodified lines | |||
| 4284 | const HifiSockAddr& senderSockAddr, bool wasStatsPacket) { | 4198 | const HifiSockAddr& senderSockAddr, bool wasStatsPacket) { |
| 4285 | 4199 | ||
| 4286 | // Attempt to identify the sender from it's address. | 4200 | // Attempt to identify the sender from it's address. |
| 4287 | Node* serverNode = NodeList::getInstance()->nodeWithAddress(senderSockAddr); | 4201 | SharedNodePointer serverNode = NodeList::getInstance()->nodeWithAddress(senderSockAddr); |
| 4288 | if (serverNode) { | 4202 | if (serverNode) { |
| 4289 | QUuid nodeUUID = serverNode->getUUID(); | 4203 | QUuid nodeUUID = serverNode->getUUID(); |
| 4290 | 4204 | ||
| @@ -4301,7 +4215,7 @@ void Application::trackIncomingVoxelPacket(unsigned char* messageData, ssize_t m · 10 unmodified lines | |||
| 4301 | int Application::parseOctreeStats(unsigned char* messageData, ssize_t messageLength, const HifiSockAddr& senderSockAddr) { | 4215 | int Application::parseOctreeStats(unsigned char* messageData, ssize_t messageLength, const HifiSockAddr& senderSockAddr) { |
| 4302 | 4216 | ||
| 4303 | // But, also identify the sender, and keep track of the contained jurisdiction root for this server | 4217 | // But, also identify the sender, and keep track of the contained jurisdiction root for this server |
| 4304 | Node* server = NodeList::getInstance()->nodeWithAddress(senderSockAddr); | 4218 | SharedNodePointer server = NodeList::getInstance()->nodeWithAddress(senderSockAddr); |
| 4305 | 4219 | ||
| 4306 | // parse the incoming stats datas stick it in a temporary object for now, while we | 4220 | // parse the incoming stats datas stick it in a temporary object for now, while we |
| 4307 | // determine which server it belongs to | 4221 | // determine which server it belongs to |