Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/animation/drivers.c')
-rw-r--r--source/blender/editors/animation/drivers.c63
1 files changed, 33 insertions, 30 deletions
diff --git a/source/blender/editors/animation/drivers.c b/source/blender/editors/animation/drivers.c
index 5024ca39970..3fc228e1c15 100644
--- a/source/blender/editors/animation/drivers.c
+++ b/source/blender/editors/animation/drivers.c
@@ -197,27 +197,42 @@ short ANIM_remove_driver (struct ID *id, const char rna_path[], int array_index,
{
AnimData *adt;
FCurve *fcu;
+ int success= 0;
/* get F-Curve
* Note: here is one of the places where we don't want new F-Curve + Driver added!
* so 'add' var must be 0
*/
/* we don't check the validity of the path here yet, but it should be ok... */
- fcu= verify_driver_fcurve(id, rna_path, array_index, 0);
adt= BKE_animdata_from_id(id);
- /* only continue if we have an driver to remove */
- if (adt && fcu) {
- /* remove F-Curve from driver stack, then free it */
- BLI_remlink(&adt->drivers, fcu);
- free_fcurve(fcu);
-
- /* done successfully */
- return 1;
+ if(adt) {
+ if(array_index == -1) {
+ FCurve *fcu_iter= adt->drivers.first;
+ while((fcu= iter_step_fcurve(fcu_iter, rna_path))) {
+ /* store the next fcurve for looping */
+ fcu_iter= fcu->next;
+
+ /* remove F-Curve from driver stack, then free it */
+ BLI_remlink(&adt->drivers, fcu);
+ free_fcurve(fcu);
+
+ /* done successfully */
+ success |= 1;
+ }
+ }
+ else {
+ fcu= verify_driver_fcurve(id, rna_path, array_index, 0);
+ if(fcu) {
+ BLI_remlink(&adt->drivers, fcu);
+ free_fcurve(fcu);
+
+ success = 1;
+ }
+ }
}
-
- /* failed */
- return 0;
+
+ return success;
}
/* ************************************************** */
@@ -408,33 +423,21 @@ static int remove_driver_button_exec (bContext *C, wmOperator *op)
PropertyRNA *prop= NULL;
char *path;
short success= 0;
- int a, index, length, all= RNA_boolean_get(op->ptr, "all");
+ int index, all= RNA_boolean_get(op->ptr, "all");
/* try to find driver using property retrieved from UI */
memset(&ptr, 0, sizeof(PointerRNA));
uiAnimContextProperty(C, &ptr, &prop, &index);
+
+ if (all)
+ index= -1;
if (ptr.data && prop) {
path= RNA_path_from_ID_to_property(&ptr, prop);
-
- if (path) {
- if (all) {
- length= RNA_property_array_length(&ptr, prop);
-
- if(length) index= 0;
- else length= 1;
- }
- else
- length= 1;
-
- for (a=0; a<length; a++)
- success+= ANIM_remove_driver(ptr.id.data, path, index+a, 0);
-
- MEM_freeN(path);
- }
+ success= ANIM_remove_driver(ptr.id.data, path, index, 0);
+ MEM_freeN(path);
}
-
if (success) {
/* send updates */
DAG_ids_flush_update(0);