Mesh: Replace auto smooth with node group #108014

Merged
Hans Goudey merged 149 commits from HooglyBoogly/blender:refactor-mesh-corner-normals-lazy into main 2023-10-20 16:54:20 +02:00
4 changed files with 15 additions and 5 deletions
Showing only changes of commit c34b92f6d1 - Show all commits

View File

@ -198,9 +198,9 @@ class DATA_PT_normals(MeshButtonsPanel, Panel):
mesh = context.mesh
if mesh.has_custom_normals:
col.operator("mesh.customdata_custom_splitnormals_clear", icon='X')
layout.operator("mesh.customdata_custom_splitnormals_clear", icon='X')
else:
col.operator("mesh.customdata_custom_splitnormals_add", icon='ADD')
layout.operator("mesh.customdata_custom_splitnormals_add", icon='ADD')
class DATA_PT_texture_space(MeshButtonsPanel, Panel):

View File

@ -131,7 +131,17 @@ static void version_mesh_objects_replace_auto_smooth(Main &bmain)
STRNCPY(md->modifier.name, DATA_("Auto Smooth"));
BKE_modifier_unique_name(&object->modifiers, &md->modifier);
md->node_group = auto_smooth_node_tree;
BLI_addtail(&object->modifiers, md);
if (!BLI_listbase_is_empty(&object->modifiers) &&
static_cast<ModifierData *>(object->modifiers.last)->type == eModifierType_Subsurf)
{
/* Add the auto smooth node group before the last subdivision surface modifier if possible.
* Subdivision surface modifiers have special handling for interpolating face corner normals,
* and recalculating them afterwards isn't usually helpful and can be much slower. */
BLI_insertlinkbefore(&object->modifiers, object->modifiers.last, md);
}
else {
BLI_addtail(&object->modifiers, md);
}
md->settings.properties = bke::idprop::create_group("Nodes Modifier Settings").release();
IDProperty *angle_prop = bke::idprop::create(DATA_("Input_1"), mesh->smoothresh).release();

View File

@ -749,6 +749,7 @@ static int mesh_customdata_custom_splitnormals_add_exec(bContext *C, wmOperator
}
else {
CustomData_add_layer(&me->ldata, CD_CUSTOMLOOPNORMAL, CD_SET_DEFAULT, me->totloop);
me->runtime->corner_normals_dirty = true;
}
DEG_id_tag_update(&me->id, 0);

View File

@ -2451,8 +2451,7 @@ static void rna_def_mlooptri(BlenderRNA *brna)
RNA_def_property_ui_text(
prop,
"Split Normals",
"Local space unit length split normals vectors of the vertices of this triangle "
"(must be computed beforehand using calc_normals_split or calc_tangents)");
"Local space unit length split normal vectors of the face corners of this triangle");
prop = RNA_def_property(srna, "area", PROP_FLOAT, PROP_UNSIGNED);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);