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
356 356
357void Application::paintGL() {357void Application::paintGL() {
358 PerformanceWarning::setSuppressShortTimings(Menu::getInstance()->isOptionChecked(MenuOption::SuppressShortTimings));358 PerformanceWarning::setSuppressShortTimings(Menu::getInstance()->isOptionChecked(MenuOption::SuppressShortTimings));
359 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), "Application::paintGL()");359 bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
360 360 PerformanceWarning warn(showWarnings, "Application::paintGL()");
361
361 glEnable(GL_LINE_SMOOTH);362 glEnable(GL_LINE_SMOOTH);
362 363
363 if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {364 if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
@@ -545,6 +546,7 @@ void Application::keyPressEvent(QKeyEvent* event) { · 181 unmodified lines
545 }546 }
546 547
547 bool isShifted = event->modifiers().testFlag(Qt::ShiftModifier);548 bool isShifted = event->modifiers().testFlag(Qt::ShiftModifier);
549 bool isMeta = event->modifiers().testFlag(Qt::ControlModifier);
548 switch (event->key()) {550 switch (event->key()) {
549 case Qt::Key_Shift:551 case Qt::Key_Shift:
550 if (Menu::getInstance()->isOptionChecked(MenuOption::VoxelSelectMode)) {552 if (Menu::getInstance()->isOptionChecked(MenuOption::VoxelSelectMode)) {
@@ -619,8 +621,10 @@ void Application::keyPressEvent(QKeyEvent* event) { · 68 unmodified lines
619 break;621 break;
620 622
621 case Qt::Key_S:623 case Qt::Key_S:
622 if (isShifted) {624 if (isShifted && !isMeta) {
623 _voxels.collectStatsForTreesAndVBOs();625 _voxels.collectStatsForTreesAndVBOs();
626 } else if (isShifted && isMeta) {
627 Menu::getInstance()->triggerOption(MenuOption::SuppressShortTimings);
624 } else if (_nudgeStarted) {628 } else if (_nudgeStarted) {
625 if (_lookingAlongX) {629 if (_lookingAlongX) {
626 if (_lookingAwayFromOrigin) {630 if (_lookingAwayFromOrigin) {
@@ -1238,6 +1242,8 @@ static glm::vec3 getFaceVector(BoxFace face) { · 611 unmodified lines
1238}1242}
1239 1243
1240void Application::idle() {1244void Application::idle() {
1245 bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
1246 PerformanceWarning warn(showWarnings, "Application::idle()");
1241 1247
1242 timeval check;1248 timeval check;
1243 gettimeofday(&check, NULL);1249 gettimeofday(&check, NULL);
@@ -1252,7 +1258,7 @@ void Application::idle() { · 8 unmodified lines
1252 _glWidget->updateGL();1258 _glWidget->updateGL();
1253 _lastTimeUpdated = check;1259 _lastTimeUpdated = check;
1254 _idleLoopStdev.addValue(timeSinceLastUpdate);1260 _idleLoopStdev.addValue(timeSinceLastUpdate);
1255 1261
1256 // Record standard deviation and reset counter if needed1262 // Record standard deviation and reset counter if needed
1257 const int STDEV_SAMPLES = 500;1263 const int STDEV_SAMPLES = 500;
1258 if (_idleLoopStdev.getSamples() > STDEV_SAMPLES) {1264 if (_idleLoopStdev.getSamples() > STDEV_SAMPLES) {
@@ -1785,7 +1791,28 @@ void Application::renderFollowIndicator() { · 526 unmodified lines
1785 }1791 }
1786}1792}
1787 1793
1794void 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
1788void Application::update(float deltaTime) {1813void Application::update(float deltaTime) {
1814 bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
1815 PerformanceWarning warn(showWarnings, "Application::update()");
1789 1816
1790 // Use Transmitter Hand to move hand if connected, else use mouse1817 // Use Transmitter Hand to move hand if connected, else use mouse
1791 if (_myTransmitter.isConnected()) {1818 if (_myTransmitter.isConnected()) {
@@ -1886,6 +1913,8 @@ void Application::update(float deltaTime) { · 94 unmodified lines
1886 (fabs(_myAvatar.getVelocity().x) +1913 (fabs(_myAvatar.getVelocity().x) +
1887 fabs(_myAvatar.getVelocity().y) +1914 fabs(_myAvatar.getVelocity().y) +
1888 fabs(_myAvatar.getVelocity().z)) / 3 < MAX_AVATAR_EDIT_VELOCITY) {1915 fabs(_myAvatar.getVelocity().z)) / 3 < MAX_AVATAR_EDIT_VELOCITY) {
1916 PerformanceWarning warn(showWarnings, "Application::update()... findRayIntersection()");
1917
1889 if (_voxels.findRayIntersection(mouseRayOrigin, mouseRayDirection, _mouseVoxel, distance, face)) {1918 if (_voxels.findRayIntersection(mouseRayOrigin, mouseRayDirection, _mouseVoxel, distance, face)) {
1890 if (distance < MAX_VOXEL_EDIT_DISTANCE) {1919 if (distance < MAX_VOXEL_EDIT_DISTANCE) {
1891 // find the nearest voxel with the desired scale1920 // find the nearest voxel with the desired scale
@@ -1993,22 +2022,11 @@ void Application::update(float deltaTime) { · 101 unmodified lines
1993 _voxelProcessor.threadRoutine();2022 _voxelProcessor.threadRoutine();
1994 _voxelEditSender.threadRoutine();2023 _voxelEditSender.threadRoutine();
1995 }2024 }
2025
1996 2026
1997 //loop through all the other avatars and simulate them...2027 //loop through all the other avatars and simulate them...
1998 NodeList* nodeList = NodeList::getInstance();2028 updateAvatars(deltaTime, mouseRayOrigin, mouseRayDirection);
1999 for(NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {2029
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
2012 // Simulate myself2030 // Simulate myself
2013 if (Menu::getInstance()->isOptionChecked(MenuOption::Gravity)) {2031 if (Menu::getInstance()->isOptionChecked(MenuOption::Gravity)) {
2014 _myAvatar.setGravity(_environment.getGravity(_myAvatar.getPosition()));2032 _myAvatar.setGravity(_environment.getGravity(_myAvatar.getPosition()));
@@ -2043,6 +2061,7 @@ void Application::update(float deltaTime) { · 28 unmodified lines
2043 if (_voxels.findRayIntersection(_transmitterPickStart, direction, detail, distance, face)) {2061 if (_voxels.findRayIntersection(_transmitterPickStart, direction, detail, distance, face)) {
2044 minDistance = min(minDistance, distance);2062 minDistance = min(minDistance, distance);
2045 }2063 }
2064 NodeList* nodeList = NodeList::getInstance();
2046 for(NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {2065 for(NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
2047 node->lock();2066 node->lock();
2048 if (node->getLinkedData() != NULL) {2067 if (node->getLinkedData() != NULL) {
@@ -2136,6 +2155,8 @@ void Application::update(float deltaTime) { · 87 unmodified lines
2136}2155}
2137 2156
2138void Application::updateAvatar(float deltaTime) {2157void Application::updateAvatar(float deltaTime) {
2158 bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
2159 PerformanceWarning warn(showWarnings, "Application::updateAvatar()");
2139 2160
2140 // rotate body yaw for yaw received from multitouch2161 // rotate body yaw for yaw received from multitouch
2141 _myAvatar.setOrientation(_myAvatar.getOrientation()2162 _myAvatar.setOrientation(_myAvatar.getOrientation()
@@ -2992,51 +3013,54 @@ void Application::displayStats() { · 850 unmodified lines
2992 std::stringstream voxelStats;3013 std::stringstream voxelStats;
2993 voxelStats.precision(4);3014 voxelStats.precision(4);
2994 voxelStats << "Voxels Rendered: " << _voxels.getVoxelsRendered() / 1000.f << "K " <<3015 voxelStats << "Voxels Rendered: " << _voxels.getVoxelsRendered() / 1000.f << "K " <<
3016 "Written: " << _voxels.getVoxelsWritten()/1000.f << "K " <<
2995 "Updated: " << _voxels.getVoxelsUpdated()/1000.f << "K " <<3017 "Updated: " << _voxels.getVoxelsUpdated()/1000.f << "K " <<
2996 "Max: " << _voxels.getMaxVoxels()/1000.f << "K ";3018 "Max: " << _voxels.getMaxVoxels()/1000.f << "K ";
2997 statsVerticalOffset += PELS_PER_LINE;3019 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());
2999 3021
3000 voxelStats.str("");3022 voxelStats.str("");
3001 voxelStats << 3023 voxelStats <<
3002 "Voxels Memory Nodes: " << VoxelNode::getVoxelMemoryUsage() / 1000000.f << "MB "3024 "Voxels Memory Nodes: " << VoxelNode::getTotalMemoryUsage() / 1000000.f << "MB "
3003 "Octcodes: " << VoxelNode::getOctcodeMemoryUsage() / 1000000.f << "MB "
3004 "Geometry RAM: " << _voxels.getVoxelMemoryUsageRAM() / 1000000.f << "MB " <<3025 "Geometry RAM: " << _voxels.getVoxelMemoryUsageRAM() / 1000000.f << "MB " <<
3005 "VBO: " << _voxels.getVoxelMemoryUsageVBO() / 1000000.f << "MB ";3026 "VBO: " << _voxels.getVoxelMemoryUsageVBO() / 1000000.f << "MB ";
3006 if (_voxels.hasVoxelMemoryUsageGPU()) {3027 if (_voxels.hasVoxelMemoryUsageGPU()) {
3007 voxelStats << "GPU: " << _voxels.getVoxelMemoryUsageGPU() / 1000000.f << "MB ";3028 voxelStats << "GPU: " << _voxels.getVoxelMemoryUsageGPU() / 1000000.f << "MB ";
3008 }3029 }
3030 statsVerticalOffset += PELS_PER_LINE;
3031 drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, (char*)voxelStats.str().c_str());
3009 3032
3010 // Some debugging for memory usage of VoxelNodes3033 voxelStats.str("");
3011 //voxelStats << "VoxelNode size: " << sizeof(VoxelNode) << " bytes ";3034 voxelStats <<
3012 //voxelStats << "AABox size: " << sizeof(AABox) << " bytes ";3035 "Local Voxels Total: " << VoxelNode::getNodeCount() << ", " <<
3013 3036 "Internal: " << VoxelNode::getInternalNodeCount() << " , " <<
3037 "Leaves: " << VoxelNode::getLeafNodeCount() << "";
3014 statsVerticalOffset += PELS_PER_LINE;3038 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());
3016 3040
3017 voxelStats.str("");3041 voxelStats.str("");
3018 char* voxelDetails = _voxelSceneStats.getItemValue(VoxelSceneStats::ITEM_VOXELS);3042 char* voxelDetails = _voxelSceneStats.getItemValue(VoxelSceneStats::ITEM_VOXELS);
3019 voxelStats << "Voxels Sent from Server: " << voxelDetails;3043 voxelStats << "Voxels Sent from Server: " << voxelDetails;
3020 statsVerticalOffset += PELS_PER_LINE;3044 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());
3022 3046
3023 voxelStats.str("");3047 voxelStats.str("");
3024 voxelDetails = _voxelSceneStats.getItemValue(VoxelSceneStats::ITEM_ELAPSED);3048 voxelDetails = _voxelSceneStats.getItemValue(VoxelSceneStats::ITEM_ELAPSED);
3025 voxelStats << "Scene Send Time from Server: " << voxelDetails;3049 voxelStats << "Scene Send Time from Server: " << voxelDetails;
3026 statsVerticalOffset += PELS_PER_LINE;3050 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());
3028 3052
3029 voxelStats.str("");3053 voxelStats.str("");
3030 voxelDetails = _voxelSceneStats.getItemValue(VoxelSceneStats::ITEM_ENCODE);3054 voxelDetails = _voxelSceneStats.getItemValue(VoxelSceneStats::ITEM_ENCODE);
3031 voxelStats << "Encode Time on Server: " << voxelDetails;3055 voxelStats << "Encode Time on Server: " << voxelDetails;
3032 statsVerticalOffset += PELS_PER_LINE;3056 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());
3034 3058
3035 voxelStats.str("");3059 voxelStats.str("");
3036 voxelDetails = _voxelSceneStats.getItemValue(VoxelSceneStats::ITEM_MODE);3060 voxelDetails = _voxelSceneStats.getItemValue(VoxelSceneStats::ITEM_MODE);
3037 voxelStats << "Sending Mode: " << voxelDetails;3061 voxelStats << "Sending Mode: " << voxelDetails;
3038 statsVerticalOffset += PELS_PER_LINE;3062 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());
3040 3064
3041 Node *avatarMixer = NodeList::getInstance()->soloNodeOfType(NODE_TYPE_AVATAR_MIXER);3065 Node *avatarMixer = NodeList::getInstance()->soloNodeOfType(NODE_TYPE_AVATAR_MIXER);
3042 char avatarMixerStats[200];3066 char avatarMixerStats[200];
@@ -3051,7 +3075,7 @@ void Application::displayStats() { · 8 unmodified lines
3051 statsVerticalOffset += PELS_PER_LINE;3075 statsVerticalOffset += PELS_PER_LINE;
3052 drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, avatarMixerStats);3076 drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, avatarMixerStats);
3053 statsVerticalOffset += PELS_PER_LINE;3077 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());
3055 3079
3056 if (_perfStatsOn) {3080 if (_perfStatsOn) {
3057 // Get the PerfStats group details. We need to allocate and array of char* long enough to hold 1+groups3081 // 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
3237 3261
3238 3262
3239 3263
3240/////////////////////////////////////////////////////////////////////////////////////
3241// renderViewFrustum()3264// renderViewFrustum()
3242//3265//
3243// Description: this will render the view frustum bounds for EITHER the head3266// Description: this will render the view frustum bounds for EITHER the head
@@ -3319,7 +3342,7 @@ void Application::renderViewFrustum(ViewFrustum& viewFrustum) { · 75 unmodified lines
3319 || Menu::getInstance()->getFrustumDrawMode() == FRUSTUM_DRAW_MODE_PLANES3342 || Menu::getInstance()->getFrustumDrawMode() == FRUSTUM_DRAW_MODE_PLANES
3320 || Menu::getInstance()->getFrustumDrawMode() == FRUSTUM_DRAW_MODE_FAR_PLANE) {3343 || Menu::getInstance()->getFrustumDrawMode() == FRUSTUM_DRAW_MODE_FAR_PLANE) {
3321 // viewFrustum.getFar plane - bottom edge 3344 // viewFrustum.getFar plane - bottom edge
3322 glColor3f(0,1,0); // GREEN!!!3345 glColor3f(0,1,0);
3323 glVertex3f(viewFrustum.getFarBottomLeft().x, viewFrustum.getFarBottomLeft().y, viewFrustum.getFarBottomLeft().z);3346 glVertex3f(viewFrustum.getFarBottomLeft().x, viewFrustum.getFarBottomLeft().y, viewFrustum.getFarBottomLeft().z);
3324 glVertex3f(viewFrustum.getFarBottomRight().x, viewFrustum.getFarBottomRight().y, viewFrustum.getFarBottomRight().z);3347 glVertex3f(viewFrustum.getFarBottomRight().x, viewFrustum.getFarBottomRight().y, viewFrustum.getFarBottomRight().z);
3325 3348
@@ -3687,6 +3710,9 @@ int Application::parseVoxelStats(unsigned char* messageData, ssize_t messageLeng · 361 unmodified lines
3687 3710
3688// Receive packets from other nodes/servers and decide what to do with them!3711// Receive packets from other nodes/servers and decide what to do with them!
3689void* Application::networkReceive(void* args) {3712void* Application::networkReceive(void* args) {
3713 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
3714 "Application::networkReceive()");
3715
3690 sockaddr senderAddress;3716 sockaddr senderAddress;
3691 ssize_t bytesReceived;3717 ssize_t bytesReceived;
3692 3718
@@ -3714,6 +3740,9 @@ void* Application::networkReceive(void* args) { · 21 unmodified lines
3714 case PACKET_TYPE_ERASE_VOXEL:3740 case PACKET_TYPE_ERASE_VOXEL:
3715 case PACKET_TYPE_VOXEL_STATS:3741 case PACKET_TYPE_VOXEL_STATS:
3716 case PACKET_TYPE_ENVIRONMENT_DATA: {3742 case PACKET_TYPE_ENVIRONMENT_DATA: {
3743 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
3744 "Application::networkReceive()... _voxelProcessor.queueReceivedPacket()");
3745
3717 // add this packet to our list of voxel packets and process them on the voxel processing3746 // add this packet to our list of voxel packets and process them on the voxel processing
3718 app->_voxelProcessor.queueReceivedPacket(senderAddress, app->_incomingPacket, bytesReceived);3747 app->_voxelProcessor.queueReceivedPacket(senderAddress, app->_incomingPacket, bytesReceived);
3719 break;3748 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