The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

u/json: Add u_json_get_pose

authored by

Moses Turner and committed by
Jakob Bornecrantz
b31eb767 d9197529

+26
+17
src/xrt/auxiliary/util/u_json.c
··· 262 262 return true; 263 263 } 264 264 265 + // note: you should be using "position" and "orientation" and lower-case xyz(w) 266 + bool 267 + u_json_get_pose(const cJSON *json, struct xrt_pose *out_pose) 268 + { 269 + struct xrt_pose tmp; 270 + 271 + bool good = true; 272 + good = good && u_json_get_vec3(u_json_get(json, "position"), &tmp.position); 273 + good = good && u_json_get_quat(u_json_get(json, "orientation"), &tmp.orientation); 274 + 275 + if (good) { 276 + *out_pose = tmp; 277 + } 278 + return good; 279 + } 280 + 281 + 265 282 size_t 266 283 u_json_get_float_array(const cJSON *json_array, float *out_array, size_t max_size) 267 284 {
+9
src/xrt/auxiliary/util/u_json.h
··· 102 102 u_json_get_quat(const cJSON *json, struct xrt_quat *out_quat); 103 103 104 104 /*! 105 + * @brief Parse a pose from a JSON object, composed of a vec3 named "position" and a quat named "orientation". 106 + * 107 + * @return true if successful, false if not. 108 + */ 109 + bool 110 + u_json_get_pose(const cJSON *json, struct xrt_pose *out_pose); 111 + 112 + 113 + /*! 105 114 * @brief Parse up to max_size floats from a JSON array. 106 115 * 107 116 * @return the number of elements set.