Blender V4.3
GHOST_Xr_intern.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2002-2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9#pragma once
10
11#include <memory>
12#include <vector>
13
15
16#define CHECK_XR(call, error_msg) \
17 { \
18 XrResult _res = call; \
19 if (XR_FAILED(_res)) { \
20 throw GHOST_XrException(error_msg, _res); \
21 } \
22 } \
23 (void)0
24
29#define CHECK_XR_ASSERT(call) \
30 { \
31 XrResult _res = call; \
32 assert(_res == XR_SUCCESS); \
33 (void)_res; \
34 } \
35 (void)0
36
37#define INIT_EXTENSION_FUNCTION(name) \
38 CHECK_XR( \
39 xrGetInstanceProcAddr(instance, #name, reinterpret_cast<PFN_xrVoidFunction *>(&g_##name)), \
40 "Failed to get pointer to extension function: " #name);
41
42inline void copy_ghost_pose_to_openxr_pose(const GHOST_XrPose &ghost_pose, XrPosef &r_oxr_pose)
43{
44 /* Set and convert to OpenXR coordinate space. */
45 r_oxr_pose.position.x = ghost_pose.position[0];
46 r_oxr_pose.position.y = ghost_pose.position[1];
47 r_oxr_pose.position.z = ghost_pose.position[2];
48 r_oxr_pose.orientation.w = ghost_pose.orientation_quat[0];
49 r_oxr_pose.orientation.x = ghost_pose.orientation_quat[1];
50 r_oxr_pose.orientation.y = ghost_pose.orientation_quat[2];
51 r_oxr_pose.orientation.z = ghost_pose.orientation_quat[3];
52}
53
54inline void copy_openxr_pose_to_ghost_pose(const XrPosef &oxr_pose, GHOST_XrPose &r_ghost_pose)
55{
56 /* Set and convert to Blender coordinate space. */
57 r_ghost_pose.position[0] = oxr_pose.position.x;
58 r_ghost_pose.position[1] = oxr_pose.position.y;
59 r_ghost_pose.position[2] = oxr_pose.position.z;
60 r_ghost_pose.orientation_quat[0] = oxr_pose.orientation.w;
61 r_ghost_pose.orientation_quat[1] = oxr_pose.orientation.x;
62 r_ghost_pose.orientation_quat[2] = oxr_pose.orientation.y;
63 r_ghost_pose.orientation_quat[3] = oxr_pose.orientation.z;
64}
void copy_openxr_pose_to_ghost_pose(const XrPosef &oxr_pose, GHOST_XrPose &r_ghost_pose)
void copy_ghost_pose_to_openxr_pose(const GHOST_XrPose &ghost_pose, XrPosef &r_oxr_pose)