mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 03:17:02 +02:00
Fix mouse drag turning
This commit is contained in:
parent
634f8fbc83
commit
8988dd9771
3 changed files with 14 additions and 9 deletions
|
@ -2161,17 +2161,16 @@ void Application::mouseMoveEvent(QMouseEvent* event) {
|
||||||
|
|
||||||
maybeToggleMenuVisible(event);
|
maybeToggleMenuVisible(event);
|
||||||
|
|
||||||
|
auto& compositor = getApplicationCompositor();
|
||||||
// if this is a real mouse event, and we're in HMD mode, then we should use it to move the
|
// if this is a real mouse event, and we're in HMD mode, then we should use it to move the
|
||||||
// compositor reticle
|
// compositor reticle
|
||||||
if (event->spontaneous()) {
|
// handleRealMouseMoveEvent() will return true, if we shouldn't process the event further
|
||||||
// handleRealMouseMoveEvent() will return true, if we shouldn't process the event further
|
if (!compositor.fakeEventActive() && compositor.handleRealMouseMoveEvent()) {
|
||||||
if (getApplicationCompositor().handleRealMouseMoveEvent()) {
|
return; // bail
|
||||||
return; // bail
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
||||||
auto eventPosition = getApplicationCompositor().getMouseEventPosition(event);
|
auto eventPosition = compositor.getMouseEventPosition(event);
|
||||||
QPointF transformedPos = offscreenUi->mapToVirtualScreen(eventPosition, _glWidget);
|
QPointF transformedPos = offscreenUi->mapToVirtualScreen(eventPosition, _glWidget);
|
||||||
auto button = event->button();
|
auto button = event->button();
|
||||||
auto buttons = event->buttons();
|
auto buttons = event->buttons();
|
||||||
|
|
|
@ -303,11 +303,14 @@ void CompositorHelper::setReticlePosition(const glm::vec2& position, bool sendFa
|
||||||
auto button = Qt::NoButton;
|
auto button = Qt::NoButton;
|
||||||
auto buttons = QApplication::mouseButtons();
|
auto buttons = QApplication::mouseButtons();
|
||||||
auto modifiers = QApplication::keyboardModifiers();
|
auto modifiers = QApplication::keyboardModifiers();
|
||||||
|
static auto renderingWidget = PluginContainer::getInstance().getPrimaryWidget();
|
||||||
if (qApp->thread() == QThread::currentThread()) {
|
if (qApp->thread() == QThread::currentThread()) {
|
||||||
QMouseEvent event(QEvent::MouseMove, globalPos, button, buttons, modifiers);
|
QMouseEvent event(QEvent::MouseMove, globalPos, button, buttons, modifiers);
|
||||||
qApp->sendEvent(qApp, &event);
|
_fakeMouseEvent = true;
|
||||||
|
qApp->sendEvent(renderingWidget, &event);
|
||||||
|
_fakeMouseEvent = false;
|
||||||
} else {
|
} else {
|
||||||
qApp->postEvent(qApp, new QMouseEvent(QEvent::MouseMove, globalPos, button, buttons, modifiers));
|
qApp->postEvent(renderingWidget, new QMouseEvent(QEvent::MouseMove, globalPos, button, buttons, modifiers));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -54,6 +54,7 @@ public:
|
||||||
float getHmdUIAngularSize() const { return _hmdUIAngularSize; }
|
float getHmdUIAngularSize() const { return _hmdUIAngularSize; }
|
||||||
void setHmdUIAngularSize(float hmdUIAngularSize) { _hmdUIAngularSize = hmdUIAngularSize; }
|
void setHmdUIAngularSize(float hmdUIAngularSize) { _hmdUIAngularSize = hmdUIAngularSize; }
|
||||||
bool isHMD() const;
|
bool isHMD() const;
|
||||||
|
bool fakeEventActive() const { return _fakeMouseEvent; }
|
||||||
|
|
||||||
// Converter from one frame of reference to another.
|
// Converter from one frame of reference to another.
|
||||||
// Frame of reference:
|
// Frame of reference:
|
||||||
|
@ -167,7 +168,9 @@ private:
|
||||||
|
|
||||||
bool _allowMouseCapture { true };
|
bool _allowMouseCapture { true };
|
||||||
|
|
||||||
ReticleInterface* _reticleInterface;
|
bool _fakeMouseEvent { false };
|
||||||
|
|
||||||
|
ReticleInterface* _reticleInterface { nullptr };
|
||||||
};
|
};
|
||||||
|
|
||||||
// Scripting interface available to control the Reticle
|
// Scripting interface available to control the Reticle
|
||||||
|
|
Loading…
Reference in a new issue