[Bf-blender-cvs] [b539039] alembic: Optional filter group pointer in Cache Library for limiting cache content.

Lukas Tönne noreply at git.blender.org
Tue Apr 28 09:46:40 CEST 2015


Commit: b539039d19bd273533befc3978e950bea68955ee
Author: Lukas Tönne
Date:   Tue Apr 28 09:43:33 2015 +0200
Branches: alembic
https://developer.blender.org/rBb539039d19bd273533befc3978e950bea68955ee

Optional filter group pointer in Cache Library for limiting cache
content.

This group is only used for the baking operator (like the datatypes
filter), but has no effect when reading caches. The UI now uses a box
layout to reflect this.

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

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/object_dupli.c
M	source/blender/blenloader/intern/readfile.c
M	source/blender/makesdna/DNA_cache_library_types.h
M	source/blender/makesrna/intern/rna_cache_library.c
M	source/blender/pointcache/alembic/abc_group.cpp

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

diff --git a/release/scripts/startup/bl_ui/properties_object.py b/release/scripts/startup/bl_ui/properties_object.py
index cb88f38..c3d25f7 100644
--- a/release/scripts/startup/bl_ui/properties_object.py
+++ b/release/scripts/startup/bl_ui/properties_object.py
@@ -405,10 +405,17 @@ class OBJECT_PT_cache_library(ObjectButtonsPanel, Panel):
         props.use_popup = True
         props.use_clipboard = True
 
