[Bf-blender-cvs] [b94d8c9] gooseberry: New 'read' flag to toggle reading of the CacheLibrary as a whole.

Lukas Tönne noreply at git.blender.org
Mon Mar 23 13:01:58 CET 2015


Commit: b94d8c93e7437eed881fa69053bf8912c24fdb7c
Author: Lukas Tönne
Date:   Fri Feb 27 17:07:42 2015 +0100
Branches: gooseberry
https://developer.blender.org/rBb94d8c93e7437eed881fa69053bf8912c24fdb7c

New 'read' flag to toggle reading of the CacheLibrary as a whole.

This is also used during the bake process to avoid confusion: The read
flag gets disabled for the baking cachelib, so that objects don't try
to read cache data that is supposed to be generated.

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

M	release/scripts/startup/bl_ui/properties_scene.py
M	source/blender/editors/io/io_cache_library.c
M	source/blender/makesdna/DNA_cache_library_types.h
M	source/blender/makesrna/intern/rna_cache_library.c
M	source/blender/pointcache/PTC_api.cpp

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

diff --git a/release/scripts/startup/bl_ui/properties_scene.py b/release/scripts/startup/bl_ui/properties_scene.py
index a76bd5f..312799b 100644
--- a/release/scripts/startup/bl_ui/properties_scene.py
+++ b/release/scripts/startup/bl_ui/properties_scene.py
@@ -465,7 +465,9 @@ class SCENE_PT_cache_manager(SceneButtonsPanel, Panel):
         col = layout.column(align=True)
         col.label("Archive:")
         col.prop(cachelib, "filepath", text="")
-        col.operator("cachelibrary.bake")
+        row = col.row(align=True)
+        row.prop(cachelib, "read", text="Read", toggle=True)
+        row.operator("cachelibrary.bake")
 
         first = True
         for obcache in cachelib.object_caches:
