mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2024-12-29 11:06:18 +00:00
st/oxr: Refactor out conversion helper to own header
This commit is contained in:
parent
b15ac35e76
commit
a980392b9e
52
src/xrt/state_trackers/oxr/oxr_conversions.h
Normal file
52
src/xrt/state_trackers/oxr/oxr_conversions.h
Normal file
|
@ -0,0 +1,52 @@
|
|||
// Copyright 2018-2023, Collabora, Ltd.
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
/*!
|
||||
* @file
|
||||
* @brief Smaller helper functions to convert between xrt and OpenXR things.
|
||||
* @author Christoph Haag <christoph.haag@collabora.com>
|
||||
* @author Jakob Bornecrantz <jakob@collabora.com>
|
||||
* @ingroup oxr_main
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "xrt/xrt_defines.h"
|
||||
#include "xrt/xrt_vulkan_includes.h"
|
||||
#include "xrt/xrt_openxr_includes.h"
|
||||
|
||||
|
||||
static inline XrSpaceLocationFlags
|
||||
xrt_to_xr_space_location_flags(enum xrt_space_relation_flags relation_flags)
|
||||
{
|
||||
// clang-format off
|
||||
bool valid_ori = (relation_flags & XRT_SPACE_RELATION_ORIENTATION_VALID_BIT) != 0;
|
||||
bool tracked_ori = (relation_flags & XRT_SPACE_RELATION_ORIENTATION_TRACKED_BIT) != 0;
|
||||
bool valid_pos = (relation_flags & XRT_SPACE_RELATION_POSITION_VALID_BIT) != 0;
|
||||
bool tracked_pos = (relation_flags & XRT_SPACE_RELATION_POSITION_TRACKED_BIT) != 0;
|
||||
|
||||
bool linear_vel = (relation_flags & XRT_SPACE_RELATION_LINEAR_VELOCITY_VALID_BIT) != 0;
|
||||
bool angular_vel = (relation_flags & XRT_SPACE_RELATION_ANGULAR_VELOCITY_VALID_BIT) != 0;
|
||||
// clang-format on
|
||||
|
||||
XrSpaceLocationFlags location_flags = (XrSpaceLocationFlags)0;
|
||||
if (valid_ori) {
|
||||
location_flags |= XR_SPACE_LOCATION_ORIENTATION_VALID_BIT;
|
||||
}
|
||||
if (tracked_ori) {
|
||||
location_flags |= XR_SPACE_LOCATION_ORIENTATION_TRACKED_BIT;
|
||||
}
|
||||
if (valid_pos) {
|
||||
location_flags |= XR_SPACE_LOCATION_POSITION_VALID_BIT;
|
||||
}
|
||||
if (tracked_pos) {
|
||||
location_flags |= XR_SPACE_LOCATION_POSITION_TRACKED_BIT;
|
||||
}
|
||||
if (linear_vel) {
|
||||
location_flags |= XR_SPACE_VELOCITY_LINEAR_VALID_BIT;
|
||||
}
|
||||
if (angular_vel) {
|
||||
location_flags |= XR_SPACE_VELOCITY_ANGULAR_VALID_BIT;
|
||||
}
|
||||
|
||||
return location_flags;
|
||||
}
|
|
@ -828,12 +828,10 @@ oxr_space_locate(
|
|||
XRT_CHECK_RESULT bool
|
||||
is_local_space_set_up(struct oxr_session *sess);
|
||||
|
||||
XrSpaceLocationFlags
|
||||
xrt_to_xr_space_location_flags(enum xrt_space_relation_flags relation_flags);
|
||||
|
||||
XRT_CHECK_RESULT bool
|
||||
global_to_local_space(struct oxr_logger *log, struct oxr_session *sess, XrTime time, struct xrt_space_relation *rel);
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* oxr_swapchain.c
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include "oxr_api_verify.h"
|
||||
#include "oxr_chain.h"
|
||||
#include "oxr_pretty_print.h"
|
||||
#include "oxr_conversions.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "oxr_input_transform.h"
|
||||
#include "oxr_chain.h"
|
||||
#include "oxr_pretty_print.h"
|
||||
#include "oxr_conversions.h"
|
||||
|
||||
|
||||
const struct xrt_pose origin = XRT_POSE_IDENTITY;
|
||||
|
@ -350,41 +351,6 @@ print_pose(struct oxr_session *sess, const char *prefix, struct xrt_pose *pose)
|
|||
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);
|
||||
}
|
||||
|
||||
XrSpaceLocationFlags
|
||||
xrt_to_xr_space_location_flags(enum xrt_space_relation_flags relation_flags)
|
||||
{
|
||||
// clang-format off
|
||||
bool valid_ori = (relation_flags & XRT_SPACE_RELATION_ORIENTATION_VALID_BIT) != 0;
|
||||
bool tracked_ori = (relation_flags & XRT_SPACE_RELATION_ORIENTATION_TRACKED_BIT) != 0;
|
||||
bool valid_pos = (relation_flags & XRT_SPACE_RELATION_POSITION_VALID_BIT) != 0;
|
||||
bool tracked_pos = (relation_flags & XRT_SPACE_RELATION_POSITION_TRACKED_BIT) != 0;
|
||||
|
||||
bool linear_vel = (relation_flags & XRT_SPACE_RELATION_LINEAR_VELOCITY_VALID_BIT) != 0;
|
||||
bool angular_vel = (relation_flags & XRT_SPACE_RELATION_ANGULAR_VELOCITY_VALID_BIT) != 0;
|
||||
// clang-format on
|
||||
|
||||
XrSpaceLocationFlags location_flags = (XrSpaceLocationFlags)0;
|
||||
if (valid_ori) {
|
||||
location_flags |= XR_SPACE_LOCATION_ORIENTATION_VALID_BIT;
|
||||
}
|
||||
if (tracked_ori) {
|
||||
location_flags |= XR_SPACE_LOCATION_ORIENTATION_TRACKED_BIT;
|
||||
}
|
||||
if (valid_pos) {
|
||||
location_flags |= XR_SPACE_LOCATION_POSITION_VALID_BIT;
|
||||
}
|
||||
if (tracked_pos) {
|
||||
location_flags |= XR_SPACE_LOCATION_POSITION_TRACKED_BIT;
|
||||
}
|
||||
if (linear_vel) {
|
||||
location_flags |= XR_SPACE_VELOCITY_LINEAR_VALID_BIT;
|
||||
}
|
||||
if (angular_vel) {
|
||||
location_flags |= XR_SPACE_VELOCITY_ANGULAR_VALID_BIT;
|
||||
}
|
||||
return location_flags;
|
||||
}
|
||||
|
||||
XrResult
|
||||
oxr_space_locate(
|
||||
struct oxr_logger *log, struct oxr_space *spc, struct oxr_space *baseSpc, XrTime time, XrSpaceLocation *location)
|
||||
|
|
Loading…
Reference in a new issue