Fix T40585, group textures cannot be selected for painting.

Issue here is that if there's a texture in the tree, chances are it has
already been set as active texture so groups are never traversed.

Now changed logic so that if a group node is active, its own active
texture takes priority over the parent group active texture.
This commit is contained in:
Antony Riakiotakis 2014-06-18 20:40:27 +03:00
parent 72b607ab74
commit 34b8d22275

@ -195,24 +195,48 @@ static void data_from_gpu_stack_list(ListBase *sockets, bNodeStack **ns, GPUNode
bNode *nodeGetActiveTexture(bNodeTree *ntree) bNode *nodeGetActiveTexture(bNodeTree *ntree)
{ {
/* this is the node we texture paint and draw in textured draw */ /* this is the node we texture paint and draw in textured draw */
bNode *node, *tnode, *inactivenode = NULL; bNode *node, *tnode, *inactivenode = NULL, *activetexnode = NULL, *activegroup = NULL;
bool hasgroup = false;
if (!ntree) if (!ntree)
return NULL; return NULL;
for (node = ntree->nodes.first; node; node = node->next) { for (node = ntree->nodes.first; node; node = node->next) {
if (node->flag & NODE_ACTIVE_TEXTURE) if (node->flag & NODE_ACTIVE_TEXTURE) {
return node; activetexnode = node;
/* if active we can return immediately */
if (node->flag & NODE_ACTIVE)
return node;
}
else if (!inactivenode && node->typeinfo->nclass == NODE_CLASS_TEXTURE) else if (!inactivenode && node->typeinfo->nclass == NODE_CLASS_TEXTURE)
inactivenode = node; inactivenode = node;
else if (node->type == NODE_GROUP) {
if (node->flag & NODE_ACTIVE)
activegroup = node;
else
hasgroup = true;
}
} }
/* first, check active group for textures */
if (activegroup) {
tnode = nodeGetActiveTexture((bNodeTree *)activegroup->id);
/* active node takes priority, so ignore any other possible nodes here */
if (tnode)
return tnode;
}
if (activetexnode)
return activetexnode;
/* node active texture node in this tree, look inside groups */ if (hasgroup) {
for (node = ntree->nodes.first; node; node = node->next) { /* node active texture node in this tree, look inside groups */
if (node->type == NODE_GROUP) { for (node = ntree->nodes.first; node; node = node->next) {
tnode = nodeGetActiveTexture((bNodeTree *)node->id); if (node->type == NODE_GROUP) {
if (tnode && ((tnode->flag & NODE_ACTIVE_TEXTURE) || !inactivenode)) tnode = nodeGetActiveTexture((bNodeTree *)node->id);
return tnode; if (tnode && ((tnode->flag & NODE_ACTIVE_TEXTURE) || !inactivenode))
return tnode;
}
} }
} }