History

Merge branch 'master' of https://github.com/worklist/hifi into ossome

Andrzej Kapolka committed 13 years ago

Commit 247dfd32 parents cf98d90 873a479151 files · +1244 −16855Browse files

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

Unified · Split

interface/src/Application.cpp+62−33
@@ -356,8 +356,9 @@ void Application::initializeGL() { · 355 unmodified lines
356356
357357 void Application::paintGL() {
358358 PerformanceWarning::setSuppressShortTimings(Menu::getInstance()->isOptionChecked(MenuOption::SuppressShortTimings));
359− PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), "Application::paintGL()");
360−
359+ bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
360+ PerformanceWarning warn(showWarnings, "Application::paintGL()");
361+
361362 glEnable(GL_LINE_SMOOTH);
362363
363364 if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
@@ -545,6 +546,7 @@ void Application::keyPressEvent(QKeyEvent* event) { · 181 unmodified lines
545546 }
546547
547548 bool isShifted = event->modifiers().testFlag(Qt::ShiftModifier);
549+ bool isMeta = event->modifiers().testFlag(Qt::ControlModifier);
548550 switch (event->key()) {
549551 case Qt::Key_Shift:
550552 if (Menu::getInstance()->isOptionChecked(MenuOption::VoxelSelectMode)) {
@@ -619,8 +621,10 @@ void Application::keyPressEvent(QKeyEvent* event) { · 68 unmodified lines
619621 break;
620622
621623 case Qt::Key_S:
622− if (isShifted) {
624+ if (isShifted && !isMeta) {
623625 _voxels.collectStatsForTreesAndVBOs();
626+ } else if (isShifted && isMeta) {
627+ Menu::getInstance()->triggerOption(MenuOption::SuppressShortTimings);
624628 } else if (_nudgeStarted) {
625629 if (_lookingAlongX) {
626630 if (_lookingAwayFromOrigin) {
@@ -1238,6 +1242,8 @@ static glm::vec3 getFaceVector(BoxFace face) { · 611 unmodified lines
12381242 }
12391243
12401244 void Application::idle() {
1245+ bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
1246+ PerformanceWarning warn(showWarnings, "Application::idle()");
12411247
12421248 timeval check;
12431249 gettimeofday(&check, NULL);
@@ -1252,7 +1258,7 @@ void Application::idle() { · 8 unmodified lines
12521258 _glWidget->updateGL();
12531259 _lastTimeUpdated = check;
12541260 _idleLoopStdev.addValue(timeSinceLastUpdate);
1255−
1261+
12561262 // Record standard deviation and reset counter if needed
12571263 const int STDEV_SAMPLES = 500;
12581264 if (_idleLoopStdev.getSamples() > STDEV_SAMPLES) {
@@ -1785,7 +1791,28 @@ void Application::renderFollowIndicator() { · 526 unmodified lines
17851791 }
17861792 }
17871793
1794+void Application::updateAvatars(float deltaTime, glm::vec3 mouseRayOrigin, glm::vec3 mouseRayDirection) {
1795+ bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
1796+ PerformanceWarning warn(showWarnings, "Application::updateAvatars()");
1797+ NodeList* nodeList = NodeList::getInstance();
1798+
1799+ for(NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
1800+ node->lock();
1801+ if (node->getLinkedData() != NULL) {
1802+ Avatar *avatar = (Avatar *)node->getLinkedData();
1803+ if (!avatar->isInitialized()) {
1804+ avatar->init();
1805+ }
1806+ avatar->simulate(deltaTime, NULL);
1807+ avatar->setMouseRay(mouseRayOrigin, mouseRayDirection);
1808+ }
1809+ node->unlock();
1810+ }
1811+}
1812+
17881813 void Application::update(float deltaTime) {
1814+ bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
1815+ PerformanceWarning warn(showWarnings, "Application::update()");
17891816
17901817 // Use Transmitter Hand to move hand if connected, else use mouse
17911818 if (_myTransmitter.isConnected()) {
@@ -1886,6 +1913,8 @@ void Application::update(float deltaTime) { · 94 unmodified lines
18861913 (fabs(_myAvatar.getVelocity().x) +
18871914 fabs(_myAvatar.getVelocity().y) +
18881915 fabs(_myAvatar.getVelocity().z)) / 3 < MAX_AVATAR_EDIT_VELOCITY) {
1916+ PerformanceWarning warn(showWarnings, "Application::update()... findRayIntersection()");
1917+
18891918 if (_voxels.findRayIntersection(mouseRayOrigin, mouseRayDirection, _mouseVoxel, distance, face)) {
18901919 if (distance < MAX_VOXEL_EDIT_DISTANCE) {
18911920 // find the nearest voxel with the desired scale
@@ -1993,22 +2022,11 @@ void Application::update(float deltaTime) { · 101 unmodified lines
19932022 _voxelProcessor.threadRoutine();
19942023 _voxelEditSender.threadRoutine();
19952024 }
2025+
19962026
19972027 //loop through all the other avatars and simulate them...
1998− NodeList* nodeList = NodeList::getInstance();
1999− for(NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
2000− node->lock();
2001− if (node->getLinkedData() != NULL) {
2002− Avatar *avatar = (Avatar *)node->getLinkedData();
2003− if (!avatar->isInitialized()) {
2004− avatar->init();
2005− }
2006− avatar->simulate(deltaTime, NULL);
2007− avatar->setMouseRay(mouseRayOrigin, mouseRayDirection);
2008− }
2009− node->unlock();
2010− }
2011−
2028+ updateAvatars(deltaTime, mouseRayOrigin, mouseRayDirection);
2029+
20122030 // Simulate myself
20132031 if (Menu::getInstance()->isOptionChecked(MenuOption::Gravity)) {
20142032 _myAvatar.setGravity(_environment.getGravity(_myAvatar.getPosition()));
@@ -2043,6 +2061,7 @@ void Application::update(float deltaTime) { · 28 unmodified lines
20432061 if (_voxels.findRayIntersection(_transmitterPickStart, direction, detail, distance, face)) {
20442062 minDistance = min(minDistance, distance);
20452063 }
2064+ NodeList* nodeList = NodeList::getInstance();
20462065 for(NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
20472066 node->lock();
20482067 if (node->getLinkedData() != NULL) {
@@ -2136,6 +2155,8 @@ void Application::update(float deltaTime) { · 87 unmodified lines
21362155 }
21372156
21382157 void Application::updateAvatar(float deltaTime) {
2158+ bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
2159+ PerformanceWarning warn(showWarnings, "Application::updateAvatar()");
21392160
21402161 // rotate body yaw for yaw received from multitouch
21412162 _myAvatar.setOrientation(_myAvatar.getOrientation()
@@ -2992,51 +3013,54 @@ void Application::displayStats() { · 850 unmodified lines
29923013 std::stringstream voxelStats;
29933014 voxelStats.precision(4);
29943015 voxelStats << "Voxels Rendered: " << _voxels.getVoxelsRendered() / 1000.f << "K " <<
3016+ "Written: " << _voxels.getVoxelsWritten()/1000.f << "K " <<
29953017 "Updated: " << _voxels.getVoxelsUpdated()/1000.f << "K " <<
29963018 "Max: " << _voxels.getMaxVoxels()/1000.f << "K ";
29973019 statsVerticalOffset += PELS_PER_LINE;
2998− drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, (char *)voxelStats.str().c_str());
3020+ drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, (char*)voxelStats.str().c_str());
29993021
30003022 voxelStats.str("");
30013023 voxelStats <<
3002− "Voxels Memory Nodes: " << VoxelNode::getVoxelMemoryUsage() / 1000000.f << "MB "
3003− "Octcodes: " << VoxelNode::getOctcodeMemoryUsage() / 1000000.f << "MB "
3024+ "Voxels Memory Nodes: " << VoxelNode::getTotalMemoryUsage() / 1000000.f << "MB "
30043025 "Geometry RAM: " << _voxels.getVoxelMemoryUsageRAM() / 1000000.f << "MB " <<
30053026 "VBO: " << _voxels.getVoxelMemoryUsageVBO() / 1000000.f << "MB ";
30063027 if (_voxels.hasVoxelMemoryUsageGPU()) {
30073028 voxelStats << "GPU: " << _voxels.getVoxelMemoryUsageGPU() / 1000000.f << "MB ";
30083029 }
3030+ statsVerticalOffset += PELS_PER_LINE;
3031+ drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, (char*)voxelStats.str().c_str());
30093032
3010− // Some debugging for memory usage of VoxelNodes
3011− //voxelStats << "VoxelNode size: " << sizeof(VoxelNode) << " bytes ";
3012− //voxelStats << "AABox size: " << sizeof(AABox) << " bytes ";
3013−
3033+ voxelStats.str("");
3034+ voxelStats <<
3035+ "Local Voxels Total: " << VoxelNode::getNodeCount() << ", " <<
3036+ "Internal: " << VoxelNode::getInternalNodeCount() << " , " <<
3037+ "Leaves: " << VoxelNode::getLeafNodeCount() << "";
30143038 statsVerticalOffset += PELS_PER_LINE;
3015− drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, (char *)voxelStats.str().c_str());
3039+ drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, (char*)voxelStats.str().c_str());
30163040
30173041 voxelStats.str("");
30183042 char* voxelDetails = _voxelSceneStats.getItemValue(VoxelSceneStats::ITEM_VOXELS);
30193043 voxelStats << "Voxels Sent from Server: " << voxelDetails;
30203044 statsVerticalOffset += PELS_PER_LINE;
3021− drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, (char *)voxelStats.str().c_str());
3045+ drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, (char*)voxelStats.str().c_str());
30223046
30233047 voxelStats.str("");
30243048 voxelDetails = _voxelSceneStats.getItemValue(VoxelSceneStats::ITEM_ELAPSED);
30253049 voxelStats << "Scene Send Time from Server: " << voxelDetails;
30263050 statsVerticalOffset += PELS_PER_LINE;
3027− drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, (char *)voxelStats.str().c_str());
3051+ drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, (char*)voxelStats.str().c_str());
30283052
30293053 voxelStats.str("");
30303054 voxelDetails = _voxelSceneStats.getItemValue(VoxelSceneStats::ITEM_ENCODE);
30313055 voxelStats << "Encode Time on Server: " << voxelDetails;
30323056 statsVerticalOffset += PELS_PER_LINE;
3033− drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, (char *)voxelStats.str().c_str());
3057+ drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, (char*)voxelStats.str().c_str());
30343058
30353059 voxelStats.str("");
30363060 voxelDetails = _voxelSceneStats.getItemValue(VoxelSceneStats::ITEM_MODE);
30373061 voxelStats << "Sending Mode: " << voxelDetails;
30383062 statsVerticalOffset += PELS_PER_LINE;
3039− drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, (char *)voxelStats.str().c_str());
3063+ drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, (char*)voxelStats.str().c_str());
30403064
30413065 Node *avatarMixer = NodeList::getInstance()->soloNodeOfType(NODE_TYPE_AVATAR_MIXER);
30423066 char avatarMixerStats[200];
@@ -3051,7 +3075,7 @@ void Application::displayStats() { · 8 unmodified lines
30513075 statsVerticalOffset += PELS_PER_LINE;
30523076 drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, avatarMixerStats);
30533077 statsVerticalOffset += PELS_PER_LINE;
3054− drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, (char *)LeapManager::statusString().c_str());
3078+ drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, (char*)LeapManager::statusString().c_str());
30553079
30563080 if (_perfStatsOn) {
30573081 // Get the PerfStats group details. We need to allocate and array of char* long enough to hold 1+groups
@@ -3237,7 +3261,6 @@ void Application::renderCoverageMapsRecursively(CoverageMap* map) { · 179 unmodified lines
32373261
32383262
32393263
3240−/////////////////////////////////////////////////////////////////////////////////////
32413264 // renderViewFrustum()
32423265 //
32433266 // Description: this will render the view frustum bounds for EITHER the head
@@ -3319,7 +3342,7 @@ void Application::renderViewFrustum(ViewFrustum& viewFrustum) { · 75 unmodified lines
33193342 || Menu::getInstance()->getFrustumDrawMode() == FRUSTUM_DRAW_MODE_PLANES
33203343 || Menu::getInstance()->getFrustumDrawMode() == FRUSTUM_DRAW_MODE_FAR_PLANE) {
33213344 // viewFrustum.getFar plane - bottom edge
3322− glColor3f(0,1,0); // GREEN!!!
3345+ glColor3f(0,1,0);
33233346 glVertex3f(viewFrustum.getFarBottomLeft().x, viewFrustum.getFarBottomLeft().y, viewFrustum.getFarBottomLeft().z);
33243347 glVertex3f(viewFrustum.getFarBottomRight().x, viewFrustum.getFarBottomRight().y, viewFrustum.getFarBottomRight().z);
33253348
@@ -3687,6 +3710,9 @@ int Application::parseVoxelStats(unsigned char* messageData, ssize_t messageLeng · 361 unmodified lines
36873710
36883711 // Receive packets from other nodes/servers and decide what to do with them!
36893712 void* Application::networkReceive(void* args) {
3713+ PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
3714+ "Application::networkReceive()");
3715+
36903716 sockaddr senderAddress;
36913717 ssize_t bytesReceived;
36923718
@@ -3714,6 +3740,9 @@ void* Application::networkReceive(void* args) { · 21 unmodified lines
37143740 case PACKET_TYPE_ERASE_VOXEL:
37153741 case PACKET_TYPE_VOXEL_STATS:
37163742 case PACKET_TYPE_ENVIRONMENT_DATA: {
3743+ PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
3744+ "Application::networkReceive()... _voxelProcessor.queueReceivedPacket()");
3745+
37173746 // add this packet to our list of voxel packets and process them on the voxel processing
37183747 app->_voxelProcessor.queueReceivedPacket(senderAddress, app->_incomingPacket, bytesReceived);
37193748 break;

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