From e0d40471364aafca967b6ebd5266ae7d7f78dee4 Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Wed, 23 Jul 2014 11:33:29 -0300 Subject: Bake-API: Test for cyclic node connection If the active image node contributes to the final material shader (meaning it's either directly or indirectly connected to an Output Node) the user will receive an alert about circular dependency. Similar to what we do for Blender internal the baking will still happen, but the user will receive the alert which should prevent the image saving to happen if the result was not intentional. Core function to check for node output written by Lukas Toenne. Reviewers: lukastoenne, campbellbarton Differential Revision: https://developer.blender.org/D673 --- source/blender/editors/uvedit/uvedit_ops.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'source/blender/editors/uvedit/uvedit_ops.c') diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index ed88c72edc4..0d8b5a524b6 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -137,21 +137,24 @@ static bool is_image_texture_node(bNode *node) } bool ED_object_get_active_image(Object *ob, int mat_nr, - Image **r_ima, ImageUser **r_iuser, bNode **r_node) + Image **r_ima, ImageUser **r_iuser, bNode **r_node, bNodeTree **r_ntree) { Material *ma = give_current_material(ob, mat_nr); - bNode *node = (ma && ma->use_nodes) ? nodeGetActiveTexture(ma->nodetree) : NULL; + bNodeTree *ntree = (ma && ma->use_nodes) ? ma->nodetree : NULL; + bNode *node = (ntree) ? nodeGetActiveTexture(ntree) : NULL; if (node && is_image_texture_node(node)) { if (r_ima) *r_ima = (Image *)node->id; if (r_iuser) *r_iuser = NULL; if (r_node) *r_node = node; + if (r_ntree) *r_ntree = ntree; return true; } if (r_ima) *r_ima = NULL; if (r_iuser) *r_iuser = NULL; if (r_node) *r_node = node; + if (r_ntree) *r_ntree = ntree; return false; } -- cgit v1.2.3