History

Merge pull request #7879 from howard-stearns/fix-reticle-offset

fix reticle position offset

Brad Hefta-Gaub committed 10 years ago

Commit 0d5fdbd2 parents c443138 40f72121 file · +6 −17Browse files

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

Unified · Split

interface/src/Application.cpp+6−17
@@ -864,10 +864,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : · 863 unmodified lines
864 864
865 if (action == controller::toInt(controller::Action::RETICLE_CLICK)) {865 if (action == controller::toInt(controller::Action::RETICLE_CLICK)) {
866 auto reticlePos = getApplicationCompositor().getReticlePosition();866 auto reticlePos = getApplicationCompositor().getReticlePosition();
867 QPoint globalPos(reticlePos.x, reticlePos.y);867 QPoint localPos(reticlePos.x, reticlePos.y); // both hmd and desktop already handle this in our coordinates.
868
869 // FIXME - it would be nice if this was self contained in the _compositor or Reticle class
870 auto localPos = isHMDMode() ? globalPos : _glWidget->mapFromGlobal(globalPos);
871 if (state) {868 if (state) {
872 QMouseEvent mousePress(QEvent::MouseButtonPress, localPos, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);869 QMouseEvent mousePress(QEvent::MouseButtonPress, localPos, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
873 sendEvent(_glWidget, &mousePress);870 sendEvent(_glWidget, &mousePress);
@@ -888,15 +885,15 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : · 14 unmodified lines
888 } else if (action == controller::toInt(controller::Action::UI_NAV_SELECT)) {885 } else if (action == controller::toInt(controller::Action::UI_NAV_SELECT)) {
889 if (!offscreenUi->navigationFocused()) {886 if (!offscreenUi->navigationFocused()) {
890 auto reticlePosition = getApplicationCompositor().getReticlePosition();887 auto reticlePosition = getApplicationCompositor().getReticlePosition();
891 offscreenUi->toggleMenu(_glWidget->mapFromGlobal(QPoint(reticlePosition.x, reticlePosition.y)));888 offscreenUi->toggleMenu(QPoint(reticlePosition.x, reticlePosition.y));
892 }889 }
893 } else if (action == controller::toInt(controller::Action::CONTEXT_MENU)) {890 } else if (action == controller::toInt(controller::Action::CONTEXT_MENU)) {
894 auto reticlePosition = getApplicationCompositor().getReticlePosition();891 auto reticlePosition = getApplicationCompositor().getReticlePosition();
895 offscreenUi->toggleMenu(_glWidget->mapFromGlobal(QPoint(reticlePosition.x, reticlePosition.y)));892 offscreenUi->toggleMenu(QPoint(reticlePosition.x, reticlePosition.y));
896 } else if (action == controller::toInt(controller::Action::UI_NAV_SELECT)) {893 } else if (action == controller::toInt(controller::Action::UI_NAV_SELECT)) {
897 if (!offscreenUi->navigationFocused()) {894 if (!offscreenUi->navigationFocused()) {
898 auto reticlePosition = getApplicationCompositor().getReticlePosition();895 auto reticlePosition = getApplicationCompositor().getReticlePosition();
899 offscreenUi->toggleMenu(_glWidget->mapFromGlobal(QPoint(reticlePosition.x, reticlePosition.y)));896 offscreenUi->toggleMenu(QPoint(reticlePosition.x, reticlePosition.y));
900 }897 }
901 } else if (action == controller::toInt(controller::Action::RETICLE_X)) {898 } else if (action == controller::toInt(controller::Action::RETICLE_X)) {
902 auto oldPos = getApplicationCompositor().getReticlePosition();899 auto oldPos = getApplicationCompositor().getReticlePosition();
@@ -2268,7 +2265,7 @@ void Application::keyReleaseEvent(QKeyEvent* event) { · 1365 unmodified lines
2268 if (event->key() == Qt::Key_Alt && _altPressed && hasFocus()) {2265 if (event->key() == Qt::Key_Alt && _altPressed && hasFocus()) {
2269 auto offscreenUi = DependencyManager::get<OffscreenUi>();2266 auto offscreenUi = DependencyManager::get<OffscreenUi>();
2270 auto reticlePosition = getApplicationCompositor().getReticlePosition();2267 auto reticlePosition = getApplicationCompositor().getReticlePosition();
2271 offscreenUi->toggleMenu(_glWidget->mapFromGlobal(QPoint(reticlePosition.x, reticlePosition.y)));2268 offscreenUi->toggleMenu(QPoint(reticlePosition.x, reticlePosition.y));
2272 }2269 }
2273 2270
2274 _keysPressed.remove(event->key());2271 _keysPressed.remove(event->key());
@@ -2737,15 +2734,7 @@ void Application::setLowVelocityFilter(bool lowVelocityFilter) { · 462 unmodified lines
2737}2734}
2738 2735
2739ivec2 Application::getMouse() const {2736ivec2 Application::getMouse() const {
2740 auto reticlePosition = getApplicationCompositor().getReticlePosition();2737 return getApplicationCompositor().getReticlePosition();
2741
2742 // in the HMD, the reticlePosition is the mouse position
2743 if (isHMDMode()) {
2744 return reticlePosition;
2745 }
2746
2747 // in desktop mode, we need to map from global to widget space
2748 return toGlm(_glWidget->mapFromGlobal(QPoint(reticlePosition.x, reticlePosition.y)));
2749}2738}
2750 2739
2751FaceTracker* Application::getActiveFaceTracker() {2740FaceTracker* Application::getActiveFaceTracker() {