Depsgraph: minor renaming and refactor of API for adding evaluation flags.
authorAlexander Gavrilov <angavrilov@gmail.com>
Wed, 24 Oct 2018 09:31:24 +0000 (12:31 +0300)
committerAlexander Gavrilov <angavrilov@gmail.com>
Wed, 24 Oct 2018 10:45:03 +0000 (13:45 +0300)
source/blender/depsgraph/DEG_depsgraph_build.h
source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
source/blender/depsgraph/intern/builder/deg_builder_relations.cc
source/blender/depsgraph/intern/builder/deg_builder_relations.h
source/blender/depsgraph/intern/depsgraph_build.cc
source/blender/modifiers/intern/MOD_array.c
source/blender/modifiers/intern/MOD_curve.c
source/blender/modifiers/intern/MOD_datatransfer.c
source/blender/modifiers/intern/MOD_shrinkwrap.c

index 4975f18f4ce969a8cb65580dd9cdc05414621965..53138fc7c405c663640ecedd67951ed73839f3ac 100644 (file)
@@ -141,11 +141,11 @@ void DEG_add_object_relation(struct DepsNodeHandle *node,
                              struct Object *object,
                              eDepsObjectComponentType component,
                              const char *description);
-void DEG_add_object_customdata_relation(struct DepsNodeHandle *node,
-                             struct Object *object,
-                             eDepsObjectComponentType component,
-                             uint64_t customdata_mask,
-                             const char *description);
+void DEG_add_object_relation_with_customdata(struct DepsNodeHandle *node,
+                                             struct Object *object,
+                                             eDepsObjectComponentType component,
+                                             uint64_t customdata_mask,
+                                             const char *description);
 void DEG_add_bone_relation(struct DepsNodeHandle *handle,
                            struct Object *object,
                            const char *bone_name,
@@ -156,9 +156,9 @@ void DEG_add_object_cache_relation(struct DepsNodeHandle *handle,
                                    eDepsObjectComponentType component,
                                    const char *description);
 
+void DEG_add_special_eval_flag(struct DepsNodeHandle *handle, struct ID *id, short flag);
 
 struct Depsgraph *DEG_get_graph_from_handle(struct DepsNodeHandle *handle);
-void DEG_add_special_eval_flag(struct Depsgraph *graph, struct ID *id, short flag);
 
 /* ************************************************ */
 
index ff3009a6ce5032fdd69751ee86942515a7815aa3..30301cdf29a8fa628acf39082fbf7d54c2bbf9d2 100644 (file)
@@ -667,7 +667,6 @@ void DepsgraphNodeBuilder::build_object_data(
        if (object->data == NULL) {
                return;
        }
-       IDDepsNode *id_node = graph_->find_id_node(&object->id);
        /* type-specific data. */
        switch (object->type) {
                case OB_MESH:
@@ -678,15 +677,6 @@ void DepsgraphNodeBuilder::build_object_data(
                case OB_LATTICE:
                case OB_GPENCIL:
                        build_object_data_geometry(object, is_object_visible);
-                       /* TODO(sergey): Only for until we support granular
-                        * update of curves.
-                        */
-                       if (object->type == OB_FONT) {
-                               Curve *curve = (Curve *)object->data;
-                               if (curve->textoncurve) {
-                                       id_node->eval_flags |= DAG_EVAL_NEED_CURVE_PATH;
-                               }
-                       }
                        break;
                case OB_ARMATURE:
                        if (ID_IS_LINKED(object) && object->proxy_from != NULL) {
index c40df4cb74eca245d7e5c136740d8b68786054b9..e0c98b4018638c308a736e9d263bcc2f1da7f24b 100644 (file)
@@ -286,6 +286,17 @@ void DepsgraphRelationBuilder::add_customdata_mask(const ComponentKey &key, uint
        }
 }
 
+void DepsgraphRelationBuilder::add_special_eval_flag(ID *id, short flag)
+{
+       DEG::IDDepsNode *id_node = graph_->find_id_node(id);
+       if (id_node == NULL) {
+               BLI_assert(!"ID should always be valid");
+       }
+       else {
+               id_node->eval_flags |= flag;
+       }
+}
+
 DepsRelation *DepsgraphRelationBuilder::add_time_relation(
         TimeSourceDepsNode *timesrc,
         DepsNode *node_to,
@@ -670,6 +681,15 @@ void DepsgraphRelationBuilder::build_object_data(Object *object)
                case OB_GPENCIL:
                {
                        build_object_data_geometry(object);
+                       /* TODO(sergey): Only for until we support granular
+                        * update of curves.
+                        */
+                       if (object->type == OB_FONT) {
+                               Curve *curve = (Curve *)object->data;
+                               if (curve->textoncurve) {
+                                       add_special_eval_flag(&curve->textoncurve->id, DAG_EVAL_NEED_CURVE_PATH);
+                               }
+                       }
                        break;
                }
                case OB_ARMATURE:
index d3c7b0ebfaf14bd8d5e6db3ab22ccf3ae9e728d9..32330f5680d0c7517092dabc0f653f0ae0eaaf5c 100644 (file)
@@ -201,6 +201,7 @@ struct DepsgraphRelationBuilder
                                               bool check_unique = false);
 
        void add_customdata_mask(const ComponentKey &key, uint64_t mask);
+       void add_special_eval_flag(ID *object, short flag);
 
        void build_id(ID *id);
        void build_layer_collections(ListBase *lb);
index 957ca1a4275dfcd521cd4fd92589f8ba0ea51e4d..e38cebbf525bd3d50f2c4234a6d61f4c8d9eddda 100644 (file)
@@ -131,11 +131,11 @@ void DEG_add_object_relation(DepsNodeHandle *handle,
                                                      description);
 }
 
-void DEG_add_object_customdata_relation(DepsNodeHandle *handle,
-                             Object *object,
-                             eDepsObjectComponentType component,
-                             uint64_t customdata_mask,
-                             const char *description)
+void DEG_add_object_relation_with_customdata(DepsNodeHandle *handle,
+                                             Object *object,
+                                             eDepsObjectComponentType component,
+                                             uint64_t customdata_mask,
+                                             const char *description)
 {
        DEG::eDepsNode_Type type = deg_build_object_component_type(component);
        DEG::ComponentKey comp_key(&object->id, type);
@@ -178,26 +178,17 @@ void DEG_add_bone_relation(DepsNodeHandle *handle,
                                                      description);
 }
 
-struct Depsgraph *DEG_get_graph_from_handle(struct DepsNodeHandle *handle)
+void DEG_add_special_eval_flag(struct DepsNodeHandle *handle, ID *id, short flag)
 {
        DEG::DepsNodeHandle *deg_handle = get_handle(handle);
-       DEG::DepsgraphRelationBuilder *relation_builder = deg_handle->builder;
-       return reinterpret_cast<Depsgraph *>(relation_builder->getGraph());
+       deg_handle->builder->add_special_eval_flag(id, flag);
 }
 
-void DEG_add_special_eval_flag(Depsgraph *graph, ID *id, short flag)
+struct Depsgraph *DEG_get_graph_from_handle(struct DepsNodeHandle *handle)
 {
-       DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph *>(graph);
-       if (graph == NULL) {
-               BLI_assert(!"Graph should always be valid");
-               return;
-       }
-       DEG::IDDepsNode *id_node = deg_graph->find_id_node(id);
-       if (id_node == NULL) {
-               BLI_assert(!"ID should always be valid");
-               return;
-       }
-       id_node->eval_flags |= flag;
+       DEG::DepsNodeHandle *deg_handle = get_handle(handle);
+       DEG::DepsgraphRelationBuilder *relation_builder = deg_handle->builder;
+       return reinterpret_cast<Depsgraph *>(relation_builder->getGraph());
 }
 
 /* ******************** */
index 2b8c1dd8c28890b4057675b41d7b455401dadc29..9cd642e1a3b691da56a810ba18e24033eb8edd1d 100644 (file)
@@ -101,9 +101,8 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
                DEG_add_object_relation(ctx->node, amd->end_cap, DEG_OB_COMP_GEOMETRY, "Array Modifier End Cap");
        }
        if (amd->curve_ob) {
-               struct Depsgraph *depsgraph = DEG_get_graph_from_handle(ctx->node);
                DEG_add_object_relation(ctx->node, amd->curve_ob, DEG_OB_COMP_GEOMETRY, "Array Modifier Curve");
-               DEG_add_special_eval_flag(depsgraph, &amd->curve_ob->id, DAG_EVAL_NEED_CURVE_PATH);
+               DEG_add_special_eval_flag(ctx->node, &amd->curve_ob->id, DAG_EVAL_NEED_CURVE_PATH);
        }
        if (amd->offset_ob != NULL) {
                DEG_add_object_relation(ctx->node, amd->offset_ob, DEG_OB_COMP_TRANSFORM, "Array Modifier Offset");
index b74b63e2478f6e0f74da74af70c75f8eb9484719..02ddd3a180e774caabcd1eec989df8d595d6ab15 100644 (file)
@@ -97,9 +97,8 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
                /* TODO(sergey): Currently path is evaluated as a part of modifier stack,
                 * might be changed in the future.
                 */
-               struct Depsgraph *depsgraph = DEG_get_graph_from_handle(ctx->node);
                DEG_add_object_relation(ctx->node, cmd->object, DEG_OB_COMP_GEOMETRY, "Curve Modifier");
-               DEG_add_special_eval_flag(depsgraph, &cmd->object->id, DAG_EVAL_NEED_CURVE_PATH);
+               DEG_add_special_eval_flag(ctx->node, &cmd->object->id, DAG_EVAL_NEED_CURVE_PATH);
        }
 
        DEG_add_object_relation(ctx->node, ctx->object, DEG_OB_COMP_TRANSFORM, "Curve Modifier");
index 6c99b5d95b33e2fe59603c5f4eeab042cf2204ec..b8146d3fe417a0510f49766726b27c7f546b544d 100644 (file)
@@ -131,7 +131,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
        if (dtmd->ob_source != NULL) {
                CustomDataMask mask = BKE_object_data_transfer_dttypes_to_cdmask(dtmd->data_types);
 
-               DEG_add_object_customdata_relation(ctx->node, dtmd->ob_source, DEG_OB_COMP_GEOMETRY, mask, "DataTransfer Modifier");
+               DEG_add_object_relation_with_customdata(ctx->node, dtmd->ob_source, DEG_OB_COMP_GEOMETRY, mask, "DataTransfer Modifier");
        }
 }
 
index 4ba33461bbdf3c88aae2088306c807b07b24e2e2..b58613994679d0f9074ed24c2e909cf283580833 100644 (file)
@@ -149,11 +149,11 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
 
        if (smd->target != NULL) {
                DEG_add_object_relation(ctx->node, smd->target, DEG_OB_COMP_TRANSFORM, "Shrinkwrap Modifier");
-               DEG_add_object_customdata_relation(ctx->node, smd->target, DEG_OB_COMP_GEOMETRY, mask, "Shrinkwrap Modifier");
+               DEG_add_object_relation_with_customdata(ctx->node, smd->target, DEG_OB_COMP_GEOMETRY, mask, "Shrinkwrap Modifier");
        }
        if (smd->auxTarget != NULL) {
                DEG_add_object_relation(ctx->node, smd->auxTarget, DEG_OB_COMP_TRANSFORM, "Shrinkwrap Modifier");
-               DEG_add_object_customdata_relation(ctx->node, smd->auxTarget, DEG_OB_COMP_GEOMETRY, mask, "Shrinkwrap Modifier");
+               DEG_add_object_relation_with_customdata(ctx->node, smd->auxTarget, DEG_OB_COMP_GEOMETRY, mask, "Shrinkwrap Modifier");
        }
        DEG_add_object_relation(ctx->node, ctx->object, DEG_OB_COMP_TRANSFORM, "Shrinkwrap Modifier");
 }