The open source OpenXR runtime
0
fork

Configure Feed

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

st/oxr: Refactor out conversion helper to own header

+55 -38
+52
src/xrt/state_trackers/oxr/oxr_conversions.h
··· 1 + // Copyright 2018-2023, Collabora, Ltd. 2 + // SPDX-License-Identifier: BSL-1.0 3 + /*! 4 + * @file 5 + * @brief Smaller helper functions to convert between xrt and OpenXR things. 6 + * @author Christoph Haag <christoph.haag@collabora.com> 7 + * @author Jakob Bornecrantz <jakob@collabora.com> 8 + * @ingroup oxr_main 9 + */ 10 + 11 + #pragma once 12 + 13 + #include "xrt/xrt_defines.h" 14 + #include "xrt/xrt_vulkan_includes.h" 15 + #include "xrt/xrt_openxr_includes.h" 16 + 17 + 18 + static inline XrSpaceLocationFlags 19 + xrt_to_xr_space_location_flags(enum xrt_space_relation_flags relation_flags) 20 + { 21 + // clang-format off 22 + bool valid_ori = (relation_flags & XRT_SPACE_RELATION_ORIENTATION_VALID_BIT) != 0; 23 + bool tracked_ori = (relation_flags & XRT_SPACE_RELATION_ORIENTATION_TRACKED_BIT) != 0; 24 + bool valid_pos = (relation_flags & XRT_SPACE_RELATION_POSITION_VALID_BIT) != 0; 25 + bool tracked_pos = (relation_flags & XRT_SPACE_RELATION_POSITION_TRACKED_BIT) != 0; 26 + 27 + bool linear_vel = (relation_flags & XRT_SPACE_RELATION_LINEAR_VELOCITY_VALID_BIT) != 0; 28 + bool angular_vel = (relation_flags & XRT_SPACE_RELATION_ANGULAR_VELOCITY_VALID_BIT) != 0; 29 + // clang-format on 30 + 31 + XrSpaceLocationFlags location_flags = (XrSpaceLocationFlags)0; 32 + if (valid_ori) { 33 + location_flags |= XR_SPACE_LOCATION_ORIENTATION_VALID_BIT; 34 + } 35 + if (tracked_ori) { 36 + location_flags |= XR_SPACE_LOCATION_ORIENTATION_TRACKED_BIT; 37 + } 38 + if (valid_pos) { 39 + location_flags |= XR_SPACE_LOCATION_POSITION_VALID_BIT; 40 + } 41 + if (tracked_pos) { 42 + location_flags |= XR_SPACE_LOCATION_POSITION_TRACKED_BIT; 43 + } 44 + if (linear_vel) { 45 + location_flags |= XR_SPACE_VELOCITY_LINEAR_VALID_BIT; 46 + } 47 + if (angular_vel) { 48 + location_flags |= XR_SPACE_VELOCITY_ANGULAR_VALID_BIT; 49 + } 50 + 51 + return location_flags; 52 + }
+1 -3
src/xrt/state_trackers/oxr/oxr_objects.h
··· 828 828 XRT_CHECK_RESULT bool 829 829 is_local_space_set_up(struct oxr_session *sess); 830 830 831 - XrSpaceLocationFlags 832 - xrt_to_xr_space_location_flags(enum xrt_space_relation_flags relation_flags); 833 - 834 831 XRT_CHECK_RESULT bool 835 832 global_to_local_space(struct oxr_logger *log, struct oxr_session *sess, XrTime time, struct xrt_space_relation *rel); 833 + 836 834 837 835 /* 838 836 *
+1
src/xrt/state_trackers/oxr/oxr_session.c
··· 39 39 #include "oxr_api_verify.h" 40 40 #include "oxr_chain.h" 41 41 #include "oxr_pretty_print.h" 42 + #include "oxr_conversions.h" 42 43 43 44 #include <stdio.h> 44 45 #include <stdlib.h>
+1 -35
src/xrt/state_trackers/oxr/oxr_space.c
··· 23 23 #include "oxr_input_transform.h" 24 24 #include "oxr_chain.h" 25 25 #include "oxr_pretty_print.h" 26 + #include "oxr_conversions.h" 26 27 27 28 28 29 const struct xrt_pose origin = XRT_POSE_IDENTITY; ··· 348 349 struct xrt_quat *q = &pose->orientation; 349 350 350 351 U_LOG_D("%s (%f, %f, %f) (%f, %f, %f, %f)", prefix, p->x, p->y, p->z, q->x, q->y, q->z, q->w); 351 - } 352 - 353 - XrSpaceLocationFlags 354 - xrt_to_xr_space_location_flags(enum xrt_space_relation_flags relation_flags) 355 - { 356 - // clang-format off 357 - bool valid_ori = (relation_flags & XRT_SPACE_RELATION_ORIENTATION_VALID_BIT) != 0; 358 - bool tracked_ori = (relation_flags & XRT_SPACE_RELATION_ORIENTATION_TRACKED_BIT) != 0; 359 - bool valid_pos = (relation_flags & XRT_SPACE_RELATION_POSITION_VALID_BIT) != 0; 360 - bool tracked_pos = (relation_flags & XRT_SPACE_RELATION_POSITION_TRACKED_BIT) != 0; 361 - 362 - bool linear_vel = (relation_flags & XRT_SPACE_RELATION_LINEAR_VELOCITY_VALID_BIT) != 0; 363 - bool angular_vel = (relation_flags & XRT_SPACE_RELATION_ANGULAR_VELOCITY_VALID_BIT) != 0; 364 - // clang-format on 365 - 366 - XrSpaceLocationFlags location_flags = (XrSpaceLocationFlags)0; 367 - if (valid_ori) { 368 - location_flags |= XR_SPACE_LOCATION_ORIENTATION_VALID_BIT; 369 - } 370 - if (tracked_ori) { 371 - location_flags |= XR_SPACE_LOCATION_ORIENTATION_TRACKED_BIT; 372 - } 373 - if (valid_pos) { 374 - location_flags |= XR_SPACE_LOCATION_POSITION_VALID_BIT; 375 - } 376 - if (tracked_pos) { 377 - location_flags |= XR_SPACE_LOCATION_POSITION_TRACKED_BIT; 378 - } 379 - if (linear_vel) { 380 - location_flags |= XR_SPACE_VELOCITY_LINEAR_VALID_BIT; 381 - } 382 - if (angular_vel) { 383 - location_flags |= XR_SPACE_VELOCITY_ANGULAR_VALID_BIT; 384 - } 385 - return location_flags; 386 352 } 387 353 388 354 XrResult