Depsgraph: Use operation code for geometry evaluation init
authorSergey Sharybin <sergey.vfx@gmail.com>
Fri, 1 Feb 2019 09:37:14 +0000 (10:37 +0100)
committerSergey Sharybin <sergey.vfx@gmail.com>
Fri, 1 Feb 2019 14:40:19 +0000 (15:40 +0100)
Makes it more explicit and avoids strings comparisons during build.

source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
source/blender/depsgraph/intern/builder/deg_builder_relations.cc
source/blender/depsgraph/intern/node/deg_node_operation.cc
source/blender/depsgraph/intern/node/deg_node_operation.h

index 2f22d4b..26169b5 100644 (file)
@@ -1246,12 +1246,14 @@ void DepsgraphNodeBuilder::build_object_data_geometry(
        OperationNode *op_node;
        Scene *scene_cow = get_cow_datablock(scene_);
        Object *object_cow = get_cow_datablock(object);
-       /* Temporary uber-update node, which does everything.
-        * It is for the being we're porting old dependencies into the new system.
-        * We'll get rid of this node as soon as all the granular update functions
-        * are filled in.
-        *
-        * TODO(sergey): Get rid of this node. */
+       /* Entry operation, takes care of initialization, and some other
+        * relations which needs to be run prior actual geometry evaluation. */
+       op_node = add_operation_node(&object->id,
+                                    NodeType::GEOMETRY,
+                                    NULL,
+                                    OperationCode::GEOMETRY_EVAL_INIT);
+       op_node->set_as_entry();
+       /* Geometry evaluation. */
        op_node = add_operation_node(&object->id,
                                     NodeType::GEOMETRY,
                                     function_bind(BKE_object_eval_uber_data,
@@ -1260,13 +1262,6 @@ void DepsgraphNodeBuilder::build_object_data_geometry(
                                                   object_cow),
                                     OperationCode::GEOMETRY_EVAL);
        op_node->set_as_exit();
-
-       op_node = add_operation_node(&object->id,
-                                    NodeType::GEOMETRY,
-                                    NULL,
-                                    OperationCode::PLACEHOLDER,
-                                    "Eval Init");
-       op_node->set_as_entry();
        /* Materials. */
        if (object->totcol != 0) {
                if (object->type == OB_MESH) {
index 65b235d..75b4ae4 100644 (file)
@@ -1936,16 +1936,14 @@ void DepsgraphRelationBuilder::build_shapekeys(Key *key)
  *        and also for the links coming from the shapekey datablocks
  * - Animation/Drivers affecting the parameters of the geometry are made to
  *   trigger updates on the obdata geometry component, which then trigger
- *   downstream re-evaluation of the individual instances of this geometry.
- */
+ *   downstream re-evaluation of the individual instances of this geometry. */
 void DepsgraphRelationBuilder::build_object_data_geometry(Object *object)
 {
        ID *obdata = (ID *)object->data;
        /* Init operation of object-level geometry evaluation. */
        OperationKey geom_init_key(&object->id,
                                   NodeType::GEOMETRY,
-                                  OperationCode::PLACEHOLDER,
-                                  "Eval Init");
+                                  OperationCode::GEOMETRY_EVAL_INIT);
        /* Get nodes for result of obdata's evaluation, and geometry evaluation
         * on object. */
        ComponentKey obdata_geom_key(obdata, NodeType::GEOMETRY);
@@ -1981,7 +1979,7 @@ void DepsgraphRelationBuilder::build_object_data_geometry(Object *object)
                        }
                }
        }
-       /* Grease Pencil Modifiers */
+       /* Grease Pencil Modifiers. */
        if (object->greasepencil_modifiers.first != NULL) {
                ModifierUpdateDepsgraphContext ctx = {};
                ctx.scene = scene_;
@@ -1999,7 +1997,7 @@ void DepsgraphRelationBuilder::build_object_data_geometry(Object *object)
                        }
                }
        }
-       /* Shader FX */
+       /* Shader FX. */
        if (object->shader_fx.first != NULL) {
                ModifierUpdateDepsgraphContext ctx = {};
                ctx.scene = scene_;
@@ -2040,9 +2038,7 @@ void DepsgraphRelationBuilder::build_object_data_geometry(Object *object)
        if (ELEM(object->type, OB_MESH, OB_CURVE, OB_LATTICE)) {
                // add geometry collider relations
        }
-       /* Make sure uber update is the last in the dependencies.
-        *
-        * TODO(sergey): Get rid of this node. */
+       /* Make sure uber update is the last in the dependencies. */
        if (object->type != OB_ARMATURE) {
                /* Armatures does no longer require uber node. */
                OperationKey obdata_ubereval_key(&object->id,
index 68a359a..9004451 100644 (file)
@@ -64,6 +64,7 @@ const char *operationCodeAsString(OperationCode opcode)
                case OperationCode::RIGIDBODY_TRANSFORM_COPY:
                        return "RIGIDBODY_TRANSFORM_COPY";
                /* Geometry. */
+               case OperationCode::GEOMETRY_EVAL_INIT: return "GEOMETRY_EVAL_INIT";
                case OperationCode::GEOMETRY_EVAL: return "GEOMETRY_EVAL";
                case OperationCode::GEOMETRY_SHAPEKEY: return "GEOMETRY_SHAPEKEY";
                /* Object data. */
index 480b33f..3cb49cc 100644 (file)
@@ -84,6 +84,9 @@ enum class OperationCode {
 
        /* Geometry. ------------------------------------------------------------ */
 
+       /* Initialize evaluation of the geometry. Is an entry operation of geometry
+        * component. */
+       GEOMETRY_EVAL_INIT,
        /* Evaluate the whole geometry, including modifiers. */
        GEOMETRY_EVAL,
        /* Evaluation of a shape key. */