[Bf-blender-cvs] [a48b52d5466] blender2.8: 3D View: support object type visibility/selection

Campbell Barton noreply at git.blender.org
Fri Jul 6 17:53:56 CEST 2018


Commit: a48b52d5466939044589bc332918463eef186ba8
Author: Campbell Barton
Date:   Fri Jul 6 17:43:53 2018 +0200
Branches: blender2.8
https://developer.blender.org/rBa48b52d5466939044589bc332918463eef186ba8

3D View: support object type visibility/selection

Trying to have a single option for this is too likely to be
insufficient in some cases.

Instead, support object type visibility & selectability per view-port.

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

M	release/scripts/startup/bl_ui/space_view3d.py
M	source/blender/draw/intern/draw_manager.c
M	source/blender/draw/modes/object_mode.c
M	source/blender/makesdna/DNA_view3d_types.h
M	source/blender/makesrna/intern/rna_space.c

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

diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index 611deb1889b..2a358b3fc9f 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -112,6 +112,14 @@ class VIEW3D_HT_header(Header):
         sub.active = overlay.show_overlays
         sub.popover(space_type='VIEW_3D', region_type='HEADER', panel_type="VIEW3D_PT_overlay")
 
+        layout.popover(
+            text="",
+            icon='HIDE_OFF',
+            space_type='VIEW_3D',
+            region_type='HEADER',
+            panel_type="VIEW3D_PT_object_type_visibility",
+        )
+
         layout.separator_spacer()
 
         # Mode & Transform Settings
@@ -3834,7 +3842,6 @@ class VIEW3D_PT_overlay(Panel):
         sub.prop(overlay, "show_all_objects_origin")
 
         sub = split.column()
-        sub.prop(overlay, "show_non_geometry")
         sub.prop(overlay, "show_relationship_lines")
         sub.prop(overlay, "show_motion_paths")
         #sub.prop(overlay, "show_onion_skins")
@@ -4110,6 +4117,51 @@ class VIEW3D_PT_overlay_paint(Panel):
             col.prop(overlay, "show_paint_wire")
 
 
+class VIEW3D_PT_object_type_visibility(Panel):
+    bl_space_type = 'VIEW_3D'
+    bl_region_type = 'HEADER'
+    bl_label = "Object Visibility"
+
+    def draw(self, context):
+        layout = self.layout
+        view = context.space_data
+
+        col = layout.column()
+
+        split = col.split()
+
+        heading_pair = ("Visible", "Selectable")
+        attr_object_types = (
+		    "mesh",
+		    "curve",
+		    "surf",
+		    "meta",
+		    "font",
+		    "armature",
+		    "lattice",
+		    "empty",
+		    "camera",
+		    "lamp",
+		    "light_probe",
+		    "speaker",
+        )
+
+        attr_vis = [f"show_object_viewport_{attr}" for attr in attr_object_types]
+        attr_sel = [f"show_object_select_{attr}" for attr in attr_object_types]
+
+        sub = split.column()
+        sub.label("Visible")
+        for attr_v in attr_vis:
+            sub.prop(view, attr_v)
+
+        sub = split.column()
+        sub.label("Selectable")
+        for attr_v, attr_s in zip(attr_vis, attr_sel):
+            row = sub.row(align=True)
+            row.active = getattr(view, attr_v)
+            row.prop(view, attr_s)
+
+
 class VIEW3D_PT_pivot_point(Panel):
     bl_space_type = 'VIEW_3D'
     bl_region_type = 'HEADER'
