[Bf-blender-cvs] [47b95a29570] master: Fix T70561: bad custom normals in mirrored geometry.
Bastien Montagne
noreply at git.blender.org
Tue Oct 8 20:19:25 CEST 2019
Commit: 47b95a295706c3092e48a227b50360748f8789be
Author: Bastien Montagne
Date: Tue Oct 8 20:16:07 2019 +0200
Branches: master
https://developer.blender.org/rB47b95a295706c3092e48a227b50360748f8789be
Fix T70561: bad custom normals in mirrored geometry.
Original code from rB1a9e698099b5 used a rather naive approach, now use
proper transpose of inverse of geometry transform for the normals.
===================================================================
M source/blender/blenkernel/intern/mirror.c
===================================================================
diff --git a/source/blender/blenkernel/intern/mirror.c b/source/blender/blenkernel/intern/mirror.c
index c429b953015..624996f8150 100644
--- a/source/blender/blenkernel/intern/mirror.c
+++ b/source/blender/blenkernel/intern/mirror.c
@@ -321,6 +321,12 @@ Mesh *BKE_mirror_apply_mirror_on_axis(MirrorModifierData *mmd,
MLoopNorSpaceArray lnors_spacearr = {NULL};
float(*poly_normals)[3] = MEM_mallocN(sizeof(*poly_normals) * totpoly, __func__);
+ /* The transform matrix of a normal must be
+ * the transpose of inverse of transform matrix of the geometry... */
+ float mtx_nor[4][4];
+ invert_m4_m4(mtx_nor, mtx);
+ transpose_m4(mtx_nor);
+
/* calculate custom normals into loop_normals, then mirror first half into second half */
BKE_mesh_calc_normals_poly(result->mvert,
@@ -361,7 +367,7 @@ Mesh *BKE_mirror_apply_mirror_on_axis(MirrorModifierData *mmd,
mirrorj += mpmirror->totloop - (j - mp->loopstart);
}
copy_v3_v3(loop_normals[mirrorj], loop_normals[j]);
- loop_normals[mirrorj][axis] = -loop_normals[j][axis];
+ mul_m4_v3(mtx_nor, loop_normals[mirrorj]);
BKE_lnor_space_custom_normal_to_data(
lnors_spacearr.lspacearr[mirrorj], loop_normals[mirrorj], clnors[mirrorj]);
}
More information about the Bf-blender-cvs
mailing list