[Bf-blender-cvs] [03c9039e8b8] vr_scene_inspection: Cleanup: Improve naming of session state queries
Julian Eisel
noreply at git.blender.org
Mon Mar 16 11:22:37 CET 2020
Commit: 03c9039e8b8daf94fb98c64250aec9be83b9d451
Author: Julian Eisel
Date: Sun Mar 15 03:41:08 2020 +0100
Branches: vr_scene_inspection
https://developer.blender.org/rB03c9039e8b8daf94fb98c64250aec9be83b9d451
Cleanup: Improve naming of session state queries
===================================================================
M source/blender/editors/space_view3d/view3d_view.c
M source/blender/makesrna/intern/rna_space.c
M source/blender/makesrna/intern/rna_xr.c
M source/blender/windowmanager/WM_api.h
M source/blender/windowmanager/intern/wm_operators.c
M source/blender/windowmanager/intern/wm_xr.c
===================================================================
diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c
index 8e7fe1fb145..8da6099dbe8 100644
--- a/source/blender/editors/space_view3d/view3d_view.c
+++ b/source/blender/editors/space_view3d/view3d_view.c
@@ -1695,8 +1695,8 @@ void ED_view3d_local_collections_reset(struct bContext *C, const bool reset_all)
static void view3d_xr_mirror_begin(RegionView3D *rv3d)
{
- /* If the session is not running yet, changes below should not be applied! */
- BLI_assert(WM_xr_session_was_started(&((wmWindowManager *)G_MAIN->wm.first)->xr));
+ /* If there is no session yet, changes below should not be applied! */
+ BLI_assert(WM_xr_session_exists(&((wmWindowManager *)G_MAIN->wm.first)->xr));
rv3d->runtime_viewlock |= RV3D_LOCK_ANY_TRANSFORM;
/* Force perspective view. This isn't reset but that's not really an issue. */
@@ -1732,7 +1732,7 @@ bool ED_view3d_is_region_xr_mirror_active(const wmWindowManager *wm,
/* The free region (e.g. the camera region in quad-view) is always the last in the list
base. We don't want any other to be affected. */
!region->next && //
- WM_xr_session_is_running(&wm->xr);
+ WM_xr_session_is_ready(&wm->xr);
}
#endif
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index 7532c7ee922..d1baaebfe13 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -1340,8 +1340,8 @@ static void rna_SpaceView3D_mirror_xr_session_update(Main *main,
# ifdef WITH_XR_OPENXR
const wmWindowManager *wm = main->wm.first;
- /* Handle mirror toggling while a VR session runs. */
- if (WM_xr_session_was_started(&wm->xr)) {
+ /* Handle mirror toggling while there is a session already. */
+ if (WM_xr_session_exists(&wm->xr)) {
const View3D *v3d = ptr->data;
const ScrArea *area = rna_area_from_space(ptr);
ED_view3d_xr_mirror_update(area, v3d, v3d->flag & V3D_XR_SESSION_MIRROR);
diff --git a/source/blender/makesrna/intern/rna_xr.c b/source/blender/makesrna/intern/rna_xr.c
index 577f2d36a1d..e0e0d69d940 100644
--- a/source/blender/makesrna/intern/rna_xr.c
+++ b/source/blender/makesrna/intern/rna_xr.c
@@ -38,7 +38,7 @@ static bool rna_XrSessionState_is_running(bContext *C)
{
# ifdef WITH_XR_OPENXR
const wmWindowManager *wm = CTX_wm_manager(C);
- return WM_xr_session_is_running(&wm->xr);
+ return WM_xr_session_is_ready(&wm->xr);
# else
UNUSED_VARS(C);
return false;
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index 0516982e350..95e4ae62e7b 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -873,8 +873,8 @@ void WM_generic_user_data_free(struct wmGenericUserData *user_data);
#ifdef WITH_XR_OPENXR
/* wm_xr.c */
-bool WM_xr_session_was_started(const wmXrData *xr);
-bool WM_xr_session_is_running(const wmXrData *xr);
+bool WM_xr_session_exists(const wmXrData *xr);
+bool WM_xr_session_is_ready(const wmXrData *xr);
bool WM_xr_session_state_viewer_location_get(const wmXrData *xr, float r_location[3]);
bool WM_xr_session_state_viewer_rotation_get(const wmXrData *xr, float r_rotation[4]);
bool WM_xr_session_state_viewer_matrix_info_get(const wmXrData *xr,
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index da53da9ae14..a3093c3e241 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -3649,7 +3649,7 @@ static void WM_OT_stereo3d_set(wmOperatorType *ot)
static void wm_xr_session_update_mirror_views(Main *bmain, const wmXrData *xr_data)
{
- const bool enable = WM_xr_session_was_started(xr_data);
+ const bool enable = WM_xr_session_exists(xr_data);
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
for (ScrArea *area = screen->areabase.first; area; area = area->next) {
diff --git a/source/blender/windowmanager/intern/wm_xr.c b/source/blender/windowmanager/intern/wm_xr.c
index c3343be3036..15322fb4c49 100644
--- a/source/blender/windowmanager/intern/wm_xr.c
+++ b/source/blender/windowmanager/intern/wm_xr.c
@@ -355,7 +355,7 @@ wmXrSessionState *WM_xr_session_state_handle_get(const wmXrData *xr)
bool WM_xr_session_state_viewer_location_get(const wmXrData *xr, float r_location[3])
{
- if (!WM_xr_session_is_running(xr) || !xr->runtime->session_state.is_view_data_set) {
+ if (!WM_xr_session_is_ready(xr) || !xr->runtime->session_state.is_view_data_set) {
zero_v3(r_location);
return false;
}
@@ -366,7 +366,7 @@ bool WM_xr_session_state_viewer_location_get(const wmXrData *xr, float r_locatio
bool WM_xr_session_state_viewer_rotation_get(const wmXrData *xr, float r_rotation[4])
{
- if (!WM_xr_session_is_running(xr) || !xr->runtime->session_state.is_view_data_set) {
+ if (!WM_xr_session_is_ready(xr) || !xr->runtime->session_state.is_view_data_set) {
unit_qt(r_rotation);
return false;
}
@@ -379,7 +379,7 @@ bool WM_xr_session_state_viewer_matrix_info_get(const wmXrData *xr,
float r_viewmat[4][4],
float *r_focal_len)
{
- if (!WM_xr_session_is_running(xr) || !xr->runtime->session_state.is_view_data_set) {
+ if (!WM_xr_session_is_ready(xr) || !xr->runtime->session_state.is_view_data_set) {
unit_m4(r_viewmat);
*r_focal_len = 0.0f;
return false;
@@ -454,7 +454,7 @@ void wm_xr_session_toggle(wmWindowManager *wm,
{
wmXrData *xr_data = &wm->xr;
- if (WM_xr_session_was_started(xr_data)) {
+ if (WM_xr_session_exists(xr_data)) {
GHOST_XrSessionEnd(xr_data->runtime->context);
}
else {
@@ -470,29 +470,20 @@ void wm_xr_session_toggle(wmWindowManager *wm,
}
/**
- * Check if a session start was triggered and that there is no pending request to end the session.
+ * Check if the XR-Session was triggered.
* If an error happened while trying to start a session, this returns false too.
*/
-bool WM_xr_session_was_started(const wmXrData *xr)
+bool WM_xr_session_exists(const wmXrData *xr)
{
return xr->runtime && xr->runtime->context && xr->runtime->session_state.is_started;
}
/**
- * The definition used here to define a session as running differs slightly from the OpenXR
- * specification one: Here we already consider a session as stopped when session-end request was
- * issued. Ghost-XR may still have to handle session logic then, but Blender specific handling
- * should be stopped then.
- * This check should be used from external calls to WM_xr. Internally, GHOST_XrSessionIsRunning()
- * may have to be called instead. It checks for the running state according to the OpenXR
- * specification.
+ * Check if the session is running, according to the OpenXR definition.
*/
-bool WM_xr_session_is_running(const wmXrData *xr)
+bool WM_xr_session_is_ready(const wmXrData *xr)
{
- /* wmXrData.session_state will be NULL if session end was requested. That's what we use here to
- * define if the session was already stopped (even if according to OpenXR, it's still considered
- * running). */
- return WM_xr_session_was_started(xr) && GHOST_XrSessionIsRunning(xr->runtime->context);
+ return WM_xr_session_exists(xr) && GHOST_XrSessionIsRunning(xr->runtime->context);
}
/** \} */ /* XR-Session */
@@ -716,10 +707,7 @@ void wm_xr_draw_view(const GHOST_XrDrawViewInfo *draw_view, void *customdata)
float viewmat[4][4], winmat[4][4];
- /* The runtime may still trigger drawing while a session-end request is pending. */
- if (!wm->xr.runtime || !wm->xr.runtime->session_state.is_started) {
- return;
- }
+ BLI_assert(WM_xr_session_is_ready(&wm->xr));
wm_xr_draw_data_populate(session_state, draw_view, settings, scene, &draw_data);
wm_xr_draw_matrices_create(&draw_data, draw_view, settings, viewmat, winmat);
More information about the Bf-blender-cvs
mailing list