mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2024-12-29 11:06:18 +00:00
st/oxr: Refactor pose and fov copies into helpers
This commit is contained in:
parent
1fb5656862
commit
85a2abaec6
|
@ -173,6 +173,37 @@ enum oxr_image_state
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* Helpers
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Safely copy a xrt_pose to a XrPosef.
|
||||||
|
*/
|
||||||
|
#define OXR_XRT_POSE_TO_XRPOSEF(FROM, TO) \
|
||||||
|
do { \
|
||||||
|
union { \
|
||||||
|
struct xrt_pose xrt; \
|
||||||
|
XrPosef oxr; \
|
||||||
|
} safe_copy = {FROM}; \
|
||||||
|
TO = safe_copy.oxr; \
|
||||||
|
} while (false)
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Safely copy a xrt_fov to a XrFovf.
|
||||||
|
*/
|
||||||
|
#define OXR_XRT_FOV_TO_XRFOVF(FROM, TO) \
|
||||||
|
do { \
|
||||||
|
union { \
|
||||||
|
struct xrt_fov xrt; \
|
||||||
|
XrFovf oxr; \
|
||||||
|
} safe_copy = {FROM}; \
|
||||||
|
TO = safe_copy.oxr; \
|
||||||
|
} while (false)
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* oxr_handle_base.c
|
* oxr_handle_base.c
|
||||||
|
|
|
@ -382,12 +382,7 @@ oxr_session_locate_views(struct oxr_logger *log,
|
||||||
if (!oxr_space_pure_relation_in_space(log, viewLocateInfo->displayTime, &pure_head_relation, baseSpc, true,
|
if (!oxr_space_pure_relation_in_space(log, viewLocateInfo->displayTime, &pure_head_relation, baseSpc, true,
|
||||||
&head_relation_in_base_space)) {
|
&head_relation_in_base_space)) {
|
||||||
for (uint32_t i = 0; i < view_count; i++) {
|
for (uint32_t i = 0; i < view_count; i++) {
|
||||||
union {
|
OXR_XRT_POSE_TO_XRPOSEF(XRT_POSE_IDENTITY, views[i].pose);
|
||||||
struct xrt_pose xrt;
|
|
||||||
struct XrPosef oxr;
|
|
||||||
} safe_copy_pose = {0};
|
|
||||||
safe_copy_pose.xrt = (struct xrt_pose)XRT_POSE_IDENTITY;
|
|
||||||
views[i].pose = safe_copy_pose.oxr;
|
|
||||||
}
|
}
|
||||||
return XR_SUCCESS;
|
return XR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -405,12 +400,7 @@ oxr_session_locate_views(struct oxr_logger *log,
|
||||||
m_relation_chain_push_pose_if_not_identity(&xrc, &view_pose);
|
m_relation_chain_push_pose_if_not_identity(&xrc, &view_pose);
|
||||||
m_relation_chain_push_relation(&xrc, &head_relation_in_base_space);
|
m_relation_chain_push_relation(&xrc, &head_relation_in_base_space);
|
||||||
m_relation_chain_resolve(&xrc, &result);
|
m_relation_chain_resolve(&xrc, &result);
|
||||||
union {
|
OXR_XRT_POSE_TO_XRPOSEF(result.pose, views[i].pose);
|
||||||
struct xrt_pose xrt;
|
|
||||||
struct XrPosef oxr;
|
|
||||||
} safe_copy_pose = {0};
|
|
||||||
safe_copy_pose.xrt = result.pose;
|
|
||||||
views[i].pose = safe_copy_pose.oxr;
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -418,13 +408,7 @@ oxr_session_locate_views(struct oxr_logger *log,
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const struct xrt_fov fov = fovs[i];
|
const struct xrt_fov fov = fovs[i];
|
||||||
|
OXR_XRT_FOV_TO_XRFOVF(fov, views[i].fov);
|
||||||
union {
|
|
||||||
struct xrt_fov xrt;
|
|
||||||
XrFovf oxr;
|
|
||||||
} safe_copy_fov = {0};
|
|
||||||
safe_copy_fov.xrt = fov;
|
|
||||||
views[i].fov = safe_copy_fov.oxr;
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -443,12 +443,7 @@ oxr_space_locate(
|
||||||
if (!has_pure_relation) {
|
if (!has_pure_relation) {
|
||||||
location->locationFlags = 0;
|
location->locationFlags = 0;
|
||||||
|
|
||||||
// Copy
|
OXR_XRT_POSE_TO_XRPOSEF(XRT_POSE_IDENTITY, location->pose);
|
||||||
union {
|
|
||||||
struct xrt_pose xrt;
|
|
||||||
XrPosef oxr;
|
|
||||||
} safe_copy = {XRT_POSE_IDENTITY};
|
|
||||||
location->pose = safe_copy.oxr;
|
|
||||||
|
|
||||||
XrSpaceVelocity *vel = (XrSpaceVelocity *)location->next;
|
XrSpaceVelocity *vel = (XrSpaceVelocity *)location->next;
|
||||||
if (vel) {
|
if (vel) {
|
||||||
|
@ -476,14 +471,7 @@ oxr_space_locate(
|
||||||
m_relation_chain_push_inverted_pose_if_not_identity(&xrc, &baseSpc->pose);
|
m_relation_chain_push_inverted_pose_if_not_identity(&xrc, &baseSpc->pose);
|
||||||
m_relation_chain_resolve(&xrc, &result);
|
m_relation_chain_resolve(&xrc, &result);
|
||||||
|
|
||||||
// Copy
|
OXR_XRT_POSE_TO_XRPOSEF(result.pose, location->pose);
|
||||||
union {
|
|
||||||
struct xrt_pose xrt;
|
|
||||||
XrPosef oxr;
|
|
||||||
} safe_copy = {0};
|
|
||||||
safe_copy.xrt = result.pose;
|
|
||||||
|
|
||||||
location->pose = safe_copy.oxr;
|
|
||||||
location->locationFlags = xrt_to_xr_space_location_flags(result.relation_flags);
|
location->locationFlags = xrt_to_xr_space_location_flags(result.relation_flags);
|
||||||
|
|
||||||
XrSpaceVelocity *vel = (XrSpaceVelocity *)location->next;
|
XrSpaceVelocity *vel = (XrSpaceVelocity *)location->next;
|
||||||
|
|
Loading…
Reference in a new issue