Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/space_view3d/view3d_view.c')
-rw-r--r--source/blender/editors/space_view3d/view3d_view.c99
1 files changed, 91 insertions, 8 deletions
diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c
index b27bdf93389..159ea249337 100644
--- a/source/blender/editors/space_view3d/view3d_view.c
+++ b/source/blender/editors/space_view3d/view3d_view.c
@@ -36,6 +36,7 @@
#include "BKE_action.h"
#include "BKE_camera.h"
#include "BKE_context.h"
+#include "BKE_idprop.h"
#include "BKE_object.h"
#include "BKE_global.h"
#include "BKE_layer.h"
@@ -228,7 +229,7 @@ void ED_view3d_smooth_view_ex(
ob_camera_old_eval, sms.src.ofs, sms.src.quat, &sms.src.dist, &sms.src.lens);
}
/* grid draw as floor */
- if ((rv3d->viewlock & RV3D_LOCKED) == 0) {
+ if ((RV3D_LOCK_FLAGS(rv3d) & RV3D_LOCK_ROTATION) == 0) {
/* use existing if exists, means multiple calls to smooth view
* wont loose the original 'view' setting */
rv3d->view = RV3D_VIEW_USER;
@@ -291,7 +292,7 @@ void ED_view3d_smooth_view_ex(
ED_view3d_camera_lock_sync(depsgraph, v3d, rv3d);
}
- if (rv3d->viewlock & RV3D_BOXVIEW) {
+ if (RV3D_LOCK_FLAGS(rv3d) & RV3D_BOXVIEW) {
view3d_boxview_copy(sa, region);
}
@@ -344,7 +345,7 @@ static void view3d_smoothview_apply(bContext *C, View3D *v3d, ARegion *region, b
ED_view3d_camera_lock_autokey(v3d, rv3d, C, true, true);
}
- if ((rv3d->viewlock & RV3D_LOCKED) == 0) {
+ if ((RV3D_LOCK_FLAGS(rv3d) & RV3D_LOCK_ROTATION) == 0) {
rv3d->view = sms->org_view;
}
@@ -384,7 +385,7 @@ static void view3d_smoothview_apply(bContext *C, View3D *v3d, ARegion *region, b
WM_event_add_mousemove(CTX_wm_window(C));
}
- if (sync_boxview && (rv3d->viewlock & RV3D_BOXVIEW)) {
+ if (sync_boxview && (RV3D_LOCK_FLAGS(rv3d) & RV3D_BOXVIEW)) {
view3d_boxview_copy(CTX_wm_area(C), region);
}
@@ -494,7 +495,7 @@ static bool view3d_camera_to_view_poll(bContext *C)
if (ED_view3d_context_user_region(C, &v3d, &region)) {
RegionView3D *rv3d = region->regiondata;
if (v3d && v3d->camera && !ID_IS_LINKED(v3d->camera)) {
- if (rv3d && (rv3d->viewlock & RV3D_LOCKED) == 0) {
+ if (rv3d && (RV3D_LOCK_FLAGS(rv3d) & RV3D_LOCK_ANY_TRANSFORM) == 0) {
if (rv3d->persp != RV3D_CAMOB) {
return 1;
}
@@ -826,7 +827,7 @@ void view3d_viewmatrix_set(Depsgraph *depsgraph,
bool use_lock_ofs = false;
/* should be moved to better initialize later on XXX */
- if (rv3d->viewlock & RV3D_LOCKED) {
+ if (RV3D_LOCK_FLAGS(rv3d) & RV3D_LOCK_ROTATION) {
ED_view3d_lock(rv3d);
}
@@ -991,6 +992,7 @@ int view3d_opengl_select(ViewContext *vc,
eV3DSelectObjectFilter select_filter)
{
struct bThemeState theme_state;
+ const wmWindowManager *wm = CTX_wm_manager(vc->C);
Depsgraph *depsgraph = vc->depsgraph;
Scene *scene = vc->scene;
View3D *v3d = vc->v3d;
@@ -1097,7 +1099,7 @@ int view3d_opengl_select(ViewContext *vc,
/* Important we use the 'viewmat' and don't re-calculate since
* the object & bone view locking takes 'rect' into account, see: T51629. */
ED_view3d_draw_setup_view(
- vc->win, depsgraph, scene, region, v3d, vc->rv3d->viewmat, NULL, &rect);
+ wm, vc->win, depsgraph, scene, region, v3d, vc->rv3d->viewmat, NULL, &rect);
if (!XRAY_ACTIVE(v3d)) {
GPU_depth_test(true);
@@ -1165,7 +1167,8 @@ int view3d_opengl_select(ViewContext *vc,
}
G.f &= ~G_FLAG_PICKSEL;
- ED_view3d_draw_setup_view(vc->win, depsgraph, scene, region, v3d, vc->rv3d->viewmat, NULL, NULL);
+ ED_view3d_draw_setup_view(
+ wm, vc->win, depsgraph, scene, region, v3d, vc->rv3d->viewmat, NULL, NULL);
if (!XRAY_ACTIVE(v3d)) {
GPU_depth_test(false);
@@ -1684,3 +1687,83 @@ void ED_view3d_local_collections_reset(struct bContext *C, const bool reset_all)
}
/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name XR Functionality
+ * \{ */
+
+#ifdef WITH_XR_OPENXR
+
+static void view3d_xr_mirror_begin(RegionView3D *rv3d)
+{
+ /* 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. */
+ rv3d->persp = RV3D_PERSP;
+}
+
+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, &region_rv3d)) {
+ if (enable) {
+ view3d_xr_mirror_begin(region_rv3d->regiondata);
+ }
+ else {
+ view3d_xr_mirror_end(region_rv3d->regiondata);
+ }
+ }
+}
+
+void ED_view3d_xr_shading_update(wmWindowManager *wm, const View3D *v3d, const Scene *scene)
+{
+ if (v3d->runtime.flag & V3D_RUNTIME_XR_SESSION_ROOT) {
+ View3DShading *xr_shading = &wm->xr.session_settings.shading;
+
+ BLI_assert(WM_xr_session_exists(&wm->xr));
+
+ if (v3d->shading.type == OB_RENDER) {
+ if (!(BKE_scene_uses_blender_workbench(scene) || BKE_scene_uses_blender_eevee(scene))) {
+ /* Keep old shading while using Cycles or another engine, they are typically not usable in
+ * VR. */
+ return;
+ }
+ }
+
+ if (xr_shading->prop) {
+ IDP_FreeProperty(xr_shading->prop);
+ xr_shading->prop = NULL;
+ }
+
+ /* Copy shading from View3D to VR view. */
+ *xr_shading = v3d->shading;
+ if (v3d->shading.prop) {
+ xr_shading->prop = IDP_CopyProperty(xr_shading->prop);
+ }
+ }
+}
+
+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_ready(&wm->xr);
+}
+
+#endif
+
+/** \} */