The open source OpenXR runtime
0
fork

Configure Feed

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

st/oxr: Add XRT_CHECK_RESULT to some space functions

authored by

Jakob Bornecrantz and committed by
Jakob Bornecrantz
291e7957 e89e3d52

+48 -26
+7 -7
src/xrt/state_trackers/oxr/oxr_objects.h
··· 701 701 * Transforms a relation given in pure global space into the oxr_space @p spc. 702 702 * If @p apply_space_pose is true, the pose offset of @p spc will be included in @p out_relation. 703 703 */ 704 - bool 704 + XRT_CHECK_RESULT bool 705 705 oxr_space_pure_relation_in_space(struct oxr_logger *log, 706 706 XrTime time, 707 707 struct xrt_space_relation *relation, ··· 713 713 * Transforms a pose given in pure global space into a relation in the oxr_space @p spc. 714 714 * If @p apply_space_pose is true, the pose offset of @p spc will be included in @p out_relation. 715 715 */ 716 - bool 716 + XRT_CHECK_RESULT bool 717 717 oxr_space_pure_pose_in_space(struct oxr_logger *log, 718 718 XrTime time, 719 719 struct xrt_pose *pose, ··· 725 725 * Transforms a relation in an given oxr_space @p spc into pure global space, taking the pose offset of @p spc into 726 726 * account. 727 727 */ 728 - bool 728 + XRT_CHECK_RESULT bool 729 729 oxr_space_pure_relation_from_space(struct oxr_logger *log, 730 730 XrTime time, 731 731 struct xrt_space_relation *relation, ··· 736 736 * Transforms a posen in a given oxr_space @p spc into a relation in "pure" global space, taking the pose offset of @p 737 737 * spc into account. 738 738 */ 739 - bool 739 + XRT_CHECK_RESULT bool 740 740 oxr_space_pure_pose_from_space(struct oxr_logger *log, 741 741 XrTime time, 742 742 struct xrt_pose *pose, ··· 749 749 * 750 750 * @todo: This function currently assumes all reference spaces are associated with the HMD. 751 751 */ 752 - bool 752 + XRT_CHECK_RESULT bool 753 753 oxr_space_get_pure_relation(struct oxr_logger *log, 754 754 struct oxr_space *spc, 755 755 XrTime time, ··· 760 760 oxr_space_locate( 761 761 struct oxr_logger *log, struct oxr_space *spc, struct oxr_space *baseSpc, XrTime time, XrSpaceLocation *location); 762 762 763 - bool 763 + XRT_CHECK_RESULT bool 764 764 is_local_space_set_up(struct oxr_session *sess); 765 765 766 766 XrSpaceLocationFlags 767 767 xrt_to_xr_space_location_flags(enum xrt_space_relation_flags relation_flags); 768 768 769 - bool 769 + XRT_CHECK_RESULT bool 770 770 global_to_local_space(struct oxr_logger *log, struct oxr_session *sess, XrTime time, struct xrt_space_relation *rel); 771 771 772 772 /*
+25 -10
src/xrt/state_trackers/oxr/oxr_session.c
··· 856 856 m_relation_chain_resolve(&xrc, &pure_hand_relation); 857 857 858 858 struct xrt_space_relation hand_pose_in_base_space; 859 - oxr_space_pure_relation_in_space(log, at_time, &pure_hand_relation, baseSpc, true, &hand_pose_in_base_space); 859 + bool has_hand_pose_in_base_sapce = oxr_space_pure_relation_in_space( // 860 + log, // 861 + at_time, // 862 + &pure_hand_relation, // 863 + baseSpc, // 864 + true, // 865 + &hand_pose_in_base_space); // 860 866 867 + // Can we not relate to this space or did we not get values? 868 + if (!has_hand_pose_in_base_sapce || !value.is_active) { 869 + locations->isActive = false; 870 + 871 + // Loop over all joints and zero flags. 872 + for (uint32_t i = 0; i < locations->jointCount; i++) { 873 + locations->jointLocations[i].locationFlags = XRT_SPACE_RELATION_BITMASK_NONE; 874 + if (vel) { 875 + XrHandJointVelocityEXT *v = &vel->jointVelocities[i]; 876 + v->velocityFlags = XRT_SPACE_RELATION_BITMASK_NONE; 877 + } 878 + } 879 + 880 + return XR_SUCCESS; 881 + } 882 + 883 + // We know we are active. 884 + locations->isActive = true; 861 885 862 886 for (uint32_t i = 0; i < locations->jointCount; i++) { 863 887 locations->jointLocations[i].locationFlags = ··· 892 916 v->angularVelocity.x = result.angular_velocity.x; 893 917 v->angularVelocity.y = result.angular_velocity.y; 894 918 v->angularVelocity.z = result.angular_velocity.z; 895 - } 896 - } 897 - 898 - if (value.is_active) { 899 - locations->isActive = true; 900 - } else { 901 - locations->isActive = false; 902 - for (uint32_t i = 0; i < locations->jointCount; i++) { 903 - locations->jointLocations[i].locationFlags = XRT_SPACE_RELATION_BITMASK_NONE; 904 919 } 905 920 } 906 921
+16 -9
src/xrt/state_trackers/oxr/oxr_space.c
··· 166 166 * @todo: Until a proper reference space system is implemented, the xdev assigned to the head role should be used as @p 167 167 * ref_xdev for consistency. 168 168 */ 169 - static bool 169 + XRT_CHECK_RESULT static bool 170 170 oxr_space_ref_get_pure_relation(struct oxr_logger *log, 171 171 struct oxr_session *sess, 172 172 XrReferenceSpaceType ref_type, ··· 215 215 { 216 216 struct xrt_space_relation pure_space_relation; 217 217 struct xrt_device *xdev; 218 - oxr_space_get_pure_relation(log, spc, time, &pure_space_relation, &xdev); 218 + if (!oxr_space_get_pure_relation(log, spc, time, &pure_space_relation, &xdev)) { 219 + return false; 220 + } 219 221 220 222 struct xrt_relation_chain xrc = {0}; 221 223 ··· 325 327 * This returns only the relation between two directly-associated spaces without 326 328 * the app given offset pose for baseSpc applied. 327 329 */ 328 - static XrResult 330 + XRT_CHECK_RESULT static bool 329 331 get_pure_space_relation(struct oxr_logger *log, 330 332 struct oxr_space *spc, 331 333 struct oxr_space *baseSpc, ··· 334 336 { 335 337 struct xrt_space_relation space_pure_relation; 336 338 struct xrt_device *space_xdev; 337 - oxr_space_get_pure_relation(log, spc, time, &space_pure_relation, &space_xdev); 339 + if (!oxr_space_get_pure_relation(log, spc, time, &space_pure_relation, &space_xdev)) { 340 + return false; 341 + } 338 342 339 343 struct xrt_space_relation base_space_pure_relation; 340 344 struct xrt_device *base_space_xdev; 341 - oxr_space_get_pure_relation(log, baseSpc, time, &base_space_pure_relation, &base_space_xdev); 345 + if (!oxr_space_get_pure_relation(log, baseSpc, time, &base_space_pure_relation, &base_space_xdev)) { 346 + return false; 347 + } 342 348 343 349 struct xrt_relation_chain xrc = {0}; 344 350 m_relation_chain_push_relation(&xrc, &space_pure_relation); 345 351 m_relation_chain_push_inverted_relation(&xrc, &base_space_pure_relation); 346 352 m_relation_chain_resolve(&xrc, out_relation); 347 353 348 - return XR_SUCCESS; 354 + return true; 349 355 } 350 356 351 357 static void ··· 420 426 421 427 // Get the pure space relation. 422 428 struct xrt_space_relation pure; 423 - XrResult ret = get_pure_space_relation(log, spc, baseSpc, time, &pure); 424 - if (ret != XR_SUCCESS) { 429 + bool has_pure_relation = get_pure_space_relation(log, spc, baseSpc, time, &pure); 430 + if (!has_pure_relation) { 425 431 location->locationFlags = 0; 426 - return ret; 432 + return XR_SUCCESS; 427 433 } 434 + 428 435 429 436 // Combine space and base space poses with pure relation 430 437 struct xrt_space_relation result;