diff options
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/BKE_studiolight.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/studiolight.c | 26 | ||||
-rw-r--r-- | source/blender/blenloader/intern/versioning_280.c | 2 |
3 files changed, 24 insertions, 6 deletions
diff --git a/source/blender/blenkernel/BKE_studiolight.h b/source/blender/blenkernel/BKE_studiolight.h index 25931e2bbf5..cbaa25d9b3e 100644 --- a/source/blender/blenkernel/BKE_studiolight.h +++ b/source/blender/blenkernel/BKE_studiolight.h @@ -140,7 +140,7 @@ void BKE_studiolight_init(void); void BKE_studiolight_free(void); struct StudioLight *BKE_studiolight_find(const char *name, int flag); struct StudioLight *BKE_studiolight_findindex(int index, int flag); -struct StudioLight *BKE_studiolight_find_first(int flag); +struct StudioLight *BKE_studiolight_find_default(int flag); void BKE_studiolight_preview(uint *icon_buffer, StudioLight *sl, int icon_id_type); struct ListBase *BKE_studiolight_listbase(void); void BKE_studiolight_ensure_flag(StudioLight *sl, int flag); diff --git a/source/blender/blenkernel/intern/studiolight.c b/source/blender/blenkernel/intern/studiolight.c index 070b94e35a9..a52ade025af 100644 --- a/source/blender/blenkernel/intern/studiolight.c +++ b/source/blender/blenkernel/intern/studiolight.c @@ -88,6 +88,9 @@ static const char *STUDIOLIGHT_LIGHTS_FOLDER = "studiolights/studio/"; static const char *STUDIOLIGHT_WORLD_FOLDER = "studiolights/world/"; static const char *STUDIOLIGHT_MATCAP_FOLDER = "studiolights/matcap/"; +static const char *STUDIOLIGHT_WORLD_DEFAULT = "forest.exr"; +static const char *STUDIOLIGHT_MATCAP_DEFAULT = "basic_1.exr"; + /* ITER MACRO */ /** Iter on all pixel giving texel center position and pixel pointer. @@ -1249,8 +1252,23 @@ void BKE_studiolight_free(void) } } -struct StudioLight *BKE_studiolight_find_first(int flag) +struct StudioLight *BKE_studiolight_find_default(int flag) { + const char *default_name = ""; + + if (flag & STUDIOLIGHT_TYPE_WORLD) { + default_name = STUDIOLIGHT_WORLD_DEFAULT; + } + else if (flag & STUDIOLIGHT_TYPE_MATCAP) { + default_name = STUDIOLIGHT_MATCAP_DEFAULT; + } + + LISTBASE_FOREACH(StudioLight *, sl, &studiolights) { + if ((sl->flag & flag) && STREQ(sl->name, default_name)) { + return sl; + } + } + LISTBASE_FOREACH(StudioLight *, sl, &studiolights) { if ((sl->flag & flag)) { return sl; @@ -1268,12 +1286,12 @@ struct StudioLight *BKE_studiolight_find(const char *name, int flag) } else { /* flags do not match, so use default */ - return BKE_studiolight_find_first(flag); + return BKE_studiolight_find_default(flag); } } } /* When not found, use the default studio light */ - return BKE_studiolight_find_first(flag); + return BKE_studiolight_find_default(flag); } struct StudioLight *BKE_studiolight_findindex(int index, int flag) @@ -1284,7 +1302,7 @@ struct StudioLight *BKE_studiolight_findindex(int index, int flag) } } /* When not found, use the default studio light */ - return BKE_studiolight_find_first(flag); + return BKE_studiolight_find_default(flag); } struct ListBase *BKE_studiolight_listbase(void) diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index ab5f1a30d04..f81705a2c61 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -1656,7 +1656,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) } } if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "char", "matcap[256]")) { - StudioLight *default_matcap = BKE_studiolight_find_first(STUDIOLIGHT_TYPE_MATCAP); + StudioLight *default_matcap = BKE_studiolight_find_default(STUDIOLIGHT_TYPE_MATCAP); /* when loading the internal file is loaded before the matcaps */ if (default_matcap) { for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) { |