Fix T58150: crash in Texture Paint after changing selection in Edit Mode.

Texture paint code was retrieving the evaluated mesh from the
original object, which isn't supposed to happen, so the cached
mesh isn't properly cleaned up by Edit Mode toggle.
This commit is contained in:
Alexander Gavrilov 2018-11-30 17:10:52 +03:00
parent 06df05a35b
commit dabd6615cc
Notes: blender-bot 2023-02-14 05:12:58 +01:00
Referenced by issue #57157, crash, texture paint mode
1 changed files with 10 additions and 3 deletions

View File

@ -3404,17 +3404,24 @@ static bool proj_paint_state_mesh_eval_init(const bContext *C, ProjPaintState *p
Depsgraph *depsgraph = CTX_data_depsgraph(C);
Object *ob = ps->ob;
Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
if (scene_eval == NULL || ob_eval == NULL) {
return false;
}
/* Workaround for subsurf selection, try the display mesh first */
if (ps->source == PROJ_SRC_IMAGE_CAM) {
/* using render mesh, assume only camera was rendered from */
ps->me_eval = mesh_create_eval_final_render(
depsgraph, ps->scene, ps->ob, ps->scene->customdata_mask | CD_MASK_MLOOPUV | CD_MASK_MTFACE);
depsgraph, scene_eval, ob_eval, scene_eval->customdata_mask | CD_MASK_MLOOPUV | CD_MASK_MTFACE);
ps->me_eval_free = true;
}
else {
ps->me_eval = mesh_get_eval_final(
depsgraph, ps->scene, ps->ob,
ps->scene->customdata_mask | CD_MASK_MLOOPUV | CD_MASK_MTFACE | (ps->do_face_sel ? CD_MASK_ORIGINDEX : 0));
depsgraph, scene_eval, ob_eval,
scene_eval->customdata_mask | CD_MASK_MLOOPUV | CD_MASK_MTFACE | (ps->do_face_sel ? CD_MASK_ORIGINDEX : 0));
ps->me_eval_free = false;
}