[Bf-blender-cvs] [fc1d50f] alembic: Reorganization of file paths and input/output workflow in cache libraries.

Lukas Tönne noreply at git.blender.org
Tue Mar 31 10:40:32 CEST 2015


Commit: fc1d50f1e7eeeb5fbcb75d1c9c60027374effb23
Author: Lukas Tönne
Date:   Tue Mar 31 10:33:33 2015 +0200
Branches: alembic
https://developer.blender.org/rBfc1d50f1e7eeeb5fbcb75d1c9c60027374effb23

Reorganization of file paths and input/output workflow in cache
libraries.

Having a cache archive output in each modifier is not really practical.

Now the cache library has at most 2 file paths. These are used based on
2 associated settings: source mode/path and display mode/path.

* The SOURCE mode determines whether the original scene data is used as
input or a cache archive. If the scene input is used the dupli group
objects will be evaluated as usual with Mesh data, modifiers, proxy
armatures, etc.. With cache input the data stored in a cache is used to
override the scene data instead.
* The DISPLAY mode is essentially a toggle for the whole cache modifier
stack. If it is set to 'source' the respective source data is used
without further modification. If set to 'result' the data from the
output cache archive is used, which can be generated using the bake
operator. During baking the data will be passed through the cache
modifiers to create a variation of the original source data.

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

M	intern/cycles/blender/blender_mesh.cpp
M	release/scripts/startup/bl_ui/properties_object.py
M	source/blender/blenkernel/BKE_cache_library.h
M	source/blender/blenkernel/intern/cache_library.c
M	source/blender/blenkernel/intern/depsgraph.c
M	source/blender/blenkernel/intern/object_dupli.c
M	source/blender/editors/io/io_cache_library.c
M	source/blender/makesdna/DNA_cache_library_types.h
M	source/blender/makesdna/DNA_object_types.h
M	source/blender/makesrna/intern/rna_cache_library.c
M	source/blender/makesrna/intern/rna_main_api.c
M	source/blender/makesrna/intern/rna_object.c

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

