From 53543c26fe21e41fb3a7c7c22b7184d36e4d51f6 Mon Sep 17 00:00:00 2001 From: Mark Peng Date: Fri, 28 Jun 2013 16:02:49 -0700 Subject: [PATCH] Added menu toggle for displaying ping --- interface/src/Application.cpp | 38 ++++++++++++++++++++--------------- interface/src/Application.h | 1 + 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 953cb8b880..63726fa16e 100755 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -848,7 +848,9 @@ void sendPingPackets() { // Every second, check the frame rates and other stuff void Application::timer() { gettimeofday(&_timerEnd, NULL); - sendPingPackets(); + + if (_testPing->isChecked()) + sendPingPackets(); _fps = (float)_frameCount / ((float)diffclock(&_timerStart, &_timerEnd) / 1000.f); _packetsPerSecond = (float)_packetCount / ((float)diffclock(&_timerStart, &_timerEnd) / 1000.f); @@ -1352,6 +1354,8 @@ void Application::initMenu() { (_gravityUse = optionsMenu->addAction("Use Gravity"))->setCheckable(true); _gravityUse->setChecked(true); _gravityUse->setShortcut(Qt::SHIFT | Qt::Key_G); + (_testPing = optionsMenu->addAction("Test Ping"))->setCheckable(true); + _testPing->setChecked(true); (_fullScreenMode = optionsMenu->addAction("Fullscreen", this, SLOT(setFullscreen(bool)), Qt::Key_F))->setCheckable(true); optionsMenu->addAction("Webcam", &_webcam, SLOT(setEnabled(bool)))->setCheckable(true); @@ -2294,24 +2298,26 @@ void Application::displayStats() { _fps, _packetsPerSecond, (float)_bytesPerSecond * 8.f / 1000000.f); drawtext(10, statsVerticalOffset + 15, 0.10f, 0, 1.0, 0, stats); - int pingAudio = 0, pingAvatar = 0, pingVoxel = 0; + if (_testPing->isChecked()) { + int pingAudio = 0, pingAvatar = 0, pingVoxel = 0; - AgentList *agentList = AgentList::getInstance(); - Agent *audioMixerAgent = agentList->soloAgentOfType(AGENT_TYPE_AUDIO_MIXER); - Agent *avatarMixerAgent = agentList->soloAgentOfType(AGENT_TYPE_AVATAR_MIXER); - Agent *voxelServerAgent = agentList->soloAgentOfType(AGENT_TYPE_VOXEL_SERVER); + AgentList *agentList = AgentList::getInstance(); + Agent *audioMixerAgent = agentList->soloAgentOfType(AGENT_TYPE_AUDIO_MIXER); + Agent *avatarMixerAgent = agentList->soloAgentOfType(AGENT_TYPE_AVATAR_MIXER); + Agent *voxelServerAgent = agentList->soloAgentOfType(AGENT_TYPE_VOXEL_SERVER); - if (audioMixerAgent != NULL) - pingAudio = audioMixerAgent->getPingMs(); - if (avatarMixerAgent != NULL) - pingAvatar = avatarMixerAgent->getPingMs(); - if (voxelServerAgent != NULL) - pingVoxel = voxelServerAgent->getPingMs(); + if (audioMixerAgent != NULL) + pingAudio = audioMixerAgent->getPingMs(); + if (avatarMixerAgent != NULL) + pingAvatar = avatarMixerAgent->getPingMs(); + if (voxelServerAgent != NULL) + pingVoxel = voxelServerAgent->getPingMs(); - char pingStats[200]; - sprintf(pingStats, "Ping audio/avatar/voxel: %d / %d / %d ", pingAudio, pingAvatar, pingVoxel); - drawtext(10, statsVerticalOffset + 35, 0.10f, 0, 1.0, 0, pingStats); - + char pingStats[200]; + sprintf(pingStats, "Ping audio/avatar/voxel: %d / %d / %d ", pingAudio, pingAvatar, pingVoxel); + drawtext(10, statsVerticalOffset + 35, 0.10f, 0, 1.0, 0, pingStats); + } + std::stringstream voxelStats; voxelStats.precision(4); voxelStats << "Voxels Rendered: " << _voxels.getVoxelsRendered() / 1000.f << "K Updated: " << _voxels.getVoxelsUpdated()/1000.f << "K"; diff --git a/interface/src/Application.h b/interface/src/Application.h index baf4fceea0..743fcd29de 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -199,6 +199,7 @@ private: QAction* _showHeadMouse; // Whether the have the mouse near edge of screen move your view QAction* _transmitterDrives; // Whether to have Transmitter data move/steer the Avatar QAction* _gravityUse; // Whether gravity is on or not + QAction* _testPing; // Whether to display ping or not QAction* _renderVoxels; // Whether to render voxels QAction* _renderVoxelTextures; // Whether to render noise textures on voxels QAction* _renderStarsOn; // Whether to display the stars