Commit: f7ec70895c78900db8e7db88d3713ebb9aa62730
Author: Jeroen Bakker
Date:   Thu Jul 5 14:38:14 2018 +0200
Branches: blender2.8
https://developer.blender.org/rBf7ec70895c78900db8e7db88d3713ebb9aa62730

Overlay: enable/disable drawing of specific object types.

Added a option to the overlay popover that controls the visibility of
non-renderable objects like lamps, cameras, speakers, armatures, curves
empties and force fields.

After discussion we went for a single option with more detailed check in
the object_mode draw engine.

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

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

M       release/scripts/startup/bl_ui/space_view3d.py
M       source/blender/blenloader/intern/versioning_280.c
M       source/blender/draw/modes/object_mode.c
M       source/blender/editors/space_view3d/space_view3d.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 7b71d41e678..0c3219ae8e1 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -3833,6 +3833,14 @@ class VIEW3D_PT_overlay(Panel):
         sub.prop(overlay, "show_all_objects_origin")
 
         sub = split.column()
+        row = sub.row(align=True)
+        row.prop(overlay, "show_empties", text="", toggle=True)
+        row.prop(overlay, "show_lamps", text="", toggle=True)
+        row.prop(overlay, "show_cameras", text="", toggle=True)
+        row.prop(overlay, "show_armatures", text="", toggle=True)
+        row.prop(overlay, "show_lightprobes", text="", toggle=True)
+        row.prop(overlay, "show_speakers", text="", toggle=True)
+
         sub.prop(overlay, "show_relationship_lines")
         sub.prop(overlay, "show_motion_paths")
         #sub.prop(overlay, "show_onion_skins")
@@ -3847,6 +3855,7 @@ class VIEW3D_PT_overlay(Panel):
         sub.active = overlay.show_wireframes
         sub.prop(overlay, "wireframe_threshold", text="")
 
+
         col = layout.column()
         col.active = display_all
         split = col.split(percentage=0.55)
diff --git a/source/blender/blenloader/intern/versioning_280.c 
b/source/blender/blenloader/intern/versioning_280.c
index 3bdd4db3b94..8194648f369 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -1530,6 +1530,19 @@ void blo_do_versions_280(FileData *fd, Library 
*UNUSED(lib), Main *bmain)
                        }
                }
 
