43 void init(XrInstance instance, XrSession session);
46 bool isValid()
const {
return m_initialized; }
54 void updatePoses(XrTime predictedDisplayTime, XrSpace appSpace);
55 void updateHandtracking(XrTime predictedDisplayTime, XrSpace appSpace,
bool aimExtensionEnabled);
70 bool isPoseInUse(Hand hand, HandPoseSpace poseSpace);
89 void setupHandTracking();
90 bool queryHandMesh(Hand hand);
92 void destroyActions();
93 [[
nodiscard]]
bool checkXrResult(
const XrResult &result);
94 void setPath(XrPath &path,
const QByteArray &pathString);
96 void createAction(XrActionType type,
98 const char *localizedName,
100 XrPath *subactionPath,
102 void getBoolInputState(XrActionStateGetInfo &getInfo,
const XrAction &action,
std::function<
void(
bool)> setter);
103 void getFloatInputState(XrActionStateGetInfo &getInfo,
const XrAction &action,
std::function<
void(
float)> setter);
105 void setInputValue(Hand hand,
int id,
const char *shortName,
float value);
109 XrInstance m_instance{XR_NULL_HANDLE};
110 XrSession m_session{XR_NULL_HANDLE};
112 enum SubPathSelector {NoSubPath = 0, LeftHandSubPath = 1, RightHandSubPath = 2, BothHandsSubPath = 3};
114 struct QXRHandComponentPath
116 XrPath paths[2] = {{}, {}};
117 QByteArray componentPathString;
119 QXRHandComponentPath makeHandInputPaths(
const QByteArrayView path);
120 XrPath makeInputPath(
const QByteArrayView path);
122 struct InputActionInfo {
123 QQuick3DXrInputAction::Action id;
124 const char *shortName;
125 const char *localizedName;
129 QList<InputActionInfo> m_handInputActionDefs;
132 XrAction gripPoseAction{XR_NULL_HANDLE};
133 XrAction aimPoseAction{XR_NULL_HANDLE};
134 XrAction hapticAction{XR_NULL_HANDLE};
137 enum class ActionPaths {
190 struct ControllerBindings {
191 QByteArray profileName;
192 QByteArray profilePath;
193 QList<InputMapping> profileMappingDefs;
194 QList<ActionPaths> supportedActionPaths;
198 XrActionSet m_actionSet{XR_NULL_HANDLE};
199 XrPath m_handSubactionPath[2] = {XR_NULL_PATH, XR_NULL_PATH};
200 XrSpace m_handGripSpace[2] {XR_NULL_HANDLE, XR_NULL_HANDLE};
201 XrSpace m_handAimSpace[2] {XR_NULL_HANDLE, XR_NULL_HANDLE};
204 HandActions m_handActions;
206 QSet<QQuick3DXrController *> m_controllers;
207 bool m_poseInUse[2][2] = {};
208 bool m_poseUsageDirty =
true;
210 uint m_aimStateFlags[2] = {};
211 bool m_initialized =
false;
212 bool m_validAimStateFromUpdatePoses[2] = {
false,
false};
214 void loadBindings(QList<ControllerBindings>* controllerBindingsList);
215 void setUpBindings(QList<ControllerBindings>* controllerBindingsList, QMap<InputNames, QXRHandComponentPath>* handComponentPaths);
218 struct HandMeshData {
219 QVector<XrVector3f> vertexPositions;
220 QVector<XrVector3f> vertexNormals;
221 QVector<XrVector2f> vertexUVs;
222 QVector<XrVector4sFB> vertexBlendIndices;
223 QVector<XrVector4f> vertexBlendWeights;
224 QVector<int16_t> indices;
225 XrPosef jointBindPoses[XR_HAND_JOINT_COUNT_EXT];
226 XrHandJointEXT jointParents[XR_HAND_JOINT_COUNT_EXT];
227 float jointRadii[XR_HAND_JOINT_COUNT_EXT];
231 struct HandGeometryData {
232 QQuick3DGeometry *geometry =
nullptr;
233 } m_handGeometryData[2];
235 QQuick3DGeometry *createHandMeshGeometry(
const HandMeshData &handMeshData);
236 void createHandModelData(Hand hand);
237 friend class QOpenXrHandModel;