CR feedback

This commit is contained in:
Brad Hefta-Gaub 2016-02-21 09:59:19 -08:00
parent 1a4591db58
commit 32a7179c62
5 changed files with 27 additions and 27 deletions

View file

@ -4720,7 +4720,7 @@ glm::uvec2 Application::getCanvasSize() const {
return glm::uvec2(_glWidget->width(), _glWidget->height());
}
QRect Application::getApplicationGeometry() const {
QRect Application::getRenderingGeometry() const {
auto geometry = _glWidget->geometry();
auto topLeft = geometry.topLeft();
auto topLeftScreen = _glWidget->mapToGlobal(topLeft);

View file

@ -114,7 +114,7 @@ public:
bool eventFilter(QObject* object, QEvent* event) override;
glm::uvec2 getCanvasSize() const;
QRect getApplicationGeometry() const;
QRect getRenderingGeometry() const;
glm::uvec2 getUiSize() const;
QSize getDeviceSize() const;

View file

@ -113,6 +113,7 @@ ApplicationCompositor::ApplicationCompositor() :
_reticleInterface(new ReticleInterface(this))
{
_reticlePositionInHMD.store(glm::vec2(0.0f));
auto geometryCache = DependencyManager::get<GeometryCache>();
_reticleQuad = geometryCache->allocateID();
@ -300,7 +301,8 @@ void ApplicationCompositor::displayOverlayTextureHmd(RenderArgs* renderArgs, int
QPointF ApplicationCompositor::getMouseEventPosition(QMouseEvent* event) {
if (qApp->isHMDMode()) {
return QPointF(_reticlePositionInHMD.x, _reticlePositionInHMD.y);
auto reticlePositionInHMD = _reticlePositionInHMD.load();
return QPointF(reticlePositionInHMD.x, reticlePositionInHMD.y);
}
return event->localPos();
}
@ -314,7 +316,7 @@ void ApplicationCompositor::handleLeaveEvent() {
if (shouldCaptureMouse()) {
QWidget* mainWidget = (QWidget*)qApp->getWindow();
QRect mainWidgetFrame = qApp->getApplicationGeometry();
QRect mainWidgetFrame = qApp->getRenderingGeometry();
QRect uncoveredRect = mainWidgetFrame;
foreach(QWidget* widget, QApplication::topLevelWidgets()) {
if (widget->isWindow() && widget->isVisible() && widget != mainWidget) {
@ -355,7 +357,8 @@ bool ApplicationCompositor::handleRealMouseMoveEvent(bool sendFakeEvent) {
if (shouldCaptureMouse()) {
auto newPosition = QCursor::pos();
auto changeInRealMouse = newPosition - _lastKnownRealMouse;
auto newReticlePosition = _reticlePositionInHMD + toGlm(changeInRealMouse);
auto reticlePositionInHMD = _reticlePositionInHMD.load();
auto newReticlePosition = reticlePositionInHMD + toGlm(changeInRealMouse);
setReticlePosition(newReticlePosition, sendFakeEvent);
_ignoreMouseMove = true;
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 maxMouse = maxOverlayPosition + mouseExtra;
_reticlePositionInHMD = glm::clamp(position, minMouse, maxMouse);
auto reticlePositionInHMD = glm::clamp(position, minMouse, maxMouse);
_reticlePositionInHMD.store(reticlePositionInHMD);
if (sendFakeEvent) {
// 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 buttons = QApplication::mouseButtons();
auto modifiers = QApplication::keyboardModifiers();

View file

@ -9,11 +9,13 @@
#ifndef hifi_ApplicationCompositor_h
#define hifi_ApplicationCompositor_h
#include <atomic>
#include <cstdint>
#include <QCursor>
#include <QMouseEvent>
#include <QObject>
#include <QPropertyAnimation>
#include <cstdint>
#include <EntityItemID.h>
#include <GeometryCache.h>
@ -81,16 +83,16 @@ public:
float getAlpha() const { return _alpha; }
void setAlpha(float alpha) { _alpha = alpha; }
Q_INVOKABLE bool getReticleVisible() { return _reticleVisible; }
Q_INVOKABLE void setReticleVisible(bool visible) { _reticleVisible = visible; }
bool getReticleVisible() { return _reticleVisible; }
void setReticleVisible(bool visible) { _reticleVisible = visible; }
Q_INVOKABLE float getReticleDepth() { return _reticleDepth; }
Q_INVOKABLE void setReticleDepth(float depth) { _reticleDepth = depth; }
float getReticleDepth() { return _reticleDepth; }
void setReticleDepth(float depth) { _reticleDepth = depth; }
Q_INVOKABLE glm::vec2 getReticlePosition();
Q_INVOKABLE void setReticlePosition(glm::vec2 position, bool sendFakeEvent = true);
glm::vec2 getReticlePosition();
void setReticlePosition(glm::vec2 position, bool sendFakeEvent = true);
Q_INVOKABLE glm::vec2 getReticleMaximumPosition() const;
glm::vec2 getReticleMaximumPosition() const;
ReticleInterface* getReticleInterface() { return _reticleInterface; }
@ -138,19 +140,17 @@ private:
std::unique_ptr<QPropertyAnimation> _alphaPropertyAnimation;
bool _reticleVisible { true };
float _reticleDepth { 1.0f };
std::atomic<bool> _reticleVisible { true };
std::atomic<float> _reticleDepth { 1.0f };
// 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
// the system mouse.
glm::vec2 _reticlePositionInHMD{ 0.0f, 0.0f };
std::atomic<glm::vec2> _reticlePositionInHMD;
QPointF _lastKnownRealMouse;
QPoint _lastKnownCursorPos;
bool _ignoreMouseMove { false };
ReticleInterface* _reticleInterface;
};
// Scripting interface available to control the Reticle

View file

@ -252,12 +252,8 @@ void ApplicationOverlay::buildFramebufferObject() {
PROFILE_RANGE(__FUNCTION__);
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
return;
}
@ -271,8 +267,8 @@ void ApplicationOverlay::buildFramebufferObject() {
_overlayFramebuffer = gpu::FramebufferPointer(gpu::Framebuffer::create());
auto colorFormat = gpu::Element(gpu::VEC4, gpu::NUINT8, gpu::RGBA);
auto width = desiredSize.width();
auto height = desiredSize.height();
auto width = uiSize.x;
auto height = uiSize.y;
auto defaultSampler = gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_LINEAR);
_overlayColorTexture = gpu::TexturePointer(gpu::Texture::create2D(colorFormat, width, height, defaultSampler));