Fix T72688: Vertex Group Weights in Edit Mode Occludes In Front Armatures

Due to legacy this overlay was implemented twice (Edit Mesh and Weight
Painting) with different results. This patch consolidates both drawing
and uses only the Weight Painting drawing.

Reviewed By: Clément Foucault

Differential Revision: https://developer.blender.org/D7289
This commit is contained in:
Jeroen Bakker 2020-03-31 15:32:03 +02:00
parent 1c3ded12f4
commit 782e6ea4ed
Notes: blender-bot 2023-02-14 10:29:32 +01:00
Referenced by commit fa8a3c8f26, Revert "Fix T72688: Vertex Group Weights in Edit Mode Occludes In Front Armatures"
Referenced by issue #72688, Vertex Group Weights in Edit Mode Occludes In Front Armatures
5 changed files with 21 additions and 31 deletions

View File

@ -118,18 +118,6 @@ void OVERLAY_edit_mesh_cache_init(OVERLAY_Data *vedata)
show_face_dots = true;
}
{
/* TODO(fclem) Shouldn't this be going into the paint overlay? */
state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL;
DRW_PASS_CREATE(psl->edit_mesh_weight_ps, state | pd->clipping_state);
sh = OVERLAY_shader_paint_weight();
pd->edit_mesh_weight_grp = grp = DRW_shgroup_create(sh, psl->edit_mesh_weight_ps);
DRW_shgroup_uniform_float_copy(grp, "opacity", 1.0);
DRW_shgroup_uniform_bool_copy(grp, "drawContours", false);
DRW_shgroup_uniform_texture(grp, "colorramp", G_draw.weight_ramp);
DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
}
/* Run Twice for in-front passes. */
for (int i = 0; i < 2; i++) {
/* Complementary Depth Pass */
@ -283,17 +271,12 @@ void OVERLAY_edit_mesh_cache_populate(OVERLAY_Data *vedata, Object *ob)
bool do_in_front = (ob->dtx & OB_DRAWXRAY) != 0;
bool do_occlude_wire = (pd->edit_mesh.flag & V3D_OVERLAY_EDIT_OCCLUDE_WIRE) != 0;
bool do_show_weight = (pd->edit_mesh.flag & V3D_OVERLAY_EDIT_WEIGHT) != 0;
bool do_show_mesh_analysis = (pd->edit_mesh.flag & V3D_OVERLAY_EDIT_STATVIS) != 0;
bool fnormals_do = (pd->edit_mesh.flag & V3D_OVERLAY_EDIT_FACE_NORMALS) != 0;
bool vnormals_do = (pd->edit_mesh.flag & V3D_OVERLAY_EDIT_VERT_NORMALS) != 0;
bool lnormals_do = (pd->edit_mesh.flag & V3D_OVERLAY_EDIT_LOOP_NORMALS) != 0;
if (do_show_weight) {
geom = DRW_cache_mesh_surface_weights_get(ob);
DRW_shgroup_call_no_cull(pd->edit_mesh_weight_grp, geom, ob);
}
else if (do_show_mesh_analysis && !pd->xray_enabled) {
if (do_show_mesh_analysis && !pd->xray_enabled) {
geom = DRW_cache_mesh_surface_mesh_analysis_get(ob);
if (geom) {
DRW_shgroup_call_no_cull(pd->edit_mesh_analysis_grp, geom, ob);
@ -364,7 +347,6 @@ void OVERLAY_edit_mesh_draw(OVERLAY_Data *vedata)
GPU_framebuffer_bind(fbl->overlay_default_fb);
}
DRW_draw_pass(psl->edit_mesh_weight_ps);
DRW_draw_pass(psl->edit_mesh_analysis_ps);
DRW_draw_pass(psl->edit_mesh_depth_ps[NOT_IN_FRONT]);

View File

@ -106,10 +106,14 @@ static void OVERLAY_cache_init(void *vedata)
OVERLAY_Data *data = vedata;
OVERLAY_StorageList *stl = data->stl;
OVERLAY_PrivateData *pd = stl->pd;
const bool draw_edit_weights = (pd->edit_mesh.flag & V3D_OVERLAY_EDIT_WEIGHT);
switch (pd->ctx_mode) {
case CTX_MODE_EDIT_MESH:
OVERLAY_edit_mesh_cache_init(vedata);
if (draw_edit_weights) {
OVERLAY_paint_cache_init(vedata);
}
break;
case CTX_MODE_EDIT_SURFACE:
case CTX_MODE_EDIT_CURVE:
@ -251,6 +255,7 @@ static void OVERLAY_cache_populate(void *vedata, Object *ob)
(ob->base_flag & BASE_SELECTED);
const bool draw_bone_selection = (ob->type == OB_MESH) && pd->armature.do_pose_fade_geom &&
!is_select;
const bool draw_edit_weights = in_edit_mode && (pd->edit_mesh.flag & V3D_OVERLAY_EDIT_WEIGHT);
const bool draw_extras =
(!pd->hide_overlays) &&
(((pd->overlay.flag & V3D_OVERLAY_HIDE_OBJECT_XTRAS) == 0) ||
@ -279,6 +284,9 @@ static void OVERLAY_cache_populate(void *vedata, Object *ob)
switch (ob->type) {
case OB_MESH:
OVERLAY_edit_mesh_cache_populate(vedata, ob);
if (draw_edit_weights) {
OVERLAY_paint_weight_cache_populate(vedata, ob);
}
break;
case OB_ARMATURE:
if (draw_bones) {
@ -495,6 +503,7 @@ static void OVERLAY_draw_scene(void *vedata)
switch (pd->ctx_mode) {
case CTX_MODE_EDIT_MESH:
OVERLAY_paint_draw(vedata);
OVERLAY_edit_mesh_draw(vedata);
break;
case CTX_MODE_EDIT_SURFACE:

View File

@ -76,15 +76,18 @@ void OVERLAY_paint_cache_init(OVERLAY_Data *vedata)
DRWShadingGroup *grp;
DRWState state;
const bool draw_contours = (pd->overlay.wpaint_flag & V3D_OVERLAY_WPAINT_CONTOURS) != 0;
const bool is_edit_mode = (pd->ctx_mode == CTX_MODE_EDIT_MESH);
const bool draw_contours = !is_edit_mode &&
(pd->overlay.wpaint_flag & V3D_OVERLAY_WPAINT_CONTOURS) != 0;
float opacity = 0.0f;
pd->paint_depth_grp = NULL;
psl->paint_depth_ps = NULL;
switch (pd->ctx_mode) {
case CTX_MODE_POSE:
case CTX_MODE_EDIT_MESH:
case CTX_MODE_PAINT_WEIGHT: {
opacity = pd->overlay.weight_paint_mode_opacity;
opacity = is_edit_mode ? 1.0 : pd->overlay.weight_paint_mode_opacity;
if (opacity > 0.0f) {
state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL;
state |= pd->painting.alpha_blending ? DRW_STATE_BLEND_ALPHA : DRW_STATE_BLEND_MUL;
@ -207,11 +210,12 @@ void OVERLAY_paint_vertex_cache_populate(OVERLAY_Data *vedata, Object *ob)
struct GPUBatch *geom = NULL;
const Mesh *me_orig = DEG_get_original_object(ob)->data;
const bool use_wire = (pd->overlay.paint_flag & V3D_OVERLAY_PAINT_WIRE) != 0;
const bool use_face_sel = (me_orig->editflag & ME_EDIT_PAINT_FACE_SEL) != 0;
const bool use_vert_sel = (me_orig->editflag & ME_EDIT_PAINT_VERT_SEL) != 0;
const bool is_edit_mode = (pd->ctx_mode == CTX_MODE_EDIT_MESH);
const bool use_wire = !is_edit_mode && (pd->overlay.paint_flag & V3D_OVERLAY_PAINT_WIRE);
const bool use_face_sel = !is_edit_mode && (me_orig->editflag & ME_EDIT_PAINT_FACE_SEL);
const bool use_vert_sel = !is_edit_mode && (me_orig->editflag & ME_EDIT_PAINT_VERT_SEL);
if (ob->mode == OB_MODE_WEIGHT_PAINT) {
if (ELEM(ob->mode, OB_MODE_WEIGHT_PAINT, OB_MODE_EDIT)) {
if (pd->paint_surf_grp) {
geom = DRW_cache_mesh_surface_weights_get(ob);
DRW_shgroup_call(pd->paint_surf_grp, geom, ob);

View File

@ -70,7 +70,6 @@ typedef struct OVERLAY_PassList {
DRWPass *edit_mesh_faces_cage_ps[2];
DRWPass *edit_mesh_analysis_ps;
DRWPass *edit_mesh_normals_ps;
DRWPass *edit_mesh_weight_ps;
DRWPass *edit_particle_ps;
DRWPass *edit_text_overlay_ps;
DRWPass *edit_text_wire_ps[2];
@ -235,7 +234,6 @@ typedef struct OVERLAY_PrivateData {
DRWShadingGroup *edit_mesh_skin_roots_grp[2];
DRWShadingGroup *edit_mesh_normals_grp;
DRWShadingGroup *edit_mesh_analysis_grp;
DRWShadingGroup *edit_mesh_weight_grp;
DRWShadingGroup *edit_particle_strand_grp;
DRWShadingGroup *edit_particle_point_grp;
DRWShadingGroup *edit_text_overlay_grp;

View File

@ -145,11 +145,8 @@ bool DRW_object_is_renderable(const Object *ob)
if (ob->type == OB_MESH) {
if ((ob == DST.draw_ctx.object_edit) || DRW_object_is_in_edit_mode(ob)) {
View3D *v3d = DST.draw_ctx.v3d;
const int mask = (V3D_OVERLAY_EDIT_OCCLUDE_WIRE | V3D_OVERLAY_EDIT_WEIGHT);
if (v3d && v3d->overlay.edit_flag & mask) {
if (v3d && v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_OCCLUDE_WIRE) {
return false;
}
}