[Bf-blender-cvs] [3fcf535] master: Split id->flag in two, persistent flags and runtime tags.

Bastien Montagne noreply at git.blender.org
Sun Dec 27 12:02:20 CET 2015


Commit: 3fcf535d2e003ad939fa1f1c7aa4d5da1b38aef7
Author: Bastien Montagne
Date:   Sun Dec 27 11:53:50 2015 +0100
Branches: master
https://developer.blender.org/rB3fcf535d2e003ad939fa1f1c7aa4d5da1b38aef7

Split id->flag in two, persistent flags and runtime tags.

This is purely internal sanitizing/cleanup, no change in behavior is expected at all.

This change was also needed because we were getting short on ID flags, and
future enhancement of 'user_one' ID behavior requires two new ones.

id->flag remains for persistent data (fakeuser only, so far!), this also allows us
100% backward & forward compatibility.

New id->tag is used for most flags. Though written in .blend files, its content
is cleared at read time.

Note that .blend file version was bumped, so that we can clear runtimeflags from
old .blends, important in case we add new persistent flags in future.

Also, behavior of tags (either status ones, or whether they need to be cleared before/after use)
has been added as comments to their declaration.

Reviewers: sergey, campbellbarton

Differential Revision: https://developer.blender.org/D1683

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

M	source/blender/blenkernel/BKE_blender.h
M	source/blender/blenkernel/BKE_library.h
M	source/blender/blenkernel/intern/anim_sys.c
M	source/blender/blenkernel/intern/blender.c
M	source/blender/blenkernel/intern/depsgraph.c
M	source/blender/blenkernel/intern/group.c
M	source/blender/blenkernel/intern/image.c
M	source/blender/blenkernel/intern/lamp.c
M	source/blender/blenkernel/intern/library.c
M	source/blender/blenkernel/intern/mask.c
M	source/blender/blenkernel/intern/material.c
M	source/blender/blenkernel/intern/object.c
M	source/blender/blenkernel/intern/object_dupli.c
M	source/blender/blenkernel/intern/scene.c
M	source/blender/blenkernel/intern/sequencer.c
M	source/blender/blenloader/intern/readfile.c
M	source/blender/blenloader/intern/versioning_270.c
M	source/blender/blenloader/intern/versioning_legacy.c
M	source/blender/blenloader/intern/writefile.c
M	source/blender/collada/SceneExporter.cpp
M	source/blender/collada/collada_utils.cpp
M	source/blender/depsgraph/intern/depsgraph.cc
M	source/blender/depsgraph/intern/depsgraph_build.cc
M	source/blender/depsgraph/intern/depsgraph_build_nodes.cc
M	source/blender/depsgraph/intern/depsgraph_build_relations.cc
M	source/blender/depsgraph/intern/depsgraph_tag.cc
M	source/blender/editors/animation/anim_filter.c
M	source/blender/editors/interface/interface_ops.c
M	source/blender/editors/interface/interface_templates.c
M	source/blender/editors/mesh/editmesh_utils.c
M	source/blender/editors/object/object_add.c
M	source/blender/editors/object/object_bake.c
M	source/blender/editors/object/object_bake_api.c
M	source/blender/editors/object/object_data_transfer.c
M	source/blender/editors/object/object_relations.c
M	source/blender/editors/object/object_transform.c
M	source/blender/editors/render/render_internal.c
M	source/blender/editors/space_node/node_edit.c
M	source/blender/editors/space_outliner/outliner_draw.c
M	source/blender/editors/space_outliner/outliner_tools.c
M	source/blender/editors/space_outliner/outliner_tree.c
M	source/blender/makesdna/DNA_ID.h
M	source/blender/makesrna/intern/rna_ID.c
M	source/blender/makesrna/intern/rna_scene.c
M	source/blender/modifiers/intern/MOD_correctivesmooth.c
M	source/blender/modifiers/intern/MOD_smoke.c
M	source/blender/python/intern/bpy_library.c
M	source/blender/render/intern/source/bake.c
M	source/blender/render/intern/source/convertblender.c
M	source/blender/render/intern/source/multires_bake.c
M	source/blender/render/intern/source/pipeline.c
M	source/blender/windowmanager/intern/wm_operators.c
M	source/gameengine/Converter/KX_BlenderSceneConverter.cpp
M	source/gameengine/Ketsji/BL_ActionManager.cpp
M	source/gameengine/Ketsji/KX_Scene.h

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

diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h
index 6886740..9efaad8 100644
--- a/source/blender/blenkernel/BKE_blender.h
+++ b/source/blender/blenkernel/BKE_blender.h
@@ -42,7 +42,7 @@ extern "C" {
  * and keep comment above the defines.
  * Use STRINGIFY() rather than defining with quotes */
 #define BLENDER_VERSION         276
-#define BLENDER_SUBVERSION      4
+#define BLENDER_SUBVERSION      5
 /* Several breakages with 270, e.g. constraint deg vs rad */
 #define BLENDER_MINVERSION      270
 #define BLENDER_MINSUBVERSION   5
diff --git a/source/blender/blenkernel/BKE_library.h b/source/blender/blenkernel/BKE_library.h
index 9a961ba..ff0cad2 100644
--- a/source/blender/blenkernel/BKE_library.h
+++ b/source/blender/blenkernel/BKE_library.h
@@ -102,8 +102,8 @@ void BKE_main_id_tag_idcode(struct Main *mainvar, const short type, const bool t
 void BKE_main_id_tag_listbase(struct ListBase *lb, const bool tag);
 void BKE_main_id_tag_all(struct Main *mainvar, const bool tag);
 
-void BKE_main_id_flag_listbase(ListBase *lb, const short flag, const bool value);
-void BKE_main_id_flag_all(struct Main *bmain, const short flag, const bool value);
+void BKE_main_id_flag_listbase(ListBase *lb, const int flag, const bool value);
+void BKE_main_id_flag_all(struct Main *bmain, const int flag, const bool value);
 
 void BKE_main_id_clear_newpoins(struct Main *bmain);
 
@@ -129,7 +129,7 @@ void BKE_library_callback_free_editor_id_reference_set(BKE_library_free_editor_i
 /* use when "" is given to new_id() */
 #define ID_FALLBACK_NAME N_("Untitled")
 
-#define IS_TAGGED(_id) ((_id) && (((ID *)_id)->flag & LIB_DOIT))
+#define IS_TAGGED(_id) ((_id) && (((ID *)_id)->tag & LIB_TAG_DOIT))
 
 #ifdef __cplusplus
 }
diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c
index 2ddf014..41950c5 100644
--- a/source/blender/blenkernel/intern/anim_sys.c
+++ b/source/blender/blenkernel/intern/anim_sys.c
@@ -1596,8 +1596,8 @@ static bool animsys_write_rna_setting(PointerRNA *ptr, char *path, int array_ind
 
 				/* for cases like duplifarmes it's only a temporary so don't
 				 * notify anyone of updates */
-				if (!(id->flag & LIB_ANIM_NO_RECALC)) {
-					id->flag |= LIB_ID_RECALC;
+				if (!(id->tag & LIB_TAG_ANIM_NO_RECALC)) {
+					id->tag |= LIB_TAG_ID_RECALC;
 					DAG_id_type_tag(G.main, GS(id->name));
 				}
 			}
@@ -2562,8 +2562,8 @@ static void animsys_evaluate_nla(ListBase *echannels, PointerRNA *ptr, AnimData
 	 */
 	if (ptr->id.data != NULL) {
 		ID *id = ptr->id.data;
-		if (!(id->flag & LIB_ANIM_NO_RECALC)) {
-			id->flag |= LIB_ID_RECALC;
+		if (!(id->tag & LIB_TAG_ANIM_NO_RECALC)) {
+			id->tag |= LIB_TAG_ID_RECALC;
 			DAG_id_type_tag(G.main, GS(id->name));
 		}
 	}
diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c
index fc76c29..8b44737 100644
--- a/source/blender/blenkernel/intern/blender.c
+++ b/source/blender/blenkernel/intern/blender.c
@@ -963,12 +963,12 @@ Main *BKE_undo_get_main(Scene **r_scene)
 void BKE_copybuffer_begin(Main *bmain)
 {
 	/* set all id flags to zero; */
-	BKE_main_id_flag_all(bmain, LIB_NEED_EXPAND | LIB_DOIT, false);
+	BKE_main_id_flag_all(bmain, LIB_TAG_NEED_EXPAND | LIB_TAG_DOIT, false);
 }
 
 void BKE_copybuffer_tag_ID(ID *id)
 {
-	id->flag |= LIB_NEED_EXPAND | LIB_DOIT;
+	id->tag |= LIB_TAG_NEED_EXPAND | LIB_TAG_DOIT;
 }
 
 static void copybuffer_doit(void *UNUSED(handle), Main *UNUSED(bmain), void *vid)
@@ -976,8 +976,8 @@ static void copybuffer_doit(void *UNUSED(handle), Main *UNUSED(bmain), void *vid
 	if (vid) {
 		ID *id = vid;
 		/* only tag for need-expand if not done, prevents eternal loops */
-		if ((id->flag & LIB_DOIT) == 0)
-			id->flag |= LIB_NEED_EXPAND | LIB_DOIT;
+		if ((id->tag & LIB_TAG_DOIT) == 0)
+			id->tag |= LIB_TAG_NEED_EXPAND | LIB_TAG_DOIT;
 	}
 }
 
@@ -1006,7 +1006,7 @@ int BKE_copybuffer_save(const char *filename, ReportList *reports)
 		
 		for (id = lb2->first; id; id = nextid) {
 			nextid = id->next;
-			if (id->flag & LIB_DOIT) {
+			if (id->tag & LIB_TAG_DOIT) {
 				BLI_remlink(lb2, id);
 				BLI_addtail(lb1, id);
 			}
@@ -1033,7 +1033,7 @@ int BKE_copybuffer_save(const char *filename, ReportList *reports)
 	MEM_freeN(mainb);
 	
 	/* set id flag to zero; */
-	BKE_main_id_flag_all(G.main, LIB_NEED_EXPAND | LIB_DOIT, false);
+	BKE_main_id_flag_all(G.main, LIB_TAG_NEED_EXPAND | LIB_TAG_DOIT, false);
 	
 	if (path_list_backup) {
 		BKE_bpath_list_restore(G.main, path_list_flag, path_list_backup);
@@ -1064,8 +1064,8 @@ int BKE_copybuffer_paste(bContext *C, const char *libname, ReportList *reports)
 	/* tag everything, all untagged data can be made local
 	 * its also generally useful to know what is new
 	 *
-	 * take extra care BKE_main_id_flag_all(bmain, LIB_LINK_TAG, false) is called after! */
-	BKE_main_id_flag_all(bmain, LIB_PRE_EXISTING, true);
+	 * take extra care BKE_main_id_flag_all(bmain, LIB_TAG_PRE_EXISTING, false) is called after! */
+	BKE_main_id_flag_all(bmain, LIB_TAG_PRE_EXISTING, true);
 	
 	/* here appending/linking starts */
 	mainl = BLO_library_link_begin(bmain, &bh, libname);
@@ -1084,7 +1084,7 @@ int BKE_copybuffer_paste(bContext *C, const char *libname, ReportList *reports)
 	
 	/* important we unset, otherwise these object wont
 	 * link into other scenes from this blend file */
-	BKE_main_id_flag_all(bmain, LIB_PRE_EXISTING, false);
+	BKE_main_id_flag_all(bmain, LIB_TAG_PRE_EXISTING, false);
 	
 	/* recreate dependency graph to include new objects */
 	DAG_relations_tag_update(bmain);
diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c
index 17faae0..e313ad7 100644
--- a/source/blender/blenkernel/intern/depsgraph.c
+++ b/source/blender/blenkernel/intern/depsgraph.c
@@ -398,13 +398,13 @@ static void dag_add_shader_nodetree_driver_relations(DagForest *dag, DagNode *no
 static void dag_add_material_driver_relations(DagForest *dag, DagNode *node, Material *ma)
 {
 	/* Prevent infinite recursion by checking (and tagging the material) as having been visited 
-	 * already (see build_dag()). This assumes ma->id.flag & LIB_DOIT isn't set by anything else
+	 * already (see build_dag()). This assumes ma->id.tag & LIB_TAG_DOIT isn't set by anything else
 	 * in the meantime... [#32017]
 	 */
-	if (ma->id.flag & LIB_DOIT)
+	if (ma->id.tag & LIB_TAG_DOIT)
 		return;
 
-	ma->id.flag |= LIB_DOIT;
+	ma->id.tag |= LIB_TAG_DOIT;
 	
 	/* material itself */
 	if (ma->adt)
@@ -418,20 +418,20 @@ static void dag_add_material_driver_relations(DagForest *dag, DagNode *node, Mat
 	if (ma->nodetree)
 		dag_add_shader_nodetree_driver_relations(dag, node, ma->nodetree);
 
-	ma->id.flag &= ~LIB_DOIT;
+	ma->id.tag &= ~LIB_TAG_DOIT;
 }
 
 /* recursive handling for lamp drivers */
 static void dag_add_lamp_driver_relations(DagForest *dag, DagNode *node, Lamp *la)
 {
 	/* Prevent infinite recursion by checking (and tagging the lamp) as having been visited 
-	 * already (see build_dag()). This assumes la->id.flag & LIB_DOIT isn't set by anything else
+	 * already (see build_dag()). This assumes la->id.tag & LIB_TAG_DOIT isn't set by anything else
 	 * in the meantime... [#32017]
 	 */
-	if (la->id.flag & LIB_DOIT)
+	if (la->id.tag & LIB_TAG_DOIT)
 		return;
 
-	la->id.flag |= LIB_DOIT;
+	la->id.tag |= LIB_TAG_DOIT;
 	
 	/* lamp itself */
 	if (la->adt)
@@ -445,7 +445,7 @@ static void dag_add_lamp_driver_relations(DagForest *dag, DagNode *node, Lamp *l
 	if (la->nodetree)
 		dag_add_shader_nodetree_driver_relations(dag, node, la->nodetree);
 
-	la->id.flag &= ~LIB_DOIT;
+	la->id.tag &= ~LIB_TAG_DOIT;
 }
 
 static void check_and_create_collision_relation(DagForest *dag, Object *ob, DagNode *node, Object *ob1, int skip_forcefield, bool no_collision)
@@ -903,10 +903,10 @@ static void build_dag_group(DagForest *dag, DagNode *scenenode, Main *bmain, Sce
 {
 	GroupObject *go;
 
-	if (group->id.flag & LIB_DOIT)
+	if (group->id.tag & LIB_TAG_DOIT)
 		return;
 	
-	group->id.flag |= LIB_DOIT;
+	group->id.tag |= LIB_TAG_DOIT;
 
 	for (go = group->gobject.first; go; go = go->next) {
 		build_dag_object(dag, scenenode, bmain, scene, go->ob, mask);
@@ -932,7 +932,7 @@ DagForest *build_dag(Main *bmain, Scene *sce, short mask)
 		sce->theDag = dag;
 	}
 	
-	/* clear "LIB_DOIT" flag from all materials, to prevent infinite recursion problems later [#32017] */
+	/* clear "LIB_TAG_DOIT" flag from all materials, to prevent infinite recursion problems later [#32017] */
 	BKE_main_id_tag_idcode(bmain, ID_MA, false);
 	BKE_main_id_tag_idcode(bmain, ID_LA, false);
 	BKE_main_id_tag_idcode(bmain, ID_GR, false);
@@ -1402,15 +1402,15 @@ static void scene_sort_groups(Main *bmain, Scene *sce)
 	
 	/* test; are group objects all in this scene? */
 	for (ob = bmain->object.first; ob; ob = ob->id.next) {
-		ob->id.flag &= ~LIB_DOIT;
+		ob->id.tag &= ~LIB_TAG_DOIT;
 		ob->id.newid = NULL; /* newid abuse for GroupObject */
 	}
 	for (base = sce->base.first; base; base = base->next)
-		base->object->id.flag |= LIB_DOIT;
+		base->object->id.tag |= LIB_TAG_DOIT;
 	
 	for (group = bmain->group.first; group; group = group->id.next) {
 		for (go = group->gobject.first; go; go = go->next) {
-			if ((go->ob->id.flag & LIB_DOIT) == 0)
+			if ((go->ob->id.tag & LIB_TAG_DOIT) == 0)
 				break;
 		}
 		/* this group is entirely in this scene */
@@ -1481,7 +1481,7 @@ static bool check_object_tagged_for_update(Object *object)
 
 	if (ELEM(object->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_MBALL, OB_LATTICE)) {
 		ID *data_id = object->data;
-		return (data_id->flag & (LIB_ID_RECALC_DATA | LIB_ID_RECALC)) != 0;
+		return (data_id->tag & (LIB_TAG_ID_RECALC_DATA | LIB_TAG_ID_RECALC)) != 0;
 	}
 
 	return false;
@@ -1729,13 +1729,13 @@ void DAG_scene_free(Scene *sce)
 
 static void lib_id_recalc_tag(Main *bmain, ID *id)
 {
-	id->flag |= LIB_ID_RECALC;
+	id->tag |= LIB_TAG_ID_RECALC;
 	DAG_id_type_tag(bmain, GS(id->name));
 }
 
 static void lib_id_recalc_data_tag(Main *bmain, ID *id)
 {
-	id->flag |= LIB_ID_RECALC_DATA;
+	id->tag |= LIB_TAG_ID_RECALC_DATA;
 	DAG_id_type_tag(bmain, GS(id->name));
 }
 
@@ -2262,10 +2262,10 @@ static void dag_group_update_flags

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list