9#if defined(Q_NO_TEMPORARY_DISABLE_XR_API)
16 : m_openXRRuntimeInfo(&m_openXRManager)
23 m_inDestructor =
true;
28 return m_openXRManager.m_xrOrigin;
33 return m_openXRManager.m_vrViewport ? m_openXRManager.m_vrViewport->
environment() :
nullptr;
38#if !defined(Q_OS_VISIONOS)
39 return m_openXRManager.m_inputManager ? m_openXRManager.m_inputManager->leftHandInput() :
nullptr;
47#if !defined(Q_OS_VISIONOS)
48 return m_openXRManager.m_inputManager ? m_openXRManager.m_inputManager->rightHandInput() :
nullptr;
56#if !defined(Q_OS_VISIONOS)
57 return m_openXRManager.m_inputManager->leftHandTrackerInput();
65#if !defined(Q_OS_VISIONOS)
66 return m_openXRManager.m_inputManager->rightHandTrackerInput();
74#if !defined(Q_OS_VISIONOS)
75 return m_openXRManager.m_inputManager ? m_openXRManager.m_inputManager->gamepadInput() :
nullptr;
83 return m_openXRManager.m_vrViewport;
88 return m_openXRManager.m_enablePassthrough;
93 return &m_openXRRuntimeInfo;
101 if (!m_openXRManager.m_vrViewport)
104 auto oldEnvironment = m_openXRManager.m_vrViewport->
environment();
114 handleClearColorChanged();
127 if (!m_openXRManager.
isValid())
130 return m_openXRManager.supportsPassthrough();
135 if (!m_openXRManager.
isValid())
138 if (m_openXRManager.m_enablePassthrough ==
enable)
142 if (
enable && !m_openXRManager.supportsPassthrough()) {
143 qWarning(
"Enabling Passthrough is not supported.");
154#if !defined(Q_OS_VISIONOS)
155 if (!m_openXRManager.
isValid())
167#if !defined(Q_OS_VISIONOS)
168 if (!m_openXRManager.
isValid())
171 const XrFoveationLevelFB xrLevel = XrFoveationLevelFB(
level);
172 if (m_openXRManager.m_foveationLevel == xrLevel)
175 m_openXRManager.m_foveationLevel = xrLevel;
176 m_openXRManager.setupMetaQuestFoveation();
187 return m_quitOnSessionEnd;
192 if (m_quitOnSessionEnd ==
enable)
195 m_quitOnSessionEnd =
enable;
201 return m_openXRManager.m_vrViewport ? m_openXRManager.m_vrViewport->
renderStats() :
nullptr;
204void QOpenXRView::updateViewportGeometry()
206 auto contentItem = m_openXRManager.m_quickWindow->
contentItem();
207 auto viewport = m_openXRManager.m_vrViewport;
208 if (
viewport->height() != contentItem->height())
210 if (
viewport->width() != contentItem->width())
211 viewport->setWidth(contentItem->width());
212 if (
viewport->x() != contentItem->x())
214 if (
viewport->y() != contentItem->y())
218void QOpenXRView::handleSessionEnded()
221 if (m_quitOnSessionEnd)
225void QOpenXRView::handleClearColorChanged()
231 m_openXRManager.m_quickWindow->setColor(env->clearColor());
237void QOpenXRView::handleAAChanged()
242 switch (env->antialiasingQuality()) {
257bool QOpenXRView::init()
259 if (m_isInitialized) {
265 qDebug() <<
"Waiting for OpenXR to be initialized...";
282 auto contentItem = m_openXRManager.m_quickWindow->
contentItem();
284 m_openXRManager.m_vrViewport =
viewport;
306 m_openXRManager.update();
308 m_isInitialized =
true;
310 return m_isInitialized;
326 return m_openXRManager.m_vrViewport->rayPick(origin,
direction);
345 return m_openXRManager.m_vrViewport->rayPickAll(origin,
direction);
365 QHash<int, QOpenXRItem::TouchState>
points;
392 state.pointId = pointId;
394 auto *prevTarget =
state.target;
395 bool grabbed =
false;
397 grabbed = prevTarget->handleVirtualTouch(
this,
pos, &
state, &
offset);
399 for (
auto *
item : std::as_const(m_xrItems)) {
402 if (
item != prevTarget)
444#define Q_TOUCHPOINT_STATE(prop) { QStringLiteral(#prop), QVariant::fromValue(it->prop) }
459#undef Q_TOUCHPOINT_STATE
461#if defined(Q_NO_TEMPORARY_DISABLE_XR_API)
466 switch (referenceSpace) {
468 return XR_REFERENCE_SPACE_TYPE_LOCAL;
470 return XR_REFERENCE_SPACE_TYPE_STAGE;
472 return XR_REFERENCE_SPACE_TYPE_LOCAL_FLOOR_EXT;
474 return XR_REFERENCE_SPACE_TYPE_LOCAL;
480 switch (referenceSpace) {
481 case XR_REFERENCE_SPACE_TYPE_LOCAL:
483 case XR_REFERENCE_SPACE_TYPE_STAGE:
485 case XR_REFERENCE_SPACE_TYPE_LOCAL_FLOOR_EXT:
498#if !defined(Q_OS_VISIONOS)
499 return getReferenceSpaceType(m_openXRManager.m_referenceSpace);
509#if !defined(Q_OS_VISIONOS)
510 XrReferenceSpaceType
referenceSpace = getXrReferenceSpaceType(newReferenceSpace);
526#if !defined(Q_OS_VISIONOS)
527 if (!m_openXRManager.
isValid())
530 return m_openXRManager.m_submitLayerDepth;
539 m_xrItems.
append(newXrItem);
549#if !defined(Q_OS_VISIONOS)
550 if (!m_openXRManager.
isValid()) {
551 qWarning(
"Attempted to set depth submission mode without having m_openXRManager initialized");
555 if (m_openXRManager.m_submitLayerDepth ==
enable)
558 if (m_openXRManager.m_compositionLayerDepthSupported) {
560 qDebug(
"Enabling submitLayerDepth");
561 m_openXRManager.m_submitLayerDepth =
enable;
static void quit()
\threadsafe
const_iterator constFind(const Key &key) const noexcept
friend class const_iterator
bool isEmpty() const noexcept
qsizetype removeAll(const AT &t)
void append(parameter_type t)
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
void setPassthroughEnabled(bool enabled)
void referenceSpaceChanged()
void setSamples(int samples)
QString errorString() const
void frameReady(QRhiTexture *colorBuffer)
Q_INVOKABLE QVariantMap touchpointState(int pointId) const
bool isPassthroughSupported() const
QOpenXRRuntimeInfo * runtimeInfo
void frameReady(QRhiTexture *colorBuffer)
QOpenXRHandTrackerInput * rightHandTrackerInput
Q_INVOKABLE QList< QQuick3DPickResult > rayPickAll(const QVector3D &origin, const QVector3D &direction) const
\qmlmethod List<PickResult> XrView::rayPickAll(vector3d origin, vector3d direction)
void fixedFoveationChanged()
Q_INVOKABLE void setTouchpoint(QQuickItem *target, const QPointF &position, int pointId, bool active)
\qmlmethod XrView::setTouchpoint(Item target, point position, int pointId, bool pressed)
void enableDepthSubmissionChanged()
QOpenXRHandTrackerInput * leftHandTrackerInput
void enablePassthroughChanged(bool enable)
void unregisterXrItem(QOpenXRItem *xrItem)
QOpenXRHandInput * leftHandInput
QQuick3DSceneEnvironment * environment
void quitOnSessionEndChanged()
void referenceSpaceChanged()
QOpenXRGamepadInput * gamepadInput
void setFixedFoveation(FoveationLevel level)
FoveationLevel fixedFoveation
QQuick3DRenderStats * renderStats
void environmentChanged(QQuick3DSceneEnvironment *environment)
void setReferenceSpace(ReferenceSpace newReferenceSpace)
void setEnableDepthSubmission(bool enable)
Q_INVOKABLE QVector3D processTouch(const QVector3D &pos, int pointId)
\qmlmethod vector3d XrView::processTouch(vector3d position, int pointId)
Q_INVOKABLE QQuick3DPickResult rayPick(const QVector3D &origin, const QVector3D &direction) const
\qmlmethod PickResult XrView::rayPick(vector3d origin, vector3d direction)
bool isDepthSubmissionEnabled() const
void registerXrItem(QOpenXRItem *newXrItem)
void setQuitOnSessionEnd(bool enable)
void setEnablePassthrough(bool enable)
ReferenceSpace referenceSpace
QOpenXRHandInput * rightHandInput
bool isQuitOnSessionEndEnabled() const
void setEnvironment(QQuick3DSceneEnvironment *environment)
@ ReferenceSpaceLocalFloor
\inmodule QtCore\reentrant
void antialiasingModeChanged()
void antialiasingQualityChanged()
void backgroundModeChanged()
void setImportScene(QQuick3DNode *inScene)
void setEnvironment(QQuick3DSceneEnvironment *environment)
QQuick3DRenderStats * renderStats
QQuick3DSceneEnvironment * environment
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
void setParentItem(QQuickItem *parent)
QQuickItem * contentItem
\qmlattachedproperty Item Window::contentItem
\macro QT_RESTRICTED_CAST_FROM_ASCII
static auto fromValue(T &&value) noexcept(std::is_nothrow_copy_constructible_v< T > &&Private::CanUseInternalSpace< T >) -> std::enable_if_t< std::conjunction_v< std::is_copy_constructible< T >, std::is_destructible< T > >, QVariant >
The QVector3D class represents a vector or vertex in 3D space.
QSet< QString >::iterator it
Combined button and popup list for selecting options.
GLenum GLuint GLint level
GLenum GLuint GLintptr offset
#define Q_TOUCHPOINT_STATE(prop)
\qmlmethod object XrView::touchpointState(int pointId)
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
#define qPrintable(string)
#define QStringLiteral(str)
myObject disconnect()
[26]
view viewport() -> scroll(dx, dy, deviceRect)
QHash< int, QOpenXRItem::TouchState > points