diff --git a/source/blender/editors/io/io_cache_library.c b/source/blender/editors/io/io_cache_library.c
index 2b4f53d..2118925 100644
--- a/source/blender/editors/io/io_cache_library.c
+++ b/source/blender/editors/io/io_cache_library.c
@@ -269,6 +269,9 @@ static void cache_library_bake_startjob(void *customdata, short *stop, short *do
 	/* XXX how can this be defined properly? */
 	required_mode = eModifierMode_Render;
 	
+	/* disable reading for the duration of the bake process */
+	data->cachelib->flag &= ~CACHE_LIBRARY_READ;
+	
 	data->archive = PTC_cachelib_writers(scene, required_mode, data->cachelib, &data->writers);
 	
 	/* XXX where to get this from? */
@@ -290,6 +293,9 @@ static void cache_library_bake_endjob(void *customdata)
 	
 	PTC_cachelib_writers_free(data->archive, &data->writers);
 	
+	/* enable reading */
+	data->cachelib->flag |= CACHE_LIBRARY_READ;
+	
 	/* reset scene frame */
 	scene->r.cfra = data->origfra;
 	scene->r.framelen = data->origframelen;
diff --git a/source/blender/makesdna/DNA_cache_library_types.h b/source/blender/makesdna/DNA_cache_library_types.h
index b37887d..d31956a 100644
--- a/source/blender/makesdna/DNA_cache_library_types.h
+++ b/source/blender/makesdna/DNA_cache_library_types.h
@@ -64,6 +64,9 @@ typedef enum eCacheItem_Flag {
 typedef struct CacheLibrary {
 	ID id;
 	
+	int flag;
+	int pad;
+	
 	char filepath[1024]; /* 1024 = FILE_MAX */
 	struct Group *group;
 	
@@ -71,5 +74,8 @@ typedef struct CacheLibrary {
 	struct GHash *items_hash;	/* runtime: cached items hash for fast lookup */
 } CacheLibrary;
 
-#endif
+typedef enum eCacheLibrary_Flag {
+	CACHE_LIBRARY_READ              = 1, /* read data from this cache library */
+} eCacheLibrary_Flag;
 
+#endif
diff --git a/source/blender/makesrna/intern/rna_cache_library.c b/source/blender/makesrna/intern/rna_cache_library.c
index 2ee0a83..d42f2f7 100644
--- a/source/blender/makesrna/intern/rna_cache_library.c
+++ b/source/blender/makesrna/intern/rna_cache_library.c
@@ -279,6 +279,11 @@ static void rna_def_cache_library(BlenderRNA *brna)
 	RNA_def_struct_ui_text(srna, "Cache Library", "Cache Library datablock for constructing an archive of caches");
 	RNA_def_struct_ui_icon(srna, ICON_PHYSICS);
 	
+	prop = RNA_def_property(srna, "read", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_sdna(prop, NULL, "flag", CACHE_LIBRARY_READ);
+	RNA_def_property_ui_text(prop, "Read", "Apply stored data from this cache library");
+	RNA_def_property_update(prop, 0, "rna_CacheLibrary_update");
+	
 	prop = RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH);
 	RNA_def_property_string_sdna(prop, NULL, "filepath");
 	RNA_def_property_ui_text(prop, "File Path", "Path to cache library storage");
diff --git a/source/blender/pointcache/PTC_api.cpp b/source/blender/pointcache/PTC_api.cpp
index 61b22e2..bd2a75d 100644
--- a/source/blender/pointcache/PTC_api.cpp
+++ b/source/blender/pointcache/PTC_api.cpp
@@ -216,6 +216,8 @@ PTCReader *PTC_reader_from_rna(Scene *scene, PointerRNA *ptr)
 
 PTCReader *PTC_cachelib_reader_derived_mesh(CacheLibrary *cachelib, PTCReaderArchive *archive, Object *ob)
 {
+	if (!(cachelib->flag & CACHE_LIBRARY_READ))
+		return NULL;
 	CacheItem *item = BKE_cache_library_find_item(cachelib, ob, CACHE_TYPE_DERIVED_MESH, -1);
 	if (item && (item->flag & CACHE_ITEM_ENABLED)) {
 		char name[2*MAX_NAME];
@@ -229,6 +231,8 @@ PTCReader *PTC_cachelib_reader_derived_mesh(CacheLibrary *cachelib, PTCReaderArc
 
 PTCReader *PTC_cachelib_reader_hair_dynamics(CacheLibrary *cachelib, PTCReaderArchive *archive, Object *ob, ParticleSystem *psys)
 {
+	if (!(cachelib->flag & CACHE_LIBRARY_READ))
+		return NULL;
 	if (!(psys && psys->part && psys->part->type == PART_HAIR && psys->clmd))
 		return NULL;
 	
@@ -246,6 +250,8 @@ PTCReader *PTC_cachelib_reader_hair_dynamics(CacheLibrary *cachelib, PTCReaderAr
 
 PTCReader *PTC_cachelib_reader_particles(CacheLibrary *cachelib, PTCReaderArchive *archive, Object *ob, ParticleSystem *psys)
 {
+	if (!(cachelib->flag & CACHE_LIBRARY_READ))
+		return NULL;
 	if (!(psys && psys->part && psys->part->type != PART_HAIR))
 		return NULL;
 	
@@ -263,6 +269,8 @@ PTCReader *PTC_cachelib_reader_particles(CacheLibrary *cachelib, PTCReaderArchiv
 
 PTCReader *PTC_cachelib_reader_particles_pathcache_parents(CacheLibrary *cachelib, PTCReaderArchive *archive, Object *ob, ParticleSystem *psys)
 {
+	if (!(cachelib->flag & CACHE_LIBRARY_READ))
+		return NULL;
 	if (!(psys && psys->part && psys->part->type == PART_HAIR))
 		return NULL;
 	
@@ -280,6 +288,8 @@ PTCReader *PTC_cachelib_reader_particles_pathcache_parents(CacheLibrary *cacheli
 
 PTCReader *PTC_cachelib_reader_particles_pathcache_children(CacheLibrary *cachelib, PTCReaderArchive *archive, Object *ob, ParticleSystem *psys)
 {
+	if (!(cachelib->flag & CACHE_LIBRARY_READ))
+		return NULL;
 	if (!(psys && psys->part && psys->part->type == PART_HAIR))
 		return NULL;
 	
@@ -297,6 +307,9 @@ PTCReader *PTC_cachelib_reader_particles_pathcache_children(CacheLibrary *cachel
 
 PTCReadSampleResult PTC_cachelib_read_sample_derived_mesh(Scene *scene, float frame, CacheLibrary *cachelib, Object *ob, DerivedMesh **r_dm)
 {
+	if (!(cachelib->flag & CACHE_LIBRARY_READ))
+		return PTC_READ_SAMPLE_INVALID;
+	
 	std::string filename = ptc_archive_path(cachelib->filepath, (ID *)cachelib, cachelib->id.lib);
 	PTCReaderArchive *archive = PTC_open_reader_archive(scene, filename.c_str());
 	
@@ -315,6 +328,9 @@ PTCReadSampleResult PTC_cachelib_read_sample_derived_mesh(Scene *scene, float fr
 
 PTCReadSampleResult PTC_cachelib_read_sample_hair_dynamics(Scene *scene, float frame, CacheLibrary *cachelib, Object *ob, ParticleSystem *psys)
 {
+	if (!(cachelib->flag & CACHE_LIBRARY_READ))
+		return PTC_READ_SAMPLE_INVALID;
+	
 	std::string filename = ptc_archive_path(cachelib->filepath, (ID *)cachelib, cachelib->id.lib);
 	PTCReaderArchive *archive = PTC_open_reader_archive(scene, filename.c_str());
 	
@@ -328,6 +344,9 @@ PTCReadSampleResult PTC_cachelib_read_sample_hair_dynamics(Scene *scene, float f
 
 PTCReadSampleResult PTC_cachelib_read_sample_particles(Scene *scene, float frame, CacheLibrary *cachelib, Object *ob, ParticleSystem *psys)
 {
+	if (!(cachelib->flag & CACHE_LIBRARY_READ))
+		return PTC_READ_SAMPLE_INVALID;
+	
 	std::string filename = ptc_archive_path(cachelib->filepath, (ID *)cachelib, cachelib->id.lib);
 	PTCReaderArchive *archive = PTC_open_reader_archive(scene, filename.c_str());
 	
@@ -341,6 +360,9 @@ PTCReadSampleResult PTC_cachelib_read_sample_particles(Scene *scene, float frame
 
 PTCReadSampleResult PTC_cachelib_read_sample_particles_pathcache_parents(Scene *scene, float frame, CacheLibrary *cachelib, Object *ob, ParticleSystem *psys)
 {
+	if (!(cachelib->flag & CACHE_LIBRARY_READ))
+		return PTC_READ_SAMPLE_INVALID;
+	
 	std::string filename = ptc_archive_path(cachelib->filepath, (ID *)cachelib, cachelib->id.lib);
 	PTCReaderArchive *archive = PTC_open_reader_archive(scene, filename.c_str());
 	
@@ -354,6 +376,9 @@ PTCReadSampleResult PTC_cachelib_read_sample_particles_pathcache_parents(Scene *
 
 PTCReadSampleResult PTC_cachelib_read_sample_particles_pathcache_children(Scene *scene, float frame, CacheLibrary *cachelib, Object *ob, ParticleSystem *psys)
 {
+	if (!(cachelib->flag & CACHE_LIBRARY_READ))
+		return PTC_READ_SAMPLE_INVALID;
+	
 	std::string filename = ptc_archive_path(cachelib->filepath, (ID *)cachelib, cachelib->id.lib);
 	PTCReaderArchive *archive = PTC_open_reader_archive(scene, filename.c_str());




More information about the Bf-blender-cvs mailing list