mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-13 12:12:36 +02:00
first cut at exposing recommend overlay rectangle
This commit is contained in:
parent
91334d6a39
commit
c7f58dc17c
10 changed files with 71 additions and 8 deletions
|
@ -355,20 +355,52 @@ ToolBar = function(x, y, direction, optionalPersistenceKey, optionalInitialPosit
|
|||
});
|
||||
}
|
||||
};
|
||||
that.windowDimensions = Controller.getViewportDimensions();
|
||||
|
||||
var recommendedRect = Controller.getRecommendedOverlayRect();
|
||||
var recommendedDimmensions = { x: recommendedRect.z - recommendedRect.x, y: recommendedRect.w - recommendedRect.y };
|
||||
print("recommendedDimmensions:"+JSON.stringify(recommendedDimmensions));
|
||||
that.windowDimensions = recommendedDimmensions; // Controller.getViewportDimensions();
|
||||
that.origin = { x: recommendedRect.x, y: recommendedRect.y };
|
||||
// Maybe fixme: Keeping the same percent of the window size isn't always the right thing.
|
||||
// For example, maybe we want "keep the same percentage to whatever two edges are closest to the edge of screen".
|
||||
// If we change that, the places to do so are onResizeViewport, save (maybe), and the initial move based on Settings, below.
|
||||
that.onResizeViewport = function (newSize) { // Can be overridden or extended by clients.
|
||||
var fractionX = that.x / that.windowDimensions.x;
|
||||
var fractionY = that.y / that.windowDimensions.y;
|
||||
that.windowDimensions = newSize || Controller.getViewportDimensions();
|
||||
that.move(fractionX * that.windowDimensions.x, fractionY * that.windowDimensions.y);
|
||||
print("that.onResizeViewport().... newSize:"+JSON.stringify(newSize));
|
||||
|
||||
var recommendedRect = Controller.getRecommendedOverlayRect();
|
||||
print("that.onResizeViewport().... recommendedRect:"+JSON.stringify(recommendedRect));
|
||||
var recommendedDimmensions = { x: recommendedRect.z - recommendedRect.x, y: recommendedRect.w - recommendedRect.y };
|
||||
print("that.onResizeViewport().... recommendedDimmensions:"+JSON.stringify(recommendedDimmensions));
|
||||
|
||||
print("that.onResizeViewport().... that.x/that.y:"+that.x+","+that.y);
|
||||
var originRelativeX = (that.x - that.origin.x);
|
||||
var originRelativeY = (that.y - that.origin.y);
|
||||
print("that.onResizeViewport().... originRelativeX/originRelativeY:"+originRelativeX+","+originRelativeY);
|
||||
|
||||
var fractionX = originRelativeX / that.windowDimensions.x;
|
||||
var fractionY = originRelativeY / that.windowDimensions.y;
|
||||
print("that.onResizeViewport().... fractionX/fractionY:"+fractionX+","+fractionY);
|
||||
|
||||
that.windowDimensions = newSize || recommendedDimmensions;
|
||||
print("that.onResizeViewport().... that.windowDimensions:"+JSON.stringify(that.windowDimensions));
|
||||
|
||||
that.origin = { x: recommendedRect.x, y: recommendedRect.y };
|
||||
print("that.onResizeViewport().... that.origin:"+JSON.stringify(that.origin));
|
||||
|
||||
var newX = (fractionX * that.windowDimensions.x) + recommendedRect.x;
|
||||
var newY = (fractionY * that.windowDimensions.y) + recommendedRect.y;
|
||||
print("that.onResizeViewport().... newX/newY:"+newX+","+newY);
|
||||
|
||||
that.move(newX, newY);
|
||||
};
|
||||
if (optionalPersistenceKey) {
|
||||
this.fractionKey = optionalPersistenceKey + '.fraction';
|
||||
this.save = function () {
|
||||
var screenSize = Controller.getViewportDimensions();
|
||||
//var screenSize = Controller.getViewportDimensions();
|
||||
var recommendedRect = Controller.getRecommendedOverlayRect();
|
||||
var screenSize = { x: recommendedRect.z - recommendedRect.x, y: recommendedRect.w - recommendedRect.y };
|
||||
print("screenSize:"+JSON.stringify(screenSize));
|
||||
|
||||
if (screenSize.x > 0 && screenSize.y > 0) {
|
||||
// Guard against invalid screen size that can occur at shut-down.
|
||||
var fraction = {x: that.x / screenSize.x, y: that.y / screenSize.y};
|
||||
|
@ -411,7 +443,9 @@ ToolBar = function(x, y, direction, optionalPersistenceKey, optionalInitialPosit
|
|||
that.move(that.dragOffsetX + event.x, that.dragOffsetY + event.y);
|
||||
};
|
||||
that.checkResize = function () { // Can be overriden or extended, but usually not. See onResizeViewport.
|
||||
var currentWindowSize = Controller.getViewportDimensions();
|
||||
var recommendedRect = Controller.getRecommendedOverlayRect();
|
||||
var currentWindowSize = { x: recommendedRect.z - recommendedRect.x, y: recommendedRect.w - recommendedRect.y };
|
||||
|
||||
if ((currentWindowSize.x !== that.windowDimensions.x) || (currentWindowSize.y !== that.windowDimensions.y)) {
|
||||
that.onResizeViewport(currentWindowSize);
|
||||
}
|
||||
|
@ -434,7 +468,10 @@ ToolBar = function(x, y, direction, optionalPersistenceKey, optionalInitialPosit
|
|||
}
|
||||
if (this.fractionKey || optionalInitialPositionFunction) {
|
||||
var savedFraction = JSON.parse(Settings.getValue(this.fractionKey) || '0'); // getValue can answer empty string
|
||||
var screenSize = Controller.getViewportDimensions();
|
||||
//var screenSize = Controller.getViewportDimensions();
|
||||
var recommendedRect = Controller.getRecommendedOverlayRect();
|
||||
var screenSize = { x: recommendedRect.z - recommendedRect.x, y: recommendedRect.w - recommendedRect.y };
|
||||
print("screenSize:"+JSON.stringify(screenSize));
|
||||
if (savedFraction) {
|
||||
// If we have saved data, keep the toolbar at the same proportion of the screen width/height.
|
||||
that.move(savedFraction.x * screenSize.x, savedFraction.y * screenSize.y);
|
||||
|
|
|
@ -4885,6 +4885,10 @@ glm::uvec2 Application::getUiSize() const {
|
|||
return getActiveDisplayPlugin()->getRecommendedUiSize();
|
||||
}
|
||||
|
||||
glm::uvec4 Application::getRecommendedOverlayRect() const {
|
||||
return getActiveDisplayPlugin()->getRecommendedOverlayRect();
|
||||
}
|
||||
|
||||
QSize Application::getDeviceSize() const {
|
||||
return fromGlm(getActiveDisplayPlugin()->getRecommendedRenderSize());
|
||||
}
|
||||
|
|
|
@ -117,6 +117,7 @@ public:
|
|||
QRect getRenderingGeometry() const;
|
||||
|
||||
glm::uvec2 getUiSize() const;
|
||||
glm::uvec4 getRecommendedOverlayRect() const;
|
||||
QSize getDeviceSize() const;
|
||||
bool hasFocus() const;
|
||||
|
||||
|
|
|
@ -80,6 +80,11 @@ glm::vec2 ControllerScriptingInterface::getViewportDimensions() const {
|
|||
return qApp->getUiSize();
|
||||
}
|
||||
|
||||
glm::vec4 ControllerScriptingInterface::getRecommendedOverlayRect() const {
|
||||
auto rect = qApp->getRecommendedOverlayRect();
|
||||
return vec4(rect.x, rect.y, rect.z, rect.w);
|
||||
}
|
||||
|
||||
controller::InputController* ControllerScriptingInterface::createInputController(const QString& deviceName, const QString& tracker) {
|
||||
// This is where we retrieve the Device Tracker category and then the sub tracker within it
|
||||
auto icIt = _inputControllers.find(0);
|
||||
|
|
|
@ -96,6 +96,7 @@ public slots:
|
|||
virtual void releaseJoystick(int joystickIndex);
|
||||
|
||||
virtual glm::vec2 getViewportDimensions() const;
|
||||
virtual glm::vec4 getRecommendedOverlayRect() const;
|
||||
|
||||
/// Factory to create an InputController
|
||||
virtual controller::InputController* createInputController(const QString& deviceName, const QString& tracker);
|
||||
|
|
|
@ -34,6 +34,7 @@ static const float reticleSize = TWO_PI / 100.0f;
|
|||
static QString _tooltipId;
|
||||
|
||||
const uvec2 CompositorHelper::VIRTUAL_SCREEN_SIZE = uvec2(3960, 1188); // ~10% more pixel density than old version, 72dx240d FOV
|
||||
const uvec4 CompositorHelper::VIRTUAL_SCREEN_RECOMMENDED_OVERLAY_RECT = uvec4(956, 0, 3004, 1188); // don't include entire width only center 2048
|
||||
const float CompositorHelper::VIRTUAL_UI_ASPECT_RATIO = (float)VIRTUAL_SCREEN_SIZE.x / (float)VIRTUAL_SCREEN_SIZE.y;
|
||||
const vec2 CompositorHelper::VIRTUAL_UI_TARGET_FOV = vec2(PI * 3.0f / 2.0f, PI * 3.0f / 2.0f / VIRTUAL_UI_ASPECT_RATIO);
|
||||
const vec2 CompositorHelper::MOUSE_EXTENTS_ANGULAR_SIZE = vec2(PI * 2.0f, PI * 0.95f); // horizontal: full sphere, vertical: ~5deg from poles
|
||||
|
|
|
@ -42,6 +42,7 @@ class CompositorHelper : public QObject, public Dependency {
|
|||
Q_PROPERTY(bool reticleOverDesktop READ getReticleOverDesktop WRITE setReticleOverDesktop)
|
||||
public:
|
||||
static const uvec2 VIRTUAL_SCREEN_SIZE;
|
||||
static const uvec4 VIRTUAL_SCREEN_RECOMMENDED_OVERLAY_RECT;
|
||||
static const float VIRTUAL_UI_ASPECT_RATIO;
|
||||
static const vec2 VIRTUAL_UI_TARGET_FOV;
|
||||
static const vec2 MOUSE_EXTENTS_ANGULAR_SIZE;
|
||||
|
|
|
@ -34,6 +34,11 @@ glm::uvec2 HmdDisplayPlugin::getRecommendedUiSize() const {
|
|||
return CompositorHelper::VIRTUAL_SCREEN_SIZE;
|
||||
}
|
||||
|
||||
glm::uvec4 HmdDisplayPlugin::getRecommendedOverlayRect() const {
|
||||
return CompositorHelper::VIRTUAL_SCREEN_RECOMMENDED_OVERLAY_RECT;
|
||||
}
|
||||
|
||||
|
||||
bool HmdDisplayPlugin::internalActivate() {
|
||||
_monoPreview = _container->getBoolSetting("monoPreview", DEFAULT_MONO_VIEW);
|
||||
|
||||
|
|
|
@ -26,6 +26,8 @@ public:
|
|||
void setEyeRenderPose(uint32_t frameIndex, Eye eye, const glm::mat4& pose) override final;
|
||||
bool isDisplayVisible() const override { return isHmdMounted(); }
|
||||
|
||||
glm::uvec4 getRecommendedOverlayRect() const override final;
|
||||
|
||||
virtual glm::mat4 getHeadPose() const override;
|
||||
|
||||
|
||||
|
|
|
@ -105,6 +105,12 @@ public:
|
|||
return aspect(getRecommendedRenderSize());
|
||||
}
|
||||
|
||||
// The recommended bounds for primary overlay placement
|
||||
virtual glm::uvec4 getRecommendedOverlayRect() const {
|
||||
auto recommendedSize = getRecommendedUiSize();
|
||||
return glm::uvec4(0, 0, recommendedSize.x, recommendedSize.y);
|
||||
}
|
||||
|
||||
// Stereo specific methods
|
||||
virtual glm::mat4 getEyeProjection(Eye eye, const glm::mat4& baseProjection) const {
|
||||
return baseProjection;
|
||||
|
|
Loading…
Reference in a new issue