From 6aaedc7cfd3e2efdeb1cf42e8c5c7a1c303e42d8 Mon Sep 17 00:00:00 2001 From: Gaia Clary Date: Thu, 12 Mar 2015 14:21:41 +0100 Subject: Refer to Task 43975: Deleting a Shapekey can break the relative pointers This patch would reassign the relative of all keyblocks to the relative of the deleted keyblock. And it fixes the misalignement of the index values after the keyblock is deleted. Reviewers: campbellbarton Differential Revision: https://developer.blender.org/D1176 --- source/blender/editors/object/object_shapekey.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'source/blender/editors/object/object_shapekey.c') diff --git a/source/blender/editors/object/object_shapekey.c b/source/blender/editors/object/object_shapekey.c index 3fe8c86ef5c..fb9687da6df 100644 --- a/source/blender/editors/object/object_shapekey.c +++ b/source/blender/editors/object/object_shapekey.c @@ -120,9 +120,16 @@ static bool ED_object_shape_key_remove(Main *bmain, Object *ob) kb = BLI_findlink(&key->block, ob->shapenr - 1); if (kb) { - for (rkb = key->block.first; rkb; rkb = rkb->next) - if (rkb->relative == ob->shapenr - 1) + for (rkb = key->block.first; rkb; rkb = rkb->next) { + if (rkb->relative == ob->shapenr - 1) { + /* remap to the 'Basis' */ rkb->relative = 0; + } + else if (rkb->relative >= ob->shapenr) { + /* Fix positional shift of the keys when kb is deleted from the list */ + rkb->relative -= 1; + } + } BLI_remlink(&key->block, kb); key->totkey--; -- cgit v1.2.3