Fix [#22199] Cloth Cache Panel > Disk Cache doesn't work
Condition for this to work (.blend file must be saved) was poorly communicated in the UI (printfs are no good for this - ideally should use reports). Tweaked this a bit.
This commit is contained in:
		@@ -20,6 +20,7 @@
 | 
			
		||||
 | 
			
		||||
narrowui = 180
 | 
			
		||||
 | 
			
		||||
import bpy
 | 
			
		||||
 | 
			
		||||
def point_cache_ui(self, context, cache, enabled, particles, smoke):
 | 
			
		||||
    layout = self.layout
 | 
			
		||||
@@ -67,7 +68,10 @@ def point_cache_ui(self, context, cache, enabled, particles, smoke):
 | 
			
		||||
            sub = col.column()
 | 
			
		||||
            sub.enabled = enabled
 | 
			
		||||
            sub.prop(cache, "quick_cache")
 | 
			
		||||
            col.prop(cache, "disk_cache")
 | 
			
		||||
            
 | 
			
		||||
            sub = col.column()
 | 
			
		||||
            sub.enabled = bpy.data.file_is_saved
 | 
			
		||||
            sub.prop(cache, "disk_cache")
 | 
			
		||||
            col.label(text=cache.info)
 | 
			
		||||
 | 
			
		||||
        
 | 
			
		||||
 
 | 
			
		||||
@@ -2652,6 +2652,7 @@ void BKE_ptcache_mem_to_disk(PTCacheID *pid)
 | 
			
		||||
			ptcache_file_init_pointers(pf);
 | 
			
		||||
 | 
			
		||||
			if(!ptcache_file_write_header_begin(pf) || !pid->write_header(pf)) {
 | 
			
		||||
				if (G.f & G_DEBUG) 
 | 
			
		||||
					printf("Error writing to disk cache\n");
 | 
			
		||||
				cache->flag &= ~PTCACHE_DISK_CACHE;
 | 
			
		||||
 | 
			
		||||
@@ -2662,6 +2663,7 @@ void BKE_ptcache_mem_to_disk(PTCacheID *pid)
 | 
			
		||||
			for(i=0; i<pm->totpoint; i++) {
 | 
			
		||||
				ptcache_copy_data(pm->cur, pf->cur);
 | 
			
		||||
				if(!ptcache_file_write_data(pf)) {
 | 
			
		||||
					if (G.f & G_DEBUG) 
 | 
			
		||||
						printf("Error writing to disk cache\n");
 | 
			
		||||
					cache->flag &= ~PTCACHE_DISK_CACHE;
 | 
			
		||||
 | 
			
		||||
@@ -2678,6 +2680,7 @@ void BKE_ptcache_mem_to_disk(PTCacheID *pid)
 | 
			
		||||
				BKE_ptcache_write_cache(pid, 0);
 | 
			
		||||
		}
 | 
			
		||||
		else
 | 
			
		||||
			if (G.f & G_DEBUG) 
 | 
			
		||||
				printf("Error creating disk cache file\n");
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@@ -2688,6 +2691,7 @@ void BKE_ptcache_toggle_disk_cache(PTCacheID *pid)
 | 
			
		||||
 | 
			
		||||
	if (!G.relbase_valid){
 | 
			
		||||
		cache->flag &= ~PTCACHE_DISK_CACHE;
 | 
			
		||||
		if (G.f & G_DEBUG) 
 | 
			
		||||
			printf("File must be saved before using disk cache!\n");
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
@@ -50,6 +50,10 @@ static void rna_Main_debug_set(PointerRNA *ptr, const int value)
 | 
			
		||||
		G.f &= ~G_DEBUG;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int rna_Main_fileissaved_get(PointerRNA *ptr)
 | 
			
		||||
{
 | 
			
		||||
	return G.relbase_valid;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void rna_Main_filename_get(PointerRNA *ptr, char *value)
 | 
			
		||||
{
 | 
			
		||||
@@ -309,6 +313,11 @@ void RNA_def_main(BlenderRNA *brna)
 | 
			
		||||
	RNA_def_property_clear_flag(prop, PROP_EDITABLE);
 | 
			
		||||
	RNA_def_property_ui_text(prop, "Filename", "Path to the .blend file");
 | 
			
		||||
	
 | 
			
		||||
	prop= RNA_def_property(srna, "file_is_saved", PROP_BOOLEAN, PROP_NONE);
 | 
			
		||||
	RNA_def_property_clear_flag(prop, PROP_EDITABLE);
 | 
			
		||||
	RNA_def_property_boolean_funcs(prop, "rna_Main_fileissaved_get", NULL);
 | 
			
		||||
	RNA_def_property_ui_text(prop, "File is Saved", "Has the current session been saved to disk as a .blend file");
 | 
			
		||||
 | 
			
		||||
	prop= RNA_def_property(srna, "debug", PROP_BOOLEAN, PROP_NONE);
 | 
			
		||||
	RNA_def_property_boolean_funcs(prop, "rna_Main_debug_get", "rna_Main_debug_set");
 | 
			
		||||
	RNA_def_property_ui_text(prop, "Debug", "Print debugging information in console");
 | 
			
		||||
 
 | 
			
		||||
@@ -709,7 +709,7 @@ static void rna_def_pointcache(BlenderRNA *brna)
 | 
			
		||||
 | 
			
		||||
	prop= RNA_def_property(srna, "disk_cache", PROP_BOOLEAN, PROP_NONE);
 | 
			
		||||
	RNA_def_property_boolean_sdna(prop, NULL, "flag", PTCACHE_DISK_CACHE);
 | 
			
		||||
	RNA_def_property_ui_text(prop, "Disk Cache", "Save cache files to disk");
 | 
			
		||||
	RNA_def_property_ui_text(prop, "Disk Cache", "Save cache files to disk (.blend file must be saved first)");
 | 
			
		||||
	RNA_def_property_update(prop, NC_OBJECT, "rna_Cache_toggle_disk_cache");
 | 
			
		||||
 | 
			
		||||
	prop= RNA_def_property(srna, "outdated", PROP_BOOLEAN, PROP_NONE);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user