diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-04-03 18:03:13 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-04-03 18:03:33 +0300 |
commit | 06a62d4e06445506b69b9d83c3ab5480254d40da (patch) | |
tree | 28ef375a7aba28f54b3c4ed9c0c01d5817895e5f /source/blender/editors/mesh | |
parent | 5a7deab65a7d9bcbd62d880987859e0c171e2b51 (diff) |
Undo: use with_prev verisons of id-map lookups
Diffstat (limited to 'source/blender/editors/mesh')
-rw-r--r-- | source/blender/editors/mesh/editmesh_undo.c | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/source/blender/editors/mesh/editmesh_undo.c b/source/blender/editors/mesh/editmesh_undo.c index 220f9cc0287..50aecd0a821 100644 --- a/source/blender/editors/mesh/editmesh_undo.c +++ b/source/blender/editors/mesh/editmesh_undo.c @@ -687,8 +687,8 @@ static void mesh_undosys_step_encode_store_ids(MeshUndoStep *us) BMesh *bm = me->edit_btmesh->bm; const int mtex_len = CustomData_number_of_layers(&bm->pdata, CD_MTEXPOLY); if (mtex_len != 0) { - ID **id_src = BLI_array_alloca(id_src, mtex_len); - memset(id_src, 0x0, sizeof(*id_src) * mtex_len); + ID **id_prev_array = BLI_array_alloca(id_prev_array, mtex_len); + memset(id_prev_array, 0x0, sizeof(*id_prev_array) * mtex_len); BMIter iter; BMFace *efa; @@ -706,10 +706,7 @@ static void mesh_undosys_step_encode_store_ids(MeshUndoStep *us) { const MTexPoly *tf = BM_ELEM_CD_GET_VOID_P(efa, cd_poly_tex_offset); if (tf->tpage != NULL) { - if ((ID *)tf->tpage != id_src[i]) { - BKE_undosys_ID_map_add(us->id_map, (ID *)tf->tpage); - id_src[i] = (ID *)tf->tpage; - } + BKE_undosys_ID_map_add_with_prev(us->id_map, (ID *)tf->tpage, &id_prev_array[i]); } } } @@ -725,9 +722,8 @@ static void mesh_undosys_step_decode_restore_ids(MeshUndoStep *us) BMIter iter; BMFace *efa; - ID **id_dst = BLI_array_alloca(id_dst, mtex_len); - ID **id_src = BLI_array_alloca(id_src, mtex_len); - memset(id_src, 0x0, sizeof(*id_src) * mtex_len); + ID *(*id_prev_array)[2] = BLI_array_alloca(id_prev_array, mtex_len); + memset(id_prev_array, 0x0, sizeof(*id_prev_array) * mtex_len); uint cd_poly_tex_offset_first = CustomData_get_n_offset(&bm->pdata, CD_MTEXPOLY, 0); uint cd_poly_tex_offset_end = cd_poly_tex_offset_first + (sizeof(MTexPoly) * mtex_len); @@ -738,14 +734,7 @@ static void mesh_undosys_step_decode_restore_ids(MeshUndoStep *us) { MTexPoly *tf = BM_ELEM_CD_GET_VOID_P(efa, cd_poly_tex_offset); if (tf->tpage != NULL) { - if ((ID *)tf->tpage == id_src[i]) { - tf->tpage = (Image *)id_dst[i]; - } - else { - id_src[i] = (ID *)tf->tpage; - tf->tpage = (Image *)BKE_undosys_ID_map_lookup(us->id_map, (ID *)tf->tpage); - id_dst[i] = (ID *)tf->tpage; - } + tf->tpage = (Image *)BKE_undosys_ID_map_lookup_with_prev(us->id_map, (ID *)tf->tpage, id_prev_array[i]); } } } |