1
1

Force continuous redraws of mirrored 3D Views

This commit is contained in:
2020-03-13 13:03:37 +01:00
parent 5ea28551cb
commit 3bc41d2f50
4 changed files with 32 additions and 12 deletions

View File

@@ -738,6 +738,9 @@ void ED_view3d_local_collections_reset(struct bContext *C, const bool reset_all)
void ED_view3d_xr_mirror_update(const struct ScrArea *area,
const struct View3D *v3d,
const bool enable);
bool ED_view3d_is_region_xr_mirror_active(const struct wmWindowManager *wm,
const struct View3D *v3d,
const struct ARegion *region);
#endif
#ifdef __cplusplus

View File

@@ -315,17 +315,6 @@ static void view3d_stereo3d_setup(
}
#ifdef WITH_XR_OPENXR
static bool view3d_xr_mirror_active(const wmWindowManager *wm,
const View3D *v3d,
const ARegion *region)
{
return (v3d->flag & V3D_XR_SESSION_MIRROR) &&
/* 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);
}
static void view3d_xr_mirror_setup(const wmWindowManager *wm,
Depsgraph *depsgraph,
Scene *scene,
@@ -366,7 +355,7 @@ void ED_view3d_draw_setup_view(const wmWindowManager *wm,
#ifdef WITH_XR_OPENXR
/* Setup the view matrix. */
if (view3d_xr_mirror_active(wm, v3d, region)) {
if (ED_view3d_is_region_xr_mirror_active(wm, v3d, region)) {
view3d_xr_mirror_setup(wm, depsgraph, scene, v3d, region, rect);
}
else

View File

@@ -1724,6 +1724,17 @@ void ED_view3d_xr_mirror_update(const ScrArea *area, const View3D *v3d, const bo
}
}
bool ED_view3d_is_region_xr_mirror_active(const wmWindowManager *wm,
const View3D *v3d,
const ARegion *region)
{
return (v3d->flag & V3D_XR_SESSION_MIRROR) &&
/* 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);
}
#endif
/** \} */

View File

@@ -257,6 +257,19 @@ static void wm_region_test_render_do_draw(const Scene *scene,
}
}
#ifdef WITH_XR_OPENXR
static void wm_region_test_xr_do_draw(const wmWindowManager *wm,
const ScrArea *area,
ARegion *region)
{
if (area->spacetype == SPACE_VIEW3D && region->regiontype == RGN_TYPE_WINDOW) {
if (ED_view3d_is_region_xr_mirror_active(wm, area->spacedata.first, region->regiondata)) {
ED_region_tag_redraw_no_rebuild(region);
}
}
}
#endif
static bool wm_region_use_viewport_by_type(short space_type, short region_type)
{
return (ELEM(space_type, SPACE_VIEW3D, SPACE_IMAGE) && region_type == RGN_TYPE_WINDOW);
@@ -875,6 +888,7 @@ static void wm_draw_surface(bContext *C, wmSurface *surface)
/* quick test to prevent changing window drawable */
static bool wm_draw_update_test_window(Main *bmain, bContext *C, wmWindow *win)
{
const wmWindowManager *wm = CTX_wm_manager(C);
Scene *scene = WM_window_get_active_scene(win);
ViewLayer *view_layer = WM_window_get_active_view_layer(win);
struct Depsgraph *depsgraph = BKE_scene_get_depsgraph(bmain, scene, view_layer, true);
@@ -897,6 +911,9 @@ static bool wm_draw_update_test_window(Main *bmain, bContext *C, wmWindow *win)
for (region = sa->regionbase.first; region; region = region->next) {
wm_region_test_gizmo_do_draw(C, sa, region, true);
wm_region_test_render_do_draw(scene, depsgraph, sa, region);
#ifdef WITH_XR_OPENXR
wm_region_test_xr_do_draw(wm, sa, region);
#endif
if (region->visible && region->do_draw) {
do_draw = true;