[Bf-blender-cvs] [1a07728c997] vr_scene_inspection: Refactor XR mirror toggling some more
Julian Eisel
noreply at git.blender.org
Thu Mar 12 14:45:41 CET 2020
Commit: 1a07728c997aedda35ca5e31ce4d2523190babb3
Author: Julian Eisel
Date: Thu Mar 12 14:45:18 2020 +0100
Branches: vr_scene_inspection
https://developer.blender.org/rB1a07728c997aedda35ca5e31ce4d2523190babb3
Refactor XR mirror toggling some more
===================================================================
M source/blender/editors/include/ED_view3d.h
M source/blender/editors/space_view3d/view3d_view.c
M source/blender/makesrna/intern/rna_space.c
M source/blender/windowmanager/intern/wm_operators.c
===================================================================
diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h
index a3e9fd5efa5..c83edda9fb6 100644
--- a/source/blender/editors/include/ED_view3d.h
+++ b/source/blender/editors/include/ED_view3d.h
@@ -735,8 +735,9 @@ bool ED_view3d_local_collections_set(struct Main *bmain, struct View3D *v3d);
void ED_view3d_local_collections_reset(struct bContext *C, const bool reset_all);
#ifdef WITH_XR_OPENXR
-void ED_view3d_xr_mirror_begin(RegionView3D *rv3d);
-void ED_view3d_xr_mirror_end(RegionView3D *rv3d);
+void ED_view3d_xr_mirror_update(const struct ScrArea *area,
+ const struct View3D *v3d,
+ const bool enable);
#endif
#ifdef __cplusplus
diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c
index f3e37d6b2b9..cb641c55e44 100644
--- a/source/blender/editors/space_view3d/view3d_view.c
+++ b/source/blender/editors/space_view3d/view3d_view.c
@@ -1693,7 +1693,7 @@ void ED_view3d_local_collections_reset(struct bContext *C, const bool reset_all)
#ifdef WITH_XR_OPENXR
-void ED_view3d_xr_mirror_begin(RegionView3D *rv3d)
+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));
@@ -1703,11 +1703,27 @@ void ED_view3d_xr_mirror_begin(RegionView3D *rv3d)
rv3d->persp = RV3D_PERSP;
}
-void ED_view3d_xr_mirror_end(RegionView3D *rv3d)
+static void view3d_xr_mirror_end(RegionView3D *rv3d)
{
rv3d->runtime_viewlock &= ~RV3D_LOCK_ANY_TRANSFORM;
}
+void ED_view3d_xr_mirror_update(const ScrArea *area, const View3D *v3d, const bool enable)
+{
+ ARegion *region_rv3d;
+
+ BLI_assert(v3d->spacetype == SPACE_VIEW3D);
+
+ if (ED_view3d_area_user_region(area, v3d, ®ion_rv3d)) {
+ if (enable) {
+ view3d_xr_mirror_begin(region_rv3d->regiondata);
+ }
+ else {
+ view3d_xr_mirror_end(region_rv3d->regiondata);
+ }
+ }
+}
+
#endif
/** \} */
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index 7e49965b24f..2d60d523f00 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -1338,26 +1338,13 @@ static void rna_SpaceView3D_mirror_xr_session_update(Main *main,
PointerRNA *ptr)
{
# ifdef WITH_XR_OPENXR
- wmWindowManager *wm = main->wm.first;
- ScrArea *area = rna_area_from_space(ptr);
- View3D *v3d = ptr->data;
- ARegion *region_rv3d = NULL;
-
- /* The VR session may not have been started yet, so the view should only be tagged to
- * let the VR code manage the call to ED_view3d_xr_mirror_begin/end(). */
- if (!WM_xr_session_was_started(&wm->xr)) {
- return;
- }
+ const wmWindowManager *wm = main->wm.first;
/* Handle mirror toggling while a VR session runs. */
-
- if (ED_view3d_area_user_region(area, v3d, ®ion_rv3d)) {
- if (v3d->flag & V3D_XR_SESSION_MIRROR) {
- ED_view3d_xr_mirror_begin(region_rv3d->regiondata);
- }
- else {
- ED_view3d_xr_mirror_end(region_rv3d->regiondata);
- }
+ if (WM_xr_session_was_started(&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);
}
# else
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index bb4b99e2f28..1fae8bb42b0 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -3655,19 +3655,10 @@ static void wm_xr_session_update_mirror_views(Main *bmain, wmWindowManager *wm)
for (ScrArea *area = screen->areabase.first; area; area = area->next) {
for (SpaceLink *slink = area->spacedata.first; slink; slink = slink->next) {
if (slink->spacetype == SPACE_VIEW3D) {
- View3D *v3d = (View3D *)slink;
+ const View3D *v3d = (View3D *)slink;
if (v3d->flag & V3D_XR_SESSION_MIRROR) {
- ARegion *region_rv3d;
-
- if (ED_view3d_area_user_region(area, (View3D *)slink, ®ion_rv3d)) {
- if (enable) {
- ED_view3d_xr_mirror_begin(region_rv3d->regiondata);
- }
- else {
- ED_view3d_xr_mirror_end(region_rv3d->regiondata);
- }
- }
+ ED_view3d_xr_mirror_update(area, v3d, enable);
}
}
}
More information about the Bf-blender-cvs
mailing list