-        col = layout.column()
-        col.operator("cachelibrary.bake")
-        col.row().prop(cachelib, "eval_mode", toggle=True, expand=True)
-        col.row().prop(cachelib, "data_types", icon_only=True, toggle=True)
+        box = layout.box()
+        row = box.row()
+        
+        col = row.column()
+        row2 = col.row()
+        row2.prop(cachelib, "eval_mode", toggle=True, expand=True)
+        row2 = col.row()
+        row2.alignment = 'LEFT'
+        row2.prop(cachelib, "data_types", icon_only=True, toggle=True)
+        row2.template_ID(cachelib, "filter_group")
+        row.operator("cachelibrary.bake")
 
         '''
         row = layout.row(align=True)
diff --git a/source/blender/blenkernel/BKE_cache_library.h b/source/blender/blenkernel/BKE_cache_library.h
index 431f8d8..eb334f3 100644
--- a/source/blender/blenkernel/BKE_cache_library.h
+++ b/source/blender/blenkernel/BKE_cache_library.h
@@ -73,6 +73,8 @@ void BKE_cache_archive_output_path(struct CacheLibrary *cachelib, char *result,
 
 void BKE_cache_library_dag_recalc_tag(struct EvaluationContext *eval_ctx, struct Main *bmain);
 
+void BKE_cache_library_filter_duplilist(struct CacheLibrary *cachelib, struct ListBase *duplilist);
+
 bool BKE_cache_read_dupli_cache(struct CacheLibrary *cachelib, struct DupliCache *dupcache,
                                 struct Scene *scene, struct Group *dupgroup, float frame, eCacheLibrary_EvalMode eval_mode, bool for_display);
 bool BKE_cache_read_dupli_object(struct CacheLibrary *cachelib, struct DupliObjectData *data,
diff --git a/source/blender/blenkernel/intern/cache_library.c b/source/blender/blenkernel/intern/cache_library.c
index 53a5e35..b3530ce 100644
--- a/source/blender/blenkernel/intern/cache_library.c
+++ b/source/blender/blenkernel/intern/cache_library.c
@@ -101,6 +101,9 @@ CacheLibrary *BKE_cache_library_copy(CacheLibrary *cachelib)
 	
 	cachelibn = BKE_libblock_copy(&cachelib->id);
 	
+	if (cachelibn->filter_group)
+		id_us_plus(&cachelibn->filter_group->id);
+	
 	{
 		CacheModifier *md;
 		BLI_listbase_clear(&cachelibn->modifiers);
@@ -122,6 +125,9 @@ void BKE_cache_library_free(CacheLibrary *cachelib)
 {
 	BKE_cache_modifier_clear(cachelib);
 	
+	if (cachelib->filter_group)
+		id_us_min(&cachelib->filter_group->id);
+	
 	if (cachelib->archive_info)
 		BKE_cache_archive_info_free(cachelib->archive_info);
 }
@@ -208,6 +214,40 @@ bool BKE_cache_library_validate_item(CacheLibrary *cachelib, Object *ob, int typ
 
 /* ========================================================================= */
 
+void BKE_cache_library_filter_duplilist(CacheLibrary *cachelib, ListBase *duplilist)
+{
+	if (cachelib->filter_group) {
+		GroupObject *gob;
+		
+		/* tag only filter group objects as valid */
+		BKE_main_id_tag_idcode(G.main, ID_OB, false);
+		for (gob = cachelib->filter_group->gobject.first; gob; gob = gob->next)
+			gob->ob->id.flag |= LIB_DOIT;
+	}
+	else {
+		/* all objects valid */
+		BKE_main_id_tag_idcode(G.main, ID_OB, true);
+	}
+	
+	{
+		/* remove invalid duplis */
+		DupliObject *dob, *dob_next;
+		for (dob = duplilist->first; dob; dob = dob_next) {
+			dob_next = dob->next;
+			
+			if (!(dob->ob->id.flag & LIB_DOIT)) {
+				BLI_remlink(duplilist, dob);
+				MEM_freeN(dob);
+			}
+		}
+	}
+	
+	/* clear LIB_DOIT tags */
+	BKE_main_id_tag_idcode(G.main, ID_OB, false);
+}
+
+/* ========================================================================= */
+
 BLI_INLINE bool path_is_dirpath(const char *path)
 {
 	/* last char is a slash? */
diff --git a/source/blender/blenkernel/intern/object_dupli.c b/source/blender/blenkernel/intern/object_dupli.c
index 962ab77..1574c4a 100644
--- a/source/blender/blenkernel/intern/object_dupli.c
+++ b/source/blender/blenkernel/intern/object_dupli.c
@@ -1644,6 +1644,7 @@ void BKE_dupli_cache_from_group(Scene *scene, Group *group, CacheLibrary *cachel
 	{
 		/* copy duplilist to the cache */
 		ListBase *duplilist = group_duplilist(eval_ctx, scene, group);
+		BKE_cache_library_filter_duplilist(cachelib, duplilist);
 		dupcache->duplilist = *duplilist;
 		MEM_freeN(duplilist);
 	}
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 68d7fe9..22f24ec 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -2016,6 +2016,8 @@ static void lib_link_cache_library(FileData *fd, Main *main)
 		if (cachelib->id.flag & LIB_NEED_LINK) {
 			cachelib->id.flag -= LIB_NEED_LINK;
 			
+			cachelib->filter_group = newlibadr_us(fd, cachelib->id.lib, cachelib->filter_group);
+			
 			lib_link_cache_modifiers(fd, cachelib);
 		}
 	}
@@ -9097,8 +9099,10 @@ static void expand_gpencil(FileData *fd, Main *mainvar, bGPdata *gpd)
 		expand_animdata(fd, mainvar, gpd->adt);
 }
 
-static void expand_cache_library(FileData *UNUSED(fd), Main *UNUSED(mainvar), CacheLibrary *UNUSED(cachelib))
+static void expand_cache_library(FileData *fd, Main *mainvar, CacheLibrary *cachelib)
 {
+	if (cachelib->filter_group)
+		expand_doit(fd, mainvar, cachelib->filter_group);
 }
 
 void BLO_main_expander(void (*expand_doit_func)(void *, Main *, void *))
diff --git a/source/blender/makesdna/DNA_cache_library_types.h b/source/blender/makesdna/DNA_cache_library_types.h
index d76aa4c..cb952aa 100644
--- a/source/blender/makesdna/DNA_cache_library_types.h
+++ b/source/blender/makesdna/DNA_cache_library_types.h
@@ -96,6 +96,7 @@ typedef struct CacheLibrary {
 	int display_flag;
 	int render_flag;
 	int data_types;
+	struct Group *filter_group;
 	
 	char input_filepath[1024]; /* 1024 = FILE_MAX */
 	char output_filepath[1024]; /* 1024 = FILE_MAX */
diff --git a/source/blender/makesrna/intern/rna_cache_library.c b/source/blender/makesrna/intern/rna_cache_library.c
index 7b286a7..818e772 100644
--- a/source/blender/makesrna/intern/rna_cache_library.c
+++ b/source/blender/makesrna/intern/rna_cache_library.c
@@ -579,6 +579,12 @@ static void rna_def_cache_library(BlenderRNA *brna)
 	RNA_def_property_ui_text(prop, "Data Types", "Types of data to store in the cache");
 	RNA_def_property_update(prop, 0, "rna_CacheLibrary_update");
 	
+	prop = RNA_def_property(srna, "filter_group", PROP_POINTER, PROP_NONE);
+	RNA_def_property_pointer_sdna(prop, NULL, "filter_group");
+	RNA_def_property_flag(prop, PROP_EDITABLE);
+	RNA_def_property_ui_text(prop, "Filter Group", "If set, only objects in this group will be cached");
+	RNA_def_property_update(prop, 0, "rna_CacheLibrary_update");
+	
 	/* modifiers */
 	prop = RNA_def_property(srna, "modifiers", PROP_COLLECTION, PROP_NONE);
 	RNA_def_property_struct_type(prop, "CacheLibraryModifier");
diff --git a/source/blender/pointcache/alembic/abc_group.cpp b/source/blender/pointcache/alembic/abc_group.cpp
index 27504b9..3df85fb 100644
--- a/source/blender/pointcache/alembic/abc_group.cpp
+++ b/source/blender/pointcache/alembic/abc_group.cpp
@@ -198,6 +198,7 @@ void AbcDupligroupWriter::write_sample()
 		return;
 	
 	ListBase *duplilist = group_duplilist_ex(m_eval_ctx, m_scene, m_group, true);
+	BKE_cache_library_filter_duplilist(m_cachelib, duplilist);
 	DupliObject *dob;
 	int i;




More information about the Bf-blender-cvs mailing list