Blender V5.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
8
9#pragma once
10
11#include <memory>
12#include <vector>
13
14#include "GHOST_Types.hh"
16
17#include "CLG_log.h"
18
21
22#define CHECK_XR(call, error_msg) \
23 { \
24 XrResult _res = call; \
25 if (XR_FAILED(_res)) { \
26 throw GHOST_XrException(error_msg, _res); \
27 } \
28 } \
29 (void)0
30
35#define CHECK_XR_ASSERT(call) \
36 { \
37 XrResult _res = call; \
38 assert(_res == XR_SUCCESS); \
39 (void)_res; \
40 } \
41 (void)0
42
43#define INIT_EXTENSION_FUNCTION(name) \
44 CHECK_XR( \
45 xrGetInstanceProcAddr(instance, #name, reinterpret_cast<PFN_xrVoidFunction *>(&g_##name)), \
46 "Failed to get pointer to extension function: " #name);
47
48inline void copy_ghost_pose_to_openxr_pose(const GHOST_XrPose &ghost_pose, XrPosef &r_oxr_pose)
49{
50 /* Set and convert to OpenXR coordinate space. */
51 r_oxr_pose.position.x = ghost_pose.position[0];
52 r_oxr_pose.position.y = ghost_pose.position[1];
53 r_oxr_pose.position.z = ghost_pose.position[2];
54 r_oxr_pose.orientation.w = ghost_pose.orientation_quat[0];
55 r_oxr_pose.orientation.x = ghost_pose.orientation_quat[1];
56 r_oxr_pose.orientation.y = ghost_pose.orientation_quat[2];
57 r_oxr_pose.orientation.z = ghost_pose.orientation_quat[3];
58}
59
60inline void copy_openxr_pose_to_ghost_pose(const XrPosef &oxr_pose, GHOST_XrPose &r_ghost_pose)
61{
62 /* Set and convert to Blender coordinate space. */
63 r_ghost_pose.position[0] = oxr_pose.position.x;
64 r_ghost_pose.position[1] = oxr_pose.position.y;
65 r_ghost_pose.position[2] = oxr_pose.position.z;
66 r_ghost_pose.orientation_quat[0] = oxr_pose.orientation.w;
67 r_ghost_pose.orientation_quat[1] = oxr_pose.orientation.x;
68 r_ghost_pose.orientation_quat[2] = oxr_pose.orientation.y;
69 r_ghost_pose.orientation_quat[3] = oxr_pose.orientation.z;
70}
CLG_LogRef * LOG_GHOST_XR
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)