[Bf-blender-cvs] [3b01edd52e8] soc-2017-normal-tools: Fix weighted normals modifier sometimes affecting actual mesh.

Bastien Montagne noreply at git.blender.org
Wed Apr 11 17:28:31 CEST 2018


Commit: 3b01edd52e8e28f425d76ae17ee50f3feed69d36
Author: Bastien Montagne
Date:   Wed Apr 11 17:27:23 2018 +0200
Branches: soc-2017-normal-tools
https://developer.blender.org/rB3b01edd52e8e28f425d76ae17ee50f3feed69d36

Fix weighted normals modifier sometimes affecting actual mesh.

Same issue & same fix as with edit normals modifier some times ago...

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

M	source/blender/modifiers/intern/MOD_weighted_normal.c

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

diff --git a/source/blender/modifiers/intern/MOD_weighted_normal.c b/source/blender/modifiers/intern/MOD_weighted_normal.c
index 1f06803505a..7e339f0012d 100644
--- a/source/blender/modifiers/intern/MOD_weighted_normal.c
+++ b/source/blender/modifiers/intern/MOD_weighted_normal.c
@@ -491,9 +491,15 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *dm,
 	const int numLoops = dm->getNumLoops(dm);
 	const int numPolys = dm->getNumPolys(dm);
 
+	MEdge *medge = dm->getEdgeArray(dm);
+	if (me->medge == medge) {
+		/* We need to duplicate data here, otherwise setting custom normals (which may also affect sharp edges) could
+		 * modify org mesh. */
+		dm = CDDM_copy(dm);
+		medge = dm->getEdgeArray(dm);
+	}
 	MPoly *mpoly = dm->getPolyArray(dm);
 	MVert *mvert = dm->getVertArray(dm);
-	MEdge *medge = dm->getEdgeArray(dm);
 	MLoop *mloop = dm->getLoopArray(dm);
 
 	bool free_polynors = false;



More information about the Bf-blender-cvs mailing list