diff options
author | Julian Eisel <julian@blender.org> | 2022-03-29 16:36:02 +0300 |
---|---|---|
committer | Julian Eisel <julian@blender.org> | 2022-03-29 16:37:22 +0300 |
commit | 810e225c260dfc2eac9c6b8bfd3271066dc0224b (patch) | |
tree | 78a3fdf108c080787b4ad34e1522d4f07f686afc /source/blender/blenkernel | |
parent | 9ec77d709c3cd8cc6b210fd4c5fbf762bd18188e (diff) |
Assets: Support automatic collection previews
Adds supports for collection previews that are rendered automatically when
collections are marked as assets. (Or when preview rendering is triggered
differently, e.g. through the //Refresh Data-Block Previews// operator).
Idea in this patch is to create a collection instance empty outside of main for
the collection, and then reuse the object rendering code to render the preview.
This keeps things very simple and works just fine.
Differential Revision: https://developer.blender.org/D14460
Reviewed by: Bastien Montagne
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_object.h | 7 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/icons.cc | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/object.cc | 2 |
3 files changed, 7 insertions, 4 deletions
diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h index 17d90e64459..4d699e1ff54 100644 --- a/source/blender/blenkernel/BKE_object.h +++ b/source/blender/blenkernel/BKE_object.h @@ -163,9 +163,12 @@ int BKE_object_visibility(const struct Object *ob, int dag_eval_mode); /** * More general add: creates minimum required data, but without vertices etc. + * + * \param bmain: The main to add the object to. May be null for #LIB_ID_CREATE_NO_MAIN behavior. */ -struct Object *BKE_object_add_only_object(struct Main *bmain, int type, const char *name) - ATTR_NONNULL(1) ATTR_RETURNS_NONNULL; +struct Object *BKE_object_add_only_object(struct Main *bmain, + int type, + const char *name) ATTR_RETURNS_NONNULL; /** * General add: to scene, with layer from area and default name. * diff --git a/source/blender/blenkernel/intern/icons.cc b/source/blender/blenkernel/intern/icons.cc index 8883613786b..2ba6510ee71 100644 --- a/source/blender/blenkernel/intern/icons.cc +++ b/source/blender/blenkernel/intern/icons.cc @@ -416,7 +416,7 @@ void BKE_previewimg_id_custom_set(ID *id, const char *path) bool BKE_previewimg_id_supports_jobs(const ID *id) { - return ELEM(GS(id->name), ID_OB, ID_MA, ID_TE, ID_LA, ID_WO, ID_IM, ID_BR); + return ELEM(GS(id->name), ID_OB, ID_MA, ID_TE, ID_LA, ID_WO, ID_IM, ID_BR, ID_GR); } void BKE_previewimg_deferred_release(PreviewImage *prv) diff --git a/source/blender/blenkernel/intern/object.cc b/source/blender/blenkernel/intern/object.cc index 6006ce88896..84d9002f4d2 100644 --- a/source/blender/blenkernel/intern/object.cc +++ b/source/blender/blenkernel/intern/object.cc @@ -2217,7 +2217,7 @@ Object *BKE_object_add_only_object(Main *bmain, int type, const char *name) } /* We cannot use #BKE_id_new here as we need some custom initialization code. */ - Object *ob = (Object *)BKE_libblock_alloc(bmain, ID_OB, name, 0); + Object *ob = (Object *)BKE_libblock_alloc(bmain, ID_OB, name, bmain ? 0 : LIB_ID_CREATE_NO_MAIN); /* We increase object user count when linking to Collections. */ id_us_min(&ob->id); |