[Bf-blender-cvs] [819b9bdfa15] blender-v3.0-release: Fix T92631: Fix negative thickness regression in complex solidify

Henrik Dick noreply at git.blender.org
Mon Nov 22 15:34:06 CET 2021


Commit: 819b9bdfa156082f6778337909cea9ad0c60d84d
Author: Henrik Dick
Date:   Mon Nov 22 09:33:49 2021 -0500
Branches: blender-v3.0-release
https://developer.blender.org/rB819b9bdfa156082f6778337909cea9ad0c60d84d

Fix T92631: Fix negative thickness regression in complex solidify

This regression was introduced by D11832, but there was problems before
that as well. I seem to have missed it in review. See the differential
revision for a screenshot of the difference.

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

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

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

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

diff --git a/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c b/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c
index d4aaefcfe05..0cc1627afcd 100644
--- a/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c
+++ b/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c
@@ -74,6 +74,7 @@ static float angle_signed_on_axis_normalized_v3v3_v3(const float n[3],
 static float clamp_nonzero(const float value, const float epsilon)
 {
   BLI_assert(!(epsilon < 0.0f));
+  /* Return closest value with `abs(value) >= epsilon`. */
   if (value < 0.0f) {
     return min_ff(value, -epsilon);
   }
@@ -171,15 +172,22 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData *md,
 
   float(*poly_nors)[3] = NULL;
 
+  /* #ofs_front and #ofs_back are the offset from the original
+   * surface along the normal, where #oft_front is along the positive
+   * and #oft_back is along the negative normal. */
   const float ofs_front = (smd->offset_fac + 1.0f) * 0.5f * smd->offset;
   const float ofs_back = ofs_front - smd->offset * smd->offset_fac;
-  const float ofs_front_clamped = clamp_nonzero(smd->offset > 0 ? ofs_front : ofs_back, 1e-5f);
-  const float ofs_back_clamped = clamp_nonzero(smd->offset > 0 ? ofs_back : ofs_front, 1e-5f);
+  /* #ofs_front_clamped and #ofs_back_clamped are the same as
+   * #ofs_front and #ofs_back, but never zero. */
+  const float ofs_front_clamped = clamp_nonzero(ofs_front, 1e-5f);
+  const float ofs_back_clamped = clamp_nonzero(ofs_back, 1e-5f);
   const float offset_fac_vg = smd->offset_fac_vg;
   const float offset_fac_vg_inv = 1.0f - smd->offset_fac_vg;
   const float offset = fabsf(smd->offset) * smd->offset_clamp;
   const bool do_angle_clamp = smd->flag & MOD_SOLIDIFY_OFFSET_ANGLE_CLAMP;
-  const bool do_flip = (smd->flag & MOD_SOLIDIFY_FLIP) != 0;
+  /* #do_flip, flips the normals of the result. This is inverted if negative thickness
+   * is used, since simple soldify with negative thickness keeps the faces facing outside. */
+  const bool do_flip = ((smd->flag & MOD_SOLIDIFY_FLIP) != 0) == (smd->offset > 0);
   const bool do_rim = smd->flag & MOD_SOLIDIFY_RIM;
   const bool do_shell = ((smd->flag & MOD_SOLIDIFY_RIM) && (smd->flag & MOD_SOLIDIFY_NOSHELL)) ==
                         0;



More information about the Bf-blender-cvs mailing list