Depsgraph: Add facilities to store what ID recalc flag component corresponds to
authorSergey Sharybin <sergey.vfx@gmail.com>
Mon, 18 Dec 2017 15:46:32 +0000 (16:46 +0100)
committerSergey Sharybin <sergey.vfx@gmail.com>
Mon, 18 Dec 2017 15:46:32 +0000 (16:46 +0100)
The idea is to de-duplicate logic in DEG_id_tag_update() and flushing where we
need to translate depsgraph tag or component type to ID level recalc flag.

Currently unused, but is required for Blender 2.8.

source/blender/depsgraph/intern/depsgraph_intern.h
source/blender/depsgraph/intern/nodes/deg_node.cc
source/blender/depsgraph/intern/nodes/deg_node.h
source/blender/depsgraph/intern/nodes/deg_node_component.cc
source/blender/depsgraph/intern/nodes/deg_node_component.h

index 3aee55369824e12e04ffaa8f5f7bd1046878147d..f562f5d64f8b5ed80e6ee3c8bc68d7060ff7fb87 100644 (file)
@@ -61,6 +61,7 @@ struct DepsNodeFactory {
        virtual eDepsNode_Type type() const = 0;
        virtual eDepsNode_Class tclass() const = 0;
        virtual const char *tname() const = 0;
+       virtual int id_recalc_tag() const = 0;
 
        virtual DepsNode *create_node(const ID *id,
                                      const char *subdata,
@@ -72,6 +73,7 @@ struct DepsNodeFactoryImpl : public DepsNodeFactory {
        eDepsNode_Type type() const { return NodeType::typeinfo.type; }
        eDepsNode_Class tclass() const { return NodeType::typeinfo.tclass; }
        const char *tname() const { return NodeType::typeinfo.tname; }
+       int id_recalc_tag() const { return NodeType::typeinfo.id_recalc_tag; }
 
        DepsNode *create_node(const ID *id, const char *subdata, const char *name) const
        {
index 1d4d542e7cc0e1d29b2be9b37ec6ee109ca24626..77182332e0250bfa2d6e720ac750b4b8340a97a0 100644 (file)
@@ -57,16 +57,19 @@ namespace DEG {
 
 /* Add ------------------------------------------------ */
 
-DepsNode::TypeInfo::TypeInfo(eDepsNode_Type type, const char *tname)
+DepsNode::TypeInfo::TypeInfo(eDepsNode_Type type,
+                             const char *tname,
+                             int id_recalc_tag)
+        : type(type),
+          tname(tname),
+          id_recalc_tag(id_recalc_tag)
 {
-       this->type = type;
        if (type == DEG_NODE_TYPE_OPERATION)
                this->tclass = DEG_NODE_CLASS_OPERATION;
        else if (type < DEG_NODE_TYPE_PARAMETERS)
                this->tclass = DEG_NODE_CLASS_GENERIC;
        else
                this->tclass = DEG_NODE_CLASS_COMPONENT;
-       this->tname = tname;
 }
 
 DepsNode::DepsNode()
index 9f1b61faf24e6b16f169b7f0343128f9ff247d86..b9aa36bbd4329993bfb8fd6f92a21d3bfc73d917 100644 (file)
@@ -51,11 +51,13 @@ struct OperationDepsNode;
 struct DepsNode {
        /* Helper class for static typeinfo in subclasses. */
        struct TypeInfo {
-               TypeInfo(eDepsNode_Type type, const char *tname);
+               TypeInfo(eDepsNode_Type type, const char *tname, int id_recalc_tag = 0);
 
                eDepsNode_Type type;
                eDepsNode_Class tclass;
                const char *tname;
+
+               int id_recalc_tag;
        };
 
        /* Identifier - mainly for debugging purposes. */
index 17f35acee79c9eb7755276c373fe6ca1598eec0c..8ac73671678230cf1789184dc27b90effe6c1cb2 100644 (file)
@@ -359,26 +359,6 @@ void ComponentDepsNode::finalize_build()
        operations_map = NULL;
 }
 
-/* Register all components. =============================== */
-
-#define DEG_COMPONENT_DEFINE(name, NAME)                             \
-  DEG_DEPSNODE_DEFINE(name ## ComponentDepsNode,                     \
-                      DEG_NODE_TYPE_ ## NAME,                        \
-                      #name  " Component");                          \
-static DepsNodeFactoryImpl<name ## ComponentDepsNode> DNTI_ ## NAME
-
-
-DEG_COMPONENT_DEFINE(Animation, ANIMATION);
-DEG_COMPONENT_DEFINE(Cache, CACHE);
-DEG_COMPONENT_DEFINE(Geometry, GEOMETRY);
-DEG_COMPONENT_DEFINE(Parameters, PARAMETERS);
-DEG_COMPONENT_DEFINE(Particles, EVAL_PARTICLES);
-DEG_COMPONENT_DEFINE(Proxy, PROXY);
-DEG_COMPONENT_DEFINE(Pose, EVAL_POSE);
-DEG_COMPONENT_DEFINE(Sequencer, SEQUENCER);
-DEG_COMPONENT_DEFINE(Shading, SHADING);
-DEG_COMPONENT_DEFINE(Transform, TRANSFORM);
-
 /* Bone Component ========================================= */
 
 /* Initialize 'bone component' node - from pointer data given */
@@ -398,7 +378,19 @@ void BoneComponentDepsNode::init(const ID *id, const char *subdata)
        this->pchan = BKE_pose_channel_find_name(object->pose, subdata);
 }
 
-DEG_COMPONENT_DEFINE(Bone, BONE);
+/* Register all components. =============================== */
+
+DEG_COMPONENT_NODE_DEFINE(Animation,         ANIMATION,          ID_RECALC_NONE);
+DEG_COMPONENT_NODE_DEFINE(Bone,              BONE,               ID_RECALC_NONE);
+DEG_COMPONENT_NODE_DEFINE(Cache,             CACHE,              ID_RECALC_NONE);
+DEG_COMPONENT_NODE_DEFINE(Geometry,          GEOMETRY,           ID_RECALC_NONE);
+DEG_COMPONENT_NODE_DEFINE(Parameters,        PARAMETERS,         ID_RECALC_NONE);
+DEG_COMPONENT_NODE_DEFINE(Particles,         EVAL_PARTICLES,     ID_RECALC_NONE);
+DEG_COMPONENT_NODE_DEFINE(Proxy,             PROXY,              ID_RECALC_NONE);
+DEG_COMPONENT_NODE_DEFINE(Pose,              EVAL_POSE,          ID_RECALC_NONE);
+DEG_COMPONENT_NODE_DEFINE(Sequencer,         SEQUENCER,          ID_RECALC_NONE);
+DEG_COMPONENT_NODE_DEFINE(Shading,           SHADING,            ID_RECALC_NONE);
+DEG_COMPONENT_NODE_DEFINE(Transform,         TRANSFORM,          ID_RECALC_NONE);
 
 /* Node Types Register =================================== */
 
index 1c21a71737f2a7097bb5dbaa60d35080d2e57bdd..702697eba3a61a8f53f92dec96f447e8107b925d 100644 (file)
@@ -166,21 +166,34 @@ struct ComponentDepsNode : public DepsNode {
 
 /* ---------------------------------------- */
 
-#define DEG_COMPONENT_DECLARE_GENERIC(name)                        \
+#define DEG_COMPONENT_NODE_DEFINE_TYPEINFO(NodeType, type_, tname_, id_recalc_tag) \
+    const DepsNode::TypeInfo NodeType::typeinfo = \
+        DepsNode::TypeInfo(type_, tname_, id_recalc_tag)
+
+#define DEG_COMPONENT_NODE_DECLARE DEG_DEPSNODE_DECLARE
+
+#define DEG_COMPONENT_NODE_DEFINE(name, NAME, id_recalc_tag)            \
+    DEG_COMPONENT_NODE_DEFINE_TYPEINFO(name ## ComponentDepsNode,       \
+                                       DEG_NODE_TYPE_ ## NAME,          \
+                                       #name  " Component",             \
+                                       id_recalc_tag) ;                 \
+    static DepsNodeFactoryImpl<name ## ComponentDepsNode> DNTI_ ## NAME
+
+#define DEG_COMPONENT_NODE_DECLARE_GENERIC(name)                   \
        struct name ## ComponentDepsNode : public ComponentDepsNode {  \
-               DEG_DEPSNODE_DECLARE;                                      \
+               DEG_COMPONENT_NODE_DECLARE;                                \
        }
 
-DEG_COMPONENT_DECLARE_GENERIC(Animation);
-DEG_COMPONENT_DECLARE_GENERIC(Cache);
-DEG_COMPONENT_DECLARE_GENERIC(Geometry);
-DEG_COMPONENT_DECLARE_GENERIC(Parameters);
-DEG_COMPONENT_DECLARE_GENERIC(Particles);
-DEG_COMPONENT_DECLARE_GENERIC(Proxy);
-DEG_COMPONENT_DECLARE_GENERIC(Pose);
-DEG_COMPONENT_DECLARE_GENERIC(Sequencer);
-DEG_COMPONENT_DECLARE_GENERIC(Shading);
-DEG_COMPONENT_DECLARE_GENERIC(Transform);
+DEG_COMPONENT_NODE_DECLARE_GENERIC(Animation);
+DEG_COMPONENT_NODE_DECLARE_GENERIC(Cache);
+DEG_COMPONENT_NODE_DECLARE_GENERIC(Geometry);
+DEG_COMPONENT_NODE_DECLARE_GENERIC(Parameters);
+DEG_COMPONENT_NODE_DECLARE_GENERIC(Particles);
+DEG_COMPONENT_NODE_DECLARE_GENERIC(Proxy);
+DEG_COMPONENT_NODE_DECLARE_GENERIC(Pose);
+DEG_COMPONENT_NODE_DECLARE_GENERIC(Sequencer);
+DEG_COMPONENT_NODE_DECLARE_GENERIC(Shading);
+DEG_COMPONENT_NODE_DECLARE_GENERIC(Transform);
 
 /* Bone Component */
 struct BoneComponentDepsNode : public ComponentDepsNode {
@@ -188,7 +201,7 @@ struct BoneComponentDepsNode : public ComponentDepsNode {
 
        struct bPoseChannel *pchan;     /* the bone that this component represents */
 
-       DEG_DEPSNODE_DECLARE;
+       DEG_COMPONENT_NODE_DECLARE;
 };
 
 void deg_register_component_depsnodes();