diff --git a/intern/cycles/blender/blender_mesh.cpp b/intern/cycles/blender/blender_mesh.cpp
index 787e009..171bcf8 100644
--- a/intern/cycles/blender/blender_mesh.cpp
+++ b/intern/cycles/blender/blender_mesh.cpp
@@ -626,7 +626,10 @@ Mesh *BlenderSync::sync_mesh(BL::Object b_parent, bool object_updated, bool hide
 	Mesh *mesh;
 
 	bool need_update;
-	bool use_dupli_override = b_dupli_ob && b_parent.cache_library() && b_parent.use_dupli_cache_read();
+	BL::CacheLibrary b_cachelib = b_parent.cache_library();
+	bool use_dupli_override = b_dupli_ob && b_cachelib &&
+	                          (b_cachelib.source_mode() == BL::CacheLibrary::source_mode_CACHE ||
+	                           b_cachelib.display_mode() == BL::CacheLibrary::display_mode_RESULT);
 	if (use_dupli_override) {
 		/* if a dupli override (cached data) is used, identify the mesh by object and parent together,
 		 * so that individual per-dupli overrides are possible.
diff --git a/release/scripts/startup/bl_ui/properties_object.py b/release/scripts/startup/bl_ui/properties_object.py
index 4830f52..b767492 100644
--- a/release/scripts/startup/bl_ui/properties_object.py
+++ b/release/scripts/startup/bl_ui/properties_object.py
@@ -319,31 +319,41 @@ class OBJECT_PT_duplication(ObjectButtonsPanel, Panel):
         row.prop(md, "name", text="")
         row.operator("cachelibrary.remove_modifier", icon='X', text="", emboss=False)
 
-        col = layout.column(align=True)
-        col.prop(md, "filepath")
-        col.operator("cachelibrary.bake", text="Bake")
-
         # match enum type to our functions, avoids a lookup table.
         getattr(self, md.type)(layout, cachelib, md)
 
     def draw_cachelib(self, context, layout, ob, cachelib, objects):
-        col = layout.column(align=True)
-        colrow = col.row(align=True)
-        colrow.label("Archive:")
-        props = colrow.operator("cachelibrary.archive_info", text="", icon='QUESTION')
+        col = layout.column()
+        row = col.row()
+        row.label("Source:")
+        row.prop(cachelib, "source_mode", text="Source", expand=True)
+        row = col.row(align=True)
+        row.enabled = (cachelib.source_mode == 'CACHE')
+        row.prop(cachelib, "input_filepath", text="")
+        props = row.operator("cachelibrary.archive_info", text="", icon='QUESTION')
+        props.filepath = cachelib.input_filepath
         props.use_stdout = True
         props.use_popup = True
         props.use_clipboard = True
-        col.prop(cachelib, "filepath", text="")
 
+        layout.separator()
+
+        col = layout.column()
+        row = col.row()
+        row.label("Display:")
+        row.prop(cachelib, "display_mode", expand=True)
         row = col.row(align=True)
-        row.prop(ob, "use_dupli_cache_read", text="Read", toggle=True)
-        row.prop(ob, "use_dupli_cache_write", text="Write", toggle=True)
+        row.enabled = (cachelib.display_mode == 'RESULT')
+        row.prop(cachelib, "output_filepath", text="")
+        props = row.operator("cachelibrary.archive_info", text="", icon='QUESTION')
+        props.filepath = cachelib.output_filepath
+        props.use_stdout = True
+        props.use_popup = True
+        props.use_clipboard = True
+
         col.operator("cachelibrary.bake")
-        row = col.row()
-        row.prop(cachelib, "eval_mode", toggle=True, expand=True)
-        row = col.row()
-        row.prop(cachelib, "data_types", icon_only=True, toggle=True)
+        col.row().prop(cachelib, "eval_mode", toggle=True, expand=True)
+        col.row().prop(cachelib, "data_types", icon_only=True, toggle=True)
 
         row = layout.row(align=True)
         row.label("Filter:")
diff --git a/source/blender/blenkernel/BKE_cache_library.h b/source/blender/blenkernel/BKE_cache_library.h
index fb808de..f14ffa8 100644
--- a/source/blender/blenkernel/BKE_cache_library.h
+++ b/source/blender/blenkernel/BKE_cache_library.h
@@ -76,8 +76,10 @@ bool BKE_cache_library_validate_item(struct CacheLibrary *cachelib, struct Objec
 
 /* ========================================================================= */
 
-bool BKE_cache_archive_path_test(struct CacheLibrary *cachelib, struct CacheModifier *md);
-void BKE_cache_archive_path(struct CacheLibrary *cachelib, struct CacheModifier *md, char *result, int max);
+bool BKE_cache_archive_path_test(struct CacheLibrary *cachelib, const char *path);
+void BKE_cache_archive_path_ex(const char *path, struct Library *lib, const char *default_filename, char *result, int max);
+void BKE_cache_archive_input_path(struct CacheLibrary *cachelib, char *result, int max);
+void BKE_cache_archive_output_path(struct CacheLibrary *cachelib, char *result, int max);
 
 void BKE_cache_library_dag_recalc_tag(struct EvaluationContext *eval_ctx, struct Main *bmain);
 
diff --git a/source/blender/blenkernel/intern/cache_library.c b/source/blender/blenkernel/intern/cache_library.c
index 4f9452a..54e6a0f 100644
--- a/source/blender/blenkernel/intern/cache_library.c
+++ b/source/blender/blenkernel/intern/cache_library.c
@@ -72,8 +72,10 @@ CacheLibrary *BKE_cache_library_add(Main *bmain, const char *name)
 
 	BLI_strncpy(basename, cachelib->id.name+2, sizeof(basename));
 	BLI_filename_make_safe(basename);
-	BLI_snprintf(cachelib->filepath, sizeof(cachelib->filepath), "//cache/%s.%s", basename, PTC_get_default_archive_extension());
+	BLI_snprintf(cachelib->output_filepath, sizeof(cachelib->output_filepath), "//cache/%s.%s", basename, PTC_get_default_archive_extension());
 
+	cachelib->source_mode = CACHE_LIBRARY_SOURCE_SCENE;
+	cachelib->display_mode = CACHE_LIBRARY_DISPLAY_RESULT;
 	cachelib->eval_mode = CACHE_LIBRARY_EVAL_REALTIME | CACHE_LIBRARY_EVAL_RENDER;
 
 	/* cache everything by default */
@@ -272,10 +274,8 @@ BLI_INLINE bool path_is_dirpath(const char *path)
 	return *(BLI_last_slash(path) + 1) == '\0';
 }
 
-bool BKE_cache_archive_path_test(CacheLibrary *cachelib, CacheModifier *cachemd)
+bool BKE_cache_archive_path_test(CacheLibrary *cachelib, const char *path)
 {
-	const char *path = cachemd ? cachemd->filepath : cachelib->filepath;
-	
 	if (BLI_path_is_rel(path)) {
 		if (!(G.relbase_valid || cachelib->id.lib))
 			return false;
@@ -285,7 +285,7 @@ bool BKE_cache_archive_path_test(CacheLibrary *cachelib, CacheModifier *cachemd)
 	
 }
 
-static void cache_archive_path_ex(const char *path, Library *lib, char *result, int max, const char *default_filename)
+void BKE_cache_archive_path_ex(const char *path, Library *lib, const char *default_filename, char *result, int max)
 {
 	char abspath[FILE_MAX];
 	
@@ -307,47 +307,34 @@ static void cache_archive_path_ex(const char *path, Library *lib, char *result,
 		BLI_strncpy(abspath, path, sizeof(abspath));
 	}
 	
-	if (abspath[0] == '\0') {
-		result[0] = '\0';
-	}
-	else if (path_is_dirpath(abspath) || BLI_is_dir(abspath)) {
-		BLI_join_dirfile(result, max, abspath, default_filename);
-	}
-	else {
-		BLI_strncpy(result, abspath, max);
+	if (abspath[0] != '\0') {
+		if (path_is_dirpath(abspath) || BLI_is_dir(abspath)) {
+			if (default_filename && default_filename[0] != '\0')
+				BLI_join_dirfile(result, max, abspath, default_filename);
+		}
+		else {
+			BLI_strncpy(result, abspath, max);
+		}
 	}
 }
 
-void BKE_cache_archive_path(CacheLibrary *cachelib, CacheModifier *cachemd, char *result, int max)
+void BKE_cache_archive_input_path(CacheLibrary *cachelib, char *result, int max)
 {
-	if (cachemd)
-		cache_archive_path_ex(cachemd->filepath, cachelib->id.lib, result, max, cachemd->name);
-	else
-		cache_archive_path_ex(cachelib->filepath, cachelib->id.lib, result, max, cachelib->id.name+2);
+	BKE_cache_archive_path_ex(cachelib->input_filepath, cachelib->id.lib, NULL, result, max);
+}
+
+void BKE_cache_archive_output_path(CacheLibrary *cachelib, char *result, int max)
+{
+	BKE_cache_archive_path_ex(cachelib->output_filepath, cachelib->id.lib, cachelib->id.name+2, result, max);
 }
 
 
 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(cachelib, md, 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, NULL, filename, sizeof(filename));
-	archive = PTC_open_reader_archive(scene, filename);
-	if (archive)
-		return archive;
 	
-	return NULL;
+	BKE_cache_archive_input_path(cachelib, filename, sizeof(filename));
+	return PTC_open_reader_archive(scene, filename);
 }
 
 bool BKE_cache_read_dupli_cache(Scene *scene, float frame, eCacheLibrary_EvalMode eval_mode,
@@ -694,7 +681,7 @@ static void hairsim_bake(HairSimCacheModifier *hsmd, CacheLibrary *cachelib, Cac
 	
 	scene->r.framelen = 1.0f;
 	
-	BKE_cache_archive_path(cachelib, &hsmd->modifier, filename, sizeof(filename));
+	BKE_cache_archive_output_path(cachelib, filename, sizeof(filename));
 	archive = PTC_open_writer_archive(scene, filename);
 	
 	if (archive) {
diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c
index 378663f..cc0da53 100644
--- a/source/blender/blenkernel/intern/depsgraph.c
+++ b/source/blender/blenkernel/intern/depsgraph.c
@@ -45,6 +45,7 @@
 #include "BLI_threads.h"
 
 #include "DNA_anim_types.h"
+#include "DNA_cache_library_types.h"
 #include "DNA_camera_types.h"
 #include "DNA_group_types.h"
 #include "DNA_lamp_types.h"
@@ -625,8 +626,9 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Main *bmain, Sc
 	 * when the duplicator is visible (even if group objects are not visible themselves).
 	 * It is not a true dependency, the duplicator does not in any way depend on group objects or data!
 	 */
-	if (ob->transflag & OB_DUPLI && !(ob->transflag & OB_DUPLI_READ_CACHE)) {
-		if ((ob->transflag & OB_DUPLIGROUP) && ob->dup_group) {
+	if (ob->transflag & OB_DUPLI) {
+		bool is_cached = ob->cache_library && ob->cache_library->source_mode == CACHE_LIBRARY_SOURCE_CACHE;
+		if (!is_cached &

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list