From 2977280b0e672465426f4c57c0c6746f3571faa3 Mon Sep 17 00:00:00 2001 From: YimingWu Date: Thu, 11 May 2023 15:01:55 +0800 Subject: [PATCH] Fix #107768: vpaint select fix in retopo overlay. This fixes the "unable to select vertex/face mask in vertex paint when retopo overlay is enabled" behaviour, it allows the selection ID to be drawn normally without getting bypassed by the newly added retopo overlay option check since that option would need the solid mesh to do occlusion when XRay is not enabled. --- .../draw/engines/overlay/overlay_edit_uv.cc | 8 ++++---- .../blender/draw/engines/select/select_engine.c | 2 +- source/blender/draw/intern/DRW_render.h | 8 ++++++++ source/blender/draw/intern/draw_manager.c | 17 ++++++++++++++++- 4 files changed, 29 insertions(+), 6 deletions(-) diff --git a/source/blender/draw/engines/overlay/overlay_edit_uv.cc b/source/blender/draw/engines/overlay/overlay_edit_uv.cc index 90c83357477..996b3d37518 100644 --- a/source/blender/draw/engines/overlay/overlay_edit_uv.cc +++ b/source/blender/draw/engines/overlay/overlay_edit_uv.cc @@ -117,10 +117,10 @@ void OVERLAY_edit_uv_init(OVERLAY_Data *vedata) const bool show_modified_uvs = sima->flag & SI_DRAWSHADOW; const bool is_tiled_image = image && (image->source == IMA_SRC_TILED); const bool do_edges_only = (ts->uv_flag & UV_SYNC_SELECTION) ? - /* NOTE: Ignore #SCE_SELECT_EDGE because a single selected edge - * on the mesh may cause single UV vertices to be selected. */ - false : - (ts->uv_selectmode == UV_SELECT_EDGE); + /* NOTE: Ignore #SCE_SELECT_EDGE because a single selected edge + * on the mesh may cause single UV vertices to be selected. */ + false : + (ts->uv_selectmode == UV_SELECT_EDGE); const bool do_faces = ((sima->flag & SI_NO_DRAWFACES) == 0); const bool do_face_dots = (ts->uv_flag & UV_SYNC_SELECTION) ? (ts->selectmode & SCE_SELECT_FACE) != 0 : diff --git a/source/blender/draw/engines/select/select_engine.c b/source/blender/draw/engines/select/select_engine.c index 1cf5586c146..79621f4be87 100644 --- a/source/blender/draw/engines/select/select_engine.c +++ b/source/blender/draw/engines/select/select_engine.c @@ -217,7 +217,7 @@ static void select_cache_populate(void *vedata, Object *ob) const bool retopology_occlusion = RETOPOLOGY_ENABLED(draw_ctx->v3d) && !XRAY_ENABLED(draw_ctx->v3d); - if (retopology_occlusion && !DRW_object_is_in_edit_mode(ob)) { + if (retopology_occlusion && !DRW_object_should_not_occlude(ob)) { if (ob->dt >= OB_SOLID) { struct GPUBatch *geom_faces = DRW_mesh_batch_cache_get_surface(ob->data); DRW_shgroup_call_obmat(stl->g_data->shgrp_occlude, geom_faces, ob->object_to_world); diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h index f4406dbdca0..18a25af4f7c 100644 --- a/source/blender/draw/intern/DRW_render.h +++ b/source/blender/draw/intern/DRW_render.h @@ -877,6 +877,14 @@ bool DRW_object_is_renderable(const struct Object *ob); * This will not be the case when one of the objects are influenced by modifiers. */ bool DRW_object_is_in_edit_mode(const struct Object *ob); + +/** + * Should `ob` be used for occlusion in selection when in weight and vertex paint mode, this + * is needed for when retopology overlay is enabled to still be able to render IDs for face + * and vertex selection. + */ +bool DRW_object_should_not_occlude(const Object *ob); + /** * Return whether this object is visible depending if * we are rendering or drawing in the viewport. diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index ae874e44414..c5fcbdc1bd5 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -210,6 +210,21 @@ bool DRW_object_is_in_edit_mode(const Object *ob) return false; } +bool DRW_object_should_not_occlude(const Object *ob) +{ + if (DRW_object_is_in_edit_mode(ob)) { + return true; + } + if (ob->type == OB_MESH && (ob->mode & OB_MODE_VERTEX_PAINT) || + (ob->mode & OB_MODE_WEIGHT_PAINT)) { + Mesh *me = ob->data; + if ((ME_EDIT_PAINT_SEL_MODE(me))) { + return true; + } + } + return false; +} + int DRW_object_visibility_in_active_context(const Object *ob) { const eEvaluationMode mode = DRW_state_is_scene_render() ? DAG_EVAL_RENDER : DAG_EVAL_VIEWPORT; @@ -2788,7 +2803,7 @@ void DRW_draw_select_id(Depsgraph *depsgraph, ARegion *region, View3D *v3d, cons * It also has non-mesh objects however, which are not supported here. */ continue; } - if (DRW_object_is_in_edit_mode(ob)) { + if (DRW_object_should_not_occlude(ob)) { /* Only background (non-edit) objects are used for occlusion. */ continue; } -- 2.30.2