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
852852 deleteVoxelUnderCursor();
853853 }
854854 }
855+
856+ _pieMenu.mouseMoveEvent(_mouseX, _mouseY);
855857 }
856858 }
857859
@@ -869,7 +871,12 @@ void Application::mousePressEvent(QMouseEvent* event) { · 11 unmodified lines
869871 _mouseDragStartedY = _mouseY;
870872 _mouseVoxelDragging = _mouseVoxel;
871873 _mousePressed = true;
872− maybeEditVoxelUnderCursor();
874+
875+
876+ if (!maybeEditVoxelUnderCursor()) {
877+ _pieMenu.mousePressEvent(_mouseX, _mouseY);
878+ }
879+
873880 if (MAKE_SOUND_ON_VOXEL_CLICK && _isHoverVoxel && !_isHoverVoxelSounding) {
874881 _hoverVoxelOriginalColor[0] = _hoverVoxel.red;
875882 _hoverVoxelOriginalColor[1] = _hoverVoxel.green;
@@ -892,6 +899,8 @@ void Application::mouseReleaseEvent(QMouseEvent* event) { · 16 unmodified lines
892899 _mouseY = event->y();
893900 _mousePressed = false;
894901 checkBandwidthMeterClick();
902+
903+ _pieMenu.mouseReleaseEvent(_mouseX, _mouseY);
895904 }
896905 }
897906 }
@@ -1383,6 +1392,10 @@ void Application::doFalseColorizeOccludedV2() { · 485 unmodified lines
13831392 _voxels.falseColorizeOccludedV2();
13841393 }
13851394
1395+void Application::doFalseColorizeBySource() {
1396+ _voxels.falseColorizeBySource();
1397+}
1398+
13861399 void Application::doTrueVoxelColors() {
13871400 _voxels.trueColorize();
13881401 }
@@ -1804,6 +1817,7 @@ void Application::initMenu() { · 415 unmodified lines
18041817 _testPing->setChecked(true);
18051818 (_fullScreenMode = optionsMenu->addAction("Fullscreen", this, SLOT(setFullscreen(bool)), Qt::Key_F))->setCheckable(true);
18061819 optionsMenu->addAction("Webcam", &_webcam, SLOT(setEnabled(bool)))->setCheckable(true);
1820+ optionsMenu->addAction("Toggle Skeleton Tracking", &_webcam, SLOT(setSkeletonTrackingOn(bool)))->setCheckable(true);
18071821 optionsMenu->addAction("Cycle Webcam Send Mode", _webcam.getGrabber(), SLOT(cycleVideoSendMode()));
18081822 optionsMenu->addAction("Go Home", this, SLOT(goHome()));
18091823
@@ -1832,7 +1846,6 @@ void Application::initMenu() { · 22 unmodified lines
18321846 (_renderLookatIndicatorOn = renderMenu->addAction("Lookat Indicator"))->setCheckable(true);
18331847 _renderLookatIndicatorOn->setChecked(true);
18341848 (_renderParticleSystemOn = renderMenu->addAction("Particle System"))->setCheckable(true);
1835− _renderParticleSystemOn->setChecked(true);
18361849 (_manualFirstPerson = renderMenu->addAction(
18371850 "First Person", this, SLOT(setRenderFirstPerson(bool)), Qt::Key_P))->setCheckable(true);
18381851 (_manualThirdPerson = renderMenu->addAction(
@@ -1919,6 +1932,7 @@ void Application::initMenu() { · 80 unmodified lines
19191932 renderDebugMenu->addAction("FALSE Color Voxel Out of View", this, SLOT(doFalseColorizeInView()));
19201933 renderDebugMenu->addAction("FALSE Color Occluded Voxels", this, SLOT(doFalseColorizeOccluded()), Qt::CTRL | Qt::Key_O);
19211934 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);
19221936 renderDebugMenu->addAction("Show TRUE Colors", this, SLOT(doTrueVoxelColors()), Qt::CTRL | Qt::Key_T);
19231937
19241938 (_shouldLowPassFilter = debugMenu->addAction("Test: LowPass filter"))->setCheckable(true);
@@ -2057,7 +2071,15 @@ void Application::init() { · 132 unmodified lines
20572071 _palette.addTool(&_swatch);
20582072 _palette.addAction(_colorVoxelMode, 0, 2);
20592073 _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);
20612083 }
20622084
20632085
@@ -2069,7 +2091,7 @@ const float HEAD_SPHERE_RADIUS = 0.07; · 5 unmodified lines
20692091 static uint16_t DEFAULT_NODE_ID_REF = 1;
20702092
20712093
2072−bool Application::isLookingAtOtherAvatar(glm::vec3& mouseRayOrigin, glm::vec3& mouseRayDirection,
2094+Avatar* Application::isLookingAtOtherAvatar(glm::vec3& mouseRayOrigin, glm::vec3& mouseRayDirection,
20732095 glm::vec3& eyePosition, uint16_t& nodeID = DEFAULT_NODE_ID_REF) {
20742096
20752097 NodeList* nodeList = NodeList::getInstance();
@@ -2082,11 +2104,11 @@ bool Application::isLookingAtOtherAvatar(glm::vec3& mouseRayOrigin, glm::vec3& m · 6 unmodified lines
20822104 _lookatIndicatorScale = avatar->getScale();
20832105 _lookatOtherPosition = headPosition;
20842106 nodeID = avatar->getOwningNode()->getNodeID();
2085− return true;
2107+ return avatar;
20862108 }
20872109 }
20882110 }
2089− return false;
2111+ return NULL;
20902112 }
20912113
20922114 void Application::renderLookatIndicator(glm::vec3 pointOfInterest, Camera& whichCamera) {
@@ -2101,6 +2123,7 @@ void Application::renderLookatIndicator(glm::vec3 pointOfInterest, Camera& which · 8 unmodified lines
21012123 }
21022124
21032125 void Application::update(float deltaTime) {
2126+
21042127 // Use Transmitter Hand to move hand if connected, else use mouse
21052128 if (_myTransmitter.isConnected()) {
21062129 const float HAND_FORCE_SCALING = 0.01f;
@@ -2997,6 +3020,10 @@ void Application::displayOverlay() { · 890 unmodified lines
29973020 _swatch.checkColor();
29983021 }
29993022
3023+ if (_pieMenu.isDisplayed()) {
3024+ _pieMenu.render();
3025+ }
3026+
30003027 glPopMatrix();
30013028 }
30023029
@@ -3009,19 +3036,35 @@ void Application::displayStats() { · 6 unmodified lines
30093036 drawtext(10, statsVerticalOffset + 15, 0.10f, 0, 1.0, 0, stats);
30103037
30113038 if (_testPing->isChecked()) {
3012− int pingAudio = 0, pingAvatar = 0, pingVoxel = 0;
3039+ int pingAudio = 0, pingAvatar = 0, pingVoxel = 0, pingVoxelMax = 0;
30133040
3014− NodeList *nodeList = NodeList::getInstance();
3015− Node *audioMixerNode = nodeList->soloNodeOfType(NODE_TYPE_AUDIO_MIXER);
3016− Node *avatarMixerNode = nodeList->soloNodeOfType(NODE_TYPE_AVATAR_MIXER);
3017− Node *voxelServerNode = nodeList->soloNodeOfType(NODE_TYPE_VOXEL_SERVER);
3041+ NodeList* nodeList = NodeList::getInstance();
3042+ Node* audioMixerNode = nodeList->soloNodeOfType(NODE_TYPE_AUDIO_MIXER);
3043+ Node* avatarMixerNode = nodeList->soloNodeOfType(NODE_TYPE_AVATAR_MIXER);
30183044
30193045 pingAudio = audioMixerNode ? audioMixerNode->getPingMs() : 0;
30203046 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+
30223065
30233066 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);
30253068 drawtext(10, statsVerticalOffset + 35, 0.10f, 0, 1.0, 0, pingStats);
30263069 }
30273070
@@ -3396,7 +3439,7 @@ void Application::shiftPaintingColor() { · 368 unmodified lines
33963439 }
33973440
33983441
3399−void Application::maybeEditVoxelUnderCursor() {
3442+bool Application::maybeEditVoxelUnderCursor() {
34003443 if (_addVoxelMode->isChecked() || _colorVoxelMode->isChecked()) {
34013444 if (_mouseVoxel.s != 0) {
34023445 PACKET_TYPE message = (_destructiveAddVoxel->isChecked() ?
@@ -3467,7 +3510,11 @@ void Application::maybeEditVoxelUnderCursor() { · 64 unmodified lines
34673510 deleteVoxelUnderCursor();
34683511 } else if (_eyedropperMode->isChecked()) {
34693512 eyedropperVoxelUnderCursor();
3513+ } else {
3514+ return false;
34703515 }
3516+
3517+ return true;
34713518 }
34723519
34733520 void Application::deleteVoxelUnderCursor() {
@@ -3510,6 +3557,22 @@ void Application::goHome() { · 36 unmodified lines
35103557 _myAvatar.setPosition(START_LOCATION);
35113558 }
35123559
3560+
3561+void 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+
35133576 void Application::resetSensors() {
35143577 _headMouseX = _mouseX = _glWidget->width() / 2;
35153578 _headMouseY = _mouseY = _glWidget->height() / 2;
@@ -3622,13 +3685,15 @@ void* Application::networkReceive(void* args) { · 106 unmodified lines
36223685 } // fall through to piggyback message
36233686
36243687 if (app->_renderVoxels->isChecked()) {
3625− Node* voxelServer = NodeList::getInstance()->soloNodeOfType(NODE_TYPE_VOXEL_SERVER);
3688+ Node* voxelServer = NodeList::getInstance()->nodeWithAddress(&senderAddress);
36263689 if (voxelServer && socketMatch(voxelServer->getActiveSocket(), &senderAddress)) {
36273690 voxelServer->lock();
36283691 if (messageData[0] == PACKET_TYPE_ENVIRONMENT_DATA) {
36293692 app->_environment.parseData(&senderAddress, messageData, messageLength);
36303693 } else {
3694+ app->_voxels.setDataSourceID(voxelServer->getNodeID());
36313695 app->_voxels.parseData(messageData, messageLength);
3696+ app->_voxels.setDataSourceID(UNKNOWN_NODE_ID);
36323697 }
36333698 voxelServer->unlock();
36343699 }

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