[Bf-blender-cvs] [2b970f1940c] tmp-CollectionsAnim: wip

Joshua Leung noreply at git.blender.org
Sat Jun 2 19:38:32 CEST 2018


Commit: 2b970f1940cd62d296e2c2dcf0d20737518a892d
Author: Joshua Leung
Date:   Tue May 29 11:47:47 2018 +0200
Branches: tmp-CollectionsAnim
https://developer.blender.org/rB2b970f1940cd62d296e2c2dcf0d20737518a892d

wip

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

M	source/blender/blenkernel/intern/anim_sys.c
M	source/blender/blenkernel/intern/collection.c
M	source/blender/blenloader/intern/readfile.c
M	source/blender/blenloader/intern/writefile.c
M	source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
M	source/blender/depsgraph/intern/builder/deg_builder_relations.cc
M	source/blender/makesdna/DNA_group_types.h
M	source/blender/makesrna/intern/rna_group.c

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

diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c
index a14231fd427..fd089ec73b9 100644
--- a/source/blender/blenkernel/intern/anim_sys.c
+++ b/source/blender/blenkernel/intern/anim_sys.c
@@ -104,6 +104,7 @@ bool id_type_can_have_animdata(const short id_type)
 		case ID_MSK:
 		case ID_GD:
 		case ID_CF:
+		case ID_GR:
 			return true;
 		
 		/* no AnimData */
