Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/object/object_shapekey.c
| Context not available. | |||||
| #include "BKE_object.h" | #include "BKE_object.h" | ||||
| #include "BKE_lattice.h" | #include "BKE_lattice.h" | ||||
| #include "BKE_curve.h" | #include "BKE_curve.h" | ||||
| #include "BKE_object.h" | |||||
| #include "BLI_sys_types.h" // for intptr_t support | #include "BLI_sys_types.h" // for intptr_t support | ||||
| Context not available. | |||||
| static bool ED_object_shape_key_remove(Main *bmain, Object *ob) | static bool ED_object_shape_key_remove(Main *bmain, Object *ob) | ||||
| { | { | ||||
| KeyBlock *kb, *rkb; | KeyBlock *kb; | ||||
| Key *key; | Key *key = BKE_key_from_object(ob); | ||||
| key = BKE_key_from_object(ob); | key = BKE_key_from_object(ob); | ||||
| if (key == NULL) | if (key == NULL) | ||||
| Context not available. | |||||
| kb = BLI_findlink(&key->block, ob->shapenr - 1); | kb = BLI_findlink(&key->block, ob->shapenr - 1); | ||||
| if (kb) { | if (kb) { | ||||
| for (rkb = key->block.first; rkb; rkb = rkb->next) { | return BKE_object_remove_shape_key(bmain, ob, kb); | ||||
| 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--; | |||||
| if (key->refkey == kb) { | |||||
| key->refkey = key->block.first; | |||||
| if (key->refkey) { | |||||
| /* apply new basis key on original data */ | |||||
| switch (ob->type) { | |||||
| case OB_MESH: | |||||
| BKE_keyblock_convert_to_mesh(key->refkey, ob->data); | |||||
| break; | |||||
| case OB_CURVE: | |||||
| case OB_SURF: | |||||
| BKE_keyblock_convert_to_curve(key->refkey, ob->data, BKE_curve_nurbs_get(ob->data)); | |||||
| break; | |||||
| case OB_LATTICE: | |||||
| BKE_keyblock_convert_to_lattice(key->refkey, ob->data); | |||||
| break; | |||||
| } | |||||
| } | |||||
| } | |||||
| if (kb->data) MEM_freeN(kb->data); | |||||
| MEM_freeN(kb); | |||||
| if (ob->shapenr > 1) { | return false; | ||||
| ob->shapenr--; | |||||
| } | |||||
| } | |||||
| if (key->totkey == 0) { | |||||
| switch (GS(key->from->name)) { | |||||
| case ID_ME: ((Mesh *)key->from)->key = NULL; break; | |||||
| case ID_CU: ((Curve *)key->from)->key = NULL; break; | |||||
| case ID_LT: ((Lattice *)key->from)->key = NULL; break; | |||||
| } | |||||
| BKE_libblock_free_us(bmain, key); | |||||
| } | |||||
| return true; | |||||
| } | } | ||||
| static bool object_shape_key_mirror(bContext *C, Object *ob, | static bool object_shape_key_mirror(bContext *C, Object *ob, | ||||
| Context not available. | |||||