Edit Mesh: Fix buggy occlusion when in xray mode.

This mimics the behaviour of the old wireframe mode. When in Xray mode,
don't use the limit selection to visible option.

Also hide the option if Xray is enabled.
This commit is contained in:
Clément Foucault 2018-06-17 20:11:23 +02:00
parent 06a1a66a9b
commit 195879a50d
2 changed files with 13 additions and 7 deletions

@ -65,8 +65,9 @@ class VIEW3D_HT_header(Header):
row.prop(tool_settings.particle_edit, "select_mode", text="", expand=True) row.prop(tool_settings.particle_edit, "select_mode", text="", expand=True)
# Occlude geometry # Occlude geometry
if ((shading.type not in {'BOUNDBOX', 'WIREFRAME'} and (mode == 'PARTICLE_EDIT' or (mode == 'EDIT' and obj.type == 'MESH'))) or if ((((shading.type not in {'SOLID', 'TEXTURED'}) or not shading.show_xray) and
(mode in {'WEIGHT_PAINT', 'VERTEX_PAINT'})): (mode == 'PARTICLE_EDIT' or (mode == 'EDIT' and obj.type == 'MESH'))) or
(mode in {'WEIGHT_PAINT', 'VERTEX_PAINT'})):
row = layout.row() row = layout.row()
row.prop(view, "use_occlude_geometry", text="") row.prop(view, "use_occlude_geometry", text="")

@ -134,6 +134,7 @@ typedef struct EDIT_MESH_PrivateData {
DRWShadingGroup *facedot_occluded_shgrp; DRWShadingGroup *facedot_occluded_shgrp;
DRWShadingGroup *facefill_occluded_shgrp; DRWShadingGroup *facefill_occluded_shgrp;
bool do_zbufclip;
} EDIT_MESH_PrivateData; /* Transient data */ } EDIT_MESH_PrivateData; /* Transient data */
/* *********** FUNCTIONS *********** */ /* *********** FUNCTIONS *********** */
@ -352,8 +353,6 @@ static void EDIT_MESH_cache_init(void *vedata)
const DRWContextState *draw_ctx = DRW_context_state_get(); const DRWContextState *draw_ctx = DRW_context_state_get();
View3D *v3d = draw_ctx->v3d; View3D *v3d = draw_ctx->v3d;
bool do_zbufclip = ((v3d->flag & V3D_ZBUF_SELECT) == 0);
static float zero = 0.0f; static float zero = 0.0f;
if (!stl->g_data) { if (!stl->g_data) {
@ -361,6 +360,11 @@ static void EDIT_MESH_cache_init(void *vedata)
stl->g_data = MEM_mallocN(sizeof(*stl->g_data), __func__); stl->g_data = MEM_mallocN(sizeof(*stl->g_data), __func__);
} }
const bool xray_enabled = ((draw_ctx->v3d->shading.flag & V3D_SHADING_XRAY) != 0) &&
(draw_ctx->v3d->drawtype < OB_MATERIAL);
stl->g_data->do_zbufclip = ((v3d->flag & V3D_ZBUF_SELECT) == 0) || xray_enabled;
{ {
psl->vcolor_faces = DRW_pass_create( psl->vcolor_faces = DRW_pass_create(
"Vert Color Pass", "Vert Color Pass",
@ -403,7 +407,7 @@ static void EDIT_MESH_cache_init(void *vedata)
DRW_shgroup_uniform_vec4(stl->g_data->lnormals_shgrp, "color", ts.colorLNormal, 1); DRW_shgroup_uniform_vec4(stl->g_data->lnormals_shgrp, "color", ts.colorLNormal, 1);
} }
if (!do_zbufclip) { if (!stl->g_data->do_zbufclip) {
psl->edit_face_overlay = edit_mesh_create_overlay_pass( psl->edit_face_overlay = edit_mesh_create_overlay_pass(
&face_mod, DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_WRITE_DEPTH | DRW_STATE_BLEND, &face_mod, DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_WRITE_DEPTH | DRW_STATE_BLEND,
&stl->g_data->face_overlay_shgrp, &stl->g_data->ledges_overlay_shgrp, &stl->g_data->face_overlay_shgrp, &stl->g_data->ledges_overlay_shgrp,
@ -519,7 +523,7 @@ static void EDIT_MESH_cache_populate(void *vedata, Object *ob)
} }
} }
if ((v3d->flag & V3D_ZBUF_SELECT) == 0) { if (stl->g_data->do_zbufclip) {
edit_mesh_add_ob_to_pass( edit_mesh_add_ob_to_pass(
scene, ob, stl->g_data->face_occluded_shgrp, stl->g_data->ledges_occluded_shgrp, scene, ob, stl->g_data->face_occluded_shgrp, stl->g_data->ledges_occluded_shgrp,
stl->g_data->lverts_occluded_shgrp, stl->g_data->facedot_occluded_shgrp, stl->g_data->lverts_occluded_shgrp, stl->g_data->facedot_occluded_shgrp,
@ -550,6 +554,7 @@ static void EDIT_MESH_cache_populate(void *vedata, Object *ob)
static void EDIT_MESH_draw_scene(void *vedata) static void EDIT_MESH_draw_scene(void *vedata)
{ {
EDIT_MESH_PassList *psl = ((EDIT_MESH_Data *)vedata)->psl; EDIT_MESH_PassList *psl = ((EDIT_MESH_Data *)vedata)->psl;
EDIT_MESH_StorageList *stl = ((EDIT_MESH_Data *)vedata)->stl;
EDIT_MESH_FramebufferList *fbl = ((EDIT_MESH_Data *)vedata)->fbl; EDIT_MESH_FramebufferList *fbl = ((EDIT_MESH_Data *)vedata)->fbl;
DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get(); DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get();
@ -557,7 +562,7 @@ static void EDIT_MESH_draw_scene(void *vedata)
DRW_draw_pass(psl->depth_hidden_wire); DRW_draw_pass(psl->depth_hidden_wire);
if (psl->edit_face_occluded) { if (stl->g_data->do_zbufclip) {
float clearcol[4] = {0.0f, 0.0f, 0.0f, 0.0f}; float clearcol[4] = {0.0f, 0.0f, 0.0f, 0.0f};
/* render facefill */ /* render facefill */
DRW_draw_pass(psl->facefill_occlude); DRW_draw_pass(psl->facefill_occlude);