Fix T95479: geometry nodes crash with cage display
Differential Revision: https://developer.blender.org/D14225
This commit is contained in:
parent
6883c47bb5
commit
7935d3668a
Notes:
blender-bot
2023-02-13 23:39:48 +01:00
Referenced by issue #95479, GN mesh to curve to mesh causes hard crash with cage display
|
@ -1227,8 +1227,34 @@ static void modifyGeometry(ModifierData *md,
|
|||
return;
|
||||
}
|
||||
|
||||
bool use_orig_index_verts = false;
|
||||
bool use_orig_index_edges = false;
|
||||
bool use_orig_index_polys = false;
|
||||
if (geometry_set.has_mesh()) {
|
||||
const Mesh &mesh = *geometry_set.get_mesh_for_read();
|
||||
use_orig_index_verts = CustomData_has_layer(&mesh.vdata, CD_ORIGINDEX);
|
||||
use_orig_index_edges = CustomData_has_layer(&mesh.edata, CD_ORIGINDEX);
|
||||
use_orig_index_polys = CustomData_has_layer(&mesh.pdata, CD_ORIGINDEX);
|
||||
}
|
||||
|
||||
geometry_set = compute_geometry(
|
||||
tree, input_nodes, output_node, std::move(geometry_set), nmd, ctx);
|
||||
|
||||
if (geometry_set.has_mesh()) {
|
||||
/* Add #CD_ORIGINDEX layers if they don't exist already. This is required because the
|
||||
* #eModifierTypeFlag_SupportsMapping flag is set. If the layers did not exist before, it is
|
||||
* assumed that the output mesh does not have a mapping to the original mesh. */
|
||||
Mesh &mesh = *geometry_set.get_mesh_for_write();
|
||||
if (use_orig_index_verts) {
|
||||
CustomData_add_layer(&mesh.vdata, CD_ORIGINDEX, CD_DEFAULT, nullptr, mesh.totvert);
|
||||
}
|
||||
if (use_orig_index_edges) {
|
||||
CustomData_add_layer(&mesh.edata, CD_ORIGINDEX, CD_DEFAULT, nullptr, mesh.totedge);
|
||||
}
|
||||
if (use_orig_index_polys) {
|
||||
CustomData_add_layer(&mesh.pdata, CD_ORIGINDEX, CD_DEFAULT, nullptr, mesh.totpoly);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh)
|
||||
|
|
Loading…
Reference in New Issue