diff options
5 files changed, 49 insertions, 9 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..06ef56a212b 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; @@ -484,6 +503,16 @@ static void edit_uv_stretching_update_ratios(OVERLAY_Data *vedata) BLI_freelistN(&pd->edit_uv.totals); } +void OVERLAY_edit_uv_cache_finish(OVERLAY_Data *vedata) +{ + OVERLAY_StorageList *stl = vedata->stl; + OVERLAY_PrivateData *pd = stl->pd; + + if (pd->edit_uv.do_uv_stretching_overlay) { + edit_uv_stretching_update_ratios(vedata); + } +} + static void OVERLAY_edit_uv_draw_finish(OVERLAY_Data *vedata) { OVERLAY_StorageList *stl = vedata->stl; @@ -525,7 +554,6 @@ void OVERLAY_edit_uv_draw(OVERLAY_Data *vedata) } if (pd->edit_uv.do_uv_stretching_overlay) { - edit_uv_stretching_update_ratios(vedata); DRW_draw_pass(psl->edit_uv_stretching_ps); } diff --git a/source/blender/draw/engines/overlay/overlay_engine.c b/source/blender/draw/engines/overlay/overlay_engine.c index f87f781b6ce..fc9ec7ecc22 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; } @@ -489,7 +486,12 @@ static void OVERLAY_cache_finish(void *vedata) { OVERLAY_Data *data = vedata; OVERLAY_PrivateData *pd = data->stl->pd; - if (ELEM(pd->space_type, SPACE_IMAGE, SPACE_NODE)) { + + if (ELEM(pd->space_type, SPACE_IMAGE)) { + OVERLAY_edit_uv_cache_finish(vedata); + return; + } + if (ELEM(pd->space_type, SPACE_NODE)) { return; } diff --git a/source/blender/draw/engines/overlay/overlay_private.h b/source/blender/draw/engines/overlay/overlay_private.h index 3aee391c281..db43136e308 100644 --- a/source/blender/draw/engines/overlay/overlay_private.h +++ b/source/blender/draw/engines/overlay/overlay_private.h @@ -555,7 +555,7 @@ 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_cache_finish(OVERLAY_Data *vedata); void OVERLAY_edit_uv_draw(OVERLAY_Data *vedata); void OVERLAY_extra_cache_init(OVERLAY_Data *vedata); diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c index a77864415ce..2ab809c3633 100644 --- a/source/blender/editors/animation/anim_markers.c +++ b/source/blender/editors/animation/anim_markers.c @@ -749,8 +749,8 @@ static bool ed_marker_move_use_time(MarkerMove *mm) ((mm->slink->spacetype == SPACE_ACTION) && (((SpaceAction *)mm->slink)->flag & SACTION_DRAWTIME)) || ((mm->slink->spacetype == SPACE_GRAPH) && - !(((SpaceGraph *)mm->slink)->flag & SIPO_DRAWTIME)) || - ((mm->slink->spacetype == SPACE_NLA) && !(((SpaceNla *)mm->slink)->flag & SNLA_DRAWTIME))) { + (((SpaceGraph *)mm->slink)->flag & SIPO_DRAWTIME)) || + ((mm->slink->spacetype == SPACE_NLA) && (((SpaceNla *)mm->slink)->flag & SNLA_DRAWTIME))) { return true; } diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index eee8549572f..af9f5937b4f 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -1959,6 +1959,16 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(Depsgraph *depsgraph, } } + /* XXX(jbakker): `do_color_management` should be controlled by the caller. Currently when doing a + * viewport render animation and saving to an 8bit file format, color management would be applied + * twice. Once here, and once when saving the saving to disk. In this case the Save As Render + * option cannot be controlled either. But when doing an offscreen render you want to do the + * color management here. + * + * This option was added here to increase the performance when rendering for a playblast. When + * using workbench the color differences haven't been reported as a bug. But users also use the + * viewport rendering to render Eevee scenes. In the later situation the saved colors + * are totally wrong. */ const bool do_color_management = (ibuf->rect_float == NULL); ED_view3d_draw_offscreen(depsgraph, scene, |