Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Eisel <julian@blender.org>2020-11-23 16:14:55 +0300
committerJulian Eisel <julian@blender.org>2020-11-23 16:14:55 +0300
commit31acdbed95a5e51baf377f06604313463b3f2a00 (patch)
treec3dcc848f148e6869bccda96d9dce0fd33e8587f /source/blender/blenkernel/intern/asset.c
parent3f33bf619502cd7cb1d8e546d7a56cd18af28ea7 (diff)
Add custom property support for assetsasset-metadata
I didn't do this earlier because I was afraid it would make reading of asset data (and asset data only!) difficult. Mainly because custom properties could store pointers to other data, that would have to be read too then (e.g. an object). But turns out, we can easily disable custom pointers to other data-blocks, so reading stays simple :).
Diffstat (limited to 'source/blender/blenkernel/intern/asset.c')
-rw-r--r--source/blender/blenkernel/intern/asset.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/asset.c b/source/blender/blenkernel/intern/asset.c
index 0f62ee6df1d..427ede47272 100644
--- a/source/blender/blenkernel/intern/asset.c
+++ b/source/blender/blenkernel/intern/asset.c
@@ -26,6 +26,7 @@
#include "BKE_asset.h"
#include "BKE_icons.h"
+#include "BKE_idprop.h"
#include "DNA_ID.h"
#include "DNA_asset_types.h"
@@ -44,6 +45,9 @@ AssetData *BKE_asset_data_create(void)
void BKE_asset_data_free(AssetData *asset_data)
{
+ if (asset_data->properties) {
+ IDP_FreeProperty(asset_data->properties);
+ }
MEM_SAFE_FREE(asset_data->description);
BLI_freelistN(&asset_data->tags);
@@ -86,6 +90,10 @@ void BKE_assetdata_write(BlendWriter *writer, AssetData *asset_data)
{
BLO_write_struct(writer, AssetData, asset_data);
+ if (asset_data->properties) {
+ IDP_BlendWrite(writer, asset_data->properties);
+ }
+
if (asset_data->description) {
BLO_write_string(writer, asset_data->description);
}
@@ -98,6 +106,11 @@ void BKE_assetdata_read(BlendDataReader *reader, AssetData *asset_data)
{
/* asset_data itself has been read already. */
+ if (asset_data->properties) {
+ BLO_read_data_address(reader, &asset_data->properties);
+ IDP_BlendDataRead(reader, &asset_data->properties);
+ }
+
BLO_read_data_address(reader, &asset_data->description);
BLO_read_list(reader, &asset_data->tags);
}