diff options
Diffstat (limited to 'source/blender/editors/sculpt_paint')
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_image_proj.c | 23 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/sculpt.c | 15 |
2 files changed, 27 insertions, 11 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c index 017232d1856..db55dc271f1 100644 --- a/source/blender/editors/sculpt_paint/paint_image_proj.c +++ b/source/blender/editors/sculpt_paint/paint_image_proj.c @@ -2816,7 +2816,11 @@ static void project_paint_begin(ProjPaintState *ps) int a, i; /* generic looping vars */ int image_index = -1, face_index; - int *mpoly_origindex; + + /* double lookup */ + const int *index_mf_to_mpoly = NULL; + const int *index_mp_to_orig = NULL; + MVert *mv; MemArena *arena; /* at the moment this is just ps->arena_mt[0], but use this to show were not multithreading */ @@ -2871,12 +2875,17 @@ static void project_paint_begin(ProjPaintState *ps) ps->dm_totface = ps->dm->getNumTessFaces(ps->dm); if (ps->do_face_sel) { - mpoly_orig = ((Mesh *)ps->ob->data)->mpoly; - mpoly_origindex = ps->dm->getPolyDataArray(ps->dm, CD_ORIGINDEX); + index_mf_to_mpoly = ps->dm->getTessFaceDataArray(ps->dm, CD_ORIGINDEX); + index_mp_to_orig = ps->dm->getPolyDataArray(ps->dm, CD_ORIGINDEX); + if (index_mf_to_mpoly == NULL) { + index_mp_to_orig = NULL; + } + else { + mpoly_orig = ((Mesh *)ps->ob->data)->mpoly; + } } else { mpoly_orig = NULL; - mpoly_origindex = NULL; } /* use clone mtface? */ @@ -3166,8 +3175,10 @@ static void project_paint_begin(ProjPaintState *ps) if (ps->do_face_sel) { int orig_index; - if (mpoly_origindex && ((orig_index = mpoly_origindex[face_index])) != ORIGINDEX_NONE) { - MPoly *mp = mpoly_orig + orig_index; + if (index_mp_to_orig && ((orig_index = DM_origindex_mface_mpoly(index_mf_to_mpoly, index_mp_to_orig, + face_index))) != ORIGINDEX_NONE) + { + MPoly *mp = &mpoly_orig[orig_index]; is_face_sel = ((mp->flag & ME_FACE_SEL) != 0); } else { diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index c7f8161c7ed..f67cc0359a2 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -4652,13 +4652,18 @@ void sculpt_dynamic_topology_disable(bContext *C, sculptsession_bm_to_me(ob, TRUE); } - BM_mesh_free(ss->bm); - /* Clear data */ me->flag &= ~ME_SCULPT_DYNAMIC_TOPOLOGY; - ss->bm = NULL; - BM_log_free(ss->bm_log); - ss->bm_log = NULL; + + /* typically valid but with global-undo they can be NULL, [#36234] */ + if (ss->bm) { + BM_mesh_free(ss->bm); + ss->bm = NULL; + } + if (ss->bm_log) { + BM_log_free(ss->bm_log); + ss->bm_log = NULL; + } /* Refresh */ sculpt_update_after_dynamic_topology_toggle(C); |