@@ -4458,6 +4510,7 @@ classes = (
     VIEW3D_PT_overlay_pose,
     VIEW3D_PT_overlay_paint,
     VIEW3D_PT_overlay_sculpt,
+    VIEW3D_PT_object_type_visibility,
     VIEW3D_PT_pivot_point,
     VIEW3D_PT_snapping,
     VIEW3D_PT_transform_orientations,
diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c
index ea25739e52d..7e40966f9c8 100644
--- a/source/blender/draw/intern/draw_manager.c
+++ b/source/blender/draw/intern/draw_manager.c
@@ -1274,9 +1274,12 @@ void DRW_draw_render_loop_ex(
 		PROFILE_START(stime);
 		drw_engines_cache_init();
 
+		const int object_type_exclude_viewport = v3d->object_type_exclude_viewport;
 		DEG_OBJECT_ITER_FOR_RENDER_ENGINE_BEGIN(depsgraph, ob)
 		{
-			drw_engines_cache_populate(ob);
+			if ((object_type_exclude_viewport & (1 << ob->type)) == 0) {
+				drw_engines_cache_populate(ob);
+			}
 		}
 		DEG_OBJECT_ITER_FOR_RENDER_ENGINE_END;
 
@@ -1557,12 +1560,17 @@ void DRW_render_object_iter(
 	void *vedata, RenderEngine *engine, struct Depsgraph *depsgraph,
 	void (*callback)(void *vedata, Object *ob, RenderEngine *engine, struct Depsgraph *depsgraph))
 {
+	const DRWContextState *draw_ctx = DRW_context_state_get();
+
 	DRW_hair_init();
 
+	const int object_type_exclude_viewport = draw_ctx->v3d->object_type_exclude_viewport;
 	DEG_OBJECT_ITER_FOR_RENDER_ENGINE_BEGIN(depsgraph, ob)
 	{
-		DST.ob_state = NULL;
-		callback(vedata, ob, engine, depsgraph);
+		if ((object_type_exclude_viewport & (1 << ob->type)) == 0) {
+			DST.ob_state = NULL;
+			callback(vedata, ob, engine, depsgraph);
+		}
 	}
 	DEG_OBJECT_ITER_FOR_RENDER_ENGINE_END
 }
@@ -1701,6 +1709,9 @@ void DRW_draw_select_loop(
 #endif
 		}
 		else {
+			const int object_type_exclude_select = (
+			        v3d->object_type_exclude_viewport | v3d->object_type_exclude_select
+			);
 			bool filter_exclude = false;
 			DEG_OBJECT_ITER_BEGIN(
 			        depsgraph, ob,
@@ -1708,8 +1719,9 @@ void DRW_draw_select_loop(
 			        DEG_ITER_OBJECT_FLAG_VISIBLE |
 			        DEG_ITER_OBJECT_FLAG_DUPLI)
 			{
-				if ((ob->base_flag & BASE_SELECTABLE) != 0) {
-
+				if ((ob->base_flag & BASE_SELECTABLE) &&
+				    (object_type_exclude_select & (1 << ob->type)) == 0)
+				{
 					if (object_filter_fn != NULL) {
 						if (ob->base_flag & BASE_FROMDUPLI) {
 							/* pass (use previous filter_exclude value) */
@@ -1880,9 +1892,12 @@ void DRW_draw_depth_loop(
 	{
 		drw_engines_cache_init();
 
+		const int object_type_exclude_viewport = v3d->object_type_exclude_viewport;
 		DEG_OBJECT_ITER_FOR_RENDER_ENGINE_BEGIN(depsgraph, ob)
 		{
-			drw_engines_cache_populate(ob);
+			if ((object_type_exclude_viewport & (1 << ob->type)) == 0) {
+				drw_engines_cache_populate(ob);
+			}
 		}
 		DEG_OBJECT_ITER_FOR_RENDER_ENGINE_END;
 
diff --git a/source/blender/draw/modes/object_mode.c b/source/blender/draw/modes/object_mode.c
index 1e77631fbf0..17e4a7b15ce 100644
--- a/source/blender/draw/modes/object_mode.c
+++ b/source/blender/draw/modes/object_mode.c
@@ -2127,10 +2127,6 @@ static void OBJECT_cache_populate(void *vedata, Object *ob)
 		return;
 	}
 
-	if (v3d->overlay.object_type_exclude & (1 << ob->type)) {
-		return;
-	}
-
 	bool do_outlines = (draw_ctx->v3d->flag & V3D_SELECT_OUTLINE) && ((ob->base_flag & BASE_SELECTED) != 0);
 	bool show_relations = ((draw_ctx->v3d->flag & V3D_HIDE_HELPLINES) == 0);
 
diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h
index 5668cf24fe6..806d6f925ba 100644
--- a/source/blender/makesdna/DNA_view3d_types.h
+++ b/source/blender/makesdna/DNA_view3d_types.h
@@ -179,7 +179,7 @@ typedef struct View3DOverlay {
 
 	/* Other settings */
 	float wireframe_threshold;
-	int object_type_exclude;
+	char _pad0[4];
 
 } View3DOverlay;
 
@@ -202,6 +202,9 @@ typedef struct View3D {
 	unsigned int lay_prev; /* for active layer toggle */
 	unsigned int lay_used; /* used while drawing */
 
+	int object_type_exclude_viewport;
+	int object_type_exclude_select;
+
 	short persp  DNA_DEPRECATED;
 	short view   DNA_DEPRECATED;
 
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index 2a7bb5994c3..13978f3f5ee 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -2609,16 +2609,6 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna)
 	RNA_def_property_ui_text(prop, "Show 3D Cursor", "Display 3D Cursor Overlay");
 	RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
 
-	prop = RNA_def_property(srna, "show_non_geometry", PROP_BOOLEAN, PROP_NONE);
-	RNA_def_property_boolean_negative_sdna(
-	        prop, NULL, "overlay.object_type_exclude",
-	        ((1 << OB_TYPE_MAX) - 1) &
-	        ~((1 << OB_MESH) | (1 << OB_CURVE) | (1 << OB_SURF) | (1 << OB_FONT) | (1 << OB_MBALL)));
-	RNA_def_property_boolean_default(prop, true);
-	RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
-	RNA_def_property_ui_text(prop, "Show Non Renderable", "Draw not renderable objects in the overlay");
-	RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
-
 	prop = RNA_def_property(srna, "show_text", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_negative_sdna(prop, NULL, "overlay.flag", V3D_OVERLAY_HIDE_TEXT);
 	RNA_def_property_ui_text(prop, "Show Text", "Display overlay text");
@@ -3024,6 +3014,54 @@ static void rna_def_space_view3d(BlenderRNA *brna)
 	RNA_def_property_ui_text(prop, "Volume Alpha", "Opacity (alpha) of the cameras' frustum volume");
 	RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
 
+	{
+		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_CURVE),
+			 {"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"}},
+			{"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"}},
+			{"Camera", (1 << OB_CAMERA),
+			 {"show_object_viewport_camera", "show_object_select_camera"}},
+			{"Lamp", (1 << OB_LAMP),
+			 {"show_object_viewport_lamp", "show_object_select_lamp"}},
+			{"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] = {
+			"object_type_exclude_viewport",
+			"object_type_exclude_select",
+		};
+		for (int mask_index = 0; mask_index < 2; mask_index++) {
+			for (int type_index = 0; type_index < ARRAY_SIZE(info); type_index++) {
+				prop = RNA_def_property(srna, info[type_index].identifier[mask_index], PROP_BOOLEAN, PROP_NONE);
+				RNA_def_property_boolean_negative_sdna(
+				        prop, NULL, view_mask_member[mask_index], info[type_index].type_mask);
+				RNA_def_property_ui_text(prop, info[type_index].name, "");
+				RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, NULL);
+
+			}
+		}
+	}
+
 	/* Nested Structs */
 	prop = RNA_def_property(srna, "shading", PROP_POINTER, PROP_NONE);
 	RNA_def_property_flag(prop, PROP_NEVER_NULL);



More information about the Bf-blender-cvs mailing list