Make it so the effect only applies to the glasses' display
This commit is contained in:
parent
f5cbd9281b
commit
cceed0f856
|
|
@ -18,6 +18,12 @@ Node {
|
||||||
|
|
||||||
property real viewportDiagonalFOVDegrees: effect.diagonalFOV
|
property real viewportDiagonalFOVDegrees: effect.diagonalFOV
|
||||||
property var viewportResolution: effect.displayResolution
|
property var viewportResolution: effect.displayResolution
|
||||||
|
property QtObject targetScreen
|
||||||
|
property bool targetScreenSupported: {
|
||||||
|
return supportedModels.some(function(model) {
|
||||||
|
return targetScreen.model.endsWith(model);
|
||||||
|
});
|
||||||
|
}
|
||||||
property var screens: KWinComponents.Workspace.screens
|
property var screens: KWinComponents.Workspace.screens
|
||||||
// .filter(function(screen) {
|
// .filter(function(screen) {
|
||||||
// return supportedModels.includes(screen.model);
|
// return supportedModels.includes(screen.model);
|
||||||
|
|
|
||||||
|
|
@ -20,15 +20,21 @@ Item {
|
||||||
implicitWidth: parent.width
|
implicitWidth: parent.width
|
||||||
implicitHeight: parent.height
|
implicitHeight: parent.height
|
||||||
|
|
||||||
|
Displays {
|
||||||
|
id: displays
|
||||||
|
}
|
||||||
|
|
||||||
function updateCamera(rotation) {
|
function updateCamera(rotation) {
|
||||||
camera.eulerRotation = rotation;
|
camera.eulerRotation = rotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
// how far to look ahead is how old the IMU data is plus a constant that is either the default for this device or an override
|
// how far to look ahead is how old the IMU data is plus a constant that is either the default for this device or an override
|
||||||
function lookAheadMS(imuDateMs, lookAheadConstant, override) {
|
function lookAheadMS(imuDateMs, lookAheadConfig, override) {
|
||||||
// how stale the imu data is
|
// how stale the imu data is
|
||||||
const dataAge = Date.now() - imuDateMs;
|
const dataAge = Date.now() - imuDateMs;
|
||||||
|
|
||||||
|
const lookAheadConstant = lookAheadConfig[0];
|
||||||
|
const lookAheadMultiplier = lookAheadConfig[1];
|
||||||
return (override === -1 ? lookAheadConstant : override) + dataAge;
|
return (override === -1 ? lookAheadConstant : override) + dataAge;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -54,7 +60,10 @@ Item {
|
||||||
|
|
||||||
function updateFOV() {
|
function updateFOV() {
|
||||||
const aspectRatio = displayResolution[0] / displayResolution[1];
|
const aspectRatio = displayResolution[0] / displayResolution[1];
|
||||||
camera.fieldOfView = 2 * Math.atan(Math.tan(diagonalFOV * Math.PI / 360) / Math.sqrt(1 + aspectRatio * aspectRatio)) * 180 / Math.PI;
|
camera.fieldOfView = displays.radianToDegree(displays.diagonalToCrossFOVs(
|
||||||
|
displays.degreeToRadian(root.diagonalFOV),
|
||||||
|
aspectRatio
|
||||||
|
).vertical);
|
||||||
}
|
}
|
||||||
|
|
||||||
onDisplayResolutionChanged: updateFOV();
|
onDisplayResolutionChanged: updateFOV();
|
||||||
|
|
@ -68,7 +77,7 @@ Item {
|
||||||
root.imuRotations[0],
|
root.imuRotations[0],
|
||||||
root.imuRotations[1],
|
root.imuRotations[1],
|
||||||
root.imuTimeElapsedMs,
|
root.imuTimeElapsedMs,
|
||||||
lookAheadMS(root.imuTimestamp, root.lookAheadConfig[0], -1)
|
lookAheadMS(root.imuTimestamp, root.lookAheadConfig, -1)
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,15 @@ Item {
|
||||||
required property QtObject effect
|
required property QtObject effect
|
||||||
required property QtObject targetScreen
|
required property QtObject targetScreen
|
||||||
|
|
||||||
|
DesktopView {
|
||||||
|
id: desktopView
|
||||||
|
screen: root.targetScreen
|
||||||
|
width: root.targetScreen.geometry.width
|
||||||
|
height: root.targetScreen.geometry.height
|
||||||
|
}
|
||||||
|
|
||||||
View3D {
|
View3D {
|
||||||
|
id: view3D
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
environment: SceneEnvironment {
|
environment: SceneEnvironment {
|
||||||
antialiasingMode: SceneEnvironment.MSAA
|
antialiasingMode: SceneEnvironment.MSAA
|
||||||
|
|
@ -24,6 +32,7 @@ Item {
|
||||||
|
|
||||||
BreezyDesktop {
|
BreezyDesktop {
|
||||||
id: breezyDesktop
|
id: breezyDesktop
|
||||||
|
targetScreen: root.targetScreen
|
||||||
}
|
}
|
||||||
|
|
||||||
CameraController {
|
CameraController {
|
||||||
|
|
@ -33,5 +42,10 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: start();
|
// TODO - make it so the View3D isn't loaded unless it's a supported screen
|
||||||
|
Component.onCompleted: {
|
||||||
|
console.log(`Breezy - initialized with target screen: ${breezyDesktop.targetScreen.model}, supported: ${breezyDesktop.targetScreenSupported}`);
|
||||||
|
view3D.opacity = breezyDesktop.targetScreenSupported ? 1.0 : 0.0;
|
||||||
|
desktopView.opacity = breezyDesktop.targetScreenSupported ? 0.0 : 1.0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue