diff options
author | Lukas Toenne <lukas.toenne@googlemail.com> | 2013-02-06 17:59:54 +0400 |
---|---|---|
committer | Lukas Toenne <lukas.toenne@googlemail.com> | 2013-02-06 17:59:54 +0400 |
commit | 8b1fb0fd2aac4a393cca8bb4e9fa21dc5f53cced (patch) | |
tree | c133d26dcec10172aa53537f48e087b37c3acab4 /source/blender | |
parent | 12ef1b63e255b7387f7432d3266c33adcca5258c (diff) |
Fix #34115, Group Node corrupted by frames.
The group node operators offset nodes when moving them between node trees, but this should only be done for "free", un-parented nodes not attached to a frame, otherwise the node loc is relative to the parent node.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/space_node/node_group.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/source/blender/editors/space_node/node_group.c b/source/blender/editors/space_node/node_group.c index 7572ca04a33..943f12c4c54 100644 --- a/source/blender/editors/space_node/node_group.c +++ b/source/blender/editors/space_node/node_group.c @@ -457,8 +457,10 @@ static int node_group_ungroup(bNodeTree *ntree, bNode *gnode) /* ensure unique node name in the nodee tree */ nodeUniqueName(ntree, node); - node->locx += gnode->locx; - node->locy += gnode->locy; + if (!node->parent) { + node->locx += gnode->locx; + node->locy += gnode->locy; + } node->flag |= NODE_SELECT; } @@ -673,8 +675,10 @@ static int node_group_separate_selected(bNodeTree *ntree, bNode *gnode, int make /* ensure unique node name in the node tree */ nodeUniqueName(ntree, newnode); - newnode->locx += gnode->locx; - newnode->locy += gnode->locy; + if (!newnode->parent) { + newnode->locx += gnode->locx; + newnode->locy += gnode->locy; + } } else { /* ensure valid parent pointers, detach if child stays inside the group */ @@ -865,12 +869,14 @@ static int node_group_make_test(bNodeTree *ntree, bNode *gnode) static void node_get_selected_minmax(bNodeTree *ntree, bNode *gnode, float *min, float *max) { bNode *node; + float loc[2]; INIT_MINMAX2(min, max); for (node = ntree->nodes.first; node; node = node->next) { if (node == gnode) continue; if (node->flag & NODE_SELECT) { - minmax_v2v2_v2(min, max, &node->locx); + nodeToView(node, 0.0f, 0.0f, &loc[0], &loc[1]); + minmax_v2v2_v2(min, max, loc); } } } @@ -921,8 +927,10 @@ static int node_group_make_insert_selected(bNodeTree *ntree, bNode *gnode) /* ensure unique node name in the ngroup */ nodeUniqueName(ngroup, node); - node->locx -= 0.5f * (min[0] + max[0]); - node->locy -= 0.5f * (min[1] + max[1]); + if (!node->parent) { + node->locx -= 0.5f * (min[0] + max[0]); + node->locy -= 0.5f * (min[1] + max[1]); + } } else { /* if the parent is to be inserted but not the child, detach properly */ |