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>2010-04-01 10:26:41 +0400
committerJoshua Leung <aligorith@gmail.com>2010-04-01 10:26:41 +0400
commitc46a955ee0e13d812780f8afe78a6a9c34bb84fa (patch)
tree30d4dbcfc9eb107c71235087151ed1dd56b4306b /source/blender/makesrna/intern/rna_action.c
parentceebd182ed2e3310d6b65fa73574b941156aa1b0 (diff)
Assorted animsys fixes/tweaks:
* Fixed all the dangerous code added in 27907. Using the code there, scripters could corrupt animation files in ways which would render them useless, with channels not appearing in any animation editors, and others not getting evaluated at all. * Partial fix of bug 21818, by disabling destructive replacement of keyframes. Will followup this commit with a more comprehensive commit which gets rid of the rest of the problems, by incorporating some requests from Durian team. * Fixed problems with users being able to see+edit the name of the active Keying Set in the Scene buttons. There is still a bug though with the list widget given how the indices are now interpreted...
Diffstat (limited to 'source/blender/makesrna/intern/rna_action.c')
-rw-r--r--source/blender/makesrna/intern/rna_action.c43
1 files changed, 25 insertions, 18 deletions
diff --git a/source/blender/makesrna/intern/rna_action.c b/source/blender/makesrna/intern/rna_action.c
index c1a74f21fa2..7fdc27e8004 100644
--- a/source/blender/makesrna/intern/rna_action.c
+++ b/source/blender/makesrna/intern/rna_action.c
@@ -34,6 +34,8 @@
#include "MEM_guardedalloc.h"
+#include "BKE_action.h"
+
#include "WM_types.h"
@@ -54,32 +56,34 @@ static void rna_ActionGroup_channels_next(CollectionPropertyIterator *iter)
iter->valid= (internal->link != NULL);
}
-static bActionGroup *rna_Action_groups_add(bAction *act, char *name)
+static bActionGroup *rna_Action_groups_add(bAction *act, char name[])
{
- bActionGroup *agrp= MEM_callocN(sizeof(bActionGroup), "bActionGroup");
- strncpy(agrp->name, name, sizeof(agrp->name));
- BLI_addtail(&act->groups, agrp);
- BLI_uniquename(&act->groups, agrp, "Group", '.', offsetof(bActionGroup, name), sizeof(agrp->name));
- return agrp;
+ return action_groups_add_new(act, name);
}
static void rna_Action_groups_remove(bAction *act, ReportList *reports, bActionGroup *agrp)
{
- FCurve *fcu;
-
- if(!BLI_remlink_safe(&act->groups, agrp)) {
+ FCurve *fcu, *fcn;
+
+ /* try to remove the F-Curve from the action */
+ if (!BLI_remlink_safe(&act->groups, agrp)) {
BKE_reportf(reports, RPT_ERROR, "ActionGroup '%s' not found in action '%s'", agrp->name, act->id.name);
return;
}
- for(fcu= act->curves.first; fcu; fcu= fcu->next) {
- if(fcu->grp==agrp)
- fcu->grp= NULL;
+ /* move every one one of the group's F-Curves out into the Action again */
+ for (fcu= agrp->channels.first; (fcu) && (fcu->grp==agrp); fcu=fcn) {
+ fcn= fcu->next;
+
+ /* remove from group */
+ action_groups_remove_channel(act, fcu);
+
+ /* tack onto the end */
+ BLI_addtail(&act->curves, fcu);
}
-
- /* XXX, can these be added to drivers??? */
-
- MEM_freeN(agrp); /* XXX, invalidate PyObject */
+
+ /* XXX, invalidates PyObject */
+ MEM_freeN(agrp);
}
@@ -243,8 +247,11 @@ static void rna_def_action_group(BlenderRNA *brna)
* defined like a standard ListBase. Adding/removing channels from this list needs
* extreme care, otherwise the F-Curve list running through adjacent groups does
* not match up with the one stored in the Action, resulting in curves which do not
- * show up in animation editors. For that reason, such operations are currently
- * prohibited.
+ * show up in animation editors. In extreme cases, animation may also selectively
+ * fail to play back correctly.
+ *
+ * If such changes are required, these MUST go through the API functions for manipulating
+ * these F-Curve groupings. Also, note that groups only apply in actions ONLY.
*/
prop= RNA_def_property(srna, "channels", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "channels", NULL);