forked from bartvdbraak/blender
Fixes for context updates of the node editor:
* If the node tree can be updated from context (tree has get_from_context callback defined), reset the pointers first to clear the editor path if no tree can be found. * Stupid mistake: snode->from != snode->from is always false. * Shader nodes context update: set the 'from' pointer to the active object, even if it doesn't have a material or node tree.
This commit is contained in:
parent
4857d62ac6
commit
0f3515d4e2
@ -530,11 +530,17 @@ void snode_set_context(const bContext *C)
|
||||
}
|
||||
|
||||
if (!(snode->flag & SNODE_PIN) || ntree == NULL) {
|
||||
if (treetype->get_from_context)
|
||||
if (treetype->get_from_context) {
|
||||
/* reset and update from context */
|
||||
ntree = NULL;
|
||||
id = NULL;
|
||||
from = NULL;
|
||||
|
||||
treetype->get_from_context(C, treetype, &ntree, &id, &from);
|
||||
}
|
||||
}
|
||||
|
||||
if (snode->nodetree != ntree || snode->id != id || snode->from != snode->from) {
|
||||
if (snode->nodetree != ntree || snode->id != id || snode->from != from) {
|
||||
ED_node_tree_start(snode, ntree, id, from);
|
||||
}
|
||||
}
|
||||
|
@ -80,15 +80,14 @@ static void shader_get_from_context(const bContext *C, bNodeTreeType *UNUSED(tre
|
||||
|
||||
if (snode->shaderfrom == SNODE_SHADER_OBJECT) {
|
||||
if (ob) {
|
||||
*r_from = &ob->id;
|
||||
if (ob->type == OB_LAMP) {
|
||||
*r_from = &ob->id;
|
||||
*r_id = ob->data;
|
||||
*r_ntree = ((Lamp *)ob->data)->nodetree;
|
||||
}
|
||||
else {
|
||||
Material *ma = give_current_material(ob, ob->actcol);
|
||||
if (ma) {
|
||||
*r_from = &ob->id;
|
||||
*r_id = &ma->id;
|
||||
*r_ntree = ma->nodetree;
|
||||
}
|
||||
|
@ -83,11 +83,13 @@ static void texture_get_from_context(const bContext *C, bNodeTreeType *UNUSED(tr
|
||||
}
|
||||
}
|
||||
else if (snode->texfrom == SNODE_TEX_WORLD) {
|
||||
tx = give_current_world_texture(scene->world);
|
||||
if (tx) {
|
||||
if (scene->world) {
|
||||
*r_from = (ID *)scene->world;
|
||||
*r_id = &tx->id;
|
||||
*r_ntree = tx->nodetree;
|
||||
tx = give_current_world_texture(scene->world);
|
||||
if (tx) {
|
||||
*r_id = &tx->id;
|
||||
*r_ntree = tx->nodetree;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
Loading…
Reference in New Issue
Block a user