Geometry Nodes: Avoid repeated node tools lookup when empty
Currently the node tools asset tree for extending 3D view headers is rebuilt whenever it's cleared, which is done by clearing the tree's storage. That means the data is rebuilt on every redraw if there are no node tools and the tree storage is empty. With larger asset libraries that can be quite expensive. Now, instead of clearing the map, use a new dirty tag to store whether the asset tree is out of date compared to the assets. This should resolve #120494
This commit is contained in:
@@ -54,6 +54,8 @@ struct AssetItemTree {
|
||||
assets_per_path;
|
||||
/** Assets not added to a catalog, not part of #assets_per_path. */
|
||||
Vector<asset_system::AssetRepresentation *> unassigned_assets;
|
||||
/** True if the tree is out of date compared to asset libraries and must be rebuilt. */
|
||||
bool dirty = true;
|
||||
};
|
||||
|
||||
asset_system::AssetCatalogTree build_filtered_catalog_tree(
|
||||
|
||||
@@ -150,7 +150,8 @@ AssetItemTree build_filtered_all_catalog_tree(
|
||||
|
||||
return {std::move(catalogs_with_node_assets),
|
||||
std::move(assets_per_path),
|
||||
std::move(unassigned_assets)};
|
||||
std::move(unassigned_assets),
|
||||
false};
|
||||
}
|
||||
|
||||
} // namespace blender::ed::asset
|
||||
|
||||
@@ -787,7 +787,7 @@ void clear_operator_asset_trees()
|
||||
for (const ObjectType type : {OB_MESH, OB_CURVES, OB_POINTCLOUD}) {
|
||||
for (const eObjectMode mode : {OB_MODE_OBJECT, OB_MODE_EDIT, OB_MODE_SCULPT_CURVES}) {
|
||||
if (asset::AssetItemTree *tree = get_static_item_tree(type, mode)) {
|
||||
*tree = {};
|
||||
tree->dirty = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1105,7 +1105,7 @@ void ui_template_node_operator_asset_root_items(uiLayout &layout, const bContext
|
||||
if (!tree) {
|
||||
return;
|
||||
}
|
||||
if (tree->assets_per_path.size() == 0) {
|
||||
if (tree->dirty) {
|
||||
*tree = build_catalog_tree(C, *active_object);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user