[Bf-blender-cvs] [6f7b613] alembic_pointcache: Use a new flag in duplicator objects to enable cache reading and avoid unnecessary dependencies.

Lukas Tönne noreply at git.blender.org
Tue Mar 17 16:21:05 CET 2015


Commit: 6f7b613715bc3f0628995905c7d59c65056eba0e
Author: Lukas Tönne
Date:   Tue Mar 17 16:17:04 2015 +0100
Branches: alembic_pointcache
https://developer.blender.org/rB6f7b613715bc3f0628995905c7d59c65056eba0e

Use a new flag in duplicator objects to enable cache reading and avoid
unnecessary dependencies.

This flag will replace the current "read" mode on cache libraries.

Beside enabling cache reading, it also disables the current "fake"
dependencies between duplicators and their group objects. This is
exploiting the layer visibility mechanism in depsgraph to ensure that
animated group objects get evaluated when used by a visible duplicator,
even when they are not themselves visible. These dependencies cause
group object updates even if the duplicator is using cached results.
To avoid this unnecessary overhead and make caching worthwhile we
rebuild depsgraph without these relations when using the cache instead.

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

M	release/scripts/startup/bl_ui/properties_object.py
M	source/blender/blenkernel/intern/depsgraph.c
M	source/blender/blenkernel/intern/object_dupli.c
M	source/blender/makesdna/DNA_object_types.h
M	source/blender/makesrna/intern/rna_object.c

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

diff --git a/release/scripts/startup/bl_ui/properties_object.py b/release/scripts/startup/bl_ui/properties_object.py
index 15c25a7..5a14052 100644
--- a/release/scripts/startup/bl_ui/properties_object.py
+++ b/release/scripts/startup/bl_ui/properties_object.py
@@ -294,6 +294,7 @@ class OBJECT_PT_duplication(ObjectButtonsPanel, Panel):
 
         elif ob.dupli_type == 'GROUP':
             layout.prop(ob, "dupli_group", text="Group")
+            layout.prop(ob, "use_dupli_cache")
             layout.operator("cachelibrary.rebuild_dupligroup")
 
 
diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c
index c9b906e..b35d070 100644
--- a/source/blender/blenkernel/intern/depsgraph.c
+++ b/source/blender/blenkernel/intern/depsgraph.c
@@ -620,7 +620,12 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Main *bmain, Sc
 		/* inverted relation, so addtoroot shouldn't be set to zero */
 	}
 	
-	if (ob->transflag & OB_DUPLI) {
+	/* XXX Fake dependency: duplicator object becomes a child of group objects.
+	 * This exploits the layer visibility mechanism, making the group objects update
+	 * 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_USE_CACHE)) {
 		if ((ob->transflag & OB_DUPLIGROUP) && ob->dup_group) {
 			GroupObject *go;
 			for (go = ob->dup_group->gobject.first; go; go = go->next) {
diff --git a/source/blender/blenkernel/intern/object_dupli.c b/source/blender/blenkernel/intern/object_dupli.c
index 388be0c..e29153f 100644
--- a/source/blender/blenkernel/intern/object_dupli.c
+++ b/source/blender/blenkernel/intern/object_dupli.c
@@ -1397,9 +1397,11 @@ void BKE_object_dupli_cache_update(Scene *scene, Object *ob, EvaluationContext *
 	const eCacheLibrary_EvalMode eval_mode = eval_ctx->mode == DAG_EVAL_RENDER ? CACHE_LIBRARY_EVAL_RENDER : CACHE_LIBRARY_EVAL_VIEWPORT;
 	Main *bmain = G.main;
 	
+	bool is_dupligroup = (ob->transflag & OB_DUPLIGROUP) && ob->dup_group;
+	bool is_cached = (ob->transflag & OB_DUPLI_USE_CACHE) && BKE_cache_test_dupligroup(bmain, eval_mode, ob->dup_group);
+	
 	/* cache is a group duplicator feature only */
-	if ((ob->transflag & OB_DUPLIGROUP) && ob->dup_group &&
-	    BKE_cache_test_dupligroup(bmain, eval_mode, ob->dup_group)) {
+	if (is_dupligroup && is_cached) {
 		
 		if (ob->dup_cache && !(ob->dup_cache->flag & DUPCACHE_FLAG_DIRTY)) {
 			/* skip if cache is valid */
diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h
index 9aace3b..ed03bf8 100644
--- a/source/blender/makesdna/DNA_object_types.h
+++ b/source/blender/makesdna/DNA_object_types.h
@@ -430,6 +430,7 @@ enum {
 	OB_RENDER_DUPLI     = 1 << 12,
 	OB_NO_CONSTRAINTS   = 1 << 13,  /* runtime constraints disable */
 	OB_NO_PSYS_UPDATE   = 1 << 14,  /* hack to work around particle issue */
+	OB_DUPLI_USE_CACHE  = 1 << 15,  /* use cache instead of object data */
 
 	OB_DUPLI            = OB_DUPLIFRAMES | OB_DUPLIVERTS | OB_DUPLIGROUP | OB_DUPLIFACES | OB_DUPLIPARTS,
 };
diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c
index d8aa659..c5d901e 100644
--- a/source/blender/makesrna/intern/rna_object.c
+++ b/source/blender/makesrna/intern/rna_object.c
@@ -2634,6 +2634,11 @@ static void rna_def_object(BlenderRNA *brna)
 	RNA_def_property_ui_text(prop, "Dupli Faces Scale", "Scale the DupliFace objects");
 	RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update");
 
+	prop = RNA_def_property(srna, "use_dupli_cache", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_sdna(prop, NULL, "transflag", OB_DUPLI_USE_CACHE);
+	RNA_def_property_ui_text(prop, "Use Dupli Cache", "Use caching instead of object data");
+	RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_dependency_update");
+
 	prop = RNA_def_property(srna, "dupli_group", PROP_POINTER, PROP_NONE);
 	RNA_def_property_pointer_sdna(prop, NULL, "dup_group");
 	RNA_def_property_flag(prop, PROP_EDITABLE);




More information about the Bf-blender-cvs mailing list