diff options
author | Jeroen Bakker <jeroen@blender.org> | 2021-01-27 16:17:53 +0300 |
---|---|---|
committer | Jeroen Bakker <jeroen@blender.org> | 2021-01-27 18:07:17 +0300 |
commit | f83aa830cd00ad9b8656e2806620d80cb56b3172 (patch) | |
tree | 5d4d617cb454ff9560d79b6fbae1c4a8c50aafbc /source/blender/draw/engines/overlay | |
parent | 4fbeb3e6be3ed03e55ebd8a9d41c80c2a4f08815 (diff) |
Fix T83187: Unselected UVs shows selected on linked meshes.
When uv editing objects that share the same mesh only the selection
state can get confused. The cause is that the UV editor uses a
particular order of objects and store its state in the first object of a
mesh it hasn't handled. During drawing this state is updated into the
GPU buffers. In the case of linked meshes it can happen that the GPU
buffers are updated based on the object that does not have the correct
selection state making th selection VBOs incorrect.
This patch adds a work around that uses the order that the UV editor is
also using so the GPU buffers are built with the right data.
Diffstat (limited to 'source/blender/draw/engines/overlay')
-rw-r--r-- | source/blender/draw/engines/overlay/overlay_edit_uv.c | 21 | ||||
-rw-r--r-- | source/blender/draw/engines/overlay/overlay_engine.c | 3 | ||||
-rw-r--r-- | source/blender/draw/engines/overlay/overlay_private.h | 1 |
3 files changed, 20 insertions, 5 deletions
diff --git a/source/blender/draw/engines/overlay/overlay_edit_uv.c b/source/blender/draw/engines/overlay/overlay_edit_uv.c index 53f517f12ca..d33136a3801 100644 --- a/source/blender/draw/engines/overlay/overlay_edit_uv.c +++ b/source/blender/draw/engines/overlay/overlay_edit_uv.c @@ -26,6 +26,7 @@ #include "BKE_editmesh.h" #include "BKE_image.h" +#include "BKE_layer.h" #include "BKE_mask.h" #include "BKE_paint.h" @@ -45,6 +46,9 @@ #include "overlay_private.h" +/* Forward declarations. */ +static void overlay_edit_uv_cache_populate(OVERLAY_Data *vedata, Object *ob); + typedef struct OVERLAY_StretchingAreaTotals { void *next, *prev; float *total_area; @@ -393,9 +397,24 @@ void OVERLAY_edit_uv_cache_init(OVERLAY_Data *vedata) DRW_shgroup_uniform_vec4_copy(grp, "color", (float[4]){1.0f, 1.0f, 1.0f, 1.0f}); DRW_shgroup_call_obmat(grp, geom, NULL); } + + /* HACK: When editing objects that share the same mesh we should only draw the + * first one in the order that is used during uv editing. We can only trust that the first object + * has the correct batches with the correct selection state. See T83187. */ + if (pd->edit_uv.do_uv_overlay || pd->edit_uv.do_uv_shadow_overlay) { + uint objects_len = 0; + Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs( + draw_ctx->view_layer, NULL, &objects_len); + for (uint ob_index = 0; ob_index < objects_len; ob_index++) { + Object *object_eval = DEG_get_evaluated_object(draw_ctx->depsgraph, objects[ob_index]); + DRW_mesh_batch_cache_validate((Mesh *)object_eval->data); + overlay_edit_uv_cache_populate(vedata, object_eval); + } + MEM_freeN(objects); + } } -void OVERLAY_edit_uv_cache_populate(OVERLAY_Data *vedata, Object *ob) +static void overlay_edit_uv_cache_populate(OVERLAY_Data *vedata, Object *ob) { OVERLAY_StorageList *stl = vedata->stl; OVERLAY_PrivateData *pd = stl->pd; diff --git a/source/blender/draw/engines/overlay/overlay_engine.c b/source/blender/draw/engines/overlay/overlay_engine.c index f87f781b6ce..3e56ed7de5d 100644 --- a/source/blender/draw/engines/overlay/overlay_engine.c +++ b/source/blender/draw/engines/overlay/overlay_engine.c @@ -298,9 +298,6 @@ static void OVERLAY_cache_populate(void *vedata, Object *ob) OVERLAY_PrivateData *pd = data->stl->pd; if (pd->space_type == SPACE_IMAGE) { - if (ob->type == OB_MESH) { - OVERLAY_edit_uv_cache_populate(vedata, ob); - } return; } diff --git a/source/blender/draw/engines/overlay/overlay_private.h b/source/blender/draw/engines/overlay/overlay_private.h index 3aee391c281..2975fe70796 100644 --- a/source/blender/draw/engines/overlay/overlay_private.h +++ b/source/blender/draw/engines/overlay/overlay_private.h @@ -555,7 +555,6 @@ void OVERLAY_edit_particle_draw(OVERLAY_Data *vedata); void OVERLAY_edit_uv_init(OVERLAY_Data *vedata); void OVERLAY_edit_uv_cache_init(OVERLAY_Data *vedata); -void OVERLAY_edit_uv_cache_populate(OVERLAY_Data *vedata, Object *ob); void OVERLAY_edit_uv_draw(OVERLAY_Data *vedata); void OVERLAY_extra_cache_init(OVERLAY_Data *vedata); |