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:
authorCampbell Barton <ideasman42@gmail.com>2009-11-16 14:11:16 +0300
committerCampbell Barton <ideasman42@gmail.com>2009-11-16 14:11:16 +0300
commit567ee32f14304a462e59bde2de92b10861ad7c86 (patch)
tree29e95d2fe7945d976fc0d01722f400134b4e775a /source/blender/blenkernel
parentd2ca3e55820258361aa1f4cd9db1c1084b1e3f23 (diff)
- fcurve modifiers.new()/remove()/active
- renamed .add() to .new() for rna collection functions since they dont add an existing item. - remove 'name' as an argument from the new driver target function, better to keep the api minimal and let scripters use the data api for editing values after. - added some api functions to keep rna api from becoming a mess.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/BKE_constraint.h7
-rw-r--r--source/blender/blenkernel/BKE_fcurve.h3
-rw-r--r--source/blender/blenkernel/intern/constraint.c46
-rw-r--r--source/blender/blenkernel/intern/fmodifier.c20
4 files changed, 71 insertions, 5 deletions
diff --git a/source/blender/blenkernel/BKE_constraint.h b/source/blender/blenkernel/BKE_constraint.h
index 7e0bb9fa08e..7bb17d9a0e0 100644
--- a/source/blender/blenkernel/BKE_constraint.h
+++ b/source/blender/blenkernel/BKE_constraint.h
@@ -105,6 +105,13 @@ bConstraintTypeInfo *get_constraint_typeinfo(int type);
struct bConstraint *add_ob_constraint(struct Object *ob, const char *name, short type);
struct bConstraint *add_pose_constraint(struct Object *ob, struct bPoseChannel *pchan, const char *name, short type);
+struct bConstraint *find_active_constraint(ListBase *constraints);
+void set_active_constraint(ListBase *constraints, struct bConstraint *con);
+
+
+int remove_constraint(ListBase *constraints, struct bConstraint *con);
+int remove_constraint_index(ListBase *constraints, int index);
+
/* ---------------------------------------------------------------------------- */
/* Useful macros for testing various common flag combinations */
diff --git a/source/blender/blenkernel/BKE_fcurve.h b/source/blender/blenkernel/BKE_fcurve.h
index 24d5be524d7..5888c6d7530 100644
--- a/source/blender/blenkernel/BKE_fcurve.h
+++ b/source/blender/blenkernel/BKE_fcurve.h
@@ -130,7 +130,8 @@ FModifierTypeInfo *get_fmodifier_typeinfo(int type);
struct FModifier *add_fmodifier(ListBase *modifiers, int type);
void copy_fmodifiers(ListBase *dst, ListBase *src);
-void remove_fmodifier(ListBase *modifiers, struct FModifier *fcm);
+int remove_fmodifier(ListBase *modifiers, struct FModifier *fcm);
+int remove_fmodifier_index(ListBase *modifiers, int index);
void free_fmodifiers(ListBase *modifiers);
struct FModifier *find_active_fmodifier(ListBase *modifiers);
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c
index 65f1719e0ca..5015420000d 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -3690,6 +3690,52 @@ bConstraint *add_ob_constraint(Object *ob, const char *name, short type)
return add_new_constraint(ob, NULL, name, type);
}
+struct bConstraint *find_active_constraint(ListBase *constraints)
+{
+ bConstraint *con;
+ if (constraints==NULL)
+ return NULL;
+
+ for(con= constraints->first; con; con= con->next) {
+ if(con->flag & CONSTRAINT_ACTIVE)
+ return con;
+ }
+
+ return NULL;
+}
+
+void set_active_constraint(ListBase *constraints, struct bConstraint *con)
+{
+ bConstraint *con_i;
+ for(con_i= constraints->first; con_i; con_i= con_i->next) {
+ if(con_i==con) con->flag |= CONSTRAINT_ACTIVE;
+ else con->flag &= ~CONSTRAINT_ACTIVE;
+ }
+}
+
+int remove_constraint(ListBase *constraints, struct bConstraint *con)
+{
+ if(con) {
+ free_constraint_data(con);
+ BLI_freelinkN(constraints, con);
+ return 1;
+ }
+ else {
+ return 0;
+ }
+}
+
+int remove_constraint_index(ListBase *constraints, int index)
+{
+ bConstraint *con= BLI_findlink(constraints, index);
+ if(con) {
+ return remove_constraint(constraints, con);
+ }
+ else {
+ return 0;
+ }
+}
+
/* ************************* General Constraints API ************************** */
/* The functions here are called by various parts of Blender. Very few (should be none if possible)
* constraint-specific code should occur here.
diff --git a/source/blender/blenkernel/intern/fmodifier.c b/source/blender/blenkernel/intern/fmodifier.c
index f70de4983e3..e9e12e29606 100644
--- a/source/blender/blenkernel/intern/fmodifier.c
+++ b/source/blender/blenkernel/intern/fmodifier.c
@@ -992,13 +992,13 @@ void copy_fmodifiers (ListBase *dst, ListBase *src)
}
/* Remove and free the given F-Modifier from the given stack */
-void remove_fmodifier (ListBase *modifiers, FModifier *fcm)
+int remove_fmodifier (ListBase *modifiers, FModifier *fcm)
{
FModifierTypeInfo *fmi= fmodifier_get_typeinfo(fcm);
/* sanity check */
if (fcm == NULL)
- return;
+ return 0;
/* free modifier's special data (stored inside fcm->data) */
if (fcm->data) {
@@ -1010,12 +1010,24 @@ void remove_fmodifier (ListBase *modifiers, FModifier *fcm)
}
/* remove modifier from stack */
- if (modifiers)
+ if (modifiers) {
BLI_freelinkN(modifiers, fcm);
- else {
+ return 1;
+ } else {
// XXX this case can probably be removed some day, as it shouldn't happen...
printf("remove_fmodifier() - no modifier stack given \n");
MEM_freeN(fcm);
+ return 0;
+ }
+}
+int remove_fmodifier_index (ListBase *modifiers, int index)
+{
+ FModifier *fcm= BLI_findlink(modifiers, index);
+ if(fcm) {
+ return remove_fmodifier(modifiers, fcm);
+ }
+ else {
+ return 0;
}
}