diff options
author | Henrik Dick <weasel> | 2021-11-22 17:33:49 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2021-11-22 17:33:49 +0300 |
commit | 819b9bdfa156082f6778337909cea9ad0c60d84d (patch) | |
tree | e692a7e446026e0c5297d45a38bb08125d85c933 /source/blender/modifiers/intern | |
parent | 7b09213f2f9a677fc38f4e7466c4d14a58bab74f (diff) |
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
Diffstat (limited to 'source/blender/modifiers/intern')
-rw-r--r-- | source/blender/modifiers/intern/MOD_solidify_nonmanifold.c | 14 |
1 files changed, 11 insertions, 3 deletions
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; |