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
47#include <QDesktopServices>47#include <QDesktopServices>
48#include <QXmlStreamReader>48#include <QXmlStreamReader>
49#include <QXmlStreamAttributes>49#include <QXmlStreamAttributes>
50#include <QMediaPlayer>
50 51
51#include <AudioInjector.h>52#include <AudioInjector.h>
52#include <Logging.h>53#include <Logging.h>
@@ -69,6 +70,7 @@ · 16 unmodified lines
69#include "renderer/ProgramObject.h"70#include "renderer/ProgramObject.h"
70#include "ui/TextRenderer.h"71#include "ui/TextRenderer.h"
71#include "InfoView.h"72#include "InfoView.h"
73#include "ui/Snapshot.h"
72 74
73using namespace std;75using namespace std;
74 76
@@ -97,6 +99,8 @@ const float MIRROR_REARVIEW_BODY_DISTANCE = 2.3f; · 22 unmodified lines
97const QString CHECK_VERSION_URL = "http://highfidelity.io/latestVersion.xml";99const QString CHECK_VERSION_URL = "http://highfidelity.io/latestVersion.xml";
98const QString SKIP_FILENAME = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/hifi.skipversion";100const QString SKIP_FILENAME = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/hifi.skipversion";
99 101
102const int STATS_PELS_PER_LINE = 20;
103
100void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString &message) {104void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString &message) {
101 QString messageWithNewLine = message + "\n";105 QString messageWithNewLine = message + "\n";
102 fprintf(stdout, "%s", messageWithNewLine.toLocal8Bit().constData());106 fprintf(stdout, "%s", messageWithNewLine.toLocal8Bit().constData());
@@ -107,6 +111,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 4 unmodified lines
107 QApplication(argc, argv),111 QApplication(argc, argv),
108 _window(new QMainWindow(desktop())),112 _window(new QMainWindow(desktop())),
109 _glWidget(new GLCanvas()),113 _glWidget(new GLCanvas()),
114 _statsExpanded(false),
110 _nodeThread(new QThread(this)),115 _nodeThread(new QThread(this)),
111 _datagramProcessor(),116 _datagramProcessor(),
112 _frameCount(0),117 _frameCount(0),
@@ -249,6 +254,10 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 136 unmodified lines
249 254
250 restoreSizeAndPosition();255 restoreSizeAndPosition();
251 loadScripts();256 loadScripts();
257
258 QFontDatabase fontDatabase;
259 fontDatabase.addApplicationFont("resources/styles/Inconsolata.otf");
260
252 _window->setVisible(true);261 _window->setVisible(true);
253 _glWidget->setFocusPolicy(Qt::StrongFocus);262 _glWidget->setFocusPolicy(Qt::StrongFocus);
254 _glWidget->setFocus();263 _glWidget->setFocus();
@@ -764,6 +773,8 @@ void Application::keyPressEvent(QKeyEvent* event) { · 509 unmodified lines
764 _voxels.collectStatsForTreesAndVBOs();773 _voxels.collectStatsForTreesAndVBOs();
765 } else if (isShifted && isMeta) {774 } else if (isShifted && isMeta) {
766 Menu::getInstance()->triggerOption(MenuOption::SuppressShortTimings);775 Menu::getInstance()->triggerOption(MenuOption::SuppressShortTimings);
776 } else if (!isShifted && isMeta) {
777 takeSnapshot();
767 } else if (_nudgeStarted) {778 } else if (_nudgeStarted) {
768 if (_lookingAlongX) {779 if (_lookingAlongX) {
769 if (_lookingAwayFromOrigin) {780 if (_lookingAwayFromOrigin) {
@@ -1258,6 +1269,9 @@ void Application::mouseReleaseEvent(QMouseEvent* event) { · 488 unmodified lines
1258 _mouseY = event->y();1269 _mouseY = event->y();
1259 _mousePressed = false;1270 _mousePressed = false;
1260 checkBandwidthMeterClick();1271 checkBandwidthMeterClick();
1272 if (Menu::getInstance()->isOptionChecked(MenuOption::Stats)) {
1273 checkStatsClick();
1274 }
1261 1275
1262 _pieMenu.mouseReleaseEvent(_mouseX, _mouseY);1276 _pieMenu.mouseReleaseEvent(_mouseX, _mouseY);
1263 }1277 }
@@ -1718,7 +1732,7 @@ void Application::init() { · 454 unmodified lines
1718 _sharedVoxelSystem.changeTree(&_clipboard);1732 _sharedVoxelSystem.changeTree(&_clipboard);
1719 delete tmpTree;1733 delete tmpTree;
1720 1734
1721 _voxelImporter.init();1735 _voxelImporter.init(_settings);
1722 1736
1723 _environment.init();1737 _environment.init();
1724 1738
@@ -2962,9 +2976,11 @@ void Application::displayOverlay() { · 1237 unmodified lines
2962 }2976 }
2963 2977
2964 if (Menu::getInstance()->isOptionChecked(MenuOption::Stats)) {2978 if (Menu::getInstance()->isOptionChecked(MenuOption::Stats)) {
2979 displayStatsBackground(0x33333399, 0, _glWidget->height() - 68, 296, 68);
2965 _audio.render(_glWidget->width(), _glWidget->height());2980 _audio.render(_glWidget->width(), _glWidget->height());
2966 if (Menu::getInstance()->isOptionChecked(MenuOption::Oscilloscope)) {2981 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);
2968 }2984 }
2969 }2985 }
2970 2986
@@ -3019,17 +3035,9 @@ void Application::displayOverlay() { · 48 unmodified lines
3019 displayStats();3035 displayStats();
3020 // Bandwidth meter3036 // Bandwidth meter
3021 if (Menu::getInstance()->isOptionChecked(MenuOption::Bandwidth)) {3037 if (Menu::getInstance()->isOptionChecked(MenuOption::Bandwidth)) {
3038 displayStatsBackground(0x33333399, _glWidget->width() - 296, _glWidget->height() - 68, 296, 68);
3022 _bandwidthMeter.render(_glWidget->width(), _glWidget->height());3039 _bandwidthMeter.render(_glWidget->width(), _glWidget->height());
3023 }3040 }
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);
3033 }3041 }
3034 3042
3035 // testing rendering coverage map3043 // testing rendering coverage map
@@ -3051,8 +3059,12 @@ void Application::displayOverlay() { · 15 unmodified lines
3051 char frameTimer[10];3059 char frameTimer[10];
3052 uint64_t mSecsNow = floor(usecTimestampNow() / 1000.0 + 0.5);3060 uint64_t mSecsNow = floor(usecTimestampNow() / 1000.0 + 0.5);
3053 sprintf(frameTimer, "%d\n", (int)(mSecsNow % 1000));3061 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);3062 int timerBottom =
3055 drawtext(_glWidget->width() - 102, _glWidget->height() - 22, 0.30f, 0, 1.0f, 0, frameTimer, 1, 1, 1);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);
3056 }3068 }
3057 3069
3058 _palette.render(_glWidget->width(), _glWidget->height());3070 _palette.render(_glWidget->width(), _glWidget->height());
@@ -3110,15 +3122,73 @@ void Application::displayOverlay() { · 51 unmodified lines
3110 glPopMatrix();3122 glPopMatrix();
3111}3123}
3112 3124
3125// translucent background box that makes stats more readable
3126void 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}
3113 3139
3140// display expanded or contracted stats
3114void Application::displayStats() {3141void Application::displayStats() {
3115 int statsVerticalOffset = 8;3142 unsigned int backgroundColor = 0x33333399;
3116 const int PELS_PER_LINE = 15;3143 int verticalOffset = 0, horizontalOffset = 0, lines = 0;
3117 char stats[200];3144 bool mirrorEnabled = Menu::getInstance()->isOptionChecked(MenuOption::Mirror);
3118 statsVerticalOffset += PELS_PER_LINE;3145
3119 sprintf(stats, "%3.0f FPS, %d Pkts/sec, %3.2f Mbps ",3146 QLocale locale(QLocale::English);
3120 _fps, _packetsPerSecond, (float)_bytesPerSecond * 8.f / 1000000.f);3147 std::stringstream voxelStats;
3121 drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, stats);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;
3122 3192
3123 if (Menu::getInstance()->isOptionChecked(MenuOption::TestPing)) {3193 if (Menu::getInstance()->isOptionChecked(MenuOption::TestPing)) {
3124 int pingAudio = 0, pingAvatar = 0, pingVoxel = 0, pingVoxelMax = 0;3194 int pingAudio = 0, pingAvatar = 0, pingVoxel = 0, pingVoxelMax = 0;
@@ -3130,7 +3200,6 @@ void Application::displayStats() { · 5 unmodified lines
3130 pingAudio = audioMixerNode ? audioMixerNode->getPingMs() : 0;3200 pingAudio = audioMixerNode ? audioMixerNode->getPingMs() : 0;
3131 pingAvatar = avatarMixerNode ? avatarMixerNode->getPingMs() : 0;3201 pingAvatar = avatarMixerNode ? avatarMixerNode->getPingMs() : 0;
3132 3202
3133
3134 // Now handle voxel servers, since there could be more than one, we average their ping times3203 // Now handle voxel servers, since there could be more than one, we average their ping times
3135 unsigned long totalPingVoxel = 0;3204 unsigned long totalPingVoxel = 0;
3136 int voxelServerCount = 0;3205 int voxelServerCount = 0;
@@ -3149,35 +3218,115 @@ void Application::displayStats() { · 12 unmodified lines
3149 pingVoxel = totalPingVoxel/voxelServerCount;3218 pingVoxel = totalPingVoxel/voxelServerCount;
3150 }3219 }
3151 3220
3152 char pingStats[200];3221 lines = _statsExpanded ? 4 : 3;
3153 statsVerticalOffset += PELS_PER_LINE;3222 displayStatsBackground(backgroundColor, horizontalOffset, 0, 175, lines * STATS_PELS_PER_LINE + 10);
3154 sprintf(pingStats, "Ping audio/avatar/voxel: %d / %d / %d avg %d max ", pingAudio, pingAvatar, pingVoxel, pingVoxelMax);3223 horizontalOffset += 5;
3155 drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, pingStats);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;
3156 }3249 }
3157 3250
3158 char avatarStats[200];
3159 statsVerticalOffset += PELS_PER_LINE;
3160 glm::vec3 avatarPos = _myAvatar.getPosition();3251 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);
3163 3252
3164 SharedNodePointer avatarMixer = NodeList::getInstance()->soloNodeOfType(NODE_TYPE_AVATAR_MIXER);3253 lines = _statsExpanded ? 4 : 3;
3165 char avatarMixerStats[200];3254 displayStatsBackground(backgroundColor, horizontalOffset, 0, _glWidget->width() - (mirrorEnabled ? 301 : 411) - horizontalOffset, lines * STATS_PELS_PER_LINE + 10);
3166 if (avatarMixer) {3255 horizontalOffset += 5;
3167 sprintf(avatarMixerStats, "Avatar Mixer: %.f kbps, %.f pps",3256
3168 roundf(avatarMixer->getAverageKilobitsPerSecond()),3257 char avatarPosition[200];
3169 roundf(avatarMixer->getAveragePacketsPerSecond()));3258 if (mirrorEnabled) {
3259 // shorthand formatting
3260 sprintf(avatarPosition, "Pos: %.0f,%.0f,%.0f", avatarPos.x, avatarPos.y, avatarPos.z);
3170 } else {3261 } 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);
3172 }3290 }
3173 statsVerticalOffset += PELS_PER_LINE;
3174 drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, avatarMixerStats);
3175 3291
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 }
3176 3323
3177 // Used for formatting voxel stats details3324 voxelStats.str("");
3178 statsVerticalOffset += PELS_PER_LINE; // skip a line for voxels3325 voxelStats.precision(4);
3179 QLocale locale(QLocale::English);3326 voxelStats << "Drawn: " << _voxels.getVoxelsWritten() / 1000.f << "K " <<
3180 std::stringstream voxelStats;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);
3181 3330
3182 // iterate all the current voxel stats, and list their sending modes, and total voxel counts3331 // iterate all the current voxel stats, and list their sending modes, and total voxel counts
3183 std::stringstream sendingMode("");3332 std::stringstream sendingMode("");
@@ -3191,107 +3340,165 @@ void Application::displayStats() { · 7 unmodified lines
3191 //const QUuid& uuid = i->first;3340 //const QUuid& uuid = i->first;
3192 VoxelSceneStats& stats = i->second;3341 VoxelSceneStats& stats = i->second;
3193 serverCount++;3342 serverCount++;
3194 if (serverCount > 1) {3343 if (_statsExpanded) {
3195 sendingMode << ",";3344 if (serverCount > 1) {
3196 }3345 sendingMode << ",";
3197 if (stats.isMoving()) {3346 }
3198 sendingMode << "M";3347 if (stats.isMoving()) {
3199 movingServerCount++;3348 sendingMode << "M";
3200 } else {3349 movingServerCount++;
3201 sendingMode << "S";3350 } else {
3351 sendingMode << "S";
3352 }
3202 }3353 }
3203 3354
3204 // calculate server node totals3355 // calculate server node totals
3205 totalNodes += stats.getTotalElements();3356 totalNodes += stats.getTotalElements();
3206 totalInternal += stats.getTotalInternal();3357 if (_statsExpanded) {
3207 totalLeaves += stats.getTotalLeaves();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);
3208 }3374 }
3209 if (serverCount == 0) {3375
3210 sendingMode << "---";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);
3211 }3386 }
3212 sendingMode << "] " << serverCount << " servers";3387
3213 if (movingServerCount > 0) {3388 if (_resetRecentMaxPacketsSoon && voxelPacketsToProcess > 0) {
3214 sendingMode << " <SCENE NOT STABLE>";3389 _recentMaxPackets = 0;
3390 _resetRecentMaxPacketsSoon = false;
3391 }
3392 if (voxelPacketsToProcess == 0) {
3393 _resetRecentMaxPacketsSoon = true;
3215 } else {3394 } else {
3216 sendingMode << " <SCENE STABLE>";3395 if (voxelPacketsToProcess > _recentMaxPackets) {
3396 _recentMaxPackets = voxelPacketsToProcess;
3397 }
3217 }3398 }
3218 3399
3400 verticalOffset += (_statsExpanded ? STATS_PELS_PER_LINE : 0);
3401
3219 QString serversTotalString = locale.toString((uint)totalNodes); // consider adding: .rightJustified(10, ' ');3402 QString serversTotalString = locale.toString((uint)totalNodes); // consider adding: .rightJustified(10, ' ');
3220 QString serversInternalString = locale.toString((uint)totalInternal);
3221 QString serversLeavesString = locale.toString((uint)totalLeaves);
3222 3403
3223 // Server Voxels3404 // Server Voxels
3224 voxelStats.str("");3405 voxelStats.str("");
3225 voxelStats <<3406 voxelStats << "Server voxels: " << serversTotalString.toLocal8Bit().constData();
3226 "Server Voxels Total: " << serversTotalString.toLocal8Bit().constData() << " / " <<3407 verticalOffset += STATS_PELS_PER_LINE;
3227 "Internal: " << serversInternalString.toLocal8Bit().constData() << " / " <<3408 drawtext(horizontalOffset, verticalOffset, 0.10f, 0, 1.0, 2, (char*)voxelStats.str().c_str(), .93f, .93f, .93f);
3228 "Leaves: " << serversLeavesString.toLocal8Bit().constData() << "";3409
3229 statsVerticalOffset += PELS_PER_LINE;3410 if (_statsExpanded) {
3230 drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, (char*)voxelStats.str().c_str());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 }
3231 3421
3232 unsigned long localTotal = VoxelTreeElement::getNodeCount();3422 unsigned long localTotal = VoxelTreeElement::getNodeCount();
3233 unsigned long localInternal = VoxelTreeElement::getInternalNodeCount();
3234 unsigned long localLeaves = VoxelTreeElement::getLeafNodeCount();
3235 QString localTotalString = locale.toString((uint)localTotal); // consider adding: .rightJustified(10, ' ');3423 QString localTotalString = locale.toString((uint)localTotal); // consider adding: .rightJustified(10, ' ');
3236 QString localInternalString = locale.toString((uint)localInternal);
3237 QString localLeavesString = locale.toString((uint)localLeaves);
3238 3424
3239 // Local Voxels3425 // Local Voxels
3240 voxelStats.str("");3426 voxelStats.str("");
3241 voxelStats <<3427 voxelStats << "Local voxels: " << localTotalString.toLocal8Bit().constData();
3242 "Local Voxels Total: " << localTotalString.toLocal8Bit().constData() << " / " <<3428 verticalOffset += STATS_PELS_PER_LINE;
3243 "Internal: " << localInternalString.toLocal8Bit().constData() << " / " <<3429 drawtext(horizontalOffset, verticalOffset, 0.10f, 0, 1.0, 2, (char*)voxelStats.str().c_str(), .93f, .93f, .93f);
3244 "Leaves: " << localLeavesString.toLocal8Bit().constData() << "";3430
3245 statsVerticalOffset += PELS_PER_LINE;3431 if (_statsExpanded) {
3246 drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, (char*)voxelStats.str().c_str());3432 unsigned long localInternal = VoxelTreeElement::getInternalNodeCount();
3247 3433 unsigned long localLeaves = VoxelTreeElement::getLeafNodeCount();
3248 // Local Voxel Memory Usage3434 QString localInternalString = locale.toString((uint)localInternal);
3249 voxelStats.str("");3435 QString localLeavesString = locale.toString((uint)localLeaves);
3250 voxelStats <<3436
3251 "Voxels Memory Nodes: " << VoxelTreeElement::getTotalMemoryUsage() / 1000000.f << "MB "3437 voxelStats.str("");
3252 "Geometry RAM: " << _voxels.getVoxelMemoryUsageRAM() / 1000000.f << "MB " <<3438 voxelStats <<
3253 "VBO: " << _voxels.getVoxelMemoryUsageVBO() / 1000000.f << "MB ";3439 "Internal: " << localInternalString.toLocal8Bit().constData() << " " <<
3254 if (_voxels.hasVoxelMemoryUsageGPU()) {3440 "Leaves: " << localLeavesString.toLocal8Bit().constData() << "";
3255 voxelStats << "GPU: " << _voxels.getVoxelMemoryUsageGPU() / 1000000.f << "MB ";3441 verticalOffset += STATS_PELS_PER_LINE;
3442 drawtext(horizontalOffset, verticalOffset, 0.10f, 0, 1.0, 2, (char*)voxelStats.str().c_str(), .93f, .93f, .93f);
3256 }3443 }
3257 statsVerticalOffset += PELS_PER_LINE;3444}
3258 drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, (char*)voxelStats.str().c_str());
3259 3445
3260 // Voxel Rendering3446// called on mouse click release
3261 voxelStats.str("");3447// check for clicks over stats in order to expand or contract them
3262 voxelStats.precision(4);3448void Application::checkStatsClick() {
3263 voxelStats << "Voxel Rendering Slots " <<3449 if (0 != glm::compMax(glm::abs(glm::ivec2(_mouseX - _mouseDragStartedX, _mouseY - _mouseDragStartedY)))) {
3264 "Max: " << _voxels.getMaxVoxels() / 1000.f << "K " <<3450 // not worried about dragging on stats
3265 "Drawn: " << _voxels.getVoxelsWritten() / 1000.f << "K " <<3451 return;
3266 "Abandoned: " << _voxels.getAbandonedVoxels() / 1000.f << "K ";3452 }
3267 statsVerticalOffset += PELS_PER_LINE;
3268 drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, (char*)voxelStats.str().c_str());
3269 3453
3270 // draw Sending mode AFTER server node stats3454 int statsHeight = 0, statsWidth = 0, statsX = 0, statsY = 0, lines = 0;
3271 statsVerticalOffset += PELS_PER_LINE;
3272 drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, (char*)sendingMode.str().c_str());
3273 3455
3274 // Incoming packets3456 if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) {
3275 voxelStats.str("");3457 statsX += MIRROR_VIEW_WIDTH;
3276 int voxelPacketsToProcess = _voxelProcessor.packetsToProcessCount();3458 }
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() << "]";
3281 3459
3282 if (_resetRecentMaxPacketsSoon && voxelPacketsToProcess > 0) {3460 // top-left stats click
3283 _recentMaxPackets = 0;3461 lines = _statsExpanded ? 5 : 3;
3284 _resetRecentMaxPacketsSoon = false;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;
3285 }3467 }
3286 if (voxelPacketsToProcess == 0) {3468
3287 _resetRecentMaxPacketsSoon = true;3469 // ping stats click
3288 } else {3470 lines = _statsExpanded ? 4 : 3;
3289 if (voxelPacketsToProcess > _recentMaxPackets) {3471 statsX += statsWidth;
3290 _recentMaxPackets = voxelPacketsToProcess;3472 statsHeight = lines * STATS_PELS_PER_LINE + 10;
3291 }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;
3292 }3497 }
3293 statsVerticalOffset += PELS_PER_LINE;3498}
3294 drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, (char*)voxelStats.str().c_str());3499
3500void Application::toggleStatsExpanded() {
3501 _statsExpanded = !_statsExpanded;
3295}3502}
3296 3503
3297void Application::renderThrustAtVoxel(const glm::vec3& thrust) {3504void Application::renderThrustAtVoxel(const glm::vec3& thrust) {
@@ -4123,3 +4330,14 @@ void Application::skipVersion(QString latestVersion) { · 825 unmodified lines
4123 skipFile.seek(0);4330 skipFile.seek(0);
4124 skipFile.write(latestVersion.toStdString().c_str());4331 skipFile.write(latestVersion.toStdString().c_str());
4125}4332}
4333
4334void 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