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};
138 XrActionSet m_actionSet{XR_NULL_HANDLE};
139 XrPath m_handSubactionPath[2] = {XR_NULL_PATH, XR_NULL_PATH};
140 XrSpace m_handGripSpace[2] {XR_NULL_HANDLE, XR_NULL_HANDLE};
141 XrSpace m_handAimSpace[2] {XR_NULL_HANDLE, XR_NULL_HANDLE};
144 HandActions m_handActions;
146 QSet<QQuick3DXrController *> m_controllers;
147 bool m_poseInUse[2][2] = {};
148 bool m_poseUsageDirty =
true;
150 uint m_aimStateFlags[2] = {};
151 bool m_initialized =
false;
152 bool m_validAimStateFromUpdatePoses[2] = {
false,
false};
155 struct HandMeshData {
156 QVector<XrVector3f> vertexPositions;
157 QVector<XrVector3f> vertexNormals;
158 QVector<XrVector2f> vertexUVs;
159 QVector<XrVector4sFB> vertexBlendIndices;
160 QVector<XrVector4f> vertexBlendWeights;
161 QVector<int16_t> indices;
162 XrPosef jointBindPoses[XR_HAND_JOINT_COUNT_EXT];
163 XrHandJointEXT jointParents[XR_HAND_JOINT_COUNT_EXT];
164 float jointRadii[XR_HAND_JOINT_COUNT_EXT];
168 struct HandGeometryData {
169 QQuick3DGeometry *geometry =
nullptr;
170 } m_handGeometryData[2];
172 QQuick3DGeometry *createHandMeshGeometry(
const HandMeshData &handMeshData);
173 void createHandModelData(Hand hand);
174 friend class QOpenXrHandModel;