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:
authorSybren A. Stüvel <sybren@blender.org>2021-02-04 16:17:50 +0300
committerSybren A. Stüvel <sybren@blender.org>2021-02-04 20:56:41 +0300
commit2397ccc583afbd908e54237f29c80bbc99b43740 (patch)
tree2a6f8404e6b6fc4fcb08c226b2fe2c276fd388c1
parente027d93ab08d0bf37dff9d544489595c58234966 (diff)
Animation: Add PreviewImage to bAction struct
Make it possible to attach a preview image to an Action. In the #asset_browser_pose_libraries project, poses will be stored as individual Action datablocks. Having a thumbnail for each pose is of course essential. Reviewed By: mont29 Differential Revision: https://developer.blender.org/D10306
-rw-r--r--source/blender/blenkernel/intern/action.c20
-rw-r--r--source/blender/blenkernel/intern/icons.cc1
-rw-r--r--source/blender/makesdna/DNA_action_types.h2
3 files changed, 19 insertions, 4 deletions
diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c
index db8fe75b6d1..94680dc5c0c 100644
--- a/source/blender/blenkernel/intern/action.c
+++ b/source/blender/blenkernel/intern/action.c
@@ -54,6 +54,7 @@
#include "BKE_constraint.h"
#include "BKE_deform.h"
#include "BKE_fcurve.h"
+#include "BKE_icons.h"
#include "BKE_idprop.h"
#include "BKE_idtype.h"
#include "BKE_lib_id.h"
@@ -101,10 +102,7 @@ static CLG_LogRef LOG = {"bke.action"};
*
* \param flag: Copying options (see BKE_lib_id.h's LIB_ID_COPY_... flags for more).
*/
-static void action_copy_data(Main *UNUSED(bmain),
- ID *id_dst,
- const ID *id_src,
- const int UNUSED(flag))
+static void action_copy_data(Main *UNUSED(bmain), ID *id_dst, const ID *id_src, const int flag)
{
bAction *action_dst = (bAction *)id_dst;
const bAction *action_src = (const bAction *)id_src;
@@ -145,6 +143,13 @@ static void action_copy_data(Main *UNUSED(bmain),
}
}
}
+
+ if (flag & LIB_ID_COPY_NO_PREVIEW) {
+ action_dst->preview = NULL;
+ }
+ else {
+ BKE_previewimg_id_copy(&action_dst->id, &action_src->id);
+ }
}
/** Free (or release) any data used by this action (does not free the action itself). */
@@ -161,6 +166,8 @@ static void action_free_data(struct ID *id)
/* Free pose-references (aka local markers). */
BLI_freelistN(&action->markers);
+
+ BKE_previewimg_free(&action->preview);
}
static void action_foreach_id(ID *id, LibraryForeachIDData *data)
@@ -192,6 +199,8 @@ static void action_blend_write(BlendWriter *writer, ID *id, const void *id_addre
LISTBASE_FOREACH (TimeMarker *, marker, &act->markers) {
BLO_write_struct(writer, TimeMarker, marker);
}
+
+ BKE_previewimg_blend_write(writer, act->preview);
}
}
@@ -218,6 +227,9 @@ static void action_blend_read_data(BlendDataReader *reader, ID *id)
BLO_read_data_address(reader, &agrp->channels.first);
BLO_read_data_address(reader, &agrp->channels.last);
}
+
+ BLO_read_data_address(reader, &act->preview);
+ BKE_previewimg_blend_read(reader, act->preview);
}
static void blend_read_lib_constraint_channels(BlendLibReader *reader, ID *id, ListBase *chanbase)
diff --git a/source/blender/blenkernel/intern/icons.cc b/source/blender/blenkernel/intern/icons.cc
index cba1726a1b9..afb009b66cd 100644
--- a/source/blender/blenkernel/intern/icons.cc
+++ b/source/blender/blenkernel/intern/icons.cc
@@ -374,6 +374,7 @@ PreviewImage **BKE_previewimg_id_get_p(const ID *id)
ID_PRV_CASE(ID_GR, Collection);
ID_PRV_CASE(ID_SCE, Scene);
ID_PRV_CASE(ID_SCR, bScreen);
+ ID_PRV_CASE(ID_AC, bAction);
#undef ID_PRV_CASE
default:
break;
diff --git a/source/blender/makesdna/DNA_action_types.h b/source/blender/makesdna/DNA_action_types.h
index 790a7a36288..96245e3b067 100644
--- a/source/blender/makesdna/DNA_action_types.h
+++ b/source/blender/makesdna/DNA_action_types.h
@@ -676,6 +676,8 @@ typedef struct bAction {
*/
int idroot;
char _pad[4];
+
+ PreviewImage *preview;
} bAction;
/* Flags for the action */