Depsgraph: Build relations for objects linked via pchan constraints
authorSergey Sharybin <sergey.vfx@gmail.com>
Tue, 10 Apr 2018 09:56:20 +0000 (11:56 +0200)
committerSergey Sharybin <sergey.vfx@gmail.com>
Tue, 10 Apr 2018 09:57:20 +0000 (11:57 +0200)
This is similar to previous fix for missing ID nodes, just the original
fix missed this part of change because it looked like it is already
happening.

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

index 6f3686f2a10191de2a8b12d340a976fafee6a9ba..4ebc08044792c474149e18b75206e33554e6548c 100644 (file)
@@ -114,51 +114,6 @@ extern "C" {
 
 namespace DEG {
 
-namespace {
-
-struct BuilderWalkUserData {
-       DepsgraphRelationBuilder *builder;
-};
-
-void modifier_walk(void *user_data,
-                   struct Object * /*object*/,
-                   struct ID **idpoin,
-                   int /*cb_flag*/)
-{
-       BuilderWalkUserData *data = (BuilderWalkUserData *)user_data;
-       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;
-       }
-}
-
-void constraint_walk(bConstraint * /*con*/,
-                     ID **idpoin,
-                     bool /*is_reference*/,
-                     void *user_data)
-{
-       BuilderWalkUserData *data = (BuilderWalkUserData *)user_data;
-       if (*idpoin) {
-               ID *id = *idpoin;
-               if (GS(id->name) == ID_OB) {
-                       data->builder->build_object((Object *)id);
-               }
-       }
-}
-
-}  /* namespace */
-
 /* ***************** */
 /* Relations Builder */
 
@@ -1886,4 +1841,43 @@ void DepsgraphRelationBuilder::build_movieclip(MovieClip *clip)
        build_animdata(&clip->id);
 }
 
+/* **** ID traversal callbacks functions **** */
+
+void DepsgraphRelationBuilder::modifier_walk(void *user_data,
+                                             struct Object * /*object*/,
+                                             struct ID **idpoin,
+                                             int /*cb_flag*/)
+{
+       BuilderWalkUserData *data = (BuilderWalkUserData *)user_data;
+       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;
+       }
+}
+
+void DepsgraphRelationBuilder::constraint_walk(bConstraint * /*con*/,
+                                               ID **idpoin,
+                                               bool /*is_reference*/,
+                                               void *user_data)
+{
+       BuilderWalkUserData *data = (BuilderWalkUserData *)user_data;
+       if (*idpoin) {
+               ID *id = *idpoin;
+               if (GS(id->name) == ID_OB) {
+                       data->builder->build_object((Object *)id);
+               }
+       }
+}
+
 }  // namespace DEG
index c4d77d97232876b17b3ea9d72974261685a422b9..d1ca0b6c7dd72df31cd7ec1a122af4344fd3e4c9 100644 (file)
@@ -313,6 +313,20 @@ protected:
                                         const KeyTo& key_to);
 
 private:
+       struct BuilderWalkUserData {
+               DepsgraphRelationBuilder *builder;
+       };
+
+       static void modifier_walk(void *user_data,
+                                 struct Object *object,
+                                 struct ID **idpoin,
+                                 int cb_flag);
+
+       static void constraint_walk(bConstraint *con,
+                                   ID **idpoin,
+                                   bool is_reference,
+                                   void *user_data);
+
        /* State which never changes, same for the whole builder time. */
        Main *bmain_;
        Depsgraph *graph_;
index db8f987fa39bb397651970e76f380beeab7b80bb..2eee167179554dfa02acf521c1c53ff612c3fe05 100644 (file)
@@ -51,6 +51,7 @@ extern "C" {
 
 #include "BKE_action.h"
 #include "BKE_armature.h"
+#include "BKE_constraint.h"
 } /* extern "C" */
 
 #include "DEG_depsgraph.h"
@@ -411,6 +412,11 @@ void DepsgraphRelationBuilder::build_rig(Object *object)
 
                /* constraints */
                if (pchan->constraints.first != NULL) {
+                       /* Build relations for indirectly linked objects. */
+                       BuilderWalkUserData data;
+                       data.builder = this;
+                       BKE_constraints_id_loop(&pchan->constraints, constraint_walk, &data);
+
                        /* constraints stack and constraint dependencies */
                        build_constraints(&object->id, DEG_NODE_TYPE_BONE, pchan->name, &pchan->constraints, &root_map);