[Bf-blender-cvs] [0427eca2a67] blender2.8: StudioLight: remove caches when removing studiolight

Jeroen Bakker noreply at git.blender.org
Fri Jun 22 12:37:54 CEST 2018


Commit: 0427eca2a6761e1b8a8fd9a44434c2f0e94df75e
Author: Jeroen Bakker
Date:   Fri Jun 22 12:30:27 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB0427eca2a6761e1b8a8fd9a44434c2f0e94df75e

StudioLight: remove caches when removing studiolight

Cache files were not deleted and when uploading a new file with the same
name resulted in using the old cache file.

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

M	release/scripts/startup/bl_operators/wm.py
M	source/blender/makesrna/intern/rna_userdef.c

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

diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py
index b0a5e19d269..4108487b6f5 100644
--- a/release/scripts/startup/bl_operators/wm.py
+++ b/release/scripts/startup/bl_operators/wm.py
@@ -2478,16 +2478,20 @@ class WM_OT_studiolight_uninstall(Operator):
     bl_label = "Uninstall Studio Light"
     index = bpy.props.IntProperty()
 
+    def _remove_path(self, path):
+        if path.exists():
+            path.unlink()
+
     def execute(self, context):
         import pathlib
         userpref = context.user_preferences
         for studio_light in userpref.studio_lights:
             if studio_light.index == self.index:
-                path = pathlib.Path(studio_light.path)
-                if path.exists():
-                    path.unlink()
-                    userpref.studio_lights_refresh()
-                    return {'FINISHED'}
+                self._remove_path(pathlib.Path(studio_light.path))
+                self._remove_path(pathlib.Path(studio_light.path_irr_cache))
+                self._remove_path(pathlib.Path(studio_light.path_sh_cache))
+                userpref.studio_lights_refresh()
+                return {'FINISHED'}
         return {'CANCELLED'}
 
 
diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c
index d6e6eb31dc3..b617d1ba9be 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -692,6 +692,32 @@ static int rna_UserDef_studiolight_path_length(PointerRNA *ptr)
 	return strlen(sl->path);
 }
 
+/* StudioLight.path_irr_cache */
+static void rna_UserDef_studiolight_path_irr_cache_get(PointerRNA *ptr, char *value)
+{
+	StudioLight *sl = (StudioLight *)ptr->data;
+	BLI_strncpy(value, sl->path_irr_cache, FILE_MAX);
+}
+
+static int rna_UserDef_studiolight_path_irr_cache_length(PointerRNA *ptr)
+{
+	StudioLight *sl = (StudioLight *)ptr->data;
+	return strlen(sl->path_irr_cache);
+}
+
+/* StudioLight.path_sh_cache */
+static void rna_UserDef_studiolight_path_sh_cache_get(PointerRNA *ptr, char *value)
+{
+	StudioLight *sl = (StudioLight *)ptr->data;
+	BLI_strncpy(value, sl->path_sh_cache, FILE_MAX);
+}
+
+static int rna_UserDef_studiolight_path_sh_cache_length(PointerRNA *ptr)
+{
+	StudioLight *sl = (StudioLight *)ptr->data;
+	return strlen(sl->path_sh_cache);
+}
+
 /* StudioLight.index */
 static int rna_UserDef_studiolight_index_get(PointerRNA *ptr)
 {
@@ -3270,6 +3296,16 @@ static void rna_def_userdef_studiolight(BlenderRNA *brna)
 	RNA_def_property_ui_text(prop, "Path", "");
 	RNA_def_property_clear_flag(prop, PROP_EDITABLE);
 
+	prop = RNA_def_property(srna, "path_irr_cache", PROP_STRING, PROP_DIRPATH);
+	RNA_def_property_string_funcs(prop, "rna_UserDef_studiolight_path_irr_cache_get", "rna_UserDef_studiolight_path_irr_cache_length", NULL);
+	RNA_def_property_ui_text(prop, "Irradiance Cache Path", "Path where the irradiance cache is stored");
+	RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+
+	prop = RNA_def_property(srna, "path_sh_cache", PROP_STRING, PROP_DIRPATH);
+	RNA_def_property_string_funcs(prop, "rna_UserDef_studiolight_path_sh_cache_get", "rna_UserDef_studiolight_path_sh_cache_length", NULL);
+	RNA_def_property_ui_text(prop, "SH Cache Path", "Path where the spherical harmonics cache is stored");
+	RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+
 	RNA_define_verify_sdna(true);
 
 }



More information about the Bf-blender-cvs mailing list