Depsgraph: Special relation for instances and metaballs
authorSergey Sharybin <sergey.vfx@gmail.com>
Tue, 12 Feb 2019 14:58:45 +0000 (15:58 +0100)
committerSergey Sharybin <sergey.vfx@gmail.com>
Tue, 12 Feb 2019 15:42:34 +0000 (16:42 +0100)
Ensures that object which is set for instance-vert or instance-face
is evaluated prior to metaball. This is because metaball will request
list of instances during evaluation.

This should fix issue reported T61431 in release build. The assert is
still there and is to be addressed separately.

source/blender/depsgraph/intern/builder/deg_builder_relations.cc

index 879ad5b..1f679cd 100644 (file)
@@ -836,6 +836,7 @@ void DepsgraphRelationBuilder::build_object_data_speaker(Object *object)
 
 void DepsgraphRelationBuilder::build_object_parent(Object *object)
 {
+       Object *parent = object->parent;
        ID *parent_id = &object->parent->id;
        ComponentKey ob_key(&object->id, NodeType::TRANSFORM);
        /* Type-specific links/ */
@@ -911,6 +912,16 @@ void DepsgraphRelationBuilder::build_object_parent(Object *object)
                        break;
                }
        }
+       /* Metaballs are the odd balls here (no pun intended): they will request
+        * instance-list (formerly known as dupli-list) during evaluation. This is
+        * their way of interacting with all instanced surfaces, making a nice
+        * effect when is used form particle system. */
+       if (object->type == OB_MBALL && parent->transflag & OB_DUPLI) {
+               ComponentKey parent_geometry_key(parent_id, NodeType::GEOMETRY);
+               /* NOTE: Metaballs are evaluating geometry only after their transform,
+                * so we onl;y hook up to transform channel here. */
+               add_relation(parent_geometry_key, ob_key, "Parent");
+       }
 }
 
 void DepsgraphRelationBuilder::build_object_pointcache(Object *object)