diff options
Diffstat (limited to 'source/blender/depsgraph/intern')
96 files changed, 779 insertions, 559 deletions
diff --git a/source/blender/depsgraph/intern/builder/deg_builder.cc b/source/blender/depsgraph/intern/builder/deg_builder.cc index 82f3ea7d182..39de6054615 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder.cc @@ -50,7 +50,8 @@ #include "DEG_depsgraph.h" -namespace DEG { +namespace blender { +namespace deg { bool deg_check_id_in_depsgraph(const Depsgraph *graph, ID *id_orig) { @@ -240,4 +241,5 @@ void deg_graph_build_finalize(Main *bmain, Depsgraph *graph) } } -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/builder/deg_builder.h b/source/blender/depsgraph/intern/builder/deg_builder.h index 2db861b6fca..36b6b1bf17d 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder.h +++ b/source/blender/depsgraph/intern/builder/deg_builder.h @@ -29,7 +29,8 @@ struct Main; struct Object; struct bPoseChannel; -namespace DEG { +namespace blender { +namespace deg { struct Depsgraph; class DepsgraphBuilderCache; @@ -58,4 +59,5 @@ bool deg_check_id_in_depsgraph(const Depsgraph *graph, ID *id_orig); bool deg_check_base_in_depsgraph(const Depsgraph *graph, Base *base); void deg_graph_build_finalize(Main *bmain, Depsgraph *graph); -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/builder/deg_builder_cache.cc b/source/blender/depsgraph/intern/builder/deg_builder_cache.cc index 104676f7ab6..2faedc4fcd6 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_cache.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_cache.cc @@ -31,7 +31,8 @@ #include "BKE_animsys.h" -namespace DEG { +namespace blender { +namespace deg { /* Animated property storage. */ @@ -155,21 +156,16 @@ DepsgraphBuilderCache::DepsgraphBuilderCache() DepsgraphBuilderCache::~DepsgraphBuilderCache() { - for (AnimatedPropertyStorageMap::value_type &iter : animated_property_storage_map_) { - AnimatedPropertyStorage *animated_property_storage = iter.second; + for (AnimatedPropertyStorage *animated_property_storage : + animated_property_storage_map_.values()) { OBJECT_GUARDED_DELETE(animated_property_storage, AnimatedPropertyStorage); } } AnimatedPropertyStorage *DepsgraphBuilderCache::ensureAnimatedPropertyStorage(ID *id) { - AnimatedPropertyStorageMap::iterator it = animated_property_storage_map_.find(id); - if (it != animated_property_storage_map_.end()) { - return it->second; - } - AnimatedPropertyStorage *animated_property_storage = OBJECT_GUARDED_NEW(AnimatedPropertyStorage); - animated_property_storage_map_.insert(make_pair(id, animated_property_storage)); - return animated_property_storage; + return animated_property_storage_map_.lookup_or_add_cb( + id, []() { return OBJECT_GUARDED_NEW(AnimatedPropertyStorage); }); } AnimatedPropertyStorage *DepsgraphBuilderCache::ensureInitializedAnimatedPropertyStorage(ID *id) @@ -182,4 +178,5 @@ AnimatedPropertyStorage *DepsgraphBuilderCache::ensureInitializedAnimatedPropert return animated_property_storage; } -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/builder/deg_builder_cache.h b/source/blender/depsgraph/intern/builder/deg_builder_cache.h index bb4e1f5c96a..6e159f55c94 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_cache.h +++ b/source/blender/depsgraph/intern/builder/deg_builder_cache.h @@ -31,7 +31,8 @@ struct ID; struct PointerRNA; struct PropertyRNA; -namespace DEG { +namespace blender { +namespace deg { class DepsgraphBuilderCache; @@ -45,8 +46,6 @@ class AnimatedPropertyID { AnimatedPropertyID(ID *id, StructRNA *type, void *data, const char *property_name); uint32_t hash() const; - - bool operator<(const AnimatedPropertyID &other) const; friend bool operator==(const AnimatedPropertyID &a, const AnimatedPropertyID &b); /* Corresponds to PointerRNA.data. */ @@ -73,8 +72,6 @@ class AnimatedPropertyStorage { Set<AnimatedPropertyID> animated_properties_set; }; -typedef map<ID *, AnimatedPropertyStorage *> AnimatedPropertyStorageMap; - /* Cached data which can be re-used by multiple builders. */ class DepsgraphBuilderCache { public: @@ -100,7 +97,8 @@ class DepsgraphBuilderCache { return animated_property_storage->isPropertyAnimated(args...); } - AnimatedPropertyStorageMap animated_property_storage_map_; + Map<ID *, AnimatedPropertyStorage *> animated_property_storage_map_; }; -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/builder/deg_builder_cycle.cc b/source/blender/depsgraph/intern/builder/deg_builder_cycle.cc index 6deecfde9e1..f8c7737c843 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_cycle.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_cycle.cc @@ -37,7 +37,8 @@ #include "intern/depsgraph.h" #include "intern/depsgraph_relation.h" -namespace DEG { +namespace blender { +namespace deg { namespace { @@ -234,4 +235,5 @@ void deg_graph_detect_cycles(Depsgraph *graph) } } -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/builder/deg_builder_cycle.h b/source/blender/depsgraph/intern/builder/deg_builder_cycle.h index aafdcdbea04..f9674e0e60d 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_cycle.h +++ b/source/blender/depsgraph/intern/builder/deg_builder_cycle.h @@ -23,11 +23,13 @@ #pragma once -namespace DEG { +namespace blender { +namespace deg { struct Depsgraph; /* Detect and solve dependency cycles. */ void deg_graph_detect_cycles(Depsgraph *graph); -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/builder/deg_builder_map.cc b/source/blender/depsgraph/intern/builder/deg_builder_map.cc index 4bca4f037b0..e605e83a862 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_map.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_map.cc @@ -25,7 +25,8 @@ #include "DNA_ID.h" -namespace DEG { +namespace blender { +namespace deg { BuilderMap::BuilderMap() { @@ -42,33 +43,21 @@ bool BuilderMap::checkIsBuilt(ID *id, int tag) const void BuilderMap::tagBuild(ID *id, int tag) { - IDTagMap::iterator it = id_tags_.find(id); - if (it == id_tags_.end()) { - id_tags_.insert(make_pair(id, tag)); - return; - } - it->second |= tag; + id_tags_.lookup_or_add(id, 0) |= tag; } bool BuilderMap::checkIsBuiltAndTag(ID *id, int tag) { - IDTagMap::iterator it = id_tags_.find(id); - if (it == id_tags_.end()) { - id_tags_.insert(make_pair(id, tag)); - return false; - } - const bool result = (it->second & tag) == tag; - it->second |= tag; + int &id_tag = id_tags_.lookup_or_add(id, 0); + const bool result = (id_tag & tag) == tag; + id_tag |= tag; return result; } int BuilderMap::getIDTag(ID *id) const { - IDTagMap::const_iterator it = id_tags_.find(id); - if (it == id_tags_.end()) { - return 0; - } - return it->second; + return id_tags_.lookup_default(id, 0); } -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/builder/deg_builder_map.h b/source/blender/depsgraph/intern/builder/deg_builder_map.h index 65b493e2467..5dfc3297b3e 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_map.h +++ b/source/blender/depsgraph/intern/builder/deg_builder_map.h @@ -27,7 +27,8 @@ struct ID; -namespace DEG { +namespace blender { +namespace deg { class BuilderMap { public: @@ -75,8 +76,8 @@ class BuilderMap { protected: int getIDTag(ID *id) const; - typedef map<ID *, int> IDTagMap; - IDTagMap id_tags_; + Map<ID *, int> id_tags_; }; -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc index 513472f6ec9..f5cc5963253 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc @@ -119,7 +119,8 @@ #include "intern/node/deg_node_id.h" #include "intern/node/deg_node_operation.h" -namespace DEG { +namespace blender { +namespace deg { /* ************ */ /* Node Builder */ @@ -594,7 +595,7 @@ void DepsgraphNodeBuilder::build_object(int base_index, } id_node->has_base |= (base_index != -1); /* Various flags, flushing from bases/collections. */ - build_object_flags(base_index, object, linked_state); + build_object_from_layer(base_index, object, linked_state); /* Transform. */ build_object_transform(object); /* Parent. */ @@ -662,6 +663,21 @@ void DepsgraphNodeBuilder::build_object(int base_index, function_bind(BKE_object_sync_to_original, _1, object_cow)); } +void DepsgraphNodeBuilder::build_object_from_layer(int base_index, + Object *object, + eDepsNode_LinkedState_Type linked_state) +{ + + OperationNode *entry_node = add_operation_node( + &object->id, NodeType::OBJECT_FROM_LAYER, OperationCode::OBJECT_FROM_LAYER_ENTRY); + entry_node->set_as_entry(); + OperationNode *exit_node = add_operation_node( + &object->id, NodeType::OBJECT_FROM_LAYER, OperationCode::OBJECT_FROM_LAYER_EXIT); + exit_node->set_as_exit(); + + build_object_flags(base_index, object, linked_state); +} + void DepsgraphNodeBuilder::build_object_flags(int base_index, Object *object, eDepsNode_LinkedState_Type linked_state) @@ -733,7 +749,7 @@ void DepsgraphNodeBuilder::build_object_data(Object *object, bool is_object_visi break; case OB_ARMATURE: if (ID_IS_LINKED(object) && object->proxy_from != nullptr) { - build_proxy_rig(object); + build_proxy_rig(object, is_object_visible); } else { build_rig(object, is_object_visible); @@ -1884,4 +1900,5 @@ void DepsgraphNodeBuilder::constraint_walk(bConstraint * /*con*/, } } -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h index 8c0e486ec04..256fa3450a6 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h @@ -64,7 +64,8 @@ struct bNodeTree; struct bPoseChannel; struct bSound; -namespace DEG { +namespace blender { +namespace deg { struct ComponentNode; struct Depsgraph; @@ -168,6 +169,9 @@ class DepsgraphNodeBuilder : public DepsgraphBuilder { virtual void build_object_proxy_from(Object *object, bool is_object_visible); virtual void build_object_proxy_group(Object *object, bool is_object_visible); virtual void build_object_instance_collection(Object *object, bool is_object_visible); + virtual void build_object_from_layer(int base_index, + Object *object, + eDepsNode_LinkedState_Type linked_state); virtual void build_object_flags(int base_index, Object *object, eDepsNode_LinkedState_Type linked_state); @@ -200,7 +204,7 @@ class DepsgraphNodeBuilder : public DepsgraphBuilder { virtual void build_ik_pose(Object *object, bPoseChannel *pchan, bConstraint *con); virtual void build_splineik_pose(Object *object, bPoseChannel *pchan, bConstraint *con); virtual void build_rig(Object *object, bool is_object_visible); - virtual void build_proxy_rig(Object *object); + virtual void build_proxy_rig(Object *object, bool is_object_visible); virtual void build_armature(bArmature *armature); virtual void build_armature_bones(ListBase *bones); virtual void build_shapekeys(Key *key); @@ -287,4 +291,5 @@ class DepsgraphNodeBuilder : public DepsgraphBuilder { BuilderMap built_map_; }; -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc index ab0a5c13321..62282ac4d37 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc @@ -54,7 +54,8 @@ #include "intern/node/deg_node_component.h" #include "intern/node/deg_node_operation.h" -namespace DEG { +namespace blender { +namespace deg { void DepsgraphNodeBuilder::build_pose_constraints(Object *object, bPoseChannel *pchan, @@ -283,7 +284,7 @@ void DepsgraphNodeBuilder::build_rig(Object *object, bool is_object_visible) } } -void DepsgraphNodeBuilder::build_proxy_rig(Object *object) +void DepsgraphNodeBuilder::build_proxy_rig(Object *object, bool is_object_visible) { bArmature *armature = (bArmature *)object->data; OperationNode *op_node; @@ -326,6 +327,11 @@ void DepsgraphNodeBuilder::build_proxy_rig(Object *object) &object->id, NodeType::PARAMETERS, OperationCode::PARAMETERS_EVAL, nullptr, pchan->name); } + /* Custom shape. */ + if (pchan->custom != nullptr) { + build_object(-1, pchan->custom, DEG_ID_LINKED_INDIRECTLY, is_object_visible); + } + pchan_index++; } op_node = add_operation_node(&object->id, @@ -339,4 +345,5 @@ void DepsgraphNodeBuilder::build_proxy_rig(Object *object) op_node->set_as_exit(); } -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes_scene.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes_scene.cc index 60e843f9124..ee40fa3f5c8 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes_scene.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes_scene.cc @@ -25,7 +25,8 @@ #include "DNA_scene_types.h" -namespace DEG { +namespace blender { +namespace deg { void DepsgraphNodeBuilder::build_scene_render(Scene *scene, ViewLayer *view_layer) { @@ -83,4 +84,5 @@ void DepsgraphNodeBuilder::build_scene_compositor(Scene *scene) build_nodetree(scene->nodetree); } -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes_view_layer.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes_view_layer.cc index 58cfb36b4ab..1d6712d16ef 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes_view_layer.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes_view_layer.cc @@ -55,7 +55,8 @@ #include "intern/node/deg_node_component.h" #include "intern/node/deg_node_operation.h" -namespace DEG { +namespace blender { +namespace deg { void DepsgraphNodeBuilder::build_layer_collections(ListBase *lb) { @@ -174,4 +175,5 @@ void DepsgraphNodeBuilder::build_view_layer(Scene *scene, } } -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/builder/deg_builder_pchanmap.cc b/source/blender/depsgraph/intern/builder/deg_builder_pchanmap.cc index a0179181866..924088cbc13 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_pchanmap.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_pchanmap.cc @@ -28,7 +28,8 @@ #include "BLI_utildefines.h" -namespace DEG { +namespace blender { +namespace deg { RootPChanMap::RootPChanMap() { @@ -77,4 +78,5 @@ bool RootPChanMap::has_common_root(const char *bone1, const char *bone2) const return Set<StringRefNull>::Intersects(*bone1_roots, *bone2_roots); } -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/builder/deg_builder_pchanmap.h b/source/blender/depsgraph/intern/builder/deg_builder_pchanmap.h index df8b295f5bb..7a6ea38a0f0 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_pchanmap.h +++ b/source/blender/depsgraph/intern/builder/deg_builder_pchanmap.h @@ -25,7 +25,8 @@ #include "intern/depsgraph_type.h" -namespace DEG { +namespace blender { +namespace deg { struct RootPChanMap { /* Constructor and destructor - Create and free the internal map respectively. */ @@ -49,4 +50,5 @@ struct RootPChanMap { Map<StringRefNull, Set<StringRefNull>> map_; }; -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc index 92dff751b8a..50c52a519b4 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc @@ -118,7 +118,8 @@ #include "intern/depsgraph_relation.h" #include "intern/depsgraph_type.h" -namespace DEG { +namespace blender { +namespace deg { /* ***************** */ /* Relations Builder */ @@ -321,7 +322,7 @@ void DepsgraphRelationBuilder::add_customdata_mask(Object *object, { if (customdata_masks != DEGCustomDataMeshMasks() && object != nullptr && object->type == OB_MESH) { - DEG::IDNode *id_node = graph_->find_id_node(&object->id); + IDNode *id_node = graph_->find_id_node(&object->id); if (id_node == nullptr) { BLI_assert(!"ID should always be valid"); @@ -334,7 +335,7 @@ void DepsgraphRelationBuilder::add_customdata_mask(Object *object, void DepsgraphRelationBuilder::add_special_eval_flag(ID *id, uint32_t flag) { - DEG::IDNode *id_node = graph_->find_id_node(id); + IDNode *id_node = graph_->find_id_node(id); if (id_node == nullptr) { BLI_assert(!"ID should always be valid"); } @@ -496,7 +497,7 @@ void DepsgraphRelationBuilder::build_id(ID *id) build_collection(nullptr, nullptr, (Collection *)id); break; case ID_OB: - build_object(nullptr, (Object *)id); + build_object((Object *)id); break; case ID_KE: build_shapekeys((Key *)id); @@ -598,7 +599,7 @@ void DepsgraphRelationBuilder::build_collection(LayerCollection *from_layer_coll ComponentKey duplicator_key(object != nullptr ? &object->id : nullptr, NodeType::DUPLI); if (!group_done) { LISTBASE_FOREACH (CollectionObject *, cob, &collection->gobject) { - build_object(nullptr, cob->ob); + build_object(cob->ob); } LISTBASE_FOREACH (CollectionChild *, child, &collection->children) { build_collection(nullptr, nullptr, child->collection); @@ -621,12 +622,9 @@ void DepsgraphRelationBuilder::build_collection(LayerCollection *from_layer_coll } } -void DepsgraphRelationBuilder::build_object(Base *base, Object *object) +void DepsgraphRelationBuilder::build_object(Object *object) { if (built_map_.checkIsBuiltAndTag(object)) { - if (base != nullptr) { - build_object_flags(base, object); - } return; } /* Object Transforms */ @@ -644,11 +642,11 @@ void DepsgraphRelationBuilder::build_object(Base *base, Object *object) OperationKey ob_eval_key(&object->id, NodeType::TRANSFORM, OperationCode::TRANSFORM_EVAL); add_relation(init_transform_key, local_transform_key, "Transform Init"); /* Various flags, flushing from bases/collections. */ - build_object_flags(base, object); + build_object_from_layer_relations(object); /* Parenting. */ if (object->parent != nullptr) { /* Make sure parent object's relations are built. */ - build_object(nullptr, object->parent); + build_object(object->parent); /* Parent relationship. */ build_object_parent(object); /* Local -> parent. */ @@ -736,7 +734,7 @@ void DepsgraphRelationBuilder::build_object_proxy_from(Object *object) return; } /* Object is linked here (comes from the library). */ - build_object(nullptr, object->proxy_from); + build_object(object->proxy_from); ComponentKey ob_transform_key(&object->proxy_from->id, NodeType::TRANSFORM); ComponentKey proxy_transform_key(&object->id, NodeType::TRANSFORM); add_relation(ob_transform_key, proxy_transform_key, "Proxy Transform"); @@ -748,27 +746,40 @@ void DepsgraphRelationBuilder::build_object_proxy_group(Object *object) return; } /* Object is local here (local in .blend file, users interacts with it). */ - build_object(nullptr, object->proxy_group); + build_object(object->proxy_group); OperationKey proxy_group_eval_key( &object->proxy_group->id, NodeType::TRANSFORM, OperationCode::TRANSFORM_EVAL); OperationKey transform_eval_key(&object->id, NodeType::TRANSFORM, OperationCode::TRANSFORM_EVAL); add_relation(proxy_group_eval_key, transform_eval_key, "Proxy Group Transform"); } -void DepsgraphRelationBuilder::build_object_flags(Base *base, Object *object) +void DepsgraphRelationBuilder::build_object_from_layer_relations(Object *object) { - if (base == nullptr) { - return; - } - OperationKey view_layer_done_key( - &scene_->id, NodeType::LAYER_COLLECTIONS, OperationCode::VIEW_LAYER_EVAL); + OperationKey object_from_layer_entry_key( + &object->id, NodeType::OBJECT_FROM_LAYER, OperationCode::OBJECT_FROM_LAYER_ENTRY); + OperationKey object_from_layer_exit_key( + &object->id, NodeType::OBJECT_FROM_LAYER, OperationCode::OBJECT_FROM_LAYER_EXIT); OperationKey object_flags_key( &object->id, NodeType::OBJECT_FROM_LAYER, OperationCode::OBJECT_BASE_FLAGS); - add_relation(view_layer_done_key, object_flags_key, "Base flags flush"); + + if (!has_node(object_flags_key)) { + /* Just connect Entry -> Exit if there is no OBJECT_BASE_FLAGS node. */ + add_relation(object_from_layer_entry_key, object_from_layer_exit_key, "Object from Layer"); + return; + } + + /* Entry -> OBJECT_BASE_FLAGS -> Exit */ + add_relation(object_from_layer_entry_key, object_flags_key, "Base flags flush Entry"); + add_relation(object_flags_key, object_from_layer_exit_key, "Base flags flush Exit"); + /* Synchronization back to original object. */ OperationKey synchronize_key( &object->id, NodeType::SYNCHRONIZATION, OperationCode::SYNCHRONIZE_TO_ORIGINAL); - add_relation(object_flags_key, synchronize_key, "Synchronize to Original"); + add_relation(object_from_layer_exit_key, synchronize_key, "Synchronize to Original"); + + OperationKey view_layer_done_key( + &scene_->id, NodeType::LAYER_COLLECTIONS, OperationCode::VIEW_LAYER_EVAL); + add_relation(view_layer_done_key, object_from_layer_entry_key, "View Layer flags to Object"); } void DepsgraphRelationBuilder::build_object_data(Object *object) @@ -1729,9 +1740,9 @@ void DepsgraphRelationBuilder::build_rigidbody(Scene *scene) continue; } /* Make sure indirectly linked objects are fully built. */ - build_object(nullptr, object); - build_object(nullptr, rbc->ob1); - build_object(nullptr, rbc->ob2); + build_object(object); + build_object(rbc->ob1); + build_object(rbc->ob2); /* final result of the constraint object's transform controls how * the constraint affects the physics sim for these objects. */ ComponentKey trans_key(&object->id, NodeType::TRANSFORM); @@ -1820,7 +1831,7 @@ void DepsgraphRelationBuilder::build_particle_systems(Object *object) continue; } /* Make sure target object is pulled into the graph. */ - build_object(nullptr, particle_target->ob); + build_object(particle_target->ob); /* Use geometry component, since that's where particles are * actually evaluated. */ ComponentKey target_key(&particle_target->ob->id, NodeType::GEOMETRY); @@ -1832,7 +1843,7 @@ void DepsgraphRelationBuilder::build_particle_systems(Object *object) case PART_DRAW_OB: if (part->instance_object != nullptr) { /* Make sure object's relations are all built. */ - build_object(nullptr, part->instance_object); + build_object(part->instance_object); /* Build relation for the particle visualization. */ build_particle_system_visualization_object(object, psys, part->instance_object); } @@ -2123,19 +2134,19 @@ void DepsgraphRelationBuilder::build_object_data_geometry_datablock(ID *obdata) add_relation(bevob_geom_key, obdata_geom_eval_key, "Curve Bevel Geometry"); ComponentKey bevob_key(&cu->bevobj->id, NodeType::TRANSFORM); add_relation(bevob_key, obdata_geom_eval_key, "Curve Bevel Transform"); - build_object(nullptr, cu->bevobj); + build_object(cu->bevobj); } if (cu->taperobj != nullptr) { ComponentKey taperob_key(&cu->taperobj->id, NodeType::GEOMETRY); add_relation(taperob_key, obdata_geom_eval_key, "Curve Taper"); - build_object(nullptr, cu->taperobj); + build_object(cu->taperobj); } if (cu->textoncurve != nullptr) { ComponentKey textoncurve_geom_key(&cu->textoncurve->id, NodeType::GEOMETRY); add_relation(textoncurve_geom_key, obdata_geom_eval_key, "Text on Curve Geometry"); ComponentKey textoncurve_key(&cu->textoncurve->id, NodeType::TRANSFORM); add_relation(textoncurve_key, obdata_geom_eval_key, "Text on Curve Transform"); - build_object(nullptr, cu->textoncurve); + build_object(cu->textoncurve); } break; } @@ -2232,7 +2243,7 @@ void DepsgraphRelationBuilder::build_camera(Camera *camera) build_animdata(&camera->id); build_parameters(&camera->id); if (camera->dof.focus_object != nullptr) { - build_object(nullptr, camera->dof.focus_object); + build_object(camera->dof.focus_object); ComponentKey camera_parameters_key(&camera->id, NodeType::PARAMETERS); ComponentKey dof_ob_key(&camera->dof.focus_object->id, NodeType::TRANSFORM); add_relation(dof_ob_key, camera_parameters_key, "Camera DOF"); @@ -2307,7 +2318,7 @@ void DepsgraphRelationBuilder::build_nodetree(bNodeTree *ntree) add_relation(image_key, shading_key, "Image -> Node"); } else if (id_type == ID_OB) { - build_object(nullptr, (Object *)id); + build_object((Object *)id); ComponentKey object_transform_key(id, NodeType::TRANSFORM); add_relation(object_transform_key, shading_key, "Object Transform -> Node"); if (object_have_geometry_component(reinterpret_cast<Object *>(id))) { @@ -2323,7 +2334,7 @@ void DepsgraphRelationBuilder::build_nodetree(bNodeTree *ntree) * On the one hand it's annoying to always pull it in, but on another hand it's also annoying * to have hardcoded node-type exception here. */ if (node_scene->camera != nullptr) { - build_object(nullptr, node_scene->camera); + build_object(node_scene->camera); } } else if (id_type == ID_TXT) { @@ -2661,7 +2672,7 @@ void DepsgraphRelationBuilder::build_scene_speakers(Scene * /*scene*/, ViewLayer if (object->type != OB_SPEAKER || !need_pull_base_into_graph(base)) { continue; } - build_object(nullptr, base->object); + build_object(base->object); } } @@ -2887,9 +2898,7 @@ void DepsgraphRelationBuilder::build_driver_relations(IDNode *id_node) } // Mapping from RNA prefix -> set of driver evaluation nodes: - typedef Vector<Node *> DriverGroup; - typedef map<string, DriverGroup> DriverGroupMap; - DriverGroupMap driver_groups; + Map<string, Vector<Node *>> driver_groups; LISTBASE_FOREACH (FCurve *, fcu, &adt->drivers) { if (fcu->rna_path == nullptr) { @@ -2897,33 +2906,33 @@ void DepsgraphRelationBuilder::build_driver_relations(IDNode *id_node) } // Get the RNA path except the part after the last dot. char *last_dot = strrchr(fcu->rna_path, '.'); - string rna_prefix; + StringRef rna_prefix; if (last_dot != nullptr) { - rna_prefix = string(fcu->rna_path, last_dot); + rna_prefix = StringRef(fcu->rna_path, last_dot); } // Insert this driver node into the group belonging to the RNA prefix. OperationKey driver_key( id_orig, NodeType::PARAMETERS, OperationCode::DRIVER, fcu->rna_path, fcu->array_index); Node *node_driver = get_node(driver_key); - driver_groups[rna_prefix].append(node_driver); + driver_groups.lookup_or_add_default_as(rna_prefix).append(node_driver); } - for (pair<string, DriverGroup> prefix_group : driver_groups) { + for (Span<Node *> prefix_group : driver_groups.values()) { // For each node in the driver group, try to connect it to another node // in the same group without creating any cycles. - int num_drivers = prefix_group.second.size(); + int num_drivers = prefix_group.size(); if (num_drivers < 2) { // A relation requires two drivers. continue; } for (int from_index = 0; from_index < num_drivers; ++from_index) { - Node *op_from = prefix_group.second[from_index]; + Node *op_from = prefix_group[from_index]; // Start by trying the next node in the group. for (int to_offset = 1; to_offset < num_drivers; ++to_offset) { int to_index = (from_index + to_offset) % num_drivers; - Node *op_to = prefix_group.second[to_index]; + Node *op_to = prefix_group[to_index]; // Investigate whether this relation would create a dependency cycle. // Example graph: @@ -2975,4 +2984,5 @@ void DepsgraphRelationBuilder::constraint_walk(bConstraint * /*con*/, data->builder->build_id(id); } -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.h b/source/blender/depsgraph/intern/builder/deg_builder_relations.h index aa6d8ababd3..b4b0dc71f85 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.h +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.h @@ -84,7 +84,8 @@ struct bSound; struct PropertyRNA; -namespace DEG { +namespace blender { +namespace deg { struct ComponentNode; struct DepsNodeHandle; @@ -210,10 +211,10 @@ class DepsgraphRelationBuilder : public DepsgraphBuilder { virtual void build_collection(LayerCollection *from_layer_collection, Object *object, Collection *collection); - virtual void build_object(Base *base, Object *object); + virtual void build_object(Object *object); virtual void build_object_proxy_from(Object *object); virtual void build_object_proxy_group(Object *object); - virtual void build_object_flags(Base *base, Object *object); + virtual void build_object_from_layer_relations(Object *object); virtual void build_object_data(Object *object); virtual void build_object_data_camera(Object *object); virtual void build_object_data_geometry(Object *object); @@ -385,6 +386,7 @@ struct DepsNodeHandle { const char *default_name; }; -} // namespace DEG +} // namespace deg +} // namespace blender #include "intern/builder/deg_builder_relations_impl.h" diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations_impl.h b/source/blender/depsgraph/intern/builder/deg_builder_relations_impl.h index 5983627fafc..d4c28060878 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations_impl.h +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations_impl.h @@ -28,7 +28,8 @@ #include "DNA_ID.h" #include "DNA_object_types.h" -namespace DEG { +namespace blender { +namespace deg { template<typename KeyType> OperationNode *DepsgraphRelationBuilder::find_operation_node(const KeyType &key) @@ -215,4 +216,5 @@ bool DepsgraphRelationBuilder::is_same_nodetree_node_dependency(const KeyFrom &k return true; } -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations_keys.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations_keys.cc index 6c449900f03..2220ba6ee13 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations_keys.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations_keys.cc @@ -25,7 +25,8 @@ #include "intern/builder/deg_builder_relations.h" -namespace DEG { +namespace blender { +namespace deg { //////////////////////////////////////////////////////////////////////////////// // Time source. @@ -192,4 +193,5 @@ string RNAPathKey::identifier() const return string("RnaPathKey(") + "id: " + id_name + ", prop: '" + prop_name + "')"; } -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc index fe9adecbf0a..b695c43402f 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc @@ -58,7 +58,8 @@ #include "intern/depsgraph_relation.h" #include "intern/depsgraph_type.h" -namespace DEG { +namespace blender { +namespace deg { /* IK Solver Eval Steps */ void DepsgraphRelationBuilder::build_ik_pose(Object *object, @@ -449,7 +450,7 @@ void DepsgraphRelationBuilder::build_rig(Object *object) } /* Custom shape. */ if (pchan->custom != nullptr) { - build_object(nullptr, pchan->custom); + build_object(pchan->custom); } } } @@ -509,4 +510,5 @@ void DepsgraphRelationBuilder::build_proxy_rig(Object *object) } } -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations_scene.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations_scene.cc index 410df839875..6ebf5210b63 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations_scene.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations_scene.cc @@ -25,7 +25,8 @@ #include "DNA_scene_types.h" -namespace DEG { +namespace blender { +namespace deg { void DepsgraphRelationBuilder::build_scene_render(Scene *scene, ViewLayer *view_layer) { @@ -43,7 +44,7 @@ void DepsgraphRelationBuilder::build_scene_render(Scene *scene, ViewLayer *view_ build_scene_speakers(scene, view_layer); } if (scene->camera != nullptr) { - build_object(nullptr, scene->camera); + build_object(scene->camera); } } @@ -71,4 +72,5 @@ void DepsgraphRelationBuilder::build_scene_compositor(Scene *scene) build_nodetree(scene->nodetree); } -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations_view_layer.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations_view_layer.cc index e132ba30e67..6e64eba60dc 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations_view_layer.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations_view_layer.cc @@ -56,7 +56,8 @@ #include "intern/depsgraph_type.h" -namespace DEG { +namespace blender { +namespace deg { void DepsgraphRelationBuilder::build_layer_collections(ListBase *lb) { @@ -96,14 +97,14 @@ void DepsgraphRelationBuilder::build_view_layer(Scene *scene, * do nullptr-pointer check of the base, so it's fine to pass original one. */ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) { if (need_pull_base_into_graph(base)) { - build_object(base, base->object); + build_object(base->object); } } build_layer_collections(&view_layer->layer_collections); if (scene->camera != nullptr) { - build_object(nullptr, scene->camera); + build_object(scene->camera); } /* Rigidbody. */ if (scene->rigidbody_world != nullptr) { @@ -153,4 +154,5 @@ void DepsgraphRelationBuilder::build_view_layer(Scene *scene, } } -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/builder/deg_builder_remove_noop.cc b/source/blender/depsgraph/intern/builder/deg_builder_remove_noop.cc index c6545362bb1..a9b405cfb27 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_remove_noop.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_remove_noop.cc @@ -33,7 +33,8 @@ #include "intern/depsgraph_relation.h" #include "intern/depsgraph_type.h" -namespace DEG { +namespace blender { +namespace deg { static inline bool is_unused_noop(OperationNode *op_node) { @@ -84,4 +85,5 @@ void deg_graph_remove_unused_noops(Depsgraph *graph) (::Depsgraph *)graph, BUILD, "Removed %d relations to no-op nodes\n", num_removed_relations); } -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/builder/deg_builder_remove_noop.h b/source/blender/depsgraph/intern/builder/deg_builder_remove_noop.h index e7a2e90cf7c..e30e90af9c0 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_remove_noop.h +++ b/source/blender/depsgraph/intern/builder/deg_builder_remove_noop.h @@ -23,11 +23,13 @@ #pragma once -namespace DEG { +namespace blender { +namespace deg { struct Depsgraph; /* Remove all no-op nodes that have zero outgoing relations. */ void deg_graph_remove_unused_noops(Depsgraph *graph); -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/builder/deg_builder_rna.cc b/source/blender/depsgraph/intern/builder/deg_builder_rna.cc index fbd53bf46f8..98ae653d294 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_rna.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_rna.cc @@ -48,7 +48,8 @@ #include "intern/node/deg_node_id.h" #include "intern/node/deg_node_operation.h" -namespace DEG { +namespace blender { +namespace deg { /* ********************************* ID Data ******************************** */ @@ -365,8 +366,9 @@ RNANodeIdentifier RNANodeQuery::construct_node_identifier(const PointerRNA *ptr, RNANodeQueryIDData *RNANodeQuery::ensure_id_data(const ID *id) { unique_ptr<RNANodeQueryIDData> &id_data = id_data_map_.lookup_or_add_cb( - id, [&]() { return blender::make_unique<RNANodeQueryIDData>(id); }); + id, [&]() { return std::make_unique<RNANodeQueryIDData>(id); }); return id_data.get(); } -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/builder/deg_builder_rna.h b/source/blender/depsgraph/intern/builder/deg_builder_rna.h index bd806ce058a..52d0e5f6b12 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_rna.h +++ b/source/blender/depsgraph/intern/builder/deg_builder_rna.h @@ -30,7 +30,8 @@ struct ID; struct PointerRNA; struct PropertyRNA; -namespace DEG { +namespace blender { +namespace deg { struct Depsgraph; struct Node; @@ -94,4 +95,5 @@ class RNANodeQuery { RNANodeQueryIDData *ensure_id_data(const ID *id); }; -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/builder/deg_builder_transitive.cc b/source/blender/depsgraph/intern/builder/deg_builder_transitive.cc index 22ceac899b8..8ffb20a9999 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_transitive.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_transitive.cc @@ -33,7 +33,8 @@ #include "intern/depsgraph.h" #include "intern/depsgraph_relation.h" -namespace DEG { +namespace blender { +namespace deg { /* -------------------------------------------------- */ @@ -109,4 +110,5 @@ void deg_graph_transitive_reduction(Depsgraph *graph) DEG_DEBUG_PRINTF((::Depsgraph *)graph, BUILD, "Removed %d relations\n", num_removed_relations); } -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/builder/deg_builder_transitive.h b/source/blender/depsgraph/intern/builder/deg_builder_transitive.h index 43068886809..3f083381f83 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_transitive.h +++ b/source/blender/depsgraph/intern/builder/deg_builder_transitive.h @@ -23,11 +23,13 @@ #pragma once -namespace DEG { +namespace blender { +namespace deg { struct Depsgraph; /* Performs a transitive reduction to remove redundant relations. */ void deg_graph_transitive_reduction(Depsgraph *graph); -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/debug/deg_debug.cc b/source/blender/depsgraph/intern/debug/deg_debug.cc index ca27cef2c56..ab6adea6416 100644 --- a/source/blender/depsgraph/intern/debug/deg_debug.cc +++ b/source/blender/depsgraph/intern/debug/deg_debug.cc @@ -32,7 +32,8 @@ #include "BKE_global.h" -namespace DEG { +namespace blender { +namespace deg { DepsgraphDebug::DepsgraphDebug() : flags(G.debug), is_ever_evaluated(false), graph_evaluation_start_time_(0) @@ -97,4 +98,5 @@ string color_end(void) return string(TRUECOLOR_ANSI_COLOR_FINISH); } -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/debug/deg_debug.h b/source/blender/depsgraph/intern/debug/deg_debug.h index f5e2f2c4b51..043cdc85333 100644 --- a/source/blender/depsgraph/intern/debug/deg_debug.h +++ b/source/blender/depsgraph/intern/debug/deg_debug.h @@ -30,7 +30,8 @@ #include "DEG_depsgraph_debug.h" -namespace DEG { +namespace blender { +namespace deg { class DepsgraphDebug { public: @@ -89,4 +90,5 @@ bool terminal_do_color(void); string color_for_pointer(const void *pointer); string color_end(void); -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/debug/deg_debug_relations_graphviz.cc b/source/blender/depsgraph/intern/debug/deg_debug_relations_graphviz.cc index 1f33bdefb79..458baf4fb1e 100644 --- a/source/blender/depsgraph/intern/debug/deg_debug_relations_graphviz.cc +++ b/source/blender/depsgraph/intern/debug/deg_debug_relations_graphviz.cc @@ -40,10 +40,13 @@ #include "intern/node/deg_node_operation.h" #include "intern/node/deg_node_time.h" +namespace deg = blender::deg; + /* ****************** */ /* Graphviz Debugging */ -namespace DEG { +namespace blender { +namespace deg { #define NL "\r\n" @@ -578,7 +581,8 @@ static void deg_debug_graphviz_graph_relations(const DebugContext &ctx, const De } } -} // namespace DEG +} // namespace deg +} // namespace blender void DEG_debug_relations_graphviz(const Depsgraph *graph, FILE *f, const char *label) { @@ -586,29 +590,29 @@ void DEG_debug_relations_graphviz(const Depsgraph *graph, FILE *f, const char *l return; } - const DEG::Depsgraph *deg_graph = reinterpret_cast<const DEG::Depsgraph *>(graph); + const deg::Depsgraph *deg_graph = reinterpret_cast<const deg::Depsgraph *>(graph); - DEG::DebugContext ctx; + deg::DebugContext ctx; ctx.file = f; - DEG::deg_debug_fprintf(ctx, "digraph depgraph {" NL); - DEG::deg_debug_fprintf(ctx, "rankdir=LR;" NL); - DEG::deg_debug_fprintf(ctx, "graph ["); - DEG::deg_debug_fprintf(ctx, "compound=true"); - DEG::deg_debug_fprintf(ctx, ",labelloc=\"t\""); - DEG::deg_debug_fprintf(ctx, ",fontsize=%f", DEG::deg_debug_graphviz_graph_label_size); - DEG::deg_debug_fprintf(ctx, ",fontname=\"%s\"", DEG::deg_debug_graphviz_fontname); - DEG::deg_debug_fprintf(ctx, ",label=\"%s\"", label); - DEG::deg_debug_fprintf(ctx, ",splines=ortho"); - DEG::deg_debug_fprintf(ctx, ",overlap=scalexy"); // XXX: only when using neato - DEG::deg_debug_fprintf(ctx, "];" NL); + deg::deg_debug_fprintf(ctx, "digraph depgraph {" NL); + deg::deg_debug_fprintf(ctx, "rankdir=LR;" NL); + deg::deg_debug_fprintf(ctx, "graph ["); + deg::deg_debug_fprintf(ctx, "compound=true"); + deg::deg_debug_fprintf(ctx, ",labelloc=\"t\""); + deg::deg_debug_fprintf(ctx, ",fontsize=%f", deg::deg_debug_graphviz_graph_label_size); + deg::deg_debug_fprintf(ctx, ",fontname=\"%s\"", deg::deg_debug_graphviz_fontname); + deg::deg_debug_fprintf(ctx, ",label=\"%s\"", label); + deg::deg_debug_fprintf(ctx, ",splines=ortho"); + deg::deg_debug_fprintf(ctx, ",overlap=scalexy"); // XXX: only when using neato + deg::deg_debug_fprintf(ctx, "];" NL); - DEG::deg_debug_graphviz_graph_nodes(ctx, deg_graph); - DEG::deg_debug_graphviz_graph_relations(ctx, deg_graph); + deg::deg_debug_graphviz_graph_nodes(ctx, deg_graph); + deg::deg_debug_graphviz_graph_relations(ctx, deg_graph); - DEG::deg_debug_graphviz_legend(ctx); + deg::deg_debug_graphviz_legend(ctx); - DEG::deg_debug_fprintf(ctx, "}" NL); + deg::deg_debug_fprintf(ctx, "}" NL); } #undef NL diff --git a/source/blender/depsgraph/intern/debug/deg_debug_stats_gnuplot.cc b/source/blender/depsgraph/intern/debug/deg_debug_stats_gnuplot.cc index 9e751093ae2..78525ba6b69 100644 --- a/source/blender/depsgraph/intern/debug/deg_debug_stats_gnuplot.cc +++ b/source/blender/depsgraph/intern/debug/deg_debug_stats_gnuplot.cc @@ -36,7 +36,10 @@ #define NL "\r\n" -namespace DEG { +namespace deg = blender::deg; + +namespace blender { +namespace deg { namespace { struct DebugContext { @@ -147,7 +150,8 @@ void deg_debug_stats_gnuplot(const DebugContext &ctx) } } // namespace -} // namespace DEG +} // namespace deg +} // namespace blender void DEG_debug_stats_gnuplot(const Depsgraph *depsgraph, FILE *f, @@ -157,10 +161,10 @@ void DEG_debug_stats_gnuplot(const Depsgraph *depsgraph, if (depsgraph == nullptr) { return; } - DEG::DebugContext ctx; + deg::DebugContext ctx; ctx.file = f; - ctx.graph = (DEG::Depsgraph *)depsgraph; + ctx.graph = (deg::Depsgraph *)depsgraph; ctx.label = label; ctx.output_filename = output_filename; - DEG::deg_debug_stats_gnuplot(ctx); + deg::deg_debug_stats_gnuplot(ctx); } diff --git a/source/blender/depsgraph/intern/debug/deg_time_average.h b/source/blender/depsgraph/intern/debug/deg_time_average.h index 9794e9a88c3..838ceff8d96 100644 --- a/source/blender/depsgraph/intern/debug/deg_time_average.h +++ b/source/blender/depsgraph/intern/debug/deg_time_average.h @@ -23,7 +23,8 @@ #pragma once -namespace DEG { +namespace blender { +namespace deg { // Utility class which takes care of calculating average of time series, such as // FPS counters. @@ -68,4 +69,5 @@ template<int MaxSamples> class AveragedTimeSampler { int next_sample_index_; }; -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/depsgraph.cc b/source/blender/depsgraph/intern/depsgraph.cc index 51ae56ac613..ce2c7110aee 100644 --- a/source/blender/depsgraph/intern/depsgraph.cc +++ b/source/blender/depsgraph/intern/depsgraph.cc @@ -55,7 +55,10 @@ #include "intern/node/deg_node_operation.h" #include "intern/node/deg_node_time.h" -namespace DEG { +namespace deg = blender::deg; + +namespace blender { +namespace deg { Depsgraph::Depsgraph(Main *bmain, Scene *scene, ViewLayer *view_layer, eEvaluationMode mode) : time_source(nullptr), @@ -258,7 +261,8 @@ ID *Depsgraph::get_cow_id(const ID *id_orig) const return id_node->id_cow; } -} // namespace DEG +} // namespace deg +} // namespace blender /* **************** */ /* Public Graph API */ @@ -266,9 +270,9 @@ ID *Depsgraph::get_cow_id(const ID *id_orig) const /* Initialize a new Depsgraph */ Depsgraph *DEG_graph_new(Main *bmain, Scene *scene, ViewLayer *view_layer, eEvaluationMode mode) { - DEG::Depsgraph *deg_depsgraph = OBJECT_GUARDED_NEW( - DEG::Depsgraph, bmain, scene, view_layer, mode); - DEG::register_graph(deg_depsgraph); + deg::Depsgraph *deg_depsgraph = OBJECT_GUARDED_NEW( + deg::Depsgraph, bmain, scene, view_layer, mode); + deg::register_graph(deg_depsgraph); return reinterpret_cast<Depsgraph *>(deg_depsgraph); } @@ -279,11 +283,11 @@ void DEG_graph_replace_owners(struct Depsgraph *depsgraph, Scene *scene, ViewLayer *view_layer) { - DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph *>(depsgraph); + deg::Depsgraph *deg_graph = reinterpret_cast<deg::Depsgraph *>(depsgraph); const bool do_update_register = deg_graph->bmain != bmain; if (do_update_register && deg_graph->bmain != NULL) { - DEG::unregister_graph(deg_graph); + deg::unregister_graph(deg_graph); } deg_graph->bmain = bmain; @@ -291,7 +295,7 @@ void DEG_graph_replace_owners(struct Depsgraph *depsgraph, deg_graph->view_layer = view_layer; if (do_update_register) { - DEG::register_graph(deg_graph); + deg::register_graph(deg_graph); } } @@ -301,15 +305,15 @@ void DEG_graph_free(Depsgraph *graph) if (graph == nullptr) { return; } - using DEG::Depsgraph; - DEG::Depsgraph *deg_depsgraph = reinterpret_cast<DEG::Depsgraph *>(graph); - DEG::unregister_graph(deg_depsgraph); + using deg::Depsgraph; + deg::Depsgraph *deg_depsgraph = reinterpret_cast<deg::Depsgraph *>(graph); + deg::unregister_graph(deg_depsgraph); OBJECT_GUARDED_DELETE(deg_depsgraph, Depsgraph); } bool DEG_is_evaluating(const struct Depsgraph *depsgraph) { - const DEG::Depsgraph *deg_graph = reinterpret_cast<const DEG::Depsgraph *>(depsgraph); + const deg::Depsgraph *deg_graph = reinterpret_cast<const deg::Depsgraph *>(depsgraph); return deg_graph->is_evaluating; } @@ -322,19 +326,19 @@ bool DEG_is_active(const struct Depsgraph *depsgraph) * cases. */ return false; } - const DEG::Depsgraph *deg_graph = reinterpret_cast<const DEG::Depsgraph *>(depsgraph); + const deg::Depsgraph *deg_graph = reinterpret_cast<const deg::Depsgraph *>(depsgraph); return deg_graph->is_active; } void DEG_make_active(struct Depsgraph *depsgraph) { - DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph *>(depsgraph); + deg::Depsgraph *deg_graph = reinterpret_cast<deg::Depsgraph *>(depsgraph); deg_graph->is_active = true; /* TODO(sergey): Copy data from evaluated state to original. */ } void DEG_make_inactive(struct Depsgraph *depsgraph) { - DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph *>(depsgraph); + deg::Depsgraph *deg_graph = reinterpret_cast<deg::Depsgraph *>(depsgraph); deg_graph->is_active = false; } diff --git a/source/blender/depsgraph/intern/depsgraph.h b/source/blender/depsgraph/intern/depsgraph.h index e0686bd04aa..9dea518b89c 100644 --- a/source/blender/depsgraph/intern/depsgraph.h +++ b/source/blender/depsgraph/intern/depsgraph.h @@ -47,7 +47,8 @@ struct ID; struct Scene; struct ViewLayer; -namespace DEG { +namespace blender { +namespace deg { struct IDNode; struct Node; @@ -169,4 +170,5 @@ struct Depsgraph { Map<const ID *, ListBase *> *physics_relations[DEG_PHYSICS_RELATIONS_NUM]; }; -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/depsgraph_build.cc b/source/blender/depsgraph/intern/depsgraph_build.cc index cdaf68cb826..c11d051e663 100644 --- a/source/blender/depsgraph/intern/depsgraph_build.cc +++ b/source/blender/depsgraph/intern/depsgraph_build.cc @@ -64,22 +64,24 @@ /* ****************** */ /* External Build API */ -static DEG::NodeType deg_build_scene_component_type(eDepsSceneComponentType component) +namespace deg = blender::deg; + +static deg::NodeType deg_build_scene_component_type(eDepsSceneComponentType component) { switch (component) { case DEG_SCENE_COMP_PARAMETERS: - return DEG::NodeType::PARAMETERS; + return deg::NodeType::PARAMETERS; case DEG_SCENE_COMP_ANIMATION: - return DEG::NodeType::ANIMATION; + return deg::NodeType::ANIMATION; case DEG_SCENE_COMP_SEQUENCER: - return DEG::NodeType::SEQUENCER; + return deg::NodeType::SEQUENCER; } - return DEG::NodeType::UNDEFINED; + return deg::NodeType::UNDEFINED; } -static DEG::DepsNodeHandle *get_node_handle(DepsNodeHandle *node_handle) +static deg::DepsNodeHandle *get_node_handle(DepsNodeHandle *node_handle) { - return reinterpret_cast<DEG::DepsNodeHandle *>(node_handle); + return reinterpret_cast<deg::DepsNodeHandle *>(node_handle); } void DEG_add_scene_relation(DepsNodeHandle *node_handle, @@ -87,9 +89,9 @@ void DEG_add_scene_relation(DepsNodeHandle *node_handle, eDepsSceneComponentType component, const char *description) { - DEG::NodeType type = deg_build_scene_component_type(component); - DEG::ComponentKey comp_key(&scene->id, type); - DEG::DepsNodeHandle *deg_node_handle = get_node_handle(node_handle); + deg::NodeType type = deg_build_scene_component_type(component); + deg::ComponentKey comp_key(&scene->id, type); + deg::DepsNodeHandle *deg_node_handle = get_node_handle(node_handle); deg_node_handle->builder->add_node_handle_relation(comp_key, deg_node_handle, description); } @@ -98,9 +100,9 @@ void DEG_add_object_relation(DepsNodeHandle *node_handle, eDepsObjectComponentType component, const char *description) { - DEG::NodeType type = DEG::nodeTypeFromObjectComponent(component); - DEG::ComponentKey comp_key(&object->id, type); - DEG::DepsNodeHandle *deg_node_handle = get_node_handle(node_handle); + deg::NodeType type = deg::nodeTypeFromObjectComponent(component); + deg::ComponentKey comp_key(&object->id, type); + deg::DepsNodeHandle *deg_node_handle = get_node_handle(node_handle); deg_node_handle->builder->add_node_handle_relation(comp_key, deg_node_handle, description); } @@ -108,9 +110,9 @@ void DEG_add_simulation_relation(DepsNodeHandle *node_handle, Simulation *simulation, const char *description) { - DEG::OperationKey operation_key( - &simulation->id, DEG::NodeType::SIMULATION, DEG::OperationCode::SIMULATION_EVAL); - DEG::DepsNodeHandle *deg_node_handle = get_node_handle(node_handle); + deg::OperationKey operation_key( + &simulation->id, deg::NodeType::SIMULATION, deg::OperationCode::SIMULATION_EVAL); + deg::DepsNodeHandle *deg_node_handle = get_node_handle(node_handle); deg_node_handle->builder->add_node_handle_relation(operation_key, deg_node_handle, description); } @@ -119,9 +121,9 @@ void DEG_add_object_cache_relation(DepsNodeHandle *node_handle, eDepsObjectComponentType component, const char *description) { - DEG::NodeType type = DEG::nodeTypeFromObjectComponent(component); - DEG::ComponentKey comp_key(&cache_file->id, type); - DEG::DepsNodeHandle *deg_node_handle = get_node_handle(node_handle); + deg::NodeType type = deg::nodeTypeFromObjectComponent(component); + deg::ComponentKey comp_key(&cache_file->id, type); + deg::DepsNodeHandle *deg_node_handle = get_node_handle(node_handle); deg_node_handle->builder->add_node_handle_relation(comp_key, deg_node_handle, description); } @@ -131,9 +133,9 @@ void DEG_add_bone_relation(DepsNodeHandle *node_handle, eDepsObjectComponentType component, const char *description) { - DEG::NodeType type = DEG::nodeTypeFromObjectComponent(component); - DEG::ComponentKey comp_key(&object->id, type, bone_name); - DEG::DepsNodeHandle *deg_node_handle = get_node_handle(node_handle); + deg::NodeType type = deg::nodeTypeFromObjectComponent(component); + deg::ComponentKey comp_key(&object->id, type, bone_name); + deg::DepsNodeHandle *deg_node_handle = get_node_handle(node_handle); deg_node_handle->builder->add_node_handle_relation(comp_key, deg_node_handle, description); } @@ -142,18 +144,18 @@ void DEG_add_object_pointcache_relation(struct DepsNodeHandle *node_handle, eDepsObjectComponentType component, const char *description) { - DEG::NodeType type = DEG::nodeTypeFromObjectComponent(component); - DEG::ComponentKey comp_key(&object->id, type); - DEG::DepsNodeHandle *deg_node_handle = get_node_handle(node_handle); - DEG::DepsgraphRelationBuilder *relation_builder = deg_node_handle->builder; + deg::NodeType type = deg::nodeTypeFromObjectComponent(component); + deg::ComponentKey comp_key(&object->id, type); + deg::DepsNodeHandle *deg_node_handle = get_node_handle(node_handle); + deg::DepsgraphRelationBuilder *relation_builder = deg_node_handle->builder; /* Add relation from source to the node handle. */ relation_builder->add_node_handle_relation(comp_key, deg_node_handle, description); /* Node deduct point cache component and connect source to it. */ ID *id = DEG_get_id_from_handle(node_handle); - DEG::ComponentKey point_cache_key(id, DEG::NodeType::POINT_CACHE); - DEG::Relation *rel = relation_builder->add_relation(comp_key, point_cache_key, "Point Cache"); + deg::ComponentKey point_cache_key(id, deg::NodeType::POINT_CACHE); + deg::Relation *rel = relation_builder->add_relation(comp_key, point_cache_key, "Point Cache"); if (rel != nullptr) { - rel->flag |= DEG::RELATION_FLAG_FLUSH_USER_EDIT_ONLY; + rel->flag |= deg::RELATION_FLAG_FLUSH_USER_EDIT_ONLY; } else { fprintf(stderr, "Error in point cache relation from %s to ^%s.\n", object->id.name, id->name); @@ -164,22 +166,22 @@ void DEG_add_generic_id_relation(struct DepsNodeHandle *node_handle, struct ID *id, const char *description) { - DEG::OperationKey operation_key( - id, DEG::NodeType::GENERIC_DATABLOCK, DEG::OperationCode::GENERIC_DATABLOCK_UPDATE); - DEG::DepsNodeHandle *deg_node_handle = get_node_handle(node_handle); + deg::OperationKey operation_key( + id, deg::NodeType::GENERIC_DATABLOCK, deg::OperationCode::GENERIC_DATABLOCK_UPDATE); + deg::DepsNodeHandle *deg_node_handle = get_node_handle(node_handle); deg_node_handle->builder->add_node_handle_relation(operation_key, deg_node_handle, description); } void DEG_add_modifier_to_transform_relation(struct DepsNodeHandle *node_handle, const char *description) { - DEG::DepsNodeHandle *deg_node_handle = get_node_handle(node_handle); + deg::DepsNodeHandle *deg_node_handle = get_node_handle(node_handle); deg_node_handle->builder->add_modifier_to_transform_relation(deg_node_handle, description); } void DEG_add_special_eval_flag(struct DepsNodeHandle *node_handle, ID *id, uint32_t flag) { - DEG::DepsNodeHandle *deg_node_handle = get_node_handle(node_handle); + deg::DepsNodeHandle *deg_node_handle = get_node_handle(node_handle); deg_node_handle->builder->add_special_eval_flag(id, flag); } @@ -187,41 +189,41 @@ void DEG_add_customdata_mask(struct DepsNodeHandle *node_handle, struct Object *object, const CustomData_MeshMasks *masks) { - DEG::DepsNodeHandle *deg_node_handle = get_node_handle(node_handle); - deg_node_handle->builder->add_customdata_mask(object, DEG::DEGCustomDataMeshMasks(masks)); + deg::DepsNodeHandle *deg_node_handle = get_node_handle(node_handle); + deg_node_handle->builder->add_customdata_mask(object, deg::DEGCustomDataMeshMasks(masks)); } struct ID *DEG_get_id_from_handle(struct DepsNodeHandle *node_handle) { - DEG::DepsNodeHandle *deg_handle = get_node_handle(node_handle); + deg::DepsNodeHandle *deg_handle = get_node_handle(node_handle); return deg_handle->node->owner->owner->id_orig; } struct Depsgraph *DEG_get_graph_from_handle(struct DepsNodeHandle *node_handle) { - DEG::DepsNodeHandle *deg_node_handle = get_node_handle(node_handle); - DEG::DepsgraphRelationBuilder *relation_builder = deg_node_handle->builder; + deg::DepsNodeHandle *deg_node_handle = get_node_handle(node_handle); + deg::DepsgraphRelationBuilder *relation_builder = deg_node_handle->builder; return reinterpret_cast<Depsgraph *>(relation_builder->getGraph()); } /* ******************** */ /* Graph Building API's */ -static void graph_build_finalize_common(DEG::Depsgraph *deg_graph, Main *bmain) +static void graph_build_finalize_common(deg::Depsgraph *deg_graph, Main *bmain) { /* Detect and solve cycles. */ - DEG::deg_graph_detect_cycles(deg_graph); + deg::deg_graph_detect_cycles(deg_graph); /* Simplify the graph by removing redundant relations (to optimize * traversal later). */ /* TODO: it would be useful to have an option to disable this in cases where * it is causing trouble. */ if (G.debug_value == 799) { - DEG::deg_graph_transitive_reduction(deg_graph); + deg::deg_graph_transitive_reduction(deg_graph); } /* Store pointers to commonly used valuated datablocks. */ deg_graph->scene_cow = (Scene *)deg_graph->get_cow_id(°_graph->scene->id); /* Flush visibility layer and re-schedule nodes for update. */ - DEG::deg_graph_build_finalize(bmain, deg_graph); + deg::deg_graph_build_finalize(bmain, deg_graph); DEG_graph_on_visible_update(bmain, reinterpret_cast<::Depsgraph *>(deg_graph), false); #if 0 if (!DEG_debug_consistency_check(deg_graph)) { @@ -243,21 +245,21 @@ void DEG_graph_build_from_view_layer(Depsgraph *graph, if (G.debug & (G_DEBUG_DEPSGRAPH_BUILD | G_DEBUG_DEPSGRAPH_TIME)) { start_time = PIL_check_seconds_timer(); } - DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph *>(graph); + deg::Depsgraph *deg_graph = reinterpret_cast<deg::Depsgraph *>(graph); /* Perform sanity checks. */ BLI_assert(BLI_findindex(&scene->view_layers, view_layer) != -1); BLI_assert(deg_graph->scene == scene); BLI_assert(deg_graph->view_layer == view_layer); - DEG::DepsgraphBuilderCache builder_cache; + deg::DepsgraphBuilderCache builder_cache; /* Generate all the nodes in the graph first */ - DEG::DepsgraphNodeBuilder node_builder(bmain, deg_graph, &builder_cache); + deg::DepsgraphNodeBuilder node_builder(bmain, deg_graph, &builder_cache); node_builder.begin_build(); - node_builder.build_view_layer(scene, view_layer, DEG::DEG_ID_LINKED_DIRECTLY); + node_builder.build_view_layer(scene, view_layer, deg::DEG_ID_LINKED_DIRECTLY); node_builder.end_build(); /* Hook up relationships between operations - to determine evaluation order. */ - DEG::DepsgraphRelationBuilder relation_builder(bmain, deg_graph, &builder_cache); + deg::DepsgraphRelationBuilder relation_builder(bmain, deg_graph, &builder_cache); relation_builder.begin_build(); - relation_builder.build_view_layer(scene, view_layer, DEG::DEG_ID_LINKED_DIRECTLY); + relation_builder.build_view_layer(scene, view_layer, deg::DEG_ID_LINKED_DIRECTLY); relation_builder.build_copy_on_write_relations(); relation_builder.build_driver_relations(); /* Finalize building. */ @@ -277,19 +279,19 @@ void DEG_graph_build_for_render_pipeline(Depsgraph *graph, if (G.debug & (G_DEBUG_DEPSGRAPH_BUILD | G_DEBUG_DEPSGRAPH_TIME)) { start_time = PIL_check_seconds_timer(); } - DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph *>(graph); + deg::Depsgraph *deg_graph = reinterpret_cast<deg::Depsgraph *>(graph); /* Perform sanity checks. */ BLI_assert(deg_graph->scene == scene); deg_graph->is_render_pipeline_depsgraph = true; - DEG::DepsgraphBuilderCache builder_cache; + deg::DepsgraphBuilderCache builder_cache; /* Generate all the nodes in the graph first */ - DEG::DepsgraphNodeBuilder node_builder(bmain, deg_graph, &builder_cache); + deg::DepsgraphNodeBuilder node_builder(bmain, deg_graph, &builder_cache); node_builder.begin_build(); node_builder.build_scene_render(scene, view_layer); node_builder.end_build(); /* Hook up relationships between operations - to determine evaluation * order. */ - DEG::DepsgraphRelationBuilder relation_builder(bmain, deg_graph, &builder_cache); + deg::DepsgraphRelationBuilder relation_builder(bmain, deg_graph, &builder_cache); relation_builder.begin_build(); relation_builder.build_scene_render(scene, view_layer); relation_builder.build_copy_on_write_relations(); @@ -309,20 +311,20 @@ void DEG_graph_build_for_compositor_preview( if (G.debug & (G_DEBUG_DEPSGRAPH_BUILD | G_DEBUG_DEPSGRAPH_TIME)) { start_time = PIL_check_seconds_timer(); } - DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph *>(graph); + deg::Depsgraph *deg_graph = reinterpret_cast<deg::Depsgraph *>(graph); /* Perform sanity checks. */ BLI_assert(deg_graph->scene == scene); deg_graph->is_render_pipeline_depsgraph = true; - DEG::DepsgraphBuilderCache builder_cache; + deg::DepsgraphBuilderCache builder_cache; /* Generate all the nodes in the graph first */ - DEG::DepsgraphNodeBuilder node_builder(bmain, deg_graph, &builder_cache); + deg::DepsgraphNodeBuilder node_builder(bmain, deg_graph, &builder_cache); node_builder.begin_build(); node_builder.build_scene_render(scene, view_layer); node_builder.build_nodetree(nodetree); node_builder.end_build(); /* Hook up relationships between operations - to determine evaluation * order. */ - DEG::DepsgraphRelationBuilder relation_builder(bmain, deg_graph, &builder_cache); + deg::DepsgraphRelationBuilder relation_builder(bmain, deg_graph, &builder_cache); relation_builder.begin_build(); relation_builder.build_scene_render(scene, view_layer); relation_builder.build_nodetree(nodetree); @@ -349,7 +351,8 @@ void DEG_graph_build_for_compositor_preview( * This way we avoid high-poly character body pulled into the dependency graph when it's coming * from a library into an animation file and the dependency graph constructed for a proxy rig. */ -namespace DEG { +namespace blender { +namespace deg { namespace { class DepsgraphFromIDsFilter { @@ -433,7 +436,8 @@ class DepsgraphFromIDsRelationBuilder : public DepsgraphRelationBuilder { }; } // namespace -} // namespace DEG +} // namespace deg +} // namespace blender void DEG_graph_build_from_ids(Depsgraph *graph, Main *bmain, @@ -446,25 +450,25 @@ void DEG_graph_build_from_ids(Depsgraph *graph, if (G.debug & (G_DEBUG_DEPSGRAPH_BUILD | G_DEBUG_DEPSGRAPH_TIME)) { start_time = PIL_check_seconds_timer(); } - DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph *>(graph); + deg::Depsgraph *deg_graph = reinterpret_cast<deg::Depsgraph *>(graph); /* Perform sanity checks. */ BLI_assert(BLI_findindex(&scene->view_layers, view_layer) != -1); BLI_assert(deg_graph->scene == scene); BLI_assert(deg_graph->view_layer == view_layer); - DEG::DepsgraphBuilderCache builder_cache; + deg::DepsgraphBuilderCache builder_cache; /* Generate all the nodes in the graph first */ - DEG::DepsgraphFromIDsNodeBuilder node_builder(bmain, deg_graph, &builder_cache, ids, num_ids); + deg::DepsgraphFromIDsNodeBuilder node_builder(bmain, deg_graph, &builder_cache, ids, num_ids); node_builder.begin_build(); - node_builder.build_view_layer(scene, view_layer, DEG::DEG_ID_LINKED_DIRECTLY); + node_builder.build_view_layer(scene, view_layer, deg::DEG_ID_LINKED_DIRECTLY); for (int i = 0; i < num_ids; ++i) { node_builder.build_id(ids[i]); } node_builder.end_build(); /* Hook up relationships between operations - to determine evaluation order. */ - DEG::DepsgraphFromIDsRelationBuilder relation_builder( + deg::DepsgraphFromIDsRelationBuilder relation_builder( bmain, deg_graph, &builder_cache, ids, num_ids); relation_builder.begin_build(); - relation_builder.build_view_layer(scene, view_layer, DEG::DEG_ID_LINKED_DIRECTLY); + relation_builder.build_view_layer(scene, view_layer, deg::DEG_ID_LINKED_DIRECTLY); for (int i = 0; i < num_ids; ++i) { relation_builder.build_id(ids[i]); } @@ -482,7 +486,7 @@ void DEG_graph_build_from_ids(Depsgraph *graph, void DEG_graph_tag_relations_update(Depsgraph *graph) { DEG_DEBUG_PRINTF(graph, TAG, "%s: Tagging relations for update.\n", __func__); - DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph *>(graph); + deg::Depsgraph *deg_graph = reinterpret_cast<deg::Depsgraph *>(graph); deg_graph->need_update = true; /* NOTE: When relations are updated, it's quite possible that * we've got new bases in the scene. This means, we need to @@ -490,16 +494,16 @@ void DEG_graph_tag_relations_update(Depsgraph *graph) * * TODO(sergey): Try to make it so we don't flush updates * to the whole depsgraph. */ - DEG::IDNode *id_node = deg_graph->find_id_node(°_graph->scene->id); + deg::IDNode *id_node = deg_graph->find_id_node(°_graph->scene->id); if (id_node != nullptr) { - id_node->tag_update(deg_graph, DEG::DEG_UPDATE_SOURCE_RELATIONS); + id_node->tag_update(deg_graph, deg::DEG_UPDATE_SOURCE_RELATIONS); } } /* Create or update relations in the specified graph. */ void DEG_graph_relations_update(Depsgraph *graph, Main *bmain, Scene *scene, ViewLayer *view_layer) { - DEG::Depsgraph *deg_graph = (DEG::Depsgraph *)graph; + deg::Depsgraph *deg_graph = (deg::Depsgraph *)graph; if (!deg_graph->need_update) { /* Graph is up to date, nothing to do. */ return; @@ -511,7 +515,7 @@ void DEG_graph_relations_update(Depsgraph *graph, Main *bmain, Scene *scene, Vie void DEG_relations_tag_update(Main *bmain) { DEG_GLOBAL_DEBUG_PRINTF(TAG, "%s: Tagging relations for update.\n", __func__); - for (DEG::Depsgraph *depsgraph : DEG::get_all_registered_graphs(bmain)) { + for (deg::Depsgraph *depsgraph : deg::get_all_registered_graphs(bmain)) { DEG_graph_tag_relations_update(reinterpret_cast<Depsgraph *>(depsgraph)); } } diff --git a/source/blender/depsgraph/intern/depsgraph_debug.cc b/source/blender/depsgraph/intern/depsgraph_debug.cc index 8f5117ec0f6..0763738ff59 100644 --- a/source/blender/depsgraph/intern/depsgraph_debug.cc +++ b/source/blender/depsgraph/intern/depsgraph_debug.cc @@ -42,27 +42,29 @@ #include "intern/node/deg_node_id.h" #include "intern/node/deg_node_time.h" +namespace deg = blender::deg; + void DEG_debug_flags_set(Depsgraph *depsgraph, int flags) { - DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph *>(depsgraph); + deg::Depsgraph *deg_graph = reinterpret_cast<deg::Depsgraph *>(depsgraph); deg_graph->debug.flags = flags; } int DEG_debug_flags_get(const Depsgraph *depsgraph) { - const DEG::Depsgraph *deg_graph = reinterpret_cast<const DEG::Depsgraph *>(depsgraph); + const deg::Depsgraph *deg_graph = reinterpret_cast<const deg::Depsgraph *>(depsgraph); return deg_graph->debug.flags; } void DEG_debug_name_set(struct Depsgraph *depsgraph, const char *name) { - DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph *>(depsgraph); + deg::Depsgraph *deg_graph = reinterpret_cast<deg::Depsgraph *>(depsgraph); deg_graph->debug.name = name; } const char *DEG_debug_name_get(struct Depsgraph *depsgraph) { - const DEG::Depsgraph *deg_graph = reinterpret_cast<const DEG::Depsgraph *>(depsgraph); + const deg::Depsgraph *deg_graph = reinterpret_cast<const deg::Depsgraph *>(depsgraph); return deg_graph->debug.name.c_str(); } @@ -70,8 +72,8 @@ bool DEG_debug_compare(const struct Depsgraph *graph1, const struct Depsgraph *g { BLI_assert(graph1 != nullptr); BLI_assert(graph2 != nullptr); - const DEG::Depsgraph *deg_graph1 = reinterpret_cast<const DEG::Depsgraph *>(graph1); - const DEG::Depsgraph *deg_graph2 = reinterpret_cast<const DEG::Depsgraph *>(graph2); + const deg::Depsgraph *deg_graph1 = reinterpret_cast<const deg::Depsgraph *>(graph1); + const deg::Depsgraph *deg_graph2 = reinterpret_cast<const deg::Depsgraph *>(graph2); if (deg_graph1->operations.size() != deg_graph2->operations.size()) { return false; } @@ -103,18 +105,18 @@ bool DEG_debug_graph_relations_validate(Depsgraph *graph, bool DEG_debug_consistency_check(Depsgraph *graph) { - const DEG::Depsgraph *deg_graph = reinterpret_cast<const DEG::Depsgraph *>(graph); + const deg::Depsgraph *deg_graph = reinterpret_cast<const deg::Depsgraph *>(graph); /* Validate links exists in both directions. */ - for (DEG::OperationNode *node : deg_graph->operations) { - for (DEG::Relation *rel : node->outlinks) { + for (deg::OperationNode *node : deg_graph->operations) { + for (deg::Relation *rel : node->outlinks) { int counter1 = 0; - for (DEG::Relation *tmp_rel : node->outlinks) { + for (deg::Relation *tmp_rel : node->outlinks) { if (tmp_rel == rel) { counter1++; } } int counter2 = 0; - for (DEG::Relation *tmp_rel : rel->to->inlinks) { + for (deg::Relation *tmp_rel : rel->to->inlinks) { if (tmp_rel == rel) { counter2++; } @@ -130,16 +132,16 @@ bool DEG_debug_consistency_check(Depsgraph *graph) } } - for (DEG::OperationNode *node : deg_graph->operations) { - for (DEG::Relation *rel : node->inlinks) { + for (deg::OperationNode *node : deg_graph->operations) { + for (deg::Relation *rel : node->inlinks) { int counter1 = 0; - for (DEG::Relation *tmp_rel : node->inlinks) { + for (deg::Relation *tmp_rel : node->inlinks) { if (tmp_rel == rel) { counter1++; } } int counter2 = 0; - for (DEG::Relation *tmp_rel : rel->from->outlinks) { + for (deg::Relation *tmp_rel : rel->from->outlinks) { if (tmp_rel == rel) { counter2++; } @@ -153,19 +155,19 @@ bool DEG_debug_consistency_check(Depsgraph *graph) } /* Validate node valency calculated in both directions. */ - for (DEG::OperationNode *node : deg_graph->operations) { + for (deg::OperationNode *node : deg_graph->operations) { node->num_links_pending = 0; node->custom_flags = 0; } - for (DEG::OperationNode *node : deg_graph->operations) { + for (deg::OperationNode *node : deg_graph->operations) { if (node->custom_flags) { printf("Node %s is twice in the operations!\n", node->identifier().c_str()); return false; } - for (DEG::Relation *rel : node->outlinks) { - if (rel->to->type == DEG::NodeType::OPERATION) { - DEG::OperationNode *to = (DEG::OperationNode *)rel->to; + for (deg::Relation *rel : node->outlinks) { + if (rel->to->type == deg::NodeType::OPERATION) { + deg::OperationNode *to = (deg::OperationNode *)rel->to; BLI_assert(to->num_links_pending < to->inlinks.size()); ++to->num_links_pending; } @@ -173,10 +175,10 @@ bool DEG_debug_consistency_check(Depsgraph *graph) node->custom_flags = 1; } - for (DEG::OperationNode *node : deg_graph->operations) { + for (deg::OperationNode *node : deg_graph->operations) { int num_links_pending = 0; - for (DEG::Relation *rel : node->inlinks) { - if (rel->from->type == DEG::NodeType::OPERATION) { + for (deg::Relation *rel : node->inlinks) { + if (rel->from->type == deg::NodeType::OPERATION) { num_links_pending++; } } @@ -205,7 +207,7 @@ void DEG_stats_simple(const Depsgraph *graph, size_t *r_operations, size_t *r_relations) { - const DEG::Depsgraph *deg_graph = reinterpret_cast<const DEG::Depsgraph *>(graph); + const deg::Depsgraph *deg_graph = reinterpret_cast<const deg::Depsgraph *>(graph); /* number of operations */ if (r_operations) { @@ -219,17 +221,17 @@ void DEG_stats_simple(const Depsgraph *graph, size_t tot_outer = 0; size_t tot_rels = 0; - for (DEG::IDNode *id_node : deg_graph->id_nodes) { + for (deg::IDNode *id_node : deg_graph->id_nodes) { tot_outer++; - for (DEG::ComponentNode *comp_node : id_node->components.values()) { + for (deg::ComponentNode *comp_node : id_node->components.values()) { tot_outer++; - for (DEG::OperationNode *op_node : comp_node->operations) { + for (deg::OperationNode *op_node : comp_node->operations) { tot_rels += op_node->inlinks.size(); } } } - DEG::TimeSourceNode *time_source = deg_graph->find_time_source(); + deg::TimeSourceNode *time_source = deg_graph->find_time_source(); if (time_source != nullptr) { tot_rels += time_source->inlinks.size(); } @@ -243,13 +245,13 @@ void DEG_stats_simple(const Depsgraph *graph, } } -static DEG::string depsgraph_name_for_logging(struct Depsgraph *depsgraph) +static deg::string depsgraph_name_for_logging(struct Depsgraph *depsgraph) { const char *name = DEG_debug_name_get(depsgraph); if (name[0] == '\0') { return ""; } - return "[" + DEG::string(name) + "]: "; + return "[" + deg::string(name) + "]: "; } void DEG_debug_print_begin(struct Depsgraph *depsgraph) @@ -270,9 +272,9 @@ void DEG_debug_print_eval(struct Depsgraph *depsgraph, depsgraph_name_for_logging(depsgraph).c_str(), function_name, object_name, - DEG::color_for_pointer(object_address).c_str(), + deg::color_for_pointer(object_address).c_str(), object_address, - DEG::color_end().c_str()); + deg::color_end().c_str()); fflush(stdout); } @@ -292,14 +294,14 @@ void DEG_debug_print_eval_subdata(struct Depsgraph *depsgraph, depsgraph_name_for_logging(depsgraph).c_str(), function_name, object_name, - DEG::color_for_pointer(object_address).c_str(), + deg::color_for_pointer(object_address).c_str(), object_address, - DEG::color_end().c_str(), + deg::color_end().c_str(), subdata_comment, subdata_name, - DEG::color_for_pointer(subdata_address).c_str(), + deg::color_for_pointer(subdata_address).c_str(), subdata_address, - DEG::color_end().c_str()); + deg::color_end().c_str()); fflush(stdout); } @@ -320,15 +322,15 @@ void DEG_debug_print_eval_subdata_index(struct Depsgraph *depsgraph, depsgraph_name_for_logging(depsgraph).c_str(), function_name, object_name, - DEG::color_for_pointer(object_address).c_str(), + deg::color_for_pointer(object_address).c_str(), object_address, - DEG::color_end().c_str(), + deg::color_end().c_str(), subdata_comment, subdata_name, subdata_index, - DEG::color_for_pointer(subdata_address).c_str(), + deg::color_for_pointer(subdata_address).c_str(), subdata_address, - DEG::color_end().c_str()); + deg::color_end().c_str()); fflush(stdout); } @@ -348,14 +350,14 @@ void DEG_debug_print_eval_parent_typed(struct Depsgraph *depsgraph, depsgraph_name_for_logging(depsgraph).c_str(), function_name, object_name, - DEG::color_for_pointer(object_address).c_str(), + deg::color_for_pointer(object_address).c_str(), object_address, - DEG::color_end().c_str(), + deg::color_end().c_str(), parent_comment, parent_name, - DEG::color_for_pointer(parent_address).c_str(), + deg::color_for_pointer(parent_address).c_str(), parent_address, - DEG::color_end().c_str()); + deg::color_end().c_str()); fflush(stdout); } @@ -373,9 +375,9 @@ void DEG_debug_print_eval_time(struct Depsgraph *depsgraph, depsgraph_name_for_logging(depsgraph).c_str(), function_name, object_name, - DEG::color_for_pointer(object_address).c_str(), + deg::color_for_pointer(object_address).c_str(), object_address, - DEG::color_end().c_str(), + deg::color_end().c_str(), time); fflush(stdout); } diff --git a/source/blender/depsgraph/intern/depsgraph_eval.cc b/source/blender/depsgraph/intern/depsgraph_eval.cc index b6c6129e9ba..8a641f23a42 100644 --- a/source/blender/depsgraph/intern/depsgraph_eval.cc +++ b/source/blender/depsgraph/intern/depsgraph_eval.cc @@ -45,44 +45,46 @@ #include "intern/depsgraph.h" +namespace deg = blender::deg; + /* Evaluate all nodes tagged for updating. */ void DEG_evaluate_on_refresh(Main *bmain, Depsgraph *graph) { - DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph *>(graph); + deg::Depsgraph *deg_graph = reinterpret_cast<deg::Depsgraph *>(graph); deg_graph->ctime = BKE_scene_frame_get(deg_graph->scene); /* Update time on primary timesource. */ - DEG::TimeSourceNode *tsrc = deg_graph->find_time_source(); + deg::TimeSourceNode *tsrc = deg_graph->find_time_source(); tsrc->cfra = deg_graph->ctime; /* Update time in scene. */ if (deg_graph->scene_cow) { BKE_scene_frame_set(deg_graph->scene_cow, deg_graph->ctime); } - DEG::deg_graph_flush_updates(bmain, deg_graph); - DEG::deg_evaluate_on_refresh(deg_graph); + deg::deg_graph_flush_updates(bmain, deg_graph); + deg::deg_evaluate_on_refresh(deg_graph); deg_graph->need_update_time = false; } /* Frame-change happened for root scene that graph belongs to. */ void DEG_evaluate_on_framechange(Main *bmain, Depsgraph *graph, float ctime) { - DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph *>(graph); + deg::Depsgraph *deg_graph = reinterpret_cast<deg::Depsgraph *>(graph); deg_graph->ctime = ctime; /* Update time on primary timesource. */ - DEG::TimeSourceNode *tsrc = deg_graph->find_time_source(); + deg::TimeSourceNode *tsrc = deg_graph->find_time_source(); tsrc->cfra = ctime; deg_graph->need_update_time = true; - DEG::deg_graph_flush_updates(bmain, deg_graph); + deg::deg_graph_flush_updates(bmain, deg_graph); /* Update time in scene. */ if (deg_graph->scene_cow) { BKE_scene_frame_set(deg_graph->scene_cow, deg_graph->ctime); } /* Perform recalculation updates. */ - DEG::deg_evaluate_on_refresh(deg_graph); + deg::deg_evaluate_on_refresh(deg_graph); deg_graph->need_update_time = false; } bool DEG_needs_eval(Depsgraph *graph) { - DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph *>(graph); + deg::Depsgraph *deg_graph = reinterpret_cast<deg::Depsgraph *>(graph); return !deg_graph->entry_tags.is_empty() || deg_graph->need_update_time; } diff --git a/source/blender/depsgraph/intern/depsgraph_physics.cc b/source/blender/depsgraph/intern/depsgraph_physics.cc index ad67117fda3..76f3a2e8ff4 100644 --- a/source/blender/depsgraph/intern/depsgraph_physics.cc +++ b/source/blender/depsgraph/intern/depsgraph_physics.cc @@ -44,6 +44,8 @@ #include "depsgraph.h" +namespace deg = blender::deg; + /*************************** Evaluation Query API *****************************/ static ePhysicsRelationType modifier_to_relation_type(unsigned int modifier_type) @@ -63,7 +65,7 @@ static ePhysicsRelationType modifier_to_relation_type(unsigned int modifier_type ListBase *DEG_get_effector_relations(const Depsgraph *graph, Collection *collection) { - const DEG::Depsgraph *deg_graph = reinterpret_cast<const DEG::Depsgraph *>(graph); + const deg::Depsgraph *deg_graph = reinterpret_cast<const deg::Depsgraph *>(graph); if (deg_graph->physics_relations[DEG_PHYSICS_EFFECTOR] == nullptr) { return nullptr; } @@ -77,7 +79,7 @@ ListBase *DEG_get_collision_relations(const Depsgraph *graph, Collection *collection, unsigned int modifier_type) { - const DEG::Depsgraph *deg_graph = reinterpret_cast<const DEG::Depsgraph *>(graph); + const deg::Depsgraph *deg_graph = reinterpret_cast<const deg::Depsgraph *>(graph); const ePhysicsRelationType type = modifier_to_relation_type(modifier_type); if (deg_graph->physics_relations[type] == nullptr) { return nullptr; @@ -96,7 +98,7 @@ void DEG_add_collision_relations(DepsNodeHandle *handle, const char *name) { Depsgraph *depsgraph = DEG_get_graph_from_handle(handle); - DEG::Depsgraph *deg_graph = (DEG::Depsgraph *)depsgraph; + deg::Depsgraph *deg_graph = (deg::Depsgraph *)depsgraph; ListBase *relations = build_collision_relations(deg_graph, collection, modifier_type); LISTBASE_FOREACH (CollisionRelation *, relation, relations) { Object *ob1 = relation->ob; @@ -119,7 +121,7 @@ void DEG_add_forcefield_relations(DepsNodeHandle *handle, const char *name) { Depsgraph *depsgraph = DEG_get_graph_from_handle(handle); - DEG::Depsgraph *deg_graph = (DEG::Depsgraph *)depsgraph; + deg::Depsgraph *deg_graph = (deg::Depsgraph *)depsgraph; ListBase *relations = build_effector_relations(deg_graph, effector_weights->group); LISTBASE_FOREACH (EffectorRelation *, relation, relations) { if (relation->ob == object) { @@ -158,7 +160,8 @@ void DEG_add_forcefield_relations(DepsNodeHandle *handle, /******************************** Internal API ********************************/ -namespace DEG { +namespace blender { +namespace deg { ListBase *build_effector_relations(Depsgraph *graph, Collection *collection) { @@ -218,4 +221,5 @@ void clear_physics_relations(Depsgraph *graph) } } -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/depsgraph_physics.h b/source/blender/depsgraph/intern/depsgraph_physics.h index f5d7b9817b5..dbcb577b0b2 100644 --- a/source/blender/depsgraph/intern/depsgraph_physics.h +++ b/source/blender/depsgraph/intern/depsgraph_physics.h @@ -26,7 +26,8 @@ struct Collection; struct ListBase; -namespace DEG { +namespace blender { +namespace deg { struct Depsgraph; @@ -36,4 +37,5 @@ ListBase *build_collision_relations(Depsgraph *graph, unsigned int modifier_type); void clear_physics_relations(Depsgraph *graph); -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/depsgraph_query.cc b/source/blender/depsgraph/intern/depsgraph_query.cc index 3c760e71197..0b6014c18f1 100644 --- a/source/blender/depsgraph/intern/depsgraph_query.cc +++ b/source/blender/depsgraph/intern/depsgraph_query.cc @@ -47,39 +47,41 @@ #include "intern/eval/deg_eval_copy_on_write.h" #include "intern/node/deg_node_id.h" +namespace deg = blender::deg; + struct Scene *DEG_get_input_scene(const Depsgraph *graph) { - const DEG::Depsgraph *deg_graph = reinterpret_cast<const DEG::Depsgraph *>(graph); + const deg::Depsgraph *deg_graph = reinterpret_cast<const deg::Depsgraph *>(graph); return deg_graph->scene; } struct ViewLayer *DEG_get_input_view_layer(const Depsgraph *graph) { - const DEG::Depsgraph *deg_graph = reinterpret_cast<const DEG::Depsgraph *>(graph); + const deg::Depsgraph *deg_graph = reinterpret_cast<const deg::Depsgraph *>(graph); return deg_graph->view_layer; } eEvaluationMode DEG_get_mode(const Depsgraph *graph) { - const DEG::Depsgraph *deg_graph = reinterpret_cast<const DEG::Depsgraph *>(graph); + const deg::Depsgraph *deg_graph = reinterpret_cast<const deg::Depsgraph *>(graph); return deg_graph->mode; } float DEG_get_ctime(const Depsgraph *graph) { - const DEG::Depsgraph *deg_graph = reinterpret_cast<const DEG::Depsgraph *>(graph); + const deg::Depsgraph *deg_graph = reinterpret_cast<const deg::Depsgraph *>(graph); return deg_graph->ctime; } bool DEG_id_type_updated(const Depsgraph *graph, short id_type) { - const DEG::Depsgraph *deg_graph = reinterpret_cast<const DEG::Depsgraph *>(graph); + const deg::Depsgraph *deg_graph = reinterpret_cast<const deg::Depsgraph *>(graph); return deg_graph->id_type_updated[BKE_idtype_idcode_to_index(id_type)] != 0; } bool DEG_id_type_any_updated(const Depsgraph *graph) { - const DEG::Depsgraph *deg_graph = reinterpret_cast<const DEG::Depsgraph *>(graph); + const deg::Depsgraph *deg_graph = reinterpret_cast<const deg::Depsgraph *>(graph); /* Loop over all ID types. */ for (int id_type_index = 0; id_type_index < MAX_LIBARRAY; id_type_index++) { @@ -93,7 +95,7 @@ bool DEG_id_type_any_updated(const Depsgraph *graph) bool DEG_id_type_any_exists(const Depsgraph *depsgraph, short id_type) { - const DEG::Depsgraph *deg_graph = reinterpret_cast<const DEG::Depsgraph *>(depsgraph); + const deg::Depsgraph *deg_graph = reinterpret_cast<const deg::Depsgraph *>(depsgraph); return deg_graph->id_type_exist[BKE_idtype_idcode_to_index(id_type)] != 0; } @@ -108,8 +110,8 @@ uint32_t DEG_get_eval_flags_for_id(const Depsgraph *graph, ID *id) return 0; } - const DEG::Depsgraph *deg_graph = reinterpret_cast<const DEG::Depsgraph *>(graph); - const DEG::IDNode *id_node = deg_graph->find_id_node(DEG_get_original_id(id)); + const deg::Depsgraph *deg_graph = reinterpret_cast<const deg::Depsgraph *>(graph); + const deg::IDNode *id_node = deg_graph->find_id_node(DEG_get_original_id(id)); if (id_node == nullptr) { /* TODO(sergey): Does it mean we need to check set scene? */ return 0; @@ -131,8 +133,8 @@ void DEG_get_customdata_mask_for_object(const Depsgraph *graph, return; } - const DEG::Depsgraph *deg_graph = reinterpret_cast<const DEG::Depsgraph *>(graph); - const DEG::IDNode *id_node = deg_graph->find_id_node(DEG_get_original_id(&ob->id)); + const deg::Depsgraph *deg_graph = reinterpret_cast<const deg::Depsgraph *>(graph); + const deg::IDNode *id_node = deg_graph->find_id_node(DEG_get_original_id(&ob->id)); if (id_node == nullptr) { /* TODO(sergey): Does it mean we need to check set scene? */ return; @@ -147,17 +149,17 @@ void DEG_get_customdata_mask_for_object(const Depsgraph *graph, Scene *DEG_get_evaluated_scene(const Depsgraph *graph) { - const DEG::Depsgraph *deg_graph = reinterpret_cast<const DEG::Depsgraph *>(graph); + const deg::Depsgraph *deg_graph = reinterpret_cast<const deg::Depsgraph *>(graph); Scene *scene_cow = deg_graph->scene_cow; /* TODO(sergey): Shall we expand data-block here? Or is it OK to assume * that caller is OK with just a pointer in case scene is not updated yet? */ - BLI_assert(scene_cow != nullptr && DEG::deg_copy_on_write_is_expanded(&scene_cow->id)); + BLI_assert(scene_cow != nullptr && deg::deg_copy_on_write_is_expanded(&scene_cow->id)); return scene_cow; } ViewLayer *DEG_get_evaluated_view_layer(const Depsgraph *graph) { - const DEG::Depsgraph *deg_graph = reinterpret_cast<const DEG::Depsgraph *>(graph); + const deg::Depsgraph *deg_graph = reinterpret_cast<const deg::Depsgraph *>(graph); Scene *scene_cow = DEG_get_evaluated_scene(graph); if (scene_cow == nullptr) { return nullptr; /* Happens with new, not-yet-built/evaluated graphes. */ @@ -184,8 +186,8 @@ ID *DEG_get_evaluated_id(const Depsgraph *depsgraph, ID *id) /* TODO(sergey): This is a duplicate of Depsgraph::get_cow_id(), * but here we never do assert, since we don't know nature of the * incoming ID data-block. */ - const DEG::Depsgraph *deg_graph = (const DEG::Depsgraph *)depsgraph; - const DEG::IDNode *id_node = deg_graph->find_id_node(id); + const deg::Depsgraph *deg_graph = (const deg::Depsgraph *)depsgraph; + const deg::IDNode *id_node = deg_graph->find_id_node(id); if (id_node == nullptr) { return id; } @@ -309,7 +311,7 @@ bool DEG_is_evaluated_object(const Object *object) bool DEG_is_fully_evaluated(const struct Depsgraph *depsgraph) { - const DEG::Depsgraph *deg_graph = (const DEG::Depsgraph *)depsgraph; + const deg::Depsgraph *deg_graph = (const deg::Depsgraph *)depsgraph; /* Check whether relations are up to date. */ if (deg_graph->need_update) { return false; diff --git a/source/blender/depsgraph/intern/depsgraph_query_foreach.cc b/source/blender/depsgraph/intern/depsgraph_query_foreach.cc index b68c4b91fcc..ebdd08ce519 100644 --- a/source/blender/depsgraph/intern/depsgraph_query_foreach.cc +++ b/source/blender/depsgraph/intern/depsgraph_query_foreach.cc @@ -40,9 +40,12 @@ #include "intern/node/deg_node_id.h" #include "intern/node/deg_node_operation.h" +namespace deg = blender::deg; + /* ************************ DEG TRAVERSAL ********************* */ -namespace DEG { +namespace blender { +namespace deg { namespace { typedef deque<OperationNode *> TraversalQueue; @@ -262,14 +265,15 @@ void deg_foreach_id(const Depsgraph *depsgraph, DEGForeachIDCallback callback, v } } // namespace -} // namespace DEG +} // namespace deg +} // namespace blender void DEG_foreach_dependent_ID(const Depsgraph *depsgraph, const ID *id, DEGForeachIDCallback callback, void *user_data) { - DEG::deg_foreach_dependent_ID((const DEG::Depsgraph *)depsgraph, id, callback, user_data); + deg::deg_foreach_dependent_ID((const deg::Depsgraph *)depsgraph, id, callback, user_data); } void DEG_foreach_dependent_ID_component(const Depsgraph *depsgraph, @@ -279,8 +283,8 @@ void DEG_foreach_dependent_ID_component(const Depsgraph *depsgraph, DEGForeachIDComponentCallback callback, void *user_data) { - DEG::deg_foreach_dependent_ID_component( - (const DEG::Depsgraph *)depsgraph, id, source_component_type, flags, callback, user_data); + deg::deg_foreach_dependent_ID_component( + (const deg::Depsgraph *)depsgraph, id, source_component_type, flags, callback, user_data); } void DEG_foreach_ancestor_ID(const Depsgraph *depsgraph, @@ -288,10 +292,10 @@ void DEG_foreach_ancestor_ID(const Depsgraph *depsgraph, DEGForeachIDCallback callback, void *user_data) { - DEG::deg_foreach_ancestor_ID((const DEG::Depsgraph *)depsgraph, id, callback, user_data); + deg::deg_foreach_ancestor_ID((const deg::Depsgraph *)depsgraph, id, callback, user_data); } void DEG_foreach_ID(const Depsgraph *depsgraph, DEGForeachIDCallback callback, void *user_data) { - DEG::deg_foreach_id((const DEG::Depsgraph *)depsgraph, callback, user_data); + deg::deg_foreach_id((const deg::Depsgraph *)depsgraph, callback, user_data); } diff --git a/source/blender/depsgraph/intern/depsgraph_query_iter.cc b/source/blender/depsgraph/intern/depsgraph_query_iter.cc index 1eb07206465..c27a7cc3b93 100644 --- a/source/blender/depsgraph/intern/depsgraph_query_iter.cc +++ b/source/blender/depsgraph/intern/depsgraph_query_iter.cc @@ -59,6 +59,8 @@ # define INVALIDATE_WORK_DATA #endif +namespace deg = blender::deg; + /* ************************ DEG ITERATORS ********************* */ namespace { @@ -169,14 +171,14 @@ bool deg_objects_dupli_iterator_next(BLI_Iterator *iter) copy_m4_m4(data->temp_dupli_object.obmat, dob->mat); invert_m4_m4(data->temp_dupli_object.imat, data->temp_dupli_object.obmat); iter->current = &data->temp_dupli_object; - BLI_assert(DEG::deg_validate_copy_on_write_datablock(&data->temp_dupli_object.id)); + BLI_assert(deg::deg_validate_copy_on_write_datablock(&data->temp_dupli_object.id)); return true; } return false; } -void deg_iterator_objects_step(BLI_Iterator *iter, DEG::IDNode *id_node) +void deg_iterator_objects_step(BLI_Iterator *iter, deg::IDNode *id_node) { /* Set it early in case we need to exit and we are running from within a loop. */ iter->skip = true; @@ -193,17 +195,17 @@ void deg_iterator_objects_step(BLI_Iterator *iter, DEG::IDNode *id_node) } switch (id_node->linked_state) { - case DEG::DEG_ID_LINKED_DIRECTLY: + case deg::DEG_ID_LINKED_DIRECTLY: if ((data->flag & DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY) == 0) { return; } break; - case DEG::DEG_ID_LINKED_VIA_SET: + case deg::DEG_ID_LINKED_VIA_SET: if ((data->flag & DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET) == 0) { return; } break; - case DEG::DEG_ID_LINKED_INDIRECTLY: + case deg::DEG_ID_LINKED_INDIRECTLY: if ((data->flag & DEG_ITER_OBJECT_FLAG_LINKED_INDIRECTLY) == 0) { return; } @@ -211,7 +213,7 @@ void deg_iterator_objects_step(BLI_Iterator *iter, DEG::IDNode *id_node) } Object *object = (Object *)id_node->id_cow; - BLI_assert(DEG::deg_validate_copy_on_write_datablock(&object->id)); + BLI_assert(deg::deg_validate_copy_on_write_datablock(&object->id)); int ob_visibility = OB_VISIBLE_ALL; if (data->flag & DEG_ITER_OBJECT_FLAG_VISIBLE) { @@ -241,7 +243,7 @@ void deg_iterator_objects_step(BLI_Iterator *iter, DEG::IDNode *id_node) void DEG_iterator_objects_begin(BLI_Iterator *iter, DEGObjectIterData *data) { Depsgraph *depsgraph = data->graph; - DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph *>(depsgraph); + deg::Depsgraph *deg_graph = reinterpret_cast<deg::Depsgraph *>(depsgraph); const size_t num_id_nodes = deg_graph->id_nodes.size(); iter->data = data; @@ -261,7 +263,7 @@ void DEG_iterator_objects_begin(BLI_Iterator *iter, DEGObjectIterData *data) data->eval_mode = DEG_get_mode(depsgraph); deg_invalidate_iterator_work_data(data); - DEG::IDNode *id_node = deg_graph->id_nodes[data->id_node_index]; + deg::IDNode *id_node = deg_graph->id_nodes[data->id_node_index]; deg_iterator_objects_step(iter, id_node); if (iter->skip) { @@ -273,7 +275,7 @@ void DEG_iterator_objects_next(BLI_Iterator *iter) { DEGObjectIterData *data = (DEGObjectIterData *)iter->data; Depsgraph *depsgraph = data->graph; - DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph *>(depsgraph); + deg::Depsgraph *deg_graph = reinterpret_cast<deg::Depsgraph *>(depsgraph); do { iter->skip = false; if (data->dupli_list) { @@ -297,7 +299,7 @@ void DEG_iterator_objects_next(BLI_Iterator *iter) return; } - DEG::IDNode *id_node = deg_graph->id_nodes[data->id_node_index]; + deg::IDNode *id_node = deg_graph->id_nodes[data->id_node_index]; deg_iterator_objects_step(iter, id_node); } while (iter->skip); } @@ -314,7 +316,7 @@ void DEG_iterator_objects_end(BLI_Iterator *iter) /* ************************ DEG ID ITERATOR ********************* */ -static void DEG_iterator_ids_step(BLI_Iterator *iter, DEG::IDNode *id_node, bool only_updated) +static void DEG_iterator_ids_step(BLI_Iterator *iter, deg::IDNode *id_node, bool only_updated) { ID *id_cow = id_node->id_cow; @@ -339,7 +341,7 @@ static void DEG_iterator_ids_step(BLI_Iterator *iter, DEG::IDNode *id_node, bool void DEG_iterator_ids_begin(BLI_Iterator *iter, DEGIDIterData *data) { Depsgraph *depsgraph = data->graph; - DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph *>(depsgraph); + deg::Depsgraph *deg_graph = reinterpret_cast<deg::Depsgraph *>(depsgraph); const size_t num_id_nodes = deg_graph->id_nodes.size(); iter->data = data; @@ -352,7 +354,7 @@ void DEG_iterator_ids_begin(BLI_Iterator *iter, DEGIDIterData *data) data->id_node_index = 0; data->num_id_nodes = num_id_nodes; - DEG::IDNode *id_node = deg_graph->id_nodes[data->id_node_index]; + deg::IDNode *id_node = deg_graph->id_nodes[data->id_node_index]; DEG_iterator_ids_step(iter, id_node, data->only_updated); if (iter->skip) { @@ -364,7 +366,7 @@ void DEG_iterator_ids_next(BLI_Iterator *iter) { DEGIDIterData *data = (DEGIDIterData *)iter->data; Depsgraph *depsgraph = data->graph; - DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph *>(depsgraph); + deg::Depsgraph *deg_graph = reinterpret_cast<deg::Depsgraph *>(depsgraph); do { iter->skip = false; @@ -375,7 +377,7 @@ void DEG_iterator_ids_next(BLI_Iterator *iter) return; } - DEG::IDNode *id_node = deg_graph->id_nodes[data->id_node_index]; + deg::IDNode *id_node = deg_graph->id_nodes[data->id_node_index]; DEG_iterator_ids_step(iter, id_node, data->only_updated); } while (iter->skip); } diff --git a/source/blender/depsgraph/intern/depsgraph_registry.cc b/source/blender/depsgraph/intern/depsgraph_registry.cc index 7eac7b45069..6bfd2e881cc 100644 --- a/source/blender/depsgraph/intern/depsgraph_registry.cc +++ b/source/blender/depsgraph/intern/depsgraph_registry.cc @@ -27,7 +27,8 @@ #include "intern/depsgraph.h" -namespace DEG { +namespace blender { +namespace deg { static Map<Main *, VectorSet<Depsgraph *>> g_graph_registry; @@ -58,4 +59,5 @@ Span<Depsgraph *> get_all_registered_graphs(Main *bmain) return {}; } -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/depsgraph_registry.h b/source/blender/depsgraph/intern/depsgraph_registry.h index 967791d2fbf..dc29f9d8edf 100644 --- a/source/blender/depsgraph/intern/depsgraph_registry.h +++ b/source/blender/depsgraph/intern/depsgraph_registry.h @@ -27,7 +27,8 @@ struct Main; -namespace DEG { +namespace blender { +namespace deg { struct Depsgraph; @@ -35,4 +36,5 @@ void register_graph(Depsgraph *depsgraph); void unregister_graph(Depsgraph *depsgraph); Span<Depsgraph *> get_all_registered_graphs(Main *bmain); -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/depsgraph_relation.cc b/source/blender/depsgraph/intern/depsgraph_relation.cc index a4ec48658f5..d09247b03d9 100644 --- a/source/blender/depsgraph/intern/depsgraph_relation.cc +++ b/source/blender/depsgraph/intern/depsgraph_relation.cc @@ -28,7 +28,8 @@ #include "intern/depsgraph_type.h" #include "intern/node/deg_node.h" -namespace DEG { +namespace blender { +namespace deg { Relation::Relation(Node *from, Node *to, const char *description) : from(from), to(to), name(description), flag(0) @@ -64,4 +65,5 @@ void Relation::unlink() to->inlinks.remove_first_occurrence_and_reorder(this); } -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/depsgraph_relation.h b/source/blender/depsgraph/intern/depsgraph_relation.h index 2f9f0249b1f..a5d69c08d1f 100644 --- a/source/blender/depsgraph/intern/depsgraph_relation.h +++ b/source/blender/depsgraph/intern/depsgraph_relation.h @@ -23,7 +23,8 @@ #pragma once -namespace DEG { +namespace blender { +namespace deg { struct Node; @@ -60,4 +61,5 @@ struct Relation { int flag; /* Bitmask of RelationFlag) */ }; -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/depsgraph_tag.cc b/source/blender/depsgraph/intern/depsgraph_tag.cc index b757a4fc477..f13153545fd 100644 --- a/source/blender/depsgraph/intern/depsgraph_tag.cc +++ b/source/blender/depsgraph/intern/depsgraph_tag.cc @@ -70,10 +70,13 @@ #include "intern/node/deg_node_id.h" #include "intern/node/deg_node_operation.h" +namespace deg = blender::deg; + /* *********************** */ /* Update Tagging/Flushing */ -namespace DEG { +namespace blender { +namespace deg { namespace { @@ -109,7 +112,7 @@ void depsgraph_select_tag_to_component_opcode(const ID *id, } else if (id_type == ID_OB) { *component_type = NodeType::OBJECT_FROM_LAYER; - *operation_code = OperationCode::OBJECT_BASE_FLAGS; + *operation_code = OperationCode::OBJECT_FROM_LAYER_ENTRY; } else if (id_type == ID_MC) { *component_type = NodeType::BATCH_CACHE; @@ -510,7 +513,7 @@ void deg_graph_on_visible_update(Main *bmain, Depsgraph *graph, const bool do_ti /* NOTE: It is possible to have this function called with `do_time=false` first and later (prior * to evaluation though) with `do_time=true`. This means early output checks should be aware of * this. */ - for (DEG::IDNode *id_node : graph->id_nodes) { + for (deg::IDNode *id_node : graph->id_nodes) { const ID_Type id_type = GS(id_node->id_orig->name); if (id_type == ID_OB) { Object *object_orig = reinterpret_cast<Object *>(id_node->id_orig); @@ -525,7 +528,7 @@ void deg_graph_on_visible_update(Main *bmain, Depsgraph *graph, const bool do_ti continue; } int flag = 0; - if (!DEG::deg_copy_on_write_is_expanded(id_node->id_cow)) { + if (!deg::deg_copy_on_write_is_expanded(id_node->id_cow)) { flag |= ID_RECALC_COPY_ON_WRITE; if (do_time) { if (BKE_animdata_from_id(id_node->id_orig) != nullptr) { @@ -619,7 +622,7 @@ NodeType geometry_tag_to_component(const ID *id) void id_tag_update(Main *bmain, ID *id, int flag, eUpdateSource update_source) { graph_id_tag_update(bmain, nullptr, id, flag, update_source); - for (DEG::Depsgraph *depsgraph : DEG::get_all_registered_graphs(bmain)) { + for (deg::Depsgraph *depsgraph : deg::get_all_registered_graphs(bmain)) { graph_id_tag_update(bmain, depsgraph, id, flag, update_source); } @@ -684,7 +687,8 @@ void graph_id_tag_update( } } -} // namespace DEG +} // namespace deg +} // namespace blender const char *DEG_update_tag_as_string(IDRecalcFlag flag) { @@ -759,7 +763,7 @@ void DEG_id_tag_update_ex(Main *bmain, ID *id, int flag) /* Ideally should not happen, but old depsgraph allowed this. */ return; } - DEG::id_tag_update(bmain, id, flag, DEG::DEG_UPDATE_SOURCE_USER_EDIT); + deg::id_tag_update(bmain, id, flag, deg::DEG_UPDATE_SOURCE_USER_EDIT); } void DEG_graph_id_tag_update(struct Main *bmain, @@ -767,8 +771,8 @@ void DEG_graph_id_tag_update(struct Main *bmain, struct ID *id, int flag) { - DEG::Depsgraph *graph = (DEG::Depsgraph *)depsgraph; - DEG::graph_id_tag_update(bmain, graph, id, flag, DEG::DEG_UPDATE_SOURCE_USER_EDIT); + deg::Depsgraph *graph = (deg::Depsgraph *)depsgraph; + deg::graph_id_tag_update(bmain, graph, id, flag, deg::DEG_UPDATE_SOURCE_USER_EDIT); } /* Mark a particular datablock type as having changing. */ @@ -784,13 +788,13 @@ void DEG_graph_id_type_tag(Depsgraph *depsgraph, short id_type) DEG_graph_id_type_tag(depsgraph, ID_SCE); } const int id_type_index = BKE_idtype_idcode_to_index(id_type); - DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph *>(depsgraph); + deg::Depsgraph *deg_graph = reinterpret_cast<deg::Depsgraph *>(depsgraph); deg_graph->id_type_updated[id_type_index] = 1; } void DEG_id_type_tag(Main *bmain, short id_type) { - for (DEG::Depsgraph *depsgraph : DEG::get_all_registered_graphs(bmain)) { + for (deg::Depsgraph *depsgraph : deg::get_all_registered_graphs(bmain)) { DEG_graph_id_type_tag(reinterpret_cast<::Depsgraph *>(depsgraph), id_type); } } @@ -798,13 +802,13 @@ void DEG_id_type_tag(Main *bmain, short id_type) /* Update dependency graph when visible scenes/layers changes. */ void DEG_graph_on_visible_update(Main *bmain, Depsgraph *depsgraph, const bool do_time) { - DEG::Depsgraph *graph = (DEG::Depsgraph *)depsgraph; - DEG::deg_graph_on_visible_update(bmain, graph, do_time); + deg::Depsgraph *graph = (deg::Depsgraph *)depsgraph; + deg::deg_graph_on_visible_update(bmain, graph, do_time); } void DEG_on_visible_update(Main *bmain, const bool do_time) { - for (DEG::Depsgraph *depsgraph : DEG::get_all_registered_graphs(bmain)) { + for (deg::Depsgraph *depsgraph : deg::get_all_registered_graphs(bmain)) { DEG_graph_on_visible_update(bmain, reinterpret_cast<::Depsgraph *>(depsgraph), do_time); } } @@ -821,7 +825,7 @@ void DEG_ids_check_recalc( update_ctx.depsgraph = depsgraph; update_ctx.scene = scene; update_ctx.view_layer = view_layer; - DEG::deg_editors_scene_update(&update_ctx, updated); + deg::deg_editors_scene_update(&update_ctx, updated); } static void deg_graph_clear_id_recalc_flags(ID *id) @@ -837,14 +841,14 @@ static void deg_graph_clear_id_recalc_flags(ID *id) void DEG_ids_clear_recalc(Main *UNUSED(bmain), Depsgraph *depsgraph) { - DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph *>(depsgraph); + deg::Depsgraph *deg_graph = reinterpret_cast<deg::Depsgraph *>(depsgraph); /* TODO(sergey): Re-implement POST_UPDATE_HANDLER_WORKAROUND using entry_tags * and id_tags storage from the new dependency graph. */ if (!DEG_id_type_any_updated(depsgraph)) { return; } /* Go over all ID nodes nodes, clearing tags. */ - for (DEG::IDNode *id_node : deg_graph->id_nodes) { + for (deg::IDNode *id_node : deg_graph->id_nodes) { /* TODO: we clear original ID recalc flags here, but this may not work * correctly when there are multiple depsgraph with others still using * the recalc flag. */ diff --git a/source/blender/depsgraph/intern/depsgraph_tag.h b/source/blender/depsgraph/intern/depsgraph_tag.h index e79372f2459..68b6a164be4 100644 --- a/source/blender/depsgraph/intern/depsgraph_tag.h +++ b/source/blender/depsgraph/intern/depsgraph_tag.h @@ -26,7 +26,8 @@ struct ID; struct Main; -namespace DEG { +namespace blender { +namespace deg { struct Depsgraph; @@ -40,4 +41,5 @@ void id_tag_update(Main *bmain, ID *id, int flag, eUpdateSource update_source); void graph_id_tag_update( Main *bmain, Depsgraph *graph, ID *id, int flag, eUpdateSource update_source); -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/depsgraph_type.cc b/source/blender/depsgraph/intern/depsgraph_type.cc index 92d775b0ae4..25e9a4643b3 100644 --- a/source/blender/depsgraph/intern/depsgraph_type.cc +++ b/source/blender/depsgraph/intern/depsgraph_type.cc @@ -37,13 +37,15 @@ #include "intern/node/deg_node_factory.h" #include "intern/node/deg_node_operation.h" +namespace deg = blender::deg; + /* Register all node types */ void DEG_register_node_types(void) { /* register node types */ - DEG::deg_register_base_depsnodes(); - DEG::deg_register_component_depsnodes(); - DEG::deg_register_operation_depsnodes(); + deg::deg_register_base_depsnodes(); + deg::deg_register_component_depsnodes(); + deg::deg_register_operation_depsnodes(); } /* Free registry on exit */ @@ -51,7 +53,7 @@ void DEG_free_node_types(void) { } -DEG::DEGCustomDataMeshMasks::DEGCustomDataMeshMasks(const CustomData_MeshMasks *other) +deg::DEGCustomDataMeshMasks::DEGCustomDataMeshMasks(const CustomData_MeshMasks *other) : vert_mask(other->vmask), edge_mask(other->emask), face_mask(other->fmask), diff --git a/source/blender/depsgraph/intern/depsgraph_type.h b/source/blender/depsgraph/intern/depsgraph_type.h index 3d386695e6c..50f697323c4 100644 --- a/source/blender/depsgraph/intern/depsgraph_type.h +++ b/source/blender/depsgraph/intern/depsgraph_type.h @@ -50,20 +50,13 @@ struct Depsgraph; struct CustomData_MeshMasks; -namespace DEG { +namespace blender { +namespace deg { /* Commonly used types. */ -using blender::Map; -using blender::Set; -using blender::Span; -using blender::StringRef; -using blender::StringRefNull; -using blender::Vector; -using blender::VectorSet; using std::deque; -using std::map; +using std::optional; using std::pair; -using std::set; using std::string; using std::unique_ptr; @@ -176,4 +169,5 @@ struct DEGCustomDataMeshMasks { } }; -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/depsgraph_update.cc b/source/blender/depsgraph/intern/depsgraph_update.cc index d10bfaaace8..98ff136f7bc 100644 --- a/source/blender/depsgraph/intern/depsgraph_update.cc +++ b/source/blender/depsgraph/intern/depsgraph_update.cc @@ -27,7 +27,10 @@ #include "intern/depsgraph_type.h" -namespace DEG { +namespace deg = blender::deg; + +namespace blender { +namespace deg { static DEG_EditorUpdateIDCb deg_editor_update_id_cb = nullptr; static DEG_EditorUpdateSceneCb deg_editor_update_scene_cb = nullptr; @@ -46,11 +49,12 @@ void deg_editors_scene_update(const DEGEditorUpdateContext *update_ctx, bool upd } } -} // namespace DEG +} // namespace deg +} // namespace blender /* Set callbacks which are being called when depsgraph changes. */ void DEG_editors_set_update_cb(DEG_EditorUpdateIDCb id_func, DEG_EditorUpdateSceneCb scene_func) { - DEG::deg_editor_update_id_cb = id_func; - DEG::deg_editor_update_scene_cb = scene_func; + deg::deg_editor_update_id_cb = id_func; + deg::deg_editor_update_scene_cb = scene_func; } diff --git a/source/blender/depsgraph/intern/depsgraph_update.h b/source/blender/depsgraph/intern/depsgraph_update.h index 1723658ced3..6f40a4366a5 100644 --- a/source/blender/depsgraph/intern/depsgraph_update.h +++ b/source/blender/depsgraph/intern/depsgraph_update.h @@ -26,10 +26,12 @@ struct DEGEditorUpdateContext; struct ID; -namespace DEG { +namespace blender { +namespace deg { void deg_editors_id_update(const DEGEditorUpdateContext *update_ctx, struct ID *id); void deg_editors_scene_update(const DEGEditorUpdateContext *update_ctx, bool updated); -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/eval/deg_eval.cc b/source/blender/depsgraph/intern/eval/deg_eval.cc index 189beb506b3..6ca30a67f1f 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval.cc +++ b/source/blender/depsgraph/intern/eval/deg_eval.cc @@ -54,7 +54,8 @@ #include "intern/node/deg_node_operation.h" #include "intern/node/deg_node_time.h" -namespace DEG { +namespace blender { +namespace deg { namespace { @@ -416,4 +417,5 @@ void deg_evaluate_on_refresh(Depsgraph *graph) graph->debug.end_graph_evaluation(); } -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/eval/deg_eval.h b/source/blender/depsgraph/intern/eval/deg_eval.h index 5baf13653ca..49690f15412 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval.h +++ b/source/blender/depsgraph/intern/eval/deg_eval.h @@ -25,7 +25,8 @@ #pragma once -namespace DEG { +namespace blender { +namespace deg { struct Depsgraph; @@ -38,4 +39,5 @@ struct Depsgraph; */ void deg_evaluate_on_refresh(Depsgraph *graph); -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc index 70a6875f1c0..2290c37fc2a 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc +++ b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc @@ -100,7 +100,8 @@ #include "intern/node/deg_node.h" #include "intern/node/deg_node_id.h" -namespace DEG { +namespace blender { +namespace deg { #define DEBUG_PRINT \ if (G.debug & G_DEBUG_DEPSGRAPH_EVAL) \ @@ -945,7 +946,7 @@ ID *deg_expand_copy_on_write_datablock(const Depsgraph *depsgraph, DepsgraphNodeBuilder *node_builder, bool create_placeholders) { - DEG::IDNode *id_node = depsgraph->find_id_node(id_orig); + IDNode *id_node = depsgraph->find_id_node(id_orig); BLI_assert(id_node != nullptr); return deg_expand_copy_on_write_datablock(depsgraph, id_node, node_builder, create_placeholders); } @@ -969,7 +970,7 @@ ID *deg_update_copy_on_write_datablock(const Depsgraph *depsgraph, const IDNode /* NOTE: Depsgraph is supposed to have ID node already. */ ID *deg_update_copy_on_write_datablock(const Depsgraph *depsgraph, ID *id_orig) { - DEG::IDNode *id_node = depsgraph->find_id_node(id_orig); + IDNode *id_node = depsgraph->find_id_node(id_orig); BLI_assert(id_node != nullptr); return deg_update_copy_on_write_datablock(depsgraph, id_node); } @@ -1089,7 +1090,7 @@ void deg_free_copy_on_write_datablock(ID *id_cow) void deg_evaluate_copy_on_write(struct ::Depsgraph *graph, const IDNode *id_node) { - const DEG::Depsgraph *depsgraph = reinterpret_cast<const DEG::Depsgraph *>(graph); + const Depsgraph *depsgraph = reinterpret_cast<const Depsgraph *>(graph); DEG_debug_print_eval(graph, __func__, id_node->id_orig->name, id_node->id_cow); if (id_node->id_orig == &depsgraph->scene->id) { /* NOTE: This is handled by eval_ctx setup routines, which @@ -1137,4 +1138,5 @@ bool deg_copy_on_write_is_needed(const ID_Type id_type) return ID_TYPE_IS_COW(id_type); } -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.h b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.h index 05464d11f13..255ea840088 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.h +++ b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.h @@ -43,7 +43,8 @@ struct ID; struct Depsgraph; -namespace DEG { +namespace blender { +namespace deg { struct Depsgraph; class DepsgraphNodeBuilder; @@ -98,4 +99,5 @@ bool deg_copy_on_write_is_expanded(const struct ID *id_cow); bool deg_copy_on_write_is_needed(const ID *id_orig); bool deg_copy_on_write_is_needed(const ID_Type id_type); -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/eval/deg_eval_flush.cc b/source/blender/depsgraph/intern/eval/deg_eval_flush.cc index df6c139e916..a0a9ff7eca3 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_flush.cc +++ b/source/blender/depsgraph/intern/eval/deg_eval_flush.cc @@ -32,9 +32,11 @@ #include "BLI_task.h" #include "BLI_utildefines.h" +#include "BKE_key.h" #include "BKE_object.h" #include "BKE_scene.h" +#include "DNA_key_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" @@ -67,7 +69,8 @@ // catch usage of invalid state. #undef INVALIDATE_ON_FLUSH -namespace DEG { +namespace blender { +namespace deg { enum { ID_STATE_NONE = 0, @@ -227,7 +230,7 @@ void flush_editors_id_update(Depsgraph *graph, const DEGEditorUpdateContext *upd ID *id_orig = id_node->id_orig; ID *id_cow = id_node->id_cow; /* Gather recalc flags from all changed components. */ - for (DEG::ComponentNode *comp_node : id_node->components.values()) { + for (ComponentNode *comp_node : id_node->components.values()) { if (comp_node->custom_flags != COMPONENT_STATE_DONE) { continue; } @@ -250,9 +253,30 @@ void flush_editors_id_update(Depsgraph *graph, const DEGEditorUpdateContext *upd if (deg_copy_on_write_is_expanded(id_cow)) { if (graph->is_active && id_node->is_user_modified) { deg_editors_id_update(update_ctx, id_orig); - } - if (ID_IS_OVERRIDE_LIBRARY(id_orig)) { - id_orig->tag |= LIB_TAG_OVERRIDE_LIBRARY_AUTOREFRESH; + + /* We only want to tag an ID for lib-override auto-refresh if it was actually tagged as + * changed. CoW IDs indirectly modified because of changes in other IDs should never + * require a lib-override diffing. */ + if (ID_IS_OVERRIDE_LIBRARY_REAL(id_orig)) { + id_orig->tag |= LIB_TAG_OVERRIDE_LIBRARY_AUTOREFRESH; + } + else if (ID_IS_OVERRIDE_LIBRARY_VIRTUAL(id_orig)) { + switch (GS(id_orig->name)) { + case ID_KE: + ((Key *)id_orig)->from->tag |= LIB_TAG_OVERRIDE_LIBRARY_AUTOREFRESH; + break; + case ID_GR: + BLI_assert(id_orig->flag & LIB_EMBEDDED_DATA); + /* TODO. */ + break; + case ID_NT: + BLI_assert(id_orig->flag & LIB_EMBEDDED_DATA); + /* TODO. */ + break; + default: + BLI_assert(0); + } + } } /* Inform draw engines that something was changed. */ flush_engine_data_update(id_cow); @@ -336,9 +360,9 @@ void deg_graph_flush_updates(Main *bmain, Depsgraph *graph) if (graph->need_update_time) { const Scene *scene_orig = graph->scene; const float ctime = BKE_scene_frame_get(scene_orig); - DEG::TimeSourceNode *time_source = graph->find_time_source(); + TimeSourceNode *time_source = graph->find_time_source(); graph->ctime = ctime; - time_source->tag_update(graph, DEG::DEG_UPDATE_SOURCE_TIME); + time_source->tag_update(graph, DEG_UPDATE_SOURCE_TIME); } if (graph->entry_tags.is_empty()) { return; @@ -389,4 +413,5 @@ void deg_graph_clear_tags(Depsgraph *graph) graph->entry_tags.clear(); } -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/eval/deg_eval_flush.h b/source/blender/depsgraph/intern/eval/deg_eval_flush.h index a4550dd4851..c76dc9fe01d 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_flush.h +++ b/source/blender/depsgraph/intern/eval/deg_eval_flush.h @@ -27,7 +27,8 @@ struct Main; -namespace DEG { +namespace blender { +namespace deg { struct Depsgraph; @@ -39,4 +40,5 @@ void deg_graph_flush_updates(struct Main *bmain, struct Depsgraph *graph); /* Clear tags from all operation nodes. */ void deg_graph_clear_tags(struct Depsgraph *graph); -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup.cc b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup.cc index c3733cb235c..f3d9422a88b 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup.cc +++ b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup.cc @@ -29,7 +29,8 @@ #include "DRW_engine.h" -namespace DEG { +namespace blender { +namespace deg { RuntimeBackup::RuntimeBackup(const Depsgraph *depsgraph) : have_backup(false), @@ -116,4 +117,5 @@ void RuntimeBackup::restore_to_id(ID *id) } } -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup.h b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup.h index dde7d0b2782..c6249c83daa 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup.h +++ b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup.h @@ -32,7 +32,8 @@ #include "intern/eval/deg_eval_runtime_backup_sound.h" #include "intern/eval/deg_eval_runtime_backup_volume.h" -namespace DEG { +namespace blender { +namespace deg { struct Depsgraph; @@ -67,4 +68,5 @@ class RuntimeBackup { VolumeBackup volume_backup; }; -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_animation.cc b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_animation.cc index 29f70e8548e..6c4eb8a91ee 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_animation.cc +++ b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_animation.cc @@ -32,7 +32,8 @@ #include "intern/depsgraph.h" -namespace DEG { +namespace blender { +namespace deg { namespace { @@ -141,4 +142,5 @@ void AnimationBackup::restore_to_id(ID *id) } } -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_animation.h b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_animation.h index d021354e6f2..6b5d5eab75f 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_animation.h +++ b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_animation.h @@ -27,7 +27,8 @@ #include "intern/depsgraph_type.h" -namespace DEG { +namespace blender { +namespace deg { struct Depsgraph; @@ -62,4 +63,5 @@ class AnimationBackup { Vector<AnimationValueBackup> values_backup; }; -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_modifier.cc b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_modifier.cc index 3361c26a077..f2d9a87ca9d 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_modifier.cc +++ b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_modifier.cc @@ -23,7 +23,8 @@ #include "intern/eval/deg_eval_runtime_backup_modifier.h" -namespace DEG { +namespace blender { +namespace deg { ModifierDataBackupID::ModifierDataBackupID(const Depsgraph * /*depsgraph*/) : ModifierDataBackupID(nullptr, eModifierType_None) @@ -35,15 +36,16 @@ ModifierDataBackupID::ModifierDataBackupID(ModifierData *modifier_data, Modifier { } -bool ModifierDataBackupID::operator<(const ModifierDataBackupID &other) const +bool operator==(const ModifierDataBackupID &a, const ModifierDataBackupID &b) { - if (modifier_data < other.modifier_data) { - return true; - } - if (modifier_data == other.modifier_data) { - return static_cast<int>(type) < static_cast<int>(other.type); - } - return false; + return a.modifier_data == b.modifier_data && a.type == b.type; } -} // namespace DEG +uint32_t ModifierDataBackupID::hash() const +{ + uintptr_t ptr = (uintptr_t)modifier_data; + return (ptr >> 4) ^ (uintptr_t)type; +} + +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_modifier.h b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_modifier.h index 4b3d46126f3..dc16bdcc1b8 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_modifier.h +++ b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_modifier.h @@ -29,7 +29,8 @@ struct ModifierData; -namespace DEG { +namespace blender { +namespace deg { struct Depsgraph; @@ -46,13 +47,16 @@ class ModifierDataBackupID { ModifierDataBackupID(const Depsgraph *depsgraph); ModifierDataBackupID(ModifierData *modifier_data, ModifierType type); - bool operator<(const ModifierDataBackupID &other) const; + friend bool operator==(const ModifierDataBackupID &a, const ModifierDataBackupID &b); + + uint32_t hash() const; ModifierData *modifier_data; ModifierType type; }; /* Storage for backed up runtime modifier data. */ -typedef map<ModifierDataBackupID, void *> ModifierRuntimeDataBackup; +typedef Map<ModifierDataBackupID, void *> ModifierRuntimeDataBackup; -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_movieclip.cc b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_movieclip.cc index d552c8da99a..9d3740258cc 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_movieclip.cc +++ b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_movieclip.cc @@ -27,7 +27,8 @@ #include "BLI_utildefines.h" -namespace DEG { +namespace blender { +namespace deg { MovieClipBackup::MovieClipBackup(const Depsgraph * /*depsgraph*/) { @@ -58,4 +59,5 @@ void MovieClipBackup::restore_to_movieclip(MovieClip *movieclip) reset(); } -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_movieclip.h b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_movieclip.h index 427e9c7b483..0b1de633696 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_movieclip.h +++ b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_movieclip.h @@ -27,7 +27,8 @@ struct MovieClip; struct MovieClipCache; struct anim; -namespace DEG { +namespace blender { +namespace deg { struct Depsgraph; @@ -45,4 +46,5 @@ class MovieClipBackup { struct MovieClipCache *cache; }; -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_object.cc b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_object.cc index 2b172f824b6..e0957a10cb1 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_object.cc +++ b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_object.cc @@ -32,7 +32,8 @@ #include "BKE_action.h" #include "BKE_object.h" -namespace DEG { +namespace blender { +namespace deg { ObjectRuntimeBackup::ObjectRuntimeBackup(const Depsgraph * /*depsgraph*/) : base_flag(0), base_local_view_bits(0) @@ -75,7 +76,7 @@ void ObjectRuntimeBackup::backup_modifier_runtime_data(Object *object) } BLI_assert(modifier_data->orig_modifier_data != nullptr); ModifierDataBackupID modifier_data_id = create_modifier_data_id(modifier_data); - modifier_runtime_data.insert(make_pair(modifier_data_id, modifier_data->runtime)); + modifier_runtime_data.add(modifier_data_id, modifier_data->runtime); modifier_data->runtime = nullptr; } } @@ -86,7 +87,7 @@ void ObjectRuntimeBackup::backup_pose_channel_runtime_data(Object *object) LISTBASE_FOREACH (bPoseChannel *, pchan, &object->pose->chanbase) { /* This is nullptr in Edit mode. */ if (pchan->orig_pchan != nullptr) { - pose_channel_runtime_data[pchan->orig_pchan] = pchan->runtime; + pose_channel_runtime_data.add(pchan->orig_pchan, pchan->runtime); BKE_pose_channel_runtime_reset(&pchan->runtime); } } @@ -153,22 +154,16 @@ void ObjectRuntimeBackup::restore_modifier_runtime_data(Object *object) LISTBASE_FOREACH (ModifierData *, modifier_data, &object->modifiers) { BLI_assert(modifier_data->orig_modifier_data != nullptr); ModifierDataBackupID modifier_data_id = create_modifier_data_id(modifier_data); - ModifierRuntimeDataBackup::iterator runtime_data_iterator = modifier_runtime_data.find( - modifier_data_id); - if (runtime_data_iterator != modifier_runtime_data.end()) { - modifier_data->runtime = runtime_data_iterator->second; - runtime_data_iterator->second = nullptr; + void *runtime = modifier_runtime_data.pop_default(modifier_data_id, nullptr); + if (runtime != nullptr) { + modifier_data->runtime = runtime; } } - for (ModifierRuntimeDataBackup::value_type value : modifier_runtime_data) { - const ModifierDataBackupID modifier_data_id = value.first; - void *runtime = value.second; - if (value.second == nullptr) { - continue; - } - const ModifierTypeInfo *modifier_type_info = BKE_modifier_get_info(modifier_data_id.type); + + for (ModifierRuntimeDataBackup::Item item : modifier_runtime_data.items()) { + const ModifierTypeInfo *modifier_type_info = BKE_modifier_get_info(item.key.type); BLI_assert(modifier_type_info != nullptr); - modifier_type_info->freeRuntimeData(runtime); + modifier_type_info->freeRuntimeData(item.value); } } @@ -178,18 +173,18 @@ void ObjectRuntimeBackup::restore_pose_channel_runtime_data(Object *object) LISTBASE_FOREACH (bPoseChannel *, pchan, &object->pose->chanbase) { /* This is nullptr in Edit mode. */ if (pchan->orig_pchan != nullptr) { - PoseChannelRuntimeDataBackup::iterator runtime_data_iterator = - pose_channel_runtime_data.find(pchan->orig_pchan); - if (runtime_data_iterator != pose_channel_runtime_data.end()) { - pchan->runtime = runtime_data_iterator->second; - pose_channel_runtime_data.erase(runtime_data_iterator); + optional<bPoseChannel_Runtime> runtime = pose_channel_runtime_data.pop_try( + pchan->orig_pchan); + if (runtime.has_value()) { + pchan->runtime = *runtime; } } } } - for (PoseChannelRuntimeDataBackup::value_type &value : pose_channel_runtime_data) { - BKE_pose_channel_runtime_free(&value.second); + for (bPoseChannel_Runtime &runtime : pose_channel_runtime_data.values()) { + BKE_pose_channel_runtime_free(&runtime); } } -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_object.h b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_object.h index e5c3d6a967a..04d7fb1bc22 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_object.h +++ b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_object.h @@ -30,7 +30,8 @@ struct Object; -namespace DEG { +namespace blender { +namespace deg { class ObjectRuntimeBackup { public: @@ -53,7 +54,8 @@ class ObjectRuntimeBackup { short base_flag; unsigned short base_local_view_bits; ModifierRuntimeDataBackup modifier_runtime_data; - PoseChannelRuntimeDataBackup pose_channel_runtime_data; + Map<bPoseChannel *, bPoseChannel_Runtime> pose_channel_runtime_data; }; -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_pose.cc b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_pose.cc index 821cc21f359..45663378f67 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_pose.cc +++ b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_pose.cc @@ -23,6 +23,8 @@ #include "intern/eval/deg_eval_runtime_backup_pose.h" -namespace DEG { +namespace blender { +namespace deg { -} // namespace DEG +} +} // namespace blender diff --git a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_pose.h b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_pose.h index 53a2c4c0784..a6ce97529b7 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_pose.h +++ b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_pose.h @@ -27,11 +27,8 @@ #include "DNA_action_types.h" -struct bPoseChannel; +namespace blender { +namespace deg { -namespace DEG { - -/* Storage for backed up pose channel runtime data. */ -typedef map<bPoseChannel *, bPoseChannel_Runtime> PoseChannelRuntimeDataBackup; - -} // namespace DEG +} +} // namespace blender diff --git a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_scene.cc b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_scene.cc index 32b2d0b93c1..f000c8b5d4d 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_scene.cc +++ b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_scene.cc @@ -28,7 +28,8 @@ #include "DNA_rigidbody_types.h" #include "DNA_scene_types.h" -namespace DEG { +namespace blender { +namespace deg { SceneBackup::SceneBackup(const Depsgraph *depsgraph) : sequencer_backup(depsgraph) { @@ -85,4 +86,5 @@ void SceneBackup::restore_to_scene(Scene *scene) reset(); } -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_scene.h b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_scene.h index 751bc4208d2..007236e7890 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_scene.h +++ b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_scene.h @@ -27,7 +27,8 @@ struct Scene; -namespace DEG { +namespace blender { +namespace deg { struct Depsgraph; @@ -55,4 +56,5 @@ class SceneBackup { SequencerBackup sequencer_backup; }; -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_sequence.cc b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_sequence.cc index f26d78d3138..3866a89cc17 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_sequence.cc +++ b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_sequence.cc @@ -25,7 +25,8 @@ #include "DNA_sequence_types.h" -namespace DEG { +namespace blender { +namespace deg { SequenceBackup::SequenceBackup(const Depsgraph * /*depsgraph*/) { @@ -55,4 +56,5 @@ bool SequenceBackup::isEmpty() const return (scene_sound == nullptr); } -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_sequence.h b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_sequence.h index 8a762a2785e..eb38dc3dc5b 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_sequence.h +++ b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_sequence.h @@ -25,7 +25,8 @@ struct Sequence; -namespace DEG { +namespace blender { +namespace deg { struct Depsgraph; @@ -44,4 +45,5 @@ class SequenceBackup { void *scene_sound; }; -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_sequencer.cc b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_sequencer.cc index adc7fd570e8..2780938fe05 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_sequencer.cc +++ b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_sequencer.cc @@ -29,7 +29,8 @@ #include "BKE_sequencer.h" #include "BKE_sound.h" -namespace DEG { +namespace blender { +namespace deg { SequencerBackup::SequencerBackup(const Depsgraph *depsgraph) : depsgraph(depsgraph) { @@ -42,7 +43,7 @@ void SequencerBackup::init_from_scene(Scene *scene) SequenceBackup sequence_backup(depsgraph); sequence_backup.init_from_sequence(sequence); if (!sequence_backup.isEmpty()) { - sequences_backup.insert(make_pair(sequence->orig_sequence, sequence_backup)); + sequences_backup.add(sequence->orig_sequence, sequence_backup); } } SEQ_END; @@ -52,21 +53,19 @@ void SequencerBackup::restore_to_scene(Scene *scene) { Sequence *sequence; SEQ_BEGIN (scene->ed, sequence) { - SequencesBackupMap::iterator it = sequences_backup.find(sequence->orig_sequence); - if (it == sequences_backup.end()) { - continue; + SequenceBackup *sequence_backup = sequences_backup.lookup_ptr(sequence->orig_sequence); + if (sequence_backup != nullptr) { + sequence_backup->restore_to_sequence(sequence); } - SequenceBackup &sequence_backup = it->second; - sequence_backup.restore_to_sequence(sequence); } SEQ_END; /* Cleanup audio while the scene is still known. */ - for (SequencesBackupMap::value_type &it : sequences_backup) { - SequenceBackup &sequence_backup = it.second; + for (SequenceBackup &sequence_backup : sequences_backup.values()) { if (sequence_backup.scene_sound != nullptr) { BKE_sound_remove_scene_sound(scene, sequence_backup.scene_sound); } } } -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_sequencer.h b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_sequencer.h index 05f37b45dc4..9fe38ec270c 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_sequencer.h +++ b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_sequencer.h @@ -28,7 +28,8 @@ struct Scene; -namespace DEG { +namespace blender { +namespace deg { struct Depsgraph; @@ -42,8 +43,8 @@ class SequencerBackup { const Depsgraph *depsgraph; - typedef map<Sequence *, SequenceBackup> SequencesBackupMap; - SequencesBackupMap sequences_backup; + Map<Sequence *, SequenceBackup> sequences_backup; }; -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_sound.cc b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_sound.cc index f427d57a8ef..4b63ada8bde 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_sound.cc +++ b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_sound.cc @@ -27,7 +27,8 @@ #include "DNA_sound_types.h" -namespace DEG { +namespace blender { +namespace deg { SoundBackup::SoundBackup(const Depsgraph * /*depsgraph*/) { @@ -61,4 +62,5 @@ void SoundBackup::restore_to_sound(bSound *sound) reset(); } -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_sound.h b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_sound.h index 87783146701..754deb57556 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_sound.h +++ b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_sound.h @@ -25,7 +25,8 @@ struct bSound; -namespace DEG { +namespace blender { +namespace deg { struct Depsgraph; @@ -44,4 +45,5 @@ class SoundBackup { void *playback_handle; }; -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_volume.cc b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_volume.cc index 09e13ec131d..8808673ce6a 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_volume.cc +++ b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_volume.cc @@ -33,7 +33,8 @@ #include <stdio.h> -namespace DEG { +namespace blender { +namespace deg { VolumeBackup::VolumeBackup(const Depsgraph * /*depsgraph*/) : grids(nullptr) { @@ -57,4 +58,5 @@ void VolumeBackup::restore_to_volume(Volume *volume) } } -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_volume.h b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_volume.h index cf57c702c8f..c0ef5204653 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_volume.h +++ b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_volume.h @@ -26,7 +26,8 @@ struct Volume; struct VolumeGridVector; -namespace DEG { +namespace blender { +namespace deg { struct Depsgraph; @@ -42,4 +43,5 @@ class VolumeBackup { char filepath[1024]; /* FILE_MAX */ }; -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/eval/deg_eval_stats.cc b/source/blender/depsgraph/intern/eval/deg_eval_stats.cc index 9d3b1356570..3c84c781cbb 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_stats.cc +++ b/source/blender/depsgraph/intern/eval/deg_eval_stats.cc @@ -32,7 +32,8 @@ #include "intern/node/deg_node_id.h" #include "intern/node/deg_node_operation.h" -namespace DEG { +namespace blender { +namespace deg { void deg_eval_stats_aggregate(Depsgraph *graph) { @@ -54,4 +55,5 @@ void deg_eval_stats_aggregate(Depsgraph *graph) } } -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/eval/deg_eval_stats.h b/source/blender/depsgraph/intern/eval/deg_eval_stats.h index 988b42e15ae..8f0d3b1b938 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_stats.h +++ b/source/blender/depsgraph/intern/eval/deg_eval_stats.h @@ -23,11 +23,13 @@ #pragma once -namespace DEG { +namespace blender { +namespace deg { struct Depsgraph; /* Aggregate operation timings to overall component and ID nodes timing. */ void deg_eval_stats_aggregate(Depsgraph *graph); -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/node/deg_node.cc b/source/blender/depsgraph/intern/node/deg_node.cc index 10760d3170b..54a22a07ee4 100644 --- a/source/blender/depsgraph/intern/node/deg_node.cc +++ b/source/blender/depsgraph/intern/node/deg_node.cc @@ -36,7 +36,8 @@ #include "intern/node/deg_node_operation.h" #include "intern/node/deg_node_time.h" -namespace DEG { +namespace blender { +namespace deg { const char *nodeClassAsString(NodeClass node_class) { @@ -340,4 +341,5 @@ void deg_register_base_depsnodes() register_node_typeinfo(&DNTI_ID_REF); } -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/node/deg_node.h b/source/blender/depsgraph/intern/node/deg_node.h index f0ce38ddeae..94953c4ec5d 100644 --- a/source/blender/depsgraph/intern/node/deg_node.h +++ b/source/blender/depsgraph/intern/node/deg_node.h @@ -32,7 +32,8 @@ struct ID; struct Scene; -namespace DEG { +namespace blender { +namespace deg { struct Depsgraph; struct OperationNode; @@ -212,4 +213,5 @@ struct Node { void deg_register_base_depsnodes(); -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/node/deg_node_component.cc b/source/blender/depsgraph/intern/node/deg_node_component.cc index 87d704bb0a0..c99b3aba312 100644 --- a/source/blender/depsgraph/intern/node/deg_node_component.cc +++ b/source/blender/depsgraph/intern/node/deg_node_component.cc @@ -38,7 +38,8 @@ #include "intern/node/deg_node_id.h" #include "intern/node/deg_node_operation.h" -namespace DEG { +namespace blender { +namespace deg { /* *********** */ /* Outer Nodes */ @@ -377,4 +378,5 @@ void deg_register_component_depsnodes() register_node_typeinfo(&DNTI_SIMULATION); } -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/node/deg_node_component.h b/source/blender/depsgraph/intern/node/deg_node_component.h index 036baa9d46c..3757a1dea5b 100644 --- a/source/blender/depsgraph/intern/node/deg_node_component.h +++ b/source/blender/depsgraph/intern/node/deg_node_component.h @@ -32,7 +32,8 @@ struct ID; struct bPoseChannel; -namespace DEG { +namespace blender { +namespace deg { struct BoneComponentNode; struct Depsgraph; @@ -83,12 +84,9 @@ struct ComponentNode : public Node { * 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 */ + * \param opcode: 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, @@ -203,4 +201,5 @@ struct BoneComponentNode : public ComponentNode { void deg_register_component_depsnodes(); -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/node/deg_node_factory.cc b/source/blender/depsgraph/intern/node/deg_node_factory.cc index 9dfd018b4fd..9bb093139a1 100644 --- a/source/blender/depsgraph/intern/node/deg_node_factory.cc +++ b/source/blender/depsgraph/intern/node/deg_node_factory.cc @@ -23,7 +23,8 @@ #include "intern/node/deg_node_factory.h" -namespace DEG { +namespace blender { +namespace deg { /* Global type registry */ static DepsNodeFactory *node_typeinfo_registry[static_cast<int>(NodeType::NUM_TYPES)] = {nullptr}; @@ -42,4 +43,5 @@ DepsNodeFactory *type_get_factory(const NodeType type) return node_typeinfo_registry[type_as_int]; } -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/node/deg_node_factory.h b/source/blender/depsgraph/intern/node/deg_node_factory.h index db2c3bb2f44..125f340a0fa 100644 --- a/source/blender/depsgraph/intern/node/deg_node_factory.h +++ b/source/blender/depsgraph/intern/node/deg_node_factory.h @@ -30,7 +30,8 @@ struct ID; -namespace DEG { +namespace blender { +namespace deg { struct DepsNodeFactory { virtual NodeType type() const = 0; @@ -56,6 +57,7 @@ void register_node_typeinfo(DepsNodeFactory *factory); /* Get typeinfo for specified type */ DepsNodeFactory *type_get_factory(const NodeType type); -} // namespace DEG +} // namespace deg +} // namespace blender #include "intern/node/deg_node_factory_impl.h" 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 ad25ffdf26c..f5dd7122fca 100644 --- a/source/blender/depsgraph/intern/node/deg_node_factory_impl.h +++ b/source/blender/depsgraph/intern/node/deg_node_factory_impl.h @@ -27,7 +27,8 @@ struct ID; -namespace DEG { +namespace blender { +namespace deg { template<class ModeObjectType> NodeType DepsNodeFactoryImpl<ModeObjectType>::type() const { @@ -63,4 +64,5 @@ Node *DepsNodeFactoryImpl<ModeObjectType>::create_node(const ID *id, return node; } -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/node/deg_node_id.cc b/source/blender/depsgraph/intern/node/deg_node_id.cc index 984873fbcac..843f59b446a 100644 --- a/source/blender/depsgraph/intern/node/deg_node_id.cc +++ b/source/blender/depsgraph/intern/node/deg_node_id.cc @@ -41,7 +41,8 @@ #include "intern/node/deg_node_factory.h" #include "intern/node/deg_node_time.h" -namespace DEG { +namespace blender { +namespace deg { const char *linkedStateAsString(eDepsNode_LinkedState_Type linked_state) { @@ -212,4 +213,5 @@ IDComponentsMask IDNode::get_visible_components_mask() const return result; } -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/node/deg_node_id.h b/source/blender/depsgraph/intern/node/deg_node_id.h index 1e315195c1a..9bd6130bbdc 100644 --- a/source/blender/depsgraph/intern/node/deg_node_id.h +++ b/source/blender/depsgraph/intern/node/deg_node_id.h @@ -28,7 +28,8 @@ #include "DNA_ID.h" #include "intern/node/deg_node.h" -namespace DEG { +namespace blender { +namespace deg { struct ComponentNode; @@ -115,4 +116,5 @@ struct IDNode : public Node { DEG_DEPSNODE_DECLARE; }; -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/node/deg_node_operation.cc b/source/blender/depsgraph/intern/node/deg_node_operation.cc index 91bd0117f6c..680e7757ebb 100644 --- a/source/blender/depsgraph/intern/node/deg_node_operation.cc +++ b/source/blender/depsgraph/intern/node/deg_node_operation.cc @@ -32,7 +32,8 @@ #include "intern/node/deg_node_factory.h" #include "intern/node/deg_node_id.h" -namespace DEG { +namespace blender { +namespace deg { const char *operationCodeAsString(OperationCode opcode) { @@ -63,8 +64,12 @@ const char *operationCodeAsString(OperationCode opcode) case OperationCode::AUDIO_VOLUME: return "AUDIO_VOLUME"; /* Object related. */ + case OperationCode::OBJECT_FROM_LAYER_ENTRY: + return "OBJECT_FROM_LAYER_ENTRY"; case OperationCode::OBJECT_BASE_FLAGS: return "OBJECT_BASE_FLAGS"; + case OperationCode::OBJECT_FROM_LAYER_EXIT: + return "OBJECT_FROM_LAYER_EXIT"; case OperationCode::DIMENSIONS: return "DIMENSIONS"; /* Transform. */ @@ -266,4 +271,5 @@ void deg_register_operation_depsnodes() register_node_typeinfo(&DNTI_OPERATION); } -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/node/deg_node_operation.h b/source/blender/depsgraph/intern/node/deg_node_operation.h index 6b14e6af02f..87168fc3659 100644 --- a/source/blender/depsgraph/intern/node/deg_node_operation.h +++ b/source/blender/depsgraph/intern/node/deg_node_operation.h @@ -29,7 +29,8 @@ struct Depsgraph; -namespace DEG { +namespace blender { +namespace deg { struct ComponentNode; @@ -63,7 +64,9 @@ enum class OperationCode { AUDIO_VOLUME, /* Object related. ------------------------------------------------------ */ + OBJECT_FROM_LAYER_ENTRY, OBJECT_BASE_FLAGS, + OBJECT_FROM_LAYER_EXIT, DIMENSIONS, /* Transform. ----------------------------------------------------------- */ @@ -274,4 +277,5 @@ struct OperationNode : public Node { void deg_register_operation_depsnodes(); -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/node/deg_node_time.cc b/source/blender/depsgraph/intern/node/deg_node_time.cc index ff3e950bb44..af931fbae34 100644 --- a/source/blender/depsgraph/intern/node/deg_node_time.cc +++ b/source/blender/depsgraph/intern/node/deg_node_time.cc @@ -28,7 +28,8 @@ #include "intern/depsgraph.h" #include "intern/depsgraph_relation.h" -namespace DEG { +namespace blender { +namespace deg { void TimeSourceNode::tag_update(Depsgraph *graph, eUpdateSource /*source*/) { @@ -38,4 +39,5 @@ void TimeSourceNode::tag_update(Depsgraph *graph, eUpdateSource /*source*/) } } -} // namespace DEG +} // namespace deg +} // namespace blender diff --git a/source/blender/depsgraph/intern/node/deg_node_time.h b/source/blender/depsgraph/intern/node/deg_node_time.h index 684414f7780..364c214b014 100644 --- a/source/blender/depsgraph/intern/node/deg_node_time.h +++ b/source/blender/depsgraph/intern/node/deg_node_time.h @@ -25,7 +25,8 @@ #include "intern/node/deg_node.h" -namespace DEG { +namespace blender { +namespace deg { /* Time Source Node. */ struct TimeSourceNode : public Node { @@ -42,4 +43,5 @@ struct TimeSourceNode : public Node { DEG_DEPSNODE_DECLARE; }; -} // namespace DEG +} // namespace deg +} // namespace blender |