mirror of
https://github.com/blender/blender
synced 2026-09-29 04:37:17 +03:00
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
This commit is contained in:
parent
ec44ab0e89
commit
79945c8126
3 changed files with 19 additions and 3 deletions
|
|
@ -254,6 +254,7 @@ void mesh_buffer_cache_create_requested(MeshBatchCache *cache,
|
|||
Mesh *me,
|
||||
const bool is_editmode,
|
||||
const bool is_paint_mode,
|
||||
const bool is_mode_active,
|
||||
const float obmat[4][4],
|
||||
const bool do_final,
|
||||
const bool do_uvedit,
|
||||
|
|
|
|||
|
|
@ -130,6 +130,7 @@ typedef struct MeshRenderData {
|
|||
static MeshRenderData *mesh_render_data_create(Mesh *me,
|
||||
const bool is_editmode,
|
||||
const bool is_paint_mode,
|
||||
const bool is_mode_active,
|
||||
const float obmat[4][4],
|
||||
const bool do_final,
|
||||
const bool do_uvedit,
|
||||
|
|
@ -151,9 +152,10 @@ static MeshRenderData *mesh_render_data_create(Mesh *me,
|
|||
BLI_assert(me->edit_mesh->mesh_eval_cage && me->edit_mesh->mesh_eval_final);
|
||||
mr->bm = me->edit_mesh->bm;
|
||||
mr->edit_bmesh = me->edit_mesh;
|
||||
mr->edit_data = me->runtime.edit_data;
|
||||
mr->edit_data = is_mode_active ? mr->me->runtime.edit_data : NULL;
|
||||
mr->me = (do_final) ? me->edit_mesh->mesh_eval_final : me->edit_mesh->mesh_eval_cage;
|
||||
bool use_mapped = !do_uvedit && mr->me && !mr->me->runtime.is_original;
|
||||
|
||||
bool use_mapped = is_mode_active && (!do_uvedit && mr->me && !mr->me->runtime.is_original);
|
||||
|
||||
int bm_ensure_types = BM_VERT | BM_EDGE | BM_LOOP | BM_FACE;
|
||||
|
||||
|
|
@ -4605,6 +4607,7 @@ void mesh_buffer_cache_create_requested(MeshBatchCache *cache,
|
|||
Mesh *me,
|
||||
const bool is_editmode,
|
||||
const bool is_paint_mode,
|
||||
const bool is_mode_active,
|
||||
const float obmat[4][4],
|
||||
const bool do_final,
|
||||
const bool do_uvedit,
|
||||
|
|
@ -4669,6 +4672,7 @@ void mesh_buffer_cache_create_requested(MeshBatchCache *cache,
|
|||
MeshRenderData *mr = mesh_render_data_create(me,
|
||||
is_editmode,
|
||||
is_paint_mode,
|
||||
is_mode_active,
|
||||
obmat,
|
||||
do_final,
|
||||
do_uvedit,
|
||||
|
|
|
|||
|
|
@ -1035,7 +1035,15 @@ void DRW_mesh_batch_cache_create_requested(
|
|||
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;
|
||||
|
|
@ -1373,6 +1381,7 @@ void DRW_mesh_batch_cache_create_requested(
|
|||
me,
|
||||
is_editmode,
|
||||
is_paint_mode,
|
||||
is_mode_active,
|
||||
ob->obmat,
|
||||
false,
|
||||
true,
|
||||
|
|
@ -1389,6 +1398,7 @@ void DRW_mesh_batch_cache_create_requested(
|
|||
me,
|
||||
is_editmode,
|
||||
is_paint_mode,
|
||||
is_mode_active,
|
||||
ob->obmat,
|
||||
false,
|
||||
false,
|
||||
|
|
@ -1404,6 +1414,7 @@ void DRW_mesh_batch_cache_create_requested(
|
|||
me,
|
||||
is_editmode,
|
||||
is_paint_mode,
|
||||
is_mode_active,
|
||||
ob->obmat,
|
||||
true,
|
||||
false,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue