DRW: Fix flat object not being selectable in wireframe view
authorClément Foucault <foucault.clem@gmail.com>
Tue, 18 Dec 2018 14:08:33 +0000 (15:08 +0100)
committerClément Foucault <foucault.clem@gmail.com>
Tue, 18 Dec 2018 19:51:52 +0000 (20:51 +0100)
The problem was double. They were not selectable in wireframe view and
they would not display with the right color, thus always appearing
un-selected.

source/blender/draw/engines/basic/basic_engine.c
source/blender/draw/modes/overlay_mode.c

index 9dc8c8f2f34619884f402dce16bbd02d068a3bcd..eea41c932e247c6637b95f76959bc9cdde3f854f 100644 (file)
@@ -141,6 +141,7 @@ static void basic_cache_populate(void *vedata, Object *ob)
 
        /* Make flat object selectable in ortho view if wireframe is enabled. */
        if ((draw_ctx->v3d->overlay.flag & V3D_OVERLAY_WIREFRAMES) ||
 
        /* Make flat object selectable in ortho view if wireframe is enabled. */
        if ((draw_ctx->v3d->overlay.flag & V3D_OVERLAY_WIREFRAMES) ||
+           (draw_ctx->v3d->shading.type == OB_WIRE) ||
            (ob->dtx & OB_DRAWWIRE) ||
            (ob->dt == OB_WIRE))
        {
            (ob->dtx & OB_DRAWWIRE) ||
            (ob->dt == OB_WIRE))
        {
index 0c67263bd4fd3a18c344e407781e7384e3c43d36..7060c1c970482e608e75bc840e44ef557d502412 100644 (file)
@@ -174,7 +174,6 @@ static void overlay_cache_init(void *vedata)
                psl->face_wireframe_pass = DRW_pass_create("Face Wires", state);
 
                g_data->flat_wires = DRW_shgroup_create(flat_wires_sh, psl->face_wireframe_pass);
                psl->face_wireframe_pass = DRW_pass_create("Face Wires", state);
 
                g_data->flat_wires = DRW_shgroup_create(flat_wires_sh, psl->face_wireframe_pass);
-               DRW_shgroup_uniform_vec4(g_data->flat_wires, "color", ts.colorWire, 1);
 
                g_data->sculpt_wires = DRW_shgroup_create(sculpt_wire_sh, psl->face_wireframe_pass);
 
 
                g_data->sculpt_wires = DRW_shgroup_create(sculpt_wire_sh, psl->face_wireframe_pass);
 
@@ -246,6 +245,13 @@ static void overlay_cache_populate(void *vedata, Object *ob)
                        const int stencil_mask = (ob->dtx & OB_DRAWXRAY) ? 0x00 : 0xFF;
                        DRWShadingGroup *shgrp = NULL;
 
                        const int stencil_mask = (ob->dtx & OB_DRAWXRAY) ? 0x00 : 0xFF;
                        DRWShadingGroup *shgrp = NULL;
 
+                       float *rim_col = ts.colorWire;
+                       if (!is_edit_mode && !is_sculpt_mode && !has_edit_mesh_cage &&
+                           ((ob->base_flag & BASE_SELECTED) != 0))
+                       {
+                               rim_col = (ob == draw_ctx->obact) ? ts.colorActive : ts.colorSelect;
+                       }
+
                        /* This fixes only the biggest case which is a plane in ortho view. */
                        int flat_axis = 0;
                        bool is_flat_object_viewed_from_side = (rv3d->persp == RV3D_ORTHO) &&
                        /* This fixes only the biggest case which is a plane in ortho view. */
                        int flat_axis = 0;
                        bool is_flat_object_viewed_from_side = (rv3d->persp == RV3D_ORTHO) &&
@@ -260,17 +266,12 @@ static void overlay_cache_populate(void *vedata, Object *ob)
                                        shgrp = DRW_shgroup_create_sub(shgrp);
                                        DRW_shgroup_stencil_mask(shgrp, stencil_mask);
                                        DRW_shgroup_call_object_add(shgrp, geom, ob);
                                        shgrp = DRW_shgroup_create_sub(shgrp);
                                        DRW_shgroup_stencil_mask(shgrp, stencil_mask);
                                        DRW_shgroup_call_object_add(shgrp, geom, ob);
+                                       DRW_shgroup_uniform_vec4(shgrp, "color", rim_col, 1);
                                }
                        }
                        else {
                                struct GPUBatch *geom = DRW_cache_object_face_wireframe_get(ob);
                                if (geom || is_sculpt_mode) {
                                }
                        }
                        else {
                                struct GPUBatch *geom = DRW_cache_object_face_wireframe_get(ob);
                                if (geom || is_sculpt_mode) {
-                                       float *rim_col = ts.colorWire;
-                                       if (!is_edit_mode && !is_sculpt_mode && !has_edit_mesh_cage &&
-                                           ((ob->base_flag & BASE_SELECTED) != 0))
-                                       {
-                                               rim_col = (ob == draw_ctx->obact) ? ts.colorActive : ts.colorSelect;
-                                       }
                                        shgrp = (is_sculpt_mode) ? pd->sculpt_wires : pd->face_wires;
                                        shgrp = DRW_shgroup_create_sub(shgrp);
 
                                        shgrp = (is_sculpt_mode) ? pd->sculpt_wires : pd->face_wires;
                                        shgrp = DRW_shgroup_create_sub(shgrp);