[Bf-blender-cvs] [e9df0e5] alembic: Use the last valid cache modifier output file for reading into the dupli cache.
Lukas Tönne
noreply at git.blender.org
Fri Mar 27 11:22:07 CET 2015
Commit: e9df0e53d1dbc60c071e9de9b5ab99c705db7bb2
Author: Lukas Tönne
Date: Fri Mar 27 11:19:00 2015 +0100
Branches: alembic
https://developer.blender.org/rBe9df0e53d1dbc60c071e9de9b5ab99c705db7bb2
Use the last valid cache modifier output file for reading into the
dupli cache.
This makes the cache modifier stack work more like actual modifiers:
Each will take the previous result and write it into its own output
file. The last output is the final result used for viewport display.
===================================================================
M release/scripts/startup/bl_ui/properties_object.py
M source/blender/blenkernel/intern/cache_library.c
M source/blender/makesdna/DNA_cache_library_types.h
M source/blender/makesrna/intern/rna_cache_library.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/properties_object.py b/release/scripts/startup/bl_ui/properties_object.py
index 8fd90b9..b0a33b5 100644
--- a/release/scripts/startup/bl_ui/properties_object.py
+++ b/release/scripts/startup/bl_ui/properties_object.py
@@ -332,6 +332,9 @@ class OBJECT_PT_duplication(ObjectButtonsPanel, Panel):
row.prop(md, "name", text="")
row.operator("cachelibrary.remove_modifier", icon='X', text="", emboss=False)
+ row = layout.row()
+ row.prop(md, "filepath")
+
# match enum type to our functions, avoids a lookup table.
getattr(self, md.type)(layout, cachelib, md)
diff --git a/source/blender/blenkernel/intern/cache_library.c b/source/blender/blenkernel/intern/cache_library.c
index 90f7081..fc078cd 100644
--- a/source/blender/blenkernel/intern/cache_library.c
+++ b/source/blender/blenkernel/intern/cache_library.c
@@ -655,7 +655,10 @@ void BKE_cache_archive_path(const char *path, ID *id, Library *lib, char *result
BLI_strncpy(abspath, path, sizeof(abspath));
}
- if (path_is_dirpath(abspath) || BLI_is_dir(abspath)) {
+ if (abspath[0] == '\0') {
+ result[0] = '\0';
+ }
+ else if (path_is_dirpath(abspath) || BLI_is_dir(abspath)) {
BLI_join_dirfile(result, max, abspath, id ? id->name+2 : default_filename);
}
else {
@@ -664,28 +667,49 @@ void BKE_cache_archive_path(const char *path, ID *id, Library *lib, char *result
}
+static struct PTCReaderArchive *find_active_cache(Scene *scene, CacheLibrary *cachelib)
+{
+ struct PTCReaderArchive *archive = NULL;
+ char filename[FILE_MAX];
+ CacheModifier *md;
+
+ /* look for last valid modifier output */
+ for (md = cachelib->modifiers.last; md; md = md->prev) {
+ BKE_cache_archive_path(md->filepath, (ID *)cachelib, cachelib->id.lib, filename, sizeof(filename));
+ archive = PTC_open_reader_archive(scene, filename);
+ if (archive)
+ return archive;
+ }
+
+ /* if no modifier has a valid output, try the base cache */
+ BKE_cache_archive_path(cachelib->filepath, (ID *)cachelib, cachelib->id.lib, filename, sizeof(filename));
+ archive = PTC_open_reader_archive(scene, filename);
+ if (archive)
+ return archive;
+
+ return NULL;
+}
+
bool BKE_cache_read_dupli_cache(Scene *scene, float frame, eCacheLibrary_EvalMode eval_mode,
struct Group *dupgroup, struct DupliCache *dupcache, CacheLibrary *cachelib)
{
- char filename[FILE_MAX];
struct PTCReaderArchive *archive;
struct PTCReader *reader;
- eCacheReadSampleResult result;
+ /*eCacheReadSampleResult result;*/ /* unused */
if (!dupcache || !dupgroup || !cachelib)
return false;
if (!(cachelib->eval_mode & eval_mode))
return false;
- BKE_cache_archive_path(cachelib->filepath, (ID *)cachelib, cachelib->id.lib, filename, sizeof(filename));
- archive = PTC_open_reader_archive(scene, filename);
+ archive = find_active_cache(scene, cachelib);
if (!archive)
return false;
reader = PTC_reader_duplicache(dupgroup->id.name, dupgroup, dupcache);
PTC_reader_init(reader, archive);
- result = BKE_cache_read_result(PTC_read_sample(reader, frame));
+ /*result = */BKE_cache_read_result(PTC_read_sample(reader, frame));
PTC_reader_free(reader);
PTC_close_reader_archive(archive);
@@ -696,18 +720,16 @@ bool BKE_cache_read_dupli_cache(Scene *scene, float frame, eCacheLibrary_EvalMod
bool BKE_cache_read_dupli_object(Scene *scene, float frame, eCacheLibrary_EvalMode eval_mode,
struct Object *ob, struct DupliObjectData *data, CacheLibrary *cachelib)
{
- char filename[FILE_MAX];
struct PTCReaderArchive *archive;
struct PTCReader *reader;
- eCacheReadSampleResult result;
+ /*eCacheReadSampleResult result;*/ /* unused */
if (!data || !ob || !cachelib)
return false;
if (!(cachelib->eval_mode & eval_mode))
return false;
- BKE_cache_archive_path(cachelib->filepath, (ID *)cachelib, cachelib->id.lib, filename, sizeof(filename));
- archive = PTC_open_reader_archive(scene, filename);
+ archive = find_active_cache(scene, cachelib);
if (!archive)
return false;
@@ -716,7 +738,7 @@ bool BKE_cache_read_dupli_object(Scene *scene, float frame, eCacheLibrary_EvalMo
reader = PTC_reader_duplicache_object(ob->id.name, ob, data);
PTC_reader_init(reader, archive);
- result = BKE_cache_read_result(PTC_read_sample(reader, frame));
+ /*result = */BKE_cache_read_result(PTC_read_sample(reader, frame));
PTC_reader_free(reader);
PTC_close_reader_archive(archive);
diff --git a/source/blender/makesdna/DNA_cache_library_types.h b/source/blender/makesdna/DNA_cache_library_types.h
index a05e013..3a816e9 100644
--- a/source/blender/makesdna/DNA_cache_library_types.h
+++ b/source/blender/makesdna/DNA_cache_library_types.h
@@ -103,7 +103,7 @@ typedef struct CacheModifier {
int flag;
char name[64]; /* MAX_NAME */
- char output_filepath[1024];
+ char filepath[1024];
} CacheModifier;
typedef enum eCacheModifier_Type {
diff --git a/source/blender/makesrna/intern/rna_cache_library.c b/source/blender/makesrna/intern/rna_cache_library.c
index e2f2c5d..42634a7 100644
--- a/source/blender/makesrna/intern/rna_cache_library.c
+++ b/source/blender/makesrna/intern/rna_cache_library.c
@@ -357,6 +357,11 @@ static void rna_def_cache_modifier(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Name", "Modifier name");
RNA_def_property_update(prop, NC_ID | NA_RENAME, NULL);
RNA_def_struct_name_property(srna, prop);
+
+ 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 modifier output storage");
+ RNA_def_property_update(prop, 0, "rna_CacheLibrary_update");
}
static void rna_def_cache_library_modifiers(BlenderRNA *brna, PropertyRNA *cprop)
More information about the Bf-blender-cvs
mailing list