diff options
author | Campbell Barton <ideasman42@gmail.com> | 2020-08-25 16:49:55 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2020-08-25 16:54:26 +0300 |
commit | 33ac3582bbd5551bdfbc7ef8856640b5e61888f8 (patch) | |
tree | 13c9bef0922ebfd0eb19a98190ce8c9ccc700f1e /source/blender/draw/intern/draw_cache_impl_mesh.c | |
parent | 3ea324488ac9a45cb96d6fc98f4021a38e2ff20f (diff) |
Fix T77359: Crash adding UV's in edit-mode with linked duplicates
This prevents UV layer mix up in
MeshBatchCache.cd_used/cd_needed/cd_used_over_time which depends on the
extraction method.
One object's mesh can be accessed with MR_EXTRACT_MESH, another object
that uses the same mesh can use MR_EXTRACT_BMESH based on
(Object.mode & OB_MODE_EDIT), this causes a problem as the edit-mesh
and the mesh aren't always in sync, the custom data layers wont
necessarily match up, causing T77359.
Reviewed by @jbakker, @brecht
Ref D8645
Diffstat (limited to 'source/blender/draw/intern/draw_cache_impl_mesh.c')
-rw-r--r-- | source/blender/draw/intern/draw_cache_impl_mesh.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.c b/source/blender/draw/intern/draw_cache_impl_mesh.c index d3a057b1016..772871f726e 100644 --- a/source/blender/draw/intern/draw_cache_impl_mesh.c +++ b/source/blender/draw/intern/draw_cache_impl_mesh.c @@ -1187,7 +1187,15 @@ void DRW_mesh_batch_cache_create_requested(struct TaskGraph *task_graph, BLI_assert(me->edit_mesh->mesh_eval_final != NULL); } - const bool is_editmode = (me->edit_mesh != NULL) && DRW_object_is_in_edit_mode(ob); + /* Don't check `DRW_object_is_in_edit_mode(ob)` here because it means the same mesh + * may draw with edit-mesh data and regular mesh data. + * In this case the custom-data layers used wont always match in `me->runtime.batch_cache`. + * If we want to display regular mesh data, we should have a separate cache for the edit-mesh. + * See T77359. */ + const bool is_editmode = (me->edit_mesh != NULL) /* && DRW_object_is_in_edit_mode(ob) */; + + /* This could be set for paint mode too, currently it's only used for edit-mode. */ + const bool is_mode_active = is_editmode && DRW_object_is_in_edit_mode(ob); DRWBatchFlag batch_requested = cache->batch_requested; cache->batch_requested = 0; @@ -1508,6 +1516,7 @@ void DRW_mesh_batch_cache_create_requested(struct TaskGraph *task_graph, me, is_editmode, is_paint_mode, + is_mode_active, ob->obmat, false, true, @@ -1525,6 +1534,7 @@ void DRW_mesh_batch_cache_create_requested(struct TaskGraph *task_graph, me, is_editmode, is_paint_mode, + is_mode_active, ob->obmat, false, false, @@ -1541,6 +1551,7 @@ void DRW_mesh_batch_cache_create_requested(struct TaskGraph *task_graph, me, is_editmode, is_paint_mode, + is_mode_active, ob->obmat, true, false, |