diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/intern/icons.cc | 30 | ||||
-rw-r--r-- | source/blender/editors/include/ED_render.h | 2 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_icons.c | 5 | ||||
-rw-r--r-- | source/blender/editors/render/render_preview.c | 25 |
4 files changed, 39 insertions, 23 deletions
diff --git a/source/blender/blenkernel/intern/icons.cc b/source/blender/blenkernel/intern/icons.cc index f820b345c59..9cf289935ab 100644 --- a/source/blender/blenkernel/intern/icons.cc +++ b/source/blender/blenkernel/intern/icons.cc @@ -359,30 +359,22 @@ void BKE_previewimg_id_copy(ID *new_id, const ID *old_id) PreviewImage **BKE_previewimg_id_get_p(const ID *id) { switch (GS(id->name)) { - case ID_OB: { - Object *ob = (Object *)id; - /* Currently, only object types with real geometry can be rendered as preview. */ - if (!OB_TYPE_IS_GEOMETRY(ob->type)) { - return nullptr; - } - return &ob->preview; - } - #define ID_PRV_CASE(id_code, id_struct) \ case id_code: { \ return &((id_struct *)id)->preview; \ } \ ((void)0) - ID_PRV_CASE(ID_MA, Material); - ID_PRV_CASE(ID_TE, Tex); - ID_PRV_CASE(ID_WO, World); - ID_PRV_CASE(ID_LA, Light); - ID_PRV_CASE(ID_IM, Image); - ID_PRV_CASE(ID_BR, Brush); - ID_PRV_CASE(ID_GR, Collection); - ID_PRV_CASE(ID_SCE, Scene); - ID_PRV_CASE(ID_SCR, bScreen); - ID_PRV_CASE(ID_AC, bAction); + ID_PRV_CASE(ID_OB, Object); + ID_PRV_CASE(ID_MA, Material); + ID_PRV_CASE(ID_TE, Tex); + ID_PRV_CASE(ID_WO, World); + ID_PRV_CASE(ID_LA, Light); + ID_PRV_CASE(ID_IM, Image); + ID_PRV_CASE(ID_BR, Brush); + 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/editors/include/ED_render.h b/source/blender/editors/include/ED_render.h index 5cdcbbab42a..2d042b8b0e3 100644 --- a/source/blender/editors/include/ED_render.h +++ b/source/blender/editors/include/ED_render.h @@ -82,6 +82,8 @@ typedef enum ePreviewRenderMethod { void ED_preview_ensure_dbase(void); void ED_preview_free_dbase(void); +bool ED_preview_id_is_supported(const struct ID *id); + void ED_preview_shader_job(const struct bContext *C, void *owner, struct ID *id, diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index d0a7716b4dd..c335632faae 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -2037,11 +2037,14 @@ void UI_icon_render_id( const bContext *C, Scene *scene, ID *id, const enum eIconSizes size, const bool use_job) { PreviewImage *pi = BKE_previewimg_id_ensure(id); - if (pi == NULL) { return; } + if (!ED_preview_id_is_supported(id)) { + return; + } + ui_id_preview_image_render_size(C, scene, id, pi, size, use_job); } diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c index 4bf250b9d4f..0cc944436b2 100644 --- a/source/blender/editors/render/render_preview.c +++ b/source/blender/editors/render/render_preview.c @@ -786,6 +786,11 @@ struct ObjectPreviewData { int sizey; }; +static bool object_preview_is_type_supported(const Object *ob) +{ + return OB_TYPE_IS_GEOMETRY(ob->type); +} + static Object *object_preview_camera_create(Main *preview_main, ViewLayer *view_layer, Object *preview_object) @@ -1658,9 +1663,12 @@ static void icon_preview_startjob_all_sizes(void *customdata, if (ip->id != NULL) { switch (GS(ip->id->name)) { case ID_OB: - /* Much simpler than the ShaderPreview mess used for other ID types. */ - object_preview_render(ip, cur_size); - continue; + if (object_preview_is_type_supported((Object *)ip->id)) { + /* Much simpler than the ShaderPreview mess used for other ID types. */ + object_preview_render(ip, cur_size); + continue; + } + break; case ID_AC: action_preview_render(ip, cur_size); continue; @@ -1749,6 +1757,17 @@ static void icon_preview_free(void *customdata) MEM_freeN(ip); } +/** + * Check if \a id is supported by the automatic preview render. + */ +bool ED_preview_id_is_supported(const ID *id) +{ + if (GS(id->name) == ID_OB) { + return object_preview_is_type_supported((const Object *)id); + } + return BKE_previewimg_id_get_p(id) != NULL; +} + void ED_preview_icon_render( const bContext *C, Scene *scene, ID *id, uint *rect, int sizex, int sizey) { |