From 51cdf665abd2bd5ef8a0a588d69741da77fcafba Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Mon, 18 Mar 2024 21:43:22 +0100 Subject: [PATCH] Fix #119520: Auto smooth modifier added unnecessarily with bevel If the bevel "Harden Normals" option is on, custom normals will be generated. In that case, the automatic sharp edge tagging based on the angle shouldn't run. This PR extends the earlier fix to #116395 to handle this case and also extends the check to not just check the last modifier, which doesn't work in this test file which has a collision modifier at the end. That makes sense anyway, since what we really care about is whether the evaluated mesh has custom normals or not. Pull Request: https://projects.blender.org/blender/blender/pulls/119638 --- .../blenkernel/intern/mesh_legacy_convert.cc | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/source/blender/blenkernel/intern/mesh_legacy_convert.cc b/source/blender/blenkernel/intern/mesh_legacy_convert.cc index e66fee30fc3..bbe66337c79 100644 --- a/source/blender/blenkernel/intern/mesh_legacy_convert.cc +++ b/source/blender/blenkernel/intern/mesh_legacy_convert.cc @@ -2418,6 +2418,12 @@ void BKE_main_mesh_legacy_convert_auto_smooth(Main &bmain) if (ELEM(md->type, eModifierType_WeightedNormal, eModifierType_NormalEdit)) { has_custom_normals = true; } + if (md->type == eModifierType_Bevel) { + BevelModifierData *bmd = reinterpret_cast(md); + if (bmd->flags & MOD_BEVEL_HARDEN_NORMALS) { + has_custom_normals = true; + } + } if (md->type == eModifierType_WeightedNormal) { WeightedNormalModifierData *nmd = reinterpret_cast(md); if ((nmd->flag & MOD_WEIGHTEDNORMAL_KEEP_SHARP) != 0) { @@ -2430,13 +2436,11 @@ void BKE_main_mesh_legacy_convert_auto_smooth(Main &bmain) /* Some modifiers always generate custom normals which disabled sharp edge tagging, making * adding a modifier at the end unnecessary. Conceptually this is similar to checking if the * evaluated mesh had custom normals. */ - ModifierData *last_md = static_cast(object->modifiers.last); - if (last_md) { - if (ELEM(last_md->type, eModifierType_WeightedNormal, eModifierType_NormalEdit)) { - continue; - } + if (has_custom_normals) { + continue; } + ModifierData *last_md = static_cast(object->modifiers.last); ModifierData *new_md = create_auto_smooth_modifier(*object, add_node_group, angle); if (last_md && last_md->type == eModifierType_Subsurf && has_custom_normals && (reinterpret_cast(last_md)->flags &