DNA: move back-face culling to shading popover
authorCampbell Barton <ideasman42@gmail.com>
Tue, 18 Dec 2018 23:55:53 +0000 (10:55 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 18 Dec 2018 23:55:53 +0000 (10:55 +1100)
Overlay options shouldn't be used when overlays are disabled.

Move to shading popover, reported as T58070.

release/scripts/startup/bl_ui/space_view3d.py
source/blender/blenloader/intern/versioning_280.c
source/blender/draw/engines/basic/basic_engine.c
source/blender/draw/engines/eevee/eevee_materials.c
source/blender/draw/engines/workbench/workbench_deferred.c
source/blender/draw/engines/workbench/workbench_forward.c
source/blender/makesdna/DNA_view3d_types.h
source/blender/makesrna/intern/rna_space.c

index 3c713de9a71a450fd464a83eb797ac05b4d2dd35..e8fb17258d16a3a73cb80c98b547bf42cc9fe936 100644 (file)
@@ -4547,6 +4547,9 @@ class VIEW3D_PT_shading_options(Panel):
             )
 
             col = layout.column()
+
+            col.prop(shading, "show_backface_culling")
+
             row = col.row()
             row.active = not shading.show_xray
             row.prop(shading, "show_cavity")
@@ -4766,13 +4769,9 @@ class VIEW3D_PT_overlay_geometry(Panel):
         col = layout.column(align=True)
         col.active = display_all
 
-        split = col.split()
-        sub = split.column(align=True)
-        sub.prop(overlay, "show_backface_culling")
+        col.prop(overlay, "show_face_orientation")
 
-        sub = split.column(align=True)
-        #sub.prop(overlay, "show_onion_skins")
-        sub.prop(overlay, "show_face_orientation")
+        # sub.prop(overlay, "show_onion_skins")
 
 
 class VIEW3D_PT_overlay_motion_tracking(Panel):
index a2a2c3fb73828fe20c9aee0ece393f26decd99a7..0c9b98064255117b949ff84c0f449c3feae3f05d 100644 (file)
@@ -2743,5 +2743,24 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
                                        SCE_SNAP_TRANSFORM_MODE_TRANSLATE;
                        }
                }
+
+               for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) {
+                       for (ScrArea *area = screen->areabase.first; area; area = area->next) {
+                               for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) {
+                                       switch (sl->spacetype) {
+                                               case SPACE_VIEW3D:
+                                               {
+                                                       enum { V3D_BACKFACE_CULLING = (1 << 10) };
+                                                       View3D *v3d = (View3D *)sl;
+                                                       if (v3d->flag2 & V3D_BACKFACE_CULLING) {
+                                                               v3d->flag2 &= ~V3D_BACKFACE_CULLING;
+                                                               v3d->shading.flag |= V3D_SHADING_BACKFACE_CULLING;
+                                                       }
+                                                       break;
+                                               }
+                                       }
+                               }
+                       }
+               }
        }
 }
index f64d345c52f15c620f981350af4c3ab06a2fe149..cf0605c7edaba96bbcd0ba3d9df43215ded3cc34 100644 (file)
@@ -160,7 +160,7 @@ static void basic_cache_populate(void *vedata, Object *ob)
 
        struct GPUBatch *geom = DRW_cache_object_surface_get(ob);
        if (geom) {
-               const bool do_cull = (draw_ctx->v3d && (draw_ctx->v3d->flag2 & V3D_BACKFACE_CULLING));
+               const bool do_cull = (draw_ctx->v3d && (draw_ctx->v3d->shading.flag & V3D_SHADING_BACKFACE_CULLING));
                /* Depth Prepass */
                DRW_shgroup_call_add((do_cull) ? stl->g_data->depth_shgrp_cull : stl->g_data->depth_shgrp, geom, ob->obmat);
        }
