diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2017-07-21 15:20:30 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2017-07-21 15:20:30 +0300 |
commit | 9edb7e49d7e5e69385f3a0434c568c79fad88cd8 (patch) | |
tree | 86920a3a0ca2b7ad11ce5a9c2d79786d793a7bf0 /source/blender | |
parent | 4e28d88ece20fabd773a0a2e7b3423227358b7c7 (diff) |
Depsgraph: Fix missing material update when changing links in node tree
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/depsgraph/DEG_depsgraph.h | 5 | ||||
-rw-r--r-- | source/blender/depsgraph/intern/depsgraph_tag.cc | 18 | ||||
-rw-r--r-- | source/blender/editors/render/render_update.c | 17 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_nodetree.c | 4 |
4 files changed, 42 insertions, 2 deletions
diff --git a/source/blender/depsgraph/DEG_depsgraph.h b/source/blender/depsgraph/DEG_depsgraph.h index 76681e6611c..1941dc98d53 100644 --- a/source/blender/depsgraph/DEG_depsgraph.h +++ b/source/blender/depsgraph/DEG_depsgraph.h @@ -157,6 +157,11 @@ enum { /* Update copy on write component without flushing down the road. */ DEG_TAG_COPY_ON_WRITE = (1 << 8), + + /* Tag shading components for update. + * Only parameters of material changed). + */ + DEG_TAG_SHADING_UPDATE = (1 << 9), }; void DEG_id_tag_update(struct ID *id, int flag); void DEG_id_tag_update_ex(struct Main *bmain, diff --git a/source/blender/depsgraph/intern/depsgraph_tag.cc b/source/blender/depsgraph/intern/depsgraph_tag.cc index 91b049beabb..a4918207372 100644 --- a/source/blender/depsgraph/intern/depsgraph_tag.cc +++ b/source/blender/depsgraph/intern/depsgraph_tag.cc @@ -234,6 +234,21 @@ void id_tag_update_particle(Depsgraph *graph, IDDepsNode *id_node, int tag) particle_comp->tag_update(graph); } +void id_tag_update_shading(Depsgraph *graph, IDDepsNode *id_node, int tag) +{ + ComponentDepsNode *shading_comp = + id_node->find_component(DEG_NODE_TYPE_SHADING); + if (shading_comp == NULL) { +#ifdef STRICT_COMPONENT_TAGGING + DEG_ERROR_PRINTF("ERROR: Unable to find shading component for %s\n", + id_node->id_orig->name); + BLI_assert(!"This is not supposed to happen!"); +#endif + return; + } + shading_comp->tag_update(graph); +} + #ifdef WITH_COPY_ON_WRITE /* Tag corresponding to DEG_TAG_COPY_ON_WRITE. */ void id_tag_update_copy_on_write(Depsgraph *graph, IDDepsNode *id_node) @@ -272,6 +287,9 @@ void deg_graph_id_tag_update(Main *bmain, Depsgraph *graph, ID *id, int flag) if (flag & PSYS_RECALC) { id_tag_update_particle(graph, id_node, flag); } + if (flag & DEG_TAG_SHADING_UPDATE) { + id_tag_update_shading(graph, id_node, flag); + } #ifdef WITH_COPY_ON_WRITE if (flag & DEG_TAG_COPY_ON_WRITE) { id_tag_update_copy_on_write(graph, id_node); diff --git a/source/blender/editors/render/render_update.c b/source/blender/editors/render/render_update.c index 07b445fa6eb..3a9d11be3fd 100644 --- a/source/blender/editors/render/render_update.c +++ b/source/blender/editors/render/render_update.c @@ -298,6 +298,13 @@ static void material_changed(Main *bmain, Material *ma) /* icons */ BKE_icon_changed(BKE_icon_id_ensure(&ma->id)); + /* glsl */ + if (ma->id.tag & LIB_TAG_ID_RECALC) { + if (!BLI_listbase_is_empty(&ma->gpumaterial)) { + GPU_material_free(&ma->gpumaterial); + } + } + /* find node materials using this */ for (parent = bmain->mat.first; parent; parent = parent->id.next) { if (parent->use_nodes && parent->nodetree && nodes_use_material(parent->nodetree, ma)) { @@ -474,6 +481,16 @@ static void world_changed(Main *UNUSED(bmain), World *wo) /* XXX temporary flag waiting for depsgraph proper tagging */ wo->update_flag = 1; + + /* glsl */ + if (wo->id.tag & LIB_TAG_ID_RECALC) { + if (!BLI_listbase_is_empty(&defmaterial.gpumaterial)) { + GPU_material_free(&defmaterial.gpumaterial); + } + if (!BLI_listbase_is_empty(&wo->gpumaterial)) { + GPU_material_free(&wo->gpumaterial); + } + } } static void image_changed(Main *bmain, Image *ima) diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 3c5989c79cd..0b92749e7ad 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -2284,11 +2284,11 @@ static void rna_NodeSocket_value_update(Main *bmain, Scene *scene, PointerRNA *p FOREACH_NODETREE(bmain, tntree, id) { switch (GS(id->name)) { case ID_WO: - DEG_id_tag_update_ex(bmain, id, 0); + DEG_id_tag_update_ex(bmain, id, DEG_TAG_SHADING_UPDATE); WM_main_add_notifier(NC_MATERIAL | ND_SHADING, NULL); break; case ID_MA: - DEG_id_tag_update_ex(bmain, id, 0); + DEG_id_tag_update_ex(bmain, id, DEG_TAG_SHADING_UPDATE); WM_main_add_notifier(NC_MATERIAL | ND_SHADING, id); break; } |