[Bf-blender-cvs] [7661f8a65ba] blender2.8: Modifiers: Bring back custom data referencing logic

Sergey Sharybin noreply at git.blender.org
Wed May 30 17:00:57 CEST 2018


Commit: 7661f8a65bace62987e0bb419d4fcaced9000667
Author: Sergey Sharybin
Date:   Wed May 30 17:00:05 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB7661f8a65bace62987e0bb419d4fcaced9000667

Modifiers: Bring back custom data referencing logic

Brings dependency graph evaluation time to similar time than 2.79
for file reported in T55228.

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

M	source/blender/modifiers/intern/MOD_normal_edit.c
M	source/blender/modifiers/intern/MOD_util.c
M	source/blender/modifiers/intern/MOD_weightvgedit.c
M	source/blender/modifiers/intern/MOD_weightvgmix.c
M	source/blender/modifiers/intern/MOD_weightvgproximity.c

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

diff --git a/source/blender/modifiers/intern/MOD_normal_edit.c b/source/blender/modifiers/intern/MOD_normal_edit.c
index 5ac6569ea1f..bbb4608ee71 100644
--- a/source/blender/modifiers/intern/MOD_normal_edit.c
+++ b/source/blender/modifiers/intern/MOD_normal_edit.c
@@ -405,13 +405,19 @@ static Mesh *normalEditModifier_do(NormalEditModifierData *enmd, Object *ob, Mes
 	}
 
 	Mesh *result;
-	BKE_id_copy_ex(
-	        NULL, &mesh->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,
-	        false);
+	if (mesh->medge == ((Mesh *)ob->data)->medge) {
+		/* We need to duplicate data here, otherwise setting custom normals (which may also affect sharp edges) could
+		 * modify org mesh, see T43671. */
+		BKE_id_copy_ex(
+		        NULL, &mesh->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,
+		        false);
+	} else {
+		result = mesh;
+	}
 
 	const int num_verts = result->totvert;
 	const int num_edges = result->totedge;
diff --git a/source/blender/modifiers/intern/MOD_util.c b/source/blender/modifiers/intern/MOD_util.c
index 4a62d17fa27..7a586cd6b2e 100644
--- a/source/blender/modifiers/intern/MOD_util.c
+++ b/source/blender/modifiers/intern/MOD_util.c
@@ -311,10 +311,11 @@ Mesh *get_mesh(
 			 * we really need a copy here. Maybe the CoW ob->data can be directly used. */
 			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,
+			        (LIB_ID_CREATE_NO_MAIN |
+			         LIB_ID_CREATE_NO_USER_REFCOUNT |
+			         LIB_ID_CREATE_NO_DEG_TAG |
+			         LIB_ID_COPY_NO_PREVIEW |
+			         LIB_ID_COPY_CD_REFERENCE),
 			        false);
 			mesh->runtime.deformed_only = 1;
 		}
diff --git a/source/blender/modifiers/intern/MOD_weightvgedit.c b/source/blender/modifiers/intern/MOD_weightvgedit.c
index 18d79966938..00bc8a05cee 100644
--- a/source/blender/modifiers/intern/MOD_weightvgedit.c
+++ b/source/blender/modifiers/intern/MOD_weightvgedit.c
@@ -202,14 +202,7 @@ static Mesh *applyModifier(
 		}
 	}
 
-	Mesh *result;
-	BKE_id_copy_ex(
-	        NULL, &mesh->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,
-	        false);
+	Mesh *result = mesh;
 
 	if (has_mdef) {
 		dvert = CustomData_duplicate_referenced_layer(&result->vdata, CD_MDEFORMVERT, numVerts);
diff --git a/source/blender/modifiers/intern/MOD_weightvgmix.c b/source/blender/modifiers/intern/MOD_weightvgmix.c
index eeaf292991f..2b0f90008cf 100644
--- a/source/blender/modifiers/intern/MOD_weightvgmix.c
+++ b/source/blender/modifiers/intern/MOD_weightvgmix.c
@@ -243,14 +243,7 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
 		}
 	}
 
-	Mesh *result;
-	BKE_id_copy_ex(
-	        NULL, &mesh->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,
-	        false);
+	Mesh *result = mesh;
 
 	if (has_mdef) {
 		dvert = CustomData_duplicate_referenced_layer(&result->vdata, CD_MDEFORMVERT, numVerts);
diff --git a/source/blender/modifiers/intern/MOD_weightvgproximity.c b/source/blender/modifiers/intern/MOD_weightvgproximity.c
index 52d94cfd76c..070d4ad80e6 100644
--- a/source/blender/modifiers/intern/MOD_weightvgproximity.c
+++ b/source/blender/modifiers/intern/MOD_weightvgproximity.c
@@ -421,14 +421,7 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
 		return mesh;
 	}
 
-	Mesh *result;
-	BKE_id_copy_ex(
-	        NULL, &mesh->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,
-	        false);
+	Mesh *result = mesh;
 
 	if (has_mdef) {
 		dvert = CustomData_duplicate_referenced_layer(&result->vdata, CD_MDEFORMVERT, numVerts);



More information about the Bf-blender-cvs mailing list