+               if (!DNA_struct_elem_find(fd->filesdna, "View3DOverlay", "int", 
"visible_object_types")) {
+                       for (bScreen *screen = bmain->screen.first; screen; 
screen = screen->id.next) {
+                               for (ScrArea *sa = screen->areabase.first; sa; 
sa = sa->next) {
+                                       for (SpaceLink *sl = 
sa->spacedata.first; sl; sl = sl->next) {
+                                               if (sl->spacetype == 
SPACE_VIEW3D) {
+                                                       View3D *v3d = (View3D 
*)sl;
+                                                       
v3d->overlay.visible_object_types = V3D_OVERLAY_VISIBLE_OBJECT_TYPES_MASK;
+                                               }
+                                       }
+                               }
+                       }
+               }
+
                for (Scene *scene = bmain->scene.first; scene; scene = 
scene->id.next) {
                        if (scene->toolsettings->manipulator_flag == 0) {
                                scene->toolsettings->manipulator_flag = 
SCE_MANIP_TRANSLATE | SCE_MANIP_ROTATE | SCE_MANIP_SCALE;
diff --git a/source/blender/draw/modes/object_mode.c 
b/source/blender/draw/modes/object_mode.c
index 736bde725ae..2beb453e069 100644
--- a/source/blender/draw/modes/object_mode.c
+++ b/source/blender/draw/modes/object_mode.c
@@ -2217,34 +2217,52 @@ static void OBJECT_cache_populate(void *vedata, Object 
*ob)
                        break;
                }
                case OB_LAMP:
-                       DRW_shgroup_lamp(stl, ob, view_layer);
+                       if (v3d->overlay.visible_object_types & 
V3D_OVERLAY_SHOW_LAMP)
+                       {
+                               DRW_shgroup_lamp(stl, ob, view_layer);
+                       }
                        break;
                case OB_CAMERA:
-                       DRW_shgroup_camera(stl, ob, view_layer);
+                       if (v3d->overlay.visible_object_types & 
V3D_OVERLAY_SHOW_CAMERA)
+                       {
+                               DRW_shgroup_camera(stl, ob, view_layer);
+                       }
                        break;
                case OB_EMPTY:
-                       DRW_shgroup_empty(stl, psl, ob, view_layer);
+                       if (v3d->overlay.visible_object_types & 
V3D_OVERLAY_SHOW_EMPTY)
+                       {
+                               DRW_shgroup_empty(stl, psl, ob, view_layer);
+                       }
                        break;
                case OB_SPEAKER:
-                       DRW_shgroup_speaker(stl, ob, view_layer);
+                       if (v3d->overlay.visible_object_types & 
V3D_OVERLAY_SHOW_SPEAKER)
+                       {
+                               DRW_shgroup_speaker(stl, ob, view_layer);
+                       }
                        break;
                case OB_LIGHTPROBE:
-                       DRW_shgroup_lightprobe(stl, psl, ob, view_layer);
+                       if (v3d->overlay.visible_object_types & 
V3D_OVERLAY_SHOW_LIGHTPROBE)
+                       {
+                               DRW_shgroup_lightprobe(stl, psl, ob, 
view_layer);
+                       }
                        break;
                case OB_ARMATURE:
                {
-                       bArmature *arm = ob->data;
-                       if (arm->edbo == NULL) {
-                               if (DRW_state_is_select() || 
!DRW_pose_mode_armature(ob, draw_ctx->obact)) {
-                                       DRWArmaturePasses passes = {
-                                           .bone_solid = psl->bone_solid,
-                                           .bone_outline = psl->bone_outline,
-                                           .bone_wire = psl->bone_wire,
-                                           .bone_envelope = psl->bone_envelope,
-                                           .bone_axes = psl->bone_axes,
-                                           .relationship_lines = NULL, /* 
Don't draw relationship lines */
-                                       };
-                                       DRW_shgroup_armature_object(ob, 
view_layer, passes);
+                       if (v3d->overlay.visible_object_types & 
V3D_OVERLAY_SHOW_ARMATURE)
+                       {
+                               bArmature *arm = ob->data;
+                               if (arm->edbo == NULL) {
+                                       if (DRW_state_is_select() || 
!DRW_pose_mode_armature(ob, draw_ctx->obact)) {
+                                               DRWArmaturePasses passes = {
+                                                   .bone_solid = 
psl->bone_solid,
+                                                   .bone_outline = 
psl->bone_outline,
+                                                   .bone_wire = psl->bone_wire,
+                                                   .bone_envelope = 
psl->bone_envelope,
+                                                   .bone_axes = psl->bone_axes,
+                                                   .relationship_lines = NULL, 
/* Don't draw relationship lines */
+                                               };
+                                               DRW_shgroup_armature_object(ob, 
view_layer, passes);
+                                       }
                                }
                        }
                        break;
diff --git a/source/blender/editors/space_view3d/space_view3d.c 
b/source/blender/editors/space_view3d/space_view3d.c
index 77beadccd5d..5383e3d9e01 100644
--- a/source/blender/editors/space_view3d/space_view3d.c
+++ b/source/blender/editors/space_view3d/space_view3d.c
@@ -338,6 +338,7 @@ static SpaceLink *view3d_new(const ScrArea *UNUSED(sa), 
const Scene *scene)
        v3d->overlay.texture_paint_mode_opacity = 0.8;
        v3d->overlay.weight_paint_mode_opacity = 0.8;
        v3d->overlay.vertex_paint_mode_opacity = 0.8;
+       v3d->overlay.visible_object_types = 
V3D_OVERLAY_VISIBLE_OBJECT_TYPES_MASK;
 
        v3d->gridflag = V3D_SHOW_X | V3D_SHOW_Y | V3D_SHOW_FLOOR;
 
diff --git a/source/blender/makesdna/DNA_view3d_types.h 
b/source/blender/makesdna/DNA_view3d_types.h
index 70f06b2eda0..f7fd4a52a5f 100644
--- a/source/blender/makesdna/DNA_view3d_types.h
+++ b/source/blender/makesdna/DNA_view3d_types.h
@@ -49,6 +49,7 @@ struct GPUViewport;
 #include "DNA_defs.h"
 #include "DNA_listBase.h"
 #include "DNA_image_types.h"
+#include "DNA_object_types.h"
 #include "DNA_movieclip_types.h"
 #include "DNA_gpu_types.h"
 
@@ -178,8 +179,8 @@ typedef struct View3DOverlay {
 
        /* Other settings */
        float wireframe_threshold;
+       int visible_object_types;
 
-       int pad;
 } View3DOverlay;
 
 /* 3D ViewPort Struct */
@@ -383,6 +384,17 @@ enum {
        V3D_OVERLAY_ONION_SKINS       = (1 << 7),
 };
 
+/* View3DOverlay->visible_object_types */
+enum {
+       V3D_OVERLAY_SHOW_EMPTY        = (1 << OB_EMPTY),
+       V3D_OVERLAY_SHOW_LAMP         = (1 << OB_LAMP),
+       V3D_OVERLAY_SHOW_CAMERA       = (1 << OB_CAMERA),
+       V3D_OVERLAY_SHOW_SPEAKER      = (1 << OB_SPEAKER),
+       V3D_OVERLAY_SHOW_LIGHTPROBE   = (1 << OB_LIGHTPROBE),
+       V3D_OVERLAY_SHOW_ARMATURE     = (1 << OB_ARMATURE),
+};
+#define V3D_OVERLAY_VISIBLE_OBJECT_TYPES_MASK (V3D_OVERLAY_SHOW_EMPTY | 
V3D_OVERLAY_SHOW_LAMP | V3D_OVERLAY_SHOW_CAMERA | V3D_OVERLAY_SHOW_SPEAKER | 
V3D_OVERLAY_SHOW_LIGHTPROBE | V3D_OVERLAY_SHOW_ARMATURE)
+
 /* View3DOverlay->edit_flag */
 enum {
        V3D_OVERLAY_EDIT_VERT_NORMALS = (1 << 0),
diff --git a/source/blender/makesrna/intern/rna_space.c 
b/source/blender/makesrna/intern/rna_space.c
index dfad4c07cb3..00baf948a84 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -2608,6 +2608,54 @@ 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_empties", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, 
"overlay.visible_object_types", V3D_OVERLAY_SHOW_EMPTY);
+       RNA_def_property_boolean_default(prop, true);
+       RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+       RNA_def_property_ui_text(prop, "Show Empties", "Draw empties in the 
overlay");
+       RNA_def_property_ui_icon(prop, ICON_OUTLINER_OB_EMPTY, 0);
+       RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+
+       prop = RNA_def_property(srna, "show_cameras", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, 
"overlay.visible_object_types", V3D_OVERLAY_SHOW_CAMERA);
+       RNA_def_property_boolean_default(prop, true);
+       RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+       RNA_def_property_ui_text(prop, "Show Cameras", "Draw cameras in the 
overlay");
+       RNA_def_property_ui_icon(prop, ICON_OUTLINER_OB_CAMERA, 0);
+       RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+
+       prop = RNA_def_property(srna, "show_speakers", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, 
"overlay.visible_object_types", V3D_OVERLAY_SHOW_SPEAKER);
+       RNA_def_property_boolean_default(prop, true);
+       RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+       RNA_def_property_ui_text(prop, "Show Speakers", "Draw speakers in the 
overlay");
+       RNA_def_property_ui_icon(prop, ICON_OUTLINER_OB_SPEAKER, 0);
+       RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+
+       prop = RNA_def_property(srna, "show_lightprobes", PROP_BOOLEAN, 
PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, 
"overlay.visible_object_types", V3D_OVERLAY_SHOW_LIGHTPROBE);
+       RNA_def_property_boolean_default(prop, true);
+       RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+       RNA_def_property_ui_text(prop, "Show Lightprobes", "Draw lightprobes in 
the overlay");
+       RNA_def_property_ui_icon(prop, ICON_OUTLINER_OB_LIGHTPROBE, 0);
+       RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+
+       prop = RNA_def_property(srna, "show_armatures", PROP_BOOLEAN, 
PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, 
"overlay.visible_object_types", V3D_OVERLAY_SHOW_ARMATURE);
+       RNA_def_property_boolean_default(prop, true);
+       RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+       RNA_def_property_ui_text(prop, "Show Armatures", "Draw armatures in the 
overlay");
+       RNA_def_property_ui_icon(prop, ICON_OUTLINER_OB_ARMATURE, 0);
+       RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+
+       prop = RNA_def_property(srna, "show_lamps", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, 
"overlay.visible_object_types", V3D_OVERLAY_SHOW_LAMP);
+       RNA_def_property_boolean_default(prop, true);
+       RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+       RNA_def_property_ui_text(prop, "Show La

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to