Assets/IDs: Don't generate previews for object types with no real geometry
Object types like empties, cameras or lamps will just end up as empty preview images. We can think about ways to visualize them still, but meanwhile, don't create such an empty preview. Differential Revision: https://developer.blender.org/D10334 Reviewed by: Bastien Montagne, Sybren Stüvel
This commit is contained in:
@@ -359,22 +359,30 @@ 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 NULL;
|
||||
}
|
||||
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_OB, Object);
|
||||
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_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;
|
||||
|
||||
@@ -501,6 +501,9 @@ enum {
|
||||
/* check if the object type supports materials */
|
||||
#define OB_TYPE_SUPPORT_MATERIAL(_type) \
|
||||
(((_type) >= OB_MESH && (_type) <= OB_MBALL) || ((_type) >= OB_GPENCIL && (_type) <= OB_VOLUME))
|
||||
/** Does the object have some render-able geometry (unlike empties, cameras, etc.). */
|
||||
#define OB_TYPE_IS_GEOMETRY(_type) \
|
||||
(ELEM(_type, OB_MESH, OB_SURF, OB_FONT, OB_MBALL, OB_GPENCIL, OB_HAIR, OB_POINTCLOUD, OB_VOLUME))
|
||||
#define OB_TYPE_SUPPORT_VGROUP(_type) (ELEM(_type, OB_MESH, OB_LATTICE, OB_GPENCIL))
|
||||
#define OB_TYPE_SUPPORT_EDITMODE(_type) \
|
||||
(ELEM(_type, OB_MESH, OB_FONT, OB_CURVE, OB_SURF, OB_MBALL, OB_LATTICE, OB_ARMATURE))
|
||||
|
||||
Reference in New Issue
Block a user