[Bf-blender-cvs] [dfdc7c3f810] blender-v2.93-release: Fix T94422: Shading/Normals break on array modifier caps

Philipp Oeser noreply at git.blender.org
Tue Jan 11 16:00:22 CET 2022


Commit: dfdc7c3f8107ac98074f3c78036618ee56424d95
Author: Philipp Oeser
Date:   Tue Dec 28 16:57:36 2021 +0100
Branches: blender-v2.93-release
https://developer.blender.org/rBdfdc7c3f8107ac98074f3c78036618ee56424d95

Fix T94422: Shading/Normals break on array modifier caps

The array modifier does not necessarily tag normals dirty.
If it doesnt, normals are recalculated "internally" using the offset ob
transform. This was happening for the array items, but not for the caps.

Now do the same thing for caps.

Maniphest Tasks: T94422

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

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

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

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

diff --git a/source/blender/modifiers/intern/MOD_array.c b/source/blender/modifiers/intern/MOD_array.c
index 0282f0d2934..e28662c9715 100644
--- a/source/blender/modifiers/intern/MOD_array.c
+++ b/source/blender/modifiers/intern/MOD_array.c
@@ -285,7 +285,8 @@ static void mesh_merge_transform(Mesh *result,
                                  int cap_nloops,
                                  int cap_npolys,
                                  int *remap,
-                                 int remap_len)
+                                 int remap_len,
+                                 const bool recalc_normals_later)
 {
   int *index_orig;
   int i;
@@ -305,6 +306,15 @@ static void mesh_merge_transform(Mesh *result,
     mul_m4_v3(cap_offset, mv->co);
     /* Reset MVert flags for caps */
     mv->flag = mv->bweight = 0;
+
+    /* We have to correct normals too, if we do not tag them as dirty later! */
+    if (!recalc_normals_later) {
+      float no[3];
+      normal_short_to_float_v3(no, mv->no);
+      mul_mat3_m4_v3(cap_offset, no);
+      normalize_v3(no);
+      normal_float_to_short_v3(mv->no, no);
+    }
   }
 
   /* remap the vertex groups if necessary */
@@ -711,7 +721,8 @@ static Mesh *arrayModifier_doArray(ArrayModifierData *amd,
                          start_cap_nloops,
                          start_cap_npolys,
                          vgroup_start_cap_remap,
-                         vgroup_start_cap_remap_len);
+                         vgroup_start_cap_remap_len,
+                         use_recalc_normals);
     /* Identify doubles with first chunk */
     if (use_merge) {
       dm_mvert_map_doubles(full_doubles_map,
@@ -740,7 +751,8 @@ static Mesh *arrayModifier_doArray(ArrayModifierData *amd,
                          end_cap_nloops,
                          end_cap_npolys,
                          vgroup_end_cap_remap,
-                         vgroup_end_cap_remap_len);
+                         vgroup_end_cap_remap_len,
+                         use_recalc_normals);
     /* Identify doubles with last chunk */
     if (use_merge) {
       dm_mvert_map_doubles(full_doubles_map,



More information about the Bf-blender-cvs mailing list