[Bf-blender-cvs] [b6771ccaf6a] master: BKE_library: id_copy: More general usage of LIB_ID_COPY_LOCALIZE.

Bastien Montagne noreply at git.blender.org
Tue Feb 5 11:08:07 CET 2019


Commit: b6771ccaf6a547ae5463af7102fbe23a621c2bf2
Author: Bastien Montagne
Date:   Mon Feb 4 17:51:15 2019 +0100
Branches: master
https://developer.blender.org/rBb6771ccaf6a547ae5463af7102fbe23a621c2bf2

BKE_library: id_copy: More general usage of LIB_ID_COPY_LOCALIZE.

Turns out most of our 'local working copy' cases can use same set of
flags.

Note that this commit adds LIB_ID_COPY_CACHES to all our local meshes
copying, however this is no-op since that flag is unused during mesh
copying... We may want to add another set of flags without that one at
some point, but for now it would not be useful imho.

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

M	source/blender/blenkernel/intern/displist.c
M	source/blender/blenkernel/intern/mesh.c
M	source/blender/blenkernel/intern/mesh_convert.c
M	source/blender/blenkernel/intern/node.c
M	source/blender/blenkernel/intern/particle_distribute.c
M	source/blender/blenkernel/intern/particle_system.c
M	source/blender/collada/collada_utils.cpp
M	source/blender/editors/physics/particle_object.c
M	source/blender/modifiers/intern/MOD_boolean.c
M	source/blender/modifiers/intern/MOD_cloth.c
M	source/blender/modifiers/intern/MOD_collision.c
M	source/blender/modifiers/intern/MOD_datatransfer.c
M	source/blender/modifiers/intern/MOD_normal_edit.c
M	source/blender/modifiers/intern/MOD_ocean.c
M	source/blender/modifiers/intern/MOD_surface.c
M	source/blender/modifiers/intern/MOD_util.c
M	source/blender/modifiers/intern/MOD_weighted_normal.c

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

diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c
index 28cdf3b3b36..5df8210d075 100644
--- a/source/blender/blenkernel/intern/displist.c
+++ b/source/blender/blenkernel/intern/displist.c
@@ -999,9 +999,7 @@ static void curve_calc_modifiers_post(
 			if (modified) {
 				if (vertCos) {
 					Mesh *temp_mesh;
-					BKE_id_copy_ex(NULL, &modified->id, (ID **)&temp_mesh,
-					               LIB_ID_CREATE_NO_MAIN | LIB_ID_CREATE_NO_USER_REFCOUNT |
-					               LIB_ID_CREATE_NO_DEG_TAG | LIB_ID_COPY_NO_PREVIEW);
+					BKE_id_copy_ex(NULL, &modified->id, (ID **)&temp_mesh, LIB_ID_COPY_LOCALIZE);
 					BKE_id_free(NULL, modified);
 					modified = temp_mesh;
 
@@ -1044,9 +1042,7 @@ static void curve_calc_modifiers_post(
 	if (vertCos) {
 		if (modified) {
 			Mesh *temp_mesh;
-			BKE_id_copy_ex(NULL, &modified->id, (ID **)&temp_mesh,
-			               LIB_ID_CREATE_NO_MAIN | LIB_ID_CREATE_NO_USER_REFCOUNT |
-			               LIB_ID_CREATE_NO_DEG_TAG | LIB_ID_COPY_NO_PREVIEW);
+			BKE_id_copy_ex(NULL, &modified->id, (ID **)&temp_mesh, LIB_ID_COPY_LOCALIZE);
 			BKE_id_free(NULL, modified);
 			modified = temp_mesh;
 
diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c
index 30080b64e95..93bba2cf9d2 100644
--- a/source/blender/blenkernel/intern/mesh.c
+++ b/source/blender/blenkernel/intern/mesh.c
@@ -609,9 +609,7 @@ Mesh *BKE_mesh_new_nomain(int verts_len, int edges_len, int tessface_len, int lo
 	Mesh *mesh = BKE_libblock_alloc(
 	        NULL, ID_ME,
 	        BKE_idcode_to_name(ID_ME),
-	        LIB_ID_CREATE_NO_MAIN |
-	        LIB_ID_CREATE_NO_USER_REFCOUNT |
-	        LIB_ID_CREATE_NO_DEG_TAG);
+	        LIB_ID_COPY_LOCALIZE);
 	BKE_libblock_init_empty(&mesh->id);
 
 	/* don't use CustomData_reset(...); because we dont want to touch customdata */
@@ -691,10 +689,7 @@ Mesh *BKE_mesh_new_nomain_from_template(
 
 Mesh *BKE_mesh_copy_for_eval(struct Mesh *source, bool reference)
 {
-	int flags = (LIB_ID_CREATE_NO_MAIN |
-	             LIB_ID_CREATE_NO_USER_REFCOUNT |
-	             LIB_ID_CREATE_NO_DEG_TAG |
-	             LIB_ID_COPY_NO_PREVIEW);
+	int flags = LIB_ID_COPY_LOCALIZE;
 
 	if (reference) {
 		flags |= LIB_ID_COPY_CD_REFERENCE;
diff --git a/source/blender/blenkernel/intern/mesh_convert.c b/source/blender/blenkernel/intern/mesh_convert.c
index b48ede55e52..ee72291b87a 100644
--- a/source/blender/blenkernel/intern/mesh_convert.c
+++ b/source/blender/blenkernel/intern/mesh_convert.c
@@ -1141,12 +1141,7 @@ Mesh *BKE_mesh_create_derived_for_modifier(
 		float (*deformedVerts)[3] = BKE_mesh_vertexCos_get(me, &numVerts);
 
 		mti->deformVerts(md, &mectx, NULL, deformedVerts, numVerts);
-		BKE_id_copy_ex(
-		        NULL, &me->id, (ID **)&result,
-		        LIB_ID_CREATE_NO_MAIN |
-		        LIB_ID_CREATE_NO_USER_REFCOUNT |
-		        LIB_ID_CREATE_NO_DEG_TAG |
-		        LIB_ID_COPY_NO_PREVIEW);
+		BKE_id_copy_ex(NULL, &me->id, (ID **)&result, LIB_ID_COPY_LOCALIZE);
 		BKE_mesh_apply_vert_coords(result, deformedVerts);
 
 		if (build_shapekey_layers)
@@ -1156,12 +1151,7 @@ Mesh *BKE_mesh_create_derived_for_modifier(
 	}
 	else {
 		Mesh *mesh_temp;
-		BKE_id_copy_ex(
-		        NULL, &me->id, (ID **)&mesh_temp,
-		        LIB_ID_CREATE_NO_MAIN |
-		        LIB_ID_CREATE_NO_USER_REFCOUNT |
-		        LIB_ID_CREATE_NO_DEG_TAG |
-		        LIB_ID_COPY_NO_PREVIEW);
+		BKE_id_copy_ex(NULL, &me->id, (ID **)&mesh_temp, LIB_ID_COPY_LOCALIZE);
 
 		if (build_shapekey_layers)
 			add_shapekey_layers(mesh_temp, me);
diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c
index daa7ce80ba2..4c09c687724 100644
--- a/source/blender/blenkernel/intern/node.c
+++ b/source/blender/blenkernel/intern/node.c
@@ -2035,9 +2035,7 @@ bNodeTree *ntreeLocalize(bNodeTree *ntree)
 		 */
 		BKE_id_copy_ex(
 		        NULL, &ntree->id, (ID **)&ltree,
-		        (LIB_ID_CREATE_NO_MAIN |
-		         LIB_ID_CREATE_NO_USER_REFCOUNT |
-		         LIB_ID_COPY_NO_PREVIEW |
+		        (LIB_ID_COPY_LOCALIZE |
 		         LIB_ID_COPY_NO_ANIMDATA));
 
 		for (node = ltree->nodes.first; node; node = node->next) {
diff --git a/source/blender/blenkernel/intern/particle_distribute.c b/source/blender/blenkernel/intern/particle_distribute.c
index b2372c40b46..2abfebfe902 100644
--- a/source/blender/blenkernel/intern/particle_distribute.c
+++ b/source/blender/blenkernel/intern/particle_distribute.c
@@ -858,12 +858,7 @@ static int psys_thread_context_init_distribute(ParticleThreadContext *ctx, Parti
 				mesh = final_mesh;
 			}
 			else {
-				BKE_id_copy_ex(
-				        NULL, ob->data, (ID **)&mesh,
-				        LIB_ID_CREATE_NO_MAIN |
-				        LIB_ID_CREATE_NO_USER_REFCOUNT |
-				        LIB_ID_CREATE_NO_DEG_TAG |
-				        LIB_ID_COPY_NO_PREVIEW);
+				BKE_id_copy_ex(NULL, ob->data, (ID **)&mesh, LIB_ID_COPY_LOCALIZE);
 			}
 			BKE_mesh_tessface_ensure(mesh);
 
@@ -909,12 +904,7 @@ static int psys_thread_context_init_distribute(ParticleThreadContext *ctx, Parti
 		if (psys->part->use_modifier_stack)
 			mesh = final_mesh;
 		else
-			BKE_id_copy_ex(
-			            NULL, ob->data, (ID **)&mesh,
-			            LIB_ID_CREATE_NO_MAIN |
-			            LIB_ID_CREATE_NO_USER_REFCOUNT |
-			            LIB_ID_CREATE_NO_DEG_TAG |
-			            LIB_ID_COPY_NO_PREVIEW);
+			BKE_id_copy_ex(NULL, ob->data, (ID **)&mesh, LIB_ID_COPY_LOCALIZE);
 
 		BKE_mesh_tessface_ensure(mesh);
 
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c
index 77422ca20e3..aebee71fc51 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -3195,12 +3195,7 @@ static void do_hair_dynamics(ParticleSimulationData *sim)
 	clmd_effweights = psys->clmd->sim_parms->effector_weights;
 	psys->clmd->sim_parms->effector_weights = psys->part->effector_weights;
 
-	BKE_id_copy_ex(
-	            NULL, &psys->hair_in_mesh->id, (ID **)&psys->hair_out_mesh,
-	            LIB_ID_CREATE_NO_MAIN |
-	            LIB_ID_CREATE_NO_USER_REFCOUNT |
-	            LIB_ID_CREATE_NO_DEG_TAG |
-	            LIB_ID_COPY_NO_PREVIEW);
+	BKE_id_copy_ex(NULL, &psys->hair_in_mesh->id, (ID **)&psys->hair_out_mesh, LIB_ID_COPY_LOCALIZE);
 	deformedVerts = BKE_mesh_vertexCos_get(psys->hair_out_mesh, NULL);
 	clothModifier_do(psys->clmd, sim->depsgraph, sim->scene, sim->ob, psys->hair_in_mesh, deformedVerts);
 	BKE_mesh_apply_vert_coords(psys->hair_out_mesh, deformedVerts);
diff --git a/source/blender/collada/collada_utils.cpp b/source/blender/collada/collada_utils.cpp
index 63290f38ac8..1b9deded8a8 100644
--- a/source/blender/collada/collada_utils.cpp
+++ b/source/blender/collada/collada_utils.cpp
@@ -283,11 +283,7 @@ Mesh *bc_get_mesh_copy(
 		tmpmesh = (Mesh *)ob->data;
 	}
 
-	BKE_id_copy_ex(NULL, &tmpmesh->id, (ID **)&tmpmesh,
-	               LIB_ID_CREATE_NO_MAIN |
-	               LIB_ID_CREATE_NO_USER_REFCOUNT |
-	               LIB_ID_CREATE_NO_DEG_TAG |
-	               LIB_ID_COPY_NO_PREVIEW);
+	BKE_id_copy_ex(NULL, &tmpmesh->id, (ID **)&tmpmesh, LIB_ID_COPY_LOCALIZE);
 
 	if (triangulate) {
 		bc_triangulate_mesh(tmpmesh);
diff --git a/source/blender/editors/physics/particle_object.c b/source/blender/editors/physics/particle_object.c
index 4894828f808..c8a161b7ac0 100644
--- a/source/blender/editors/physics/particle_object.c
+++ b/source/blender/editors/physics/particle_object.c
@@ -717,12 +717,7 @@ static bool remap_hair_emitter(
 		return false;
 	}
 	/* don't modify the original vertices */
-	BKE_id_copy_ex(
-	            NULL, &mesh->id, (ID **)&mesh,
-	            LIB_ID_CREATE_NO_MAIN |
-	            LIB_ID_CREATE_NO_USER_REFCOUNT |
-	            LIB_ID_CREATE_NO_DEG_TAG |
-	            LIB_ID_COPY_NO_PREVIEW);
+	BKE_id_copy_ex(NULL, &mesh->id, (ID **)&mesh, LIB_ID_COPY_LOCALIZE);
 
 	/* BMESH_ONLY, deform dm may not have tessface */
 	BKE_mesh_tessface_ensure(mesh);
@@ -1098,12 +1093,7 @@ static bool copy_particle_systems_to_object(const bContext *C,
 		modifier_unique_name(&ob_to->modifiers, (ModifierData *)psmd);
 
 		psmd->psys = psys;
-		BKE_id_copy_ex(
-		            NULL, &final_mesh->id, (ID **)&psmd->mesh_final,
-		            LIB_ID_CREATE_NO_MAIN |
-		            LIB_ID_CREATE_NO_USER_REFCOUNT |
-		            LIB_ID_CREATE_NO_DEG_TAG |
-		            LIB_ID_COPY_NO_PREVIEW);
+		BKE_id_copy_ex(NULL, &final_mesh->id, (ID **)&psmd->mesh_final, LIB_ID_COPY_LOCALIZE);
 
 		BKE_mesh_calc_normals(psmd->mesh_final);
 		BKE_mesh_tessface_ensure(psmd->mesh_final);
diff --git a/source/blender/modifiers/intern/MOD_boolean.c b/source/blender/modifiers/intern/MOD_boolean.c
index 2aab1b7844d..c4fbce54937 100644
--- a/source/blender/modifiers/intern/MOD_boolean.c
+++ b/source/blender/modifiers/intern/MOD_boolean.c
@@ -111,11 +111,7 @@ static Mesh *get_quick_mesh(
 					result = mesh_self;
 				}
 				else {
-					BKE_id_copy_ex(NULL, &mesh_other->id, (ID **)&result,
-					               LIB_ID_CREATE_NO_MAIN |
-					               LIB_ID_CREATE_NO_USER_REFCOUNT |
-					               LIB_ID_CREATE_NO_DEG_TAG |
-					               LIB_ID_COPY_NO_PREVIEW);
+					BKE_id_copy_ex(NULL, &mesh_other->id, (ID **)&result, LIB_ID_COPY_LOCALIZE);
 
 					float imat[4][4];
 					float omat[4][4];
diff --git a/source/blender/modifiers/intern/MOD_cloth.c b/source/blender/modifiers/intern/MOD_cloth.c
index 27ec0595b54..c1072ba94cf 100644
--- a/source/blender/modifiers/intern/MOD_cloth.c
+++ b/source/blender/modifiers/intern/MOD_cloth.c
@@ -87,12 +87,7 @@ static void deformVerts(
 	else {
 		/* Not possible to use get_mesh() in this case as we'll modify its vertices
 		 * and get_mesh() would return 'mesh' directly. */
-		BKE_id_copy_ex(
-		        NULL, (ID *)mesh, (ID **)&mesh_src,
-		        LIB_ID_CREATE_NO_MAIN |
-		        LIB_ID_CREATE_NO_USER_REFCOUNT |
-		        LIB_ID_CREATE_NO_DEG_TAG |
-		        LIB_ID_COPY_NO_PREVIEW);
+		BKE_id_copy_ex(NULL, (ID *)mesh, (ID **)&mesh_src, LIB_ID_COPY_LOCALIZE);
 	}
 
 	/* TODO(sergey): For now it actually duplicates logic from DerivedMesh.c
diff --git a/source/blender/modifiers/intern/MOD_collision.c b/source/blender/modifiers/i

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list