Merge branch 'master' into blender2.8
[blender.git] / source / blender / depsgraph / intern / builder / deg_builder_relations.cc
similarity index 97%
rename from source/blender/depsgraph/intern/depsgraph_build_relations.cc
rename to source/blender/depsgraph/intern/builder/deg_builder_relations.cc
index 23d3b391f8a5b6f44ea90e4d7e3b1d041dd291cb..6564292e7f4a7e883e7706b32cb12075fb70561b 100644 (file)
  * ***** END GPL LICENSE BLOCK *****
  */
 
-/** \file blender/depsgraph/intern/depsgraph_build_relations.cc
+/** \file blender/depsgraph/intern/builder/deg_builder_relations.cc
  *  \ingroup depsgraph
  *
  * Methods for constructing depsgraph
  */
 
+#include "intern/builder/deg_builder_relations.h"
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -91,15 +93,19 @@ extern "C" {
 #include "RNA_types.h"
 } /* extern "C" */
 
-#include "depsnode.h"
-#include "depsnode_component.h"
-#include "depsnode_operation.h"
-#include "depsgraph_build.h"
-#include "depsgraph_debug.h"
-#include "depsgraph_intern.h"
-#include "depsgraph_types.h"
+#include "intern/builder/deg_builder.h"
+#include "intern/builder/deg_builder_pchanmap.h"
+
+#include "intern/nodes/deg_node.h"
+#include "intern/nodes/deg_node_component.h"
+#include "intern/nodes/deg_node_operation.h"
+
+#include "intern/depsgraph_intern.h"
+#include "intern/depsgraph_types.h"
+
+#include "util/deg_util_foreach.h"
 
-#include "depsgraph_util_pchanmap.h"
+namespace DEG {
 
 /* ***************** */
 /* Relations Builder */
@@ -302,6 +308,19 @@ void DepsgraphRelationBuilder::build_scene(Main *bmain, Scene *scene)
        if (scene->gpd) {
                build_gpencil(&scene->id, scene->gpd);
        }
+
+       for (Depsgraph::OperationNodes::const_iterator it_op = m_graph->operations.begin();
+            it_op != m_graph->operations.end();
+            ++it_op)
+       {
+               OperationDepsNode *node = *it_op;
+               IDDepsNode *id_node = node->owner->owner;
+               ID *id = id_node->id;
+               if (GS(id->name) == ID_OB) {
+                       Object *object = (Object *)id;
+                       object->customdata_mask |= node->customdata_mask;
+               }
+       }
 }
 
 void DepsgraphRelationBuilder::build_group(Main *bmain,
@@ -466,8 +485,12 @@ void DepsgraphRelationBuilder::build_object_parent(Object *ob)
                {
                        ComponentKey parent_key(&ob->parent->id, DEPSNODE_TYPE_GEOMETRY);
                        add_relation(parent_key, ob_key, DEPSREL_TYPE_GEOMETRY_EVAL, "Vertex Parent");
+
                        /* XXX not sure what this is for or how you could be done properly - lukas */
-                       //parent_node->customdata_mask |= CD_MASK_ORIGINDEX;
+                       OperationDepsNode *parent_node = find_operation_node(parent_key);
+                       if (parent_node != NULL) {
+                               parent_node->customdata_mask |= CD_MASK_ORIGINDEX;
+                       }
 
                        ComponentKey transform_key(&ob->parent->id, DEPSNODE_TYPE_TRANSFORM);
                        add_relation(transform_key, ob_key, DEPSREL_TYPE_TRANSFORM, "Vertex Parent TFM");
@@ -618,7 +641,10 @@ void DepsgraphRelationBuilder::build_constraints(Scene *scene, ID *id, eDepsNode
                                        add_relation(target_key, constraint_op_key, DEPSREL_TYPE_GEOMETRY_EVAL, cti->name);
 
                                        if (ct->tar->type == OB_MESH) {
-                                               //node2->customdata_mask |= CD_MASK_MDEFORMVERT;
+                                               OperationDepsNode *node2 = find_operation_node(target_key);
+                                               if (node2 != NULL) {
+                                                       node2->customdata_mask |= CD_MASK_MDEFORMVERT;
+                                               }
                                        }
                                }
                                else if (con->type == CONSTRAINT_TYPE_SHRINKWRAP) {
@@ -759,8 +785,7 @@ void DepsgraphRelationBuilder::build_driver(ID *id, FCurve *fcu)
 
                if (arm_node && bone_name) {
                        /* find objects which use this, and make their eval callbacks depend on this */
-                       DEPSNODE_RELATIONS_ITER_BEGIN(arm_node->outlinks, rel)
-                       {
+                       foreach (DepsRelation *rel, arm_node->outlinks) {
                                IDDepsNode *to_node = (IDDepsNode *)rel->to;
 
                                /* we only care about objects with pose data which use this... */
@@ -774,7 +799,6 @@ void DepsgraphRelationBuilder::build_driver(ID *id, FCurve *fcu)
                                        }
                                }
                        }
-                       DEPSNODE_RELATIONS_ITER_END;
 
                        /* free temp data */
                        MEM_freeN(bone_name);
@@ -1067,7 +1091,10 @@ void DepsgraphRelationBuilder::build_ik_pose(Object *ob,
                        add_relation(target_key, solver_key, DEPSREL_TYPE_GEOMETRY_EVAL, con->name);
 
                        if (data->tar->type == OB_MESH) {
-                               //node2->customdata_mask |= CD_MASK_MDEFORMVERT;
+                               OperationDepsNode *node2 = find_operation_node(target_key);
+                               if (node2 != NULL) {
+                                       node2->customdata_mask |= CD_MASK_MDEFORMVERT;
+                               }
                        }
                }
                else {
@@ -1099,7 +1126,10 @@ void DepsgraphRelationBuilder::build_ik_pose(Object *ob,
                        add_relation(target_key, solver_key, DEPSREL_TYPE_GEOMETRY_EVAL, con->name);
 
                        if (data->poletar->type == OB_MESH) {
-                               //node2->customdata_mask |= CD_MASK_MDEFORMVERT;
+                               OperationDepsNode *node2 = find_operation_node(target_key);
+                               if (node2 != NULL) {
+                                       node2->customdata_mask |= CD_MASK_MDEFORMVERT;
+                               }
                        }
                }
                else {
@@ -1475,13 +1505,18 @@ void DepsgraphRelationBuilder::build_obdata_geom(Main *bmain, Scene *scene, Obje
 
                        if (mti->updateDepsgraph) {
                                DepsNodeHandle handle = create_node_handle(mod_key);
-                               mti->updateDepsgraph(md, bmain, scene, ob, &handle);
+                               mti->updateDepsgraph(
+                                       md,
+                                       bmain,
+                                       scene,
+                                       ob,
+                                       reinterpret_cast< ::DepsNodeHandle* >(&handle));
                        }
 
                        if (BKE_object_modifier_use_time(ob, md)) {
                                TimeSourceKey time_src_key;
                                add_relation(time_src_key, mod_key, DEPSREL_TYPE_TIME, "Time Source");
-                               
+
                                /* Hacky fix for T45633 (Animated modifiers aren't updated)
                                 *
                                 * This check works because BKE_object_modifier_use_time() tests
@@ -1791,3 +1826,4 @@ bool DepsgraphRelationBuilder::needs_animdata_node(ID *id)
        return false;
 }
 
+}  // namespace DEG