Fix T86314: materials not updated correctly after collada import (again)

While rB6b18678e34bf did the correct updates, it did it a bit early (not
covering all possible node tree changes).

Now do the ntreeUpdateTree() at the very end of the material import
instead.

Thx @scurest investigating.

Maniphest Tasks: T86314

Differential Revision: https://developer.blender.org/D11159
This commit is contained in:
Philipp Oeser 2021-05-04 15:19:33 +02:00
parent 89858e1c5d
commit a1069b6c66
Notes: blender-bot 2023-02-14 08:06:35 +01:00
Referenced by issue #88062, Principled bsdf Surface on dae models not automatically apply
Referenced by issue #86314, materials not updated correctly after collada import
3 changed files with 9 additions and 4 deletions

View File

@ -817,6 +817,8 @@ void DocumentImporter::write_profile_COMMON(COLLADAFW::EffectCommon *ef, Materia
matNode.set_ambient(ef->getAmbient());
matNode.set_specular(ef->getSpecular());
matNode.set_reflective(ef->getReflective());
matNode.update_material_nodetree();
}
/**

View File

@ -25,8 +25,6 @@ MaterialNode::MaterialNode(bContext *C, Material *ma, KeyImageMap &key_image_map
shader_node = add_node(SH_NODE_BSDF_PRINCIPLED, 0, 300, "");
output_node = add_node(SH_NODE_OUTPUT_MATERIAL, 300, 300, "");
add_link(shader_node, 0, output_node, 0);
ntreeUpdateTree(CTX_data_main(C), ntree);
}
}
@ -61,8 +59,6 @@ MaterialNode::MaterialNode(bContext *C,
shader_node = add_node(SH_NODE_BSDF_PRINCIPLED, 0, 300, "");
output_node = add_node(SH_NODE_OUTPUT_MATERIAL, 300, 300, "");
add_link(shader_node, 0, output_node, 0);
ntreeUpdateTree(CTX_data_main(C), ntree);
#endif
}
@ -109,6 +105,11 @@ bNodeTree *MaterialNode::prepare_material_nodetree()
return ntree;
}
void MaterialNode::update_material_nodetree()
{
ntreeUpdateTree(CTX_data_main(mContext), ntree);
}
bNode *MaterialNode::add_node(int node_type, int locx, int locy, std::string label)
{
bNode *node = nodeAddStaticNode(mContext, ntree, node_type);

View File

@ -68,4 +68,6 @@ class MaterialNode {
void set_alpha(COLLADAFW::EffectCommon::OpaqueMode mode,
COLLADAFW::ColorOrTexture &cot,
COLLADAFW::FloatOrParam &val);
void update_material_nodetree();
};