mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 04:06:41 +02:00
CR feedback
This commit is contained in:
parent
1a4591db58
commit
32a7179c62
5 changed files with 27 additions and 27 deletions
|
@ -4720,7 +4720,7 @@ glm::uvec2 Application::getCanvasSize() const {
|
||||||
return glm::uvec2(_glWidget->width(), _glWidget->height());
|
return glm::uvec2(_glWidget->width(), _glWidget->height());
|
||||||
}
|
}
|
||||||
|
|
||||||
QRect Application::getApplicationGeometry() const {
|
QRect Application::getRenderingGeometry() const {
|
||||||
auto geometry = _glWidget->geometry();
|
auto geometry = _glWidget->geometry();
|
||||||
auto topLeft = geometry.topLeft();
|
auto topLeft = geometry.topLeft();
|
||||||
auto topLeftScreen = _glWidget->mapToGlobal(topLeft);
|
auto topLeftScreen = _glWidget->mapToGlobal(topLeft);
|
||||||
|
|
|
@ -114,7 +114,7 @@ public:
|
||||||
bool eventFilter(QObject* object, QEvent* event) override;
|
bool eventFilter(QObject* object, QEvent* event) override;
|
||||||
|
|
||||||
glm::uvec2 getCanvasSize() const;
|
glm::uvec2 getCanvasSize() const;
|
||||||
QRect getApplicationGeometry() const;
|
QRect getRenderingGeometry() const;
|
||||||
|
|
||||||
glm::uvec2 getUiSize() const;
|
glm::uvec2 getUiSize() const;
|
||||||
QSize getDeviceSize() const;
|
QSize getDeviceSize() const;
|
||||||
|
|
|
@ -113,6 +113,7 @@ ApplicationCompositor::ApplicationCompositor() :
|
||||||
_reticleInterface(new ReticleInterface(this))
|
_reticleInterface(new ReticleInterface(this))
|
||||||
|
|
||||||
{
|
{
|
||||||
|
_reticlePositionInHMD.store(glm::vec2(0.0f));
|
||||||
auto geometryCache = DependencyManager::get<GeometryCache>();
|
auto geometryCache = DependencyManager::get<GeometryCache>();
|
||||||
|
|
||||||
_reticleQuad = geometryCache->allocateID();
|
_reticleQuad = geometryCache->allocateID();
|
||||||
|
@ -300,7 +301,8 @@ void ApplicationCompositor::displayOverlayTextureHmd(RenderArgs* renderArgs, int
|
||||||
|
|
||||||
QPointF ApplicationCompositor::getMouseEventPosition(QMouseEvent* event) {
|
QPointF ApplicationCompositor::getMouseEventPosition(QMouseEvent* event) {
|
||||||
if (qApp->isHMDMode()) {
|
if (qApp->isHMDMode()) {
|
||||||
return QPointF(_reticlePositionInHMD.x, _reticlePositionInHMD.y);
|
auto reticlePositionInHMD = _reticlePositionInHMD.load();
|
||||||
|
return QPointF(reticlePositionInHMD.x, reticlePositionInHMD.y);
|
||||||
}
|
}
|
||||||
return event->localPos();
|
return event->localPos();
|
||||||
}
|
}
|
||||||
|
@ -314,7 +316,7 @@ void ApplicationCompositor::handleLeaveEvent() {
|
||||||
|
|
||||||
if (shouldCaptureMouse()) {
|
if (shouldCaptureMouse()) {
|
||||||
QWidget* mainWidget = (QWidget*)qApp->getWindow();
|
QWidget* mainWidget = (QWidget*)qApp->getWindow();
|
||||||
QRect mainWidgetFrame = qApp->getApplicationGeometry();
|
QRect mainWidgetFrame = qApp->getRenderingGeometry();
|
||||||
QRect uncoveredRect = mainWidgetFrame;
|
QRect uncoveredRect = mainWidgetFrame;
|
||||||
foreach(QWidget* widget, QApplication::topLevelWidgets()) {
|
foreach(QWidget* widget, QApplication::topLevelWidgets()) {
|
||||||
if (widget->isWindow() && widget->isVisible() && widget != mainWidget) {
|
if (widget->isWindow() && widget->isVisible() && widget != mainWidget) {
|
||||||
|
@ -355,7 +357,8 @@ bool ApplicationCompositor::handleRealMouseMoveEvent(bool sendFakeEvent) {
|
||||||
if (shouldCaptureMouse()) {
|
if (shouldCaptureMouse()) {
|
||||||
auto newPosition = QCursor::pos();
|
auto newPosition = QCursor::pos();
|
||||||
auto changeInRealMouse = newPosition - _lastKnownRealMouse;
|
auto changeInRealMouse = newPosition - _lastKnownRealMouse;
|
||||||
auto newReticlePosition = _reticlePositionInHMD + toGlm(changeInRealMouse);
|
auto reticlePositionInHMD = _reticlePositionInHMD.load();
|
||||||
|
auto newReticlePosition = reticlePositionInHMD + toGlm(changeInRealMouse);
|
||||||
setReticlePosition(newReticlePosition, sendFakeEvent);
|
setReticlePosition(newReticlePosition, sendFakeEvent);
|
||||||
_ignoreMouseMove = true;
|
_ignoreMouseMove = true;
|
||||||
QCursor::setPos(QPoint(_lastKnownRealMouse.x(), _lastKnownRealMouse.y())); // move cursor back to where it was
|
QCursor::setPos(QPoint(_lastKnownRealMouse.x(), _lastKnownRealMouse.y())); // move cursor back to where it was
|
||||||
|
@ -387,11 +390,12 @@ void ApplicationCompositor::setReticlePosition(glm::vec2 position, bool sendFake
|
||||||
glm::vec2 minMouse = vec2(0) - mouseExtra;
|
glm::vec2 minMouse = vec2(0) - mouseExtra;
|
||||||
glm::vec2 maxMouse = maxOverlayPosition + mouseExtra;
|
glm::vec2 maxMouse = maxOverlayPosition + mouseExtra;
|
||||||
|
|
||||||
_reticlePositionInHMD = glm::clamp(position, minMouse, maxMouse);
|
auto reticlePositionInHMD = glm::clamp(position, minMouse, maxMouse);
|
||||||
|
_reticlePositionInHMD.store(reticlePositionInHMD);
|
||||||
|
|
||||||
if (sendFakeEvent) {
|
if (sendFakeEvent) {
|
||||||
// in HMD mode we need to fake our mouse moves...
|
// in HMD mode we need to fake our mouse moves...
|
||||||
QPoint globalPos(_reticlePositionInHMD.x, _reticlePositionInHMD.y);
|
QPoint globalPos(reticlePositionInHMD.x, reticlePositionInHMD.y);
|
||||||
auto button = Qt::NoButton;
|
auto button = Qt::NoButton;
|
||||||
auto buttons = QApplication::mouseButtons();
|
auto buttons = QApplication::mouseButtons();
|
||||||
auto modifiers = QApplication::keyboardModifiers();
|
auto modifiers = QApplication::keyboardModifiers();
|
||||||
|
|
|
@ -9,11 +9,13 @@
|
||||||
#ifndef hifi_ApplicationCompositor_h
|
#ifndef hifi_ApplicationCompositor_h
|
||||||
#define hifi_ApplicationCompositor_h
|
#define hifi_ApplicationCompositor_h
|
||||||
|
|
||||||
|
#include <atomic>
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
#include <QCursor>
|
#include <QCursor>
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QPropertyAnimation>
|
#include <QPropertyAnimation>
|
||||||
#include <cstdint>
|
|
||||||
|
|
||||||
#include <EntityItemID.h>
|
#include <EntityItemID.h>
|
||||||
#include <GeometryCache.h>
|
#include <GeometryCache.h>
|
||||||
|
@ -81,16 +83,16 @@ public:
|
||||||
float getAlpha() const { return _alpha; }
|
float getAlpha() const { return _alpha; }
|
||||||
void setAlpha(float alpha) { _alpha = alpha; }
|
void setAlpha(float alpha) { _alpha = alpha; }
|
||||||
|
|
||||||
Q_INVOKABLE bool getReticleVisible() { return _reticleVisible; }
|
bool getReticleVisible() { return _reticleVisible; }
|
||||||
Q_INVOKABLE void setReticleVisible(bool visible) { _reticleVisible = visible; }
|
void setReticleVisible(bool visible) { _reticleVisible = visible; }
|
||||||
|
|
||||||
Q_INVOKABLE float getReticleDepth() { return _reticleDepth; }
|
float getReticleDepth() { return _reticleDepth; }
|
||||||
Q_INVOKABLE void setReticleDepth(float depth) { _reticleDepth = depth; }
|
void setReticleDepth(float depth) { _reticleDepth = depth; }
|
||||||
|
|
||||||
Q_INVOKABLE glm::vec2 getReticlePosition();
|
glm::vec2 getReticlePosition();
|
||||||
Q_INVOKABLE void setReticlePosition(glm::vec2 position, bool sendFakeEvent = true);
|
void setReticlePosition(glm::vec2 position, bool sendFakeEvent = true);
|
||||||
|
|
||||||
Q_INVOKABLE glm::vec2 getReticleMaximumPosition() const;
|
glm::vec2 getReticleMaximumPosition() const;
|
||||||
|
|
||||||
ReticleInterface* getReticleInterface() { return _reticleInterface; }
|
ReticleInterface* getReticleInterface() { return _reticleInterface; }
|
||||||
|
|
||||||
|
@ -138,19 +140,17 @@ private:
|
||||||
|
|
||||||
std::unique_ptr<QPropertyAnimation> _alphaPropertyAnimation;
|
std::unique_ptr<QPropertyAnimation> _alphaPropertyAnimation;
|
||||||
|
|
||||||
bool _reticleVisible { true };
|
std::atomic<bool> _reticleVisible { true };
|
||||||
float _reticleDepth { 1.0f };
|
std::atomic<float> _reticleDepth { 1.0f };
|
||||||
|
|
||||||
// NOTE: when the compositor is running in HMD mode, it will control the reticle position as a custom
|
// NOTE: when the compositor is running in HMD mode, it will control the reticle position as a custom
|
||||||
// application specific position, when it's in desktop mode, the reticle position will simply move
|
// application specific position, when it's in desktop mode, the reticle position will simply move
|
||||||
// the system mouse.
|
// the system mouse.
|
||||||
glm::vec2 _reticlePositionInHMD{ 0.0f, 0.0f };
|
std::atomic<glm::vec2> _reticlePositionInHMD;
|
||||||
QPointF _lastKnownRealMouse;
|
QPointF _lastKnownRealMouse;
|
||||||
QPoint _lastKnownCursorPos;
|
|
||||||
bool _ignoreMouseMove { false };
|
bool _ignoreMouseMove { false };
|
||||||
|
|
||||||
ReticleInterface* _reticleInterface;
|
ReticleInterface* _reticleInterface;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Scripting interface available to control the Reticle
|
// Scripting interface available to control the Reticle
|
||||||
|
|
|
@ -252,12 +252,8 @@ void ApplicationOverlay::buildFramebufferObject() {
|
||||||
PROFILE_RANGE(__FUNCTION__);
|
PROFILE_RANGE(__FUNCTION__);
|
||||||
|
|
||||||
auto uiSize = qApp->getUiSize();
|
auto uiSize = qApp->getUiSize();
|
||||||
QSize desiredSize (uiSize.x, uiSize.y);
|
|
||||||
int currentWidth = _overlayFramebuffer ? _overlayFramebuffer->getWidth() : 0;
|
|
||||||
int currentHeight = _overlayFramebuffer ? _overlayFramebuffer->getHeight() : 0;
|
|
||||||
QSize frameBufferCurrentSize(currentWidth, currentHeight);
|
|
||||||
|
|
||||||
if (_overlayFramebuffer && desiredSize == frameBufferCurrentSize) {
|
if (_overlayFramebuffer && uiSize == _overlayFramebuffer->getSize()) {
|
||||||
// Already built
|
// Already built
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -271,8 +267,8 @@ void ApplicationOverlay::buildFramebufferObject() {
|
||||||
_overlayFramebuffer = gpu::FramebufferPointer(gpu::Framebuffer::create());
|
_overlayFramebuffer = gpu::FramebufferPointer(gpu::Framebuffer::create());
|
||||||
|
|
||||||
auto colorFormat = gpu::Element(gpu::VEC4, gpu::NUINT8, gpu::RGBA);
|
auto colorFormat = gpu::Element(gpu::VEC4, gpu::NUINT8, gpu::RGBA);
|
||||||
auto width = desiredSize.width();
|
auto width = uiSize.x;
|
||||||
auto height = desiredSize.height();
|
auto height = uiSize.y;
|
||||||
|
|
||||||
auto defaultSampler = gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_LINEAR);
|
auto defaultSampler = gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_LINEAR);
|
||||||
_overlayColorTexture = gpu::TexturePointer(gpu::Texture::create2D(colorFormat, width, height, defaultSampler));
|
_overlayColorTexture = gpu::TexturePointer(gpu::Texture::create2D(colorFormat, width, height, defaultSampler));
|
||||||
|
|
Loading…
Reference in a new issue