[Bf-blender-cvs] [5c92c04518b] master: XR: Add object extras, object types visibility session options

Peter Kim noreply at git.blender.org
Sat Apr 30 09:24:50 CEST 2022


Commit: 5c92c04518b5dc7c57c3b3a9e81b45879af2e080
Author: Peter Kim
Date:   Sat Apr 30 16:23:43 2022 +0900
Branches: master
https://developer.blender.org/rB5c92c04518b5dc7c57c3b3a9e81b45879af2e080

XR: Add object extras, object types visibility session options

This allows object extras such as image-empties to be shown in the VR
viewport/headset display. Being able to see reference images in VR can
be useful for architectural walkthroughs and 3D modeling applications.

Since users may not want to see all object extras (lights, cameras,
etc.), per-object-type visibility settings are also added as session
options.

By slightly refactoring the definition of the 3D View object types
visibility panel (note: no functional changes), the VR Scene Inspection
add-on can show a similar panel without duplicating code. When VR
selection is possible in the future, the object type select options can
also be enabled.

Reviewed By: Severin

Differential Revision: https://developer.blender.org/D14220

===================================================================

M	release/scripts/startup/bl_ui/space_view3d.py
M	source/blender/editors/include/ED_view3d_offscreen.h
M	source/blender/editors/space_view3d/view3d_draw.c
M	source/blender/makesdna/DNA_view3d_enums.h
M	source/blender/makesdna/DNA_xr_types.h
M	source/blender/makesrna/intern/rna_internal.h
M	source/blender/makesrna/intern/rna_space.c
M	source/blender/makesrna/intern/rna_space_api.c
M	source/blender/makesrna/intern/rna_xr.c
M	source/blender/windowmanager/xr/intern/wm_xr_draw.c
M	source/blender/windowmanager/xr/intern/wm_xr_session.c

===================================================================

diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index 9aebb4427d2..4f1d001b2f3 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -5684,13 +5684,14 @@ class VIEW3D_PT_object_type_visibility(Panel):
     bl_label = "View Object Types"
     bl_ui_units_x = 7
 
-    def draw(self, context):
+    # Allows derived classes to pass view data other than context.space_data. 
+    # This is used by the official VR add-on, which passes XrSessionSettings
+    # since VR has a 3D view that only exists for the duration of the VR session.
+    def draw_ex(self, context, view, show_select):
         layout = self.layout
         layout.use_property_split = True
         layout.use_property_decorate = False
 
-        view = context.space_data
-
         layout.label(text="Object Types Visibility")
         layout.separator()
         col = layout.column()
@@ -5728,19 +5729,25 @@ class VIEW3D_PT_object_type_visibility(Panel):
                 continue
 
             attr_v = "show_object_viewport_" + attr
-            attr_s = "show_object_select_" + attr
-
             icon_v = 'HIDE_OFF' if getattr(view, attr_v) else 'HIDE_ON'
-            icon_s = 'RESTRICT_SELECT_OFF' if getattr(view, attr_s) else 'RESTRICT_SELECT_ON'
 
             row = col.row(align=True)
             row.alignment = 'RIGHT'
 
             row.label(text=attr_name)
             row.prop(view, attr_v, text="", icon=icon_v, emboss=False)
-            rowsub = row.row(align=True)
-            rowsub.active = getattr(view, attr_v)
-            rowsub.prop(view, attr_s, text="", icon=icon_s, emboss=False)
+
+            if show_select:
+                attr_s = "show_object_select_" + attr
+                icon_s = 'RESTRICT_SELECT_OFF' if getattr(view, attr_s) else 'RESTRICT_SELECT_ON'
+
+                rowsub = row.row(align=True)
+                rowsub.active = getattr(view, attr_v)
+                rowsub.prop(view, attr_s, text="", icon=icon_s, emboss=False)
+
+    def draw(self, context):
+        view = context.space_data
+        self.draw_ex(context, view, True)
 
 
 class VIEW3D_PT_shading(Panel):
