diff options
author | Julian Eisel <julian@blender.org> | 2022-11-10 15:17:42 +0300 |
---|---|---|
committer | Julian Eisel <julian@blender.org> | 2022-11-10 15:17:42 +0300 |
commit | 7246c387435769a169ac24c91434c615df6434b4 (patch) | |
tree | 61842e3e0ce85e80720fdd7476d44d2e629f59fd /source/blender/depsgraph | |
parent | c5f55d17096d373791363e46004176e3f7f7ae52 (diff) | |
parent | 0b4bd3ddc016298e868169a541cf6c132b10c587 (diff) |
Merge branch 'master' into asset-browser-grid-viewasset-browser-grid-view
Diffstat (limited to 'source/blender/depsgraph')
39 files changed, 517 insertions, 360 deletions
diff --git a/source/blender/depsgraph/CMakeLists.txt b/source/blender/depsgraph/CMakeLists.txt index e799c5ce32a..a394ea4a54a 100644 --- a/source/blender/depsgraph/CMakeLists.txt +++ b/source/blender/depsgraph/CMakeLists.txt @@ -26,6 +26,8 @@ set(SRC intern/builder/deg_builder.cc intern/builder/deg_builder_cache.cc intern/builder/deg_builder_cycle.cc + intern/builder/deg_builder_key.cc + intern/builder/deg_builder_key.h intern/builder/deg_builder_map.cc intern/builder/deg_builder_nodes.cc intern/builder/deg_builder_nodes_rig.cc @@ -34,7 +36,6 @@ set(SRC intern/builder/deg_builder_pchanmap.cc intern/builder/deg_builder_relations.cc intern/builder/deg_builder_relations_drivers.cc - intern/builder/deg_builder_relations_keys.cc intern/builder/deg_builder_relations_rig.cc intern/builder/deg_builder_relations_scene.cc intern/builder/deg_builder_relations_view_layer.cc diff --git a/source/blender/depsgraph/DEG_depsgraph.h b/source/blender/depsgraph/DEG_depsgraph.h index a8b21e4c153..48a6a5cda74 100644 --- a/source/blender/depsgraph/DEG_depsgraph.h +++ b/source/blender/depsgraph/DEG_depsgraph.h @@ -221,6 +221,14 @@ bool DEG_is_active(const struct Depsgraph *depsgraph); void DEG_make_active(struct Depsgraph *depsgraph); void DEG_make_inactive(struct Depsgraph *depsgraph); +/** + * Disable the visibility optimization making it so IDs which affect hidden objects or disabled + * modifiers are still evaluated. + * + * For example, this ensures that an object which is needed by a modifier is ignoring checks about + * whether the object is hidden or the modifier is disabled. */ +void DEG_disable_visibility_optimization(struct Depsgraph *depsgraph); + /** \} */ /* -------------------------------------------------------------------- */ diff --git a/source/blender/depsgraph/DEG_depsgraph_build.h b/source/blender/depsgraph/DEG_depsgraph_build.h index 201a534f535..ffeb5e897ab 100644 --- a/source/blender/depsgraph/DEG_depsgraph_build.h +++ b/source/blender/depsgraph/DEG_depsgraph_build.h @@ -56,6 +56,9 @@ void DEG_graph_build_for_render_pipeline(struct Depsgraph *graph); */ void DEG_graph_build_for_compositor_preview(struct Depsgraph *graph, struct bNodeTree *nodetree); +/** + * Builds the minimal dependency graph needed for evaluation of the given IDs. + */ void DEG_graph_build_from_ids(struct Depsgraph *graph, struct ID **ids, int num_ids); /** Tag relations from the given graph for update. */ diff --git a/source/blender/depsgraph/DEG_depsgraph_query.h b/source/blender/depsgraph/DEG_depsgraph_query.h index 12663e74d24..4a9025641f9 100644 --- a/source/blender/depsgraph/DEG_depsgraph_query.h +++ b/source/blender/depsgraph/DEG_depsgraph_query.h @@ -10,6 +10,7 @@ #pragma once #include "BLI_iterator.h" +#include "BLI_utildefines.h" #include "DEG_depsgraph.h" #include "DEG_depsgraph_build.h" @@ -26,6 +27,7 @@ struct ListBase; struct PointerRNA; struct Scene; struct ViewLayer; +struct ViewerPath; #ifdef __cplusplus extern "C" { @@ -132,15 +134,42 @@ bool DEG_is_fully_evaluated(const struct Depsgraph *depsgraph); /** \name DEG object iterators * \{ */ -enum { +typedef enum DegIterFlag { DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY = (1 << 0), DEG_ITER_OBJECT_FLAG_LINKED_INDIRECTLY = (1 << 1), DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET = (1 << 2), DEG_ITER_OBJECT_FLAG_VISIBLE = (1 << 3), DEG_ITER_OBJECT_FLAG_DUPLI = (1 << 4), -}; +} DegIterFlag; +ENUM_OPERATORS(DegIterFlag, DEG_ITER_OBJECT_FLAG_DUPLI) + +typedef struct DEGObjectIterSettings { + struct Depsgraph *depsgraph; + /** + * Bit-field of the #DegIterFlag. + * + * NOTE: Be careful with #DEG_ITER_OBJECT_FLAG_LINKED_INDIRECTLY objects. + * Although they are available they have no overrides (collection_properties) + * and will crash if you try to access it. + */ + uint32_t flags; + + /** + * When set, the final evaluated geometry of the corresponding object is omitted. Instead the + * geometry for the viewer path included in the iterator. + */ + const struct ViewerPath *viewer_path; +} DEGObjectIterSettings; + +/** + * Flags to to get objects for draw manager and final render. + */ +#define DEG_OBJECT_ITER_FOR_RENDER_ENGINE_FLAGS \ + DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY | DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET | \ + DEG_ITER_OBJECT_FLAG_VISIBLE | DEG_ITER_OBJECT_FLAG_DUPLI typedef struct DEGObjectIterData { + DEGObjectIterSettings *settings; struct Depsgraph *graph; int flag; @@ -148,6 +177,9 @@ typedef struct DEGObjectIterData { eEvaluationMode eval_mode; + /** Object whose preview instead of evaluated geometry should be part of the iterator. */ + struct Object *object_orig_with_preview; + struct Object *next_object; /* **** Iteration over dupli-list. *** */ @@ -174,16 +206,12 @@ void DEG_iterator_objects_begin(struct BLI_Iterator *iter, DEGObjectIterData *da void DEG_iterator_objects_next(struct BLI_Iterator *iter); void DEG_iterator_objects_end(struct BLI_Iterator *iter); -/** - * NOTE: Be careful with DEG_ITER_OBJECT_FLAG_LINKED_INDIRECTLY objects. - * Although they are available they have no overrides (collection_properties) - * and will crash if you try to access it. - */ -#define DEG_OBJECT_ITER_BEGIN(graph_, instance_, flag_) \ +#define DEG_OBJECT_ITER_BEGIN(settings_, instance_) \ { \ DEGObjectIterData data_ = { \ - graph_, \ - flag_, \ + (settings_), \ + (settings_)->depsgraph, \ + (int)(settings_)->flags, \ }; \ \ ITER_BEGIN (DEG_iterator_objects_begin, \ @@ -198,18 +226,6 @@ void DEG_iterator_objects_end(struct BLI_Iterator *iter); } \ ((void)0) -/** - * Depsgraph objects iterator for draw manager and final render - */ -#define DEG_OBJECT_ITER_FOR_RENDER_ENGINE_BEGIN(graph_, instance_) \ - DEG_OBJECT_ITER_BEGIN (graph_, \ - instance_, \ - DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY | \ - DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET | DEG_ITER_OBJECT_FLAG_VISIBLE | \ - DEG_ITER_OBJECT_FLAG_DUPLI) - -#define DEG_OBJECT_ITER_FOR_RENDER_ENGINE_END DEG_OBJECT_ITER_END - /** \} */ /* -------------------------------------------------------------------- */ diff --git a/source/blender/depsgraph/intern/builder/deg_builder.cc b/source/blender/depsgraph/intern/builder/deg_builder.cc index 097c377ece4..16510d5f9a6 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder.cc @@ -178,6 +178,9 @@ void deg_graph_build_finalize(Main *bmain, Depsgraph *graph) if (GS(id_orig->name) == ID_OB) { flag |= ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY; } + if (GS(id_orig->name) == ID_NT) { + flag |= ID_RECALC_NTREE_OUTPUT; + } } /* Restore recalc flags from original ID, which could possibly contain recalc flags set by * an operator and then were carried on by the undo system. */ diff --git a/source/blender/depsgraph/intern/builder/deg_builder_cache.cc b/source/blender/depsgraph/intern/builder/deg_builder_cache.cc index 129e0093d11..a9f8d1f73d3 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_cache.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_cache.cc @@ -59,9 +59,9 @@ bool operator==(const AnimatedPropertyID &a, const AnimatedPropertyID &b) uint64_t AnimatedPropertyID::hash() const { - uintptr_t ptr1 = (uintptr_t)data; - uintptr_t ptr2 = (uintptr_t)property_rna; - return static_cast<uint64_t>(((ptr1 >> 4) * 33) ^ (ptr2 >> 4)); + uintptr_t ptr1 = uintptr_t(data); + uintptr_t ptr2 = uintptr_t(property_rna); + return uint64_t(((ptr1 >> 4) * 33) ^ (ptr2 >> 4)); } namespace { diff --git a/source/blender/depsgraph/intern/builder/deg_builder_cycle.cc b/source/blender/depsgraph/intern/builder/deg_builder_cycle.cc index 8ba6c840a59..7f3c59f1522 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_cycle.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_cycle.cc @@ -60,7 +60,7 @@ struct CyclesSolverState { inline void set_node_visited_state(Node *node, eCyclicCheckVisitedState state) { - node->custom_flags = (node->custom_flags & ~0x3) | (int)state; + node->custom_flags = (node->custom_flags & ~0x3) | int(state); } inline eCyclicCheckVisitedState get_node_visited_state(Node *node) diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations_keys.cc b/source/blender/depsgraph/intern/builder/deg_builder_key.cc index 8506a97c408..741c415b5cd 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations_keys.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_key.cc @@ -7,20 +7,26 @@ * Methods for constructing depsgraph */ -#include "intern/builder/deg_builder_relations.h" +#include "intern/builder/deg_builder_key.h" + +#include "RNA_path.h" namespace blender::deg { -//////////////////////////////////////////////////////////////////////////////// -/* Time source. */ +/* -------------------------------------------------------------------- */ +/** \name Time source + * \{ */ string TimeSourceKey::identifier() const { return string("TimeSourceKey"); } -//////////////////////////////////////////////////////////////////////////////// -// Component. +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Component + * \{ */ string ComponentKey::identifier() const { @@ -35,8 +41,11 @@ string ComponentKey::identifier() const return result; } -//////////////////////////////////////////////////////////////////////////////// -// Operation. +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Operation + * \{ */ string OperationKey::identifier() const { @@ -51,8 +60,11 @@ string OperationKey::identifier() const return result; } -//////////////////////////////////////////////////////////////////////////////// -// RNA path. +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name RNA path + * \{ */ RNAPathKey::RNAPathKey(ID *id, const char *path, RNAPointerSource source) : id(id), source(source) { @@ -79,4 +91,6 @@ string RNAPathKey::identifier() const return string("RnaPathKey(") + "id: " + id_name + ", prop: '" + prop_name + "')"; } +/** \} */ + } // namespace blender::deg diff --git a/source/blender/depsgraph/intern/builder/deg_builder_key.h b/source/blender/depsgraph/intern/builder/deg_builder_key.h new file mode 100644 index 00000000000..4f8b2dc9f8f --- /dev/null +++ b/source/blender/depsgraph/intern/builder/deg_builder_key.h @@ -0,0 +1,201 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later + * Copyright 2013 Blender Foundation. All rights reserved. */ + +/** \file + * \ingroup depsgraph + */ + +#pragma once + +#include "intern/builder/deg_builder_rna.h" +#include "intern/depsgraph_type.h" +#include "intern/node/deg_node_component.h" +#include "intern/node/deg_node_id.h" +#include "intern/node/deg_node_operation.h" + +#include "DNA_ID.h" + +#include "RNA_access.h" +#include "RNA_types.h" + +struct ID; +struct PropertyRNA; + +namespace blender::deg { + +struct TimeSourceKey { + TimeSourceKey() = default; + + string identifier() const; +}; + +struct ComponentKey { + ComponentKey() = default; + + inline ComponentKey(const ID *id, NodeType type, const char *name = "") + : id(id), type(type), name(name) + { + } + + string identifier() const; + + const ID *id = nullptr; + NodeType type = NodeType::UNDEFINED; + const char *name = ""; +}; + +struct OperationKey { + OperationKey() = default; + + inline OperationKey(const ID *id, NodeType component_type, const char *name, int name_tag = -1) + : id(id), + component_type(component_type), + component_name(""), + opcode(OperationCode::OPERATION), + name(name), + name_tag(name_tag) + { + } + + OperationKey(const ID *id, + NodeType component_type, + const char *component_name, + const char *name, + int name_tag) + : id(id), + component_type(component_type), + component_name(component_name), + opcode(OperationCode::OPERATION), + name(name), + name_tag(name_tag) + { + } + + OperationKey(const ID *id, NodeType component_type, OperationCode opcode) + : id(id), + component_type(component_type), + component_name(""), + opcode(opcode), + name(""), + name_tag(-1) + { + } + + OperationKey(const ID *id, + NodeType component_type, + const char *component_name, + OperationCode opcode) + : id(id), + component_type(component_type), + component_name(component_name), + opcode(opcode), + name(""), + name_tag(-1) + { + } + + OperationKey(const ID *id, + NodeType component_type, + OperationCode opcode, + const char *name, + int name_tag = -1) + : id(id), + component_type(component_type), + component_name(""), + opcode(opcode), + name(name), + name_tag(name_tag) + { + } + + OperationKey(const ID *id, + NodeType component_type, + const char *component_name, + OperationCode opcode, + const char *name, + int name_tag = -1) + : id(id), + component_type(component_type), + component_name(component_name), + opcode(opcode), + name(name), + name_tag(name_tag) + { + } + + OperationKey(OperationKey &&other) noexcept = default; + OperationKey &operator=(OperationKey &&other) = default; + + OperationKey(const OperationKey &other) = default; + OperationKey &operator=(const OperationKey &other) = default; + + string identifier() const; + + const ID *id = nullptr; + NodeType component_type = NodeType::UNDEFINED; + const char *component_name = ""; + OperationCode opcode = OperationCode::OPERATION; + const char *name = ""; + int name_tag = -1; +}; + +/* Similar to the the OperationKey but does not contain external references, which makes it + * suitable to identify operations even after the original database or graph was destroyed. + * The downside of this key over the OperationKey is that it performs string allocation upon + * the key construction. */ +struct PersistentOperationKey : public OperationKey { + /* Create the key which identifies the given operation node. */ + PersistentOperationKey(const OperationNode *operation_node) + { + const ComponentNode *component_node = operation_node->owner; + const IDNode *id_node = component_node->owner; + + /* Copy names over to our object, so that the key stays valid even after the `operation_node` + * is destroyed.*/ + component_name_storage_ = component_node->name; + name_storage_ = operation_node->name; + + /* Assign fields used by the OperationKey API. */ + id = id_node->id_orig; + component_type = component_node->type; + component_name = component_name_storage_.c_str(); + opcode = operation_node->opcode; + name = name_storage_.c_str(); + name_tag = operation_node->name_tag; + } + + PersistentOperationKey(PersistentOperationKey &&other) noexcept : OperationKey(other) + { + component_name_storage_ = std::move(other.component_name_storage_); + name_storage_ = std::move(other.name_storage_); + + /* Re-assign pointers to the strings. + * This is needed because string content can actually change address if the string uses the + * small string optimization. */ + component_name = component_name_storage_.c_str(); + name = name_storage_.c_str(); + } + + PersistentOperationKey &operator=(PersistentOperationKey &&other) = delete; + + PersistentOperationKey(const PersistentOperationKey &other) = delete; + PersistentOperationKey &operator=(const PersistentOperationKey &other) = delete; + + private: + string component_name_storage_; + string name_storage_; +}; + +struct RNAPathKey { + RNAPathKey(ID *id, const char *path, RNAPointerSource source); + RNAPathKey(ID *id, const PointerRNA &ptr, PropertyRNA *prop, RNAPointerSource source); + + string identifier() const; + + ID *id; + PointerRNA ptr; + PropertyRNA *prop; + RNAPointerSource source; +}; + +} // namespace blender::deg diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc index 324197118d2..c84852788fd 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc @@ -104,6 +104,7 @@ #include "SEQ_sequencer.h" #include "intern/builder/deg_builder.h" +#include "intern/builder/deg_builder_key.h" #include "intern/builder/deg_builder_rna.h" #include "intern/depsgraph.h" #include "intern/depsgraph_tag.h" @@ -155,14 +156,12 @@ IDNode *DepsgraphNodeBuilder::add_id_node(ID *id) IDComponentsMask previously_visible_components_mask = 0; uint32_t previous_eval_flags = 0; DEGCustomDataMeshMasks previous_customdata_masks; - int id_invisible_recalc = 0; IDInfo *id_info = id_info_hash_.lookup_default(id->session_uuid, nullptr); if (id_info != nullptr) { id_cow = id_info->id_cow; previously_visible_components_mask = id_info->previously_visible_components_mask; previous_eval_flags = id_info->previous_eval_flags; previous_customdata_masks = id_info->previous_customdata_masks; - id_invisible_recalc = id_info->id_invisible_recalc; /* Tag ID info to not free the CoW ID pointer. */ id_info->id_cow = nullptr; } @@ -170,7 +169,6 @@ IDNode *DepsgraphNodeBuilder::add_id_node(ID *id) id_node->previously_visible_components_mask = previously_visible_components_mask; id_node->previous_eval_flags = previous_eval_flags; id_node->previous_customdata_masks = previous_customdata_masks; - id_node->id_invisible_recalc = id_invisible_recalc; /* NOTE: Zero number of components indicates that ID node was just created. */ const bool is_newly_created = id_node->components.is_empty(); @@ -211,7 +209,7 @@ IDNode *DepsgraphNodeBuilder::add_id_node(ID *id) return id_node; } -IDNode *DepsgraphNodeBuilder::find_id_node(ID *id) +IDNode *DepsgraphNodeBuilder::find_id_node(const ID *id) { return graph_->find_id_node(id); } @@ -231,6 +229,17 @@ ComponentNode *DepsgraphNodeBuilder::add_component_node(ID *id, return comp_node; } +ComponentNode *DepsgraphNodeBuilder::find_component_node(const ID *id, + const NodeType comp_type, + const char *comp_name) +{ + IDNode *id_node = find_id_node(id); + if (id_node == nullptr) { + return nullptr; + } + return id_node->find_component(comp_type, comp_name); +} + OperationNode *DepsgraphNodeBuilder::add_operation_node(ComponentNode *comp_node, OperationCode opcode, const DepsEvalOperationCb &op, @@ -314,23 +323,32 @@ bool DepsgraphNodeBuilder::has_operation_node(ID *id, return find_operation_node(id, comp_type, comp_name, opcode, name, name_tag) != nullptr; } -OperationNode *DepsgraphNodeBuilder::find_operation_node(ID *id, +OperationNode *DepsgraphNodeBuilder::find_operation_node(const ID *id, NodeType comp_type, const char *comp_name, OperationCode opcode, const char *name, int name_tag) { - ComponentNode *comp_node = add_component_node(id, comp_type, comp_name); + ComponentNode *comp_node = find_component_node(id, comp_type, comp_name); + if (comp_node == nullptr) { + return nullptr; + } return comp_node->find_operation(opcode, name, name_tag); } OperationNode *DepsgraphNodeBuilder::find_operation_node( - ID *id, NodeType comp_type, OperationCode opcode, const char *name, int name_tag) + const ID *id, NodeType comp_type, OperationCode opcode, const char *name, int name_tag) { return find_operation_node(id, comp_type, "", opcode, name, name_tag); } +OperationNode *DepsgraphNodeBuilder::find_operation_node(const OperationKey &key) +{ + return find_operation_node( + key.id, key.component_type, key.component_name, key.opcode, key.name, key.name_tag); +} + ID *DepsgraphNodeBuilder::get_cow_id(const ID *id_orig) const { return graph_->get_cow_id(id_orig); @@ -369,23 +387,13 @@ void DepsgraphNodeBuilder::begin_build() id_info->previously_visible_components_mask = id_node->visible_components_mask; id_info->previous_eval_flags = id_node->eval_flags; id_info->previous_customdata_masks = id_node->customdata_masks; - id_info->id_invisible_recalc = id_node->id_invisible_recalc; BLI_assert(!id_info_hash_.contains(id_node->id_orig_session_uuid)); id_info_hash_.add_new(id_node->id_orig_session_uuid, id_info); id_node->id_cow = nullptr; } - for (OperationNode *op_node : graph_->entry_tags) { - ComponentNode *comp_node = op_node->owner; - IDNode *id_node = comp_node->owner; - - SavedEntryTag entry_tag; - entry_tag.id_orig = id_node->id_orig; - entry_tag.component_type = comp_node->type; - entry_tag.opcode = op_node->opcode; - entry_tag.name = op_node->name; - entry_tag.name_tag = op_node->name_tag; - saved_entry_tags_.append(entry_tag); + for (const OperationNode *op_node : graph_->entry_tags) { + saved_entry_tags_.append_as(op_node); } /* Make sure graph has no nodes left from previous state. */ @@ -445,6 +453,11 @@ static int foreach_id_cow_detect_need_for_update_callback(LibraryIDLinkCallbackD if (id == nullptr) { return IDWALK_RET_NOP; } + if (!ID_TYPE_IS_COW(GS(id->name))) { + /* No need to go further if the id never had a cow copy in the depsgraph. This function is + * only concerned with keeping the mapping between original and COW ids intact. */ + return IDWALK_RET_NOP; + } DepsgraphNodeBuilder *builder = static_cast<DepsgraphNodeBuilder *>(cb_data->user_data); ID *id_cow_self = cb_data->id_self; @@ -503,23 +516,15 @@ void DepsgraphNodeBuilder::update_invalid_cow_pointers() void DepsgraphNodeBuilder::tag_previously_tagged_nodes() { - for (const SavedEntryTag &entry_tag : saved_entry_tags_) { - IDNode *id_node = find_id_node(entry_tag.id_orig); - if (id_node == nullptr) { - continue; - } - ComponentNode *comp_node = id_node->find_component(entry_tag.component_type); - if (comp_node == nullptr) { - continue; - } - OperationNode *op_node = comp_node->find_operation( - entry_tag.opcode, entry_tag.name.c_str(), entry_tag.name_tag); - if (op_node == nullptr) { + for (const OperationKey &operation_key : saved_entry_tags_) { + OperationNode *operation_node = find_operation_node(operation_key); + if (operation_node == nullptr) { continue; } + /* Since the tag is coming from a saved copy of entry tags, this means * that originally node was explicitly tagged for user update. */ - op_node->tag_update(graph_, DEG_UPDATE_SOURCE_USER_EDIT); + operation_node->tag_update(graph_, DEG_UPDATE_SOURCE_USER_EDIT); } } @@ -1745,14 +1750,19 @@ void DepsgraphNodeBuilder::build_nodetree(bNodeTree *ntree) /* Animation, */ build_animdata(&ntree->id); /* Output update. */ - ID *id_cow = get_cow_id(&ntree->id); - add_operation_node(&ntree->id, - NodeType::NTREE_OUTPUT, - OperationCode::NTREE_OUTPUT, - [id_cow](::Depsgraph * /*depsgraph*/) { - bNodeTree *ntree_cow = reinterpret_cast<bNodeTree *>(id_cow); - bke::node_tree_runtime::handle_node_tree_output_changed(*ntree_cow); - }); + add_operation_node(&ntree->id, NodeType::NTREE_OUTPUT, OperationCode::NTREE_OUTPUT); + if (ntree->type == NTREE_GEOMETRY) { + ID *id_cow = get_cow_id(&ntree->id); + add_operation_node(&ntree->id, + NodeType::NTREE_GEOMETRY_PREPROCESS, + OperationCode::NTREE_GEOMETRY_PREPROCESS, + [id_cow](::Depsgraph * /*depsgraph*/) { + bNodeTree *ntree_cow = reinterpret_cast<bNodeTree *>(id_cow); + bke::node_tree_runtime::preprocess_geometry_node_tree_for_evaluation( + *ntree_cow); + }); + } + /* nodetree's nodes... */ LISTBASE_FOREACH (bNode *, bnode, &ntree->nodes) { build_idproperties(bnode->prop); @@ -2129,9 +2139,10 @@ void DepsgraphNodeBuilder::build_scene_audio(Scene *scene) }); } -void DepsgraphNodeBuilder::build_scene_speakers(Scene * /*scene*/, ViewLayer *view_layer) +void DepsgraphNodeBuilder::build_scene_speakers(Scene *scene, ViewLayer *view_layer) { - LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) { + BKE_view_layer_synced_ensure(scene, view_layer); + LISTBASE_FOREACH (Base *, base, BKE_view_layer_object_bases_get(view_layer)) { Object *object = base->object; if (object->type != OB_SPEAKER || !need_pull_base_into_graph(base)) { continue; diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h index 29cca0a8ddd..a8efe8fca9f 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h @@ -8,6 +8,7 @@ #pragma once #include "intern/builder/deg_builder.h" +#include "intern/builder/deg_builder_key.h" #include "intern/builder/deg_builder_map.h" #include "intern/depsgraph_type.h" #include "intern/node/deg_node_id.h" @@ -56,6 +57,7 @@ struct ComponentNode; struct Depsgraph; class DepsgraphBuilderCache; struct IDNode; +struct OperationKey; struct OperationNode; struct TimeSourceNode; @@ -92,10 +94,11 @@ class DepsgraphNodeBuilder : public DepsgraphBuilder { int foreach_id_cow_detect_need_for_update_callback(ID *id_cow_self, ID *id_pointer); IDNode *add_id_node(ID *id); - IDNode *find_id_node(ID *id); + IDNode *find_id_node(const ID *id); TimeSourceNode *add_time_source(); ComponentNode *add_component_node(ID *id, NodeType comp_type, const char *comp_name = ""); + ComponentNode *find_component_node(const ID *id, NodeType comp_type, const char *comp_name = ""); OperationNode *add_operation_node(ComponentNode *comp_node, OperationCode opcode, @@ -137,15 +140,20 @@ class DepsgraphNodeBuilder : public DepsgraphBuilder { const char *name = "", int name_tag = -1); - OperationNode *find_operation_node(ID *id, + OperationNode *find_operation_node(const ID *id, NodeType comp_type, const char *comp_name, OperationCode opcode, const char *name = "", int name_tag = -1); - OperationNode *find_operation_node( - ID *id, NodeType comp_type, OperationCode opcode, const char *name = "", int name_tag = -1); + OperationNode *find_operation_node(const ID *id, + NodeType comp_type, + OperationCode opcode, + const char *name = "", + int name_tag = -1); + + OperationNode *find_operation_node(const OperationKey &key); virtual void build_id(ID *id); @@ -250,24 +258,14 @@ class DepsgraphNodeBuilder : public DepsgraphBuilder { IDComponentsMask previously_visible_components_mask; /* Special evaluation flag mask from the previous depsgraph. */ uint32_t previous_eval_flags; - /* Recalculation flags which were not evaluated for the ID in the previous depsgraph. */ - int id_invisible_recalc; /* Mesh CustomData mask from the previous depsgraph. */ DEGCustomDataMeshMasks previous_customdata_masks; }; protected: - /* Allows to identify an operation which was tagged for update at the time - * relations are being updated. We can not reuse operation node pointer - * since it will change during dependency graph construction. */ - struct SavedEntryTag { - ID *id_orig; - NodeType component_type; - OperationCode opcode; - string name; - int name_tag; - }; - Vector<SavedEntryTag> saved_entry_tags_; + /* Entry tags from the previous state of the dependency graph. + * Stored before the graph is re-created so that they can be transferred over. */ + Vector<PersistentOperationKey> saved_entry_tags_; struct BuilderWalkUserData { DepsgraphNodeBuilder *builder; 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 5af9e7d4fe9..d7420b91db4 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 @@ -90,7 +90,8 @@ void DepsgraphNodeBuilder::build_view_layer(Scene *scene, * but object is expected to be an original one. Hence we go into some * tricks here iterating over the view layer. */ int base_index = 0; - LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) { + BKE_view_layer_synced_ensure(scene, view_layer); + LISTBASE_FOREACH (Base *, base, BKE_view_layer_object_bases_get(view_layer)) { /* object itself */ if (!need_pull_base_into_graph(base)) { continue; diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc index 313d4996dcf..b657d39df69 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc @@ -191,7 +191,7 @@ bool check_id_has_anim_component(ID *id) if (adt == nullptr) { return false; } - return (adt->action != nullptr) || (!BLI_listbase_is_empty(&adt->nla_tracks)); + return (adt->action != nullptr) || !BLI_listbase_is_empty(&adt->nla_tracks); } bool check_id_has_driver_component(ID *id) @@ -1723,6 +1723,11 @@ void DepsgraphRelationBuilder::build_driver_data(ID *id, FCurve *fcu) if (GS(id_ptr->name) == ID_NT) { ComponentKey ntree_output_key(id_ptr, NodeType::NTREE_OUTPUT); add_relation(driver_key, ntree_output_key, "Drivers -> NTree Output"); + if (reinterpret_cast<bNodeTree *>(id_ptr)->type == NTREE_GEOMETRY) { + OperationKey ntree_geo_preprocess_key( + id, NodeType::NTREE_GEOMETRY_PREPROCESS, OperationCode::NTREE_GEOMETRY_PREPROCESS); + add_relation(driver_key, ntree_geo_preprocess_key, "Drivers -> NTree Geo Preprocess"); + } } } @@ -2611,6 +2616,16 @@ void DepsgraphRelationBuilder::build_nodetree(bNodeTree *ntree) build_animdata(&ntree->id); build_parameters(&ntree->id); OperationKey ntree_output_key(&ntree->id, NodeType::NTREE_OUTPUT, OperationCode::NTREE_OUTPUT); + OperationKey ntree_geo_preprocess_key( + &ntree->id, NodeType::NTREE_GEOMETRY_PREPROCESS, OperationCode::NTREE_GEOMETRY_PREPROCESS); + if (ntree->type == NTREE_GEOMETRY) { + OperationKey ntree_cow_key(&ntree->id, NodeType::COPY_ON_WRITE, OperationCode::COPY_ON_WRITE); + add_relation(ntree_cow_key, ntree_geo_preprocess_key, "COW -> Preprocess"); + add_relation(ntree_geo_preprocess_key, + ntree_output_key, + "Preprocess -> Output", + RELATION_FLAG_NO_FLUSH); + } /* nodetree's nodes... */ LISTBASE_FOREACH (bNode *, bnode, &ntree->nodes) { build_idproperties(bnode->prop); @@ -2687,6 +2702,12 @@ void DepsgraphRelationBuilder::build_nodetree(bNodeTree *ntree) * the output). Currently, we lack the infrastructure to check for these cases efficiently. * That can be added later. */ add_relation(group_output_key, ntree_output_key, "Group Node"); + if (group_ntree->type == NTREE_GEOMETRY) { + OperationKey group_preprocess_key(&group_ntree->id, + NodeType::NTREE_GEOMETRY_PREPROCESS, + OperationCode::NTREE_GEOMETRY_PREPROCESS); + add_relation(group_preprocess_key, ntree_geo_preprocess_key, "Group Node Preprocess"); + } } else { BLI_assert_msg(0, "Unknown ID type used for node"); @@ -2703,6 +2724,9 @@ void DepsgraphRelationBuilder::build_nodetree(bNodeTree *ntree) if (check_id_has_anim_component(&ntree->id)) { ComponentKey animation_key(&ntree->id, NodeType::ANIMATION); add_relation(animation_key, ntree_output_key, "NTree Shading Parameters"); + if (ntree->type == NTREE_GEOMETRY) { + add_relation(animation_key, ntree_geo_preprocess_key, "NTree Animation -> Preprocess"); + } } } @@ -3050,9 +3074,10 @@ void DepsgraphRelationBuilder::build_scene_audio(Scene *scene) } } -void DepsgraphRelationBuilder::build_scene_speakers(Scene * /*scene*/, ViewLayer *view_layer) +void DepsgraphRelationBuilder::build_scene_speakers(Scene *scene, ViewLayer *view_layer) { - LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) { + BKE_view_layer_synced_ensure(scene, view_layer); + LISTBASE_FOREACH (Base *, base, BKE_view_layer_object_bases_get(view_layer)) { Object *object = base->object; if (object->type != OB_SPEAKER || !need_pull_base_into_graph(base)) { continue; diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.h b/source/blender/depsgraph/intern/builder/deg_builder_relations.h index 7d3a0fd9217..901e4a1acbb 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.h +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.h @@ -14,14 +14,13 @@ #include "DNA_ID.h" -#include "RNA_access.h" #include "RNA_path.h" -#include "RNA_types.h" #include "BLI_string.h" #include "BLI_utildefines.h" #include "intern/builder/deg_builder.h" +#include "intern/builder/deg_builder_key.h" #include "intern/builder/deg_builder_map.h" #include "intern/builder/deg_builder_rna.h" #include "intern/builder/deg_builder_stack.h" @@ -69,8 +68,6 @@ struct bNodeTree; struct bPoseChannel; struct bSound; -struct PropertyRNA; - namespace blender::deg { struct ComponentNode; @@ -84,128 +81,6 @@ struct Relation; struct RootPChanMap; struct TimeSourceNode; -struct TimeSourceKey { - TimeSourceKey() = default; - - string identifier() const; -}; - -struct ComponentKey { - ComponentKey() = default; - - inline ComponentKey(const ID *id, NodeType type, const char *name = "") - : id(id), type(type), name(name) - { - } - - string identifier() const; - - const ID *id = nullptr; - NodeType type = NodeType::UNDEFINED; - const char *name = ""; -}; - -struct OperationKey { - OperationKey() = default; - - inline OperationKey(const ID *id, NodeType component_type, const char *name, int name_tag = -1) - : id(id), - component_type(component_type), - component_name(""), - opcode(OperationCode::OPERATION), - name(name), - name_tag(name_tag) - { - } - - OperationKey(const ID *id, - NodeType component_type, - const char *component_name, - const char *name, - int name_tag) - : id(id), - component_type(component_type), - component_name(component_name), - opcode(OperationCode::OPERATION), - name(name), - name_tag(name_tag) - { - } - - OperationKey(const ID *id, NodeType component_type, OperationCode opcode) - : id(id), - component_type(component_type), - component_name(""), - opcode(opcode), - name(""), - name_tag(-1) - { - } - - OperationKey(const ID *id, - NodeType component_type, - const char *component_name, - OperationCode opcode) - : id(id), - component_type(component_type), - component_name(component_name), - opcode(opcode), - name(""), - name_tag(-1) - { - } - - OperationKey(const ID *id, - NodeType component_type, - OperationCode opcode, - const char *name, - int name_tag = -1) - : id(id), - component_type(component_type), - component_name(""), - opcode(opcode), - name(name), - name_tag(name_tag) - { - } - - OperationKey(const ID *id, - NodeType component_type, - const char *component_name, - OperationCode opcode, - const char *name, - int name_tag = -1) - : id(id), - component_type(component_type), - component_name(component_name), - opcode(opcode), - name(name), - name_tag(name_tag) - { - } - - string identifier() const; - - const ID *id = nullptr; - NodeType component_type = NodeType::UNDEFINED; - const char *component_name = ""; - OperationCode opcode = OperationCode::OPERATION; - const char *name = ""; - int name_tag = -1; -}; - -struct RNAPathKey { - RNAPathKey(ID *id, const char *path, RNAPointerSource source); - RNAPathKey(ID *id, const PointerRNA &ptr, PropertyRNA *prop, RNAPointerSource source); - - string identifier() const; - - ID *id; - PointerRNA ptr; - PropertyRNA *prop; - RNAPointerSource source; -}; - class DepsgraphRelationBuilder : public DepsgraphBuilder { public: DepsgraphRelationBuilder(Main *bmain, Depsgraph *graph, DepsgraphBuilderCache *cache); 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 d723e5beb75..938c0979de9 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 @@ -75,11 +75,12 @@ void DepsgraphRelationBuilder::build_view_layer(Scene *scene, { /* Setup currently building context. */ scene_ = scene; + BKE_view_layer_synced_ensure(scene, view_layer); /* Scene objects. */ /* NOTE: Nodes builder requires us to pass CoW base because it's being * passed to the evaluation functions. During relations builder we only * do nullptr-pointer check of the base, so it's fine to pass original one. */ - LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) { + LISTBASE_FOREACH (Base *, base, BKE_view_layer_object_bases_get(view_layer)) { if (need_pull_base_into_graph(base)) { build_object_from_view_layer_base(base->object); } diff --git a/source/blender/depsgraph/intern/builder/deg_builder_rna.cc b/source/blender/depsgraph/intern/builder/deg_builder_rna.cc index d94746fb7fa..1a4356c4a92 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_rna.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_rna.cc @@ -138,8 +138,8 @@ bool RNANodeQuery::contains(const char *prop_identifier, const char *rna_path_co return false; } - /* If substr != prop_identifier, it means that the substring is found further in prop_identifier, - * and that thus index -1 is a valid memory location. */ + /* If `substr != prop_identifier`, it means that the sub-string is found further in + * `prop_identifier`, and that thus index -1 is a valid memory location. */ const bool start_ok = substr == prop_identifier || substr[-1] == '.'; if (!start_ok) { return false; 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 b8d0fb6c365..bd47cb77f56 100644 --- a/source/blender/depsgraph/intern/debug/deg_debug_relations_graphviz.cc +++ b/source/blender/depsgraph/intern/debug/deg_debug_relations_graphviz.cc @@ -408,6 +408,7 @@ static void deg_debug_graphviz_node(DotExportContext &ctx, case NodeType::GENERIC_DATABLOCK: case NodeType::VISIBILITY: case NodeType::NTREE_OUTPUT: + case NodeType::NTREE_GEOMETRY_PREPROCESS: case NodeType::SIMULATION: { ComponentNode *comp_node = (ComponentNode *)node; if (comp_node->operations.is_empty()) { diff --git a/source/blender/depsgraph/intern/depsgraph.cc b/source/blender/depsgraph/intern/depsgraph.cc index 316d0b615c6..4d7d537b450 100644 --- a/source/blender/depsgraph/intern/depsgraph.cc +++ b/source/blender/depsgraph/intern/depsgraph.cc @@ -58,6 +58,7 @@ Depsgraph::Depsgraph(Main *bmain, Scene *scene, ViewLayer *view_layer, eEvaluati ctime(BKE_scene_ctime_get(scene)), scene_cow(nullptr), is_active(false), + use_visibility_optimization(true), is_evaluating(false), is_render_pipeline_depsgraph(false), use_editors_update(false) @@ -334,3 +335,9 @@ void DEG_make_inactive(struct Depsgraph *depsgraph) deg::Depsgraph *deg_graph = reinterpret_cast<deg::Depsgraph *>(depsgraph); deg_graph->is_active = false; } + +void DEG_disable_visibility_optimization(struct Depsgraph *depsgraph) +{ + deg::Depsgraph *deg_graph = reinterpret_cast<deg::Depsgraph *>(depsgraph); + deg_graph->use_visibility_optimization = false; +}
\ No newline at end of file diff --git a/source/blender/depsgraph/intern/depsgraph.h b/source/blender/depsgraph/intern/depsgraph.h index 2f88199384d..042cb045c6f 100644 --- a/source/blender/depsgraph/intern/depsgraph.h +++ b/source/blender/depsgraph/intern/depsgraph.h @@ -147,6 +147,9 @@ struct Depsgraph { * to read stuff from. */ bool is_active; + /* Optimize out evaluation of operations which affect hidden objects or disabled modifiers. */ + bool use_visibility_optimization; + DepsgraphDebug debug; bool is_evaluating; diff --git a/source/blender/depsgraph/intern/depsgraph_debug.cc b/source/blender/depsgraph/intern/depsgraph_debug.cc index ddad00bc0e8..2f528873f1d 100644 --- a/source/blender/depsgraph/intern/depsgraph_debug.cc +++ b/source/blender/depsgraph/intern/depsgraph_debug.cc @@ -171,7 +171,7 @@ bool DEG_debug_consistency_check(Depsgraph *graph) node->identifier().c_str(), node->num_links_pending, num_links_pending); - printf("Number of inlinks: %d\n", (int)node->inlinks.size()); + printf("Number of inlinks: %d\n", int(node->inlinks.size())); return false; } } diff --git a/source/blender/depsgraph/intern/depsgraph_physics.cc b/source/blender/depsgraph/intern/depsgraph_physics.cc index 5660d5eb1bd..d7d03ec3261 100644 --- a/source/blender/depsgraph/intern/depsgraph_physics.cc +++ b/source/blender/depsgraph/intern/depsgraph_physics.cc @@ -32,7 +32,7 @@ namespace deg = blender::deg; /*************************** Evaluation Query API *****************************/ -static ePhysicsRelationType modifier_to_relation_type(unsigned int modifier_type) +static ePhysicsRelationType modifier_to_relation_type(uint modifier_type) { switch (modifier_type) { case eModifierType_Collision: @@ -72,7 +72,7 @@ ListBase *DEG_get_effector_relations(const Depsgraph *graph, Collection *collect ListBase *DEG_get_collision_relations(const Depsgraph *graph, Collection *collection, - unsigned int modifier_type) + uint modifier_type) { const deg::Depsgraph *deg_graph = reinterpret_cast<const deg::Depsgraph *>(graph); const ePhysicsRelationType type = modifier_to_relation_type(modifier_type); @@ -91,7 +91,7 @@ ListBase *DEG_get_collision_relations(const Depsgraph *graph, void DEG_add_collision_relations(DepsNodeHandle *handle, Object *object, Collection *collection, - unsigned int modifier_type, + uint modifier_type, DEG_CollobjFilterFunction filter_function, const char *name) { @@ -174,13 +174,11 @@ ListBase *build_effector_relations(Depsgraph *graph, Collection *collection) ID *collection_id = object_id_safe(collection); return hash->lookup_or_add_cb(collection_id, [&]() { ::Depsgraph *depsgraph = reinterpret_cast<::Depsgraph *>(graph); - return BKE_effector_relations_create(depsgraph, graph->view_layer, collection); + return BKE_effector_relations_create(depsgraph, graph->scene, graph->view_layer, collection); }); } -ListBase *build_collision_relations(Depsgraph *graph, - Collection *collection, - unsigned int modifier_type) +ListBase *build_collision_relations(Depsgraph *graph, Collection *collection, uint modifier_type) { const ePhysicsRelationType type = modifier_to_relation_type(modifier_type); Map<const ID *, ListBase *> *hash = graph->physics_relations[type]; diff --git a/source/blender/depsgraph/intern/depsgraph_query_foreach.cc b/source/blender/depsgraph/intern/depsgraph_query_foreach.cc index 2839f0daed7..4f28210ba8f 100644 --- a/source/blender/depsgraph/intern/depsgraph_query_foreach.cc +++ b/source/blender/depsgraph/intern/depsgraph_query_foreach.cc @@ -45,7 +45,7 @@ bool deg_foreach_needs_visit(const OperationNode *op_node, const int flags) return true; } -void deg_foreach_dependent_operation(const Depsgraph *UNUSED(graph), +void deg_foreach_dependent_operation(const Depsgraph * /*graph*/, const IDNode *target_id_node, eDepsObjectComponentType source_component_type, int flags, diff --git a/source/blender/depsgraph/intern/depsgraph_query_iter.cc b/source/blender/depsgraph/intern/depsgraph_query_iter.cc index bcae5de1e1e..34df9a537e1 100644 --- a/source/blender/depsgraph/intern/depsgraph_query_iter.cc +++ b/source/blender/depsgraph/intern/depsgraph_query_iter.cc @@ -127,14 +127,11 @@ bool deg_object_hide_original(eEvaluationMode eval_mode, Object *ob, DupliObject return false; } -void deg_iterator_duplis_init(DEGObjectIterData *data, Object *object) +void deg_iterator_duplis_init(DEGObjectIterData *data, Object *object, ListBase *duplis) { - if ((data->flag & DEG_ITER_OBJECT_FLAG_DUPLI) && - ((object->transflag & OB_DUPLI) || object->runtime.geometry_set_eval != nullptr)) { - data->dupli_parent = object; - data->dupli_list = object_duplilist(data->graph, data->scene, object); - data->dupli_object_next = (DupliObject *)data->dupli_list->first; - } + data->dupli_parent = object; + data->dupli_list = duplis; + data->dupli_object_next = static_cast<DupliObject *>(duplis->first); } /* Returns false when iterator is exhausted. */ @@ -194,8 +191,8 @@ bool deg_iterator_duplis_step(DEGObjectIterData *data) bool is_neg_scale = is_negative_m4(dob->mat); SET_FLAG_FROM_TEST(data->temp_dupli_object.transflag, is_neg_scale, OB_NEG_SCALE); - copy_m4_m4(data->temp_dupli_object.obmat, dob->mat); - invert_m4_m4(data->temp_dupli_object.imat, data->temp_dupli_object.obmat); + copy_m4_m4(data->temp_dupli_object.object_to_world, dob->mat); + invert_m4_m4(data->temp_dupli_object.world_to_object, data->temp_dupli_object.object_to_world); data->next_object = &data->temp_dupli_object; BLI_assert(deg::deg_validate_copy_on_write_datablock(&data->temp_dupli_object.id)); return true; @@ -250,7 +247,18 @@ bool deg_iterator_objects_step(DEGObjectIterData *data) } Object *object = (Object *)id_node->id_cow; + Object *object_orig = DEG_get_original_object(object); BLI_assert(deg::deg_validate_copy_on_write_datablock(&object->id)); + object->runtime.select_id = object_orig->runtime.select_id; + + const bool use_preview = object_orig == data->object_orig_with_preview; + if (use_preview) { + ListBase *preview_duplis = object_duplilist_preview( + data->graph, data->scene, object, data->settings->viewer_path); + deg_iterator_duplis_init(data, object, preview_duplis); + data->id_node_index++; + return true; + } int ob_visibility = OB_VISIBLE_ALL; if (data->flag & DEG_ITER_OBJECT_FLAG_VISIBLE) { @@ -261,9 +269,12 @@ bool deg_iterator_objects_step(DEGObjectIterData *data) } } - object->runtime.select_id = DEG_get_original_object(object)->runtime.select_id; if (ob_visibility & OB_VISIBLE_INSTANCES) { - deg_iterator_duplis_init(data, object); + if ((data->flag & DEG_ITER_OBJECT_FLAG_DUPLI) && + ((object->transflag & OB_DUPLI) || object->runtime.geometry_set_eval != nullptr)) { + ListBase *duplis = object_duplilist(data->graph, data->scene, object); + deg_iterator_duplis_init(data, object, duplis); + } } if (ob_visibility & (OB_VISIBLE_SELF | OB_VISIBLE_PARTICLES)) { @@ -301,6 +312,22 @@ void DEG_iterator_objects_begin(BLI_Iterator *iter, DEGObjectIterData *data) data->eval_mode = DEG_get_mode(depsgraph); deg_invalidate_iterator_work_data(data); + /* Determine if the preview of any object should be in the iterator. */ + const ViewerPath *viewer_path = data->settings->viewer_path; + if (viewer_path != nullptr) { + if (!BLI_listbase_is_empty(&viewer_path->path)) { + const ViewerPathElem *elem = static_cast<const ViewerPathElem *>(viewer_path->path.first); + if (elem->type == VIEWER_PATH_ELEM_TYPE_ID) { + const IDViewerPathElem *id_elem = reinterpret_cast<const IDViewerPathElem *>(elem); + if (id_elem->id != nullptr) { + if (GS(id_elem->id->name) == ID_OB) { + data->object_orig_with_preview = reinterpret_cast<Object *>(id_elem->id); + } + } + } + } + } + DEG_iterator_objects_next(iter); } @@ -408,6 +435,6 @@ void DEG_iterator_ids_next(BLI_Iterator *iter) } while (iter->skip); } -void DEG_iterator_ids_end(BLI_Iterator *UNUSED(iter)) +void DEG_iterator_ids_end(BLI_Iterator * /*iter*/) { } diff --git a/source/blender/depsgraph/intern/depsgraph_tag.cc b/source/blender/depsgraph/intern/depsgraph_tag.cc index a8c8b4a6538..0c003cf23b2 100644 --- a/source/blender/depsgraph/intern/depsgraph_tag.cc +++ b/source/blender/depsgraph/intern/depsgraph_tag.cc @@ -235,7 +235,7 @@ void depsgraph_tag_to_component_opcode(const ID *id, } void id_tag_update_ntree_special( - Main *bmain, Depsgraph *graph, ID *id, unsigned int flags, eUpdateSource update_source) + Main *bmain, Depsgraph *graph, ID *id, uint flags, eUpdateSource update_source) { bNodeTree *ntree = ntreeFromID(id); if (ntree == nullptr) { @@ -418,13 +418,13 @@ string stringify_append_bit(const string &str, IDRecalcFlag tag) return result; } -string stringify_update_bitfield(unsigned int flags) +string stringify_update_bitfield(uint flags) { if (flags == 0) { return "LEGACY_0"; } string result; - unsigned int current_flag = flags; + uint current_flag = flags; /* Special cases to avoid ALL flags form being split into * individual bits. */ if ((current_flag & ID_RECALC_PSYS_ALL) == ID_RECALC_PSYS_ALL) { @@ -460,7 +460,7 @@ int deg_recalc_flags_for_legacy_zero() ID_RECALC_SOURCE | ID_RECALC_EDITORS); } -int deg_recalc_flags_effective(Depsgraph *graph, unsigned int flags) +int deg_recalc_flags_effective(Depsgraph *graph, uint flags) { if (graph != nullptr) { if (!graph->is_active) { @@ -531,7 +531,7 @@ void graph_tag_ids_for_visible_update(Depsgraph *graph) * No need bother with it to tag or anything. */ continue; } - unsigned int flags = 0; + uint flags = 0; if (!deg::deg_copy_on_write_is_expanded(id_node->id_cow)) { flags |= ID_RECALC_COPY_ON_WRITE; if (do_time) { @@ -625,7 +625,7 @@ NodeType geometry_tag_to_component(const ID *id) return NodeType::UNDEFINED; } -void id_tag_update(Main *bmain, ID *id, unsigned int flags, eUpdateSource update_source) +void id_tag_update(Main *bmain, ID *id, uint flags, eUpdateSource update_source) { graph_id_tag_update(bmain, nullptr, id, flags, update_source); for (deg::Depsgraph *depsgraph : deg::get_all_registered_graphs(bmain)) { @@ -638,7 +638,7 @@ void id_tag_update(Main *bmain, ID *id, unsigned int flags, eUpdateSource update } void graph_id_tag_update( - Main *bmain, Depsgraph *graph, ID *id, unsigned int flags, eUpdateSource update_source) + Main *bmain, Depsgraph *graph, ID *id, uint flags, eUpdateSource update_source) { const int debug_flags = (graph != nullptr) ? DEG_debug_flags_get((::Depsgraph *)graph) : G.debug; if (graph != nullptr && graph->is_evaluating) { @@ -676,7 +676,7 @@ void graph_id_tag_update( if (update_source == DEG_UPDATE_SOURCE_USER_EDIT) { id->recalc |= deg_recalc_flags_effective(graph, flags); } - unsigned int current_flag = flags; + uint current_flag = flags; while (current_flag != 0) { IDRecalcFlag tag = (IDRecalcFlag)(1 << bitscan_forward_clear_uint(¤t_flag)); graph_id_tag_update_single_flag(bmain, graph, id, id_node, tag, update_source); @@ -770,12 +770,12 @@ const char *DEG_update_tag_as_string(IDRecalcFlag flag) /* Data-Based Tagging. */ -void DEG_id_tag_update(ID *id, unsigned int flags) +void DEG_id_tag_update(ID *id, uint flags) { DEG_id_tag_update_ex(G.main, id, flags); } -void DEG_id_tag_update_ex(Main *bmain, ID *id, unsigned int flags) +void DEG_id_tag_update_ex(Main *bmain, ID *id, uint flags) { if (id == nullptr) { /* Ideally should not happen, but old depsgraph allowed this. */ @@ -787,7 +787,7 @@ void DEG_id_tag_update_ex(Main *bmain, ID *id, unsigned int flags) void DEG_graph_id_tag_update(struct Main *bmain, struct Depsgraph *depsgraph, struct ID *id, - unsigned int flags) + uint flags) { deg::Depsgraph *graph = (deg::Depsgraph *)depsgraph; deg::graph_id_tag_update(bmain, graph, id, flags, deg::DEG_UPDATE_SOURCE_USER_EDIT); @@ -890,13 +890,6 @@ void DEG_ids_clear_recalc(Depsgraph *depsgraph, const bool backup) } /* Go over all ID nodes, clearing tags. */ for (deg::IDNode *id_node : deg_graph->id_nodes) { - if (!id_node->is_enabled_on_eval) { - id_node->id_invisible_recalc |= id_node->id_cow->recalc; - } - else { - id_node->id_invisible_recalc = 0; - } - if (backup) { id_node->id_cow_recalc_backup |= id_node->id_cow->recalc; } diff --git a/source/blender/depsgraph/intern/eval/deg_eval.cc b/source/blender/depsgraph/intern/eval/deg_eval.cc index cd0015ff717..5ca32d00ba5 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval.cc +++ b/source/blender/depsgraph/intern/eval/deg_eval.cc @@ -12,6 +12,7 @@ #include "PIL_time.h" #include "BLI_compiler_attrs.h" +#include "BLI_function_ref.hh" #include "BLI_gsqueue.h" #include "BLI_task.h" #include "BLI_utildefines.h" @@ -52,16 +53,9 @@ struct DepsgraphEvalState; void deg_task_run_func(TaskPool *pool, void *taskdata); -template<typename ScheduleFunction, typename... ScheduleFunctionArgs> void schedule_children(DepsgraphEvalState *state, OperationNode *node, - ScheduleFunction *schedule_function, - ScheduleFunctionArgs... schedule_function_args); - -void schedule_node_to_pool(OperationNode *node, const int UNUSED(thread_id), TaskPool *pool) -{ - BLI_task_pool_push(pool, deg_task_run_func, node, false, nullptr); -} + FunctionRef<void(OperationNode *node)> schedule_fn); /* Denotes which part of dependency graph is being evaluated. */ enum class EvaluationStage { @@ -125,7 +119,9 @@ void deg_task_run_func(TaskPool *pool, void *taskdata) evaluate_node(state, operation_node); /* Schedule children. */ - schedule_children(state, operation_node, schedule_node_to_pool, pool); + schedule_children(state, operation_node, [&](OperationNode *node) { + BLI_task_pool_push(pool, deg_task_run_func, node, false, nullptr); + }); } bool check_operation_node_visible(const DepsgraphEvalState *state, OperationNode *op_node) @@ -241,12 +237,10 @@ bool need_evaluate_operation_at_stage(DepsgraphEvalState *state, * dec_parents: Decrement pending parents count, true when child nodes are * scheduled after a task has been completed. */ -template<typename ScheduleFunction, typename... ScheduleFunctionArgs> void schedule_node(DepsgraphEvalState *state, OperationNode *node, bool dec_parents, - ScheduleFunction *schedule_function, - ScheduleFunctionArgs... schedule_function_args) + const FunctionRef<void(OperationNode *node)> schedule_fn) { /* No need to schedule nodes of invisible ID. */ if (!check_operation_node_visible(state, node)) { @@ -273,34 +267,30 @@ void schedule_node(DepsgraphEvalState *state, return; } /* Actually schedule the node. */ - bool is_scheduled = atomic_fetch_and_or_uint8((uint8_t *)&node->scheduled, (uint8_t) true); + bool is_scheduled = atomic_fetch_and_or_uint8((uint8_t *)&node->scheduled, uint8_t(true)); if (!is_scheduled) { if (node->is_noop()) { /* skip NOOP node, schedule children right away */ - schedule_children(state, node, schedule_function, schedule_function_args...); + schedule_children(state, node, schedule_fn); } else { /* children are scheduled once this task is completed */ - schedule_function(node, 0, schedule_function_args...); + schedule_fn(node); } } } -template<typename ScheduleFunction, typename... ScheduleFunctionArgs> void schedule_graph(DepsgraphEvalState *state, - ScheduleFunction *schedule_function, - ScheduleFunctionArgs... schedule_function_args) + const FunctionRef<void(OperationNode *node)> schedule_fn) { for (OperationNode *node : state->graph->operations) { - schedule_node(state, node, false, schedule_function, schedule_function_args...); + schedule_node(state, node, false, schedule_fn); } } -template<typename ScheduleFunction, typename... ScheduleFunctionArgs> void schedule_children(DepsgraphEvalState *state, OperationNode *node, - ScheduleFunction *schedule_function, - ScheduleFunctionArgs... schedule_function_args) + const FunctionRef<void(OperationNode *node)> schedule_fn) { for (Relation *rel : node->outlinks) { OperationNode *child = (OperationNode *)rel->to; @@ -309,21 +299,10 @@ void schedule_children(DepsgraphEvalState *state, /* Happens when having cyclic dependencies. */ continue; } - schedule_node(state, - child, - (rel->flag & RELATION_FLAG_CYCLIC) == 0, - schedule_function, - schedule_function_args...); + schedule_node(state, child, (rel->flag & RELATION_FLAG_CYCLIC) == 0, schedule_fn); } } -void schedule_node_to_queue(OperationNode *node, - const int /*thread_id*/, - GSQueue *evaluation_queue) -{ - BLI_gsqueue_push(evaluation_queue, &node); -} - /* Evaluate given stage of the dependency graph evaluation using multiple threads. * * NOTE: Will assign the `state->stage` to the given stage. */ @@ -335,7 +314,9 @@ void evaluate_graph_threaded_stage(DepsgraphEvalState *state, calculate_pending_parents_if_needed(state); - schedule_graph(state, schedule_node_to_pool, task_pool); + schedule_graph(state, [&](OperationNode *node) { + BLI_task_pool_push(task_pool, deg_task_run_func, node, false, nullptr); + }); BLI_task_pool_work_and_wait(task_pool); } @@ -351,14 +332,17 @@ void evaluate_graph_single_threaded_if_needed(DepsgraphEvalState *state) state->stage = EvaluationStage::SINGLE_THREADED_WORKAROUND; GSQueue *evaluation_queue = BLI_gsqueue_new(sizeof(OperationNode *)); - schedule_graph(state, schedule_node_to_queue, evaluation_queue); + auto schedule_node_to_queue = [&](OperationNode *node) { + BLI_gsqueue_push(evaluation_queue, &node); + }; + schedule_graph(state, schedule_node_to_queue); while (!BLI_gsqueue_is_empty(evaluation_queue)) { OperationNode *operation_node; BLI_gsqueue_pop(evaluation_queue, &operation_node); evaluate_node(state, operation_node); - schedule_children(state, operation_node, schedule_node_to_queue, evaluation_queue); + schedule_children(state, operation_node, schedule_node_to_queue); } BLI_gsqueue_free(evaluation_queue); 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 058f57e5a61..4e07a7b173c 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 @@ -414,13 +414,16 @@ void scene_remove_all_bases(Scene *scene_cow) /* Makes it so given view layer only has bases corresponding to enabled * objects. */ -void view_layer_remove_disabled_bases(const Depsgraph *depsgraph, ViewLayer *view_layer) +void view_layer_remove_disabled_bases(const Depsgraph *depsgraph, + const Scene *scene, + ViewLayer *view_layer) { if (view_layer == nullptr) { return; } ListBase enabled_bases = {nullptr, nullptr}; - LISTBASE_FOREACH_MUTABLE (Base *, base, &view_layer->object_bases) { + BKE_view_layer_synced_ensure(scene, view_layer); + LISTBASE_FOREACH_MUTABLE (Base *, base, BKE_view_layer_object_bases_get(view_layer)) { /* TODO(sergey): Would be cool to optimize this somehow, or make it so * builder tags bases. * @@ -479,7 +482,7 @@ void scene_setup_view_layers_after_remap(const Depsgraph *depsgraph, const ViewLayer *view_layer_orig = get_original_view_layer(depsgraph, id_node); ViewLayer *view_layer_eval = reinterpret_cast<ViewLayer *>(scene_cow->view_layers.first); view_layer_update_orig_base_pointers(view_layer_orig, view_layer_eval); - view_layer_remove_disabled_bases(depsgraph, view_layer_eval); + view_layer_remove_disabled_bases(depsgraph, scene_cow, view_layer_eval); /* TODO(sergey): Remove objects from collections as well. * Not a HUGE deal for now, nobody is looking into those CURRENTLY. * Still not an excuse to have those. */ diff --git a/source/blender/depsgraph/intern/eval/deg_eval_flush.cc b/source/blender/depsgraph/intern/eval/deg_eval_flush.cc index 3f42d1a80c1..62a9158928d 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_flush.cc +++ b/source/blender/depsgraph/intern/eval/deg_eval_flush.cc @@ -31,7 +31,6 @@ #include "intern/debug/deg_debug.h" #include "intern/depsgraph.h" #include "intern/depsgraph_relation.h" -#include "intern/depsgraph_tag.h" #include "intern/depsgraph_type.h" #include "intern/depsgraph_update.h" #include "intern/node/deg_node.h" @@ -100,18 +99,6 @@ inline void flush_prepare(Depsgraph *graph) inline void flush_schedule_entrypoints(Depsgraph *graph, FlushQueue *queue) { - /* Something changed in the scene, so re-tag IDs with flags which were previously ignored due to - * ID being hidden. This will ensure the ID is properly evaluated when it becomes visible. */ - for (IDNode *node : graph->id_nodes) { - if (node->id_invisible_recalc) { - graph_id_tag_update(graph->bmain, - graph, - node->id_orig, - node->id_invisible_recalc, - DEG_UPDATE_SOURCE_VISIBILITY); - } - } - for (OperationNode *op_node : graph->entry_tags) { queue->push_back(op_node); op_node->scheduled = true; @@ -248,7 +235,7 @@ void flush_editors_id_update(Depsgraph *graph, const DEGEditorUpdateContext *upd EVAL, "Accumulated recalc bits for %s: %u\n", id_orig->name, - (unsigned int)id_cow->recalc); + uint(id_cow->recalc)); /* Inform editors. Only if the data-block is being evaluated a second * time, to distinguish between user edits and initial evaluation when @@ -297,7 +284,7 @@ void invalidate_tagged_evaluated_transform(ID *id) switch (id_type) { case ID_OB: { Object *object = (Object *)id; - copy_vn_fl((float *)object->obmat, 16, NAN); + copy_vn_fl((float *)object->object_to_world, 16, NAN); break; } default: @@ -384,10 +371,6 @@ void deg_graph_flush_updates(Depsgraph *graph) while (op_node != nullptr) { /* Tag operation as required for update. */ op_node->flag |= DEPSOP_FLAG_NEEDS_UPDATE; - /* Tag depsgraph visibility update when visibility operation is tagged for an update. */ - if (op_node->opcode == OperationCode::VISIBILITY) { - graph->need_update_nodes_visibility = true; - } /* Inform corresponding ID and component nodes about the change. */ ComponentNode *comp_node = op_node->owner; IDNode *id_node = comp_node->owner; diff --git a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_gpencil.cc b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_gpencil.cc index c5def69a70f..e3d7593eb3c 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_gpencil.cc +++ b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_gpencil.cc @@ -19,7 +19,7 @@ GPencilBackup::GPencilBackup(const Depsgraph *depsgraph) : depsgraph(depsgraph) { } -void GPencilBackup::init_from_gpencil(bGPdata *UNUSED(gpd)) +void GPencilBackup::init_from_gpencil(bGPdata * /*gpd*/) { } diff --git a/source/blender/depsgraph/intern/eval/deg_eval_visibility.cc b/source/blender/depsgraph/intern/eval/deg_eval_visibility.cc index 515c9a197d7..0ee4052eff3 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_visibility.cc +++ b/source/blender/depsgraph/intern/eval/deg_eval_visibility.cc @@ -34,13 +34,11 @@ void deg_evaluate_object_node_visibility(::Depsgraph *depsgraph, IDNode *id_node DEG_debug_print_eval(depsgraph, __func__, object->id.name, &object->id); - bool is_enabled; - if (graph->mode == DAG_EVAL_VIEWPORT) { - is_enabled = (object->base_flag & BASE_ENABLED_AND_MAYBE_VISIBLE_IN_VIEWPORT); - } - else { - is_enabled = (object->base_flag & BASE_ENABLED_RENDER); - }; + const int required_flags = (graph->mode == DAG_EVAL_VIEWPORT) ? BASE_ENABLED_VIEWPORT : + BASE_ENABLED_RENDER; + + const bool is_enabled = !graph->use_visibility_optimization || + object->base_flag & required_flags; if (id_node->is_enabled_on_eval != is_enabled) { id_node->is_enabled_on_eval = is_enabled; @@ -76,7 +74,8 @@ void deg_evaluate_object_modifiers_mode_node_visibility(::Depsgraph *depsgraph, "Modifier node in depsgraph is not found. Likely due to missing " "DEG_relations_tag_update()."); - const bool modifier_enabled = modifier->mode & modifier_mode; + const bool modifier_enabled = !graph->use_visibility_optimization || + (modifier->mode & modifier_mode); const int mute_flag = modifier_enabled ? 0 : DEPSOP_FLAG_MUTE; if ((modifier_node->flag & DEPSOP_FLAG_MUTE) != mute_flag) { modifier_node->flag &= ~DEPSOP_FLAG_MUTE; diff --git a/source/blender/depsgraph/intern/node/deg_node.cc b/source/blender/depsgraph/intern/node/deg_node.cc index 7a515424e06..6303b22cac3 100644 --- a/source/blender/depsgraph/intern/node/deg_node.cc +++ b/source/blender/depsgraph/intern/node/deg_node.cc @@ -100,6 +100,8 @@ const char *nodeTypeAsString(NodeType type) return "SIMULATION"; case NodeType::NTREE_OUTPUT: return "NTREE_OUTPUT"; + case NodeType::NTREE_GEOMETRY_PREPROCESS: + return "NTREE_GEOMETRY_PREPROCESS"; /* Total number of meaningful node types. */ case NodeType::NUM_TYPES: @@ -158,6 +160,7 @@ eDepsSceneComponentType nodeTypeToSceneComponent(NodeType type) case NodeType::CACHE: case NodeType::SIMULATION: case NodeType::NTREE_OUTPUT: + case NodeType::NTREE_GEOMETRY_PREPROCESS: return DEG_SCENE_COMP_PARAMETERS; case NodeType::VISIBILITY: @@ -232,6 +235,7 @@ eDepsObjectComponentType nodeTypeToObjectComponent(NodeType type) case NodeType::SYNCHRONIZATION: case NodeType::SIMULATION: case NodeType::NTREE_OUTPUT: + case NodeType::NTREE_GEOMETRY_PREPROCESS: case NodeType::UNDEFINED: case NodeType::NUM_TYPES: return DEG_OB_COMP_PARAMETERS; diff --git a/source/blender/depsgraph/intern/node/deg_node.h b/source/blender/depsgraph/intern/node/deg_node.h index db912ee3a82..e31c1769a2a 100644 --- a/source/blender/depsgraph/intern/node/deg_node.h +++ b/source/blender/depsgraph/intern/node/deg_node.h @@ -130,6 +130,8 @@ enum class NodeType { SIMULATION, /* Node tree output component. */ NTREE_OUTPUT, + /* Preprocessing for geometry node trees before they can be evaluated. */ + NTREE_GEOMETRY_PREPROCESS, /* Total number of meaningful node types. */ NUM_TYPES, diff --git a/source/blender/depsgraph/intern/node/deg_node_component.cc b/source/blender/depsgraph/intern/node/deg_node_component.cc index f2d82e80fa6..718097b4ef8 100644 --- a/source/blender/depsgraph/intern/node/deg_node_component.cc +++ b/source/blender/depsgraph/intern/node/deg_node_component.cc @@ -48,18 +48,18 @@ ComponentNode::OperationIDKey::OperationIDKey(OperationCode opcode, const char * string ComponentNode::OperationIDKey::identifier() const { - const string codebuf = to_string(static_cast<int>(opcode)); + const string codebuf = to_string(int(opcode)); return "OperationIDKey(" + codebuf + ", " + name + ")"; } bool ComponentNode::OperationIDKey::operator==(const OperationIDKey &other) const { - return (opcode == other.opcode) && (STREQ(name, other.name)) && (name_tag == other.name_tag); + return (opcode == other.opcode) && STREQ(name, other.name) && (name_tag == other.name_tag); } uint64_t ComponentNode::OperationIDKey::hash() const { - const int opcode_as_int = static_cast<int>(opcode); + const int opcode_as_int = int(opcode); return BLI_ghashutil_combine_hash( name_tag, BLI_ghashutil_combine_hash(BLI_ghashutil_uinthash(opcode_as_int), @@ -90,10 +90,11 @@ ComponentNode::~ComponentNode() string ComponentNode::identifier() const { - const string idname = this->owner->name; - const string typebuf = "" + to_string(static_cast<int>(type)) + ")"; - return typebuf + name + " : " + idname + - "( affects_visible_id: " + (affects_visible_id ? "true" : "false") + ")"; + const string type_name = type_get_factory(type)->type_name(); + const string name_part = name[0] ? (string(" '") + name + "'") : ""; + + return "[" + type_name + "]" + name_part + " : " + + "(affects_visible_id: " + (affects_visible_id ? "true" : "false") + ")"; } OperationNode *ComponentNode::find_operation(OperationIDKey key) const @@ -337,6 +338,7 @@ DEG_COMPONENT_NODE_DEFINE(GenericDatablock, GENERIC_DATABLOCK, 0); DEG_COMPONENT_NODE_DEFINE(Visibility, VISIBILITY, 0); DEG_COMPONENT_NODE_DEFINE(Simulation, SIMULATION, 0); DEG_COMPONENT_NODE_DEFINE(NTreeOutput, NTREE_OUTPUT, ID_RECALC_NTREE_OUTPUT); +DEG_COMPONENT_NODE_DEFINE(NTreeGeometryPreprocess, NTREE_GEOMETRY_PREPROCESS, 0); /** \} */ @@ -371,6 +373,7 @@ void deg_register_component_depsnodes() register_node_typeinfo(&DNTI_VISIBILITY); register_node_typeinfo(&DNTI_SIMULATION); register_node_typeinfo(&DNTI_NTREE_OUTPUT); + register_node_typeinfo(&DNTI_NTREE_GEOMETRY_PREPROCESS); } /** \} */ diff --git a/source/blender/depsgraph/intern/node/deg_node_component.h b/source/blender/depsgraph/intern/node/deg_node_component.h index f7f38b88854..44c63822ca3 100644 --- a/source/blender/depsgraph/intern/node/deg_node_component.h +++ b/source/blender/depsgraph/intern/node/deg_node_component.h @@ -208,6 +208,7 @@ DEG_COMPONENT_NODE_DECLARE_GENERIC(GenericDatablock); DEG_COMPONENT_NODE_DECLARE_NO_COW_TAG_ON_UPDATE(Visibility); DEG_COMPONENT_NODE_DECLARE_GENERIC(Simulation); DEG_COMPONENT_NODE_DECLARE_GENERIC(NTreeOutput); +DEG_COMPONENT_NODE_DECLARE_GENERIC(NTreeGeometryPreprocess); /* Bone Component */ struct BoneComponentNode : public ComponentNode { diff --git a/source/blender/depsgraph/intern/node/deg_node_factory.cc b/source/blender/depsgraph/intern/node/deg_node_factory.cc index bcdfdbec604..4c08d4ee7bb 100644 --- a/source/blender/depsgraph/intern/node/deg_node_factory.cc +++ b/source/blender/depsgraph/intern/node/deg_node_factory.cc @@ -10,19 +10,19 @@ namespace blender::deg { /* Global type registry */ -static DepsNodeFactory *node_typeinfo_registry[static_cast<int>(NodeType::NUM_TYPES)] = {nullptr}; +static DepsNodeFactory *node_typeinfo_registry[int(NodeType::NUM_TYPES)] = {nullptr}; void register_node_typeinfo(DepsNodeFactory *factory) { BLI_assert(factory != nullptr); - const int type_as_int = static_cast<int>(factory->type()); + const int type_as_int = int(factory->type()); node_typeinfo_registry[type_as_int] = factory; } DepsNodeFactory *type_get_factory(const NodeType type) { /* Look up type - at worst, it doesn't exist in table yet, and we fail. */ - const int type_as_int = static_cast<int>(type); + const int type_as_int = int(type); return node_typeinfo_registry[type_as_int]; } 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 d9d0a1c1e3e..5059368120e 100644 --- a/source/blender/depsgraph/intern/node/deg_node_factory_impl.h +++ b/source/blender/depsgraph/intern/node/deg_node_factory_impl.h @@ -34,15 +34,8 @@ Node *DepsNodeFactoryImpl<ModeObjectType>::create_node(const ID *id, const char *name) const { Node *node = new ModeObjectType(); - /* Populate base node settings. */ node->type = type(); - /* Set name if provided, or use default type name. */ - if (name[0] != '\0') { - node->name = name; - } - else { - node->name = type_name(); - } + node->name = name; node->init(id, subdata); return node; } diff --git a/source/blender/depsgraph/intern/node/deg_node_id.cc b/source/blender/depsgraph/intern/node/deg_node_id.cc index 9a7d27808be..a37feb7b95d 100644 --- a/source/blender/depsgraph/intern/node/deg_node_id.cc +++ b/source/blender/depsgraph/intern/node/deg_node_id.cc @@ -52,12 +52,12 @@ bool IDNode::ComponentIDKey::operator==(const ComponentIDKey &other) const uint64_t IDNode::ComponentIDKey::hash() const { - const int type_as_int = static_cast<int>(type); + const int type_as_int = int(type); return BLI_ghashutil_combine_hash(BLI_ghashutil_uinthash(type_as_int), BLI_ghashutil_strhash_p(name)); } -void IDNode::init(const ID *id, const char *UNUSED(subdata)) +void IDNode::init(const ID *id, const char * /*subdata*/) { BLI_assert(id != nullptr); /* Store ID-pointer. */ @@ -75,7 +75,6 @@ void IDNode::init(const ID *id, const char *UNUSED(subdata)) has_base = false; is_user_modified = false; id_cow_recalc_backup = 0; - id_invisible_recalc = 0; visible_components_mask = 0; previously_visible_components_mask = 0; @@ -191,7 +190,7 @@ IDComponentsMask IDNode::get_visible_components_mask() const IDComponentsMask result = 0; for (ComponentNode *comp_node : components.values()) { if (comp_node->possibly_affects_visible_id) { - const int component_type_as_int = static_cast<int>(comp_node->type); + const int component_type_as_int = int(comp_node->type); BLI_assert(component_type_as_int < 64); result |= (1ULL << component_type_as_int); } diff --git a/source/blender/depsgraph/intern/node/deg_node_id.h b/source/blender/depsgraph/intern/node/deg_node_id.h index e9bbc816907..7f0a656cb8d 100644 --- a/source/blender/depsgraph/intern/node/deg_node_id.h +++ b/source/blender/depsgraph/intern/node/deg_node_id.h @@ -123,9 +123,6 @@ struct IDNode : public Node { /* Accumulate recalc flags from multiple update passes. */ int id_cow_recalc_backup; - /* Flags which components were not evaluated due to ID being invisible. */ - int id_invisible_recalc; - IDComponentsMask visible_components_mask; IDComponentsMask previously_visible_components_mask; diff --git a/source/blender/depsgraph/intern/node/deg_node_operation.cc b/source/blender/depsgraph/intern/node/deg_node_operation.cc index 016af735fcf..d5401a6b0d1 100644 --- a/source/blender/depsgraph/intern/node/deg_node_operation.cc +++ b/source/blender/depsgraph/intern/node/deg_node_operation.cc @@ -173,6 +173,8 @@ const char *operationCodeAsString(OperationCode opcode) /* Node Tree. */ case OperationCode::NTREE_OUTPUT: return "NTREE_OUTPUT"; + case OperationCode::NTREE_GEOMETRY_PREPROCESS: + return "NTREE_GEOMETRY_PREPROCESS"; /* Movie clip. */ case OperationCode::MOVIECLIP_EVAL: return "MOVIECLIP_EVAL"; diff --git a/source/blender/depsgraph/intern/node/deg_node_operation.h b/source/blender/depsgraph/intern/node/deg_node_operation.h index cb3beb56556..b0685ac0351 100644 --- a/source/blender/depsgraph/intern/node/deg_node_operation.h +++ b/source/blender/depsgraph/intern/node/deg_node_operation.h @@ -165,6 +165,7 @@ enum class OperationCode { /* Node Tree. ----------------------------------------------------------- */ NTREE_OUTPUT, + NTREE_GEOMETRY_PREPROCESS, /* Batch caches. -------------------------------------------------------- */ GEOMETRY_SELECT_UPDATE, |