[Bf-blender-cvs] [06a62d4e064] master: Undo: use with_prev verisons of id-map lookups

Campbell Barton noreply at git.blender.org
Tue Apr 3 17:07:13 CEST 2018


Commit: 06a62d4e06445506b69b9d83c3ab5480254d40da
Author: Campbell Barton
Date:   Tue Apr 3 17:03:13 2018 +0200
Branches: master
https://developer.blender.org/rB06a62d4e06445506b69b9d83c3ab5480254d40da

Undo: use with_prev verisons of id-map lookups

===================================================================

M	source/blender/editors/mesh/editmesh_undo.c

===================================================================

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]);
 				}
 			}
 		}



More information about the Bf-blender-cvs mailing list