Fix issue with double-counting lens position changes with 6DoF
This commit is contained in:
parent
87389c6e5c
commit
0aa41a912b
|
|
@ -469,6 +469,10 @@ quint64 BreezyDesktopEffect::poseTimestamp() const {
|
||||||
return m_poseTimestamp;
|
return m_poseTimestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool BreezyDesktopEffect::poseHasPosition() const {
|
||||||
|
return m_poseHasPosition;
|
||||||
|
}
|
||||||
|
|
||||||
QList<qreal> BreezyDesktopEffect::lookAheadConfig() const {
|
QList<qreal> BreezyDesktopEffect::lookAheadConfig() const {
|
||||||
return m_lookAheadConfig;
|
return m_lookAheadConfig;
|
||||||
}
|
}
|
||||||
|
|
@ -718,7 +722,16 @@ void BreezyDesktopEffect::updatePose() {
|
||||||
<< "diagonalFOV:" << m_diagonalFOV;
|
<< "diagonalFOV:" << m_diagonalFOV;
|
||||||
activate();
|
activate();
|
||||||
m_enabled = true;
|
m_enabled = true;
|
||||||
|
m_poseHasPosition = false;
|
||||||
|
auto driverStateOpt = XRDriverIPC::instance().retrieveDriverState();
|
||||||
|
if (driverStateOpt) {
|
||||||
|
QJsonObject driverState = driverStateOpt.value();
|
||||||
|
if (driverState.contains(QStringLiteral("connected_device_pose_has_position"))) {
|
||||||
|
m_poseHasPosition = driverState.value(QStringLiteral("connected_device_pose_has_position")).toBool();
|
||||||
|
}
|
||||||
|
}
|
||||||
Q_EMIT enabledStateChanged();
|
Q_EMIT enabledStateChanged();
|
||||||
|
Q_EMIT poseHasPositionChanged();
|
||||||
activatedAt = currentTimeMs;
|
activatedAt = currentTimeMs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ namespace KWin
|
||||||
Q_PROPERTY(bool zoomOnFocusEnabled READ isZoomOnFocusEnabled WRITE setZoomOnFocusEnabled NOTIFY zoomOnFocusChanged)
|
Q_PROPERTY(bool zoomOnFocusEnabled READ isZoomOnFocusEnabled WRITE setZoomOnFocusEnabled NOTIFY zoomOnFocusChanged)
|
||||||
Q_PROPERTY(int lookingAtScreenIndex READ lookingAtScreenIndex WRITE setLookingAtScreenIndex)
|
Q_PROPERTY(int lookingAtScreenIndex READ lookingAtScreenIndex WRITE setLookingAtScreenIndex)
|
||||||
Q_PROPERTY(bool poseResetState READ poseResetState NOTIFY poseResetStateChanged)
|
Q_PROPERTY(bool poseResetState READ poseResetState NOTIFY poseResetStateChanged)
|
||||||
|
Q_PROPERTY(bool poseHasPosition READ poseHasPosition NOTIFY poseResetStateChanged)
|
||||||
Q_PROPERTY(QList<QQuaternion> poseOrientations READ poseOrientations)
|
Q_PROPERTY(QList<QQuaternion> poseOrientations READ poseOrientations)
|
||||||
Q_PROPERTY(QVector3D posePosition READ posePosition)
|
Q_PROPERTY(QVector3D posePosition READ posePosition)
|
||||||
Q_PROPERTY(quint32 poseTimeElapsedMs READ poseTimeElapsedMs)
|
Q_PROPERTY(quint32 poseTimeElapsedMs READ poseTimeElapsedMs)
|
||||||
|
|
@ -81,6 +82,7 @@ namespace KWin
|
||||||
quint32 poseTimeElapsedMs() const;
|
quint32 poseTimeElapsedMs() const;
|
||||||
quint64 poseTimestamp() const;
|
quint64 poseTimestamp() const;
|
||||||
bool poseResetState() const;
|
bool poseResetState() const;
|
||||||
|
bool poseHasPosition() const;
|
||||||
QList<qreal> lookAheadConfig() const;
|
QList<qreal> lookAheadConfig() const;
|
||||||
qreal lookAheadOverride() const;
|
qreal lookAheadOverride() const;
|
||||||
void setLookAheadOverride(qreal override);
|
void setLookAheadOverride(qreal override);
|
||||||
|
|
@ -138,6 +140,7 @@ namespace KWin
|
||||||
void enabledStateChanged();
|
void enabledStateChanged();
|
||||||
void zoomOnFocusChanged();
|
void zoomOnFocusChanged();
|
||||||
void poseResetStateChanged();
|
void poseResetStateChanged();
|
||||||
|
void poseHasPositionChanged();
|
||||||
void sbsEnabledChanged();
|
void sbsEnabledChanged();
|
||||||
void smoothFollowEnabledChanged();
|
void smoothFollowEnabledChanged();
|
||||||
void devicePropertiesChanged();
|
void devicePropertiesChanged();
|
||||||
|
|
@ -175,6 +178,7 @@ namespace KWin
|
||||||
int m_lookingAtScreenIndex = -1;
|
int m_lookingAtScreenIndex = -1;
|
||||||
int m_effectTargetScreenIndex = -1;
|
int m_effectTargetScreenIndex = -1;
|
||||||
bool m_poseResetState;
|
bool m_poseResetState;
|
||||||
|
bool m_poseHasPosition = false;
|
||||||
QList<QQuaternion> m_poseOrientations;
|
QList<QQuaternion> m_poseOrientations;
|
||||||
QVector3D m_posePosition;
|
QVector3D m_posePosition;
|
||||||
quint32 m_poseTimeElapsedMs;
|
quint32 m_poseTimeElapsedMs;
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,13 @@ Item {
|
||||||
effect.lookAheadOverride
|
effect.lookAheadOverride
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
camera.position = position.times(fovDetails.fullScreenDistancePixels).plus(orientations[0].times(Qt.vector3d(0, 0, -fovDetails.lensDistancePixels)));
|
let lensVector = Qt.vector3d(0, 0, -fovDetails.lensDistancePixels);
|
||||||
|
|
||||||
|
// if we only have 3DoF, account for a bit of positional change based on orientation,
|
||||||
|
// don't do this for 6DoF to prevent doubling the positional movement due to rotation
|
||||||
|
if (!effect.poseHasPosition) lensVector = orientations[0].times(lensVector);
|
||||||
|
|
||||||
|
camera.position = position.times(fovDetails.fullScreenDistancePixels).plus(lensVector);
|
||||||
|
|
||||||
sampleCounter += 1;
|
sampleCounter += 1;
|
||||||
if (sampleCounter === 60) {
|
if (sampleCounter === 60) {
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,6 @@ QtObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildFovDetails(screens, viewportWidth, viewportHeight, viewportDiagonalFOV, lensDistanceRatio, defaultDisplayDistance, wrappingChoice, distanceAdjustedSize) {
|
function buildFovDetails(screens, viewportWidth, viewportHeight, viewportDiagonalFOV, lensDistanceRatio, defaultDisplayDistance, wrappingChoice, distanceAdjustedSize) {
|
||||||
console.log(`Breezy - Building FOV details with viewport ${viewportWidth}x${viewportHeight}, diagonal FOV ${viewportDiagonalFOV} degrees, lens distance ratio ${lensDistanceRatio}, default display distance ${defaultDisplayDistance}, wrapping choice ${wrappingChoice}, distance adjusted size ${distanceAdjustedSize}`);
|
|
||||||
const aspect = viewportWidth / viewportHeight;
|
const aspect = viewportWidth / viewportHeight;
|
||||||
const fovLengths = diagonalToCrossFOVs(degreeToRadian(viewportDiagonalFOV), aspect);
|
const fovLengths = diagonalToCrossFOVs(degreeToRadian(viewportDiagonalFOV), aspect);
|
||||||
|
|
||||||
|
|
@ -101,7 +100,7 @@ QtObject {
|
||||||
// distance of a display at the default (most zoomed out) distance from the pivot point
|
// distance of a display at the default (most zoomed out) distance from the pivot point
|
||||||
const completeScreenDistancePixels = fullScreenDistancePixels * defaultDisplayDistance;
|
const completeScreenDistancePixels = fullScreenDistancePixels * defaultDisplayDistance;
|
||||||
|
|
||||||
const details = {
|
return {
|
||||||
widthPixels: viewportWidth,
|
widthPixels: viewportWidth,
|
||||||
distanceAdjustedSize,
|
distanceAdjustedSize,
|
||||||
sizeAdjustedWidthPixels: viewportWidth * distanceAdjustedSize,
|
sizeAdjustedWidthPixels: viewportWidth * distanceAdjustedSize,
|
||||||
|
|
@ -115,9 +114,6 @@ QtObject {
|
||||||
monitorWrappingScheme,
|
monitorWrappingScheme,
|
||||||
curvedDisplay: effect.curvedDisplay
|
curvedDisplay: effect.curvedDisplay
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log("Breezy - FOV Details:", details);
|
|
||||||
return details;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Utility constant
|
// Utility constant
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue