Fix: Remove unsupported data types in extrude and split edges nodes
The extrude node resizes an existing mesh, but doesn't initialize new data for most non-generic data types like shape keys or freestyle tags, or custom normals. The split edges node doesn't process some similar vertex data too. In the future this data can become generic attributes, or it can be supported in the nodes anyway. But now the new data is un-initialized after being allocated. Fixes #106926
This commit is contained in:
@@ -28,6 +28,11 @@ static void copy_to_new_verts(MutableSpan<T> data, const Span<int> new_to_old_ve
|
||||
|
||||
static void add_new_vertices(Mesh &mesh, const Span<int> new_to_old_verts_map)
|
||||
{
|
||||
/* These types aren't supported for interpolation below. */
|
||||
CustomData_free_layers(&mesh.vdata, CD_BWEIGHT, mesh.totvert);
|
||||
CustomData_free_layers(&mesh.vdata, CD_SHAPEKEY, mesh.totvert);
|
||||
CustomData_free_layers(&mesh.vdata, CD_CLOTH_ORCO, mesh.totvert);
|
||||
CustomData_free_layers(&mesh.vdata, CD_MVERT_SKIN, mesh.totvert);
|
||||
CustomData_realloc(&mesh.vdata, mesh.totvert, mesh.totvert + new_to_old_verts_map.size());
|
||||
mesh.totvert += new_to_old_verts_map.size();
|
||||
|
||||
|
||||
@@ -94,17 +94,27 @@ static void expand_mesh(Mesh &mesh,
|
||||
const int poly_expand,
|
||||
const int loop_expand)
|
||||
{
|
||||
/* Remove types that aren't supported for interpolation in this node. */
|
||||
if (vert_expand != 0) {
|
||||
CustomData_free_layers(&mesh.vdata, CD_ORCO, mesh.totvert);
|
||||
CustomData_free_layers(&mesh.vdata, CD_BWEIGHT, mesh.totvert);
|
||||
CustomData_free_layers(&mesh.vdata, CD_SHAPEKEY, mesh.totvert);
|
||||
CustomData_free_layers(&mesh.vdata, CD_CLOTH_ORCO, mesh.totvert);
|
||||
CustomData_free_layers(&mesh.vdata, CD_MVERT_SKIN, mesh.totvert);
|
||||
const int old_verts_num = mesh.totvert;
|
||||
mesh.totvert += vert_expand;
|
||||
CustomData_realloc(&mesh.vdata, old_verts_num, mesh.totvert);
|
||||
}
|
||||
if (edge_expand != 0) {
|
||||
CustomData_free_layers(&mesh.edata, CD_BWEIGHT, mesh.totedge);
|
||||
CustomData_free_layers(&mesh.edata, CD_FREESTYLE_EDGE, mesh.totedge);
|
||||
const int old_edges_num = mesh.totedge;
|
||||
mesh.totedge += edge_expand;
|
||||
CustomData_realloc(&mesh.edata, old_edges_num, mesh.totedge);
|
||||
}
|
||||
if (poly_expand != 0) {
|
||||
CustomData_free_layers(&mesh.pdata, CD_FACEMAP, mesh.totpoly);
|
||||
CustomData_free_layers(&mesh.pdata, CD_FREESTYLE_FACE, mesh.totpoly);
|
||||
const int old_polys_num = mesh.totpoly;
|
||||
mesh.totpoly += poly_expand;
|
||||
CustomData_realloc(&mesh.pdata, old_polys_num, mesh.totpoly);
|
||||
@@ -113,6 +123,13 @@ static void expand_mesh(Mesh &mesh,
|
||||
mesh.poly_offsets_for_write().last() = mesh.totloop + loop_expand;
|
||||
}
|
||||
if (loop_expand != 0) {
|
||||
CustomData_free_layers(&mesh.ldata, CD_NORMAL, mesh.totloop);
|
||||
CustomData_free_layers(&mesh.ldata, CD_MDISPS, mesh.totloop);
|
||||
CustomData_free_layers(&mesh.ldata, CD_TANGENT, mesh.totloop);
|
||||
CustomData_free_layers(&mesh.ldata, CD_PAINT_MASK, mesh.totloop);
|
||||
CustomData_free_layers(&mesh.ldata, CD_MLOOPTANGENT, mesh.totloop);
|
||||
CustomData_free_layers(&mesh.ldata, CD_GRID_PAINT_MASK, mesh.totloop);
|
||||
CustomData_free_layers(&mesh.ldata, CD_CUSTOMLOOPNORMAL, mesh.totloop);
|
||||
const int old_loops_num = mesh.totloop;
|
||||
mesh.totloop += loop_expand;
|
||||
CustomData_realloc(&mesh.ldata, old_loops_num, mesh.totloop);
|
||||
|
||||
Reference in New Issue
Block a user