diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-04-17 07:17:24 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-04-17 07:21:24 +0300 |
commit | e12c08e8d170b7ca40f204a5b0423c23a9fbc2c1 (patch) | |
tree | 8cf3453d12edb177a218ef8009357518ec6cab6a /source/blender/depsgraph/intern/node | |
parent | b3dabc200a4b0399ec6b81f2ff2730d07b44fcaa (diff) |
ClangFormat: apply to source, most of intern
Apply clang format as proposed in T53211.
For details on usage and instructions for migrating branches
without conflicts, see:
https://wiki.blender.org/wiki/Tools/ClangFormat
Diffstat (limited to 'source/blender/depsgraph/intern/node')
13 files changed, 1175 insertions, 1136 deletions
diff --git a/source/blender/depsgraph/intern/node/deg_node.cc b/source/blender/depsgraph/intern/node/deg_node.cc index 1eaee3d9e5b..5692983fbe2 100644 --- a/source/blender/depsgraph/intern/node/deg_node.cc +++ b/source/blender/depsgraph/intern/node/deg_node.cc @@ -39,67 +39,92 @@ namespace DEG { const char *nodeClassAsString(NodeClass node_class) { - switch (node_class) { - case NodeClass::GENERIC: return "GENERIC"; - case NodeClass::COMPONENT: return "COMPONENT"; - case NodeClass::OPERATION: return "OPERATION"; - } - BLI_assert(!"Unhandled node class, should never happen."); - return "UNKNOWN"; + switch (node_class) { + case NodeClass::GENERIC: + return "GENERIC"; + case NodeClass::COMPONENT: + return "COMPONENT"; + case NodeClass::OPERATION: + return "OPERATION"; + } + BLI_assert(!"Unhandled node class, should never happen."); + return "UNKNOWN"; } const char *nodeTypeAsString(NodeType type) { - switch (type) { - case NodeType::UNDEFINED: return "UNDEFINED"; - case NodeType::OPERATION: return "OPERATION"; - /* **** Generic Types **** */ - case NodeType::TIMESOURCE: return "TIMESOURCE"; - case NodeType::ID_REF: return "ID_REF"; - /* **** Outer Types **** */ - case NodeType::PARAMETERS: return "PARAMETERS"; - case NodeType::PROXY: return "PROXY"; - case NodeType::ANIMATION: return "ANIMATION"; - case NodeType::TRANSFORM: return "TRANSFORM"; - case NodeType::GEOMETRY: return "GEOMETRY"; - case NodeType::SEQUENCER: return "SEQUENCER"; - case NodeType::LAYER_COLLECTIONS: return "LAYER_COLLECTIONS"; - case NodeType::COPY_ON_WRITE: return "COPY_ON_WRITE"; - case NodeType::OBJECT_FROM_LAYER: return "OBJECT_FROM_LAYER"; - /* **** Evaluation-Related Outer Types (with Subdata) **** */ - case NodeType::EVAL_POSE: return "EVAL_POSE"; - case NodeType::BONE: return "BONE"; - case NodeType::PARTICLE_SYSTEM: return "PARTICLE_SYSTEM"; - case NodeType::PARTICLE_SETTINGS: return "PARTICLE_SETTINGS"; - case NodeType::SHADING: return "SHADING"; - case NodeType::SHADING_PARAMETERS: return "SHADING_PARAMETERS"; - case NodeType::CACHE: return "CACHE"; - case NodeType::POINT_CACHE: return "POINT_CACHE"; - case NodeType::BATCH_CACHE: return "BATCH_CACHE"; - /* Duplication. */ - case NodeType::DUPLI: return "DUPLI"; - /* Synchronization. */ - case NodeType::SYNCHRONIZATION: return "SYNCHRONIZATION"; - /* Generic datablock. */ - case NodeType::GENERIC_DATABLOCK: return "GENERIC_DATABLOCK"; - - /* Total number of meaningful node types. */ - case NodeType::NUM_TYPES: return "SpecialCase"; - } - BLI_assert(!"Unhandled node type, should never happen."); - return "UNKNOWN"; + switch (type) { + case NodeType::UNDEFINED: + return "UNDEFINED"; + case NodeType::OPERATION: + return "OPERATION"; + /* **** Generic Types **** */ + case NodeType::TIMESOURCE: + return "TIMESOURCE"; + case NodeType::ID_REF: + return "ID_REF"; + /* **** Outer Types **** */ + case NodeType::PARAMETERS: + return "PARAMETERS"; + case NodeType::PROXY: + return "PROXY"; + case NodeType::ANIMATION: + return "ANIMATION"; + case NodeType::TRANSFORM: + return "TRANSFORM"; + case NodeType::GEOMETRY: + return "GEOMETRY"; + case NodeType::SEQUENCER: + return "SEQUENCER"; + case NodeType::LAYER_COLLECTIONS: + return "LAYER_COLLECTIONS"; + case NodeType::COPY_ON_WRITE: + return "COPY_ON_WRITE"; + case NodeType::OBJECT_FROM_LAYER: + return "OBJECT_FROM_LAYER"; + /* **** Evaluation-Related Outer Types (with Subdata) **** */ + case NodeType::EVAL_POSE: + return "EVAL_POSE"; + case NodeType::BONE: + return "BONE"; + case NodeType::PARTICLE_SYSTEM: + return "PARTICLE_SYSTEM"; + case NodeType::PARTICLE_SETTINGS: + return "PARTICLE_SETTINGS"; + case NodeType::SHADING: + return "SHADING"; + case NodeType::SHADING_PARAMETERS: + return "SHADING_PARAMETERS"; + case NodeType::CACHE: + return "CACHE"; + case NodeType::POINT_CACHE: + return "POINT_CACHE"; + case NodeType::BATCH_CACHE: + return "BATCH_CACHE"; + /* Duplication. */ + case NodeType::DUPLI: + return "DUPLI"; + /* Synchronization. */ + case NodeType::SYNCHRONIZATION: + return "SYNCHRONIZATION"; + /* Generic datablock. */ + case NodeType::GENERIC_DATABLOCK: + return "GENERIC_DATABLOCK"; + + /* Total number of meaningful node types. */ + case NodeType::NUM_TYPES: + return "SpecialCase"; + } + BLI_assert(!"Unhandled node type, should never happen."); + return "UNKNOWN"; } /******************************************************************************* * Type information. */ -Node::TypeInfo::TypeInfo(NodeType type, - const char *type_name, - int id_recalc_tag) - : type(type), - type_name(type_name), - id_recalc_tag(id_recalc_tag) +Node::TypeInfo::TypeInfo(NodeType type, const char *type_name, int id_recalc_tag) + : type(type), type_name(type_name), id_recalc_tag(id_recalc_tag) { } @@ -109,17 +134,17 @@ Node::TypeInfo::TypeInfo(NodeType type, Node::Stats::Stats() { - reset(); + reset(); } void Node::Stats::reset() { - current_time = 0.0; + current_time = 0.0; } void Node::Stats::reset_current() { - current_time = 0.0; + current_time = 0.0; } /******************************************************************************* @@ -128,37 +153,37 @@ void Node::Stats::reset_current() Node::Node() { - name = ""; + name = ""; } Node::~Node() { - /* Free links. */ - /* NOTE: We only free incoming links. This is to avoid double-free of links - * when we're trying to free same link from both it's sides. We don't have - * dangling links so this is not a problem from memory leaks point of view. */ - for (Relation *rel : inlinks) { - OBJECT_GUARDED_DELETE(rel, Relation); - } + /* Free links. */ + /* NOTE: We only free incoming links. This is to avoid double-free of links + * when we're trying to free same link from both it's sides. We don't have + * dangling links so this is not a problem from memory leaks point of view. */ + for (Relation *rel : inlinks) { + OBJECT_GUARDED_DELETE(rel, Relation); + } } - /* Generic identifier for Depsgraph Nodes. */ string Node::identifier() const { - return string(nodeTypeAsString(type)) + " : " + name; + return string(nodeTypeAsString(type)) + " : " + name; } -NodeClass Node::get_class() const { - if (type == NodeType::OPERATION) { - return NodeClass::OPERATION; - } - else if (type < NodeType::PARAMETERS) { - return NodeClass::GENERIC; - } - else { - return NodeClass::COMPONENT; - } +NodeClass Node::get_class() const +{ + if (type == NodeType::OPERATION) { + return NodeClass::OPERATION; + } + else if (type < NodeType::PARAMETERS) { + return NodeClass::GENERIC; + } + else { + return NodeClass::COMPONENT; + } } /******************************************************************************* @@ -173,8 +198,8 @@ static DepsNodeFactoryImpl<IDNode> DNTI_ID_REF; void deg_register_base_depsnodes() { - register_node_typeinfo(&DNTI_TIMESOURCE); - register_node_typeinfo(&DNTI_ID_REF); + register_node_typeinfo(&DNTI_TIMESOURCE); + register_node_typeinfo(&DNTI_ID_REF); } } // namespace DEG diff --git a/source/blender/depsgraph/intern/node/deg_node.h b/source/blender/depsgraph/intern/node/deg_node.h index 0677b0edc15..ece43657b38 100644 --- a/source/blender/depsgraph/intern/node/deg_node.h +++ b/source/blender/depsgraph/intern/node/deg_node.h @@ -40,154 +40,161 @@ struct Relation; /* Metatype of Nodes - The general "level" in the graph structure * the node serves. */ enum class NodeClass { - /* Types generally unassociated with user-visible entities, - * but needed for graph functioning. */ - GENERIC = 0, - /* [Outer Node] An "aspect" of evaluating/updating an ID-Block, requiring - * certain types of evaluation behavior. */ - COMPONENT = 1, - /* [Inner Node] A glorified function-pointer/callback for scheduling up - * evaluation operations for components, subject to relationship - * requirements. */ - OPERATION = 2, + /* Types generally unassociated with user-visible entities, + * but needed for graph functioning. */ + GENERIC = 0, + /* [Outer Node] An "aspect" of evaluating/updating an ID-Block, requiring + * certain types of evaluation behavior. */ + COMPONENT = 1, + /* [Inner Node] A glorified function-pointer/callback for scheduling up + * evaluation operations for components, subject to relationship + * requirements. */ + OPERATION = 2, }; const char *nodeClassAsString(NodeClass node_class); /* Types of Nodes */ enum class NodeType { - /* Fallback type for invalid return value */ - UNDEFINED = 0, - /* Inner Node (Operation) */ - OPERATION, - - /* **** Generic Types **** */ - - /* Time-Source */ - TIMESOURCE, - /* ID-Block reference - used as landmarks/collection point for components, - * but not usually part of main graph. */ - ID_REF, - - /* **** Outer Types **** */ - - /* Parameters Component - Default when nothing else fits - * (i.e. just SDNA property setting). */ - PARAMETERS, - /* Generic "Proxy-Inherit" Component. */ - PROXY, - /* Animation Component */ - ANIMATION, - /* Transform Component (Parenting/Constraints) */ - TRANSFORM, - /* Geometry Component (Mesh/Displist) */ - GEOMETRY, - /* Sequencer Component (Scene Only) */ - SEQUENCER, - /* Component which contains all operations needed for layer collections - * evaluation. */ - LAYER_COLLECTIONS, - /* Entry component of majority of ID nodes: prepares CoW pointers for - * execution. */ - COPY_ON_WRITE, - /* Used by all operations which are updating object when something is - * changed in view layer. */ - OBJECT_FROM_LAYER, - /* Un-interestying datablock, which is a part of dependency graph, but does - * not have very distinctive update procedure. */ - GENERIC_DATABLOCK, - - /* **** Evaluation-Related Outer Types (with Subdata) **** */ - - /* Pose Component - Owner/Container of Bones Eval */ - EVAL_POSE, - /* Bone Component - Child/Subcomponent of Pose */ - BONE, - /* Particle Systems Component */ - PARTICLE_SYSTEM, - PARTICLE_SETTINGS, - /* Material Shading Component */ - SHADING, - SHADING_PARAMETERS, - /* Point cache Component */ - POINT_CACHE, - /* Cache Component */ - /* TODO(sergey); Verify that we really need this. */ - CACHE, - /* Batch Cache Component. - * TODO (dfelinto/sergey): rename to make it more generic. */ - BATCH_CACHE, - /* Duplication system. Used to force duplicated objects visible when - * when duplicator is visible. */ - DUPLI, - /* Synchronization back to original datablock. */ - SYNCHRONIZATION, - - /* Total number of meaningful node types. */ - NUM_TYPES, + /* Fallback type for invalid return value */ + UNDEFINED = 0, + /* Inner Node (Operation) */ + OPERATION, + + /* **** Generic Types **** */ + + /* Time-Source */ + TIMESOURCE, + /* ID-Block reference - used as landmarks/collection point for components, + * but not usually part of main graph. */ + ID_REF, + + /* **** Outer Types **** */ + + /* Parameters Component - Default when nothing else fits + * (i.e. just SDNA property setting). */ + PARAMETERS, + /* Generic "Proxy-Inherit" Component. */ + PROXY, + /* Animation Component */ + ANIMATION, + /* Transform Component (Parenting/Constraints) */ + TRANSFORM, + /* Geometry Component (Mesh/Displist) */ + GEOMETRY, + /* Sequencer Component (Scene Only) */ + SEQUENCER, + /* Component which contains all operations needed for layer collections + * evaluation. */ + LAYER_COLLECTIONS, + /* Entry component of majority of ID nodes: prepares CoW pointers for + * execution. */ + COPY_ON_WRITE, + /* Used by all operations which are updating object when something is + * changed in view layer. */ + OBJECT_FROM_LAYER, + /* Un-interestying datablock, which is a part of dependency graph, but does + * not have very distinctive update procedure. */ + GENERIC_DATABLOCK, + + /* **** Evaluation-Related Outer Types (with Subdata) **** */ + + /* Pose Component - Owner/Container of Bones Eval */ + EVAL_POSE, + /* Bone Component - Child/Subcomponent of Pose */ + BONE, + /* Particle Systems Component */ + PARTICLE_SYSTEM, + PARTICLE_SETTINGS, + /* Material Shading Component */ + SHADING, + SHADING_PARAMETERS, + /* Point cache Component */ + POINT_CACHE, + /* Cache Component */ + /* TODO(sergey); Verify that we really need this. */ + CACHE, + /* Batch Cache Component. + * TODO (dfelinto/sergey): rename to make it more generic. */ + BATCH_CACHE, + /* Duplication system. Used to force duplicated objects visible when + * when duplicator is visible. */ + DUPLI, + /* Synchronization back to original datablock. */ + SYNCHRONIZATION, + + /* Total number of meaningful node types. */ + NUM_TYPES, }; const char *nodeTypeAsString(NodeType type); /* All nodes in Depsgraph are descended from this. */ struct Node { - /* Helper class for static typeinfo in subclasses. */ - struct TypeInfo { - TypeInfo(NodeType type, - const char *type_name, - int id_recalc_tag = 0); - NodeType type; - const char *type_name; - int id_recalc_tag; - }; - struct Stats { - Stats(); - /* Reset all the counters. Including all stats needed for average - * evaluation time calculation. */ - void reset(); - /* Reset counters needed for the current graph evaluation, does not - * touch averaging accumulators. */ - void reset_current(); - /* Time spend on this node during current graph evaluation. */ - double current_time; - }; - /* Relationships between nodes - * The reason why all depsgraph nodes are descended from this type (apart - * from basic serialization benefits - from the typeinfo) is that we can - * have relationships between these nodes. */ - typedef vector<Relation *> Relations; - - string name; /* Identifier - mainly for debugging purposes. */ - NodeType type; /* Structural type of node. */ - Relations inlinks; /* Nodes which this one depends on. */ - Relations outlinks; /* Nodes which depend on this one. */ - Stats stats; /* Evaluation statistics. */ - - /* Generic tags for traversal algorithms and such. - * - * Actual meaning of values depends on a specific area. Every area is to - * clean this before use. */ - int custom_flags; - - /* Methods. */ - Node(); - virtual ~Node(); - - virtual string identifier() const; - - virtual void init(const ID * /*id*/, const char * /*subdata*/) {} - - virtual void tag_update(Depsgraph * /*graph*/, eUpdateSource /*source*/) {} - - virtual OperationNode *get_entry_operation() { return NULL; } - virtual OperationNode *get_exit_operation() { return NULL; } - - virtual NodeClass get_class() const; + /* Helper class for static typeinfo in subclasses. */ + struct TypeInfo { + TypeInfo(NodeType type, const char *type_name, int id_recalc_tag = 0); + NodeType type; + const char *type_name; + int id_recalc_tag; + }; + struct Stats { + Stats(); + /* Reset all the counters. Including all stats needed for average + * evaluation time calculation. */ + void reset(); + /* Reset counters needed for the current graph evaluation, does not + * touch averaging accumulators. */ + void reset_current(); + /* Time spend on this node during current graph evaluation. */ + double current_time; + }; + /* Relationships between nodes + * The reason why all depsgraph nodes are descended from this type (apart + * from basic serialization benefits - from the typeinfo) is that we can + * have relationships between these nodes. */ + typedef vector<Relation *> Relations; + + string name; /* Identifier - mainly for debugging purposes. */ + NodeType type; /* Structural type of node. */ + Relations inlinks; /* Nodes which this one depends on. */ + Relations outlinks; /* Nodes which depend on this one. */ + Stats stats; /* Evaluation statistics. */ + + /* Generic tags for traversal algorithms and such. + * + * Actual meaning of values depends on a specific area. Every area is to + * clean this before use. */ + int custom_flags; + + /* Methods. */ + Node(); + virtual ~Node(); + + virtual string identifier() const; + + virtual void init(const ID * /*id*/, const char * /*subdata*/) + { + } + + virtual void tag_update(Depsgraph * /*graph*/, eUpdateSource /*source*/) + { + } + + virtual OperationNode *get_entry_operation() + { + return NULL; + } + virtual OperationNode *get_exit_operation() + { + return NULL; + } + + virtual NodeClass get_class() const; }; /* Macros for common static typeinfo. */ -#define DEG_DEPSNODE_DECLARE \ - static const Node::TypeInfo typeinfo +#define DEG_DEPSNODE_DECLARE static const Node::TypeInfo typeinfo #define DEG_DEPSNODE_DEFINE(NodeType, type_, tname_) \ - const Node::TypeInfo NodeType::typeinfo = Node::TypeInfo(type_, tname_) + const Node::TypeInfo NodeType::typeinfo = Node::TypeInfo(type_, tname_) void deg_register_base_depsnodes(); diff --git a/source/blender/depsgraph/intern/node/deg_node_component.cc b/source/blender/depsgraph/intern/node/deg_node_component.cc index 06ede835a27..dc7ca371de3 100644 --- a/source/blender/depsgraph/intern/node/deg_node_component.cc +++ b/source/blender/depsgraph/intern/node/deg_node_component.cc @@ -24,7 +24,7 @@ #include "intern/node/deg_node_component.h" #include <stdio.h> -#include <cstring> /* required for STREQ later on. */ +#include <cstring> /* required for STREQ later on. */ #include "BLI_utildefines.h" #include "BLI_ghash.h" @@ -47,308 +47,281 @@ namespace DEG { /* Standard Component Methods ============================= */ ComponentNode::OperationIDKey::OperationIDKey() - : opcode(OperationCode::OPERATION), - name(""), - name_tag(-1) + : opcode(OperationCode::OPERATION), name(""), name_tag(-1) { } ComponentNode::OperationIDKey::OperationIDKey(OperationCode opcode) - : opcode(opcode), - name(""), - name_tag(-1) + : opcode(opcode), name(""), name_tag(-1) { } -ComponentNode::OperationIDKey::OperationIDKey(OperationCode opcode, - const char *name, - int name_tag) - : opcode(opcode), - name(name), - name_tag(name_tag) +ComponentNode::OperationIDKey::OperationIDKey(OperationCode opcode, const char *name, int name_tag) + : opcode(opcode), name(name), name_tag(name_tag) { } string ComponentNode::OperationIDKey::identifier() const { - const string codebuf = to_string(static_cast<int>(opcode)); - return "OperationIDKey(" + codebuf + ", " + name + ")"; + const string codebuf = to_string(static_cast<int>(opcode)); + return "OperationIDKey(" + codebuf + ", " + name + ")"; } -bool ComponentNode::OperationIDKey::operator==( - const OperationIDKey &other) const +bool ComponentNode::OperationIDKey::operator==(const OperationIDKey &other) const { - return (opcode == other.opcode) && - (STREQ(name, other.name)) && - (name_tag == other.name_tag); + return (opcode == other.opcode) && (STREQ(name, other.name)) && (name_tag == other.name_tag); } static unsigned int comp_node_hash_key(const void *key_v) { - const ComponentNode::OperationIDKey *key = - reinterpret_cast<const ComponentNode::OperationIDKey *>(key_v); - int opcode_as_int = static_cast<int>(key->opcode); - return BLI_ghashutil_combine_hash(BLI_ghashutil_uinthash(opcode_as_int), - BLI_ghashutil_strhash_p(key->name)); + const ComponentNode::OperationIDKey *key = + reinterpret_cast<const ComponentNode::OperationIDKey *>(key_v); + int opcode_as_int = static_cast<int>(key->opcode); + return BLI_ghashutil_combine_hash(BLI_ghashutil_uinthash(opcode_as_int), + BLI_ghashutil_strhash_p(key->name)); } static bool comp_node_hash_key_cmp(const void *a, const void *b) { - const ComponentNode::OperationIDKey *key_a = - reinterpret_cast<const ComponentNode::OperationIDKey *>(a); - const ComponentNode::OperationIDKey *key_b = - reinterpret_cast<const ComponentNode::OperationIDKey *>(b); - return !(*key_a == *key_b); + const ComponentNode::OperationIDKey *key_a = + reinterpret_cast<const ComponentNode::OperationIDKey *>(a); + const ComponentNode::OperationIDKey *key_b = + reinterpret_cast<const ComponentNode::OperationIDKey *>(b); + return !(*key_a == *key_b); } static void comp_node_hash_key_free(void *key_v) { - typedef ComponentNode::OperationIDKey OperationIDKey; - OperationIDKey *key = reinterpret_cast<OperationIDKey *>(key_v); - OBJECT_GUARDED_DELETE(key, OperationIDKey); + typedef ComponentNode::OperationIDKey OperationIDKey; + OperationIDKey *key = reinterpret_cast<OperationIDKey *>(key_v); + OBJECT_GUARDED_DELETE(key, OperationIDKey); } static void comp_node_hash_value_free(void *value_v) { - OperationNode *op_node = reinterpret_cast<OperationNode *>(value_v); - OBJECT_GUARDED_DELETE(op_node, OperationNode); + OperationNode *op_node = reinterpret_cast<OperationNode *>(value_v); + OBJECT_GUARDED_DELETE(op_node, OperationNode); } -ComponentNode::ComponentNode() : - entry_operation(NULL), - exit_operation(NULL), - affects_directly_visible(false) +ComponentNode::ComponentNode() + : entry_operation(NULL), exit_operation(NULL), affects_directly_visible(false) { - operations_map = BLI_ghash_new(comp_node_hash_key, - comp_node_hash_key_cmp, - "Depsgraph id hash"); + operations_map = BLI_ghash_new(comp_node_hash_key, comp_node_hash_key_cmp, "Depsgraph id hash"); } /* Initialize 'component' node - from pointer data given */ -void ComponentNode::init(const ID * /*id*/, - const char * /*subdata*/) +void ComponentNode::init(const ID * /*id*/, const char * /*subdata*/) { - /* hook up eval context? */ - // XXX: maybe this needs a special API? + /* hook up eval context? */ + // XXX: maybe this needs a special API? } /* Free 'component' node */ ComponentNode::~ComponentNode() { - clear_operations(); - if (operations_map != NULL) { - BLI_ghash_free(operations_map, - comp_node_hash_key_free, - comp_node_hash_value_free); - } + clear_operations(); + if (operations_map != NULL) { + BLI_ghash_free(operations_map, comp_node_hash_key_free, comp_node_hash_value_free); + } } string ComponentNode::identifier() const { - const string idname = this->owner->name; - const string typebuf = "" + to_string(static_cast<int>(type)) + ")"; - return typebuf + name + " : " + idname + - "( affects_directly_visible: " + - (affects_directly_visible ? "true" - : "false") + ")"; -; + const string idname = this->owner->name; + const string typebuf = "" + to_string(static_cast<int>(type)) + ")"; + return typebuf + name + " : " + idname + + "( affects_directly_visible: " + (affects_directly_visible ? "true" : "false") + ")"; + ; } OperationNode *ComponentNode::find_operation(OperationIDKey key) const { - OperationNode *node = NULL; - if (operations_map != NULL) { - node = (OperationNode *)BLI_ghash_lookup(operations_map, &key); - } - else { - for (OperationNode *op_node : operations) { - if (op_node->opcode == key.opcode && - op_node->name_tag == key.name_tag && - STREQ(op_node->name.c_str(), key.name)) - { - node = op_node; - break; - } - } - } - return node; + OperationNode *node = NULL; + if (operations_map != NULL) { + node = (OperationNode *)BLI_ghash_lookup(operations_map, &key); + } + else { + for (OperationNode *op_node : operations) { + if (op_node->opcode == key.opcode && op_node->name_tag == key.name_tag && + STREQ(op_node->name.c_str(), key.name)) { + node = op_node; + break; + } + } + } + return node; } OperationNode *ComponentNode::find_operation(OperationCode opcode, - const char *name, - int name_tag) const + const char *name, + int name_tag) const { - OperationIDKey key(opcode, name, name_tag); - return find_operation(key); + OperationIDKey key(opcode, name, name_tag); + return find_operation(key); } OperationNode *ComponentNode::get_operation(OperationIDKey key) const { - OperationNode *node = find_operation(key); - if (node == NULL) { - fprintf(stderr, "%s: find_operation(%s) failed\n", - this->identifier().c_str(), key.identifier().c_str()); - BLI_assert(!"Request for non-existing operation, should not happen"); - return NULL; - } - return node; + OperationNode *node = find_operation(key); + if (node == NULL) { + fprintf(stderr, + "%s: find_operation(%s) failed\n", + this->identifier().c_str(), + key.identifier().c_str()); + BLI_assert(!"Request for non-existing operation, should not happen"); + return NULL; + } + return node; } OperationNode *ComponentNode::get_operation(OperationCode opcode, - const char *name, - int name_tag) const + const char *name, + int name_tag) const { - OperationIDKey key(opcode, name, name_tag); - return get_operation(key); + OperationIDKey key(opcode, name, name_tag); + return get_operation(key); } bool ComponentNode::has_operation(OperationIDKey key) const { - return find_operation(key) != NULL; + return find_operation(key) != NULL; } -bool ComponentNode::has_operation(OperationCode opcode, - const char *name, - int name_tag) const +bool ComponentNode::has_operation(OperationCode opcode, const char *name, int name_tag) const { - OperationIDKey key(opcode, name, name_tag); - return has_operation(key); + OperationIDKey key(opcode, name, name_tag); + return has_operation(key); } -OperationNode *ComponentNode::add_operation(const DepsEvalOperationCb& op, - OperationCode opcode, - const char *name, - int name_tag) +OperationNode *ComponentNode::add_operation(const DepsEvalOperationCb &op, + OperationCode opcode, + const char *name, + int name_tag) { - OperationNode *op_node = find_operation(opcode, name, name_tag); - if (!op_node) { - DepsNodeFactory *factory = type_get_factory(NodeType::OPERATION); - op_node = (OperationNode *)factory->create_node(this->owner->id_orig, "", name); - - /* register opnode in this component's operation set */ - OperationIDKey *key = OBJECT_GUARDED_NEW(OperationIDKey, opcode, name, name_tag); - BLI_ghash_insert(operations_map, key, op_node); - - /* set backlink */ - op_node->owner = this; - } - else { - fprintf(stderr, "add_operation: Operation already exists - %s has %s at %p\n", - this->identifier().c_str(), op_node->identifier().c_str(), op_node); - BLI_assert(!"Should not happen!"); - } - - /* attach extra data */ - op_node->evaluate = op; - op_node->opcode = opcode; - op_node->name = name; - op_node->name_tag = name_tag; - - return op_node; + OperationNode *op_node = find_operation(opcode, name, name_tag); + if (!op_node) { + DepsNodeFactory *factory = type_get_factory(NodeType::OPERATION); + op_node = (OperationNode *)factory->create_node(this->owner->id_orig, "", name); + + /* register opnode in this component's operation set */ + OperationIDKey *key = OBJECT_GUARDED_NEW(OperationIDKey, opcode, name, name_tag); + BLI_ghash_insert(operations_map, key, op_node); + + /* set backlink */ + op_node->owner = this; + } + else { + fprintf(stderr, + "add_operation: Operation already exists - %s has %s at %p\n", + this->identifier().c_str(), + op_node->identifier().c_str(), + op_node); + BLI_assert(!"Should not happen!"); + } + + /* attach extra data */ + op_node->evaluate = op; + op_node->opcode = opcode; + op_node->name = name; + op_node->name_tag = name_tag; + + return op_node; } void ComponentNode::set_entry_operation(OperationNode *op_node) { - BLI_assert(entry_operation == NULL); - entry_operation = op_node; + BLI_assert(entry_operation == NULL); + entry_operation = op_node; } void ComponentNode::set_exit_operation(OperationNode *op_node) { - BLI_assert(exit_operation == NULL); - exit_operation = op_node; + BLI_assert(exit_operation == NULL); + exit_operation = op_node; } void ComponentNode::clear_operations() { - if (operations_map != NULL) { - BLI_ghash_clear(operations_map, - comp_node_hash_key_free, - comp_node_hash_value_free); - } - for (OperationNode *op_node : operations) { - OBJECT_GUARDED_DELETE(op_node, OperationNode); - } - operations.clear(); + if (operations_map != NULL) { + BLI_ghash_clear(operations_map, comp_node_hash_key_free, comp_node_hash_value_free); + } + for (OperationNode *op_node : operations) { + OBJECT_GUARDED_DELETE(op_node, OperationNode); + } + operations.clear(); } void ComponentNode::tag_update(Depsgraph *graph, eUpdateSource source) { - OperationNode *entry_op = get_entry_operation(); - if (entry_op != NULL && entry_op->flag & DEPSOP_FLAG_NEEDS_UPDATE) { - return; - } - for (OperationNode *op_node : operations) { - op_node->tag_update(graph, source); - } - // It is possible that tag happens before finalization. - if (operations_map != NULL) { - GHASH_FOREACH_BEGIN(OperationNode *, op_node, operations_map) - { - op_node->tag_update(graph, source); - } - GHASH_FOREACH_END(); - } + OperationNode *entry_op = get_entry_operation(); + if (entry_op != NULL && entry_op->flag & DEPSOP_FLAG_NEEDS_UPDATE) { + return; + } + for (OperationNode *op_node : operations) { + op_node->tag_update(graph, source); + } + // It is possible that tag happens before finalization. + if (operations_map != NULL) { + GHASH_FOREACH_BEGIN (OperationNode *, op_node, operations_map) { + op_node->tag_update(graph, source); + } + GHASH_FOREACH_END(); + } } OperationNode *ComponentNode::get_entry_operation() { - if (entry_operation) { - return entry_operation; - } - else if (operations_map != NULL && BLI_ghash_len(operations_map) == 1) { - OperationNode *op_node = NULL; - /* TODO(sergey): This is somewhat slow. */ - GHASH_FOREACH_BEGIN(OperationNode *, tmp, operations_map) - { - op_node = tmp; - } - GHASH_FOREACH_END(); - /* Cache for the subsequent usage. */ - entry_operation = op_node; - return op_node; - } - else if (operations.size() == 1) { - return operations[0]; - } - return NULL; + if (entry_operation) { + return entry_operation; + } + else if (operations_map != NULL && BLI_ghash_len(operations_map) == 1) { + OperationNode *op_node = NULL; + /* TODO(sergey): This is somewhat slow. */ + GHASH_FOREACH_BEGIN (OperationNode *, tmp, operations_map) { + op_node = tmp; + } + GHASH_FOREACH_END(); + /* Cache for the subsequent usage. */ + entry_operation = op_node; + return op_node; + } + else if (operations.size() == 1) { + return operations[0]; + } + return NULL; } OperationNode *ComponentNode::get_exit_operation() { - if (exit_operation) { - return exit_operation; - } - else if (operations_map != NULL && BLI_ghash_len(operations_map) == 1) { - OperationNode *op_node = NULL; - /* TODO(sergey): This is somewhat slow. */ - GHASH_FOREACH_BEGIN(OperationNode *, tmp, operations_map) - { - op_node = tmp; - } - GHASH_FOREACH_END(); - /* Cache for the subsequent usage. */ - exit_operation = op_node; - return op_node; - } - else if (operations.size() == 1) { - return operations[0]; - } - return NULL; + if (exit_operation) { + return exit_operation; + } + else if (operations_map != NULL && BLI_ghash_len(operations_map) == 1) { + OperationNode *op_node = NULL; + /* TODO(sergey): This is somewhat slow. */ + GHASH_FOREACH_BEGIN (OperationNode *, tmp, operations_map) { + op_node = tmp; + } + GHASH_FOREACH_END(); + /* Cache for the subsequent usage. */ + exit_operation = op_node; + return op_node; + } + else if (operations.size() == 1) { + return operations[0]; + } + return NULL; } void ComponentNode::finalize_build(Depsgraph * /*graph*/) { - operations.reserve(BLI_ghash_len(operations_map)); - GHASH_FOREACH_BEGIN(OperationNode *, op_node, operations_map) - { - operations.push_back(op_node); - } - GHASH_FOREACH_END(); - BLI_ghash_free(operations_map, - comp_node_hash_key_free, - NULL); - operations_map = NULL; + operations.reserve(BLI_ghash_len(operations_map)); + GHASH_FOREACH_BEGIN (OperationNode *, op_node, operations_map) { + operations.push_back(op_node); + } + GHASH_FOREACH_END(); + BLI_ghash_free(operations_map, comp_node_hash_key_free, NULL); + operations_map = NULL; } /* Bone Component ========================================= */ @@ -356,69 +329,69 @@ void ComponentNode::finalize_build(Depsgraph * /*graph*/) /* Initialize 'bone component' node - from pointer data given */ void BoneComponentNode::init(const ID *id, const char *subdata) { - /* generic component-node... */ - ComponentNode::init(id, subdata); + /* generic component-node... */ + ComponentNode::init(id, subdata); - /* name of component comes is bone name */ - /* TODO(sergey): This sets name to an empty string because subdata is - * empty. Is it a bug? */ - //this->name = subdata; + /* name of component comes is bone name */ + /* TODO(sergey): This sets name to an empty string because subdata is + * empty. Is it a bug? */ + //this->name = subdata; - /* bone-specific node data */ - Object *object = (Object *)id; - this->pchan = BKE_pose_channel_find_name(object->pose, subdata); + /* bone-specific node data */ + Object *object = (Object *)id; + this->pchan = BKE_pose_channel_find_name(object->pose, subdata); } /* Register all components. =============================== */ -DEG_COMPONENT_NODE_DEFINE(Animation, ANIMATION, ID_RECALC_ANIMATION); +DEG_COMPONENT_NODE_DEFINE(Animation, ANIMATION, ID_RECALC_ANIMATION); /* TODO(sergey): Is this a correct tag? */ -DEG_COMPONENT_NODE_DEFINE(BatchCache, BATCH_CACHE, ID_RECALC_SHADING); -DEG_COMPONENT_NODE_DEFINE(Bone, BONE, ID_RECALC_GEOMETRY); -DEG_COMPONENT_NODE_DEFINE(Cache, CACHE, 0); -DEG_COMPONENT_NODE_DEFINE(CopyOnWrite, COPY_ON_WRITE, ID_RECALC_COPY_ON_WRITE); -DEG_COMPONENT_NODE_DEFINE(Geometry, GEOMETRY, ID_RECALC_GEOMETRY); -DEG_COMPONENT_NODE_DEFINE(LayerCollections, LAYER_COLLECTIONS, 0); -DEG_COMPONENT_NODE_DEFINE(Parameters, PARAMETERS, 0); -DEG_COMPONENT_NODE_DEFINE(Particles, PARTICLE_SYSTEM, ID_RECALC_GEOMETRY); -DEG_COMPONENT_NODE_DEFINE(ParticleSettings, PARTICLE_SETTINGS, 0); -DEG_COMPONENT_NODE_DEFINE(PointCache, POINT_CACHE, 0); -DEG_COMPONENT_NODE_DEFINE(Pose, EVAL_POSE, ID_RECALC_GEOMETRY); -DEG_COMPONENT_NODE_DEFINE(Proxy, PROXY, ID_RECALC_GEOMETRY); -DEG_COMPONENT_NODE_DEFINE(Sequencer, SEQUENCER, 0); -DEG_COMPONENT_NODE_DEFINE(Shading, SHADING, ID_RECALC_SHADING); +DEG_COMPONENT_NODE_DEFINE(BatchCache, BATCH_CACHE, ID_RECALC_SHADING); +DEG_COMPONENT_NODE_DEFINE(Bone, BONE, ID_RECALC_GEOMETRY); +DEG_COMPONENT_NODE_DEFINE(Cache, CACHE, 0); +DEG_COMPONENT_NODE_DEFINE(CopyOnWrite, COPY_ON_WRITE, ID_RECALC_COPY_ON_WRITE); +DEG_COMPONENT_NODE_DEFINE(Geometry, GEOMETRY, ID_RECALC_GEOMETRY); +DEG_COMPONENT_NODE_DEFINE(LayerCollections, LAYER_COLLECTIONS, 0); +DEG_COMPONENT_NODE_DEFINE(Parameters, PARAMETERS, 0); +DEG_COMPONENT_NODE_DEFINE(Particles, PARTICLE_SYSTEM, ID_RECALC_GEOMETRY); +DEG_COMPONENT_NODE_DEFINE(ParticleSettings, PARTICLE_SETTINGS, 0); +DEG_COMPONENT_NODE_DEFINE(PointCache, POINT_CACHE, 0); +DEG_COMPONENT_NODE_DEFINE(Pose, EVAL_POSE, ID_RECALC_GEOMETRY); +DEG_COMPONENT_NODE_DEFINE(Proxy, PROXY, ID_RECALC_GEOMETRY); +DEG_COMPONENT_NODE_DEFINE(Sequencer, SEQUENCER, 0); +DEG_COMPONENT_NODE_DEFINE(Shading, SHADING, ID_RECALC_SHADING); DEG_COMPONENT_NODE_DEFINE(ShadingParameters, SHADING_PARAMETERS, ID_RECALC_SHADING); -DEG_COMPONENT_NODE_DEFINE(Transform, TRANSFORM, ID_RECALC_TRANSFORM); -DEG_COMPONENT_NODE_DEFINE(ObjectFromLayer, OBJECT_FROM_LAYER, 0); -DEG_COMPONENT_NODE_DEFINE(Dupli, DUPLI, 0); -DEG_COMPONENT_NODE_DEFINE(Synchronization, SYNCHRONIZATION, 0); -DEG_COMPONENT_NODE_DEFINE(GenericDatablock, GENERIC_DATABLOCK, 0); +DEG_COMPONENT_NODE_DEFINE(Transform, TRANSFORM, ID_RECALC_TRANSFORM); +DEG_COMPONENT_NODE_DEFINE(ObjectFromLayer, OBJECT_FROM_LAYER, 0); +DEG_COMPONENT_NODE_DEFINE(Dupli, DUPLI, 0); +DEG_COMPONENT_NODE_DEFINE(Synchronization, SYNCHRONIZATION, 0); +DEG_COMPONENT_NODE_DEFINE(GenericDatablock, GENERIC_DATABLOCK, 0); /* Node Types Register =================================== */ void deg_register_component_depsnodes() { - register_node_typeinfo(&DNTI_ANIMATION); - register_node_typeinfo(&DNTI_BONE); - register_node_typeinfo(&DNTI_CACHE); - register_node_typeinfo(&DNTI_BATCH_CACHE); - register_node_typeinfo(&DNTI_COPY_ON_WRITE); - register_node_typeinfo(&DNTI_GEOMETRY); - register_node_typeinfo(&DNTI_LAYER_COLLECTIONS); - register_node_typeinfo(&DNTI_PARAMETERS); - register_node_typeinfo(&DNTI_PARTICLE_SYSTEM); - register_node_typeinfo(&DNTI_PARTICLE_SETTINGS); - register_node_typeinfo(&DNTI_POINT_CACHE); - register_node_typeinfo(&DNTI_PROXY); - register_node_typeinfo(&DNTI_EVAL_POSE); - register_node_typeinfo(&DNTI_SEQUENCER); - register_node_typeinfo(&DNTI_SHADING); - register_node_typeinfo(&DNTI_SHADING_PARAMETERS); - register_node_typeinfo(&DNTI_TRANSFORM); - register_node_typeinfo(&DNTI_OBJECT_FROM_LAYER); - register_node_typeinfo(&DNTI_DUPLI); - register_node_typeinfo(&DNTI_SYNCHRONIZATION); - register_node_typeinfo(&DNTI_GENERIC_DATABLOCK); + register_node_typeinfo(&DNTI_ANIMATION); + register_node_typeinfo(&DNTI_BONE); + register_node_typeinfo(&DNTI_CACHE); + register_node_typeinfo(&DNTI_BATCH_CACHE); + register_node_typeinfo(&DNTI_COPY_ON_WRITE); + register_node_typeinfo(&DNTI_GEOMETRY); + register_node_typeinfo(&DNTI_LAYER_COLLECTIONS); + register_node_typeinfo(&DNTI_PARAMETERS); + register_node_typeinfo(&DNTI_PARTICLE_SYSTEM); + register_node_typeinfo(&DNTI_PARTICLE_SETTINGS); + register_node_typeinfo(&DNTI_POINT_CACHE); + register_node_typeinfo(&DNTI_PROXY); + register_node_typeinfo(&DNTI_EVAL_POSE); + register_node_typeinfo(&DNTI_SEQUENCER); + register_node_typeinfo(&DNTI_SHADING); + register_node_typeinfo(&DNTI_SHADING_PARAMETERS); + register_node_typeinfo(&DNTI_TRANSFORM); + register_node_typeinfo(&DNTI_OBJECT_FROM_LAYER); + register_node_typeinfo(&DNTI_DUPLI); + register_node_typeinfo(&DNTI_SYNCHRONIZATION); + register_node_typeinfo(&DNTI_GENERIC_DATABLOCK); } } // namespace DEG diff --git a/source/blender/depsgraph/intern/node/deg_node_component.h b/source/blender/depsgraph/intern/node/deg_node_component.h index 4392a120935..038b5917a86 100644 --- a/source/blender/depsgraph/intern/node/deg_node_component.h +++ b/source/blender/depsgraph/intern/node/deg_node_component.h @@ -42,134 +42,130 @@ struct OperationNode; /* ID Component - Base type for all components */ struct ComponentNode : public Node { - /* Key used to look up operations within a component */ - struct OperationIDKey - { - OperationCode opcode; - const char *name; - int name_tag; - - OperationIDKey(); - OperationIDKey(OperationCode opcode); - OperationIDKey(OperationCode opcode, - const char *name, - int name_tag); - - string identifier() const; - bool operator==(const OperationIDKey &other) const; - }; - - /* Typedef for container of operations */ - ComponentNode(); - ~ComponentNode(); - - void init(const ID *id, const char *subdata) override; - - virtual string identifier() const override; - - /* Find an existing operation, if requested operation does not exist - * NULL will be returned. */ - OperationNode *find_operation(OperationIDKey key) const; - OperationNode *find_operation(OperationCode opcode, - const char *name, - int name_tag) const; - - /* Find an existing operation, will throw an assert() if it does not exist. */ - OperationNode *get_operation(OperationIDKey key) const; - OperationNode *get_operation(OperationCode opcode, - const char *name, - int name_tag) const; - - /* Check operation exists and return it. */ - bool has_operation(OperationIDKey key) const; - bool has_operation(OperationCode opcode, - const char *name, - int name_tag) const; - - /** - * Create a new node for representing an operation and add this to graph - * \warning If an existing node is found, it will be modified. This helps - * when node may have been partially created earlier (e.g. parent ref before - * parent item is added) - * - * \param type: Operation node type (corresponding to context/component that - * it operates in) - * \param optype: Role that operation plays within component - * (i.e. where in eval process) - * \param op: The operation to perform - * \param name: Identifier for operation - used to find/locate it again */ - OperationNode *add_operation(const DepsEvalOperationCb& op, - OperationCode opcode, - const char *name, - int name_tag); - - /* Entry/exit operations management. - * - * Use those instead of direct set since this will perform sanity checks. */ - void set_entry_operation(OperationNode *op_node); - void set_exit_operation(OperationNode *op_node); - - void clear_operations(); - - virtual void tag_update(Depsgraph *graph, eUpdateSource source) override; - - virtual OperationNode *get_entry_operation() override; - virtual OperationNode *get_exit_operation() override; - - void finalize_build(Depsgraph *graph); - - IDNode *owner; - - /* ** Inner nodes for this component ** */ - - /* Operations stored as a hash map, for faster build. - * This hash map will be freed when graph is fully built. */ - GHash *operations_map; - - /* This is a "normal" list of operations, used by evaluation - * and other routines after construction. */ - vector<OperationNode *> operations; - - OperationNode *entry_operation; - OperationNode *exit_operation; - - virtual bool depends_on_cow() { return true; } - - /* Denotes whether COW component is to be tagged when this component - * is tagged for update. */ - virtual bool need_tag_cow_before_update() { return true; } - - /* Denotes whether this component affects (possibly indirectly) on a - * directly visible object. */ - bool affects_directly_visible; + /* Key used to look up operations within a component */ + struct OperationIDKey { + OperationCode opcode; + const char *name; + int name_tag; + + OperationIDKey(); + OperationIDKey(OperationCode opcode); + OperationIDKey(OperationCode opcode, const char *name, int name_tag); + + string identifier() const; + bool operator==(const OperationIDKey &other) const; + }; + + /* Typedef for container of operations */ + ComponentNode(); + ~ComponentNode(); + + void init(const ID *id, const char *subdata) override; + + virtual string identifier() const override; + + /* Find an existing operation, if requested operation does not exist + * NULL will be returned. */ + OperationNode *find_operation(OperationIDKey key) const; + OperationNode *find_operation(OperationCode opcode, const char *name, int name_tag) const; + + /* Find an existing operation, will throw an assert() if it does not exist. */ + OperationNode *get_operation(OperationIDKey key) const; + OperationNode *get_operation(OperationCode opcode, const char *name, int name_tag) const; + + /* Check operation exists and return it. */ + bool has_operation(OperationIDKey key) const; + bool has_operation(OperationCode opcode, const char *name, int name_tag) const; + + /** + * Create a new node for representing an operation and add this to graph + * \warning If an existing node is found, it will be modified. This helps + * when node may have been partially created earlier (e.g. parent ref before + * parent item is added) + * + * \param type: Operation node type (corresponding to context/component that + * it operates in) + * \param optype: Role that operation plays within component + * (i.e. where in eval process) + * \param op: The operation to perform + * \param name: Identifier for operation - used to find/locate it again */ + OperationNode *add_operation(const DepsEvalOperationCb &op, + OperationCode opcode, + const char *name, + int name_tag); + + /* Entry/exit operations management. + * + * Use those instead of direct set since this will perform sanity checks. */ + void set_entry_operation(OperationNode *op_node); + void set_exit_operation(OperationNode *op_node); + + void clear_operations(); + + virtual void tag_update(Depsgraph *graph, eUpdateSource source) override; + + virtual OperationNode *get_entry_operation() override; + virtual OperationNode *get_exit_operation() override; + + void finalize_build(Depsgraph *graph); + + IDNode *owner; + + /* ** Inner nodes for this component ** */ + + /* Operations stored as a hash map, for faster build. + * This hash map will be freed when graph is fully built. */ + GHash *operations_map; + + /* This is a "normal" list of operations, used by evaluation + * and other routines after construction. */ + vector<OperationNode *> operations; + + OperationNode *entry_operation; + OperationNode *exit_operation; + + virtual bool depends_on_cow() + { + return true; + } + + /* Denotes whether COW component is to be tagged when this component + * is tagged for update. */ + virtual bool need_tag_cow_before_update() + { + return true; + } + + /* Denotes whether this component affects (possibly indirectly) on a + * directly visible object. */ + bool affects_directly_visible; }; /* ---------------------------------------- */ -#define DEG_COMPONENT_NODE_DEFINE_TYPEINFO(\ - NodeType, type_, type_name_, id_recalc_tag) \ - const Node::TypeInfo NodeType::typeinfo = \ - Node::TypeInfo(type_, type_name_, id_recalc_tag) +#define DEG_COMPONENT_NODE_DEFINE_TYPEINFO(NodeType, type_, type_name_, id_recalc_tag) \ + const Node::TypeInfo NodeType::typeinfo = Node::TypeInfo(type_, type_name_, 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 ## ComponentNode, \ - NodeType:: NAME, \ - #name " Component", \ - id_recalc_tag) ; \ - static DepsNodeFactoryImpl<name ## ComponentNode> DNTI_ ## NAME - -#define DEG_COMPONENT_NODE_DECLARE_GENERIC(name) \ - struct name ## ComponentNode : public ComponentNode { \ - DEG_COMPONENT_NODE_DECLARE; \ - } - -#define DEG_COMPONENT_NODE_DECLARE_NO_COW_TAG_ON_UPDATE(name) \ - struct name ## ComponentNode : public ComponentNode { \ - DEG_COMPONENT_NODE_DECLARE; \ - virtual bool need_tag_cow_before_update() { return false; } \ - } +#define DEG_COMPONENT_NODE_DEFINE(name, NAME, id_recalc_tag) \ + DEG_COMPONENT_NODE_DEFINE_TYPEINFO( \ + name##ComponentNode, NodeType::NAME, #name " Component", id_recalc_tag); \ + static DepsNodeFactoryImpl<name##ComponentNode> DNTI_##NAME + +#define DEG_COMPONENT_NODE_DECLARE_GENERIC(name) \ + struct name##ComponentNode : public ComponentNode { \ + DEG_COMPONENT_NODE_DECLARE; \ + } + +#define DEG_COMPONENT_NODE_DECLARE_NO_COW_TAG_ON_UPDATE(name) \ + struct name##ComponentNode : public ComponentNode { \ + DEG_COMPONENT_NODE_DECLARE; \ + virtual bool need_tag_cow_before_update() \ + { \ + return false; \ + } \ + } DEG_COMPONENT_NODE_DECLARE_GENERIC(Animation); DEG_COMPONENT_NODE_DECLARE_NO_COW_TAG_ON_UPDATE(BatchCache); @@ -194,11 +190,11 @@ DEG_COMPONENT_NODE_DECLARE_GENERIC(GenericDatablock); /* Bone Component */ struct BoneComponentNode : public ComponentNode { - void init(const ID *id, const char *subdata); + void init(const ID *id, const char *subdata); - struct bPoseChannel *pchan; /* the bone that this component represents */ + struct bPoseChannel *pchan; /* the bone that this component represents */ - DEG_COMPONENT_NODE_DECLARE; + DEG_COMPONENT_NODE_DECLARE; }; void deg_register_component_depsnodes(); diff --git a/source/blender/depsgraph/intern/node/deg_node_factory.cc b/source/blender/depsgraph/intern/node/deg_node_factory.cc index e6f2fd1841d..4a11ed2a4fb 100644 --- a/source/blender/depsgraph/intern/node/deg_node_factory.cc +++ b/source/blender/depsgraph/intern/node/deg_node_factory.cc @@ -26,21 +26,20 @@ namespace DEG { /* Global type registry */ -static DepsNodeFactory * -node_typeinfo_registry[static_cast<int>(NodeType::NUM_TYPES)] = {NULL}; +static DepsNodeFactory *node_typeinfo_registry[static_cast<int>(NodeType::NUM_TYPES)] = {NULL}; void register_node_typeinfo(DepsNodeFactory *factory) { - BLI_assert(factory != NULL); - const int type_as_int = static_cast<int>(factory->type()); - node_typeinfo_registry[type_as_int] = factory; + BLI_assert(factory != NULL); + const int type_as_int = static_cast<int>(factory->type()); + node_typeinfo_registry[type_as_int] = factory; } DepsNodeFactory *type_get_factory(const NodeType type) { - /* Look up type - at worst, it doesn't exist in table yet, and we fail. */ - const int type_as_int = static_cast<int>(type); - return node_typeinfo_registry[type_as_int]; + /* Look up type - at worst, it doesn't exist in table yet, and we fail. */ + const int type_as_int = static_cast<int>(type); + return node_typeinfo_registry[type_as_int]; } } // namespace DEG diff --git a/source/blender/depsgraph/intern/node/deg_node_factory.h b/source/blender/depsgraph/intern/node/deg_node_factory.h index 29a3eebba2b..38487e7f979 100644 --- a/source/blender/depsgraph/intern/node/deg_node_factory.h +++ b/source/blender/depsgraph/intern/node/deg_node_factory.h @@ -33,26 +33,21 @@ struct ID; namespace DEG { struct DepsNodeFactory { - virtual NodeType type() const = 0; - virtual const char *type_name() const = 0; + virtual NodeType type() const = 0; + virtual const char *type_name() const = 0; - virtual int id_recalc_tag() const = 0; + virtual int id_recalc_tag() const = 0; - virtual Node *create_node(const ID *id, - const char *subdata, - const char *name) const = 0; + virtual Node *create_node(const ID *id, const char *subdata, const char *name) const = 0; }; -template <class ModeObjectType> -struct DepsNodeFactoryImpl : public DepsNodeFactory { - virtual NodeType type() const override; - virtual const char *type_name() const override; +template<class ModeObjectType> struct DepsNodeFactoryImpl : public DepsNodeFactory { + virtual NodeType type() const override; + virtual const char *type_name() const override; - virtual int id_recalc_tag() const override; + virtual int id_recalc_tag() const override; - virtual Node *create_node(const ID *id, - const char *subdata, - const char *name) const override; + virtual Node *create_node(const ID *id, const char *subdata, const char *name) const override; }; /* Register typeinfo */ diff --git a/source/blender/depsgraph/intern/node/deg_node_factory_impl.h b/source/blender/depsgraph/intern/node/deg_node_factory_impl.h index f2d478d4c16..ad25ffdf26c 100644 --- a/source/blender/depsgraph/intern/node/deg_node_factory_impl.h +++ b/source/blender/depsgraph/intern/node/deg_node_factory_impl.h @@ -29,38 +29,38 @@ struct ID; namespace DEG { -template <class ModeObjectType> -NodeType DepsNodeFactoryImpl<ModeObjectType>::type() const +template<class ModeObjectType> NodeType DepsNodeFactoryImpl<ModeObjectType>::type() const { - return ModeObjectType::typeinfo.type; + return ModeObjectType::typeinfo.type; } -template <class ModeObjectType> -const char *DepsNodeFactoryImpl<ModeObjectType>::type_name() const { - return ModeObjectType::typeinfo.type_name; +template<class ModeObjectType> const char *DepsNodeFactoryImpl<ModeObjectType>::type_name() const +{ + return ModeObjectType::typeinfo.type_name; } -template <class ModeObjectType> -int DepsNodeFactoryImpl<ModeObjectType>::id_recalc_tag() const { - return ModeObjectType::typeinfo.id_recalc_tag; +template<class ModeObjectType> int DepsNodeFactoryImpl<ModeObjectType>::id_recalc_tag() const +{ + return ModeObjectType::typeinfo.id_recalc_tag; } -template <class ModeObjectType> -Node *DepsNodeFactoryImpl<ModeObjectType>::create_node( - const ID *id, const char *subdata, const char *name) const +template<class ModeObjectType> +Node *DepsNodeFactoryImpl<ModeObjectType>::create_node(const ID *id, + const char *subdata, + const char *name) const { - Node *node = OBJECT_GUARDED_NEW(ModeObjectType); - /* Populate base node settings. */ - node->type = type(); - /* Set name if provided, or use default type name. */ - if (name[0] != '\0') { - node->name = name; - } - else { - node->name = type_name(); - } - node->init(id, subdata); - return node; + Node *node = OBJECT_GUARDED_NEW(ModeObjectType); + /* Populate base node settings. */ + node->type = type(); + /* Set name if provided, or use default type name. */ + if (name[0] != '\0') { + node->name = name; + } + else { + node->name = type_name(); + } + node->init(id, subdata); + return node; } } // namespace DEG diff --git a/source/blender/depsgraph/intern/node/deg_node_id.cc b/source/blender/depsgraph/intern/node/deg_node_id.cc index d391f727d35..77e8f4f37e0 100644 --- a/source/blender/depsgraph/intern/node/deg_node_id.cc +++ b/source/blender/depsgraph/intern/node/deg_node_id.cc @@ -24,7 +24,7 @@ #include "intern/node/deg_node_id.h" #include <stdio.h> -#include <cstring> /* required for STREQ later on. */ +#include <cstring> /* required for STREQ later on. */ #include "BLI_utildefines.h" #include "BLI_ghash.h" @@ -49,198 +49,188 @@ namespace DEG { const char *linkedStateAsString(eDepsNode_LinkedState_Type linked_state) { - switch (linked_state) { - case DEG_ID_LINKED_INDIRECTLY: return "INDIRECTLY"; - case DEG_ID_LINKED_VIA_SET: return "VIA_SET"; - case DEG_ID_LINKED_DIRECTLY: return "DIRECTLY"; - } - BLI_assert(!"Unhandled linked state, should never happen."); - return "UNKNOW"; + switch (linked_state) { + case DEG_ID_LINKED_INDIRECTLY: + return "INDIRECTLY"; + case DEG_ID_LINKED_VIA_SET: + return "VIA_SET"; + case DEG_ID_LINKED_DIRECTLY: + return "DIRECTLY"; + } + BLI_assert(!"Unhandled linked state, should never happen."); + return "UNKNOW"; } -IDNode::ComponentIDKey::ComponentIDKey(NodeType type, - const char *name) - : type(type), name(name) +IDNode::ComponentIDKey::ComponentIDKey(NodeType type, const char *name) : type(type), name(name) { } -bool IDNode::ComponentIDKey::operator== (const ComponentIDKey &other) const +bool IDNode::ComponentIDKey::operator==(const ComponentIDKey &other) const { - return type == other.type && - STREQ(name, other.name); + return type == other.type && STREQ(name, other.name); } static unsigned int id_deps_node_hash_key(const void *key_v) { - const IDNode::ComponentIDKey *key = - reinterpret_cast<const IDNode::ComponentIDKey *>(key_v); - const int type_as_int = static_cast<int>(key->type); - return BLI_ghashutil_combine_hash(BLI_ghashutil_uinthash(type_as_int), - BLI_ghashutil_strhash_p(key->name)); + const IDNode::ComponentIDKey *key = reinterpret_cast<const IDNode::ComponentIDKey *>(key_v); + const int type_as_int = static_cast<int>(key->type); + return BLI_ghashutil_combine_hash(BLI_ghashutil_uinthash(type_as_int), + BLI_ghashutil_strhash_p(key->name)); } static bool id_deps_node_hash_key_cmp(const void *a, const void *b) { - const IDNode::ComponentIDKey *key_a = - reinterpret_cast<const IDNode::ComponentIDKey *>(a); - const IDNode::ComponentIDKey *key_b = - reinterpret_cast<const IDNode::ComponentIDKey *>(b); - return !(*key_a == *key_b); + const IDNode::ComponentIDKey *key_a = reinterpret_cast<const IDNode::ComponentIDKey *>(a); + const IDNode::ComponentIDKey *key_b = reinterpret_cast<const IDNode::ComponentIDKey *>(b); + return !(*key_a == *key_b); } static void id_deps_node_hash_key_free(void *key_v) { - typedef IDNode::ComponentIDKey ComponentIDKey; - ComponentIDKey *key = reinterpret_cast<ComponentIDKey *>(key_v); - OBJECT_GUARDED_DELETE(key, ComponentIDKey); + typedef IDNode::ComponentIDKey ComponentIDKey; + ComponentIDKey *key = reinterpret_cast<ComponentIDKey *>(key_v); + OBJECT_GUARDED_DELETE(key, ComponentIDKey); } static void id_deps_node_hash_value_free(void *value_v) { - ComponentNode *comp_node = reinterpret_cast<ComponentNode *>(value_v); - OBJECT_GUARDED_DELETE(comp_node, ComponentNode); + ComponentNode *comp_node = reinterpret_cast<ComponentNode *>(value_v); + OBJECT_GUARDED_DELETE(comp_node, ComponentNode); } /* Initialize 'id' node - from pointer data given. */ void IDNode::init(const ID *id, const char *UNUSED(subdata)) { - BLI_assert(id != NULL); - /* Store ID-pointer. */ - id_orig = (ID *)id; - eval_flags = 0; - previous_eval_flags = 0; - customdata_masks = DEGCustomDataMeshMasks(); - previous_customdata_masks = DEGCustomDataMeshMasks(); - linked_state = DEG_ID_LINKED_INDIRECTLY; - is_directly_visible = true; - is_collection_fully_expanded = false; + BLI_assert(id != NULL); + /* Store ID-pointer. */ + id_orig = (ID *)id; + eval_flags = 0; + previous_eval_flags = 0; + customdata_masks = DEGCustomDataMeshMasks(); + previous_customdata_masks = DEGCustomDataMeshMasks(); + linked_state = DEG_ID_LINKED_INDIRECTLY; + is_directly_visible = true; + is_collection_fully_expanded = false; - visible_components_mask = 0; - previously_visible_components_mask = 0; + visible_components_mask = 0; + previously_visible_components_mask = 0; - components = BLI_ghash_new(id_deps_node_hash_key, - id_deps_node_hash_key_cmp, - "Depsgraph id components hash"); + components = BLI_ghash_new( + id_deps_node_hash_key, id_deps_node_hash_key_cmp, "Depsgraph id components hash"); } void IDNode::init_copy_on_write(ID *id_cow_hint) { - /* Create pointer as early as possible, so we can use it for function - * bindings. Rest of data we'll be copying to the new datablock when - * it is actually needed. */ - if (id_cow_hint != NULL) { - // BLI_assert(deg_copy_on_write_is_needed(id_orig)); - if (deg_copy_on_write_is_needed(id_orig)) { - id_cow = id_cow_hint; - } - else { - id_cow = id_orig; - } - } - else if (deg_copy_on_write_is_needed(id_orig)) { - id_cow = (ID *)BKE_libblock_alloc_notest(GS(id_orig->name)); - DEG_COW_PRINT("Create shallow copy for %s: id_orig=%p id_cow=%p\n", - id_orig->name, id_orig, id_cow); - deg_tag_copy_on_write_id(id_cow, id_orig); - } - else { - id_cow = id_orig; - } + /* Create pointer as early as possible, so we can use it for function + * bindings. Rest of data we'll be copying to the new datablock when + * it is actually needed. */ + if (id_cow_hint != NULL) { + // BLI_assert(deg_copy_on_write_is_needed(id_orig)); + if (deg_copy_on_write_is_needed(id_orig)) { + id_cow = id_cow_hint; + } + else { + id_cow = id_orig; + } + } + else if (deg_copy_on_write_is_needed(id_orig)) { + id_cow = (ID *)BKE_libblock_alloc_notest(GS(id_orig->name)); + DEG_COW_PRINT( + "Create shallow copy for %s: id_orig=%p id_cow=%p\n", id_orig->name, id_orig, id_cow); + deg_tag_copy_on_write_id(id_cow, id_orig); + } + else { + id_cow = id_orig; + } } /* Free 'id' node. */ IDNode::~IDNode() { - destroy(); + destroy(); } void IDNode::destroy() { - if (id_orig == NULL) { - return; - } + if (id_orig == NULL) { + return; + } - BLI_ghash_free(components, - id_deps_node_hash_key_free, - id_deps_node_hash_value_free); + BLI_ghash_free(components, id_deps_node_hash_key_free, id_deps_node_hash_value_free); - /* Free memory used by this CoW ID. */ - if (id_cow != id_orig && id_cow != NULL) { - deg_free_copy_on_write_datablock(id_cow); - MEM_freeN(id_cow); - id_cow = NULL; - DEG_COW_PRINT("Destroy CoW for %s: id_orig=%p id_cow=%p\n", - id_orig->name, id_orig, id_cow); - } + /* Free memory used by this CoW ID. */ + if (id_cow != id_orig && id_cow != NULL) { + deg_free_copy_on_write_datablock(id_cow); + MEM_freeN(id_cow); + id_cow = NULL; + DEG_COW_PRINT("Destroy CoW for %s: id_orig=%p id_cow=%p\n", id_orig->name, id_orig, id_cow); + } - /* Tag that the node is freed. */ - id_orig = NULL; + /* Tag that the node is freed. */ + id_orig = NULL; } string IDNode::identifier() const { - char orig_ptr[24], cow_ptr[24]; - BLI_snprintf(orig_ptr, sizeof(orig_ptr), "%p", id_orig); - BLI_snprintf(cow_ptr, sizeof(cow_ptr), "%p", id_cow); - return string(nodeTypeAsString(type)) + " : " + name + - " (orig: " + orig_ptr + ", eval: " + cow_ptr + - ", is_directly_visible " + (is_directly_visible ? "true" - : "false") + ")"; + char orig_ptr[24], cow_ptr[24]; + BLI_snprintf(orig_ptr, sizeof(orig_ptr), "%p", id_orig); + BLI_snprintf(cow_ptr, sizeof(cow_ptr), "%p", id_cow); + return string(nodeTypeAsString(type)) + " : " + name + " (orig: " + orig_ptr + + ", eval: " + cow_ptr + ", is_directly_visible " + + (is_directly_visible ? "true" : "false") + ")"; } ComponentNode *IDNode::find_component(NodeType type, const char *name) const { - ComponentIDKey key(type, name); - return reinterpret_cast<ComponentNode *>(BLI_ghash_lookup(components, &key)); + ComponentIDKey key(type, name); + return reinterpret_cast<ComponentNode *>(BLI_ghash_lookup(components, &key)); } ComponentNode *IDNode::add_component(NodeType type, const char *name) { - ComponentNode *comp_node = find_component(type, name); - if (!comp_node) { - DepsNodeFactory *factory = type_get_factory(type); - comp_node = (ComponentNode *)factory->create_node(this->id_orig, "", name); + ComponentNode *comp_node = find_component(type, name); + if (!comp_node) { + DepsNodeFactory *factory = type_get_factory(type); + comp_node = (ComponentNode *)factory->create_node(this->id_orig, "", name); - /* Register. */ - ComponentIDKey *key = OBJECT_GUARDED_NEW(ComponentIDKey, type, name); - BLI_ghash_insert(components, key, comp_node); - comp_node->owner = this; - } - return comp_node; + /* Register. */ + ComponentIDKey *key = OBJECT_GUARDED_NEW(ComponentIDKey, type, name); + BLI_ghash_insert(components, key, comp_node); + comp_node->owner = this; + } + return comp_node; } void IDNode::tag_update(Depsgraph *graph, eUpdateSource source) { - GHASH_FOREACH_BEGIN(ComponentNode *, comp_node, components) - { - comp_node->tag_update(graph, source); - } - GHASH_FOREACH_END(); + GHASH_FOREACH_BEGIN (ComponentNode *, comp_node, components) { + comp_node->tag_update(graph, source); + } + GHASH_FOREACH_END(); } void IDNode::finalize_build(Depsgraph *graph) { - /* Finalize build of all components. */ - GHASH_FOREACH_BEGIN(ComponentNode *, comp_node, components) - { - comp_node->finalize_build(graph); - } - GHASH_FOREACH_END(); - visible_components_mask = get_visible_components_mask(); -} - -IDComponentsMask IDNode::get_visible_components_mask() const { - IDComponentsMask result = 0; - GHASH_FOREACH_BEGIN(ComponentNode *, comp_node, components) - { - if (comp_node->affects_directly_visible) { - const int component_type_as_int = static_cast<int>(comp_node->type); - BLI_assert(component_type_as_int < 64); - result |= (1ULL << component_type_as_int); - } - } - GHASH_FOREACH_END(); - return result; + /* Finalize build of all components. */ + GHASH_FOREACH_BEGIN (ComponentNode *, comp_node, components) { + comp_node->finalize_build(graph); + } + GHASH_FOREACH_END(); + visible_components_mask = get_visible_components_mask(); +} + +IDComponentsMask IDNode::get_visible_components_mask() const +{ + IDComponentsMask result = 0; + GHASH_FOREACH_BEGIN (ComponentNode *, comp_node, components) { + if (comp_node->affects_directly_visible) { + const int component_type_as_int = static_cast<int>(comp_node->type); + BLI_assert(component_type_as_int < 64); + result |= (1ULL << component_type_as_int); + } + } + GHASH_FOREACH_END(); + return result; } } // namespace DEG diff --git a/source/blender/depsgraph/intern/node/deg_node_id.h b/source/blender/depsgraph/intern/node/deg_node_id.h index bbf671790c7..34d78e29060 100644 --- a/source/blender/depsgraph/intern/node/deg_node_id.h +++ b/source/blender/depsgraph/intern/node/deg_node_id.h @@ -35,71 +35,71 @@ typedef uint64_t IDComponentsMask; /* NOTE: We use max comparison to mark an id node that is linked more than once * So keep this enum ordered accordingly. */ enum eDepsNode_LinkedState_Type { - /* Generic indirectly linked id node. */ - DEG_ID_LINKED_INDIRECTLY = 0, - /* Id node present in the set (background) only. */ - DEG_ID_LINKED_VIA_SET = 1, - /* Id node directly linked via the SceneLayer. */ - DEG_ID_LINKED_DIRECTLY = 2, + /* Generic indirectly linked id node. */ + DEG_ID_LINKED_INDIRECTLY = 0, + /* Id node present in the set (background) only. */ + DEG_ID_LINKED_VIA_SET = 1, + /* Id node directly linked via the SceneLayer. */ + DEG_ID_LINKED_DIRECTLY = 2, }; const char *linkedStateAsString(eDepsNode_LinkedState_Type linked_state); /* ID-Block Reference */ struct IDNode : public Node { - struct ComponentIDKey { - ComponentIDKey(NodeType type, const char *name = ""); - bool operator==(const ComponentIDKey &other) const; + struct ComponentIDKey { + ComponentIDKey(NodeType type, const char *name = ""); + bool operator==(const ComponentIDKey &other) const; - NodeType type; - const char *name; - }; + NodeType type; + const char *name; + }; - virtual void init(const ID *id, const char *subdata) override; - void init_copy_on_write(ID *id_cow_hint = NULL); - ~IDNode(); - void destroy(); + virtual void init(const ID *id, const char *subdata) override; + void init_copy_on_write(ID *id_cow_hint = NULL); + ~IDNode(); + void destroy(); - virtual string identifier() const override; + virtual string identifier() const override; - ComponentNode *find_component(NodeType type, const char *name = "") const; - ComponentNode *add_component(NodeType type, const char *name = ""); + ComponentNode *find_component(NodeType type, const char *name = "") const; + ComponentNode *add_component(NodeType type, const char *name = ""); - virtual void tag_update(Depsgraph *graph, eUpdateSource source) override; + virtual void tag_update(Depsgraph *graph, eUpdateSource source) override; - void finalize_build(Depsgraph *graph); + void finalize_build(Depsgraph *graph); - IDComponentsMask get_visible_components_mask() const; + IDComponentsMask get_visible_components_mask() const; - /* ID Block referenced. */ - ID *id_orig; - ID *id_cow; + /* ID Block referenced. */ + ID *id_orig; + ID *id_cow; - /* Hash to make it faster to look up components. */ - GHash *components; + /* Hash to make it faster to look up components. */ + GHash *components; - /* Additional flags needed for scene evaluation. - * TODO(sergey): Only needed for until really granular updates - * of all the entities. */ - uint32_t eval_flags; - uint32_t previous_eval_flags; + /* Additional flags needed for scene evaluation. + * TODO(sergey): Only needed for until really granular updates + * of all the entities. */ + uint32_t eval_flags; + uint32_t previous_eval_flags; - /* Extra customdata mask which needs to be evaluated for the mesh object. */ - DEGCustomDataMeshMasks customdata_masks; - DEGCustomDataMeshMasks previous_customdata_masks; + /* Extra customdata mask which needs to be evaluated for the mesh object. */ + DEGCustomDataMeshMasks customdata_masks; + DEGCustomDataMeshMasks previous_customdata_masks; - eDepsNode_LinkedState_Type linked_state; + eDepsNode_LinkedState_Type linked_state; - /* Indicates the datablock is visible in the evaluated scene. */ - bool is_directly_visible; + /* Indicates the datablock is visible in the evaluated scene. */ + bool is_directly_visible; - /* For the collection type of ID, denotes whether collection was fully - * recursed into. */ - bool is_collection_fully_expanded; + /* For the collection type of ID, denotes whether collection was fully + * recursed into. */ + bool is_collection_fully_expanded; - IDComponentsMask visible_components_mask; - IDComponentsMask previously_visible_components_mask; + IDComponentsMask visible_components_mask; + IDComponentsMask previously_visible_components_mask; - DEG_DEPSNODE_DECLARE; + DEG_DEPSNODE_DECLARE; }; } // namespace DEG diff --git a/source/blender/depsgraph/intern/node/deg_node_operation.cc b/source/blender/depsgraph/intern/node/deg_node_operation.cc index b0b47f89acf..54a5ecef35c 100644 --- a/source/blender/depsgraph/intern/node/deg_node_operation.cc +++ b/source/blender/depsgraph/intern/node/deg_node_operation.cc @@ -37,112 +37,161 @@ namespace DEG { const char *operationCodeAsString(OperationCode opcode) { - switch (opcode) { - /* Generic Operations. */ - case OperationCode::OPERATION: return "OPERATION"; - case OperationCode::ID_PROPERTY: return "ID_PROPERTY"; - case OperationCode::PARAMETERS_ENTRY: return "PARAMETERS_ENTRY"; - case OperationCode::PARAMETERS_EVAL: return "PARAMETERS_EVAL"; - case OperationCode::PARAMETERS_EXIT: return "PARAMETERS_EXIT"; - /* Animation, Drivers, etc. */ - case OperationCode::ANIMATION_ENTRY: return "ANIMATION_ENTRY"; - case OperationCode::ANIMATION_EVAL: return "ANIMATION_EVAL"; - case OperationCode::ANIMATION_EXIT: return "ANIMATION_EXIT"; - case OperationCode::DRIVER: return "DRIVER"; - /* Scene related. */ - case OperationCode::SCENE_EVAL: return "SCENE_EVAL"; - /* Object related. */ - case OperationCode::OBJECT_BASE_FLAGS: return "OBJECT_BASE_FLAGS"; - /* Transform. */ - case OperationCode::TRANSFORM_INIT: return "TRANSFORM_INIT"; - case OperationCode::TRANSFORM_LOCAL: return "TRANSFORM_LOCAL"; - case OperationCode::TRANSFORM_PARENT: return "TRANSFORM_PARENT"; - case OperationCode::TRANSFORM_CONSTRAINTS: - return "TRANSFORM_CONSTRAINTS"; - case OperationCode::TRANSFORM_FINAL: return "TRANSFORM_FINAL"; - case OperationCode::TRANSFORM_EVAL: return "TRANSFORM_EVAL"; - case OperationCode::TRANSFORM_SIMULATION_INIT: - return "TRANSFORM_SIMULATION_INIT"; - /* Rigid body. */ - case OperationCode::RIGIDBODY_REBUILD: return "RIGIDBODY_REBUILD"; - case OperationCode::RIGIDBODY_SIM: return "RIGIDBODY_SIM"; - 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_EVAL_DONE: return "GEOMETRY_EVAL_DONE"; - case OperationCode::GEOMETRY_SHAPEKEY: return "GEOMETRY_SHAPEKEY"; - /* Object data. */ - case OperationCode::LIGHT_PROBE_EVAL: return "LIGHT_PROBE_EVAL"; - case OperationCode::SPEAKER_EVAL: return "SPEAKER_EVAL"; - case OperationCode::ARMATURE_EVAL: return "ARMATURE_EVAL"; - /* Pose. */ - case OperationCode::POSE_INIT: return "POSE_INIT"; - case OperationCode::POSE_INIT_IK: return "POSE_INIT_IK"; - case OperationCode::POSE_CLEANUP: return "POSE_CLEANUP"; - case OperationCode::POSE_DONE: return "POSE_DONE"; - case OperationCode::POSE_IK_SOLVER: return "POSE_IK_SOLVER"; - case OperationCode::POSE_SPLINE_IK_SOLVER: - return "POSE_SPLINE_IK_SOLVER"; - /* Bone. */ - case OperationCode::BONE_LOCAL: return "BONE_LOCAL"; - case OperationCode::BONE_POSE_PARENT: return "BONE_POSE_PARENT"; - case OperationCode::BONE_CONSTRAINTS: return "BONE_CONSTRAINTS"; - case OperationCode::BONE_READY: return "BONE_READY"; - case OperationCode::BONE_DONE: return "BONE_DONE"; - case OperationCode::BONE_SEGMENTS: return "BONE_SEGMENTS"; - /* Particle System. */ - case OperationCode::PARTICLE_SYSTEM_INIT: return "PARTICLE_SYSTEM_INIT"; - case OperationCode::PARTICLE_SYSTEM_EVAL: return "PARTICLE_SYSTEM_EVAL"; - case OperationCode::PARTICLE_SYSTEM_DONE: return "PARTICLE_SYSTEM_DONE"; - /* Particles Settings. */ - case OperationCode::PARTICLE_SETTINGS_INIT: - return "PARTICLE_SETTINGS_INIT"; - case OperationCode::PARTICLE_SETTINGS_EVAL: - return "PARTICLE_SETTINGS_EVAL"; - case OperationCode::PARTICLE_SETTINGS_RESET: - return "PARTICLE_SETTINGS_RESET"; - /* Point Cache. */ - case OperationCode::POINT_CACHE_RESET: return "POINT_CACHE_RESET"; - /* File cache. */ - case OperationCode::FILE_CACHE_UPDATE: return "FILE_CACHE_UPDATE"; - /* Batch cache. */ - case OperationCode::GEOMETRY_SELECT_UPDATE: - return "GEOMETRY_SELECT_UPDATE"; - /* Masks. */ - case OperationCode::MASK_ANIMATION: return "MASK_ANIMATION"; - case OperationCode::MASK_EVAL: return "MASK_EVAL"; - /* Collections. */ - case OperationCode::VIEW_LAYER_EVAL: return "VIEW_LAYER_EVAL"; - /* Copy on write. */ - case OperationCode::COPY_ON_WRITE: return "COPY_ON_WRITE"; - /* Shading. */ - case OperationCode::SHADING: return "SHADING"; - case OperationCode::MATERIAL_UPDATE: return "MATERIAL_UPDATE"; - case OperationCode::WORLD_UPDATE: return "WORLD_UPDATE"; - /* Movie clip. */ - case OperationCode::MOVIECLIP_EVAL: return "MOVIECLIP_EVAL"; - case OperationCode::MOVIECLIP_SELECT_UPDATE: - return "MOVIECLIP_SELECT_UPDATE"; - /* Image. */ - case OperationCode::IMAGE_ANIMATION: return "IMAGE_ANIMATION"; - /* Synchronization. */ - case OperationCode::SYNCHRONIZE_TO_ORIGINAL: - return "SYNCHRONIZE_TO_ORIGINAL"; - /* Generic datablock. */ - case OperationCode::GENERIC_DATABLOCK_UPDATE: - return "GENERIC_DATABLOCK_UPDATE"; - /* instancing/duplication. */ - case OperationCode::DUPLI: return "DUPLI"; - } - BLI_assert(!"Unhandled operation code, should never happen."); - return "UNKNOWN"; + switch (opcode) { + /* Generic Operations. */ + case OperationCode::OPERATION: + return "OPERATION"; + case OperationCode::ID_PROPERTY: + return "ID_PROPERTY"; + case OperationCode::PARAMETERS_ENTRY: + return "PARAMETERS_ENTRY"; + case OperationCode::PARAMETERS_EVAL: + return "PARAMETERS_EVAL"; + case OperationCode::PARAMETERS_EXIT: + return "PARAMETERS_EXIT"; + /* Animation, Drivers, etc. */ + case OperationCode::ANIMATION_ENTRY: + return "ANIMATION_ENTRY"; + case OperationCode::ANIMATION_EVAL: + return "ANIMATION_EVAL"; + case OperationCode::ANIMATION_EXIT: + return "ANIMATION_EXIT"; + case OperationCode::DRIVER: + return "DRIVER"; + /* Scene related. */ + case OperationCode::SCENE_EVAL: + return "SCENE_EVAL"; + /* Object related. */ + case OperationCode::OBJECT_BASE_FLAGS: + return "OBJECT_BASE_FLAGS"; + /* Transform. */ + case OperationCode::TRANSFORM_INIT: + return "TRANSFORM_INIT"; + case OperationCode::TRANSFORM_LOCAL: + return "TRANSFORM_LOCAL"; + case OperationCode::TRANSFORM_PARENT: + return "TRANSFORM_PARENT"; + case OperationCode::TRANSFORM_CONSTRAINTS: + return "TRANSFORM_CONSTRAINTS"; + case OperationCode::TRANSFORM_FINAL: + return "TRANSFORM_FINAL"; + case OperationCode::TRANSFORM_EVAL: + return "TRANSFORM_EVAL"; + case OperationCode::TRANSFORM_SIMULATION_INIT: + return "TRANSFORM_SIMULATION_INIT"; + /* Rigid body. */ + case OperationCode::RIGIDBODY_REBUILD: + return "RIGIDBODY_REBUILD"; + case OperationCode::RIGIDBODY_SIM: + return "RIGIDBODY_SIM"; + 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_EVAL_DONE: + return "GEOMETRY_EVAL_DONE"; + case OperationCode::GEOMETRY_SHAPEKEY: + return "GEOMETRY_SHAPEKEY"; + /* Object data. */ + case OperationCode::LIGHT_PROBE_EVAL: + return "LIGHT_PROBE_EVAL"; + case OperationCode::SPEAKER_EVAL: + return "SPEAKER_EVAL"; + case OperationCode::ARMATURE_EVAL: + return "ARMATURE_EVAL"; + /* Pose. */ + case OperationCode::POSE_INIT: + return "POSE_INIT"; + case OperationCode::POSE_INIT_IK: + return "POSE_INIT_IK"; + case OperationCode::POSE_CLEANUP: + return "POSE_CLEANUP"; + case OperationCode::POSE_DONE: + return "POSE_DONE"; + case OperationCode::POSE_IK_SOLVER: + return "POSE_IK_SOLVER"; + case OperationCode::POSE_SPLINE_IK_SOLVER: + return "POSE_SPLINE_IK_SOLVER"; + /* Bone. */ + case OperationCode::BONE_LOCAL: + return "BONE_LOCAL"; + case OperationCode::BONE_POSE_PARENT: + return "BONE_POSE_PARENT"; + case OperationCode::BONE_CONSTRAINTS: + return "BONE_CONSTRAINTS"; + case OperationCode::BONE_READY: + return "BONE_READY"; + case OperationCode::BONE_DONE: + return "BONE_DONE"; + case OperationCode::BONE_SEGMENTS: + return "BONE_SEGMENTS"; + /* Particle System. */ + case OperationCode::PARTICLE_SYSTEM_INIT: + return "PARTICLE_SYSTEM_INIT"; + case OperationCode::PARTICLE_SYSTEM_EVAL: + return "PARTICLE_SYSTEM_EVAL"; + case OperationCode::PARTICLE_SYSTEM_DONE: + return "PARTICLE_SYSTEM_DONE"; + /* Particles Settings. */ + case OperationCode::PARTICLE_SETTINGS_INIT: + return "PARTICLE_SETTINGS_INIT"; + case OperationCode::PARTICLE_SETTINGS_EVAL: + return "PARTICLE_SETTINGS_EVAL"; + case OperationCode::PARTICLE_SETTINGS_RESET: + return "PARTICLE_SETTINGS_RESET"; + /* Point Cache. */ + case OperationCode::POINT_CACHE_RESET: + return "POINT_CACHE_RESET"; + /* File cache. */ + case OperationCode::FILE_CACHE_UPDATE: + return "FILE_CACHE_UPDATE"; + /* Batch cache. */ + case OperationCode::GEOMETRY_SELECT_UPDATE: + return "GEOMETRY_SELECT_UPDATE"; + /* Masks. */ + case OperationCode::MASK_ANIMATION: + return "MASK_ANIMATION"; + case OperationCode::MASK_EVAL: + return "MASK_EVAL"; + /* Collections. */ + case OperationCode::VIEW_LAYER_EVAL: + return "VIEW_LAYER_EVAL"; + /* Copy on write. */ + case OperationCode::COPY_ON_WRITE: + return "COPY_ON_WRITE"; + /* Shading. */ + case OperationCode::SHADING: + return "SHADING"; + case OperationCode::MATERIAL_UPDATE: + return "MATERIAL_UPDATE"; + case OperationCode::WORLD_UPDATE: + return "WORLD_UPDATE"; + /* Movie clip. */ + case OperationCode::MOVIECLIP_EVAL: + return "MOVIECLIP_EVAL"; + case OperationCode::MOVIECLIP_SELECT_UPDATE: + return "MOVIECLIP_SELECT_UPDATE"; + /* Image. */ + case OperationCode::IMAGE_ANIMATION: + return "IMAGE_ANIMATION"; + /* Synchronization. */ + case OperationCode::SYNCHRONIZE_TO_ORIGINAL: + return "SYNCHRONIZE_TO_ORIGINAL"; + /* Generic datablock. */ + case OperationCode::GENERIC_DATABLOCK_UPDATE: + return "GENERIC_DATABLOCK_UPDATE"; + /* instancing/duplication. */ + case OperationCode::DUPLI: + return "DUPLI"; + } + BLI_assert(!"Unhandled operation code, should never happen."); + return "UNKNOWN"; } -OperationNode::OperationNode() : - name_tag(-1), - flag(0) +OperationNode::OperationNode() : name_tag(-1), flag(0) { } @@ -152,52 +201,52 @@ OperationNode::~OperationNode() string OperationNode::identifier() const { - return string(operationCodeAsString(opcode)) + "(" + name + ")"; + return string(operationCodeAsString(opcode)) + "(" + name + ")"; } /* Full node identifier, including owner name. * used for logging and debug prints. */ string OperationNode::full_identifier() const { - string owner_str = ""; - if (owner->type == NodeType::BONE) { - owner_str = string(owner->owner->name) + "." + owner->name; - } - else { - owner_str = owner->owner->name; - } - return owner_str + "." + identifier(); + string owner_str = ""; + if (owner->type == NodeType::BONE) { + owner_str = string(owner->owner->name) + "." + owner->name; + } + else { + owner_str = owner->owner->name; + } + return owner_str + "." + identifier(); } void OperationNode::tag_update(Depsgraph *graph, eUpdateSource source) { - if ((flag & DEPSOP_FLAG_NEEDS_UPDATE) == 0) { - graph->add_entry_tag(this); - } - /* Tag for update, but also note that this was the source of an update. */ - flag |= (DEPSOP_FLAG_NEEDS_UPDATE | DEPSOP_FLAG_DIRECTLY_MODIFIED); - switch (source) { - case DEG_UPDATE_SOURCE_TIME: - case DEG_UPDATE_SOURCE_RELATIONS: - case DEG_UPDATE_SOURCE_VISIBILITY: - /* Currently nothing. */ - break; - case DEG_UPDATE_SOURCE_USER_EDIT: - flag |= DEPSOP_FLAG_USER_MODIFIED; - break; - } + if ((flag & DEPSOP_FLAG_NEEDS_UPDATE) == 0) { + graph->add_entry_tag(this); + } + /* Tag for update, but also note that this was the source of an update. */ + flag |= (DEPSOP_FLAG_NEEDS_UPDATE | DEPSOP_FLAG_DIRECTLY_MODIFIED); + switch (source) { + case DEG_UPDATE_SOURCE_TIME: + case DEG_UPDATE_SOURCE_RELATIONS: + case DEG_UPDATE_SOURCE_VISIBILITY: + /* Currently nothing. */ + break; + case DEG_UPDATE_SOURCE_USER_EDIT: + flag |= DEPSOP_FLAG_USER_MODIFIED; + break; + } } void OperationNode::set_as_entry() { - BLI_assert(owner != NULL); - owner->set_entry_operation(this); + BLI_assert(owner != NULL); + owner->set_entry_operation(this); } void OperationNode::set_as_exit() { - BLI_assert(owner != NULL); - owner->set_exit_operation(this); + BLI_assert(owner != NULL); + owner->set_exit_operation(this); } DEG_DEPSNODE_DEFINE(OperationNode, NodeType::OPERATION, "Operation"); @@ -205,7 +254,7 @@ static DepsNodeFactoryImpl<OperationNode> DNTI_OPERATION; void deg_register_operation_depsnodes() { - register_node_typeinfo(&DNTI_OPERATION); + register_node_typeinfo(&DNTI_OPERATION); } } // namespace DEG diff --git a/source/blender/depsgraph/intern/node/deg_node_operation.h b/source/blender/depsgraph/intern/node/deg_node_operation.h index 56207b08d4a..c959f7f34e0 100644 --- a/source/blender/depsgraph/intern/node/deg_node_operation.h +++ b/source/blender/depsgraph/intern/node/deg_node_operation.h @@ -40,158 +40,158 @@ typedef function<void(struct ::Depsgraph *)> DepsEvalOperationCb; /* Identifiers for common operations (as an enum). */ enum class OperationCode { - /* Generic Operations. -------------------------------------------------- */ - - /* Placeholder for operations which don't need special mention */ - OPERATION = 0, - - /* Generic parameters evaluation. */ - ID_PROPERTY, - PARAMETERS_ENTRY, - PARAMETERS_EVAL, - PARAMETERS_EXIT, - - /* Animation, Drivers, etc. --------------------------------------------- */ - /* NLA + Action */ - ANIMATION_ENTRY, - ANIMATION_EVAL, - ANIMATION_EXIT, - /* Driver */ - DRIVER, - - /* Scene related. ------------------------------------------------------- */ - SCENE_EVAL, - - /* Object related. ------------------------------------------------------ */ - OBJECT_BASE_FLAGS, - - /* Transform. ----------------------------------------------------------- */ - /* Transform entry point. */ - TRANSFORM_INIT, - /* Local transforms only */ - TRANSFORM_LOCAL, - /* Parenting */ - TRANSFORM_PARENT, - /* Constraints */ - TRANSFORM_CONSTRAINTS, - /* Handle object-level updates, mainly proxies hacks and recalc flags. */ - TRANSFORM_EVAL, - /* Initializes transformation for simulation. - * For example, ensures point cache is properly reset before doing rigid - * body simulation. */ - TRANSFORM_SIMULATION_INIT, - /* Transform exit point */ - TRANSFORM_FINAL, - - /* Rigid body. ---------------------------------------------------------- */ - /* Perform Simulation */ - RIGIDBODY_REBUILD, - RIGIDBODY_SIM, - /* Copy results to object */ - RIGIDBODY_TRANSFORM_COPY, - - /* 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 geometry is completely done.. */ - GEOMETRY_EVAL_DONE, - /* Evaluation of a shape key. - * NOTE: Currently only for object data datablocks. */ - GEOMETRY_SHAPEKEY, - - /* Object data. --------------------------------------------------------- */ - LIGHT_PROBE_EVAL, - SPEAKER_EVAL, - ARMATURE_EVAL, - - /* Pose. ---------------------------------------------------------------- */ - /* Init pose, clear flags, etc. */ - POSE_INIT, - /* Initialize IK solver related pose stuff. */ - POSE_INIT_IK, - /* Pose is evaluated, and runtime data can be freed. */ - POSE_CLEANUP, - /* Pose has been fully evaluated and ready to be used by others. */ - POSE_DONE, - /* IK/Spline Solvers */ - POSE_IK_SOLVER, - POSE_SPLINE_IK_SOLVER, - - /* Bone. ---------------------------------------------------------------- */ - /* Bone local transforms - entry point */ - BONE_LOCAL, - /* Pose-space conversion (includes parent + restpose, */ - BONE_POSE_PARENT, - /* Constraints */ - BONE_CONSTRAINTS, - /* Bone transforms are ready - * - * - "READY" This (internal, noop is used to signal that all pre-IK - * operations are done. Its role is to help mediate situations - * where cyclic relations may otherwise form (i.e. one bone in - * chain targeting another in same chain, - * - * - "DONE" This noop is used to signal that the bone's final pose - * transform can be read by others. */ - // TODO: deform mats could get calculated in the final_transform ops... - BONE_READY, - BONE_DONE, - /* B-Bone segment shape computation (after DONE) */ - BONE_SEGMENTS, - - /* Particle System. ----------------------------------------------------- */ - PARTICLE_SYSTEM_INIT, - PARTICLE_SYSTEM_EVAL, - PARTICLE_SYSTEM_DONE, - - /* Particle Settings. --------------------------------------------------- */ - PARTICLE_SETTINGS_INIT, - PARTICLE_SETTINGS_EVAL, - PARTICLE_SETTINGS_RESET, - - /* Point Cache. --------------------------------------------------------- */ - POINT_CACHE_RESET, - - /* File cache. ---------------------------------------------------------- */ - FILE_CACHE_UPDATE, - - /* Collections. --------------------------------------------------------- */ - VIEW_LAYER_EVAL, - - /* Copy on Write. ------------------------------------------------------- */ - COPY_ON_WRITE, - - /* Shading. ------------------------------------------------------------- */ - SHADING, - MATERIAL_UPDATE, - WORLD_UPDATE, - - /* Batch caches. -------------------------------------------------------- */ - GEOMETRY_SELECT_UPDATE, - - /* Masks. --------------------------------------------------------------- */ - MASK_ANIMATION, - MASK_EVAL, - - /* Movie clips. --------------------------------------------------------- */ - MOVIECLIP_EVAL, - MOVIECLIP_SELECT_UPDATE, - - /* Images. -------------------------------------------------------------- */ - IMAGE_ANIMATION, - - /* Synchronization clips. ----------------------------------------------- */ - SYNCHRONIZE_TO_ORIGINAL, - - /* Generic datablock ---------------------------------------------------- */ - GENERIC_DATABLOCK_UPDATE, - - /* Duplication/instancing system. --------------------------------------- */ - DUPLI, + /* Generic Operations. -------------------------------------------------- */ + + /* Placeholder for operations which don't need special mention */ + OPERATION = 0, + + /* Generic parameters evaluation. */ + ID_PROPERTY, + PARAMETERS_ENTRY, + PARAMETERS_EVAL, + PARAMETERS_EXIT, + + /* Animation, Drivers, etc. --------------------------------------------- */ + /* NLA + Action */ + ANIMATION_ENTRY, + ANIMATION_EVAL, + ANIMATION_EXIT, + /* Driver */ + DRIVER, + + /* Scene related. ------------------------------------------------------- */ + SCENE_EVAL, + + /* Object related. ------------------------------------------------------ */ + OBJECT_BASE_FLAGS, + + /* Transform. ----------------------------------------------------------- */ + /* Transform entry point. */ + TRANSFORM_INIT, + /* Local transforms only */ + TRANSFORM_LOCAL, + /* Parenting */ + TRANSFORM_PARENT, + /* Constraints */ + TRANSFORM_CONSTRAINTS, + /* Handle object-level updates, mainly proxies hacks and recalc flags. */ + TRANSFORM_EVAL, + /* Initializes transformation for simulation. + * For example, ensures point cache is properly reset before doing rigid + * body simulation. */ + TRANSFORM_SIMULATION_INIT, + /* Transform exit point */ + TRANSFORM_FINAL, + + /* Rigid body. ---------------------------------------------------------- */ + /* Perform Simulation */ + RIGIDBODY_REBUILD, + RIGIDBODY_SIM, + /* Copy results to object */ + RIGIDBODY_TRANSFORM_COPY, + + /* 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 geometry is completely done.. */ + GEOMETRY_EVAL_DONE, + /* Evaluation of a shape key. + * NOTE: Currently only for object data datablocks. */ + GEOMETRY_SHAPEKEY, + + /* Object data. --------------------------------------------------------- */ + LIGHT_PROBE_EVAL, + SPEAKER_EVAL, + ARMATURE_EVAL, + + /* Pose. ---------------------------------------------------------------- */ + /* Init pose, clear flags, etc. */ + POSE_INIT, + /* Initialize IK solver related pose stuff. */ + POSE_INIT_IK, + /* Pose is evaluated, and runtime data can be freed. */ + POSE_CLEANUP, + /* Pose has been fully evaluated and ready to be used by others. */ + POSE_DONE, + /* IK/Spline Solvers */ + POSE_IK_SOLVER, + POSE_SPLINE_IK_SOLVER, + + /* Bone. ---------------------------------------------------------------- */ + /* Bone local transforms - entry point */ + BONE_LOCAL, + /* Pose-space conversion (includes parent + restpose, */ + BONE_POSE_PARENT, + /* Constraints */ + BONE_CONSTRAINTS, + /* Bone transforms are ready + * + * - "READY" This (internal, noop is used to signal that all pre-IK + * operations are done. Its role is to help mediate situations + * where cyclic relations may otherwise form (i.e. one bone in + * chain targeting another in same chain, + * + * - "DONE" This noop is used to signal that the bone's final pose + * transform can be read by others. */ + // TODO: deform mats could get calculated in the final_transform ops... + BONE_READY, + BONE_DONE, + /* B-Bone segment shape computation (after DONE) */ + BONE_SEGMENTS, + + /* Particle System. ----------------------------------------------------- */ + PARTICLE_SYSTEM_INIT, + PARTICLE_SYSTEM_EVAL, + PARTICLE_SYSTEM_DONE, + + /* Particle Settings. --------------------------------------------------- */ + PARTICLE_SETTINGS_INIT, + PARTICLE_SETTINGS_EVAL, + PARTICLE_SETTINGS_RESET, + + /* Point Cache. --------------------------------------------------------- */ + POINT_CACHE_RESET, + + /* File cache. ---------------------------------------------------------- */ + FILE_CACHE_UPDATE, + + /* Collections. --------------------------------------------------------- */ + VIEW_LAYER_EVAL, + + /* Copy on Write. ------------------------------------------------------- */ + COPY_ON_WRITE, + + /* Shading. ------------------------------------------------------------- */ + SHADING, + MATERIAL_UPDATE, + WORLD_UPDATE, + + /* Batch caches. -------------------------------------------------------- */ + GEOMETRY_SELECT_UPDATE, + + /* Masks. --------------------------------------------------------------- */ + MASK_ANIMATION, + MASK_EVAL, + + /* Movie clips. --------------------------------------------------------- */ + MOVIECLIP_EVAL, + MOVIECLIP_SELECT_UPDATE, + + /* Images. -------------------------------------------------------------- */ + IMAGE_ANIMATION, + + /* Synchronization clips. ----------------------------------------------- */ + SYNCHRONIZE_TO_ORIGINAL, + + /* Generic datablock ---------------------------------------------------- */ + GENERIC_DATABLOCK_UPDATE, + + /* Duplication/instancing system. --------------------------------------- */ + DUPLI, }; const char *operationCodeAsString(OperationCode opcode); @@ -199,58 +199,63 @@ const char *operationCodeAsString(OperationCode opcode); * NOTE: IS a bit shifts to allow usage as an accumulated. bitmask. */ enum OperationFlag { - /* Node needs to be updated. */ - DEPSOP_FLAG_NEEDS_UPDATE = (1 << 0), - /* Node was directly modified, causing need for update. */ - DEPSOP_FLAG_DIRECTLY_MODIFIED = (1 << 1), - /* Node was updated due to user input. */ - DEPSOP_FLAG_USER_MODIFIED = (1 << 2), - - /* Set of flags which gets flushed along the relations. */ - DEPSOP_FLAG_FLUSH = (DEPSOP_FLAG_USER_MODIFIED), + /* Node needs to be updated. */ + DEPSOP_FLAG_NEEDS_UPDATE = (1 << 0), + /* Node was directly modified, causing need for update. */ + DEPSOP_FLAG_DIRECTLY_MODIFIED = (1 << 1), + /* Node was updated due to user input. */ + DEPSOP_FLAG_USER_MODIFIED = (1 << 2), + + /* Set of flags which gets flushed along the relations. */ + DEPSOP_FLAG_FLUSH = (DEPSOP_FLAG_USER_MODIFIED), }; /* Atomic Operation - Base type for all operations */ struct OperationNode : public Node { - OperationNode(); - ~OperationNode(); + OperationNode(); + ~OperationNode(); - virtual string identifier() const override; - string full_identifier() const; + virtual string identifier() const override; + string full_identifier() const; - virtual void tag_update(Depsgraph *graph, eUpdateSource source) override; + virtual void tag_update(Depsgraph *graph, eUpdateSource source) override; - bool is_noop() const { return (bool)evaluate == false; } + bool is_noop() const + { + return (bool)evaluate == false; + } - virtual OperationNode *get_entry_operation() override { - return this; - } - virtual OperationNode *get_exit_operation() override { - return this; - } + virtual OperationNode *get_entry_operation() override + { + return this; + } + virtual OperationNode *get_exit_operation() override + { + return this; + } - /* Set this operation as component's entry/exit operation. */ - void set_as_entry(); - void set_as_exit(); + /* Set this operation as component's entry/exit operation. */ + void set_as_entry(); + void set_as_exit(); - /* Component that contains the operation. */ - ComponentNode *owner; + /* Component that contains the operation. */ + ComponentNode *owner; - /* Callback for operation. */ - DepsEvalOperationCb evaluate; + /* Callback for operation. */ + DepsEvalOperationCb evaluate; - /* How many inlinks are we still waiting on before we can be evaluated. */ - uint32_t num_links_pending; - bool scheduled; + /* How many inlinks are we still waiting on before we can be evaluated. */ + uint32_t num_links_pending; + bool scheduled; - /* Identifier for the operation being performed. */ - OperationCode opcode; - int name_tag; + /* Identifier for the operation being performed. */ + OperationCode opcode; + int name_tag; - /* (OperationFlag) extra settings affecting evaluation. */ - int flag; + /* (OperationFlag) extra settings affecting evaluation. */ + int flag; - DEG_DEPSNODE_DECLARE; + DEG_DEPSNODE_DECLARE; }; void deg_register_operation_depsnodes(); diff --git a/source/blender/depsgraph/intern/node/deg_node_time.cc b/source/blender/depsgraph/intern/node/deg_node_time.cc index 24d99d23c25..cae98ef56c0 100644 --- a/source/blender/depsgraph/intern/node/deg_node_time.cc +++ b/source/blender/depsgraph/intern/node/deg_node_time.cc @@ -31,10 +31,10 @@ namespace DEG { void TimeSourceNode::tag_update(Depsgraph *graph, eUpdateSource /*source*/) { - for (Relation *rel : outlinks) { - Node *node = rel->to; - node->tag_update(graph, DEG_UPDATE_SOURCE_TIME); - } + for (Relation *rel : outlinks) { + Node *node = rel->to; + node->tag_update(graph, DEG_UPDATE_SOURCE_TIME); + } } } // namespace DEG diff --git a/source/blender/depsgraph/intern/node/deg_node_time.h b/source/blender/depsgraph/intern/node/deg_node_time.h index 44b67ebc307..684414f7780 100644 --- a/source/blender/depsgraph/intern/node/deg_node_time.h +++ b/source/blender/depsgraph/intern/node/deg_node_time.h @@ -29,17 +29,17 @@ namespace DEG { /* Time Source Node. */ struct TimeSourceNode : public Node { - /* New "current time". */ - float cfra; + /* New "current time". */ + float cfra; - /* time-offset relative to the "official" time source that this one has. */ - float offset; + /* time-offset relative to the "official" time source that this one has. */ + float offset; - // TODO: evaluate() operation needed + // TODO: evaluate() operation needed - virtual void tag_update(Depsgraph *graph, eUpdateSource source) override; + virtual void tag_update(Depsgraph *graph, eUpdateSource source) override; - DEG_DEPSNODE_DECLARE; + DEG_DEPSNODE_DECLARE; }; } // namespace DEG |