[Bf-blender-cvs] [1792bf1c0a1] vr_scene_inspection: Always sync VR view shading with the 3D View the session was started in
Julian Eisel
noreply at git.blender.org
Tue Mar 17 15:45:01 CET 2020
Commit: 1792bf1c0a1c1b6944eb95f979ee5fe55f0df887
Author: Julian Eisel
Date: Tue Mar 17 15:43:12 2020 +0100
Branches: vr_scene_inspection
https://developer.blender.org/rB1792bf1c0a1c1b6944eb95f979ee5fe55f0df887
Always sync VR view shading with the 3D View the session was started in
Added a notifier subtype so that we can avoid unnecesarry updates of the
VR shading settings.
The VR session now needs to be invoked from a 3D View.
===================================================================
M source/blender/blenloader/intern/readfile.c
M source/blender/editors/include/ED_view3d.h
M source/blender/editors/space_view3d/space_view3d.c
M source/blender/editors/space_view3d/view3d_view.c
M source/blender/makesdna/DNA_view3d_types.h
M source/blender/makesrna/intern/rna_space.c
M source/blender/makesrna/intern/rna_xr.c
M source/blender/windowmanager/WM_types.h
M source/blender/windowmanager/intern/wm_operators.c
===================================================================
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 017bacb9177..2618f4283e1 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -7200,7 +7200,10 @@ static void direct_link_area(FileData *fd, ScrArea *area)
direct_link_gpencil(fd, v3d->gpd);
}
v3d->localvd = newdataadr(fd, v3d->localvd);
+
+ /* Runtime data */
v3d->runtime.properties_storage = NULL;
+ v3d->runtime.flag = 0;
/* render can be quite heavy, set to solid on load */
if (v3d->shading.type == OB_RENDER) {
diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h
index 6345fc00ad5..47b72b2cacc 100644
--- a/source/blender/editors/include/ED_view3d.h
+++ b/source/blender/editors/include/ED_view3d.h
@@ -738,6 +738,7 @@ 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);
+void ED_view3d_xr_shading_update(struct wmWindowManager *wm, const View3D *v3d);
bool ED_view3d_is_region_xr_mirror_active(const struct wmWindowManager *wm,
const struct View3D *v3d,
const struct ARegion *region);
diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c
index 545bbac39dc..3836ed059a2 100644
--- a/source/blender/editors/space_view3d/space_view3d.c
+++ b/source/blender/editors/space_view3d/space_view3d.c
@@ -39,6 +39,7 @@
#include "BKE_context.h"
#include "BKE_curve.h"
+#include "BKE_global.h"
#include "BKE_icons.h"
#include "BKE_idprop.h"
#include "BKE_lattice.h"
@@ -350,6 +351,8 @@ static SpaceLink *view3d_duplicate(SpaceLink *sl)
v3dn->localvd = NULL;
v3dn->runtime.properties_storage = NULL;
}
+ /* Only one View3D is allowed to have this flag! */
+ v3dn->runtime.flag &= ~V3D_RUNTIME_XR_SESSION_ROOT;
v3dn->local_collections_uuid = 0;
v3dn->flag &= ~(V3D_LOCAL_COLLECTIONS | V3D_XR_SESSION_MIRROR);
@@ -936,6 +939,9 @@ static void view3d_main_region_listener(
if (wmn->subtype == NS_VIEW3D_GPU) {
rv3d->rflag |= RV3D_GPULIGHT_UPDATE;
}
+ else if (wmn->subtype == NS_VIEW3D_SHADING) {
+ ED_view3d_xr_shading_update(G_MAIN->wm.first, v3d);
+ }
ED_region_tag_redraw(region);
WM_gizmomap_tag_refresh(gzmap);
}
diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c
index 841b5431229..40376933937 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"
@@ -1724,6 +1725,22 @@ void ED_view3d_xr_mirror_update(const ScrArea *area, const View3D *v3d, const bo
}
}
+void ED_view3d_xr_shading_update(wmWindowManager *wm, const View3D *v3d)
+{
+ 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));
+
+ /* Copy shading from View3D to VR view. */
+ *xr_shading = v3d->shading;
+ if (xr_shading->prop) {
+ IDP_FreeProperty(xr_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)
diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h
index b56f587b9cf..65a7016e69b 100644
--- a/source/blender/makesdna/DNA_view3d_types.h
+++ b/source/blender/makesdna/DNA_view3d_types.h
@@ -234,6 +234,10 @@ typedef struct View3DOverlay {
typedef struct View3D_Runtime {
/** Nkey panel stores stuff here. */
void *properties_storage;
+ /** Runtime only flags. */
+ int flag;
+
+ char _pad1[4];
} View3D_Runtime;
/** 3D ViewPort Struct. */
@@ -352,6 +356,12 @@ typedef struct View3D {
#define V3D_GLOBAL_STATS (1 << 13)
#define V3D_DRAW_CENTERS (1 << 15)
+/** #View3D_Runtime.flag */
+enum {
+ /** The 3D view which the XR session was created in is flagged with this. */
+ V3D_RUNTIME_XR_SESSION_ROOT = (1 << 0),
+};
+
/** #RegionView3D.persp */
#define RV3D_ORTHO 0
#define RV3D_PERSP 1
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index d1baaebfe13..c831ff0d65a 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -3185,19 +3185,20 @@ static void rna_def_space_view3d_shading(BlenderRNA *brna)
"rna_3DViewShading_type_itemf");
RNA_def_property_ui_text(
prop, "Viewport Shading", "Method to display/shade objects in the 3D View");
- RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_3DViewShading_type_update");
+ RNA_def_property_update(
+ prop, NC_SPACE | ND_SPACE_VIEW3D | NS_VIEW3D_SHADING, "rna_3DViewShading_type_update");
prop = RNA_def_property(srna, "light", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "light");
RNA_def_property_enum_items(prop, rna_enum_viewport_lighting_items);
RNA_def_property_ui_text(prop, "Lighting", "Lighting Method for Solid/Texture Viewport Shading");
- RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D | NS_VIEW3D_SHADING, NULL);
prop = RNA_def_property(srna, "show_object_outline", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", V3D_SHADING_OBJECT_OUTLINE);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_text(prop, "Outline", "Show Object Outline");
- RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D | NS_VIEW3D_SHADING, NULL);
prop = RNA_def_property(srna, "studio_light", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, rna_enum_studio_light_items);
@@ -3207,45 +3208,45 @@ static void rna_def_space_view3d_shading(BlenderRNA *brna)
"rna_View3DShading_studio_light_set",
"rna_View3DShading_studio_light_itemf");
RNA_def_property_ui_text(prop, "Studiolight", "Studio lighting setup");
- RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D | NS_VIEW3D_SHADING, NULL);
prop = RNA_def_property(srna, "use_world_space_lighting", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", V3D_SHADING_WORLD_ORIENTATION);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_text(
prop, "World Space Lighting", "Make the lighting fixed and not follow the camera");
- RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D | NS_VIEW3D_SHADING, NULL);
prop = RNA_def_property(srna, "show_backface_culling", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", V3D_SHADING_BACKFACE_CULLING);
RNA_def_property_ui_text(
prop, "Backface Culling", "Use back face culling to hide the back side of faces");
- RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D | NS_VIEW3D_SHADING, NULL);
prop = RNA_def_property(srna, "show_cavity", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", V3D_SHADING_CAVITY);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_text(prop, "Cavity", "Show Cavity");
- RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D | NS_VIEW3D_SHADING, NULL);
prop = RNA_def_property(srna, "cavity_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, cavity_type_items);
RNA_def_property_ui_text(prop, "Cavity Type", "Way to draw the cavity shading");
- RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D | NS_VIEW3D_SHADING, NULL);
prop = RNA_def_property(srna, "curvature_ridge_factor", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "curvature_ridge_factor");
RNA_def_property_ui_text(prop, "Curvature Ridge", "Factor for the curvature ridges");
RNA_def_property_range(prop, 0.0f, 2.0f);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
- RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D | NS_VIEW3D_SHADING, NULL);
prop = RNA_def_property(srna, "curvature_valley_factor", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "curvature_valley_factor");
RNA_def_property_ui_text(prop, "Curvature Valley", "Factor for the curvature valleys");
RNA_def_property_range(prop, 0.0f, 2.0f);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
- RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D | NS_VIEW3D_SHADING, NULL);
prop = RNA_def_property(srna, "cavity_ridge_factor", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "cavity_ridge_factor");
@@ -3253,7 +3254,7 @@ static void rna_def_space_view3d_shading(BlenderRNA *brna)
RNA_def_property_range(prop, 0.0f, 250.0f);
RNA_def_property_ui_range(prop, 0.00f, 2.5f, 1, 3);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
- RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D | NS_VIEW3D_S
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list