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
5 changed files with 21 additions and 6 deletions
Showing only changes of commit 2faacfa6dd - Show all commits

View File

@ -76,6 +76,9 @@ void BKE_mesh_tag_topology_changed(struct Mesh *mesh);
*/
void BKE_mesh_tag_edges_split(struct Mesh *mesh);
/** Call when changing "sharp_face" or "sharp_edge" data. */
void BKE_mesh_tag_sharpness_changed(struct Mesh *mesh);
/**
* Call when face vertex order has changed but positions and faces haven't changed
*/

View File

@ -858,10 +858,10 @@ static void tag_component_positions_changed(void *owner)
}
}
static void tag_component_corner_normals_dirty(void *owner)
static void tag_component_sharpness_changed(void *owner)
{
if (Mesh *mesh = static_cast<Mesh *>(owner)) {
mesh->runtime->corner_normals_cache.tag_dirty();
BKE_mesh_tag_sharpness_changed(mesh);
}
}
@ -1187,7 +1187,7 @@ static ComponentAttributeProviders create_attribute_providers_for_mesh()
BuiltinAttributeProvider::Creatable,
BuiltinAttributeProvider::Deletable,
face_access,
tag_component_corner_normals_dirty);
tag_component_sharpness_changed);
static BuiltinCustomDataLayerProvider sharp_edge("sharp_edge",
ATTR_DOMAIN_EDGE,
@ -1196,7 +1196,7 @@ static ComponentAttributeProviders create_attribute_providers_for_mesh()
BuiltinAttributeProvider::Creatable,
BuiltinAttributeProvider::Deletable,
edge_access,
tag_component_corner_normals_dirty);
tag_component_sharpness_changed);
static VertexGroupsAttributeProvider vertex_groups;
static CustomDataAttributeProvider corner_custom_data(ATTR_DOMAIN_CORNER, corner_access);

View File

@ -355,6 +355,11 @@ void BKE_mesh_tag_edges_split(Mesh *mesh)
}
}
void BKE_mesh_tag_sharpness_changed(Mesh *mesh)
{
mesh->runtime->corner_normals_cache.tag_dirty();
}
void BKE_mesh_tag_face_winding_changed(Mesh *mesh)
{
mesh->runtime->vert_normals_cache.tag_dirty();

View File

@ -582,7 +582,10 @@ static void rna_MeshPolygon_use_smooth_set(PointerRNA *ptr, bool value)
&mesh->face_data, CD_PROP_BOOL, CD_SET_DEFAULT, mesh->faces_num, "sharp_face"));
}
const int index = rna_MeshPolygon_index_get(ptr);
sharp_faces[index] = !value;
if (value != sharp_faces[index]) {
sharp_faces[index] = value;
BKE_mesh_tag_sharpness_changed(mesh);
}
}
static bool rna_MeshPolygon_select_get(PointerRNA *ptr)
@ -1368,7 +1371,10 @@ static void rna_MeshEdge_use_edge_sharp_set(PointerRNA *ptr, bool value)
&mesh->edge_data, CD_PROP_BOOL, CD_SET_DEFAULT, mesh->totedge, "sharp_edge"));
}
const int index = rna_MeshEdge_index_get(ptr);
sharp_edge[index] = value;
if (value != sharp_edge[index]) {
sharp_edge[index] = value;
BKE_mesh_tag_sharpness_changed(mesh);
}
}
static bool rna_MeshEdge_use_seam_get(PointerRNA *ptr)

View File

@ -178,6 +178,7 @@ static void rna_Mesh_update(Mesh *mesh,
mesh->runtime->vert_normals_cache.tag_dirty();
mesh->runtime->face_normals_cache.tag_dirty();
mesh->runtime->corner_normals_cache.tag_dirty();
DEG_id_tag_update(&mesh->id, 0);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, mesh);