Commit: ca8e9c881f282f2eb54d811a94b6cb0ff95fd6b1
Author: Jeroen Bakker
Date:   Wed May 16 09:13:48 2018 +0200
Branches: blender2.8
https://developer.blender.org/rBca8e9c881f282f2eb54d811a94b6cb0ff95fd6b1

Workbench: Read studiolights from USER + SYSTEM datafiles

===================================================================

M       source/blender/blenkernel/intern/studiolight.c

===================================================================

diff --git a/source/blender/blenkernel/intern/studiolight.c 
b/source/blender/blenkernel/intern/studiolight.c
index f0db054620a..24dc274cf20 100644
--- a/source/blender/blenkernel/intern/studiolight.c
+++ b/source/blender/blenkernel/intern/studiolight.c
@@ -158,28 +158,11 @@ static void 
studiolight_calculate_diffuse_light(StudioLight *sl)
        sl->flag |= STUDIOLIGHT_DIFFUSE_LIGHT_CALCULATED;
 }
 
-
-/* API */
-void BKE_studiolight_init(void)
+static void studiolight_add_files_from_datafolder(const int folder_id, const 
char* subfolder, int flag)
 {
        StudioLight *sl;
-       /* go over the preset folder and add a studiolight for every image with 
its path */
-       /* order studio lights by name */
-       /* Also reserve icon space for it. */
-       /* Add default studio light */
-       sl = studiolight_create();
-       BLI_strncpy(sl->name, "INTERNAL_01\0", FILE_MAXFILE);
-       sl->flag = STUDIOLIGHT_DIFFUSE_LIGHT_CALCULATED;
-       copy_v3_fl(sl->diffuse_light[STUDIOLIGHT_X_POS], 0.0f);
-       copy_v3_fl(sl->diffuse_light[STUDIOLIGHT_X_NEG], 0.0f);
-       copy_v3_fl(sl->diffuse_light[STUDIOLIGHT_Y_POS], 0.0f);
-       copy_v3_fl(sl->diffuse_light[STUDIOLIGHT_Y_NEG], 0.0f);
-       copy_v3_fl(sl->diffuse_light[STUDIOLIGHT_Z_POS], 1.0f);
-       copy_v3_fl(sl->diffuse_light[STUDIOLIGHT_Z_NEG], 0.0f);
-       BLI_addtail(&studiolights, sl);
-
        struct direntry *dir;
-       const char *folder = BKE_appdir_folder_id(BLENDER_DATAFILES, 
STUDIO_LIGHT_FOLDER);
+       const char *folder = BKE_appdir_folder_id(folder_id, subfolder);
        if (folder) {
                unsigned int totfile = BLI_filelist_dir_contents(folder, &dir);
                int i;
@@ -189,7 +172,7 @@ void BKE_studiolight_init(void)
                                const char *path = dir[i].path;
                                if (BLI_testextensie_n(filename, 
STUDIO_LIGHT_EXTENSIONS, NULL)) {
                                        sl = studiolight_create();
-                                       sl->flag = STUDIOLIGHT_EXTERNAL_FILE;
+                                       sl->flag = STUDIOLIGHT_EXTERNAL_FILE | 
flag;
                                        BLI_strncpy(sl->name, filename, 
FILE_MAXFILE);
                                        BLI_strncpy(sl->path, path, 
FILE_MAXFILE);
                                        BLI_addtail(&studiolights, sl);
@@ -199,6 +182,30 @@ void BKE_studiolight_init(void)
                BLI_filelist_free(dir, totfile);
                dir = NULL;
        }
+
+}
+
+/* API */
+void BKE_studiolight_init(void)
+{
+       StudioLight *sl;
+       /* go over the preset folder and add a studiolight for every image with 
its path */
+       /* order studio lights by name */
+       /* Also reserve icon space for it. */
+       /* Add default studio light */
+       sl = studiolight_create();
+       BLI_strncpy(sl->name, "INTERNAL_01\0", FILE_MAXFILE);
+       sl->flag = STUDIOLIGHT_DIFFUSE_LIGHT_CALCULATED;
+       copy_v3_fl(sl->diffuse_light[STUDIOLIGHT_X_POS], 0.0f);
+       copy_v3_fl(sl->diffuse_light[STUDIOLIGHT_X_NEG], 0.0f);
+       copy_v3_fl(sl->diffuse_light[STUDIOLIGHT_Y_POS], 0.0f);
+       copy_v3_fl(sl->diffuse_light[STUDIOLIGHT_Y_NEG], 0.0f);
+       copy_v3_fl(sl->diffuse_light[STUDIOLIGHT_Z_POS], 1.0f);
+       copy_v3_fl(sl->diffuse_light[STUDIOLIGHT_Z_NEG], 0.0f);
+       BLI_addtail(&studiolights, sl);
+
+       studiolight_add_files_from_datafolder(BLENDER_SYSTEM_DATAFILES, 
STUDIO_LIGHT_FOLDER, 0);
+       studiolight_add_files_from_datafolder(BLENDER_USER_DATAFILES,   
STUDIO_LIGHT_FOLDER, 0);
 }
 
 void BKE_studiolight_free(void)

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to