45 void init(XrInstance instance, XrSession session);
48 bool isValid()
const {
return m_initialized; }
56 void updatePoses(XrTime predictedDisplayTime, XrSpace appSpace);
57 void updateHandtracking(XrTime predictedDisplayTime, XrSpace appSpace,
bool aimExtensionEnabled);
72 bool isPoseInUse(Hand hand, HandPoseSpace poseSpace);
91 void setupHandTracking();
92 bool queryHandMesh(Hand hand);
94 void destroyActions();
95 [[nodiscard]]
bool checkXrResult(
const XrResult &result);
96 void setPath(XrPath &path,
const QByteArray &pathString);
98 void createAction(XrActionType type,
100 const char *localizedName,
102 XrPath *subactionPath,
104 void getBoolInputState(XrActionStateGetInfo &getInfo,
const XrAction &action,
std::function<
void(
bool)> setter);
105 void getFloatInputState(XrActionStateGetInfo &getInfo,
const XrAction &action,
std::function<
void(
float)> setter);
107 void setInputValue(Hand hand,
int id,
const char *shortName,
float value);
111 XrInstance m_instance{XR_NULL_HANDLE};
112 XrSession m_session{XR_NULL_HANDLE};
114 enum SubPathSelector {NoSubPath = 0, LeftHandSubPath = 1, RightHandSubPath = 2, BothHandsSubPath = 3};
116 struct QXRHandComponentPath
118 XrPath paths[2] = {{}, {}};
119 QByteArray componentPathString;
121 QXRHandComponentPath makeHandInputPaths(
const QByteArrayView path);
122 XrPath makeInputPath(
const QByteArrayView path);
124 struct InputActionInfo {
125 QQuick3DXrInputAction::Action id;
126 const char *shortName;
127 const char *localizedName;
131 QList<InputActionInfo> m_handInputActionDefs;
134 XrAction gripPoseAction{XR_NULL_HANDLE};
135 XrAction aimPoseAction{XR_NULL_HANDLE};
136 XrAction hapticAction{XR_NULL_HANDLE};
139 enum class ActionPaths {
192 struct ControllerBindings {
193 QByteArray profileName;
194 QByteArray profilePath;
195 QList<InputMapping> profileMappingDefs;
196 QList<ActionPaths> supportedActionPaths;
200 XrActionSet m_actionSet{XR_NULL_HANDLE};
201 XrPath m_handSubactionPath[2] = {XR_NULL_PATH, XR_NULL_PATH};
202 XrSpace m_handGripSpace[2] {XR_NULL_HANDLE, XR_NULL_HANDLE};
203 XrSpace m_handAimSpace[2] {XR_NULL_HANDLE, XR_NULL_HANDLE};
206 HandActions m_handActions;
208 QSet<QQuick3DXrController *> m_controllers;
209 bool m_poseInUse[2][2] = {};
210 bool m_poseUsageDirty =
true;
212 uint m_aimStateFlags[2] = {};
213 bool m_initialized =
false;
214 bool m_validAimStateFromUpdatePoses[2] = {
false,
false};
216 void loadBindings(QList<ControllerBindings>* controllerBindingsList);
217 void setUpBindings(QList<ControllerBindings>* controllerBindingsList, QMap<InputNames, QXRHandComponentPath>* handComponentPaths);
220 struct HandMeshData {
221 QVector<XrVector3f> vertexPositions;
222 QVector<XrVector3f> vertexNormals;
223 QVector<XrVector2f> vertexUVs;
224 QVector<XrVector4sFB> vertexBlendIndices;
225 QVector<XrVector4f> vertexBlendWeights;
226 QVector<int16_t> indices;
227 XrPosef jointBindPoses[XR_HAND_JOINT_COUNT_EXT];
228 XrHandJointEXT jointParents[XR_HAND_JOINT_COUNT_EXT];
229 float jointRadii[XR_HAND_JOINT_COUNT_EXT];
233 struct HandGeometryData {
234 QQuick3DGeometry *geometry =
nullptr;
235 } m_handGeometryData[2];
237 QQuick3DGeometry *createHandMeshGeometry(
const HandMeshData &handMeshData);
238 void createHandModelData(Hand hand);
239 friend class QOpenXrHandModel;