DRW: Fix flat object not being selectable in wireframe view

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.
This commit is contained in:
Clément Foucault 2018-12-18 15:08:33 +01:00
parent 6e5b573dc8
commit 45e1d4d9ac
2 changed files with 9 additions and 7 deletions

View 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) ||
(draw_ctx->v3d->shading.type == OB_WIRE) ||
(ob->dtx & OB_DRAWWIRE) ||
(ob->dt == OB_WIRE))
{

View 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);
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);
@ -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;
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) &&
@ -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);
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) {
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);