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:
authorJoshua Leung <aligorith@gmail.com>2011-01-03 02:47:03 +0300
committerJoshua Leung <aligorith@gmail.com>2011-01-03 02:47:03 +0300
commitc7aa4f86a8dccec2f03918a6258eb2b1cf7a2cc3 (patch)
treed30067ffabf314fffc38cbd142acc6e1d67c516f /source/blender/makesrna/intern/rna_fcurve.c
parent9b4adf76e3f9d1d4b09e5b010c19f400905616ee (diff)
Bugfix:
Setting the group for F-Curves from the Py-API (i.e. to move F-Curves from one group to another) was failing. After debugging this, this functionality should now work correctly, while still prohibiting the setting of groups on "F-Curves that aren't in actions" (i.e. driver- fcurves)...
Diffstat (limited to 'source/blender/makesrna/intern/rna_fcurve.c')
-rw-r--r--source/blender/makesrna/intern/rna_fcurve.c45
1 files changed, 30 insertions, 15 deletions
diff --git a/source/blender/makesrna/intern/rna_fcurve.c b/source/blender/makesrna/intern/rna_fcurve.c
index af98f6792e4..e71454ef9ec 100644
--- a/source/blender/makesrna/intern/rna_fcurve.c
+++ b/source/blender/makesrna/intern/rna_fcurve.c
@@ -334,19 +334,36 @@ static void rna_FCurve_RnaPath_set(PointerRNA *ptr, const char *value)
static void rna_FCurve_group_set(PointerRNA *ptr, PointerRNA value)
{
- AnimData *adt= BKE_animdata_from_id(ptr->id.data);
- bAction *act= (adt) ? adt->action : NULL;
+ ID *pid = (ID *)ptr->id.data;
+ ID *vid = (ID *)value.id.data;
FCurve *fcu= ptr->data;
-
- /* same ID? */
- if (value.data && (ptr->id.data != value.id.data)) {
+ bAction *act = NULL;
+
+ /* get action */
+ if (ELEM(NULL, pid, vid)) {
+ printf("ERROR: one of the ID's for the groups to assign to is invalid (ptr=%p, val=%p)\n", pid, vid);
+ return;
+ }
+ else if (value.data && (pid != vid)) {
/* id's differ, cant do this, should raise an error */
+ printf("ERROR: ID's differ - ptr=%p vs value=%p \n", pid, vid);
return;
}
+
+ if (GS(pid->name)==ID_AC && GS(vid->name)==ID_AC) {
+ /* the ID given is the action already - usually when F-Curve is obtained from an action's pointer */
+ act = (bAction *)pid;
+ }
+ else {
+ /* the ID given is the owner of the F-Curve (for drivers) */
+ AnimData *adt = BKE_animdata_from_id(ptr->id.data);
+ act = (adt)? adt->action : NULL;
+ }
+
/* already belongs to group? */
if (fcu->grp == value.data) {
/* nothing to do */
- printf("ERROR: F-Curve already belongs to the group\n");
+ printf("ERROR: F-Curve already belongs to this group\n");
return;
}
@@ -357,18 +374,16 @@ static void rna_FCurve_group_set(PointerRNA *ptr, PointerRNA value)
/* can't change the grouping of F-Curve when it doesn't belong to an action */
printf("ERROR: cannot assign F-Curve to group, since F-Curve is not attached to any ID\n");
return;
- }
-
- /* try to remove F-Curve from action (including from any existing groups)
- * - if after this op it is still attached to something, then it is a driver
- * not an animation curve as we thought, and we should exit
- */
- action_groups_remove_channel(act, fcu);
- if (fcu->next) {
- /* F-Curve is not one that exists in the action, since the above op couldn't remove it from the list */
+ }
+ /* make sure F-Curve exists in this action first, otherwise we could still have been tricked */
+ else if (BLI_findindex(&act->curves, fcu) == -1) {
+ printf("ERROR: F-Curve (%p) doesn't exist in action '%s'\n", fcu, act->id.name);
return;
}
+ /* try to remove F-Curve from action (including from any existing groups) */
+ action_groups_remove_channel(act, fcu);
+
/* add the F-Curve back to the action now in the right place */
// TODO: make the api function handle the case where there isn't any group to assign to
if (value.data) {