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
This commit is contained in:
Gaia Clary 2015-03-12 14:21:41 +01:00
parent 60df4d10ff
commit 6aaedc7cfd
1 changed files with 9 additions and 2 deletions

View File

@ -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--;