diff options
author | Sergey Sharybin <sergey@blender.org> | 2022-08-02 11:54:44 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey@blender.org> | 2022-08-02 12:38:16 +0300 |
commit | 1c90ab7bf252ba008e0f61f37886ab58c75f5c7b (patch) | |
tree | 86402776faf73c0edae7c7decda3bd882476c116 /source/blender/depsgraph/intern | |
parent | 670ced97589d3fc29feafb32e96d08541aa7b32e (diff) |
Depsgraph: Make naming and recalc flag sign consistent
Always use unsigned int for the recalc flags. This allows to use
all 32 bit of integer for the flags without worrying about the
sign. Use full notation of `unsigned int` instead of short `uint`
to avoid pulling more headers in.
Whenever depsgraph API allows passing combined recalc flags call
the variable `flags` and use `unsigned int` type for it. For a
single flag use `IDRecalcFlag` flag.
No functional changes expected.
Diffstat (limited to 'source/blender/depsgraph/intern')
-rw-r--r-- | source/blender/depsgraph/intern/depsgraph_tag.cc | 62 | ||||
-rw-r--r-- | source/blender/depsgraph/intern/depsgraph_tag.h | 4 |
2 files changed, 33 insertions, 33 deletions
diff --git a/source/blender/depsgraph/intern/depsgraph_tag.cc b/source/blender/depsgraph/intern/depsgraph_tag.cc index 9cd5980d8fe..7a2904e3766 100644 --- a/source/blender/depsgraph/intern/depsgraph_tag.cc +++ b/source/blender/depsgraph/intern/depsgraph_tag.cc @@ -224,13 +224,13 @@ void depsgraph_tag_to_component_opcode(const ID *id, } void id_tag_update_ntree_special( - Main *bmain, Depsgraph *graph, ID *id, int flag, eUpdateSource update_source) + Main *bmain, Depsgraph *graph, ID *id, unsigned int flags, eUpdateSource update_source) { bNodeTree *ntree = ntreeFromID(id); if (ntree == nullptr) { return; } - graph_id_tag_update(bmain, graph, &ntree->id, flag, update_source); + graph_id_tag_update(bmain, graph, &ntree->id, flags, update_source); } void depsgraph_update_editors_tag(Main *bmain, Depsgraph *graph, ID *id) @@ -407,13 +407,13 @@ string stringify_append_bit(const string &str, IDRecalcFlag tag) return result; } -string stringify_update_bitfield(int flag) +string stringify_update_bitfield(unsigned int flags) { - if (flag == 0) { + if (flags == 0) { return "LEGACY_0"; } string result; - int current_flag = flag; + unsigned int 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) { @@ -421,7 +421,7 @@ string stringify_update_bitfield(int flag) } /* Handle all the rest of the flags. */ while (current_flag != 0) { - IDRecalcFlag tag = (IDRecalcFlag)(1 << bitscan_forward_clear_i(¤t_flag)); + IDRecalcFlag tag = (IDRecalcFlag)(1 << bitscan_forward_clear_uint(¤t_flag)); result = stringify_append_bit(result, tag); } return result; @@ -449,7 +449,7 @@ int deg_recalc_flags_for_legacy_zero() ID_RECALC_SOURCE | ID_RECALC_EDITORS); } -int deg_recalc_flags_effective(Depsgraph *graph, int flags) +int deg_recalc_flags_effective(Depsgraph *graph, unsigned int flags) { if (graph != nullptr) { if (!graph->is_active) { @@ -520,12 +520,12 @@ void graph_tag_ids_for_visible_update(Depsgraph *graph) * No need bother with it to tag or anything. */ continue; } - int flag = 0; + unsigned int flags = 0; if (!deg::deg_copy_on_write_is_expanded(id_node->id_cow)) { - flag |= ID_RECALC_COPY_ON_WRITE; + flags |= ID_RECALC_COPY_ON_WRITE; if (do_time) { if (BKE_animdata_from_id(id_node->id_orig) != nullptr) { - flag |= ID_RECALC_ANIMATION; + flags |= ID_RECALC_ANIMATION; } } } @@ -542,9 +542,9 @@ void graph_tag_ids_for_visible_update(Depsgraph *graph) * * TODO(sergey): Need to generalize this somehow. */ if (id_type == ID_OB) { - flag |= ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY; + flags |= ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY; } - graph_id_tag_update(bmain, graph, id_node->id_orig, flag, DEG_UPDATE_SOURCE_VISIBILITY); + graph_id_tag_update(bmain, graph, id_node->id_orig, flags, DEG_UPDATE_SOURCE_VISIBILITY); if (id_type == ID_SCE) { /* Make sure collection properties are up to date. */ id_node->tag_update(graph, DEG_UPDATE_SOURCE_VISIBILITY); @@ -614,20 +614,20 @@ NodeType geometry_tag_to_component(const ID *id) return NodeType::UNDEFINED; } -void id_tag_update(Main *bmain, ID *id, int flag, eUpdateSource update_source) +void id_tag_update(Main *bmain, ID *id, unsigned int flags, eUpdateSource update_source) { - graph_id_tag_update(bmain, nullptr, id, flag, update_source); + graph_id_tag_update(bmain, nullptr, id, flags, update_source); for (deg::Depsgraph *depsgraph : deg::get_all_registered_graphs(bmain)) { - graph_id_tag_update(bmain, depsgraph, id, flag, update_source); + graph_id_tag_update(bmain, depsgraph, id, flags, update_source); } /* Accumulate all tags for an ID between two undo steps, so they can be * replayed for undo. */ - id->recalc_after_undo_push |= deg_recalc_flags_effective(nullptr, flag); + id->recalc_after_undo_push |= deg_recalc_flags_effective(nullptr, flags); } void graph_id_tag_update( - Main *bmain, Depsgraph *graph, ID *id, int flag, eUpdateSource update_source) + Main *bmain, Depsgraph *graph, ID *id, unsigned int flags, eUpdateSource update_source) { const int debug_flags = (graph != nullptr) ? DEG_debug_flags_get((::Depsgraph *)graph) : G.debug; if (graph != nullptr && graph->is_evaluating) { @@ -640,20 +640,20 @@ void graph_id_tag_update( printf("%s: id=%s flags=%s source=%s\n", __func__, id->name, - stringify_update_bitfield(flag).c_str(), + stringify_update_bitfield(flags).c_str(), update_source_as_string(update_source)); } IDNode *id_node = (graph != nullptr) ? graph->find_id_node(id) : nullptr; if (graph != nullptr) { DEG_graph_id_type_tag(reinterpret_cast<::Depsgraph *>(graph), GS(id->name)); } - if (flag == 0) { + if (flags == 0) { deg_graph_node_tag_zero(bmain, graph, id_node, update_source); } /* Store original flag in the ID. * Allows to have more granularity than a node-factory based flags. */ if (id_node != nullptr) { - id_node->id_cow->recalc |= flag; + id_node->id_cow->recalc |= flags; } /* When ID is tagged for update based on an user edits store the recalc flags in the original ID. * This way IDs in the undo steps will have this flag preserved, making it possible to restore @@ -663,20 +663,20 @@ void graph_id_tag_update( * usually newly created dependency graph skips animation update to avoid loss of unkeyed * changes). */ if (update_source == DEG_UPDATE_SOURCE_USER_EDIT) { - id->recalc |= deg_recalc_flags_effective(graph, flag); + id->recalc |= deg_recalc_flags_effective(graph, flags); } - int current_flag = flag; + unsigned int current_flag = flags; while (current_flag != 0) { - IDRecalcFlag tag = (IDRecalcFlag)(1 << bitscan_forward_clear_i(¤t_flag)); + IDRecalcFlag tag = (IDRecalcFlag)(1 << bitscan_forward_clear_uint(¤t_flag)); graph_id_tag_update_single_flag(bmain, graph, id, id_node, tag, update_source); } /* Special case for nested node tree data-blocks. */ - id_tag_update_ntree_special(bmain, graph, id, flag, update_source); + id_tag_update_ntree_special(bmain, graph, id, flags, update_source); /* Direct update tags means that something outside of simulated/cached * physics did change and that cache is to be invalidated. * This is only needed if data changes. If it's just a drawing, we keep the * point cache. */ - if (update_source == DEG_UPDATE_SOURCE_USER_EDIT && flag != ID_RECALC_SHADING) { + if (update_source == DEG_UPDATE_SOURCE_USER_EDIT && flags != ID_RECALC_SHADING) { graph_id_tag_update_single_flag( bmain, graph, id, id_node, ID_RECALC_POINT_CACHE, update_source); } @@ -747,27 +747,27 @@ const char *DEG_update_tag_as_string(IDRecalcFlag flag) /* Data-Based Tagging. */ -void DEG_id_tag_update(ID *id, int flag) +void DEG_id_tag_update(ID *id, unsigned int flags) { - DEG_id_tag_update_ex(G.main, id, flag); + DEG_id_tag_update_ex(G.main, id, flags); } -void DEG_id_tag_update_ex(Main *bmain, ID *id, int flag) +void DEG_id_tag_update_ex(Main *bmain, ID *id, unsigned int flags) { if (id == nullptr) { /* 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, flags, deg::DEG_UPDATE_SOURCE_USER_EDIT); } void DEG_graph_id_tag_update(struct Main *bmain, struct Depsgraph *depsgraph, struct ID *id, - int flag) + unsigned int flags) { deg::Depsgraph *graph = (deg::Depsgraph *)depsgraph; - deg::graph_id_tag_update(bmain, graph, id, flag, deg::DEG_UPDATE_SOURCE_USER_EDIT); + deg::graph_id_tag_update(bmain, graph, id, flags, deg::DEG_UPDATE_SOURCE_USER_EDIT); } void DEG_time_tag_update(struct Main *bmain) diff --git a/source/blender/depsgraph/intern/depsgraph_tag.h b/source/blender/depsgraph/intern/depsgraph_tag.h index b722aab5719..61643e6f740 100644 --- a/source/blender/depsgraph/intern/depsgraph_tag.h +++ b/source/blender/depsgraph/intern/depsgraph_tag.h @@ -18,11 +18,11 @@ struct Depsgraph; NodeType geometry_tag_to_component(const ID *id); /* Tag given ID for an update in all registered dependency graphs. */ -void id_tag_update(Main *bmain, ID *id, int flag, eUpdateSource update_source); +void id_tag_update(Main *bmain, ID *id, unsigned int flags, eUpdateSource update_source); /* Tag given ID for an update with in a given dependency graph. */ void graph_id_tag_update( - Main *bmain, Depsgraph *graph, ID *id, int flag, eUpdateSource update_source); + Main *bmain, Depsgraph *graph, ID *id, unsigned int flags, eUpdateSource update_source); /* Tag IDs of the graph for the visibility update tags. * Will do nothing if the graph is not tagged for visibility update. */ |