Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Oeser <info@graphics-engineer.com>2021-12-28 18:57:36 +0300
committerPhilipp Oeser <info@graphics-engineer.com>2022-01-18 10:39:39 +0300
commitdd9f4e1b81b1bb67c2322ca16b7fe34c7f70c974 (patch)
tree777c8316a44db79542bb3ab02c16c7f0d639b5c0
parent9d519f1db48602b5b728ae4fcef2bae6c2369c6f (diff)
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
-rw-r--r--source/blender/modifiers/intern/MOD_array.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/source/blender/modifiers/intern/MOD_array.c b/source/blender/modifiers/intern/MOD_array.c
index bad1d7d3cf9..20cbe70eca3 100644
--- a/source/blender/modifiers/intern/MOD_array.c
+++ b/source/blender/modifiers/intern/MOD_array.c
@@ -279,7 +279,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;
@@ -299,6 +300,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 */
@@ -703,7 +713,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,
@@ -732,7 +743,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,