index f26920c2474d7fc46fb6220cbe713e895ecd99be..00b77eee19b602115e7e9b4af54ed5af27da7ce8 100644 (file)
@@ -1439,7 +1439,7 @@ void EEVEE_materials_cache_populate(EEVEE_Data *vedata, EEVEE_ViewLayerData *sld
        Scene *scene = draw_ctx->scene;
        GHash *material_hash = stl->g_data->material_hash;
 
-       const bool do_cull = (draw_ctx->v3d && (draw_ctx->v3d->flag2 & V3D_BACKFACE_CULLING));
+       const bool do_cull = (draw_ctx->v3d && (draw_ctx->v3d->shading.flag & V3D_SHADING_BACKFACE_CULLING));
        const bool is_active = (ob == draw_ctx->obact);
        const bool is_sculpt_mode = is_active && (draw_ctx->object_mode & OB_MODE_SCULPT) != 0;
        /* For now just force fully shaded with eevee when supported. */
index 66a98ef2e009d4326a538bb4d0e99cfad1d57687..0b7d840a5896a1d63992330645b86f33bd2831f0 100644 (file)
@@ -487,7 +487,7 @@ void workbench_deferred_engine_init(WORKBENCH_Data *vedata)
        /* Prepass */
        {
                DRWShadingGroup *grp;
-               const bool do_cull = (draw_ctx->v3d && (draw_ctx->v3d->flag2 & V3D_BACKFACE_CULLING));
+               const bool do_cull = (draw_ctx->v3d && (draw_ctx->v3d->shading.flag & V3D_SHADING_BACKFACE_CULLING));
 
                int state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL;
                psl->prepass_pass = DRW_pass_create("Prepass", (do_cull) ? state | DRW_STATE_CULL_BACK : state);
index 3b755b311562d1b601bfde1891e2c9ce9d6edca1..7a0a5e2086473173b1b475dc2dd447dbaf4daac2 100644 (file)
@@ -325,7 +325,7 @@ void workbench_forward_engine_init(WORKBENCH_Data *vedata)
        });
 
        workbench_volume_cache_init(vedata);
-       const bool do_cull = (draw_ctx->v3d && (draw_ctx->v3d->flag2 & V3D_BACKFACE_CULLING));
+       const bool do_cull = (draw_ctx->v3d && (draw_ctx->v3d->shading.flag & V3D_SHADING_BACKFACE_CULLING));
        const int cull_state = (do_cull) ? DRW_STATE_CULL_BACK : 0;
 
        /* Transparency Accum */
index 242be7b75cc9c6dad6d514883467a9fe08faa627..1fc143ed71fc462392753a4147275de6884737a1 100644 (file)
@@ -362,7 +362,7 @@ typedef struct View3D {
 #define V3D_SHOW_RECONSTRUCTION (1 << 7)
 #define V3D_SHOW_CAMERAPATH     (1 << 8)
 #define V3D_SHOW_BUNDLENAME     (1 << 9)
-#define V3D_BACKFACE_CULLING    (1 << 10)
+#define V3D_FLAG2_DEPRECATED_10 (1 << 10)  /* cleared */
 #define V3D_RENDER_BORDER       (1 << 11)
 #define V3D_FLAG2_DEPRECATED_12 (1 << 12)  /* cleared */
 #define V3D_FLAG2_DEPRECATED_13 (1 << 13)  /* cleared */
@@ -396,6 +396,7 @@ enum {
        V3D_SHADING_SCENE_WORLD         = (1 << 7),
        V3D_SHADING_XRAY_BONE           = (1 << 8),
        V3D_SHADING_WORLD_ORIENTATION   = (1 << 9),
+       V3D_SHADING_BACKFACE_CULLING    = (1 << 10),
 };
 
 /* View3DShading->color_type */
index f3d2d5d805edb647f1e743f9d4a64d2a3ef1aade..b77eed67d21fe3ff41f86d882e3647781e2b29e1 100644 (file)
@@ -2475,6 +2475,11 @@ static void rna_def_space_view3d_shading(BlenderRNA *brna)
        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);
 
+       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);
+
        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);
@@ -2726,12 +2731,6 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna)
                                 "Show dashed lines indicating parent or constraint relationships");
        RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
 
-       /* TODO: this should become a per object setting? */
-       prop = RNA_def_property(srna, "show_backface_culling", PROP_BOOLEAN, PROP_NONE);
-       RNA_def_property_boolean_sdna(prop, NULL, "flag2", V3D_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);
-
        prop = RNA_def_property(srna, "show_cursor", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_negative_sdna(prop, NULL, "overlay.flag", V3D_OVERLAY_HIDE_CURSOR);
        RNA_def_property_ui_text(prop, "Show 3D Cursor", "Display 3D Cursor Overlay");