History

resolve conflicts on merge with upstream master

Stephen Birarda committed 12 years ago

Commit 2aaa9ce2 parents b009cd8 ade02c040 files · +1485 −444Browse files

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

Unified · Split

interface/src/Application.cpp+335−117
@@ -47,6 +47,7 @@ · 46 unmodified lines
4747 #include <QDesktopServices>
4848 #include <QXmlStreamReader>
4949 #include <QXmlStreamAttributes>
50+#include <QMediaPlayer>
5051
5152 #include <AudioInjector.h>
5253 #include <Logging.h>
@@ -69,6 +70,7 @@ · 16 unmodified lines
6970 #include "renderer/ProgramObject.h"
7071 #include "ui/TextRenderer.h"
7172 #include "InfoView.h"
73+#include "ui/Snapshot.h"
7274
7375 using namespace std;
7476
@@ -97,6 +99,8 @@ const float MIRROR_REARVIEW_BODY_DISTANCE = 2.3f; · 22 unmodified lines
9799 const QString CHECK_VERSION_URL = "http://highfidelity.io/latestVersion.xml";
98100 const QString SKIP_FILENAME = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/hifi.skipversion";
99101
102+const int STATS_PELS_PER_LINE = 20;
103+
100104 void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString &message) {
101105 QString messageWithNewLine = message + "\n";
102106 fprintf(stdout, "%s", messageWithNewLine.toLocal8Bit().constData());
@@ -107,6 +111,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 4 unmodified lines
107111 QApplication(argc, argv),
108112 _window(new QMainWindow(desktop())),
109113 _glWidget(new GLCanvas()),
114+ _statsExpanded(false),
110115 _nodeThread(new QThread(this)),
111116 _datagramProcessor(),
112117 _frameCount(0),
@@ -249,6 +254,10 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 136 unmodified lines
249254
250255 restoreSizeAndPosition();
251256 loadScripts();
257+
258+ QFontDatabase fontDatabase;
259+ fontDatabase.addApplicationFont("resources/styles/Inconsolata.otf");
260+
252261 _window->setVisible(true);
253262 _glWidget->setFocusPolicy(Qt::StrongFocus);
254263 _glWidget->setFocus();
@@ -764,6 +773,8 @@ void Application::keyPressEvent(QKeyEvent* event) { · 509 unmodified lines
764773 _voxels.collectStatsForTreesAndVBOs();
765774 } else if (isShifted && isMeta) {
766775 Menu::getInstance()->triggerOption(MenuOption::SuppressShortTimings);
776+ } else if (!isShifted && isMeta) {
777+ takeSnapshot();
767778 } else if (_nudgeStarted) {
768779 if (_lookingAlongX) {
769780 if (_lookingAwayFromOrigin) {
@@ -1258,6 +1269,9 @@ void Application::mouseReleaseEvent(QMouseEvent* event) { · 488 unmodified lines
12581269 _mouseY = event->y();
12591270 _mousePressed = false;
12601271 checkBandwidthMeterClick();
1272+ if (Menu::getInstance()->isOptionChecked(MenuOption::Stats)) {
1273+ checkStatsClick();
1274+ }
12611275
12621276 _pieMenu.mouseReleaseEvent(_mouseX, _mouseY);
12631277 }
@@ -1718,7 +1732,7 @@ void Application::init() { · 454 unmodified lines
17181732 _sharedVoxelSystem.changeTree(&_clipboard);
17191733 delete tmpTree;
17201734
1721− _voxelImporter.init();
1735+ _voxelImporter.init(_settings);
17221736
17231737 _environment.init();
17241738
@@ -2962,9 +2976,11 @@ void Application::displayOverlay() { · 1237 unmodified lines
29622976 }
29632977
29642978 if (Menu::getInstance()->isOptionChecked(MenuOption::Stats)) {
2979+ displayStatsBackground(0x33333399, 0, _glWidget->height() - 68, 296, 68);
29652980 _audio.render(_glWidget->width(), _glWidget->height());
29662981 if (Menu::getInstance()->isOptionChecked(MenuOption::Oscilloscope)) {
2967− _audioScope.render(45, _glWidget->height() - 200);
2982+ int oscilloscopeTop = Menu::getInstance()->isOptionChecked(MenuOption::Mirror) ? 130 : 25;
2983+ _audioScope.render(25, oscilloscopeTop);
29682984 }
29692985 }
29702986
@@ -3019,17 +3035,9 @@ void Application::displayOverlay() { · 48 unmodified lines
30193035 displayStats();
30203036 // Bandwidth meter
30213037 if (Menu::getInstance()->isOptionChecked(MenuOption::Bandwidth)) {
3038+ displayStatsBackground(0x33333399, _glWidget->width() - 296, _glWidget->height() - 68, 296, 68);
30223039 _bandwidthMeter.render(_glWidget->width(), _glWidget->height());
30233040 }
3024− // Stats at upper right of screen about who domain server is telling us about
3025− glPointSize(1.0f);
3026− char nodes[100];
3027−
3028− int totalAvatars = _avatarManager.size();
3029− int totalServers = NodeList::getInstance()->size();
3030−
3031− sprintf(nodes, "Servers: %d, Avatars: %d\n", totalServers, totalAvatars);
3032− drawtext(_glWidget->width() - 150, 20, 0.10f, 0, 1.0f, 0, nodes, 1, 0, 0);
30333041 }
30343042
30353043 // testing rendering coverage map
@@ -3051,8 +3059,12 @@ void Application::displayOverlay() { · 15 unmodified lines
30513059 char frameTimer[10];
30523060 uint64_t mSecsNow = floor(usecTimestampNow() / 1000.0 + 0.5);
30533061 sprintf(frameTimer, "%d\n", (int)(mSecsNow % 1000));
3054− drawtext(_glWidget->width() - 100, _glWidget->height() - 20, 0.30f, 0, 1.0f, 0, frameTimer, 0, 0, 0);
3055− drawtext(_glWidget->width() - 102, _glWidget->height() - 22, 0.30f, 0, 1.0f, 0, frameTimer, 1, 1, 1);
3062+ int timerBottom =
3063+ (Menu::getInstance()->isOptionChecked(MenuOption::Stats) &&
3064+ Menu::getInstance()->isOptionChecked(MenuOption::Bandwidth))
3065+ ? 80 : 20;
3066+ drawtext(_glWidget->width() - 100, _glWidget->height() - timerBottom, 0.30f, 0, 1.0f, 0, frameTimer, 0, 0, 0);
3067+ drawtext(_glWidget->width() - 102, _glWidget->height() - timerBottom - 2, 0.30f, 0, 1.0f, 0, frameTimer, 1, 1, 1);
30563068 }
30573069
30583070 _palette.render(_glWidget->width(), _glWidget->height());
@@ -3110,15 +3122,73 @@ void Application::displayOverlay() { · 51 unmodified lines
31103122 glPopMatrix();
31113123 }
31123124
3125+// translucent background box that makes stats more readable
3126+void Application::displayStatsBackground(unsigned int rgba, int x, int y, int width, int height) {
3127+ glBegin(GL_QUADS);
3128+ glColor4f(((rgba >> 24) & 0xff) / 255.0f,
3129+ ((rgba >> 16) & 0xff) / 255.0f,
3130+ ((rgba >> 8) & 0xff) / 255.0f,
3131+ (rgba & 0xff) / 255.0f);
3132+ glVertex3f(x, y, 0);
3133+ glVertex3f(x + width, y, 0);
3134+ glVertex3f(x + width, y + height, 0);
3135+ glVertex3f(x , y + height, 0);
3136+ glEnd();
3137+ glColor4f(1, 1, 1, 1);
3138+}
31133139
3140+// display expanded or contracted stats
31143141 void Application::displayStats() {
3115− int statsVerticalOffset = 8;
3116− const int PELS_PER_LINE = 15;
3117− char stats[200];
3118− statsVerticalOffset += PELS_PER_LINE;
3119− sprintf(stats, "%3.0f FPS, %d Pkts/sec, %3.2f Mbps ",
3120− _fps, _packetsPerSecond, (float)_bytesPerSecond * 8.f / 1000000.f);
3121− drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, stats);
3142+ unsigned int backgroundColor = 0x33333399;
3143+ int verticalOffset = 0, horizontalOffset = 0, lines = 0;
3144+ bool mirrorEnabled = Menu::getInstance()->isOptionChecked(MenuOption::Mirror);
3145+
3146+ QLocale locale(QLocale::English);
3147+ std::stringstream voxelStats;
3148+
3149+ glPointSize(1.0f);
3150+
3151+ int totalAvatars = 0, totalServers = 0;
3152+ foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) {
3153+ node->getType() == NODE_TYPE_AGENT ? totalAvatars++ : totalServers++;
3154+ }
3155+
3156+ if (mirrorEnabled) {
3157+ horizontalOffset += MIRROR_VIEW_WIDTH + MIRROR_VIEW_LEFT_PADDING * 2;
3158+ }
3159+
3160+ lines = _statsExpanded ? 5 : 3;
3161+ displayStatsBackground(backgroundColor, horizontalOffset, 0, 165, lines * STATS_PELS_PER_LINE + 10);
3162+ horizontalOffset += 5;
3163+
3164+ char serverNodes[30];
3165+ sprintf(serverNodes, "Servers: %d", totalServers);
3166+ char avatarNodes[30];
3167+ sprintf(avatarNodes, "Avatars: %d", totalAvatars);
3168+ char framesPerSecond[30];
3169+ sprintf(framesPerSecond, "Framerate: %3.0f FPS", _fps);
3170+
3171+ verticalOffset += STATS_PELS_PER_LINE;
3172+ drawtext(horizontalOffset, verticalOffset, 0.10f, 0, 1.0f, 2, serverNodes, .93f, .93f, .93f);
3173+ verticalOffset += STATS_PELS_PER_LINE;
3174+ drawtext(horizontalOffset, verticalOffset, 0.10f, 0, 1.0f, 2, avatarNodes, .93f, .93f, .93f);
3175+ verticalOffset += STATS_PELS_PER_LINE;
3176+ drawtext(horizontalOffset, verticalOffset, 0.10f, 0, 1.0, 2, framesPerSecond, .93f, .93f, .93f);
3177+
3178+ if (_statsExpanded) {
3179+ char packetsPerSecond[30];
3180+ sprintf(packetsPerSecond, "Pkts/sec: %d", _packetsPerSecond);
3181+ char averageMegabitsPerSecond[30];
3182+ sprintf(averageMegabitsPerSecond, "Avg Mbps: %3.2f", (float)_bytesPerSecond * 8.f / 1000000.f);
3183+
3184+ verticalOffset += STATS_PELS_PER_LINE;
3185+ drawtext(horizontalOffset, verticalOffset, 0.10f, 0, 1.0, 2, packetsPerSecond, .93f, .93f, .93f);
3186+ verticalOffset += STATS_PELS_PER_LINE;
3187+ drawtext(horizontalOffset, verticalOffset, 0.10f, 0, 1.0, 2, averageMegabitsPerSecond, .93f, .93f, .93f);
3188+ }
3189+
3190+ verticalOffset = 0;
3191+ horizontalOffset += 161;
31223192
31233193 if (Menu::getInstance()->isOptionChecked(MenuOption::TestPing)) {
31243194 int pingAudio = 0, pingAvatar = 0, pingVoxel = 0, pingVoxelMax = 0;
@@ -3130,7 +3200,6 @@ void Application::displayStats() { · 5 unmodified lines
31303200 pingAudio = audioMixerNode ? audioMixerNode->getPingMs() : 0;
31313201 pingAvatar = avatarMixerNode ? avatarMixerNode->getPingMs() : 0;
31323202
3133−
31343203 // Now handle voxel servers, since there could be more than one, we average their ping times
31353204 unsigned long totalPingVoxel = 0;
31363205 int voxelServerCount = 0;
@@ -3149,35 +3218,115 @@ void Application::displayStats() { · 12 unmodified lines
31493218 pingVoxel = totalPingVoxel/voxelServerCount;
31503219 }
31513220
3152− char pingStats[200];
3153− statsVerticalOffset += PELS_PER_LINE;
3154− sprintf(pingStats, "Ping audio/avatar/voxel: %d / %d / %d avg %d max ", pingAudio, pingAvatar, pingVoxel, pingVoxelMax);
3155− drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, pingStats);
3221+ lines = _statsExpanded ? 4 : 3;
3222+ displayStatsBackground(backgroundColor, horizontalOffset, 0, 175, lines * STATS_PELS_PER_LINE + 10);
3223+ horizontalOffset += 5;
3224+
3225+ char audioPing[30];
3226+ sprintf(audioPing, "Audio ping: %d", pingAudio);
3227+ char avatarPing[30];
3228+ sprintf(avatarPing, "Avatar ping: %d", pingAvatar);
3229+ char voxelAvgPing[30];
3230+ sprintf(voxelAvgPing, "Voxel avg ping: %d", pingVoxel);
3231+
3232+ verticalOffset += STATS_PELS_PER_LINE;
3233+ drawtext(horizontalOffset, verticalOffset, 0.10f, 0, 1.0, 2, audioPing, .93f, .93f, .93f);
3234+ verticalOffset += STATS_PELS_PER_LINE;
3235+ drawtext(horizontalOffset, verticalOffset, 0.10f, 0, 1.0, 2, avatarPing, .93f, .93f, .93f);
3236+ verticalOffset += STATS_PELS_PER_LINE;
3237+ drawtext(horizontalOffset, verticalOffset, 0.10f, 0, 1.0, 2, voxelAvgPing, .93f, .93f, .93f);
3238+
3239+ if (_statsExpanded) {
3240+ char voxelMaxPing[30];
3241+ sprintf(voxelMaxPing, "Voxel max ping: %d", pingVoxelMax);
3242+
3243+ verticalOffset += STATS_PELS_PER_LINE;
3244+ drawtext(horizontalOffset, verticalOffset, 0.10f, 0, 1.0, 2, voxelMaxPing, .93f, .93f, .93f);
3245+ }
3246+
3247+ verticalOffset = 0;
3248+ horizontalOffset += 171;
31563249 }
31573250
3158− char avatarStats[200];
3159− statsVerticalOffset += PELS_PER_LINE;
31603251 glm::vec3 avatarPos = _myAvatar.getPosition();
3161− sprintf(avatarStats, "Avatar: pos %.3f, %.3f, %.3f, vel %.1f, yaw = %.2f", avatarPos.x, avatarPos.y, avatarPos.z, glm::length(_myAvatar.getVelocity()), _myAvatar.getBodyYaw());
3162− drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, avatarStats);
31633252
3164− SharedNodePointer avatarMixer = NodeList::getInstance()->soloNodeOfType(NODE_TYPE_AVATAR_MIXER);
3165− char avatarMixerStats[200];
3166− if (avatarMixer) {
3167− sprintf(avatarMixerStats, "Avatar Mixer: %.f kbps, %.f pps",
3168− roundf(avatarMixer->getAverageKilobitsPerSecond()),
3169− roundf(avatarMixer->getAveragePacketsPerSecond()));
3253+ lines = _statsExpanded ? 4 : 3;
3254+ displayStatsBackground(backgroundColor, horizontalOffset, 0, _glWidget->width() - (mirrorEnabled ? 301 : 411) - horizontalOffset, lines * STATS_PELS_PER_LINE + 10);
3255+ horizontalOffset += 5;
3256+
3257+ char avatarPosition[200];
3258+ if (mirrorEnabled) {
3259+ // shorthand formatting
3260+ sprintf(avatarPosition, "Pos: %.0f,%.0f,%.0f", avatarPos.x, avatarPos.y, avatarPos.z);
31703261 } else {
3171− sprintf(avatarMixerStats, "No Avatar Mixer");
3262+ // longhand way
3263+ sprintf(avatarPosition, "Position: %.3f, %.3f, %.3f", avatarPos.x, avatarPos.y, avatarPos.z);
3264+ }
3265+ char avatarVelocity[30];
3266+ sprintf(avatarVelocity, "Velocity: %.1f", glm::length(_myAvatar.getVelocity()));
3267+ char avatarBodyYaw[30];
3268+ sprintf(avatarBodyYaw, "Yaw: %.2f", _myAvatar.getBodyYaw());
3269+ char avatarMixerStats[200];
3270+
3271+ verticalOffset += STATS_PELS_PER_LINE;
3272+ drawtext(horizontalOffset, verticalOffset, 0.10f, 0, 1.0, 2, avatarPosition, .93f, .93f, .93f);
3273+ verticalOffset += STATS_PELS_PER_LINE;
3274+ drawtext(horizontalOffset, verticalOffset, 0.10f, 0, 1.0, 2, avatarVelocity, .93f, .93f, .93f);
3275+ verticalOffset += STATS_PELS_PER_LINE;
3276+ drawtext(horizontalOffset, verticalOffset, 0.10f, 0, 1.0, 2, avatarBodyYaw, .93f, .93f, .93f);
3277+
3278+ if (_statsExpanded) {
3279+ SharedNodePointer avatarMixer = NodeList::getInstance()->soloNodeOfType(NODE_TYPE_AVATAR_MIXER);
3280+ if (avatarMixer) {
3281+ sprintf(avatarMixerStats, "Avatar Mixer: %.f kbps, %.f pps",
3282+ roundf(avatarMixer->getAverageKilobitsPerSecond()),
3283+ roundf(avatarMixer->getAveragePacketsPerSecond()));
3284+ } else {
3285+ sprintf(avatarMixerStats, "No Avatar Mixer");
3286+ }
3287+
3288+ verticalOffset += STATS_PELS_PER_LINE;
3289+ drawtext(horizontalOffset, verticalOffset, 0.10f, 0, 1.0, 2, avatarMixerStats, .93f, .93f, .93f);
31723290 }
3173− statsVerticalOffset += PELS_PER_LINE;
3174− drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, avatarMixerStats);
31753291
3292+ verticalOffset = 0;
3293+ horizontalOffset = _glWidget->width() - (mirrorEnabled ? 300 : 410);
3294+
3295+ lines = _statsExpanded ? 11 : 3;
3296+ displayStatsBackground(backgroundColor, horizontalOffset, 0, _glWidget->width() - horizontalOffset, lines * STATS_PELS_PER_LINE + 10);
3297+ horizontalOffset += 5;
3298+
3299+ if (_statsExpanded) {
3300+ // Local Voxel Memory Usage
3301+ voxelStats.str("");
3302+ voxelStats << "Voxels Memory Nodes: " << VoxelTreeElement::getTotalMemoryUsage() / 1000000.f << "MB";
3303+ verticalOffset += STATS_PELS_PER_LINE;
3304+ drawtext(horizontalOffset, verticalOffset, 0.10f, 0, 1.0, 2, (char*)voxelStats.str().c_str(), .93f, .93f, .93f);
3305+
3306+ voxelStats.str("");
3307+ voxelStats <<
3308+ "Geometry RAM: " << _voxels.getVoxelMemoryUsageRAM() / 1000000.f << "MB / " <<
3309+ "VBO: " << _voxels.getVoxelMemoryUsageVBO() / 1000000.f << "MB";
3310+ if (_voxels.hasVoxelMemoryUsageGPU()) {
3311+ voxelStats << " / GPU: " << _voxels.getVoxelMemoryUsageGPU() / 1000000.f << "MB";
3312+ }
3313+ verticalOffset += STATS_PELS_PER_LINE;
3314+ drawtext(horizontalOffset, verticalOffset, 0.10f, 0, 1.0, 2, (char*)voxelStats.str().c_str(), .93f, .93f, .93f);
3315+
3316+ // Voxel Rendering
3317+ voxelStats.str("");
3318+ voxelStats.precision(4);
3319+ voxelStats << "Voxel Rendering Slots Max: " << _voxels.getMaxVoxels() / 1000.f << "K";
3320+ verticalOffset += STATS_PELS_PER_LINE;
3321+ drawtext(horizontalOffset, verticalOffset, 0.10f, 0, 1.0, 2, (char*)voxelStats.str().c_str(), .93f, .93f, .93f);
3322+ }
31763323
3177− // Used for formatting voxel stats details
3178− statsVerticalOffset += PELS_PER_LINE; // skip a line for voxels
3179− QLocale locale(QLocale::English);
3180− std::stringstream voxelStats;
3324+ voxelStats.str("");
3325+ voxelStats.precision(4);
3326+ voxelStats << "Drawn: " << _voxels.getVoxelsWritten() / 1000.f << "K " <<
3327+ "Abandoned: " << _voxels.getAbandonedVoxels() / 1000.f << "K ";
3328+ verticalOffset += STATS_PELS_PER_LINE;
3329+ drawtext(horizontalOffset, verticalOffset, 0.10f, 0, 1.0, 2, (char*)voxelStats.str().c_str(), .93f, .93f, .93f);
31813330
31823331 // iterate all the current voxel stats, and list their sending modes, and total voxel counts
31833332 std::stringstream sendingMode("");
@@ -3191,107 +3340,165 @@ void Application::displayStats() { · 7 unmodified lines
31913340 //const QUuid& uuid = i->first;
31923341 VoxelSceneStats& stats = i->second;
31933342 serverCount++;
3194− if (serverCount > 1) {
3195− sendingMode << ",";
3196− }
3197− if (stats.isMoving()) {
3198− sendingMode << "M";
3199− movingServerCount++;
3200− } else {
3201− sendingMode << "S";
3343+ if (_statsExpanded) {
3344+ if (serverCount > 1) {
3345+ sendingMode << ",";
3346+ }
3347+ if (stats.isMoving()) {
3348+ sendingMode << "M";
3349+ movingServerCount++;
3350+ } else {
3351+ sendingMode << "S";
3352+ }
32023353 }
32033354
32043355 // calculate server node totals
32053356 totalNodes += stats.getTotalElements();
3206− totalInternal += stats.getTotalInternal();
3207− totalLeaves += stats.getTotalLeaves();
3357+ if (_statsExpanded) {
3358+ totalInternal += stats.getTotalInternal();
3359+ totalLeaves += stats.getTotalLeaves();
3360+ }
3361+ }
3362+ if (_statsExpanded) {
3363+ if (serverCount == 0) {
3364+ sendingMode << "---";
3365+ }
3366+ sendingMode << "] " << serverCount << " servers";
3367+ if (movingServerCount > 0) {
3368+ sendingMode << " <SCENE NOT STABLE>";
3369+ } else {
3370+ sendingMode << " <SCENE STABLE>";
3371+ }
3372+ verticalOffset += STATS_PELS_PER_LINE;
3373+ drawtext(horizontalOffset, verticalOffset, 0.10f, 0, 1.0, 2, (char*)sendingMode.str().c_str(), .93f, .93f, .93f);
32083374 }
3209− if (serverCount == 0) {
3210− sendingMode << "---";
3375+
3376+ // Incoming packets
3377+ int voxelPacketsToProcess = _voxelProcessor.packetsToProcessCount();
3378+ if (_statsExpanded) {
3379+ voxelStats.str("");
3380+ QString packetsString = locale.toString((int)voxelPacketsToProcess);
3381+ QString maxString = locale.toString((int)_recentMaxPackets);
3382+ voxelStats << "Voxel Packets to Process: " << packetsString.toLocal8Bit().constData()
3383+ << " [Recent Max: " << maxString.toLocal8Bit().constData() << "]";
3384+ verticalOffset += STATS_PELS_PER_LINE;
3385+ drawtext(horizontalOffset, verticalOffset, 0.10f, 0, 1.0, 2, (char*)voxelStats.str().c_str(), .93f, .93f, .93f);
32113386 }
3212− sendingMode << "] " << serverCount << " servers";
3213− if (movingServerCount > 0) {
3214− sendingMode << " <SCENE NOT STABLE>";
3387+
3388+ if (_resetRecentMaxPacketsSoon && voxelPacketsToProcess > 0) {
3389+ _recentMaxPackets = 0;
3390+ _resetRecentMaxPacketsSoon = false;
3391+ }
3392+ if (voxelPacketsToProcess == 0) {
3393+ _resetRecentMaxPacketsSoon = true;
32153394 } else {
3216− sendingMode << " <SCENE STABLE>";
3395+ if (voxelPacketsToProcess > _recentMaxPackets) {
3396+ _recentMaxPackets = voxelPacketsToProcess;
3397+ }
32173398 }
32183399
3400+ verticalOffset += (_statsExpanded ? STATS_PELS_PER_LINE : 0);
3401+
32193402 QString serversTotalString = locale.toString((uint)totalNodes); // consider adding: .rightJustified(10, ' ');
3220− QString serversInternalString = locale.toString((uint)totalInternal);
3221− QString serversLeavesString = locale.toString((uint)totalLeaves);
32223403
32233404 // Server Voxels
32243405 voxelStats.str("");
3225− voxelStats <<
3226− "Server Voxels Total: " << serversTotalString.toLocal8Bit().constData() << " / " <<
3227− "Internal: " << serversInternalString.toLocal8Bit().constData() << " / " <<
3228− "Leaves: " << serversLeavesString.toLocal8Bit().constData() << "";
3229− statsVerticalOffset += PELS_PER_LINE;
3230− drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, (char*)voxelStats.str().c_str());
3406+ voxelStats << "Server voxels: " << serversTotalString.toLocal8Bit().constData();
3407+ verticalOffset += STATS_PELS_PER_LINE;
3408+ drawtext(horizontalOffset, verticalOffset, 0.10f, 0, 1.0, 2, (char*)voxelStats.str().c_str(), .93f, .93f, .93f);
3409+
3410+ if (_statsExpanded) {
3411+ QString serversInternalString = locale.toString((uint)totalInternal);
3412+ QString serversLeavesString = locale.toString((uint)totalLeaves);
3413+
3414+ voxelStats.str("");
3415+ voxelStats <<
3416+ "Internal: " << serversInternalString.toLocal8Bit().constData() << " " <<
3417+ "Leaves: " << serversLeavesString.toLocal8Bit().constData() << "";
3418+ verticalOffset += STATS_PELS_PER_LINE;
3419+ drawtext(horizontalOffset, verticalOffset, 0.10f, 0, 1.0, 2, (char*)voxelStats.str().c_str(), .93f, .93f, .93f);
3420+ }
32313421
32323422 unsigned long localTotal = VoxelTreeElement::getNodeCount();
3233− unsigned long localInternal = VoxelTreeElement::getInternalNodeCount();
3234− unsigned long localLeaves = VoxelTreeElement::getLeafNodeCount();
32353423 QString localTotalString = locale.toString((uint)localTotal); // consider adding: .rightJustified(10, ' ');
3236− QString localInternalString = locale.toString((uint)localInternal);
3237− QString localLeavesString = locale.toString((uint)localLeaves);
32383424
32393425 // Local Voxels
32403426 voxelStats.str("");
3241− voxelStats <<
3242− "Local Voxels Total: " << localTotalString.toLocal8Bit().constData() << " / " <<
3243− "Internal: " << localInternalString.toLocal8Bit().constData() << " / " <<
3244− "Leaves: " << localLeavesString.toLocal8Bit().constData() << "";
3245− statsVerticalOffset += PELS_PER_LINE;
3246− drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, (char*)voxelStats.str().c_str());
3247−
3248− // Local Voxel Memory Usage
3249− voxelStats.str("");
3250− voxelStats <<
3251− "Voxels Memory Nodes: " << VoxelTreeElement::getTotalMemoryUsage() / 1000000.f << "MB "
3252− "Geometry RAM: " << _voxels.getVoxelMemoryUsageRAM() / 1000000.f << "MB " <<
3253− "VBO: " << _voxels.getVoxelMemoryUsageVBO() / 1000000.f << "MB ";
3254− if (_voxels.hasVoxelMemoryUsageGPU()) {
3255− voxelStats << "GPU: " << _voxels.getVoxelMemoryUsageGPU() / 1000000.f << "MB ";
3427+ voxelStats << "Local voxels: " << localTotalString.toLocal8Bit().constData();
3428+ verticalOffset += STATS_PELS_PER_LINE;
3429+ drawtext(horizontalOffset, verticalOffset, 0.10f, 0, 1.0, 2, (char*)voxelStats.str().c_str(), .93f, .93f, .93f);
3430+
3431+ if (_statsExpanded) {
3432+ unsigned long localInternal = VoxelTreeElement::getInternalNodeCount();
3433+ unsigned long localLeaves = VoxelTreeElement::getLeafNodeCount();
3434+ QString localInternalString = locale.toString((uint)localInternal);
3435+ QString localLeavesString = locale.toString((uint)localLeaves);
3436+
3437+ voxelStats.str("");
3438+ voxelStats <<
3439+ "Internal: " << localInternalString.toLocal8Bit().constData() << " " <<
3440+ "Leaves: " << localLeavesString.toLocal8Bit().constData() << "";
3441+ verticalOffset += STATS_PELS_PER_LINE;
3442+ drawtext(horizontalOffset, verticalOffset, 0.10f, 0, 1.0, 2, (char*)voxelStats.str().c_str(), .93f, .93f, .93f);
32563443 }
3257− statsVerticalOffset += PELS_PER_LINE;
3258− drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, (char*)voxelStats.str().c_str());
3444+}
32593445
3260− // Voxel Rendering
3261− voxelStats.str("");
3262− voxelStats.precision(4);
3263− voxelStats << "Voxel Rendering Slots " <<
3264− "Max: " << _voxels.getMaxVoxels() / 1000.f << "K " <<
3265− "Drawn: " << _voxels.getVoxelsWritten() / 1000.f << "K " <<
3266− "Abandoned: " << _voxels.getAbandonedVoxels() / 1000.f << "K ";
3267− statsVerticalOffset += PELS_PER_LINE;
3268− drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, (char*)voxelStats.str().c_str());
3446+// called on mouse click release
3447+// check for clicks over stats in order to expand or contract them
3448+void Application::checkStatsClick() {
3449+ if (0 != glm::compMax(glm::abs(glm::ivec2(_mouseX - _mouseDragStartedX, _mouseY - _mouseDragStartedY)))) {
3450+ // not worried about dragging on stats
3451+ return;
3452+ }
32693453
3270− // draw Sending mode AFTER server node stats
3271− statsVerticalOffset += PELS_PER_LINE;
3272− drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, (char*)sendingMode.str().c_str());
3454+ int statsHeight = 0, statsWidth = 0, statsX = 0, statsY = 0, lines = 0;
32733455
3274− // Incoming packets
3275− voxelStats.str("");
3276− int voxelPacketsToProcess = _voxelProcessor.packetsToProcessCount();
3277− QString packetsString = locale.toString((int)voxelPacketsToProcess);
3278− QString maxString = locale.toString((int)_recentMaxPackets);
3279− voxelStats << "Voxel Packets to Process: " << packetsString.toLocal8Bit().constData()
3280− << " [Recent Max: " << maxString.toLocal8Bit().constData() << "]";
3456+ if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) {
3457+ statsX += MIRROR_VIEW_WIDTH;
3458+ }
32813459
3282− if (_resetRecentMaxPacketsSoon && voxelPacketsToProcess > 0) {
3283− _recentMaxPackets = 0;
3284− _resetRecentMaxPacketsSoon = false;
3460+ // top-left stats click
3461+ lines = _statsExpanded ? 5 : 3;
3462+ statsHeight = lines * STATS_PELS_PER_LINE + 10;
3463+ statsWidth = 165;
3464+ if (_mouseX > statsX && _mouseX < statsX + statsWidth && _mouseY > statsY && _mouseY < statsY + statsHeight) {
3465+ toggleStatsExpanded();
3466+ return;
32853467 }
3286− if (voxelPacketsToProcess == 0) {
3287− _resetRecentMaxPacketsSoon = true;
3288− } else {
3289− if (voxelPacketsToProcess > _recentMaxPackets) {
3290− _recentMaxPackets = voxelPacketsToProcess;
3291− }
3468+
3469+ // ping stats click
3470+ lines = _statsExpanded ? 4 : 3;
3471+ statsX += statsWidth;
3472+ statsHeight = lines * STATS_PELS_PER_LINE + 10;
3473+ statsWidth = 175;
3474+ if (_mouseX > statsX && _mouseX < statsX + statsWidth && _mouseY > statsY && _mouseY < statsY + statsHeight) {
3475+ toggleStatsExpanded();
3476+ return;
3477+ }
3478+
3479+ // top-center stats panel click
3480+ lines = _statsExpanded ? 4 : 3;
3481+ statsX += statsWidth;
3482+ statsHeight = lines * STATS_PELS_PER_LINE + 10;
3483+ statsWidth = _glWidget->width() - 411 - statsX;
3484+ if (_mouseX > statsX && _mouseX < statsX + statsWidth && _mouseY > statsY && _mouseY < statsY + statsHeight) {
3485+ toggleStatsExpanded();
3486+ return;
3487+ }
3488+
3489+ // top-right stats click
3490+ lines = _statsExpanded ? 11 : 3;
3491+ statsX = _glWidget->width() - 410;
3492+ statsHeight = lines * STATS_PELS_PER_LINE + 10;
3493+ statsWidth = _glWidget->width() - statsX;
3494+ if (_mouseX > statsX && _mouseX < statsX + statsWidth && _mouseY > statsY && _mouseY < statsY + statsHeight) {
3495+ toggleStatsExpanded();
3496+ return;
32923497 }
3293− statsVerticalOffset += PELS_PER_LINE;
3294− drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, (char*)voxelStats.str().c_str());
3498+}
3499+
3500+void Application::toggleStatsExpanded() {
3501+ _statsExpanded = !_statsExpanded;
32953502 }
32963503
32973504 void Application::renderThrustAtVoxel(const glm::vec3& thrust) {
@@ -4123,3 +4330,14 @@ void Application::skipVersion(QString latestVersion) { · 825 unmodified lines
41234330 skipFile.seek(0);
41244331 skipFile.write(latestVersion.toStdString().c_str());
41254332 }
4333+
4334+void Application::takeSnapshot() {
4335+ switchToResourcesParentIfRequired();
4336+ QMediaPlayer* player = new QMediaPlayer();
4337+ QFileInfo inf = QFileInfo("resources/sounds/snap.wav");
4338+ player->setMedia(QUrl::fromLocalFile(inf.absoluteFilePath()));
4339+ player->play();
4340+
4341+ Snapshot::saveSnapshot(_glWidget, _profile.getUsername(), _myAvatar.getPosition());
4342+}
4343+

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