diff --git a/source/blender/editors/include/ED_view3d_offscreen.h b/source/blender/editors/include/ED_view3d_offscreen.h
index 097308066f3..2217ace2e62 100644
--- a/source/blender/editors/include/ED_view3d_offscreen.h
+++ b/source/blender/editors/include/ED_view3d_offscreen.h
@@ -49,6 +49,8 @@ void ED_view3d_draw_offscreen_simple(struct Depsgraph *depsgraph,
                                      struct Scene *scene,
                                      struct View3DShading *shading_override,
                                      eDrawType drawtype,
+                                     int object_type_exclude_viewport_override,
+                                     int object_type_exclude_select_override,
                                      int winx,
                                      int winy,
                                      unsigned int draw_flags,
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index 5a27349dc7f..5b068750d76 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -1723,6 +1723,8 @@ void ED_view3d_draw_offscreen_simple(Depsgraph *depsgraph,
                                      Scene *scene,
                                      View3DShading *shading_override,
                                      eDrawType drawtype,
+                                     int object_type_exclude_viewport_override,
+                                     int object_type_exclude_select_override,
                                      int winx,
                                      int winy,
                                      uint draw_flags,
@@ -1785,7 +1787,10 @@ void ED_view3d_draw_offscreen_simple(Depsgraph *depsgraph,
     /* Disable other overlays (set all available _HIDE_ flags). */
     v3d.overlay.flag |= V3D_OVERLAY_HIDE_CURSOR | V3D_OVERLAY_HIDE_TEXT |
                         V3D_OVERLAY_HIDE_MOTION_PATHS | V3D_OVERLAY_HIDE_BONES |
-                        V3D_OVERLAY_HIDE_OBJECT_XTRAS | V3D_OVERLAY_HIDE_OBJECT_ORIGINS;
+                        V3D_OVERLAY_HIDE_OBJECT_ORIGINS;
+    if ((draw_flags & V3D_OFSDRAW_SHOW_OBJECT_EXTRAS) == 0) {
+      v3d.overlay.flag |= V3D_OVERLAY_HIDE_OBJECT_XTRAS;
+    }
     v3d.flag |= V3D_HIDE_HELPLINES;
   }
 
@@ -1793,6 +1798,9 @@ void ED_view3d_draw_offscreen_simple(Depsgraph *depsgraph,
     v3d.flag |= V3D_XR_SESSION_SURFACE;
   }
 
+  v3d.object_type_exclude_viewport = object_type_exclude_viewport_override;
+  v3d.object_type_exclude_select = object_type_exclude_select_override;
+
   rv3d.persp = RV3D_PERSP;
   v3d.clip_start = clip_start;
   v3d.clip_end = clip_end;
diff --git a/source/blender/makesdna/DNA_view3d_enums.h b/source/blender/makesdna/DNA_view3d_enums.h
index f22adc5a462..99e22072045 100644
--- a/source/blender/makesdna/DNA_view3d_enums.h
+++ b/source/blender/makesdna/DNA_view3d_enums.h
@@ -19,6 +19,7 @@ typedef enum eV3DOffscreenDrawFlag {
   V3D_OFSDRAW_SHOW_SELECTION = (1 << 3),
   V3D_OFSDRAW_XR_SHOW_CONTROLLERS = (1 << 4),
   V3D_OFSDRAW_XR_SHOW_CUSTOM_OVERLAYS = (1 << 5),
+  V3D_OFSDRAW_SHOW_OBJECT_EXTRAS = (1 << 6),
 } eV3DOffscreenDrawFlag;
 
 /** #View3DShading.light */
diff --git a/source/blender/makesdna/DNA_xr_types.h b/source/blender/makesdna/DNA_xr_types.h
index 09eab0d7bf7..44419c9763f 100644
--- a/source/blender/makesdna/DNA_xr_types.h
+++ b/source/blender/makesdna/DNA_xr_types.h
@@ -36,6 +36,10 @@ typedef struct XrSessionSettings {
   float clip_start, clip_end;
 
   int flag;
+
+  /** Object type settings to apply to VR view (unlike shading, not shared with window 3D-View). */
+  int object_type_exclude_viewport;
+  int object_type_exclude_select;
 } XrSessionSettings;
 
 typedef enum eXrSessionFlag {
diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h
index b941245bcfc..bf4eec433c4 100644
--- a/source/blender/makesrna/intern/rna_internal.h
+++ b/source/blender/makesrna/intern/rna_internal.h
@@ -318,6 +318,10 @@ void rna_object_vcollayer_name_set(struct PointerRNA *ptr,
 PointerRNA rna_object_shapekey_index_get(struct ID *id, int value);
 int rna_object_shapekey_index_set(struct ID *id, PointerRNA value, int current);
 
+void rna_def_object_type_visibility_flags_common(StructRNA *srna, int noteflag);
+int rna_object_type_visibility_icon_get_common(int object_type_exclude_viewport,
+                                               const int *object_type_exclude_select);
+
 /* ViewLayer related functions defined in rna_scene.c but required in rna_layer.c */
 void rna_def_freestyle_settings(struct BlenderRNA *brna);
 struct PointerRNA rna_FreestyleLineSet_linestyle_get(struct PointerRNA *ptr);
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index 032ef86c172..1a9e7f5aad8 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -1515,12 +1515,8 @@ static void rna_SpaceView3D_mirror_xr_session_update(Main *main,
 static int rna_SpaceView3D_icon_from_show_object_viewport_get(PointerRNA *ptr)
 {
   const View3D *v3d = (View3D *)ptr->data;
-  /* Ignore selection values when view is off,
-   * intent is to show if visible objects aren't selectable. */
-  const int view_value = (v3d->object_type_exclude_viewport != 0);
-  const int select_value = (v3d->object_type_exclude_select &
-                            ~v3d->object_type_exclude_viewport) != 0;
-  return ICON_VIS_SEL_11 + (view_value << 1) + select_value;
+  return rna_object_type_visibility_icon_get_common(v3d->object_type_exclude_viewport,
+                                                    &v3d->object_type_exclude_select);
 }
 
 static char *rna_View3DShading_path(PointerRNA *UNUSED(ptr))
@@ -4997,68 +4993,15 @@ static void rna_def_space_view3d(BlenderRNA *brna)
   RNA_def_property_update(
       prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_SpaceView3D_mirror_xr_session_update");
 
-  {
-    struct {
-      const char *name;
-      int type_mask;
-      const char *identifier[2];
-    } info[] = {
-        {"Mesh", (1 << OB_MESH), {"show_object_viewport_mesh", "show_object_select_mesh"}},
-        {"Curve",
-         (1 << OB_CURVES_LEGACY),
-         {"show_object_viewport_curve", "show_object_select_curve"}},
-        {"Surface", (1 << OB_SURF), {"show_object_viewport_surf", "show_object_select_surf"}},
-        {"Meta", (1 << OB_MBALL), {"show_object_viewport_meta", "show_object_select_meta"}},
-        {"Font", (1 << OB_FONT), {"show_object_viewport_font", "show_object_select_font"}},
-        {"Hair Curves",
-         (1 << OB_CURVES),
-         {"show_object_viewport_curves", "show_object_select_curves"}},
-        {"Point Cloud",
-         (1 << OB_POINTCLOUD),
-         {"show_object_viewport_pointcloud", "show_object_select_pointcloud"}},
-        {"Volume", (1 << OB_VOLUME), {"show_object_viewport_volume", "show_object_select_volume"}},
-        {"Armature",
-         (1 << OB_ARMATURE),
-         {"show_object_viewport_armature", "show_object_select_armature"}},
-        {"Lattice",
-         (1 << OB_LATTICE),
-         {"show_object_viewport_lattice", "show_object_select_lattice"}},
-        {"Empty", (1 << OB_EMPTY), {"show_object_viewport_empty", "show_object_select_empty"}},
-        {"Grease Pencil",
-         (1 << OB_GPENCIL),
-         {"show_object_viewport_grease_pencil", "show_object_select_grease_pencil"}},
-        {"Camera", (1 << OB_CAMERA), {"show_object_viewport_camera", "show_object_select_camera"}},
-        {"Light", (1 << OB_LAMP), {"show_object_viewport_light", "show_object_select_light"}},
-        {"Speaker",
-         (1 << OB_SPEAKER),
-         {"show_object_viewport_speaker", "show_object_select_speaker"}},
-        {"Light Probe",
-         (1 << OB_LIGHTPROBE),
-         {"show_object_viewport_light_probe", "show_object_select_light_probe"}},
-    };
-
-    const char *view_mask_member[2] = {
-        "o

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list