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
3 changed files with 10 additions and 2 deletions
Showing only changes of commit 49d3dddae8 - Show all commits

View File

@ -37,6 +37,7 @@
#include "BKE_multires.hh"
#include "BKE_node.hh"
#include "BKE_node_runtime.hh"
#include "BKE_node_tree_update.h"
#include "BLT_translation.h"
@ -2178,6 +2179,7 @@ void BKE_main_mesh_legacy_convert_auto_smooth(Main &bmain)
}
if (!auto_smooth_node_tree) {
auto_smooth_node_tree = add_auto_smooth_node_tree(bmain);
BKE_ntree_update_main_tree(&bmain, auto_smooth_node_tree, nullptr);
}
auto *md = reinterpret_cast<NodesModifierData *>(BKE_modifier_new(eModifierType_Nodes));
STRNCPY(md->modifier.name, DATA_("Auto Smooth"));
@ -2197,7 +2199,13 @@ void BKE_main_mesh_legacy_convert_auto_smooth(Main &bmain)
md->settings.properties = bke::idprop::create_group("Nodes Modifier Settings").release();

MOD_nodes_update_interface(object, md);?

`MOD_nodes_update_interface(object, md);`?

Maybe. I'd rather not bring in another "MOD" include to the blenkernel though, theoretically the dependency is supposed to be in the other direction. I'm investigating just importing the asset here anyway, that might simplify things.

Maybe. I'd rather not bring in another "MOD" include to the blenkernel though, theoretically the dependency is supposed to be in the other direction. I'm investigating just importing the asset here anyway, that might simplify things.
IDProperty *angle_prop = bke::idprop::create(DATA_("Input_1"), mesh->smoothresh).release();
auto *ui_data = reinterpret_cast<IDPropertyUIDataFloat *>(IDP_ui_data_ensure(angle_prop));
ui_data->base.rna_subtype = PROP_ANGLE;
IDP_AddToGroup(md->settings.properties, angle_prop);
IDP_AddToGroup(md->settings.properties,
bke::idprop::create(DATA_("Input_1_use_attribute"), 0).release());
IDP_AddToGroup(md->settings.properties,
bke::idprop::create(DATA_("Input_1_attribute_name"), "").release());
}
}

View File

@ -527,7 +527,7 @@ void do_versions_after_setup(Main *new_bmain, BlendFileReadReport *reports)
BKE_lib_override_library_main_hierarchy_root_ensure(new_bmain);
}
if (!blendfile_or_libraries_versions_atleast(new_bmain, 400, 16)) {
if (!blendfile_or_libraries_versions_atleast(new_bmain, 400, 17)) {
BKE_main_mesh_legacy_convert_auto_smooth(*new_bmain);
}
}

View File

@ -343,7 +343,7 @@ void mesh_render_data_update_normals(MeshRenderData &mr, const eMRDataType data_
mr.face_normals = mr.me->face_normals();
}
if (((data_flag & MR_DATA_LOOP_NOR) &&
mr.me->normal_domain_all_info() == ATTR_DOMAIN_CORNER) ||
ELEM(mr.me->normal_domain_all_info(), ATTR_DOMAIN_CORNER, ATTR_DOMAIN_FACE)) ||
(data_flag & MR_DATA_TAN_LOOP_NOR))
{
mr.loop_normals = mr.me->corner_normals();