History

merge upstream/master into avatar-interaction

Andrew Meadows committed 12 years ago

Commit 84d7e392 parents d902580 72d09a515 files · +708 −614Browse files

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

Unified · Split

interface/src/Application.cpp+27−423
@@ -63,7 +63,7 @@ · 62 unmodified lines
63#include <UUID.h>63#include <UUID.h>
64#include <OctreeSceneStats.h>64#include <OctreeSceneStats.h>
65#include <LocalVoxelsList.h>65#include <LocalVoxelsList.h>
66#include <FstReader.h>66#include <ModelUploader.h>
67 67
68#include "Application.h"68#include "Application.h"
69#include "InterfaceVersion.h"69#include "InterfaceVersion.h"
@@ -81,6 +81,7 @@ · 11 unmodified lines
81#include "ui/InfoView.h"81#include "ui/InfoView.h"
82#include "ui/Snapshot.h"82#include "ui/Snapshot.h"
83#include "ui/TextRenderer.h"83#include "ui/TextRenderer.h"
84#include "ui/Stats.h"
84 85
85using namespace std;86using namespace std;
86 87
@@ -110,8 +111,6 @@ const float MIRROR_FIELD_OF_VIEW = 30.0f; · 23 unmodified lines
110const QString CHECK_VERSION_URL = "http://highfidelity.io/latestVersion.xml";111const QString CHECK_VERSION_URL = "http://highfidelity.io/latestVersion.xml";
111const QString SKIP_FILENAME = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/hifi.skipversion";112const QString SKIP_FILENAME = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/hifi.skipversion";
112 113
113const int STATS_PELS_PER_LINE = 20;
114
115void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& message) {114void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& message) {
116 if (message.size() > 0) {115 if (message.size() > 0) {
117 QString dateString = QDateTime::currentDateTime().toTimeSpec(Qt::LocalTime).toString(Qt::ISODate);116 QString dateString = QDateTime::currentDateTime().toTimeSpec(Qt::LocalTime).toString(Qt::ISODate);
@@ -135,7 +134,6 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 17 unmodified lines
135 QApplication(argc, argv),134 QApplication(argc, argv),
136 _window(new QMainWindow(desktop())),135 _window(new QMainWindow(desktop())),
137 _glWidget(new GLCanvas()),136 _glWidget(new GLCanvas()),
138 _statsExpanded(false),
139 _nodeThread(new QThread(this)),137 _nodeThread(new QThread(this)),
140 _datagramProcessor(),138 _datagramProcessor(),
141 _frameCount(0),139 _frameCount(0),
@@ -149,7 +147,6 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 7 unmodified lines
149 _lastQueriedViewFrustum(),147 _lastQueriedViewFrustum(),
150 _lastQueriedTime(usecTimestampNow()),148 _lastQueriedTime(usecTimestampNow()),
151 _audioScope(256, 200, true),149 _audioScope(256, 200, true),
152 _trailingAudioLoudness(0.f),
153 _mirrorViewRect(QRect(MIRROR_VIEW_LEFT_PADDING, MIRROR_VIEW_TOP_PADDING, MIRROR_VIEW_WIDTH, MIRROR_VIEW_HEIGHT)),150 _mirrorViewRect(QRect(MIRROR_VIEW_LEFT_PADDING, MIRROR_VIEW_TOP_PADDING, MIRROR_VIEW_WIDTH, MIRROR_VIEW_HEIGHT)),
154 _mouseX(0),151 _mouseX(0),
155 _mouseY(0),152 _mouseY(0),
@@ -166,8 +163,6 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 10 unmodified lines
166 _voxelHideShowThread(&_voxels),163 _voxelHideShowThread(&_voxels),
167 _packetsPerSecond(0),164 _packetsPerSecond(0),
168 _bytesPerSecond(0),165 _bytesPerSecond(0),
169 _recentMaxPackets(0),
170 _resetRecentMaxPacketsSoon(true),
171 _previousScriptLocation(),166 _previousScriptLocation(),
172 _logger(new FileLogger(this))167 _logger(new FileLogger(this))
173{168{
@@ -515,7 +510,7 @@ void Application::paintGL() { · 341 unmodified lines
515 _myCamera.setDistance(0.0f);510 _myCamera.setDistance(0.0f);
516 _myCamera.setTightness(0.0f); // Camera is directly connected to head without smoothing511 _myCamera.setTightness(0.0f); // Camera is directly connected to head without smoothing
517 _myCamera.setTargetPosition(_myAvatar->getHead()->calculateAverageEyePosition());512 _myCamera.setTargetPosition(_myAvatar->getHead()->calculateAverageEyePosition());
518 _myCamera.setTargetRotation(_myAvatar->getHead()->getOrientation());513 _myCamera.setTargetRotation(_myAvatar->getHead()->getCameraOrientation());
519 514
520 } else if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON) {515 } else if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON) {
521 _myCamera.setTightness(0.0f); // In first person, camera follows (untweaked) head exactly without delay516 _myCamera.setTightness(0.0f); // In first person, camera follows (untweaked) head exactly without delay
@@ -617,6 +612,14 @@ void Application::resizeGL(int width, int height) { · 95 unmodified lines
617 612
618 updateProjectionMatrix();613 updateProjectionMatrix();
619 glLoadIdentity();614 glLoadIdentity();
615
616 // update Stats width
617 int horizontalOffset = 0;
618 if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) {
619 // mirror is enabled, let's set horizontal offset to give stats some margin
620 horizontalOffset += MIRROR_VIEW_WIDTH + MIRROR_VIEW_LEFT_PADDING * 2;
621 }
622 Stats::getInstance()->resetWidth(width, horizontalOffset);
620}623}
621 624
622void Application::updateProjectionMatrix() {625void Application::updateProjectionMatrix() {
@@ -1059,7 +1062,11 @@ void Application::mouseReleaseEvent(QMouseEvent* event) { · 436 unmodified lines
1059 _mousePressed = false;1062 _mousePressed = false;
1060 checkBandwidthMeterClick();1063 checkBandwidthMeterClick();
1061 if (Menu::getInstance()->isOptionChecked(MenuOption::Stats)) {1064 if (Menu::getInstance()->isOptionChecked(MenuOption::Stats)) {
1062 checkStatsClick();1065 int horizontalOffset = 0;
1066 if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) {
1067 horizontalOffset = MIRROR_VIEW_WIDTH;
1068 }
1069 Stats::getInstance()->checkClick(_mouseX, _mouseY, _mouseDragStartedX, _mouseDragStartedY, horizontalOffset);
1063 }1070 }
1064 }1071 }
1065 }1072 }
@@ -2598,11 +2605,17 @@ void Application::displayOverlay() { · 1532 unmodified lines
2598 glPointSize(1.0f);2605 glPointSize(1.0f);
2599 2606
2600 if (Menu::getInstance()->isOptionChecked(MenuOption::Stats)) {2607 if (Menu::getInstance()->isOptionChecked(MenuOption::Stats)) {
2608 int horizontalOffset = 0;
2609 if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) {
2610 // mirror is enabled, let's set horizontal offset to give stats some margin
2611 horizontalOffset += MIRROR_VIEW_WIDTH + MIRROR_VIEW_LEFT_PADDING * 2;
2612 }
2613 int voxelPacketsToProcess = _voxelProcessor.packetsToProcessCount();
2601 // Onscreen text about position, servers, etc2614 // Onscreen text about position, servers, etc
2602 displayStats();2615 Stats::getInstance()->display(WHITE_TEXT, horizontalOffset, _fps, _packetsPerSecond, _bytesPerSecond, voxelPacketsToProcess);
2603 // Bandwidth meter2616 // Bandwidth meter
2604 if (Menu::getInstance()->isOptionChecked(MenuOption::Bandwidth)) {2617 if (Menu::getInstance()->isOptionChecked(MenuOption::Bandwidth)) {
2605 displayStatsBackground(0x33333399, _glWidget->width() - 296, _glWidget->height() - 68, 296, 68);2618 Stats::drawBackground(0x33333399, _glWidget->width() - 296, _glWidget->height() - 68, 296, 68);
2606 _bandwidthMeter.render(_glWidget->width(), _glWidget->height());2619 _bandwidthMeter.render(_glWidget->width(), _glWidget->height());
2607 }2620 }
2608 }2621 }
@@ -2624,415 +2637,6 @@ void Application::displayOverlay() { · 15 unmodified lines
2624 glPopMatrix();2637 glPopMatrix();
2625}2638}
2626 2639
2627// translucent background box that makes stats more readable
2628void Application::displayStatsBackground(unsigned int rgba, int x, int y, int width, int height) {
2629 glBegin(GL_QUADS);
2630 glColor4f(((rgba >> 24) & 0xff) / 255.0f,
2631 ((rgba >> 16) & 0xff) / 255.0f,
2632 ((rgba >> 8) & 0xff) / 255.0f,
2633 (rgba & 0xff) / 255.0f);
2634 glVertex3f(x, y, 0);
2635 glVertex3f(x + width, y, 0);
2636 glVertex3f(x + width, y + height, 0);
2637 glVertex3f(x , y + height, 0);
2638 glEnd();
2639 glColor4f(1, 1, 1, 1);
2640}
2641
2642// display expanded or contracted stats
2643
2644void Application::displayStats() {
2645 unsigned int backgroundColor = 0x33333399;
2646 int verticalOffset = 0, horizontalOffset = 0, lines = 0;
2647 bool mirrorEnabled = Menu::getInstance()->isOptionChecked(MenuOption::Mirror);
2648
2649 QLocale locale(QLocale::English);
2650 std::stringstream voxelStats;
2651
2652 glPointSize(1.0f);
2653
2654 // we need to take one avatar out so we don't include ourselves
2655 int totalAvatars = _avatarManager.size() - 1;
2656 int totalServers = NodeList::getInstance()->size();
2657
2658 if (mirrorEnabled) {
2659 horizontalOffset += MIRROR_VIEW_WIDTH + MIRROR_VIEW_LEFT_PADDING * 2;
2660 }
2661
2662 lines = _statsExpanded ? 5 : 3;
2663 displayStatsBackground(backgroundColor, horizontalOffset, 0, 165, lines * STATS_PELS_PER_LINE + 10);
2664 horizontalOffset += 5;
2665
2666 char serverNodes[30];
2667 sprintf(serverNodes, "Servers: %d", totalServers);
2668 char avatarNodes[30];
2669 sprintf(avatarNodes, "Avatars: %d", totalAvatars);
2670 char framesPerSecond[30];
2671 sprintf(framesPerSecond, "Framerate: %3.0f FPS", _fps);
2672
2673 verticalOffset += STATS_PELS_PER_LINE;
2674 drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, serverNodes, WHITE_TEXT);
2675 verticalOffset += STATS_PELS_PER_LINE;
2676 drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, avatarNodes, WHITE_TEXT);
2677 verticalOffset += STATS_PELS_PER_LINE;
2678 drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, framesPerSecond, WHITE_TEXT);
2679
2680 if (_statsExpanded) {
2681 char packetsPerSecond[30];
2682 sprintf(packetsPerSecond, "Pkts/sec: %d", _packetsPerSecond);
2683 char averageMegabitsPerSecond[30];
2684 sprintf(averageMegabitsPerSecond, "Mbps: %3.2f", (float)_bytesPerSecond * 8.f / 1000000.f);
2685
2686 verticalOffset += STATS_PELS_PER_LINE;
2687 drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, packetsPerSecond, WHITE_TEXT);
2688 verticalOffset += STATS_PELS_PER_LINE;
2689 drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, averageMegabitsPerSecond, WHITE_TEXT);
2690 }
2691
2692 verticalOffset = 0;
2693 horizontalOffset += 161;
2694
2695 if (Menu::getInstance()->isOptionChecked(MenuOption::TestPing)) {
2696 int pingAudio = 0, pingAvatar = 0, pingVoxel = 0, pingVoxelMax = 0;
2697
2698 NodeList* nodeList = NodeList::getInstance();
2699 SharedNodePointer audioMixerNode = nodeList->soloNodeOfType(NodeType::AudioMixer);
2700 SharedNodePointer avatarMixerNode = nodeList->soloNodeOfType(NodeType::AvatarMixer);
2701
2702 pingAudio = audioMixerNode ? audioMixerNode->getPingMs() : 0;
2703 pingAvatar = avatarMixerNode ? avatarMixerNode->getPingMs() : 0;
2704
2705 // Now handle voxel servers, since there could be more than one, we average their ping times
2706 unsigned long totalPingVoxel = 0;
2707 int voxelServerCount = 0;
2708
2709 foreach (const SharedNodePointer& node, nodeList->getNodeHash()) {
2710 if (node->getType() == NodeType::VoxelServer) {
2711 totalPingVoxel += node->getPingMs();
2712 voxelServerCount++;
2713 if (pingVoxelMax < node->getPingMs()) {
2714 pingVoxelMax = node->getPingMs();
2715 }
2716 }
2717 }
2718
2719 if (voxelServerCount) {
2720 pingVoxel = totalPingVoxel/voxelServerCount;
2721 }
2722
2723 lines = _statsExpanded ? 4 : 3;
2724 displayStatsBackground(backgroundColor, horizontalOffset, 0, 175, lines * STATS_PELS_PER_LINE + 10);
2725 horizontalOffset += 5;
2726
2727 char audioJitter[30];
2728 sprintf(audioJitter,
2729 "Buffer msecs %.1f",
2730 (float) (_audio.getNetworkBufferLengthSamplesPerChannel() + (float) _audio.getJitterBufferSamples()) /
2731 (float)_audio.getNetworkSampleRate() * 1000.f);
2732 drawText(30, _glWidget->height() - 22, 0.10f, 0.f, 2.f, audioJitter, WHITE_TEXT);
2733
2734
2735 char audioPing[30];
2736 sprintf(audioPing, "Audio ping: %d", pingAudio);
2737
2738
2739 char avatarPing[30];
2740 sprintf(avatarPing, "Avatar ping: %d", pingAvatar);
2741 char voxelAvgPing[30];
2742 sprintf(voxelAvgPing, "Voxel avg ping: %d", pingVoxel);
2743
2744 verticalOffset += STATS_PELS_PER_LINE;
2745 drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, audioPing, WHITE_TEXT);
2746 verticalOffset += STATS_PELS_PER_LINE;
2747 drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, avatarPing, WHITE_TEXT);
2748 verticalOffset += STATS_PELS_PER_LINE;
2749 drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, voxelAvgPing, WHITE_TEXT);
2750
2751 if (_statsExpanded) {
2752 char voxelMaxPing[30];
2753 sprintf(voxelMaxPing, "Voxel max ping: %d", pingVoxelMax);
2754
2755 verticalOffset += STATS_PELS_PER_LINE;
2756 drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, voxelMaxPing, WHITE_TEXT);
2757 }
2758
2759 verticalOffset = 0;
2760 horizontalOffset += 171;
2761 }
2762
2763 glm::vec3 avatarPos = _myAvatar->getPosition();
2764
2765 lines = _statsExpanded ? 5 : 3;
2766 displayStatsBackground(backgroundColor, horizontalOffset, 0, _glWidget->width() - (mirrorEnabled ? 301 : 411) - horizontalOffset, lines * STATS_PELS_PER_LINE + 10);
2767 horizontalOffset += 5;
2768
2769 char avatarPosition[200];
2770 if (mirrorEnabled) {
2771 // shorthand formatting
2772 sprintf(avatarPosition, "Pos: %.0f,%.0f,%.0f", avatarPos.x, avatarPos.y, avatarPos.z);
2773 } else {
2774 // longhand way
2775 sprintf(avatarPosition, "Position: %.1f, %.1f, %.1f", avatarPos.x, avatarPos.y, avatarPos.z);
2776 }
2777 char avatarVelocity[30];
2778 sprintf(avatarVelocity, "Velocity: %.1f", glm::length(_myAvatar->getVelocity()));
2779 char avatarBodyYaw[30];
2780 sprintf(avatarBodyYaw, "Yaw: %.1f", _myAvatar->getBodyYaw());
2781 char avatarMixerStats[200];
2782
2783 verticalOffset += STATS_PELS_PER_LINE;
2784 drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, avatarPosition, WHITE_TEXT);
2785 verticalOffset += STATS_PELS_PER_LINE;
2786 drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, avatarVelocity, WHITE_TEXT);
2787 verticalOffset += STATS_PELS_PER_LINE;
2788 drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, avatarBodyYaw, WHITE_TEXT);
2789
2790 if (_statsExpanded) {
2791 SharedNodePointer avatarMixer = NodeList::getInstance()->soloNodeOfType(NodeType::AvatarMixer);
2792 if (avatarMixer) {
2793 sprintf(avatarMixerStats, "Avatar Mixer: %.f kbps, %.f pps",
2794 roundf(avatarMixer->getAverageKilobitsPerSecond()),
2795 roundf(avatarMixer->getAveragePacketsPerSecond()));
2796 } else {
2797 sprintf(avatarMixerStats, "No Avatar Mixer");
2798 }
2799
2800 verticalOffset += STATS_PELS_PER_LINE;
2801 drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, avatarMixerStats, WHITE_TEXT);
2802
2803 stringstream downloadStats;
2804 downloadStats << "Downloads: ";
2805 foreach (Resource* resource, ResourceCache::getLoadingRequests()) {
2806 const float MAXIMUM_PERCENTAGE = 100.0f;
2807 downloadStats << roundf(resource->getProgress() * MAXIMUM_PERCENTAGE) << "% ";
2808 }
2809 downloadStats << "(" << ResourceCache::getPendingRequestCount() << " pending)";
2810
2811 verticalOffset += STATS_PELS_PER_LINE;
2812 drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, downloadStats.str().c_str(), WHITE_TEXT);
2813 }
2814
2815 verticalOffset = 0;
2816 horizontalOffset = _glWidget->width() - (mirrorEnabled ? 300 : 410);
2817
2818 lines = _statsExpanded ? 12 : 3;
2819 displayStatsBackground(backgroundColor, horizontalOffset, 0, _glWidget->width() - horizontalOffset, lines * STATS_PELS_PER_LINE + 10);
2820 horizontalOffset += 5;
2821
2822 if (_statsExpanded) {
2823 // Local Voxel Memory Usage
2824 voxelStats.str("");
2825 voxelStats << "Voxels Memory Nodes: " << VoxelTreeElement::getTotalMemoryUsage() / 1000000.f << "MB";
2826 verticalOffset += STATS_PELS_PER_LINE;
2827 drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, (char*)voxelStats.str().c_str(), WHITE_TEXT);
2828
2829 voxelStats.str("");
2830 voxelStats <<
2831 "Geometry RAM: " << _voxels.getVoxelMemoryUsageRAM() / 1000000.f << "MB / " <<
2832 "VBO: " << _voxels.getVoxelMemoryUsageVBO() / 1000000.f << "MB";
2833 if (_voxels.hasVoxelMemoryUsageGPU()) {
2834 voxelStats << " / GPU: " << _voxels.getVoxelMemoryUsageGPU() / 1000000.f << "MB";
2835 }
2836 verticalOffset += STATS_PELS_PER_LINE;
2837 drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, (char*)voxelStats.str().c_str(), WHITE_TEXT);
2838
2839 // Voxel Rendering
2840 voxelStats.str("");
2841 voxelStats.precision(4);
2842 voxelStats << "Voxel Rendering Slots Max: " << _voxels.getMaxVoxels() / 1000.f << "K";
2843 verticalOffset += STATS_PELS_PER_LINE;
2844 drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, (char*)voxelStats.str().c_str(), WHITE_TEXT);
2845 }
2846
2847 voxelStats.str("");
2848 voxelStats.precision(4);
2849 voxelStats << "Drawn: " << _voxels.getVoxelsWritten() / 1000.f << "K " <<
2850 "Abandoned: " << _voxels.getAbandonedVoxels() / 1000.f << "K ";
2851 verticalOffset += STATS_PELS_PER_LINE;
2852 drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, (char*)voxelStats.str().c_str(), WHITE_TEXT);
2853
2854 // iterate all the current voxel stats, and list their sending modes, and total voxel counts
2855 std::stringstream sendingMode("");
2856 sendingMode << "Octree Sending Mode: [";
2857 int serverCount = 0;
2858 int movingServerCount = 0;
2859 unsigned long totalNodes = 0;
2860 unsigned long totalInternal = 0;
2861 unsigned long totalLeaves = 0;
2862 for(NodeToOctreeSceneStatsIterator i = _octreeServerSceneStats.begin(); i != _octreeServerSceneStats.end(); i++) {
2863 //const QUuid& uuid = i->first;
2864 OctreeSceneStats& stats = i->second;
2865 serverCount++;
2866 if (_statsExpanded) {
2867 if (serverCount > 1) {
2868 sendingMode << ",";
2869 }
2870 if (stats.isMoving()) {
2871 sendingMode << "M";
2872 movingServerCount++;
2873 } else {
2874 sendingMode << "S";
2875 }
2876 }
2877
2878 // calculate server node totals
2879 totalNodes += stats.getTotalElements();
2880 if (_statsExpanded) {
2881 totalInternal += stats.getTotalInternal();
2882 totalLeaves += stats.getTotalLeaves();
2883 }
2884 }
2885 if (_statsExpanded) {
2886 if (serverCount == 0) {
2887 sendingMode << "---";
2888 }
2889 sendingMode << "] " << serverCount << " servers";
2890 if (movingServerCount > 0) {
2891 sendingMode << " <SCENE NOT STABLE>";
2892 } else {
2893 sendingMode << " <SCENE STABLE>";
2894 }
2895 verticalOffset += STATS_PELS_PER_LINE;
2896 drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, (char*)sendingMode.str().c_str(), WHITE_TEXT);
2897 }
2898
2899 // Incoming packets
2900 int voxelPacketsToProcess = _voxelProcessor.packetsToProcessCount();
2901 if (_statsExpanded) {
2902 voxelStats.str("");
2903 QString packetsString = locale.toString((int)voxelPacketsToProcess);
2904 QString maxString = locale.toString((int)_recentMaxPackets);
2905 voxelStats << "Voxel Packets to Process: " << qPrintable(packetsString)
2906 << " [Recent Max: " << qPrintable(maxString) << "]";
2907 verticalOffset += STATS_PELS_PER_LINE;
2908 drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, (char*)voxelStats.str().c_str(), WHITE_TEXT);
2909 }
2910
2911 if (_resetRecentMaxPacketsSoon && voxelPacketsToProcess > 0) {
2912 _recentMaxPackets = 0;
2913 _resetRecentMaxPacketsSoon = false;
2914 }
2915 if (voxelPacketsToProcess == 0) {
2916 _resetRecentMaxPacketsSoon = true;
2917 } else {
2918 if (voxelPacketsToProcess > _recentMaxPackets) {
2919 _recentMaxPackets = voxelPacketsToProcess;
2920 }
2921 }
2922
2923 verticalOffset += (_statsExpanded ? STATS_PELS_PER_LINE : 0);
2924
2925 QString serversTotalString = locale.toString((uint)totalNodes); // consider adding: .rightJustified(10, ' ');
2926
2927 // Server Voxels
2928 voxelStats.str("");
2929 voxelStats << "Server voxels: " << qPrintable(serversTotalString);
2930 verticalOffset += STATS_PELS_PER_LINE;
2931 drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, (char*)voxelStats.str().c_str(), WHITE_TEXT);
2932
2933 if (_statsExpanded) {
2934 QString serversInternalString = locale.toString((uint)totalInternal);
2935 QString serversLeavesString = locale.toString((uint)totalLeaves);
2936
2937 voxelStats.str("");
2938 voxelStats <<
2939 "Internal: " << qPrintable(serversInternalString) << " " <<
2940 "Leaves: " << qPrintable(serversLeavesString) << "";
2941 verticalOffset += STATS_PELS_PER_LINE;
2942 drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, (char*)voxelStats.str().c_str(), WHITE_TEXT);
2943 }
2944
2945 unsigned long localTotal = VoxelTreeElement::getNodeCount();
2946 QString localTotalString = locale.toString((uint)localTotal); // consider adding: .rightJustified(10, ' ');
2947
2948 // Local Voxels
2949 voxelStats.str("");
2950 voxelStats << "Local voxels: " << qPrintable(localTotalString);
2951 verticalOffset += STATS_PELS_PER_LINE;
2952 drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, (char*)voxelStats.str().c_str(), WHITE_TEXT);
2953
2954 if (_statsExpanded) {
2955 unsigned long localInternal = VoxelTreeElement::getInternalNodeCount();
2956 unsigned long localLeaves = VoxelTreeElement::getLeafNodeCount();
2957 QString localInternalString = locale.toString((uint)localInternal);
2958 QString localLeavesString = locale.toString((uint)localLeaves);
2959
2960 voxelStats.str("");
2961 voxelStats <<
2962 "Internal: " << qPrintable(localInternalString) << " " <<
2963 "Leaves: " << qPrintable(localLeavesString) << "";
2964 verticalOffset += STATS_PELS_PER_LINE;
2965 drawText(horizontalOffset, verticalOffset, 0.10f, 0, 2, (char*)voxelStats.str().c_str(), WHITE_TEXT);
2966 }
2967
2968 // LOD Details
2969 if (_statsExpanded) {
2970 voxelStats.str("");
2971 QString displayLODDetails = Menu::getInstance()->getLODFeedbackText();
2972 voxelStats << "LOD: You can see " << qPrintable(displayLODDetails.trimmed());
2973 verticalOffset += STATS_PELS_PER_LINE;
2974 drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, (char*)voxelStats.str().c_str(), WHITE_TEXT);
2975 }
2976}
2977
2978// called on mouse click release
2979// check for clicks over stats in order to expand or contract them
2980void Application::checkStatsClick() {
2981 if (0 != glm::compMax(glm::abs(glm::ivec2(_mouseX - _mouseDragStartedX, _mouseY - _mouseDragStartedY)))) {
2982 // not worried about dragging on stats
2983 return;
2984 }
2985
2986 int statsHeight = 0, statsWidth = 0, statsX = 0, statsY = 0, lines = 0;
2987
2988 if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) {
2989 statsX += MIRROR_VIEW_WIDTH;
2990 }
2991
2992 // top-left stats click
2993 lines = _statsExpanded ? 5 : 3;
2994 statsHeight = lines * STATS_PELS_PER_LINE + 10;
2995 statsWidth = 165;
2996 if (_mouseX > statsX && _mouseX < statsX + statsWidth && _mouseY > statsY && _mouseY < statsY + statsHeight) {
2997 toggleStatsExpanded();
2998 return;
2999 }
3000
3001 // ping stats click
3002 lines = _statsExpanded ? 4 : 3;
3003 statsX += statsWidth;
3004 statsHeight = lines * STATS_PELS_PER_LINE + 10;
3005 statsWidth = 175;
3006 if (_mouseX > statsX && _mouseX < statsX + statsWidth && _mouseY > statsY && _mouseY < statsY + statsHeight) {
3007 toggleStatsExpanded();
3008 return;
3009 }
3010
3011 // top-center stats panel click
3012 lines = _statsExpanded ? 4 : 3;
3013 statsX += statsWidth;
3014 statsHeight = lines * STATS_PELS_PER_LINE + 10;
3015 statsWidth = _glWidget->width() - 411 - statsX;
3016 if (_mouseX > statsX && _mouseX < statsX + statsWidth && _mouseY > statsY && _mouseY < statsY + statsHeight) {
3017 toggleStatsExpanded();
3018 return;
3019 }
3020
3021 // top-right stats click
3022 lines = _statsExpanded ? 11 : 3;
3023 statsX = _glWidget->width() - 410;
3024 statsHeight = lines * STATS_PELS_PER_LINE + 10;
3025 statsWidth = _glWidget->width() - statsX;
3026 if (_mouseX > statsX && _mouseX < statsX + statsWidth && _mouseY > statsY && _mouseY < statsY + statsHeight) {
3027 toggleStatsExpanded();
3028 return;
3029 }
3030}
3031
3032void Application::toggleStatsExpanded() {
3033 _statsExpanded = !_statsExpanded;
3034}
3035
3036glm::vec2 Application::getScaledScreenPoint(glm::vec2 projectedPoint) {2640glm::vec2 Application::getScaledScreenPoint(glm::vec2 projectedPoint) {
3037 float horizontalScale = _glWidget->width() / 2.0f;2641 float horizontalScale = _glWidget->width() / 2.0f;
3038 float verticalScale = _glWidget->height() / 2.0f;2642 float verticalScale = _glWidget->height() / 2.0f;
@@ -3640,9 +3244,9 @@ void Application::toggleRunningScriptsWidget() · 601 unmodified lines
3640}3244}
3641 3245
3642void Application::uploadFST(bool isHead) {3246void Application::uploadFST(bool isHead) {
3643 FstReader reader(isHead);3247 ModelUploader* uploader = new ModelUploader(isHead);
3644 if (reader.zip()) {3248 if (uploader->zip()) {
3645 reader.send();3249 uploader->send();
3646 }3250 }
3647}3251}
3648 3252

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