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-12-29 15:18:59 +0300
committerJoshua Leung <aligorith@gmail.com>2010-12-29 15:18:59 +0300
commit32b23b2b822d5229d05ef3d14144f9e16240d2ad (patch)
treee674212a5f04c1d79d613dbe11d6a2258eb300b3
parent92172b779e28fdd9321dd298bd14a3c93371bcbe (diff)
Bugfix [#24163] (PART 2) Unable to animate INSIDE a group node in the
compositor Now ungrouping grouped-nodes copies the animation back to the main nodetree. This means that it is now possible to successfully roundtrip group/un-group nodes and their animation data. --- This should also be done for the Separate Armature operator... hmm...
-rw-r--r--source/blender/blenkernel/intern/node.c48
1 files changed, 47 insertions, 1 deletions
diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c
index f85def22566..db11b42ee1e 100644
--- a/source/blender/blenkernel/intern/node.c
+++ b/source/blender/blenkernel/intern/node.c
@@ -805,6 +805,7 @@ int nodeGroupUnGroup(bNodeTree *ntree, bNode *gnode)
bNodeLink *link, *linkn;
bNode *node, *nextn;
bNodeTree *ngroup, *wgroup;
+ ListBase anim_basepaths = {NULL, NULL};
int index;
ngroup= (bNodeTree *)gnode->id;
@@ -813,16 +814,38 @@ int nodeGroupUnGroup(bNodeTree *ntree, bNode *gnode)
/* clear new pointers, set in copytree */
for(node= ntree->nodes.first; node; node= node->next)
node->new_node= NULL;
-
+
+ /* wgroup is a temporary copy of the NodeTree we're merging in
+ * - all of wgroup's nodes are transferred across to their new home
+ * - ngroup (i.e. the source NodeTree) is left unscathed
+ */
wgroup= ntreeCopyTree(ngroup, 0);
/* add the nodes into the ntree */
for(node= wgroup->nodes.first; node; node= nextn) {
nextn= node->next;
+
+ /* keep track of this node's RNA "base" path (the part of the pat identifying the node)
+ * if the old nodetree has animation data which potentially covers this node
+ */
+ if (wgroup->adt) {
+ PointerRNA ptr;
+ char *path;
+
+ RNA_pointer_create(&wgroup->id, &RNA_Node, node, &ptr);
+ path = RNA_path_from_ID_to_struct(&ptr);
+
+ if (path)
+ BLI_addtail(&anim_basepaths, BLI_genericNodeN(path));
+ }
+
+ /* migrate node */
BLI_remlink(&wgroup->nodes, node);
BLI_addtail(&ntree->nodes, node);
+
node->locx+= gnode->locx;
node->locy+= gnode->locy;
+
node->flag |= NODE_SELECT;
}
/* and the internal links */
@@ -831,6 +854,29 @@ int nodeGroupUnGroup(bNodeTree *ntree, bNode *gnode)
BLI_remlink(&wgroup->links, link);
BLI_addtail(&ntree->links, link);
}
+
+ /* and copy across the animation */
+ if (wgroup->adt) {
+ LinkData *ld, *ldn=NULL;
+ bAction *waction;
+
+ /* firstly, wgroup needs to temporary dummy action that can be destroyed, as it shares copies */
+ waction = wgroup->adt->action = copy_action(wgroup->adt->action);
+
+ /* now perform the moving */
+ BKE_animdata_separate_by_basepath(&wgroup->id, &ntree->id, &anim_basepaths);
+
+ /* paths + their wrappers need to be freed */
+ for (ld = anim_basepaths.first; ld; ld = ld->next) {
+ ldn = ld->next;
+
+ MEM_freeN(ld->data);
+ BLI_freelinkN(&anim_basepaths, ld);
+ }
+
+ /* free temp action too */
+ free_libblock(&G.main->action, waction);
+ }
/* restore links to and from the gnode */
for(link= ntree->links.first; link; link= link->next) {