From 75a87abdc907c9bff034f8eb88294b92f8502c44 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 23 Nov 2017 15:23:19 +0100 Subject: Depsgraph: Cleanup, deduplicate code around component registration --- .../depsgraph/intern/nodes/deg_node_component.cc | 72 ++++++---------------- .../depsgraph/intern/nodes/deg_node_component.h | 55 +++++------------ 2 files changed, 35 insertions(+), 92 deletions(-) (limited to 'source/blender/depsgraph/intern/nodes') diff --git a/source/blender/depsgraph/intern/nodes/deg_node_component.cc b/source/blender/depsgraph/intern/nodes/deg_node_component.cc index f21665eeb82..26678d5b23a 100644 --- a/source/blender/depsgraph/intern/nodes/deg_node_component.cc +++ b/source/blender/depsgraph/intern/nodes/deg_node_component.cc @@ -333,40 +333,25 @@ void ComponentDepsNode::finalize_build() operations_map = NULL; } -/* Parameter Component Defines ============================ */ - -DEG_DEPSNODE_DEFINE(ParametersComponentDepsNode, DEG_NODE_TYPE_PARAMETERS, "Parameters Component"); -static DepsNodeFactoryImpl DNTI_PARAMETERS; - -/* Animation Component Defines ============================ */ - -DEG_DEPSNODE_DEFINE(AnimationComponentDepsNode, DEG_NODE_TYPE_ANIMATION, "Animation Component"); -static DepsNodeFactoryImpl DNTI_ANIMATION; - -/* Transform Component Defines ============================ */ - -DEG_DEPSNODE_DEFINE(TransformComponentDepsNode, DEG_NODE_TYPE_TRANSFORM, "Transform Component"); -static DepsNodeFactoryImpl DNTI_TRANSFORM; - -/* Proxy Component Defines ================================ */ - -DEG_DEPSNODE_DEFINE(ProxyComponentDepsNode, DEG_NODE_TYPE_PROXY, "Proxy Component"); -static DepsNodeFactoryImpl DNTI_PROXY; - -/* Geometry Component Defines ============================= */ - -DEG_DEPSNODE_DEFINE(GeometryComponentDepsNode, DEG_NODE_TYPE_GEOMETRY, "Geometry Component"); -static DepsNodeFactoryImpl DNTI_GEOMETRY; - -/* Sequencer Component Defines ============================ */ - -DEG_DEPSNODE_DEFINE(SequencerComponentDepsNode, DEG_NODE_TYPE_SEQUENCER, "Sequencer Component"); -static DepsNodeFactoryImpl DNTI_SEQUENCER; - -/* Pose Component ========================================= */ - -DEG_DEPSNODE_DEFINE(PoseComponentDepsNode, DEG_NODE_TYPE_EVAL_POSE, "Pose Eval Component"); -static DepsNodeFactoryImpl DNTI_EVAL_POSE; +/* Register all components. =============================== */ + +#define DEG_COMPONENT_DEFINE(name, NAME) \ + DEG_DEPSNODE_DEFINE(name ## ComponentDepsNode, \ + DEG_NODE_TYPE_ ## NAME, \ + #name " Component"); \ +static DepsNodeFactoryImpl 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 ========================================= */ @@ -387,24 +372,7 @@ void BoneComponentDepsNode::init(const ID *id, const char *subdata) this->pchan = BKE_pose_channel_find_name(object->pose, subdata); } -DEG_DEPSNODE_DEFINE(BoneComponentDepsNode, DEG_NODE_TYPE_BONE, "Bone Component"); -static DepsNodeFactoryImpl DNTI_BONE; - -/* Particles Component Defines ============================ */ - -DEG_DEPSNODE_DEFINE(ParticlesComponentDepsNode, DEG_NODE_TYPE_EVAL_PARTICLES, "Particles Component"); -static DepsNodeFactoryImpl DNTI_EVAL_PARTICLES; - -/* Shading Component Defines ============================ */ - -DEG_DEPSNODE_DEFINE(ShadingComponentDepsNode, DEG_NODE_TYPE_SHADING, "Shading Component"); -static DepsNodeFactoryImpl DNTI_SHADING; - -/* Cache Component Defines ============================ */ - -DEG_DEPSNODE_DEFINE(CacheComponentDepsNode, DEG_NODE_TYPE_CACHE, "Cache Component"); -static DepsNodeFactoryImpl DNTI_CACHE; - +DEG_COMPONENT_DEFINE(Bone, BONE); /* Node Types Register =================================== */ diff --git a/source/blender/depsgraph/intern/nodes/deg_node_component.h b/source/blender/depsgraph/intern/nodes/deg_node_component.h index 4ef7dad3ac6..eddef3f6635 100644 --- a/source/blender/depsgraph/intern/nodes/deg_node_component.h +++ b/source/blender/depsgraph/intern/nodes/deg_node_component.h @@ -158,33 +158,21 @@ struct ComponentDepsNode : public DepsNode { /* ---------------------------------------- */ -struct ParametersComponentDepsNode : public ComponentDepsNode { - DEG_DEPSNODE_DECLARE; -}; - -struct AnimationComponentDepsNode : public ComponentDepsNode { - DEG_DEPSNODE_DECLARE; -}; - -struct TransformComponentDepsNode : public ComponentDepsNode { - DEG_DEPSNODE_DECLARE; -}; - -struct ProxyComponentDepsNode : public ComponentDepsNode { - DEG_DEPSNODE_DECLARE; -}; - -struct GeometryComponentDepsNode : public ComponentDepsNode { - DEG_DEPSNODE_DECLARE; -}; - -struct SequencerComponentDepsNode : public ComponentDepsNode { - DEG_DEPSNODE_DECLARE; -}; - -struct PoseComponentDepsNode : public ComponentDepsNode { - DEG_DEPSNODE_DECLARE; -}; +#define DEG_COMPONENT_DECLARE_GENERIC(name) \ + struct name ## ComponentDepsNode : public ComponentDepsNode { \ + DEG_DEPSNODE_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); /* Bone Component */ struct BoneComponentDepsNode : public ComponentDepsNode { @@ -195,19 +183,6 @@ struct BoneComponentDepsNode : public ComponentDepsNode { DEG_DEPSNODE_DECLARE; }; -struct ParticlesComponentDepsNode : public ComponentDepsNode { - DEG_DEPSNODE_DECLARE; -}; - -struct ShadingComponentDepsNode : public ComponentDepsNode { - DEG_DEPSNODE_DECLARE; -}; - -struct CacheComponentDepsNode : public ComponentDepsNode { - DEG_DEPSNODE_DECLARE; -}; - - void deg_register_component_depsnodes(); } // namespace DEG -- cgit v1.2.3