Depsgraph: Make sure textures used by modifiers are in the graph
authorSergey Sharybin <sergey.vfx@gmail.com>
Wed, 4 Apr 2018 10:55:38 +0000 (12:55 +0200)
committerSergey Sharybin <sergey.vfx@gmail.com>
Wed, 4 Apr 2018 10:56:04 +0000 (12:56 +0200)
source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
source/blender/depsgraph/intern/builder/deg_builder_relations.cc

index 15e3ea3e10f88ab763f1092ab0de2dbfe64f69aa..1613e9f6e5327e11d5fc800debee1f16f0c5e54d 100644 (file)
@@ -122,12 +122,24 @@ struct BuilderWalkUserData {
 
 static void modifier_walk(void *user_data,
                           struct Object * /*object*/,
-                          struct Object **obpoin,
+                          struct ID **idpoin,
                           int /*cb_flag*/)
 {
        BuilderWalkUserData *data = (BuilderWalkUserData *)user_data;
-       if (*obpoin) {
-               data->builder->build_object(NULL, *obpoin);
+       ID *id = *idpoin;
+       if (id == NULL) {
+               return;
+       }
+       switch (GS(id->name)) {
+               case ID_OB:
+                       data->builder->build_object(NULL, (Object *)id);
+                       break;
+               case ID_TE:
+                       data->builder->build_texture((Tex *)id);
+                       break;
+               default:
+                       /* pass */
+                       break;
        }
 }
 
@@ -342,7 +354,7 @@ void DepsgraphNodeBuilder::build_object(Base *base, Object *object)
        if (object->modifiers.first != NULL) {
                BuilderWalkUserData data;
                data.builder = this;
-               modifiers_foreachObjectLink(object, modifier_walk, &data);
+               modifiers_foreachIDLink(object, modifier_walk, &data);
        }
        /* Constraints. */
        if (object->constraints.first != NULL) {
@@ -1053,6 +1065,11 @@ void DepsgraphNodeBuilder::build_texture(Tex *texture)
                        build_image(texture->ima);
                }
        }
+       /* Placeholder so we can add relations and tag ID node for update. */
+       add_operation_node(&texture->id,
+                          DEG_NODE_TYPE_PARAMETERS,
+                          NULL,
+                          DEG_OPCODE_PLACEHOLDER);
 }
 
 void DepsgraphNodeBuilder::build_image(Image *image) {
index 40db9d1b5f116dd1ed26c8ff0e49122ad9b174bd..6f3686f2a10191de2a8b12d340a976fafee6a9ba 100644 (file)
@@ -122,12 +122,24 @@ struct BuilderWalkUserData {
 
 void modifier_walk(void *user_data,
                    struct Object * /*object*/,
-                   struct Object **obpoin,
+                   struct ID **idpoin,
                    int /*cb_flag*/)
 {
        BuilderWalkUserData *data = (BuilderWalkUserData *)user_data;
-       if (*obpoin) {
-               data->builder->build_object(*obpoin);
+       ID *id = *idpoin;
+       if (id == NULL) {
+               return;
+       }
+       switch (GS(id->name)) {
+               case ID_OB:
+                       data->builder->build_object((Object *)id);
+                       break;
+               case ID_TE:
+                       data->builder->build_texture((Tex *)id);
+                       break;
+               default:
+                       /* pass */
+                       break;
        }
 }
 
@@ -459,7 +471,7 @@ void DepsgraphRelationBuilder::build_object(Object *object)
        if (object->modifiers.first != NULL) {
                BuilderWalkUserData data;
                data.builder = this;
-               modifiers_foreachObjectLink(object, modifier_walk, &data);
+               modifiers_foreachIDLink(object, modifier_walk, &data);
        }
        /* Constraints. */
        if (object->constraints.first != NULL) {