@@ -1131,6 +1132,9 @@ void BKE_animdata_main_cb(Main *mainptr, ID_AnimData_Edit_Callback func, void *u
 	/* masks */
 	ANIMDATA_IDS_CB(mainptr->mask.first);
 	
+	/* collections */
+	ANIMDATA_IDS_CB(mainptr->collection.first);
+	
 	/* worlds */
 	ANIMDATA_NODETREE_IDS_CB(mainptr->world.first, World);
 
@@ -1230,6 +1234,9 @@ void BKE_animdata_fix_paths_rename_all(ID *ref_id, const char *prefix, const cha
 	/* worlds */
 	RENAMEFIX_ANIM_NODETREE_IDS(mainptr->world.first, World);
 	
+	/* collections */
+	RENAMEFIX_ANIM_IDS(mainptr->collection.first);
+	
 	/* linestyles */
 	RENAMEFIX_ANIM_IDS(mainptr->linestyle.first);
 	
@@ -2942,6 +2949,9 @@ void BKE_animsys_evaluate_all_animation(Main *main, Scene *scene, float ctime)
 	/* masks */
 	EVAL_ANIM_IDS(main->mask.first, ADT_RECALC_ANIM);
 	
+	/* collections */
+	EVAL_ANIM_IDS(main->collection.first, ADT_RECALC_ANIM);
+	
 	/* worlds */
 	EVAL_ANIM_NODETREE_IDS(main->world.first, World, ADT_RECALC_ANIM);
 	
diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c
index c4709a32f78..295b7d39f13 100644
--- a/source/blender/blenkernel/intern/collection.c
+++ b/source/blender/blenkernel/intern/collection.c
@@ -35,6 +35,7 @@
 #include "BLT_translation.h"
 #include "BLI_string_utils.h"
 
+#include "BKE_animsys.h"
 #include "BKE_collection.h"
 #include "BKE_icons.h"
 #include "BKE_idprop.h"
@@ -112,7 +113,8 @@ Collection *BKE_collection_add(Main *bmain, Collection *collection_parent, const
 /** Free (or release) any data used by this collection (does not free the collection itself). */
 void BKE_collection_free(Collection *collection)
 {
-	/* No animdata here. */
+	BKE_animdata_free(&collection->id, false);
+
 	BKE_previewimg_free(&collection->preview);
 
 	BLI_freelistN(&collection->gobject);
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index bc4b8daf0d3..acc2be27c39 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -5673,6 +5673,9 @@ static void direct_link_collection(FileData *fd, Collection *collection)
 	link_list(fd, &collection->gobject);
 	link_list(fd, &collection->children);
 
+	collection->adt = newdataadr(fd, collection->adt);
+	direct_link_animdata(fd, collection->adt);
+
 	collection->preview = direct_link_preview_image(fd, collection->preview);
 
 	collection->flag &= ~COLLECTION_HAS_OBJECT_CACHE;
@@ -5727,6 +5730,7 @@ static void lib_link_collection(FileData *fd, Main *main)
 		if (collection->id.tag & LIB_TAG_NEED_LINK) {
 			collection->id.tag &= ~LIB_TAG_NEED_LINK;
 			IDP_LibLinkProperty(collection->id.properties, fd);
+			lib_link_animdata(fd, &collection->id, collection->adt);
 
 #ifdef USE_COLLECTION_COMPAT_28
 			if (collection->collection) {
@@ -9266,6 +9270,10 @@ static void expand_particlesettings(FileData *fd, Main *mainvar, ParticleSetting
 
 static void expand_collection(FileData *fd, Main *mainvar, Collection *collection)
 {
+	if (collection->adt) {
+		expand_animdata(fd, mainvar, collection->adt);
+	}
+	
 	for (CollectionObject *cob = collection->gobject.first; cob; cob = cob->next) {
 		expand_doit(fd, mainvar, cob->ob);
 	}
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index de1699e24b7..e47a5ec2823 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -2376,6 +2376,10 @@ static void write_collection(WriteData *wd, Collection *collection)
 		/* write LibData */
 		writestruct(wd, ID_GR, Collection, 1, collection);
 		write_iddata(wd, &collection->id);
+		
+		if (collection->adt) {
+			write_animdata(wd, collection->adt);
+		}
 
 		write_collection_nolib(wd, collection);
 	}
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
index 98881ba3e57..6fe26bbffb7 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
@@ -432,6 +432,8 @@ void DepsgraphNodeBuilder::build_collection(Collection *collection)
 	LISTBASE_FOREACH (CollectionChild *, child, &collection->children) {
 		build_collection(child->collection);
 	}
+	/* Build animation data. */
+	build_animdata(&collection->id);
 
 	add_id_node(&collection->id);
 }
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
index 64bdbe49dac..64c0f1a774d 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
@@ -438,6 +438,8 @@ void DepsgraphRelationBuilder::build_collection(Object *object, Collection *coll
 		LISTBASE_FOREACH (CollectionChild *, child, &collection->children) {
 			build_collection(NULL, child->collection);
 		}
+		/* Animation data - should only need one set of relations per collection, not once per instance */
+		build_animdata(&collection->id);
 	}
 	if (object != NULL) {
 		const ListBase group_objects = BKE_collection_object_cache_get(collection);
diff --git a/source/blender/makesdna/DNA_group_types.h b/source/blender/makesdna/DNA_group_types.h
index 3b947caf59c..4212bbf9419 100644
--- a/source/blender/makesdna/DNA_group_types.h
+++ b/source/blender/makesdna/DNA_group_types.h
@@ -40,6 +40,7 @@
 
 struct Object;
 struct Collection;
+struct AnimData;
 
 typedef struct CollectionObject {
 	struct CollectionObject *next, *prev;
@@ -55,6 +56,7 @@ typedef struct CollectionChild {
 
 typedef struct Collection {
 	ID id;
+	struct AnimData *adt;
 	
 	ListBase gobject;   /* CollectionObject */
 	ListBase children;  /* CollectionChild */
diff --git a/source/blender/makesrna/intern/rna_group.c b/source/blender/makesrna/intern/rna_group.c
index 116c0bc4a26..74e23f147eb 100644
--- a/source/blender/makesrna/intern/rna_group.c
+++ b/source/blender/makesrna/intern/rna_group.c
@@ -275,6 +275,9 @@ void RNA_def_collections(BlenderRNA *brna)
 	RNA_def_property_ui_icon(prop, ICON_RESTRICT_RENDER_OFF, 1);
 	RNA_def_property_ui_text(prop, "Restrict Render", "Hide collection objects in renders");
 	RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_Collection_flag_update");
+
+	/* Animation Data */
+	rna_def_animdata_common(srna);
 }
 
 #endif



More information about the Bf-blender-cvs mailing list