From f587398ca3ad6dd112675aeefb72c9f2ad4da1d2 Mon Sep 17 00:00:00 2001 From: samcake Date: Fri, 22 Apr 2016 18:00:22 -0700 Subject: [PATCH 01/15] Adding support for plate carree --- libraries/model/src/model/TextureMap.cpp | 154 +++++++++++++++++++++-- 1 file changed, 146 insertions(+), 8 deletions(-) diff --git a/libraries/model/src/model/TextureMap.cpp b/libraries/model/src/model/TextureMap.cpp index 7200793bed..b3b76fe982 100755 --- a/libraries/model/src/model/TextureMap.cpp +++ b/libraries/model/src/model/TextureMap.cpp @@ -413,9 +413,15 @@ gpu::Texture* TextureUsage::createMetallicTextureFromImage(const QImage& srcImag class CubeLayout { public: + + enum SourceProjection { + FLAT = 0, + EQUIRECTANGULAR, + }; + int _type = FLAT; int _widthRatio = 1; int _heightRatio = 1; - + class Face { public: int _x = 0; @@ -435,6 +441,7 @@ public: Face _faceZNeg; CubeLayout(int wr, int hr, Face fXP, Face fXN, Face fYP, Face fYN, Face fZP, Face fZN) : + _type(FLAT), _widthRatio(wr), _heightRatio(hr), _faceXPos(fXP), @@ -444,6 +451,11 @@ public: _faceZPos(fZP), _faceZNeg(fZN) {} + CubeLayout(int wr, int hr) : + _type(EQUIRECTANGULAR), + _widthRatio(wr), + _heightRatio(hr) {} + static const CubeLayout CUBEMAP_LAYOUTS[]; static const int NUM_CUBEMAP_LAYOUTS; @@ -459,9 +471,127 @@ public: } return foundLayout; } + + static QImage extractEquirectangularFace(const QImage& source, gpu::Texture::CubeFace face, int faceWidth) { + QImage image(faceWidth, faceWidth, source.format()); + glm::vec2 dstInvSize(1.0 / (float)image.width(), 1.0 / (float)image.height()); + float RAD_TO_SRC = 4.0f / glm::pi(); + + + if (face == gpu::Texture::CubeFace::CUBE_FACE_BOTTOM_NEG_Y || face == gpu::Texture::CubeFace::CUBE_FACE_TOP_POS_Y) { + int isTopFace = (face == gpu::Texture::CubeFace::CUBE_FACE_TOP_POS_Y); + int isBottomFace = (1 - isTopFace); + + const int SOURCE_FACE_X_OFFSET[] = { + 2, // Right +X + 0, // Left -X + 0, // top not used + 0, // bottom not used + 3, // Back +Z + 1 // Front -Z + }; + + int srcFaceHeight = source.height() / 4; + int srcYOffset = 0 + isBottomFace * source.height(); + + int srcFaceWidth = source.width(); + int srcXOffset = 0; + + glm::vec2 dstCoord; + glm::vec2 srcCoord; + glm::ivec2 srcPixel; + for (int y = 0; y < image.height(); ++y) { + auto data = reinterpret_cast(image.scanLine(y)); + dstCoord.y = -1.0 + 2.0 * (y + 0.5) * dstInvSize.y; + + for (int x = 0; x < image.width(); ++x) { + dstCoord.x = -1.0 + 2.0 * (x + 0.5) * dstInvSize.x; + + glm::vec2 dstCoordPol(atan2(dstCoord.y, dstCoord.x), glm::length(dstCoord)); + + srcCoord.x = dstCoordPol.y * RAD_TO_SRC / 8.0f; + srcCoord.y = atan(dstCoordPol.y) * RAD_TO_SRC; + if (isBottomFace) { + srcCoord.y -= srcCoord.y; + } + + srcPixel.x = floor(srcCoord.x * srcFaceHeight + srcXOffset); + srcPixel.y = floor(srcCoord.y * srcFaceWidth + srcYOffset); + + if (srcPixel.x >= source.width() || srcPixel.y >= source.height()) { + data[x] = QRgb(0); + } else { + data[x] = source.pixel(QPoint(srcPixel.x, srcPixel.y)); + } + } + } + + } else { + const int SOURCE_FACE_X_OFFSET[] = { + 2, // Right +X + 0, // Left -X + 0, // top not used + 0, // bottom not used + 3, // Back +Z + 1 // Front -Z + }; + + int srcFaceHeight = source.height() / 2; + int srcYOffset = srcFaceHeight; + + int srcFaceWidth = source.width() / 4; + int srcXOffset = SOURCE_FACE_X_OFFSET[face] * srcFaceWidth; + + glm::vec2 dstCoord; + glm::vec2 srcCoord; + glm::ivec2 srcPixel; + for (int y = 0; y < image.height(); ++y) { + auto data = reinterpret_cast(image.scanLine(y)); + dstCoord.y = (y + 0.5) * dstInvSize.y; + + srcCoord.y = 0.5f + 0.5f * atan(-1.0 + 2.0 * dstCoord.y) * RAD_TO_SRC; + + srcPixel.y = floor(srcCoord.y * srcFaceHeight) + srcYOffset; + + for (int x = 0; x < image.width(); ++x) { + dstCoord.x = (x + 0.5) * dstInvSize.x; + + srcCoord.x = 0.5f + 0.5f * atan(-1.0 + 2.0 * dstCoord.x) * RAD_TO_SRC; + + srcPixel.x = floor(srcCoord.x * srcFaceWidth) + srcXOffset; + + if (srcPixel.x >= source.width() || srcPixel.y >= source.height()) { + data[x] = 0xff000011; + } else { + data[x] = 0xff000000 | source.pixel(QPoint(srcPixel.x, srcPixel.y)); + } + } + } + } + + return image; + } }; const CubeLayout CubeLayout::CUBEMAP_LAYOUTS[] = { + + // Here is the expected layout for the faces in an image with the 2/1 aspect ratio: + // THis is detected as an Equirectangular projection + // WIDTH + // <---------------------------> + // ^ +------+------+------+------+ + // H | | | | | + // E | | | | | + // I | | | | | + // G +------+------+------+------+ + // H | | | | | + // T | | | | | + // | | | | | | + // v +------+------+------+------+ + // + // FaceWidth = width = height / 6 + { 2, 1 }, + // Here is the expected layout for the faces in an image with the 1/6 aspect ratio: // // WIDTH @@ -582,14 +712,22 @@ gpu::Texture* TextureUsage::processCubeTextureColorFromImage(const QImage& srcIm // If found, go extract the faces as separate images if (foundLayout >= 0) { auto& layout = CubeLayout::CUBEMAP_LAYOUTS[foundLayout]; - int faceWidth = image.width() / layout._widthRatio; + if (layout._type == CubeLayout::FLAT) { + int faceWidth = image.width() / layout._widthRatio; - faces.push_back(image.copy(QRect(layout._faceXPos._x * faceWidth, layout._faceXPos._y * faceWidth, faceWidth, faceWidth)).mirrored(layout._faceXPos._horizontalMirror, layout._faceXPos._verticalMirror)); - faces.push_back(image.copy(QRect(layout._faceXNeg._x * faceWidth, layout._faceXNeg._y * faceWidth, faceWidth, faceWidth)).mirrored(layout._faceXNeg._horizontalMirror, layout._faceXNeg._verticalMirror)); - faces.push_back(image.copy(QRect(layout._faceYPos._x * faceWidth, layout._faceYPos._y * faceWidth, faceWidth, faceWidth)).mirrored(layout._faceYPos._horizontalMirror, layout._faceYPos._verticalMirror)); - faces.push_back(image.copy(QRect(layout._faceYNeg._x * faceWidth, layout._faceYNeg._y * faceWidth, faceWidth, faceWidth)).mirrored(layout._faceYNeg._horizontalMirror, layout._faceYNeg._verticalMirror)); - faces.push_back(image.copy(QRect(layout._faceZPos._x * faceWidth, layout._faceZPos._y * faceWidth, faceWidth, faceWidth)).mirrored(layout._faceZPos._horizontalMirror, layout._faceZPos._verticalMirror)); - faces.push_back(image.copy(QRect(layout._faceZNeg._x * faceWidth, layout._faceZNeg._y * faceWidth, faceWidth, faceWidth)).mirrored(layout._faceZNeg._horizontalMirror, layout._faceZNeg._verticalMirror)); + faces.push_back(image.copy(QRect(layout._faceXPos._x * faceWidth, layout._faceXPos._y * faceWidth, faceWidth, faceWidth)).mirrored(layout._faceXPos._horizontalMirror, layout._faceXPos._verticalMirror)); + faces.push_back(image.copy(QRect(layout._faceXNeg._x * faceWidth, layout._faceXNeg._y * faceWidth, faceWidth, faceWidth)).mirrored(layout._faceXNeg._horizontalMirror, layout._faceXNeg._verticalMirror)); + faces.push_back(image.copy(QRect(layout._faceYPos._x * faceWidth, layout._faceYPos._y * faceWidth, faceWidth, faceWidth)).mirrored(layout._faceYPos._horizontalMirror, layout._faceYPos._verticalMirror)); + faces.push_back(image.copy(QRect(layout._faceYNeg._x * faceWidth, layout._faceYNeg._y * faceWidth, faceWidth, faceWidth)).mirrored(layout._faceYNeg._horizontalMirror, layout._faceYNeg._verticalMirror)); + faces.push_back(image.copy(QRect(layout._faceZPos._x * faceWidth, layout._faceZPos._y * faceWidth, faceWidth, faceWidth)).mirrored(layout._faceZPos._horizontalMirror, layout._faceZPos._verticalMirror)); + faces.push_back(image.copy(QRect(layout._faceZNeg._x * faceWidth, layout._faceZNeg._y * faceWidth, faceWidth, faceWidth)).mirrored(layout._faceZNeg._horizontalMirror, layout._faceZNeg._verticalMirror)); + } else if (layout._type == CubeLayout::EQUIRECTANGULAR) { + int faceWidth = image.width() / 4; + for (int face = gpu::Texture::CUBE_FACE_RIGHT_POS_X; face < gpu::Texture::NUM_CUBE_FACES; face++) { + faces.push_back(CubeLayout::extractEquirectangularFace(image, (gpu::Texture::CubeFace) face, faceWidth)); + } + + } } else { qCDebug(modelLog) << "Failed to find a known cube map layout from this image:" << QString(srcImageName.c_str()); return nullptr; From 3aec67bb364ae5ecd6907fd23fc152e284fc2fd6 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Sat, 23 Apr 2016 16:05:34 +1200 Subject: [PATCH 02/15] Position default toolbar buttons bottom center of screen Expand edit toolbar horizontally. --- examples/directory.js | 7 ++++--- examples/edit.js | 7 ++++--- examples/examples.js | 7 ++++--- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/examples/directory.js b/examples/directory.js index 243811c8d4..4af784d59e 100644 --- a/examples/directory.js +++ b/examples/directory.js @@ -27,6 +27,7 @@ var directoryWindow = new OverlayWebWindow({ var toolHeight = 50; var toolWidth = 50; +var TOOLBAR_MARGIN_Y = 25; function showDirectory() { @@ -53,10 +54,10 @@ var toolBar = (function() { browseDirectoryButton; function initialize() { - toolBar = new ToolBar(0, 0, ToolBar.VERTICAL, "highfidelity.directory.toolbar", function(windowDimensions, toolbar) { + toolBar = new ToolBar(0, 0, ToolBar.HORIZONTAL, "highfidelity.directory.toolbar", function(windowDimensions, toolbar) { return { - x: windowDimensions.x - 8 - toolbar.width, - y: 50 + x: windowDimensions.x / 2 - 3 * toolbar.height, // Use toolbar.height to match edit.js + y: windowDimensions.y - TOOLBAR_MARGIN_Y - toolHeight }; }); browseDirectoryButton = toolBar.addTool({ diff --git a/examples/edit.js b/examples/edit.js index f03915f5ad..929f8014dd 100644 --- a/examples/edit.js +++ b/examples/edit.js @@ -53,6 +53,7 @@ selectionManager.addEventListener(function() { var toolIconUrl = HIFI_PUBLIC_BUCKET + "images/tools/"; var toolHeight = 50; var toolWidth = 50; +var TOOLBAR_MARGIN_Y = 25; var DEGREES_TO_RADIANS = Math.PI / 180.0; var RADIANS_TO_DEGREES = 180.0 / Math.PI; @@ -179,10 +180,10 @@ var toolBar = (function() { newParticleButton function initialize() { - toolBar = new ToolBar(0, 0, ToolBar.VERTICAL, "highfidelity.edit.toolbar", function(windowDimensions, toolbar) { + toolBar = new ToolBar(0, 0, ToolBar.HORIZONTAL, "highfidelity.edit.toolbar", function(windowDimensions, toolbar) { return { - x: windowDimensions.x - 8 - toolbar.width, - y: (windowDimensions.y - toolbar.height) / 2 + x: windowDimensions.x / 2 + 2 * toolbar.height, // Use toolbar.height as a proxy for width of a single button + y: windowDimensions.y - TOOLBAR_MARGIN_Y - toolHeight }; }); diff --git a/examples/examples.js b/examples/examples.js index bfa85473de..1f764ebd8e 100644 --- a/examples/examples.js +++ b/examples/examples.js @@ -27,6 +27,7 @@ var examplesWindow = new OverlayWebWindow({ var toolHeight = 50; var toolWidth = 50; +var TOOLBAR_MARGIN_Y = 25; function showExamples(marketplaceID) { @@ -58,10 +59,10 @@ var toolBar = (function() { browseExamplesButton; function initialize() { - toolBar = new ToolBar(0, 0, ToolBar.VERTICAL, "highfidelity.examples.toolbar", function(windowDimensions, toolbar) { + toolBar = new ToolBar(0, 0, ToolBar.HORIXONTAL, "highfidelity.examples.toolbar", function(windowDimensions, toolbar) { return { - x: windowDimensions.x - 8 - toolbar.width, - y: 135 + x: windowDimensions.x / 2 - toolbar.height / 2, // Use toolbar.height to match edit.js + y: windowDimensions.y - TOOLBAR_MARGIN_Y - toolHeight }; }); browseExamplesButton = toolBar.addTool({ From 958c6f48c2665102d909e464f1893d1739356c8a Mon Sep 17 00:00:00 2001 From: David Rowe Date: Sat, 23 Apr 2016 18:16:20 +1200 Subject: [PATCH 03/15] Maintain relative spacing among toolbars as the window is resized --- examples/directory.js | 7 +++++-- examples/edit.js | 7 +++++-- examples/examples.js | 7 +++++-- examples/libraries/toolBars.js | 21 +++++++++++---------- 4 files changed, 26 insertions(+), 16 deletions(-) diff --git a/examples/directory.js b/examples/directory.js index 4af784d59e..ac426cafe7 100644 --- a/examples/directory.js +++ b/examples/directory.js @@ -56,9 +56,12 @@ var toolBar = (function() { function initialize() { toolBar = new ToolBar(0, 0, ToolBar.HORIZONTAL, "highfidelity.directory.toolbar", function(windowDimensions, toolbar) { return { - x: windowDimensions.x / 2 - 3 * toolbar.height, // Use toolbar.height to match edit.js - y: windowDimensions.y - TOOLBAR_MARGIN_Y - toolHeight + x: windowDimensions.x / 2, + y: windowDimensions.y }; + }, { + x: -2 * toolWidth, + y: -TOOLBAR_MARGIN_Y - toolHeight }); browseDirectoryButton = toolBar.addTool({ imageURL: toolIconUrl + "directory-01.svg", diff --git a/examples/edit.js b/examples/edit.js index 929f8014dd..c4c3b5a99b 100644 --- a/examples/edit.js +++ b/examples/edit.js @@ -182,9 +182,12 @@ var toolBar = (function() { function initialize() { toolBar = new ToolBar(0, 0, ToolBar.HORIZONTAL, "highfidelity.edit.toolbar", function(windowDimensions, toolbar) { return { - x: windowDimensions.x / 2 + 2 * toolbar.height, // Use toolbar.height as a proxy for width of a single button - y: windowDimensions.y - TOOLBAR_MARGIN_Y - toolHeight + x: windowDimensions.x / 2, + y: windowDimensions.y }; + }, { + x: toolWidth, + y: -TOOLBAR_MARGIN_Y - toolHeight }); activeButton = toolBar.addTool({ diff --git a/examples/examples.js b/examples/examples.js index 1f764ebd8e..90dca71f38 100644 --- a/examples/examples.js +++ b/examples/examples.js @@ -61,9 +61,12 @@ var toolBar = (function() { function initialize() { toolBar = new ToolBar(0, 0, ToolBar.HORIXONTAL, "highfidelity.examples.toolbar", function(windowDimensions, toolbar) { return { - x: windowDimensions.x / 2 - toolbar.height / 2, // Use toolbar.height to match edit.js - y: windowDimensions.y - TOOLBAR_MARGIN_Y - toolHeight + x: windowDimensions.x / 2, + y: windowDimensions.y }; + }, { + x: -toolWidth / 2, + y: -TOOLBAR_MARGIN_Y - toolHeight }); browseExamplesButton = toolBar.addTool({ imageURL: toolIconUrl + "examples-01.svg", diff --git a/examples/libraries/toolBars.js b/examples/libraries/toolBars.js index 6e54c0276c..4f560e6b8d 100644 --- a/examples/libraries/toolBars.js +++ b/examples/libraries/toolBars.js @@ -139,12 +139,13 @@ Tool.prototype = new Overlay2D; Tool.IMAGE_HEIGHT = 50; Tool.IMAGE_WIDTH = 50; -ToolBar = function(x, y, direction, optionalPersistenceKey, optionalInitialPositionFunction) { +ToolBar = function(x, y, direction, optionalPersistenceKey, optionalInitialPositionFunction, optionalOffset) { this.tools = new Array(); this.x = x; this.y = y; + this.offset = optionalOffset ? optionalOffset : { x: 0, y: 0 }; this.width = 0; - this.height = 0 + this.height = 0; this.backAlpha = 1.0; this.back = Overlays.addOverlay("rectangle", { color: { red: 255, green: 255, blue: 255 }, @@ -237,7 +238,7 @@ ToolBar = function(x, y, direction, optionalPersistenceKey, optionalInitialPosit } } - this.move = function(x, y) { + this.move = function (x, y) { var dx = x - this.x; var dy = y - this.y; this.x = x; @@ -370,14 +371,14 @@ ToolBar = function(x, y, direction, optionalPersistenceKey, optionalInitialPosit that.onResizeViewport = function (newSize) { // Can be overridden or extended by clients. var recommendedRect = Controller.getRecommendedOverlayRect(); var recommendedDimmensions = { x: recommendedRect.width, y: recommendedRect.height }; - var originRelativeX = (that.x - that.origin.x); - var originRelativeY = (that.y - that.origin.y); + var originRelativeX = (that.x - that.origin.x - that.offset.x); + var originRelativeY = (that.y - that.origin.y - that.offset.y); var fractionX = clamp(originRelativeX / that.windowDimensions.x, 0, 1); var fractionY = clamp(originRelativeY / that.windowDimensions.y, 0, 1); that.windowDimensions = newSize || recommendedDimmensions; that.origin = { x: recommendedRect.x, y: recommendedRect.y }; - var newX = (fractionX * that.windowDimensions.x) + recommendedRect.x; - var newY = (fractionY * that.windowDimensions.y) + recommendedRect.y; + var newX = (fractionX * that.windowDimensions.x) + recommendedRect.x + that.offset.x; + var newY = (fractionY * that.windowDimensions.y) + recommendedRect.y + that.offset.y; that.move(newX, newY); }; if (optionalPersistenceKey) { @@ -387,7 +388,7 @@ ToolBar = function(x, y, direction, optionalPersistenceKey, optionalInitialPosit var screenSize = { x: recommendedRect.width, y: recommendedRect.height }; 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}; + var fraction = {x: (that.x - that.offset.x) / screenSize.x, y: (that.y - that.offset.y) / screenSize.y}; Settings.setValue(this.fractionKey, JSON.stringify(fraction)); } } @@ -456,7 +457,7 @@ ToolBar = function(x, y, direction, optionalPersistenceKey, optionalInitialPosit var screenSize = { x: recommendedRect.width, y: recommendedRect.height }; 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); + that.move(savedFraction.x * screenSize.x + that.offset.x, savedFraction.y * screenSize.y + that.offset.y); } else if (!optionalInitialPositionFunction) { print("No initPosition(screenSize, intializedToolbar) specified for ToolBar"); } else { @@ -464,7 +465,7 @@ ToolBar = function(x, y, direction, optionalPersistenceKey, optionalInitialPosit var that = this; Script.setTimeout(function () { var position = optionalInitialPositionFunction(screenSize, that); - that.move(position.x, position.y); + that.move(position.x + that.offset.x, position.y + that.offset.y); }, 0); } } From 1066efc73754e074b7e850fb6cfbe272cc2d0d2d Mon Sep 17 00:00:00 2001 From: Thijs Wenker Date: Mon, 25 Apr 2016 17:12:32 +0200 Subject: [PATCH 04/15] - fix the settings window of Planky - set lifetime Planky blocks 60 minutes (per request of Ryan) --- examples/example/games/planky.js | 23 ++++++++++++++++------- examples/html/plankySettings.html | 22 +++++++++++++++------- 2 files changed, 31 insertions(+), 14 deletions(-) diff --git a/examples/example/games/planky.js b/examples/example/games/planky.js index 22388eba47..742cc3b7d0 100644 --- a/examples/example/games/planky.js +++ b/examples/example/games/planky.js @@ -10,9 +10,9 @@ // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -HIFI_PUBLIC_BUCKET = "http://s3.amazonaws.com/hifi-public/"; +HIFI_PUBLIC_BUCKET = 'http://s3.amazonaws.com/hifi-public/'; -Script.include("../../libraries/toolBars.js"); +Script.include('../../libraries/toolBars.js'); const DEFAULT_NUM_LAYERS = 16; const DEFAULT_BASE_DIMENSION = { x: 7, y: 2, z: 7 }; @@ -30,6 +30,8 @@ const DEFAULT_RESTITUTION = 0.0; const DEFAULT_SPAWN_DISTANCE = 3; const DEFAULT_BLOCK_YAW_OFFSET = 45; +const PLANKY_LIFETIME = 3600; // 1 hour (3600 seconds) + var editMode = false; const BUTTON_DIMENSIONS = {width: 49, height: 49}; @@ -51,13 +53,17 @@ SettingsWindow = function() { this.plankyStack = null; this.webWindow = null; this.init = function(plankyStack) { - _this.webWindow = new OverlayWebWindow('Planky', Script.resolvePath('../../html/plankySettings.html'), 255, 500, true); + _this.webWindow = new OverlayWebWindow({ + title: 'Planky', + source: Script.resolvePath('../../html/plankySettings.html'), + toolWindow: true + }); _this.webWindow.setVisible(false); - _this.webWindow.eventBridge.webEventReceived.connect(_this.onWebEventReceived); + _this.webWindow.webEventReceived.connect(_this.onWebEventReceived); _this.plankyStack = plankyStack; }; this.sendData = function(data) { - _this.webWindow.eventBridge.emitScriptEvent(JSON.stringify(data)); + _this.webWindow.emitScriptEvent(JSON.stringify(data)); }; this.onWebEventReceived = function(data) { data = JSON.parse(data); @@ -188,7 +194,8 @@ PlankyStack = function() { dimensions: _this.options.baseDimension, position: Vec3.sum(_this.basePosition, {y: -(_this.options.baseDimension.y / 2)}), rotation: _this.baseRotation, - shapeType: 'box' + shapeType: 'box', + lifetime: PLANKY_LIFETIME }); return; } @@ -254,7 +261,8 @@ PlankyStack = function() { density: _this.options.density, velocity: {x: 0, y: 0, z: 0}, angularVelocity: Quat.fromPitchYawRollDegrees(0, 0, 0), - collisionless: true + collisionless: true, + lifetime: PLANKY_LIFETIME }; _this.planks.forEach(function(plank, index, object) { if (plank.layer === layer && plank.row === row) { @@ -304,6 +312,7 @@ var settingsWindow = new SettingsWindow(); var plankyStack = new PlankyStack(); settingsWindow.init(plankyStack); +// This function is used to get the ideal y-location for a floor function grabLowestJointY() { var jointNames = MyAvatar.getJointNames(); var floorY = MyAvatar.position.y; diff --git a/examples/html/plankySettings.html b/examples/html/plankySettings.html index 0eea4948ad..836d5454b6 100644 --- a/examples/html/plankySettings.html +++ b/examples/html/plankySettings.html @@ -3,11 +3,15 @@ + +
- \ No newline at end of file + From b7f157f4ff50d806a5df93334626a360055e79cd Mon Sep 17 00:00:00 2001 From: "Anthony J. Thibault" Date: Mon, 25 Apr 2016 14:10:20 -0700 Subject: [PATCH 05/15] Reset avatar on exit of away-mode. Exposed MyAvatar.reset(bool) to script. away.js now calls this on exit of away-mode. --- examples/away.js | 1 + interface/src/avatar/MyAvatar.cpp | 9 +++++++-- interface/src/avatar/MyAvatar.h | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/examples/away.js b/examples/away.js index 9c5aed98fa..dee4f841b0 100644 --- a/examples/away.js +++ b/examples/away.js @@ -196,6 +196,7 @@ function goActive() { } MyAvatar.setEnableMeshVisible(true); // IWBNI we respected Developer->Avatar->Draw Mesh setting. stopAwayAnimation(); + MyAvatar.reset(true); hideOverlay(); // restore overlays state to what it was when we went "away" diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index 9a61c00712..a357cd879d 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -235,7 +235,12 @@ QByteArray MyAvatar::toByteArray(bool cullSmallChanges, bool sendAll) { return AvatarData::toByteArray(cullSmallChanges, sendAll); } -void MyAvatar::reset(bool andReload) { +void MyAvatar::reset(bool andRecenter) { + + if (QThread::currentThread() != thread()) { + QMetaObject::invokeMethod(this, "reset", Q_ARG(bool, andRecenter)); + return; + } // Reset dynamic state. _wasPushing = _isPushing = _isBraking = false; @@ -245,7 +250,7 @@ void MyAvatar::reset(bool andReload) { _targetVelocity = glm::vec3(0.0f); setThrust(glm::vec3(0.0f)); - if (andReload) { + if (andRecenter) { // derive the desired body orientation from the *old* hmd orientation, before the sensor reset. auto newBodySensorMatrix = deriveBodyFromHMDSensor(); // Based on current cached HMD position/rotation.. diff --git a/interface/src/avatar/MyAvatar.h b/interface/src/avatar/MyAvatar.h index 69bb7ea4c2..e320c0e3de 100644 --- a/interface/src/avatar/MyAvatar.h +++ b/interface/src/avatar/MyAvatar.h @@ -93,7 +93,7 @@ public: AudioListenerMode getAudioListenerModeCamera() const { return FROM_CAMERA; } AudioListenerMode getAudioListenerModeCustom() const { return CUSTOM; } - void reset(bool andReload = false); + Q_INVOKABLE void reset(bool andRecenter = false); void update(float deltaTime); void preRender(RenderArgs* renderArgs); From 0e13b1623b12bfec6ffe8731d31394ba50d9409a Mon Sep 17 00:00:00 2001 From: samcake Date: Mon, 25 Apr 2016 15:55:12 -0700 Subject: [PATCH 06/15] Adding support for Equirectangular skymaps --- libraries/model/src/model/TextureMap.cpp | 137 ++++++++++------------- 1 file changed, 59 insertions(+), 78 deletions(-) diff --git a/libraries/model/src/model/TextureMap.cpp b/libraries/model/src/model/TextureMap.cpp index b3b76fe982..6d5a4e7962 100755 --- a/libraries/model/src/model/TextureMap.cpp +++ b/libraries/model/src/model/TextureMap.cpp @@ -474,101 +474,81 @@ public: static QImage extractEquirectangularFace(const QImage& source, gpu::Texture::CubeFace face, int faceWidth) { QImage image(faceWidth, faceWidth, source.format()); + glm::vec2 dstInvSize(1.0 / (float)image.width(), 1.0 / (float)image.height()); float RAD_TO_SRC = 4.0f / glm::pi(); + struct CubeToXYZ { + gpu::Texture::CubeFace _face; + CubeToXYZ(gpu::Texture::CubeFace face) : _face(face) {} - if (face == gpu::Texture::CubeFace::CUBE_FACE_BOTTOM_NEG_Y || face == gpu::Texture::CubeFace::CUBE_FACE_TOP_POS_Y) { - int isTopFace = (face == gpu::Texture::CubeFace::CUBE_FACE_TOP_POS_Y); - int isBottomFace = (1 - isTopFace); + glm::vec3 xyzFrom(const glm::vec2& uv) { + auto nuv = glm::vec2(-1.0 + 2.0f * uv.x, 1.0 - 2.0f * uv.y); - const int SOURCE_FACE_X_OFFSET[] = { - 2, // Right +X - 0, // Left -X - 0, // top not used - 0, // bottom not used - 3, // Back +Z - 1 // Front -Z - }; - - int srcFaceHeight = source.height() / 4; - int srcYOffset = 0 + isBottomFace * source.height(); - - int srcFaceWidth = source.width(); - int srcXOffset = 0; - - glm::vec2 dstCoord; - glm::vec2 srcCoord; - glm::ivec2 srcPixel; - for (int y = 0; y < image.height(); ++y) { - auto data = reinterpret_cast(image.scanLine(y)); - dstCoord.y = -1.0 + 2.0 * (y + 0.5) * dstInvSize.y; - - for (int x = 0; x < image.width(); ++x) { - dstCoord.x = -1.0 + 2.0 * (x + 0.5) * dstInvSize.x; - - glm::vec2 dstCoordPol(atan2(dstCoord.y, dstCoord.x), glm::length(dstCoord)); - - srcCoord.x = dstCoordPol.y * RAD_TO_SRC / 8.0f; - srcCoord.y = atan(dstCoordPol.y) * RAD_TO_SRC; - if (isBottomFace) { - srcCoord.y -= srcCoord.y; - } - - srcPixel.x = floor(srcCoord.x * srcFaceHeight + srcXOffset); - srcPixel.y = floor(srcCoord.y * srcFaceWidth + srcYOffset); - - if (srcPixel.x >= source.width() || srcPixel.y >= source.height()) { - data[x] = QRgb(0); - } else { - data[x] = source.pixel(QPoint(srcPixel.x, srcPixel.y)); - } + switch (_face) { + case gpu::Texture::CubeFace::CUBE_FACE_BACK_POS_Z: + return glm::normalize(glm::vec3(-nuv.x, nuv.y, 1.0)); + case gpu::Texture::CubeFace::CUBE_FACE_FRONT_NEG_Z: + return glm::normalize(glm::vec3(nuv.x, nuv.y, -1.0)); + case gpu::Texture::CubeFace::CUBE_FACE_LEFT_NEG_X: + return glm::normalize(glm::vec3(1.0, nuv.y, nuv.x)); + case gpu::Texture::CubeFace::CUBE_FACE_RIGHT_POS_X: + return glm::normalize(glm::vec3(-1.0, nuv.y, -nuv.x)); + case gpu::Texture::CubeFace::CUBE_FACE_BOTTOM_NEG_Y: + return glm::normalize(glm::vec3(-nuv.x, -1.0, nuv.y)); + case gpu::Texture::CubeFace::CUBE_FACE_TOP_POS_Y: + default: + return glm::normalize(glm::vec3(-nuv.x, 1.0, -nuv.y)); } } - - } else { - const int SOURCE_FACE_X_OFFSET[] = { - 2, // Right +X - 0, // Left -X - 0, // top not used - 0, // bottom not used - 3, // Back +Z - 1 // Front -Z - }; + }; + CubeToXYZ cubeToXYZ(face); - int srcFaceHeight = source.height() / 2; - int srcYOffset = srcFaceHeight; - - int srcFaceWidth = source.width() / 4; - int srcXOffset = SOURCE_FACE_X_OFFSET[face] * srcFaceWidth; + struct RectToXYZ { + RectToXYZ() {} - glm::vec2 dstCoord; - glm::vec2 srcCoord; - glm::ivec2 srcPixel; - for (int y = 0; y < image.height(); ++y) { - auto data = reinterpret_cast(image.scanLine(y)); - dstCoord.y = (y + 0.5) * dstInvSize.y; + glm::vec2 uvFrom(const glm::vec3& xyz) { - srcCoord.y = 0.5f + 0.5f * atan(-1.0 + 2.0 * dstCoord.y) * RAD_TO_SRC; + auto flatDir = glm::normalize(glm::vec2(xyz.x, xyz.z)); + auto uvRad = glm::vec2( atan2(flatDir.x, flatDir.y), -asin(xyz.y)); - srcPixel.y = floor(srcCoord.y * srcFaceHeight) + srcYOffset; + const float LON_TO_RECT_U = 1.0f / (glm::pi()); + const float LAT_TO_RECT_V = 2.0f / glm::pi(); + return glm::vec2(0.5f * uvRad.x * LON_TO_RECT_U + 0.5f, 0.5f * uvRad.y * LAT_TO_RECT_V + 0.5f); + } + }; + RectToXYZ rectToXYZ; - for (int x = 0; x < image.width(); ++x) { - dstCoord.x = (x + 0.5) * dstInvSize.x; - srcCoord.x = 0.5f + 0.5f * atan(-1.0 + 2.0 * dstCoord.x) * RAD_TO_SRC; + int srcFaceHeight = source.height(); + int srcFaceWidth = source.width(); - srcPixel.x = floor(srcCoord.x * srcFaceWidth) + srcXOffset; + glm::vec2 dstCoord; + glm::ivec2 srcPixel; + for (int y = 0; y < faceWidth; ++y) { + dstCoord.y = (y + 0.5) * dstInvSize.y; - if (srcPixel.x >= source.width() || srcPixel.y >= source.height()) { - data[x] = 0xff000011; - } else { - data[x] = 0xff000000 | source.pixel(QPoint(srcPixel.x, srcPixel.y)); - } + for (int x = 0; x < faceWidth; ++x) { + dstCoord.x = (x + 0.5) * dstInvSize.x; + + auto xyzDir = cubeToXYZ.xyzFrom(dstCoord); + auto srcCoord = rectToXYZ.uvFrom(xyzDir); + + srcPixel.x = floor(srcCoord.x * srcFaceWidth); + srcPixel.y = floor(srcCoord.y * srcFaceHeight); + + if (((uint32)srcPixel.x >= (uint32)source.width()) || ((uint32) srcPixel.y >= (uint32) source.height()) ) { + //image.setPixel(x, y, 0xff000011); + } else { + image.setPixel(x, y, 0xff000000 | source.pixel(QPoint(srcPixel.x, srcPixel.y))); + + // Keep for debug, this is showing the dir as a color + // glm::u8vec4 rgba((xyzDir.x + 1.0)*0.5 * 256, (xyzDir.y + 1.0)*0.5 * 256, (xyzDir.z + 1.0)*0.5 * 256, 256); + // unsigned int val = 0xff000000 | (rgba.r) | (rgba.g << 8) | (rgba.b << 16); + // image.setPixel(x, y, val); } } } - return image; } }; @@ -724,7 +704,8 @@ gpu::Texture* TextureUsage::processCubeTextureColorFromImage(const QImage& srcIm } else if (layout._type == CubeLayout::EQUIRECTANGULAR) { int faceWidth = image.width() / 4; for (int face = gpu::Texture::CUBE_FACE_RIGHT_POS_X; face < gpu::Texture::NUM_CUBE_FACES; face++) { - faces.push_back(CubeLayout::extractEquirectangularFace(image, (gpu::Texture::CubeFace) face, faceWidth)); + QImage faceImage = CubeLayout::extractEquirectangularFace(image, (gpu::Texture::CubeFace) face, faceWidth); + faces.push_back(faceImage); } } From e8691c2f200c0ebf9c09d2dc80c25f2cc6886ad7 Mon Sep 17 00:00:00 2001 From: samcake Date: Mon, 25 Apr 2016 18:15:52 -0700 Subject: [PATCH 07/15] Fixing comments, code style and constnats --- libraries/model/src/model/TextureMap.cpp | 52 ++++++++++++------------ 1 file changed, 25 insertions(+), 27 deletions(-) diff --git a/libraries/model/src/model/TextureMap.cpp b/libraries/model/src/model/TextureMap.cpp index 6d5a4e7962..f1b2bb6a54 100755 --- a/libraries/model/src/model/TextureMap.cpp +++ b/libraries/model/src/model/TextureMap.cpp @@ -475,30 +475,29 @@ public: static QImage extractEquirectangularFace(const QImage& source, gpu::Texture::CubeFace face, int faceWidth) { QImage image(faceWidth, faceWidth, source.format()); - glm::vec2 dstInvSize(1.0 / (float)image.width(), 1.0 / (float)image.height()); - float RAD_TO_SRC = 4.0f / glm::pi(); + glm::vec2 dstInvSize(1.0f / (float)image.width(), 1.0f / (float)image.height()); struct CubeToXYZ { gpu::Texture::CubeFace _face; CubeToXYZ(gpu::Texture::CubeFace face) : _face(face) {} glm::vec3 xyzFrom(const glm::vec2& uv) { - auto nuv = glm::vec2(-1.0 + 2.0f * uv.x, 1.0 - 2.0f * uv.y); + auto faceDir = glm::normalize(glm::vec3(-1.0f + 2.0f * uv.x, -1.0f + 2.0f * uv.y, 1.0f)); switch (_face) { - case gpu::Texture::CubeFace::CUBE_FACE_BACK_POS_Z: - return glm::normalize(glm::vec3(-nuv.x, nuv.y, 1.0)); - case gpu::Texture::CubeFace::CUBE_FACE_FRONT_NEG_Z: - return glm::normalize(glm::vec3(nuv.x, nuv.y, -1.0)); - case gpu::Texture::CubeFace::CUBE_FACE_LEFT_NEG_X: - return glm::normalize(glm::vec3(1.0, nuv.y, nuv.x)); - case gpu::Texture::CubeFace::CUBE_FACE_RIGHT_POS_X: - return glm::normalize(glm::vec3(-1.0, nuv.y, -nuv.x)); - case gpu::Texture::CubeFace::CUBE_FACE_BOTTOM_NEG_Y: - return glm::normalize(glm::vec3(-nuv.x, -1.0, nuv.y)); - case gpu::Texture::CubeFace::CUBE_FACE_TOP_POS_Y: - default: - return glm::normalize(glm::vec3(-nuv.x, 1.0, -nuv.y)); + case gpu::Texture::CubeFace::CUBE_FACE_BACK_POS_Z: + return glm::vec3(-faceDir.x, faceDir.y, faceDir.z); + case gpu::Texture::CubeFace::CUBE_FACE_FRONT_NEG_Z: + return glm::vec3(faceDir.x, faceDir.y, -faceDir.z); + case gpu::Texture::CubeFace::CUBE_FACE_LEFT_NEG_X: + return glm::vec3(faceDir.z, faceDir.y, faceDir.x); + case gpu::Texture::CubeFace::CUBE_FACE_RIGHT_POS_X: + return glm::vec3(-faceDir.z, faceDir.y, -faceDir.x); + case gpu::Texture::CubeFace::CUBE_FACE_BOTTOM_NEG_Y: + return glm::vec3(-faceDir.x, -faceDir.z, faceDir.y); + case gpu::Texture::CubeFace::CUBE_FACE_TOP_POS_Y: + default: + return glm::vec3(-faceDir.x, faceDir.z, -faceDir.y); } } }; @@ -511,6 +510,7 @@ public: auto flatDir = glm::normalize(glm::vec2(xyz.x, xyz.z)); auto uvRad = glm::vec2( atan2(flatDir.x, flatDir.y), -asin(xyz.y)); + // Flip the vertical axis to QImage going top to bottom const float LON_TO_RECT_U = 1.0f / (glm::pi()); const float LAT_TO_RECT_V = 2.0f / glm::pi(); @@ -519,17 +519,15 @@ public: }; RectToXYZ rectToXYZ; - - int srcFaceHeight = source.height(); + int srcFaceHeight = source.height(); int srcFaceWidth = source.width(); glm::vec2 dstCoord; glm::ivec2 srcPixel; for (int y = 0; y < faceWidth; ++y) { - dstCoord.y = (y + 0.5) * dstInvSize.y; - + dstCoord.y = 1.0 - (y + 0.5f) * dstInvSize.y; // Fill cube face images from top to bottom for (int x = 0; x < faceWidth; ++x) { - dstCoord.x = (x + 0.5) * dstInvSize.x; + dstCoord.x = (x + 0.5f) * dstInvSize.x; auto xyzDir = cubeToXYZ.xyzFrom(dstCoord); auto srcCoord = rectToXYZ.uvFrom(xyzDir); @@ -537,10 +535,8 @@ public: srcPixel.x = floor(srcCoord.x * srcFaceWidth); srcPixel.y = floor(srcCoord.y * srcFaceHeight); - if (((uint32)srcPixel.x >= (uint32)source.width()) || ((uint32) srcPixel.y >= (uint32) source.height()) ) { - //image.setPixel(x, y, 0xff000011); - } else { - image.setPixel(x, y, 0xff000000 | source.pixel(QPoint(srcPixel.x, srcPixel.y))); + if (((uint32) srcPixel.x < (uint32) source.width()) && ((uint32) srcPixel.y < (uint32) source.height())) { + image.setPixel(x, y, source.pixel(QPoint(srcPixel.x, srcPixel.y))); // Keep for debug, this is showing the dir as a color // glm::u8vec4 rgba((xyzDir.x + 1.0)*0.5 * 256, (xyzDir.y + 1.0)*0.5 * 256, (xyzDir.z + 1.0)*0.5 * 256, 256); @@ -702,12 +698,14 @@ gpu::Texture* TextureUsage::processCubeTextureColorFromImage(const QImage& srcIm faces.push_back(image.copy(QRect(layout._faceZPos._x * faceWidth, layout._faceZPos._y * faceWidth, faceWidth, faceWidth)).mirrored(layout._faceZPos._horizontalMirror, layout._faceZPos._verticalMirror)); faces.push_back(image.copy(QRect(layout._faceZNeg._x * faceWidth, layout._faceZNeg._y * faceWidth, faceWidth, faceWidth)).mirrored(layout._faceZNeg._horizontalMirror, layout._faceZNeg._verticalMirror)); } else if (layout._type == CubeLayout::EQUIRECTANGULAR) { - int faceWidth = image.width() / 4; + // THe face width is estimated from the input image + const int EQUIRECT_FACE_RATIO_TO_WIDTH = 4; + const int EQUIRECT_MAX_FACE_WIDTH = 2048; + int faceWidth = std::min(image.width() / EQUIRECT_FACE_RATIO_TO_WIDTH, EQUIRECT_MAX_FACE_WIDTH); for (int face = gpu::Texture::CUBE_FACE_RIGHT_POS_X; face < gpu::Texture::NUM_CUBE_FACES; face++) { QImage faceImage = CubeLayout::extractEquirectangularFace(image, (gpu::Texture::CubeFace) face, faceWidth); faces.push_back(faceImage); } - } } else { qCDebug(modelLog) << "Failed to find a known cube map layout from this image:" << QString(srcImageName.c_str()); From 8f2435daf0d73e2b6f83d1dd6992e3ecf4d3c61b Mon Sep 17 00:00:00 2001 From: samcake Date: Mon, 25 Apr 2016 18:39:37 -0700 Subject: [PATCH 08/15] No more warnings ? --- libraries/model/src/model/TextureMap.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/libraries/model/src/model/TextureMap.cpp b/libraries/model/src/model/TextureMap.cpp index f1b2bb6a54..6eddf6013a 100755 --- a/libraries/model/src/model/TextureMap.cpp +++ b/libraries/model/src/model/TextureMap.cpp @@ -507,10 +507,8 @@ public: RectToXYZ() {} glm::vec2 uvFrom(const glm::vec3& xyz) { - auto flatDir = glm::normalize(glm::vec2(xyz.x, xyz.z)); - auto uvRad = glm::vec2( atan2(flatDir.x, flatDir.y), -asin(xyz.y)); - // Flip the vertical axis to QImage going top to bottom + auto uvRad = glm::vec2(atan2(flatDir.x, flatDir.y), asin(xyz.y)); const float LON_TO_RECT_U = 1.0f / (glm::pi()); const float LAT_TO_RECT_V = 2.0f / glm::pi(); @@ -525,7 +523,7 @@ public: glm::vec2 dstCoord; glm::ivec2 srcPixel; for (int y = 0; y < faceWidth; ++y) { - dstCoord.y = 1.0 - (y + 0.5f) * dstInvSize.y; // Fill cube face images from top to bottom + dstCoord.y = 1.0f - (y + 0.5f) * dstInvSize.y; // Fill cube face images from top to bottom for (int x = 0; x < faceWidth; ++x) { dstCoord.x = (x + 0.5f) * dstInvSize.x; @@ -533,7 +531,8 @@ public: auto srcCoord = rectToXYZ.uvFrom(xyzDir); srcPixel.x = floor(srcCoord.x * srcFaceWidth); - srcPixel.y = floor(srcCoord.y * srcFaceHeight); + // Flip the vertical axis to QImage going top to bottom + srcPixel.y = floor((1.0 - srcCoord.y) * srcFaceHeight); if (((uint32) srcPixel.x < (uint32) source.width()) && ((uint32) srcPixel.y < (uint32) source.height())) { image.setPixel(x, y, source.pixel(QPoint(srcPixel.x, srcPixel.y))); From 91bed86b321379d84f8cfcf784506547df7ed77c Mon Sep 17 00:00:00 2001 From: samcake Date: Mon, 25 Apr 2016 19:04:02 -0700 Subject: [PATCH 09/15] ANd one more warning --- libraries/model/src/model/TextureMap.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/model/src/model/TextureMap.cpp b/libraries/model/src/model/TextureMap.cpp index 6eddf6013a..349980b702 100755 --- a/libraries/model/src/model/TextureMap.cpp +++ b/libraries/model/src/model/TextureMap.cpp @@ -532,7 +532,7 @@ public: srcPixel.x = floor(srcCoord.x * srcFaceWidth); // Flip the vertical axis to QImage going top to bottom - srcPixel.y = floor((1.0 - srcCoord.y) * srcFaceHeight); + srcPixel.y = floor((1.0f - srcCoord.y) * srcFaceHeight); if (((uint32) srcPixel.x < (uint32) source.width()) && ((uint32) srcPixel.y < (uint32) source.height())) { image.setPixel(x, y, source.pixel(QPoint(srcPixel.x, srcPixel.y))); From 4ab7b660d44e3e6095a19d583575b56c3738d998 Mon Sep 17 00:00:00 2001 From: Brad Hefta-Gaub Date: Mon, 25 Apr 2016 20:19:54 -0700 Subject: [PATCH 10/15] fix a bunch of bugs in qml window placement --- interface/resources/qml/AssetServer.qml | 1 - interface/resources/qml/AvatarInputs.qml | 2 +- interface/resources/qml/InfoView.qml | 18 ++++ interface/resources/qml/desktop/Desktop.qml | 89 +++++++++++++++++-- .../qml/hifi/dialogs/RunningScripts.qml | 1 - .../resources/qml/windows-uit/Window.qml | 16 +++- interface/resources/qml/windows/Window.qml | 16 +++- interface/src/Application.cpp | 1 + libraries/plugins/src/plugins/DisplayPlugin.h | 3 +- 9 files changed, 134 insertions(+), 13 deletions(-) diff --git a/interface/resources/qml/AssetServer.qml b/interface/resources/qml/AssetServer.qml index 495d13d118..370bc92d81 100644 --- a/interface/resources/qml/AssetServer.qml +++ b/interface/resources/qml/AssetServer.qml @@ -24,7 +24,6 @@ Window { title: "Asset Browser" resizable: true destroyOnInvisible: true - x: 40; y: 40 implicitWidth: 384; implicitHeight: 640 minSize: Qt.vector2d(200, 300) diff --git a/interface/resources/qml/AvatarInputs.qml b/interface/resources/qml/AvatarInputs.qml index 75f379a425..4150979cd4 100644 --- a/interface/resources/qml/AvatarInputs.qml +++ b/interface/resources/qml/AvatarInputs.qml @@ -25,7 +25,7 @@ Hifi.AvatarInputs { readonly property int iconPadding: 5 readonly property bool shouldReposition: true - + Settings { category: "Overlay.AvatarInputs" property alias x: root.x diff --git a/interface/resources/qml/InfoView.qml b/interface/resources/qml/InfoView.qml index bc268baeb4..025cc6cc59 100644 --- a/interface/resources/qml/InfoView.qml +++ b/interface/resources/qml/InfoView.qml @@ -22,4 +22,22 @@ Windows.Window { url: infoView.url } } + + Component.onCompleted: { + //console.log("InfoView.Component.onCompleted"); + centerWindow(root); + } + + + onVisibleChanged: { + if (visible) { + centerWindow(root); + } + } + + function centerWindow() { + //console.log("InfoView.Component.centerWindow"); + desktop.centerOnVisible(root); + } + } diff --git a/interface/resources/qml/desktop/Desktop.qml b/interface/resources/qml/desktop/Desktop.qml index c0804a967d..2a2c6b5d24 100644 --- a/interface/resources/qml/desktop/Desktop.qml +++ b/interface/resources/qml/desktop/Desktop.qml @@ -21,7 +21,8 @@ FocusScope { objectName: "desktop" anchors.fill: parent - property rect recommendedRect: rect(0,0,0,0); + property rect recommendedRect: Qt.rect(0,0,0,0); + property var expectedChildren; onHeightChanged: d.handleSizeChanged(); @@ -55,14 +56,28 @@ FocusScope { function handleSizeChanged() { var oldRecommendedRect = recommendedRect; - var newRecommendedRectJS = Controller.getRecommendedOverlayRect(); + var newRecommendedRectJS = (typeof Controller === "undefined") ? Qt.rect(0,0,0,0) : Controller.getRecommendedOverlayRect(); var newRecommendedRect = Qt.rect(newRecommendedRectJS.x, newRecommendedRectJS.y, newRecommendedRectJS.width, newRecommendedRectJS.height); - if (oldRecommendedRect != Qt.rect(0,0,0,0) - && oldRecommendedRect != newRecommendedRect) { + var oldChildren = expectedChildren; + var newChildren = d.getRepositionChildren(); + + //console.log("handleSizeChanged() - oldChildren:" + oldChildren); + //console.log("handleSizeChanged() - newChildren:" + newChildren); + //console.log("handleSizeChanged() - oldRecommendedRect:" + oldRecommendedRect); + //console.log("handleSizeChanged() - newRecommendedRect:" + newRecommendedRect); + + if (oldRecommendedRect != Qt.rect(0,0,0,0) + && (oldRecommendedRect != newRecommendedRect + || oldChildren != newChildren) + ) { + expectedChildren = newChildren; + //console.log("handleSizeChanged() - calling repositionAll()"); d.repositionAll(); + } else { + //console.log("handleSizeChanged() - DID NOT CALL repositionAll()"); } recommendedRect = newRecommendedRect; } @@ -244,6 +259,7 @@ FocusScope { for (var i = 0; i < windows.length; ++i) { var targetWindow = windows[i]; if (targetWindow.visible) { + //console.log("repositionAll() about to repositionWindow() targetWindow:" + targetWindow); repositionWindow(targetWindow, true, oldRecommendedRect, oldRecommendedDimmensions, newRecommendedRect, newRecommendedDimmensions); } } @@ -252,6 +268,7 @@ FocusScope { var otherChildren = d.getRepositionChildren(); for (var i = 0; i < otherChildren.length; ++i) { var child = otherChildren[i]; + //console.log("repositionAll() about to repositionWindow() child:" + child); repositionWindow(child, true, oldRecommendedRect, oldRecommendedDimmensions, newRecommendedRect, newRecommendedDimmensions); } @@ -279,13 +296,66 @@ FocusScope { targetWindow.focus = true; } + showDesktop(); + } + + function centerOnVisible(item) { + //console.log("centerOnVisible() item:" + item); + var targetWindow = d.getDesktopWindow(item); + //console.log("centerOnVisible() targetWindow:" + targetWindow ); + if (!targetWindow) { + console.warn("Could not find top level window for " + item); + return; + } + + if (typeof Controller === "undefined") { + console.warn("Controller not yet available... can't center"); + return; + } + + var newRecommendedRectJS = (typeof Controller === "undefined") ? Qt.rect(0,0,0,0) : Controller.getRecommendedOverlayRect(); + var newRecommendedRect = Qt.rect(newRecommendedRectJS.x, newRecommendedRectJS.y, + newRecommendedRectJS.width, + newRecommendedRectJS.height); + var newRecommendedDimmensions = { x: newRecommendedRect.width, y: newRecommendedRect.height }; + var newX = newRecommendedRect.x + ((newRecommendedRect.width - targetWindow.width) / 2); + var newY = newRecommendedRect.y + ((newRecommendedRect.height - targetWindow.height) / 2); + + //console.log("centerOnVisible() newRecommendedRect:" + newRecommendedRect.x + "," + newRecommendedRect.y + "/" + newRecommendedRect.width + "x" + newRecommendedRect.height); + //console.log("centerOnVisible() newX/newY:" + newX + "," + newY); + + targetWindow.x = newX; + targetWindow.y = newY; + + if (recommendedRect != newRecommendedRect) { + //console.log("centerOnVisible() -- detected new recommended rect"); + //console.log("old recommendedRect:" + recommendedRect); + //console.log("newRecommendedRect:" + newRecommendedRect); + recommendedRect = newRecommendedRect; + } + + } + + function repositionOnVisible(item) { + console.warn("repositionOnVisible() item:" + item); + var targetWindow = d.getDesktopWindow(item); + console.warn("repositionOnVisible() targetWindow:" + targetWindow); + if (!targetWindow) { + console.warn("Could not find top level window for " + item); + return; + } + + if (typeof Controller === "undefined") { + console.warn("Controller not yet available... can't reposition targetWindow:" + targetWindow); + return; + } + + var oldRecommendedRect = recommendedRect; var oldRecommendedDimmensions = { x: oldRecommendedRect.width, y: oldRecommendedRect.height }; var newRecommendedRect = Controller.getRecommendedOverlayRect(); var newRecommendedDimmensions = { x: newRecommendedRect.width, y: newRecommendedRect.height }; repositionWindow(targetWindow, false, oldRecommendedRect, oldRecommendedDimmensions, newRecommendedRect, newRecommendedDimmensions); - - showDesktop(); } function repositionWindow(targetWindow, forceReposition, @@ -324,10 +394,15 @@ FocusScope { } var fractionX = Utils.clamp(originRelativeX / oldRecommendedDimmensions.x, 0, 1); var fractionY = Utils.clamp(originRelativeY / oldRecommendedDimmensions.y, 0, 1); - var newX = (fractionX * newRecommendedDimmensions.x) + newRecommendedRect.x; var newY = (fractionY * newRecommendedDimmensions.y) + newRecommendedRect.y; + //console.log("repositionWindow() oldRecommendedRect:" + oldRecommendedRect.x + "," + oldRecommendedRect.y + "/" + oldRecommendedRect.width + "x" + oldRecommendedRect.height); + //console.log("repositionWindow() newRecommendedRect:" + newRecommendedRect.x + "," + newRecommendedRect.y + "/" + newRecommendedRect.width + "x" + newRecommendedRect.height); + //console.log("repositionWindow() originRelativeX/originRelativeY:" + originRelativeX + "," + originRelativeY); + //console.log("repositionWindow() fractionX/fractionY:" + fractionX + "," + fractionY); + //console.log("repositionWindow() newX/newY:" + newX + "," + newY); + newPosition = Qt.vector2d(newX, newY); } targetWindow.x = newPosition.x; diff --git a/interface/resources/qml/hifi/dialogs/RunningScripts.qml b/interface/resources/qml/hifi/dialogs/RunningScripts.qml index 9b35d55f11..071789fe16 100644 --- a/interface/resources/qml/hifi/dialogs/RunningScripts.qml +++ b/interface/resources/qml/hifi/dialogs/RunningScripts.qml @@ -23,7 +23,6 @@ Window { title: "Running Scripts" resizable: true destroyOnInvisible: true - x: 40; y: 40 implicitWidth: 400 implicitHeight: isHMD ? 695 : 728 minSize: Qt.vector2d(200, 300) diff --git a/interface/resources/qml/windows-uit/Window.qml b/interface/resources/qml/windows-uit/Window.qml index dbbf2b3eb6..59d5dcd70e 100644 --- a/interface/resources/qml/windows-uit/Window.qml +++ b/interface/resources/qml/windows-uit/Window.qml @@ -31,7 +31,7 @@ Fadable { // decorations can extend outside it. implicitHeight: content ? content.height : 0 implicitWidth: content ? content.width : 0 - x: -1; y: -1 + x: -9999; y: -9999 enabled: visible signal windowDestroyed(); @@ -249,9 +249,11 @@ Fadable { children: [ swallower, frame, pane, activator ] Component.onCompleted: { + //console.log("Window(uit).Component.onCompleted window:" + window); window.parentChanged.connect(raise); raise(); setDefaultFocus(); + centerOrReposition(); } Component.onDestruction: { window.parentChanged.disconnect(raise); // Prevent warning on shutdown @@ -267,6 +269,18 @@ Fadable { raise(); } enabled = visible + + if (visible && parent) { + centerOrReposition(); + } + } + + function centerOrReposition() { + if (x == -9999 && y == -9999) { + desktop.centerOnVisible(window); + } else { + desktop.repositionOnVisible(window); + } } function raise() { diff --git a/interface/resources/qml/windows/Window.qml b/interface/resources/qml/windows/Window.qml index 06be0cd9e7..c24f4a3b9b 100644 --- a/interface/resources/qml/windows/Window.qml +++ b/interface/resources/qml/windows/Window.qml @@ -19,7 +19,7 @@ Fadable { // decorations can extend outside it. implicitHeight: content ? content.height : 0 implicitWidth: content ? content.width : 0 - x: -1; y: -1 + x: -9999; y: -9999 enabled: visible signal windowDestroyed(); @@ -115,14 +115,24 @@ Fadable { children: [ swallower, frame, content, activator ] Component.onCompleted: { + //console.log("Window(uit).Component.onCompleted window:" + window); window.parentChanged.connect(raise); raise(); + centerOrReposition(); } Component.onDestruction: { window.parentChanged.disconnect(raise); // Prevent warning on shutdown windowDestroyed(); } + function centerOrReposition() { + if (x == -9999 && y == -9999) { + desktop.centerOnVisible(window); + } else { + desktop.repositionOnVisible(window); + } + } + onVisibleChanged: { if (!visible && destroyOnInvisible) { destroy(); @@ -132,6 +142,10 @@ Fadable { raise(); } enabled = visible + + if (visible && parent) { + centerOrReposition(); + } } function raise() { diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index fcf1425287..c2a4088dcc 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -4315,6 +4315,7 @@ void Application::nodeKilled(SharedNodePointer node) { } } } + void Application::trackIncomingOctreePacket(ReceivedMessage& message, SharedNodePointer sendingNode, bool wasStatsPacket) { // Attempt to identify the sender from its address. if (sendingNode) { diff --git a/libraries/plugins/src/plugins/DisplayPlugin.h b/libraries/plugins/src/plugins/DisplayPlugin.h index 64a73ab12a..91dcf9398f 100644 --- a/libraries/plugins/src/plugins/DisplayPlugin.h +++ b/libraries/plugins/src/plugins/DisplayPlugin.h @@ -107,7 +107,8 @@ public: // The recommended bounds for primary overlay placement virtual QRect getRecommendedOverlayRect() const { - auto recommendedSize = getRecommendedUiSize(); + const int DESKTOP_SCREEN_PADDING = 50; + auto recommendedSize = getRecommendedUiSize() - glm::uvec2(DESKTOP_SCREEN_PADDING); return QRect(0, 0, recommendedSize.x, recommendedSize.y); } From 716d9e554c90802d622a7ae3f70e309fbb7d9c57 Mon Sep 17 00:00:00 2001 From: Brad Hefta-Gaub Date: Tue, 26 Apr 2016 09:25:28 -0700 Subject: [PATCH 11/15] removed a bunch of dead code --- interface/resources/qml/InfoView.qml | 3 -- interface/resources/qml/desktop/Desktop.qml | 28 +------------------ .../resources/qml/windows-uit/Window.qml | 1 - interface/resources/qml/windows/Window.qml | 1 - 4 files changed, 1 insertion(+), 32 deletions(-) diff --git a/interface/resources/qml/InfoView.qml b/interface/resources/qml/InfoView.qml index 025cc6cc59..2e93c401d4 100644 --- a/interface/resources/qml/InfoView.qml +++ b/interface/resources/qml/InfoView.qml @@ -24,11 +24,9 @@ Windows.Window { } Component.onCompleted: { - //console.log("InfoView.Component.onCompleted"); centerWindow(root); } - onVisibleChanged: { if (visible) { centerWindow(root); @@ -36,7 +34,6 @@ Windows.Window { } function centerWindow() { - //console.log("InfoView.Component.centerWindow"); desktop.centerOnVisible(root); } diff --git a/interface/resources/qml/desktop/Desktop.qml b/interface/resources/qml/desktop/Desktop.qml index 2a2c6b5d24..f24f822f49 100644 --- a/interface/resources/qml/desktop/Desktop.qml +++ b/interface/resources/qml/desktop/Desktop.qml @@ -63,21 +63,12 @@ FocusScope { var oldChildren = expectedChildren; var newChildren = d.getRepositionChildren(); - - //console.log("handleSizeChanged() - oldChildren:" + oldChildren); - //console.log("handleSizeChanged() - newChildren:" + newChildren); - //console.log("handleSizeChanged() - oldRecommendedRect:" + oldRecommendedRect); - //console.log("handleSizeChanged() - newRecommendedRect:" + newRecommendedRect); - if (oldRecommendedRect != Qt.rect(0,0,0,0) && (oldRecommendedRect != newRecommendedRect || oldChildren != newChildren) ) { expectedChildren = newChildren; - //console.log("handleSizeChanged() - calling repositionAll()"); d.repositionAll(); - } else { - //console.log("handleSizeChanged() - DID NOT CALL repositionAll()"); } recommendedRect = newRecommendedRect; } @@ -259,7 +250,6 @@ FocusScope { for (var i = 0; i < windows.length; ++i) { var targetWindow = windows[i]; if (targetWindow.visible) { - //console.log("repositionAll() about to repositionWindow() targetWindow:" + targetWindow); repositionWindow(targetWindow, true, oldRecommendedRect, oldRecommendedDimmensions, newRecommendedRect, newRecommendedDimmensions); } } @@ -268,7 +258,6 @@ FocusScope { var otherChildren = d.getRepositionChildren(); for (var i = 0; i < otherChildren.length; ++i) { var child = otherChildren[i]; - //console.log("repositionAll() about to repositionWindow() child:" + child); repositionWindow(child, true, oldRecommendedRect, oldRecommendedDimmensions, newRecommendedRect, newRecommendedDimmensions); } @@ -300,9 +289,7 @@ FocusScope { } function centerOnVisible(item) { - //console.log("centerOnVisible() item:" + item); var targetWindow = d.getDesktopWindow(item); - //console.log("centerOnVisible() targetWindow:" + targetWindow ); if (!targetWindow) { console.warn("Could not find top level window for " + item); return; @@ -320,17 +307,11 @@ FocusScope { var newRecommendedDimmensions = { x: newRecommendedRect.width, y: newRecommendedRect.height }; var newX = newRecommendedRect.x + ((newRecommendedRect.width - targetWindow.width) / 2); var newY = newRecommendedRect.y + ((newRecommendedRect.height - targetWindow.height) / 2); - - //console.log("centerOnVisible() newRecommendedRect:" + newRecommendedRect.x + "," + newRecommendedRect.y + "/" + newRecommendedRect.width + "x" + newRecommendedRect.height); - //console.log("centerOnVisible() newX/newY:" + newX + "," + newY); - targetWindow.x = newX; targetWindow.y = newY; + // If we've noticed that our recommended desktop rect has changed, record that change here. if (recommendedRect != newRecommendedRect) { - //console.log("centerOnVisible() -- detected new recommended rect"); - //console.log("old recommendedRect:" + recommendedRect); - //console.log("newRecommendedRect:" + newRecommendedRect); recommendedRect = newRecommendedRect; } @@ -396,13 +377,6 @@ FocusScope { var fractionY = Utils.clamp(originRelativeY / oldRecommendedDimmensions.y, 0, 1); var newX = (fractionX * newRecommendedDimmensions.x) + newRecommendedRect.x; var newY = (fractionY * newRecommendedDimmensions.y) + newRecommendedRect.y; - - //console.log("repositionWindow() oldRecommendedRect:" + oldRecommendedRect.x + "," + oldRecommendedRect.y + "/" + oldRecommendedRect.width + "x" + oldRecommendedRect.height); - //console.log("repositionWindow() newRecommendedRect:" + newRecommendedRect.x + "," + newRecommendedRect.y + "/" + newRecommendedRect.width + "x" + newRecommendedRect.height); - //console.log("repositionWindow() originRelativeX/originRelativeY:" + originRelativeX + "," + originRelativeY); - //console.log("repositionWindow() fractionX/fractionY:" + fractionX + "," + fractionY); - //console.log("repositionWindow() newX/newY:" + newX + "," + newY); - newPosition = Qt.vector2d(newX, newY); } targetWindow.x = newPosition.x; diff --git a/interface/resources/qml/windows-uit/Window.qml b/interface/resources/qml/windows-uit/Window.qml index 59d5dcd70e..db286ca44e 100644 --- a/interface/resources/qml/windows-uit/Window.qml +++ b/interface/resources/qml/windows-uit/Window.qml @@ -249,7 +249,6 @@ Fadable { children: [ swallower, frame, pane, activator ] Component.onCompleted: { - //console.log("Window(uit).Component.onCompleted window:" + window); window.parentChanged.connect(raise); raise(); setDefaultFocus(); diff --git a/interface/resources/qml/windows/Window.qml b/interface/resources/qml/windows/Window.qml index c24f4a3b9b..4d6b3a2f23 100644 --- a/interface/resources/qml/windows/Window.qml +++ b/interface/resources/qml/windows/Window.qml @@ -115,7 +115,6 @@ Fadable { children: [ swallower, frame, content, activator ] Component.onCompleted: { - //console.log("Window(uit).Component.onCompleted window:" + window); window.parentChanged.connect(raise); raise(); centerOrReposition(); From 0ae6e9f241527040306e3b0a79207b19408bc3b9 Mon Sep 17 00:00:00 2001 From: Brad Hefta-Gaub Date: Tue, 26 Apr 2016 11:36:21 -0700 Subject: [PATCH 12/15] remove debug messages --- interface/resources/qml/desktop/Desktop.qml | 2 -- 1 file changed, 2 deletions(-) diff --git a/interface/resources/qml/desktop/Desktop.qml b/interface/resources/qml/desktop/Desktop.qml index f24f822f49..417ca57125 100644 --- a/interface/resources/qml/desktop/Desktop.qml +++ b/interface/resources/qml/desktop/Desktop.qml @@ -318,9 +318,7 @@ FocusScope { } function repositionOnVisible(item) { - console.warn("repositionOnVisible() item:" + item); var targetWindow = d.getDesktopWindow(item); - console.warn("repositionOnVisible() targetWindow:" + targetWindow); if (!targetWindow) { console.warn("Could not find top level window for " + item); return; From e7d26a8a63102d5fd3b9ddcb997efc337b3bdf6d Mon Sep 17 00:00:00 2001 From: Brad Hefta-Gaub Date: Tue, 26 Apr 2016 11:45:48 -0700 Subject: [PATCH 13/15] CR feedback magic numbers --- interface/resources/qml/desktop/Desktop.qml | 1 + interface/resources/qml/windows-uit/Window.qml | 4 ++-- interface/resources/qml/windows/Window.qml | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/interface/resources/qml/desktop/Desktop.qml b/interface/resources/qml/desktop/Desktop.qml index 417ca57125..c311a65730 100644 --- a/interface/resources/qml/desktop/Desktop.qml +++ b/interface/resources/qml/desktop/Desktop.qml @@ -21,6 +21,7 @@ FocusScope { objectName: "desktop" anchors.fill: parent + readonly int INVALID_POSITION: -9999; property rect recommendedRect: Qt.rect(0,0,0,0); property var expectedChildren; diff --git a/interface/resources/qml/windows-uit/Window.qml b/interface/resources/qml/windows-uit/Window.qml index db286ca44e..e549c3eef8 100644 --- a/interface/resources/qml/windows-uit/Window.qml +++ b/interface/resources/qml/windows-uit/Window.qml @@ -31,7 +31,7 @@ Fadable { // decorations can extend outside it. implicitHeight: content ? content.height : 0 implicitWidth: content ? content.width : 0 - x: -9999; y: -9999 + x: desktop.INVALID_POSITION; y: desktop.INVALID_POSITION; enabled: visible signal windowDestroyed(); @@ -275,7 +275,7 @@ Fadable { } function centerOrReposition() { - if (x == -9999 && y == -9999) { + if (x == desktop.INVALID_POSITION && y == desktop.INVALID_POSITION) { desktop.centerOnVisible(window); } else { desktop.repositionOnVisible(window); diff --git a/interface/resources/qml/windows/Window.qml b/interface/resources/qml/windows/Window.qml index 4d6b3a2f23..09621e622c 100644 --- a/interface/resources/qml/windows/Window.qml +++ b/interface/resources/qml/windows/Window.qml @@ -19,7 +19,7 @@ Fadable { // decorations can extend outside it. implicitHeight: content ? content.height : 0 implicitWidth: content ? content.width : 0 - x: -9999; y: -9999 + x: desktop.INVALID_POSITION; y: desktop.INVALID_POSITION; enabled: visible signal windowDestroyed(); @@ -125,7 +125,7 @@ Fadable { } function centerOrReposition() { - if (x == -9999 && y == -9999) { + if (x == desktop.INVALID_POSITION && y == desktop.INVALID_POSITION) { desktop.centerOnVisible(window); } else { desktop.repositionOnVisible(window); From 63b0c0a9addfb19ee1307bc048382e6c5ab6e189 Mon Sep 17 00:00:00 2001 From: Zach Pomerantz Date: Tue, 26 Apr 2016 13:23:16 -0700 Subject: [PATCH 14/15] Reset pipeline after rendering text3d --- interface/src/ui/overlays/Text3DOverlay.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/interface/src/ui/overlays/Text3DOverlay.cpp b/interface/src/ui/overlays/Text3DOverlay.cpp index 9fa8f6556b..0ae1c306ba 100644 --- a/interface/src/ui/overlays/Text3DOverlay.cpp +++ b/interface/src/ui/overlays/Text3DOverlay.cpp @@ -110,7 +110,14 @@ void Text3DOverlay::render(RenderArgs* args) { glm::vec4 textColor = { _color.red / MAX_COLOR, _color.green / MAX_COLOR, _color.blue / MAX_COLOR, getTextAlpha() }; + + // FIXME: Factor out textRenderer so that Text3DOverlay overlay parts can be grouped by pipeline + // for a gpu performance increase. Currently, + // Text renderer sets its own pipeline, _textRenderer->draw(batch, 0, 0, _text, textColor, glm::vec2(-1.0f), getDrawInFront()); + // so before we continue, we must reset the pipeline + batch.setPipeline(args->_pipeline->pipeline); + args->_pipeline->prepare(batch); } const render::ShapeKey Text3DOverlay::getShapeKey() { From 82f905dc8439972106d263070425ee9ce3a5ed30 Mon Sep 17 00:00:00 2001 From: Brad Hefta-Gaub Date: Tue, 26 Apr 2016 13:29:22 -0700 Subject: [PATCH 15/15] fix qml issue --- interface/resources/qml/desktop/Desktop.qml | 2 +- interface/resources/qml/windows-uit/Window.qml | 4 ++-- interface/resources/qml/windows/Window.qml | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/interface/resources/qml/desktop/Desktop.qml b/interface/resources/qml/desktop/Desktop.qml index c311a65730..62a72e3d8c 100644 --- a/interface/resources/qml/desktop/Desktop.qml +++ b/interface/resources/qml/desktop/Desktop.qml @@ -21,7 +21,7 @@ FocusScope { objectName: "desktop" anchors.fill: parent - readonly int INVALID_POSITION: -9999; + readonly property int invalid_position: -9999; property rect recommendedRect: Qt.rect(0,0,0,0); property var expectedChildren; diff --git a/interface/resources/qml/windows-uit/Window.qml b/interface/resources/qml/windows-uit/Window.qml index e549c3eef8..e9477f3c7e 100644 --- a/interface/resources/qml/windows-uit/Window.qml +++ b/interface/resources/qml/windows-uit/Window.qml @@ -31,7 +31,7 @@ Fadable { // decorations can extend outside it. implicitHeight: content ? content.height : 0 implicitWidth: content ? content.width : 0 - x: desktop.INVALID_POSITION; y: desktop.INVALID_POSITION; + x: desktop.invalid_position; y: desktop.invalid_position; enabled: visible signal windowDestroyed(); @@ -275,7 +275,7 @@ Fadable { } function centerOrReposition() { - if (x == desktop.INVALID_POSITION && y == desktop.INVALID_POSITION) { + if (x == desktop.invalid_position && y == desktop.invalid_position) { desktop.centerOnVisible(window); } else { desktop.repositionOnVisible(window); diff --git a/interface/resources/qml/windows/Window.qml b/interface/resources/qml/windows/Window.qml index 09621e622c..3abdbacc64 100644 --- a/interface/resources/qml/windows/Window.qml +++ b/interface/resources/qml/windows/Window.qml @@ -19,7 +19,7 @@ Fadable { // decorations can extend outside it. implicitHeight: content ? content.height : 0 implicitWidth: content ? content.width : 0 - x: desktop.INVALID_POSITION; y: desktop.INVALID_POSITION; + x: desktop.invalid_position; y: desktop.invalid_position; enabled: visible signal windowDestroyed(); @@ -125,7 +125,7 @@ Fadable { } function centerOrReposition() { - if (x == desktop.INVALID_POSITION && y == desktop.INVALID_POSITION) { + if (x == desktop.invalid_position && y == desktop.invalid_position) { desktop.centerOnVisible(window); } else { desktop.repositionOnVisible(window);