History

Merge branch 'master' of https://github.com/worklist/hifi into Remove-body

Philip Rosedale committed 13 years ago

Commit 639b6be2 parents 8aa8b5d f24cf1931 files · +1165 −199Browse files

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

Unified · Split

interface/src/Application.cpp+80−15
@@ -852,6 +852,8 @@ void Application::mouseMoveEvent(QMouseEvent* event) { · 851 unmodified lines
852 deleteVoxelUnderCursor();852 deleteVoxelUnderCursor();
853 }853 }
854 }854 }
855
856 _pieMenu.mouseMoveEvent(_mouseX, _mouseY);
855 }857 }
856}858}
857 859
@@ -869,7 +871,12 @@ void Application::mousePressEvent(QMouseEvent* event) { · 11 unmodified lines
869 _mouseDragStartedY = _mouseY;871 _mouseDragStartedY = _mouseY;
870 _mouseVoxelDragging = _mouseVoxel;872 _mouseVoxelDragging = _mouseVoxel;
871 _mousePressed = true;873 _mousePressed = true;
872 maybeEditVoxelUnderCursor();874
875
876 if (!maybeEditVoxelUnderCursor()) {
877 _pieMenu.mousePressEvent(_mouseX, _mouseY);
878 }
879
873 if (MAKE_SOUND_ON_VOXEL_CLICK && _isHoverVoxel && !_isHoverVoxelSounding) {880 if (MAKE_SOUND_ON_VOXEL_CLICK && _isHoverVoxel && !_isHoverVoxelSounding) {
874 _hoverVoxelOriginalColor[0] = _hoverVoxel.red;881 _hoverVoxelOriginalColor[0] = _hoverVoxel.red;
875 _hoverVoxelOriginalColor[1] = _hoverVoxel.green;882 _hoverVoxelOriginalColor[1] = _hoverVoxel.green;
@@ -892,6 +899,8 @@ void Application::mouseReleaseEvent(QMouseEvent* event) { · 16 unmodified lines
892 _mouseY = event->y();899 _mouseY = event->y();
893 _mousePressed = false;900 _mousePressed = false;
894 checkBandwidthMeterClick();901 checkBandwidthMeterClick();
902
903 _pieMenu.mouseReleaseEvent(_mouseX, _mouseY);
895 }904 }
896 }905 }
897}906}
@@ -1383,6 +1392,10 @@ void Application::doFalseColorizeOccludedV2() { · 485 unmodified lines
1383 _voxels.falseColorizeOccludedV2();1392 _voxels.falseColorizeOccludedV2();
1384}1393}
1385 1394
1395void Application::doFalseColorizeBySource() {
1396 _voxels.falseColorizeBySource();
1397}
1398
1386void Application::doTrueVoxelColors() {1399void Application::doTrueVoxelColors() {
1387 _voxels.trueColorize();1400 _voxels.trueColorize();
1388}1401}
@@ -1804,6 +1817,7 @@ void Application::initMenu() { · 415 unmodified lines
1804 _testPing->setChecked(true);1817 _testPing->setChecked(true);
1805 (_fullScreenMode = optionsMenu->addAction("Fullscreen", this, SLOT(setFullscreen(bool)), Qt::Key_F))->setCheckable(true);1818 (_fullScreenMode = optionsMenu->addAction("Fullscreen", this, SLOT(setFullscreen(bool)), Qt::Key_F))->setCheckable(true);
1806 optionsMenu->addAction("Webcam", &_webcam, SLOT(setEnabled(bool)))->setCheckable(true);1819 optionsMenu->addAction("Webcam", &_webcam, SLOT(setEnabled(bool)))->setCheckable(true);
1820 optionsMenu->addAction("Toggle Skeleton Tracking", &_webcam, SLOT(setSkeletonTrackingOn(bool)))->setCheckable(true);
1807 optionsMenu->addAction("Cycle Webcam Send Mode", _webcam.getGrabber(), SLOT(cycleVideoSendMode()));1821 optionsMenu->addAction("Cycle Webcam Send Mode", _webcam.getGrabber(), SLOT(cycleVideoSendMode()));
1808 optionsMenu->addAction("Go Home", this, SLOT(goHome()));1822 optionsMenu->addAction("Go Home", this, SLOT(goHome()));
1809 1823
@@ -1832,7 +1846,6 @@ void Application::initMenu() { · 22 unmodified lines
1832 (_renderLookatIndicatorOn = renderMenu->addAction("Lookat Indicator"))->setCheckable(true);1846 (_renderLookatIndicatorOn = renderMenu->addAction("Lookat Indicator"))->setCheckable(true);
1833 _renderLookatIndicatorOn->setChecked(true);1847 _renderLookatIndicatorOn->setChecked(true);
1834 (_renderParticleSystemOn = renderMenu->addAction("Particle System"))->setCheckable(true);1848 (_renderParticleSystemOn = renderMenu->addAction("Particle System"))->setCheckable(true);
1835 _renderParticleSystemOn->setChecked(true);
1836 (_manualFirstPerson = renderMenu->addAction(1849 (_manualFirstPerson = renderMenu->addAction(
1837 "First Person", this, SLOT(setRenderFirstPerson(bool)), Qt::Key_P))->setCheckable(true);1850 "First Person", this, SLOT(setRenderFirstPerson(bool)), Qt::Key_P))->setCheckable(true);
1838 (_manualThirdPerson = renderMenu->addAction(1851 (_manualThirdPerson = renderMenu->addAction(
@@ -1919,6 +1932,7 @@ void Application::initMenu() { · 80 unmodified lines
1919 renderDebugMenu->addAction("FALSE Color Voxel Out of View", this, SLOT(doFalseColorizeInView()));1932 renderDebugMenu->addAction("FALSE Color Voxel Out of View", this, SLOT(doFalseColorizeInView()));
1920 renderDebugMenu->addAction("FALSE Color Occluded Voxels", this, SLOT(doFalseColorizeOccluded()), Qt::CTRL | Qt::Key_O);1933 renderDebugMenu->addAction("FALSE Color Occluded Voxels", this, SLOT(doFalseColorizeOccluded()), Qt::CTRL | Qt::Key_O);
1921 renderDebugMenu->addAction("FALSE Color Occluded V2 Voxels", this, SLOT(doFalseColorizeOccludedV2()), Qt::CTRL | Qt::Key_P);1934 renderDebugMenu->addAction("FALSE Color Occluded V2 Voxels", this, SLOT(doFalseColorizeOccludedV2()), Qt::CTRL | Qt::Key_P);
1935 renderDebugMenu->addAction("FALSE Color By Source", this, SLOT(doFalseColorizeBySource()), Qt::CTRL | Qt::SHIFT | Qt::Key_S);
1922 renderDebugMenu->addAction("Show TRUE Colors", this, SLOT(doTrueVoxelColors()), Qt::CTRL | Qt::Key_T);1936 renderDebugMenu->addAction("Show TRUE Colors", this, SLOT(doTrueVoxelColors()), Qt::CTRL | Qt::Key_T);
1923 1937
1924 (_shouldLowPassFilter = debugMenu->addAction("Test: LowPass filter"))->setCheckable(true);1938 (_shouldLowPassFilter = debugMenu->addAction("Test: LowPass filter"))->setCheckable(true);
@@ -2057,7 +2071,15 @@ void Application::init() { · 132 unmodified lines
2057 _palette.addTool(&_swatch);2071 _palette.addTool(&_swatch);
2058 _palette.addAction(_colorVoxelMode, 0, 2);2072 _palette.addAction(_colorVoxelMode, 0, 2);
2059 _palette.addAction(_eyedropperMode, 0, 3);2073 _palette.addAction(_eyedropperMode, 0, 3);
2060 _palette.addAction(_selectVoxelMode, 0, 4); 2074 _palette.addAction(_selectVoxelMode, 0, 4);
2075
2076 _pieMenu.init("./resources/images/hifi-interface-tools-v2-pie.svg",
2077 _glWidget->width(),
2078 _glWidget->height());
2079
2080 _followMode = new QAction(this);
2081 connect(_followMode, SIGNAL(triggered()), this, SLOT(toggleFollowMode()));
2082 _pieMenu.addAction(_followMode);
2061}2083}
2062 2084
2063 2085
@@ -2069,7 +2091,7 @@ const float HEAD_SPHERE_RADIUS = 0.07; · 5 unmodified lines
2069static uint16_t DEFAULT_NODE_ID_REF = 1;2091static uint16_t DEFAULT_NODE_ID_REF = 1;
2070 2092
2071 2093
2072bool Application::isLookingAtOtherAvatar(glm::vec3& mouseRayOrigin, glm::vec3& mouseRayDirection, 2094Avatar* Application::isLookingAtOtherAvatar(glm::vec3& mouseRayOrigin, glm::vec3& mouseRayDirection,
2073 glm::vec3& eyePosition, uint16_t& nodeID = DEFAULT_NODE_ID_REF) {2095 glm::vec3& eyePosition, uint16_t& nodeID = DEFAULT_NODE_ID_REF) {
2074 2096
2075 NodeList* nodeList = NodeList::getInstance();2097 NodeList* nodeList = NodeList::getInstance();
@@ -2082,11 +2104,11 @@ bool Application::isLookingAtOtherAvatar(glm::vec3& mouseRayOrigin, glm::vec3& m · 6 unmodified lines
2082 _lookatIndicatorScale = avatar->getScale();2104 _lookatIndicatorScale = avatar->getScale();
2083 _lookatOtherPosition = headPosition;2105 _lookatOtherPosition = headPosition;
2084 nodeID = avatar->getOwningNode()->getNodeID();2106 nodeID = avatar->getOwningNode()->getNodeID();
2085 return true;2107 return avatar;
2086 }2108 }
2087 }2109 }
2088 }2110 }
2089 return false;2111 return NULL;
2090}2112}
2091 2113
2092void Application::renderLookatIndicator(glm::vec3 pointOfInterest, Camera& whichCamera) {2114void Application::renderLookatIndicator(glm::vec3 pointOfInterest, Camera& whichCamera) {
@@ -2101,6 +2123,7 @@ void Application::renderLookatIndicator(glm::vec3 pointOfInterest, Camera& which · 8 unmodified lines
2101}2123}
2102 2124
2103void Application::update(float deltaTime) {2125void Application::update(float deltaTime) {
2126
2104 // Use Transmitter Hand to move hand if connected, else use mouse2127 // Use Transmitter Hand to move hand if connected, else use mouse
2105 if (_myTransmitter.isConnected()) {2128 if (_myTransmitter.isConnected()) {
2106 const float HAND_FORCE_SCALING = 0.01f;2129 const float HAND_FORCE_SCALING = 0.01f;
@@ -2997,6 +3020,10 @@ void Application::displayOverlay() { · 890 unmodified lines
2997 _swatch.checkColor();3020 _swatch.checkColor();
2998 }3021 }
2999 3022
3023 if (_pieMenu.isDisplayed()) {
3024 _pieMenu.render();
3025 }
3026
3000 glPopMatrix();3027 glPopMatrix();
3001}3028}
3002 3029
@@ -3009,19 +3036,35 @@ void Application::displayStats() { · 6 unmodified lines
3009 drawtext(10, statsVerticalOffset + 15, 0.10f, 0, 1.0, 0, stats);3036 drawtext(10, statsVerticalOffset + 15, 0.10f, 0, 1.0, 0, stats);
3010 3037
3011 if (_testPing->isChecked()) {3038 if (_testPing->isChecked()) {
3012 int pingAudio = 0, pingAvatar = 0, pingVoxel = 0;3039 int pingAudio = 0, pingAvatar = 0, pingVoxel = 0, pingVoxelMax = 0;
3013 3040
3014 NodeList *nodeList = NodeList::getInstance();3041 NodeList* nodeList = NodeList::getInstance();
3015 Node *audioMixerNode = nodeList->soloNodeOfType(NODE_TYPE_AUDIO_MIXER);3042 Node* audioMixerNode = nodeList->soloNodeOfType(NODE_TYPE_AUDIO_MIXER);
3016 Node *avatarMixerNode = nodeList->soloNodeOfType(NODE_TYPE_AVATAR_MIXER);3043 Node* avatarMixerNode = nodeList->soloNodeOfType(NODE_TYPE_AVATAR_MIXER);
3017 Node *voxelServerNode = nodeList->soloNodeOfType(NODE_TYPE_VOXEL_SERVER);
3018 3044
3019 pingAudio = audioMixerNode ? audioMixerNode->getPingMs() : 0;3045 pingAudio = audioMixerNode ? audioMixerNode->getPingMs() : 0;
3020 pingAvatar = avatarMixerNode ? avatarMixerNode->getPingMs() : 0;3046 pingAvatar = avatarMixerNode ? avatarMixerNode->getPingMs() : 0;
3021 pingVoxel = voxelServerNode ? voxelServerNode->getPingMs() : 0;3047
3048
3049 // Now handle voxel servers, since there could be more than one, we average their ping times
3050 unsigned long totalPingVoxel = 0;
3051 int voxelServerCount = 0;
3052 for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
3053 if (node->getType() == NODE_TYPE_VOXEL_SERVER) {
3054 totalPingVoxel += node->getPingMs();
3055 voxelServerCount++;
3056 if (pingVoxelMax < node->getPingMs()) {
3057 pingVoxelMax = node->getPingMs();
3058 }
3059 }
3060 }
3061 if (voxelServerCount) {
3062 pingVoxel = totalPingVoxel/voxelServerCount;
3063 }
3064
3022 3065
3023 char pingStats[200];3066 char pingStats[200];
3024 sprintf(pingStats, "Ping audio/avatar/voxel: %d / %d / %d ", pingAudio, pingAvatar, pingVoxel);3067 sprintf(pingStats, "Ping audio/avatar/voxel: %d / %d / %d avg %d max ", pingAudio, pingAvatar, pingVoxel, pingVoxelMax);
3025 drawtext(10, statsVerticalOffset + 35, 0.10f, 0, 1.0, 0, pingStats);3068 drawtext(10, statsVerticalOffset + 35, 0.10f, 0, 1.0, 0, pingStats);
3026 }3069 }
3027 3070
@@ -3396,7 +3439,7 @@ void Application::shiftPaintingColor() { · 368 unmodified lines
3396}3439}
3397 3440
3398 3441
3399void Application::maybeEditVoxelUnderCursor() {3442bool Application::maybeEditVoxelUnderCursor() {
3400 if (_addVoxelMode->isChecked() || _colorVoxelMode->isChecked()) {3443 if (_addVoxelMode->isChecked() || _colorVoxelMode->isChecked()) {
3401 if (_mouseVoxel.s != 0) {3444 if (_mouseVoxel.s != 0) {
3402 PACKET_TYPE message = (_destructiveAddVoxel->isChecked() ?3445 PACKET_TYPE message = (_destructiveAddVoxel->isChecked() ?
@@ -3467,7 +3510,11 @@ void Application::maybeEditVoxelUnderCursor() { · 64 unmodified lines
3467 deleteVoxelUnderCursor();3510 deleteVoxelUnderCursor();
3468 } else if (_eyedropperMode->isChecked()) {3511 } else if (_eyedropperMode->isChecked()) {
3469 eyedropperVoxelUnderCursor();3512 eyedropperVoxelUnderCursor();
3513 } else {
3514 return false;
3470 }3515 }
3516
3517 return true;
3471}3518}
3472 3519
3473void Application::deleteVoxelUnderCursor() {3520void Application::deleteVoxelUnderCursor() {
@@ -3510,6 +3557,22 @@ void Application::goHome() { · 36 unmodified lines
3510 _myAvatar.setPosition(START_LOCATION);3557 _myAvatar.setPosition(START_LOCATION);
3511}3558}
3512 3559
3560
3561void Application::toggleFollowMode() {
3562 glm::vec3 mouseRayOrigin, mouseRayDirection;
3563 _viewFrustum.computePickRay(_pieMenu.getX() / (float)_glWidget->width(),
3564 _pieMenu.getY() / (float)_glWidget->height(),
3565 mouseRayOrigin, mouseRayDirection);
3566 glm::vec3 eyePositionIgnored;
3567 uint16_t nodeIDIgnored;
3568 Avatar* leadingAvatar = isLookingAtOtherAvatar(mouseRayOrigin,
3569 mouseRayDirection,
3570 eyePositionIgnored,
3571 nodeIDIgnored);
3572
3573 _myAvatar.follow(leadingAvatar);
3574}
3575
3513void Application::resetSensors() {3576void Application::resetSensors() {
3514 _headMouseX = _mouseX = _glWidget->width() / 2;3577 _headMouseX = _mouseX = _glWidget->width() / 2;
3515 _headMouseY = _mouseY = _glWidget->height() / 2;3578 _headMouseY = _mouseY = _glWidget->height() / 2;
@@ -3622,13 +3685,15 @@ void* Application::networkReceive(void* args) { · 106 unmodified lines
3622 } // fall through to piggyback message3685 } // fall through to piggyback message
3623 3686
3624 if (app->_renderVoxels->isChecked()) {3687 if (app->_renderVoxels->isChecked()) {
3625 Node* voxelServer = NodeList::getInstance()->soloNodeOfType(NODE_TYPE_VOXEL_SERVER);3688 Node* voxelServer = NodeList::getInstance()->nodeWithAddress(&senderAddress);
3626 if (voxelServer && socketMatch(voxelServer->getActiveSocket(), &senderAddress)) {3689 if (voxelServer && socketMatch(voxelServer->getActiveSocket(), &senderAddress)) {
3627 voxelServer->lock();3690 voxelServer->lock();
3628 if (messageData[0] == PACKET_TYPE_ENVIRONMENT_DATA) {3691 if (messageData[0] == PACKET_TYPE_ENVIRONMENT_DATA) {
3629 app->_environment.parseData(&senderAddress, messageData, messageLength);3692 app->_environment.parseData(&senderAddress, messageData, messageLength);
3630 } else {3693 } else {
3694 app->_voxels.setDataSourceID(voxelServer->getNodeID());
3631 app->_voxels.parseData(messageData, messageLength);3695 app->_voxels.parseData(messageData, messageLength);
3696 app->_voxels.setDataSourceID(UNKNOWN_NODE_ID);
3632 }3697 }
3633 voxelServer->unlock();3698 voxelServer->unlock();
3634 }3699 }

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