Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qquick3dxranchormanager_openxr_p.h
Go to the documentation of this file.
1// Copyright (C) 2024 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5
6#ifndef QQUICK3DXRANCHORMANAGER_OPENXR_P_H
7#define QQUICK3DXRANCHORMANAGER_OPENXR_P_H
8
9//
10// W A R N I N G
11// -------------
12//
13// This file is not part of the Qt API. It exists purely as an
14// implementation detail. This header file may change from version to
15// version without notice, or even be removed.
16//
17// We mean it.
18//
19
20#include <openxr/openxr.h>
21
22#if __has_include(<openxr/fb_spatial_entity.h>) && __has_include(<openxr/fb_scene.h>)
23#include <openxr/fb_spatial_entity.h>
24#if __has_include(<openxr/fb_spatial_entity_query.h>) && __has_include(<openxr/fb_spatial_entity_storage.h>) && __has_include(<openxr/fb_spatial_entity_container.h>)
25#include <openxr/fb_spatial_entity_query.h>
26#include <openxr/fb_spatial_entity_storage.h>
27#include <openxr/fb_spatial_entity_container.h>
28#endif
29#include <openxr/fb_scene.h>
30#if __has_include(<openxr/fb_scene_capture.h>)
31#include <openxr/fb_scene_capture.h>
32#endif
33#endif
34// Otherwise, these may be all provided in openxr.h, if it is new enough, no
35// need for the Mobile SDK specific headers anymore. If that's not the case
36// (too old openxr.h), compilation will fail.
37
38#include <QList>
39#include <QSet>
40#include <QUuid>
41
42#include <QObject>
43
44#include <QtQuick3DXr/private/qtquick3dxrglobal_p.h>
45#include <QtQuick3DXr/private/qquick3dxrspatialanchor_p.h>
46
47QT_BEGIN_NAMESPACE
48
49class QQuick3DXrAnchorManager : public QObject
50{
51 Q_OBJECT
52public:
53 static QQuick3DXrAnchorManager* instance();
54
55 void initialize(XrInstance instance, XrSession session);
56 void teardown();
57
58 QList<const char*> requiredExtensions() const;
59
60 void handleEvent(const XrEventDataBaseHeader* event);
61
62 void requestSceneCapture();
63 bool queryAllAnchors();
64 const QList<QQuick3DXrSpatialAnchor *> &anchors() const;
65 qsizetype anchorCount() const;
66
67 void updateAnchors(XrTime predictedDisplayTime, XrSpace appSpace);
68 QString getSemanticLabels(const XrSpace space);
69 QSet<QUuid> collectRoomLayoutUuids(XrSpace space);
70 QSet<QUuid> collectSpaceContainerUuids(XrSpace space);
71
72 bool isComponentSupported(XrSpace space, XrSpaceComponentTypeFB type);
73 bool isComponentEnabled(XrSpace space, XrSpaceComponentTypeFB type);
74
75 bool getBoundingBox3D(XrSpace space, QVector3D &offset, QVector3D &extent);
76 bool getBoundingBox2D(XrSpace space, QVector2D &offset, QVector2D &extent);
77
78 bool setupSpatialAnchor(XrSpace space, QQuick3DXrSpatialAnchor &anchor);
79
80Q_SIGNALS:
81 void anchorAdded(QQuick3DXrSpatialAnchor* anchor);
82 void anchorRemoved(QUuid uuid);
83 void anchorUpdated(QQuick3DXrSpatialAnchor *anchor);
84 void sceneCaptureCompleted();
85
86private:
87 QQuick3DXrAnchorManager();
88 ~QQuick3DXrAnchorManager();
89
90 XrInstance m_instance{XR_NULL_HANDLE};
91 XrSession m_session{XR_NULL_HANDLE};
92
93 [[nodiscard]] bool checkXrResult(const XrResult &result);
94
95 bool queryAllAnchorsWithSpecificComponentEnabled(const XrSpaceComponentTypeFB componentType);
96 bool queryAnchorsByUuids(const QSet<QUuid>& uuidSet);
97
98 void addAnchor(XrSpace space, XrUuidEXT uuid);
99
100 // API Wrappers
101 XrResult enumerateSpaceSupportedComponents(XrSpace space,
102 uint32_t componentTypeCapacityInput,
103 uint32_t* componentTypeCountOutput,
104 XrSpaceComponentTypeFB* componentTypes);
105 XrResult getSpaceComponentStatus(XrSpace space,
106 XrSpaceComponentTypeFB componentType,
107 XrSpaceComponentStatusFB* status);
108 XrResult setSpaceComponentStatus(XrSpace space,
109 const XrSpaceComponentStatusSetInfoFB* info,
110 XrAsyncRequestIdFB* requestId);
111 XrResult getSpaceUuid(XrSpace space, XrUuidEXT *uuid);
112 XrResult querySpaces(const XrSpaceQueryInfoBaseHeaderFB* info, XrAsyncRequestIdFB* requestId);
113 XrResult retrieveSpaceQueryResults(XrAsyncRequestIdFB requestId, XrSpaceQueryResultsFB* results);
114 XrResult getSpaceBoundingBox2D(XrSpace space, XrRect2Df* boundingBox2DOutput);
115 XrResult getSpaceBoundingBox3D(XrSpace space, XrRect3DfFB* boundingBox3DOutput);
116 XrResult getSpaceSemanticLabels(XrSpace space, XrSemanticLabelsFB* semanticLabelsOutput);
117 XrResult getSpaceBoundary2D(XrSpace space, XrBoundary2DFB* boundary2DOutput);
118 XrResult getSpaceRoomLayout(XrSpace space, XrRoomLayoutFB* roomLayoutOutput);
119 XrResult getSpaceContainer(XrSpace space, XrSpaceContainerFB* spaceContainerOutput);
120 XrResult requestSceneCapture(const XrSceneCaptureRequestInfoFB* info, XrAsyncRequestIdFB* requestId);
121
122 PFN_xrEnumerateSpaceSupportedComponentsFB xrEnumerateSpaceSupportedComponentsFB = nullptr;
123 PFN_xrGetSpaceComponentStatusFB xrGetSpaceComponentStatusFB = nullptr;
124 PFN_xrSetSpaceComponentStatusFB xrSetSpaceComponentStatusFB = nullptr;
125 PFN_xrGetSpaceUuidFB xrGetSpaceUuidFB = nullptr;
126 PFN_xrQuerySpacesFB xrQuerySpacesFB = nullptr;
127 PFN_xrRetrieveSpaceQueryResultsFB xrRetrieveSpaceQueryResultsFB = nullptr;
128 PFN_xrGetSpaceBoundingBox2DFB xrGetSpaceBoundingBox2DFB = nullptr;
129 PFN_xrGetSpaceBoundingBox3DFB xrGetSpaceBoundingBox3DFB = nullptr;
130 PFN_xrGetSpaceSemanticLabelsFB xrGetSpaceSemanticLabelsFB = nullptr;
131 PFN_xrGetSpaceBoundary2DFB xrGetSpaceBoundary2DFB = nullptr;
132 PFN_xrGetSpaceRoomLayoutFB xrGetSpaceRoomLayoutFB = nullptr;
133 PFN_xrGetSpaceContainerFB xrGetSpaceContainerFB = nullptr;
134 PFN_xrRequestSceneCaptureFB xrRequestSceneCaptureFB = nullptr;
135
136 QList<QQuick3DXrSpatialAnchor *> m_anchors;
137 QHash<QUuid,QQuick3DXrSpatialAnchor *> m_anchorsByUuid;
138};
139
140QT_END_NAMESPACE
141
142#endif // QQUICK3DXRANCHORMANAGER_OPENXR_P_H
QList< QQuick3DXrSpatialAnchor * > anchors() const
~QQuick3DXrAnchorManager() override
qsizetype anchorCount() const
static QQuick3DXrAnchorManager * instance()
bool checkXrResult(XrResult result, XrInstance instance)
bool resolveXrFunction(XrInstance instance, const char *name, PFN_xrVoidFunction *function)
Combined button and popup list for selecting options.
#define __has_include(x)
static const uint32_t MAX_PERSISTENT_SPACES
static const char qssgXrRecognizedLabels[]
static QQuick3DXrSpatialAnchor::Classification getLabelForString(const QString &label)