WIP: Brush assets project #106303
|
@ -76,6 +76,5 @@ PreviewImage *BKE_asset_metadata_preview_get_from_id(const AssetMetaData *asset_
|
|||
void BKE_asset_metadata_write(BlendWriter *writer, AssetMetaData *asset_data);
|
||||
void BKE_asset_metadata_read(BlendDataReader *reader, AssetMetaData *asset_data);
|
||||
|
||||
AssetWeakReference *BKE_asset_weak_reference_copy(const AssetWeakReference *weak_ref);
|
||||
void BKE_asset_weak_reference_write(BlendWriter *writer, const AssetWeakReference *weak_ref);
|
||||
void BKE_asset_weak_reference_read(BlendDataReader *reader, AssetWeakReference *weak_ref);
|
||||
|
|
|
@ -84,20 +84,6 @@ bool AssetWeakReference::operator!=(const AssetWeakReference &other) const
|
|||
return !(*this == other);
|
||||
}
|
||||
|
||||
AssetWeakReference *BKE_asset_weak_reference_copy(const AssetWeakReference *weak_ref)
|
||||
{
|
||||
if (weak_ref == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
AssetWeakReference *weak_ref_copy = MEM_new<AssetWeakReference>(__func__);
|
||||
weak_ref_copy->asset_library_type = weak_ref->asset_library_type;
|
||||
weak_ref_copy->asset_library_identifier = BLI_strdup_null(weak_ref->asset_library_identifier);
|
||||
weak_ref_copy->relative_asset_identifier = BLI_strdup_null(weak_ref->relative_asset_identifier);
|
||||
|
||||
return weak_ref_copy;
|
||||
}
|
||||
|
||||
AssetWeakReference AssetWeakReference::make_reference(
|
||||
const asset_system::AssetLibrary &library,
|
||||
const asset_system::AssetIdentifier &asset_identifier)
|
||||
|
|
|
@ -1290,20 +1290,23 @@ void BKE_paint_free(Paint *paint)
|
|||
MEM_delete(paint->brush_asset_reference);
|
||||
}
|
||||
|
||||
void BKE_paint_copy(const Paint *src, Paint *tar, const int flag)
|
||||
void BKE_paint_copy(const Paint *src, Paint *dst, const int flag)
|
||||
{
|
||||
tar->brush = src->brush;
|
||||
tar->cavity_curve = BKE_curvemapping_copy(src->cavity_curve);
|
||||
tar->tool_slots = static_cast<PaintToolSlot *>(MEM_dupallocN(src->tool_slots));
|
||||
dst->brush = src->brush;
|
||||
dst->cavity_curve = BKE_curvemapping_copy(src->cavity_curve);
|
||||
dst->tool_slots = static_cast<PaintToolSlot *>(MEM_dupallocN(src->tool_slots));
|
||||
|
||||
tar->brush_asset_reference = BKE_asset_weak_reference_copy(src->brush_asset_reference);
|
||||
if (src->brush_asset_reference) {
|
||||
dst->brush_asset_reference = MEM_new<AssetWeakReference>(__func__,
|
||||
*src->brush_asset_reference);
|
||||
}
|
||||
|
||||
if ((flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0) {
|
||||
id_us_plus((ID *)tar->brush);
|
||||
id_us_plus((ID *)tar->palette);
|
||||
id_us_plus((ID *)dst->brush);
|
||||
id_us_plus((ID *)dst->palette);
|
||||
if (src->tool_slots != nullptr) {
|
||||
for (int i = 0; i < tar->tool_slots_len; i++) {
|
||||
id_us_plus((ID *)tar->tool_slots[i].brush);
|
||||
for (int i = 0; i < dst->tool_slots_len; i++) {
|
||||
id_us_plus((ID *)dst->tool_slots[i].brush);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ namespace blender::ed::asset::shelf {
|
|||
class AssetView : public ui::AbstractGridView {
|
||||
const AssetLibraryReference library_ref_;
|
||||
const AssetShelf &shelf_;
|
||||
AssetWeakReference *active_asset_ = nullptr;
|
||||
std::optional<AssetWeakReference> active_asset_;
|
||||
/** Copy of the filter string from #AssetShelfSettings, with extra '*' added to the beginning and
|
||||
* end of the string, for `fnmatch()` to work. */
|
||||
char search_string[sizeof(AssetShelfSettings::search_string) + 2] = "";
|
||||
|
@ -96,14 +96,16 @@ AssetView::AssetView(const AssetLibraryReference &library_ref, const AssetShelf
|
|||
search_string, shelf.settings.search_string, '*', sizeof(search_string));
|
||||
}
|
||||
if (shelf.type->get_active_asset) {
|
||||
active_asset_ = BKE_asset_weak_reference_copy(shelf.type->get_active_asset(shelf.type));
|
||||
if (const AssetWeakReference *weak_ref = shelf.type->get_active_asset(shelf.type)) {
|
||||
active_asset_ = *weak_ref;
|
||||
}
|
||||
else {
|
||||
active_asset_.reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AssetView::~AssetView()
|
||||
{
|
||||
MEM_delete(active_asset_);
|
||||
}
|
||||
AssetView::~AssetView() {}
|
||||
|
||||
void AssetView::build_items()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue