[Bf-blender-cvs] [6b69b5349be] soc-2019-openxr: Address and remove some TODOs marked in code
Julian Eisel
noreply at git.blender.org
Thu Aug 22 23:24:49 CEST 2019
Commit: 6b69b5349be81ff941bb60920e0a382931483c50
Author: Julian Eisel
Date: Thu Aug 22 23:23:46 2019 +0200
Branches: soc-2019-openxr
https://developer.blender.org/rB6b69b5349be81ff941bb60920e0a382931483c50
Address and remove some TODOs marked in code
===================================================================
M intern/ghost/intern/GHOST_XrContext.cpp
M intern/ghost/intern/GHOST_XrSession.cpp
M intern/ghost/intern/GHOST_Xr_intern.h
M source/blender/windowmanager/intern/wm_xr.c
===================================================================
diff --git a/intern/ghost/intern/GHOST_XrContext.cpp b/intern/ghost/intern/GHOST_XrContext.cpp
index 7fbcb30196b..fbced7dceaa 100644
--- a/intern/ghost/intern/GHOST_XrContext.cpp
+++ b/intern/ghost/intern/GHOST_XrContext.cpp
@@ -65,8 +65,6 @@ GHOST_XrContext::GHOST_XrContext(const GHOST_XrContextCreateInfo *create_info)
}
GHOST_XrContext::~GHOST_XrContext()
{
- // TODO OpenXR calls here can fail, but we should not throw an exception in the destructor.
-
/* Destroy session data first. Otherwise xrDestroyInstance will implicitly do it, before the
* session had a chance to do so explicitly. */
m_session = nullptr;
@@ -76,7 +74,7 @@ GHOST_XrContext::~GHOST_XrContext()
m_oxr->s_xrDestroyDebugUtilsMessengerEXT_fn(m_oxr->debug_messenger);
}
if (m_oxr->instance != XR_NULL_HANDLE) {
- xrDestroyInstance(m_oxr->instance);
+ CHECK_XR_ASSERT(xrDestroyInstance(m_oxr->instance));
m_oxr->instance = XR_NULL_HANDLE;
}
}
diff --git a/intern/ghost/intern/GHOST_XrSession.cpp b/intern/ghost/intern/GHOST_XrSession.cpp
index b388ba07c0f..52db74ded5b 100644
--- a/intern/ghost/intern/GHOST_XrSession.cpp
+++ b/intern/ghost/intern/GHOST_XrSession.cpp
@@ -69,19 +69,17 @@ GHOST_XrSession::GHOST_XrSession(GHOST_XrContext *xr_context)
GHOST_XrSession::~GHOST_XrSession()
{
- // TODO OpenXR calls here can fail, but we should not throw an exception in the destructor.
-
unbindGraphicsContext();
for (XrSwapchain &swapchain : m_oxr->swapchains) {
- xrDestroySwapchain(swapchain);
+ CHECK_XR_ASSERT(xrDestroySwapchain(swapchain));
}
m_oxr->swapchains.clear();
if (m_oxr->reference_space != XR_NULL_HANDLE) {
- xrDestroySpace(m_oxr->reference_space);
+ CHECK_XR_ASSERT(xrDestroySpace(m_oxr->reference_space));
}
if (m_oxr->session != XR_NULL_HANDLE) {
- xrDestroySession(m_oxr->session);
+ CHECK_XR_ASSERT(xrDestroySession(m_oxr->session));
}
m_oxr->session = XR_NULL_HANDLE;
diff --git a/intern/ghost/intern/GHOST_Xr_intern.h b/intern/ghost/intern/GHOST_Xr_intern.h
index df68ccedd4f..2f3346c1925 100644
--- a/intern/ghost/intern/GHOST_Xr_intern.h
+++ b/intern/ghost/intern/GHOST_Xr_intern.h
@@ -32,7 +32,15 @@
if (XR_FAILED(_res)) { \
throw GHOST_XrException(error_msg, __FILE__, __LINE__, _res); \
} \
- }
+ } \
+ (void)0
+
+#define CHECK_XR_ASSERT(call) \
+ { \
+ XrResult _res = call; \
+ assert(_res == XR_SUCCESS); \
+ } \
+ (void)0
#define THROW_XR(error_msg) throw GHOST_XrException(error_msg, __FILE__, __LINE__);
diff --git a/source/blender/windowmanager/intern/wm_xr.c b/source/blender/windowmanager/intern/wm_xr.c
index 772c13089fd..a514eb31c5b 100644
--- a/source/blender/windowmanager/intern/wm_xr.c
+++ b/source/blender/windowmanager/intern/wm_xr.c
@@ -187,8 +187,16 @@ static void wm_xr_session_begin_info_create(const Scene *scene,
{
if (scene->camera) {
copy_v3_v3(begin_info->base_pose.position, scene->camera->loc);
- /* TODO will only work if rotmode is euler */
- eul_to_quat(begin_info->base_pose.orientation_quat, scene->camera->rot);
+ if (ELEM(scene->camera->rotmode, ROT_MODE_AXISANGLE, ROT_MODE_QUAT)) {
+ axis_angle_to_quat(
+ begin_info->base_pose.orientation_quat, scene->camera->rotAxis, scene->camera->rotAngle);
+ }
+ else if (scene->camera->rotmode == ROT_MODE_QUAT) {
+ copy_v4_v4(begin_info->base_pose.orientation_quat, scene->camera->quat);
+ }
+ else {
+ eul_to_quat(begin_info->base_pose.orientation_quat, scene->camera->rot);
+ }
}
else {
copy_v3_fl(begin_info->base_pose.position, 0.0f);
@@ -404,8 +412,8 @@ GHOST_ContextHandle wm_xr_draw_view(const GHOST_XrDrawViewInfo *draw_view, void
{
bContext *C = customdata;
wmXrSurfaceData *surface_data = g_xr_surface->customdata;
- const float clip_start = 0.01, clip_end = 500.0f;
- const float lens = 50.0f; /* TODO get from OpenXR */
+ const float clip_start = 0.01f, clip_end = 500.0f;
+ const float lens = 50.0f;
const rcti rect = {
.xmin = 0, .ymin = 0, .xmax = draw_view->width - 1, .ymax = draw_view->height - 1};
More information about the Bf-blender-cvs
mailing list