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:
authorLukas Toenne <lukas.toenne@googlemail.com>2011-07-17 22:04:28 +0400
committerLukas Toenne <lukas.toenne@googlemail.com>2011-07-17 22:04:28 +0400
commit756ef16e21c18b863bc7c9c86f5f34e15fa30f41 (patch)
tree5c70c709b25e4580c1af6a916f55ae9ca35943d0 /source/blender/editors/space_node/node_edit.c
parentb29b0acdceb98b0f67b214223c7624ca5d1e7697 (diff)
Little modification of the duplicate operator on artist request: The default behavior (shift+dkey) is now to copy nodes and internal links, but not the input links from unselected nodes. This feature is available with the alternate duplicate operator (alt+dkey).
Diffstat (limited to 'source/blender/editors/space_node/node_edit.c')
-rw-r--r--source/blender/editors/space_node/node_edit.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c
index e760c9021c2..36e8bc35e73 100644
--- a/source/blender/editors/space_node/node_edit.c
+++ b/source/blender/editors/space_node/node_edit.c
@@ -2000,12 +2000,13 @@ bNode *node_add_node(SpaceNode *snode, Scene *scene, int type, float locx, float
/* ****************** Duplicate *********************** */
-static int node_duplicate_exec(bContext *C, wmOperator *UNUSED(op))
+static int node_duplicate_exec(bContext *C, wmOperator *op)
{
SpaceNode *snode= CTX_wm_space_node(C);
bNodeTree *ntree= snode->edittree;
bNode *node, *newnode, *lastnode;
bNodeLink *link, *newlink, *lastlink;
+ int keep_inputs = RNA_boolean_get(op->ptr, "keep_inputs");
ED_preview_kill_jobs(C);
@@ -2033,10 +2034,11 @@ static int node_duplicate_exec(bContext *C, wmOperator *UNUSED(op))
*/
lastlink = ntree->links.last;
for (link=ntree->links.first; link; link=link->next) {
- /* this creates new links between copied nodes,
- * as well as input links from unselected (when fromnode==NULL) !
+ /* This creates new links between copied nodes.
+ * If keep_inputs is set, also copies input links from unselected (when fromnode==NULL)!
*/
- if (link->tonode && (link->tonode->flag & NODE_SELECT)) {
+ if (link->tonode && (link->tonode->flag & NODE_SELECT)
+ && (keep_inputs || link->fromnode && (link->fromnode->flag & NODE_SELECT))) {
newlink = MEM_callocN(sizeof(bNodeLink), "bNodeLink");
newlink->flag = link->flag;
newlink->tonode = link->tonode->new_node;
@@ -2096,6 +2098,8 @@ void NODE_OT_duplicate(wmOperatorType *ot)
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+
+ RNA_def_boolean(ot->srna, "keep_inputs", 0, "Keep Inputs", "Keep the input links to duplicated nodes");
}
/* *************************** add link op ******************** */