Fix: Missing node asset menu updates after mark asset
Use of node group assets relies on a few properties written to asset meta-data for proper filtering of assets in menus (add modifier menu, node add menu, 3D view menus for tools). Currently these meta-data properties are written when updating their source properties and when saving the file. That means they *aren't* written when marking a group as an asset, which is necessary because the meta-data doesn't exist before when the group isn't an asset. Currently users have to save the file to update menus in this case, which isn't intuitive. As a fix, call the function to write the meta-data when marking a data-block as an asset. Pull Request: https://projects.blender.org/blender/blender/pulls/112743
This commit is contained in:
parent
7dbe689b63
commit
395f279166
@ -26,6 +26,7 @@ struct IDProperty;
|
||||
struct PreviewImage;
|
||||
|
||||
typedef void (*PreSaveFn)(void *asset_ptr, struct AssetMetaData *asset_data);
|
||||
typedef void (*OnMarkAssetFn)(void *asset_ptr, struct AssetMetaData *asset_data);
|
||||
|
||||
typedef struct AssetTypeInfo {
|
||||
/**
|
||||
@ -33,6 +34,7 @@ typedef struct AssetTypeInfo {
|
||||
* saved.
|
||||
*/
|
||||
PreSaveFn pre_save_fn;
|
||||
OnMarkAssetFn on_mark_asset_fn;
|
||||
} AssetTypeInfo;
|
||||
|
||||
struct AssetMetaData *BKE_asset_metadata_create(void);
|
||||
|
@ -250,7 +250,7 @@ static IDProperty *action_asset_type_property(const bAction *action)
|
||||
return property;
|
||||
}
|
||||
|
||||
static void action_asset_pre_save(void *asset_ptr, AssetMetaData *asset_data)
|
||||
static void action_asset_metadata_ensure(void *asset_ptr, AssetMetaData *asset_data)
|
||||
{
|
||||
bAction *action = (bAction *)asset_ptr;
|
||||
BLI_assert(GS(action->id.name) == ID_AC);
|
||||
@ -260,7 +260,8 @@ static void action_asset_pre_save(void *asset_ptr, AssetMetaData *asset_data)
|
||||
}
|
||||
|
||||
static AssetTypeInfo AssetType_AC = {
|
||||
/*pre_save_fn*/ action_asset_pre_save,
|
||||
/*pre_save_fn*/ action_asset_metadata_ensure,
|
||||
/*on_mark_asset_fn*/ action_asset_metadata_ensure,
|
||||
};
|
||||
|
||||
IDTypeInfo IDType_ID_AC = {
|
||||
|
@ -1127,10 +1127,16 @@ static void node_tree_asset_pre_save(void *asset_ptr, AssetMetaData * /*asset_da
|
||||
node_update_asset_metadata(*static_cast<bNodeTree *>(asset_ptr));
|
||||
}
|
||||
|
||||
static void node_tree_asset_on_mark_asset(void *asset_ptr, AssetMetaData * /*asset_data*/)
|
||||
{
|
||||
node_update_asset_metadata(*static_cast<bNodeTree *>(asset_ptr));
|
||||
}
|
||||
|
||||
} // namespace blender::bke
|
||||
|
||||
static AssetTypeInfo AssetType_NT = {
|
||||
/*pre_save_fn*/ blender::bke::node_tree_asset_pre_save,
|
||||
/*on_mark_asset_fn*/ blender::bke::node_tree_asset_on_mark_asset,
|
||||
};
|
||||
|
||||
IDTypeInfo IDType_ID_NT = {
|
||||
|
@ -1032,7 +1032,7 @@ static IDProperty *object_asset_dimensions_property(Object *ob)
|
||||
return property;
|
||||
}
|
||||
|
||||
static void object_asset_pre_save(void *asset_ptr, AssetMetaData *asset_data)
|
||||
static void object_asset_metadata_ensure(void *asset_ptr, AssetMetaData *asset_data)
|
||||
{
|
||||
Object *ob = (Object *)asset_ptr;
|
||||
BLI_assert(GS(ob->id.name) == ID_OB);
|
||||
@ -1045,7 +1045,8 @@ static void object_asset_pre_save(void *asset_ptr, AssetMetaData *asset_data)
|
||||
}
|
||||
|
||||
static AssetTypeInfo AssetType_OB = {
|
||||
/*pre_save_fn*/ object_asset_pre_save,
|
||||
/*pre_save_fn*/ object_asset_metadata_ensure,
|
||||
/*on_mark_asset_fn*/ object_asset_metadata_ensure,
|
||||
};
|
||||
|
||||
IDTypeInfo IDType_ID_OB = {
|
||||
|
@ -44,6 +44,7 @@ bool ED_asset_mark_id(ID *id)
|
||||
const IDTypeInfo *id_type_info = BKE_idtype_get_info_from_id(id);
|
||||
id->asset_data = BKE_asset_metadata_create();
|
||||
id->asset_data->local_type_info = id_type_info->asset_type_info;
|
||||
id->asset_data->local_type_info->on_mark_asset_fn(id, id->asset_data);
|
||||
|
||||
/* Important for asset storage to update properly! */
|
||||
ED_assetlist_storage_tag_main_data_dirty();
|
||||
|
@ -1626,6 +1626,11 @@ static void view3d_header_region_listener(const wmRegionListenerParams *params)
|
||||
blender::ed::geometry::clear_operator_asset_trees();
|
||||
ED_region_tag_redraw(region);
|
||||
break;
|
||||
default:
|
||||
if (ELEM(wmn->action, NA_ADDED, NA_REMOVED)) {
|
||||
blender::ed::geometry::clear_operator_asset_trees();
|
||||
ED_region_tag_redraw(region);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case NC_NODE:
|
||||
|
Loading…
Reference in New Issue
Block a user