Fix T98266: Crash with empty mesh boolean node

The output mesh can be null. Also reorganize the WITH_GMP
check to avoid compiling the rest of the node with GMP off.
This commit is contained in:
Hans Goudey 2022-05-20 10:10:46 +02:00
parent b8bd20d7e0
commit d4cdae29c1
Notes: blender-bot 2023-02-13 15:24:21 +01:00
Referenced by issue #99256, Regression: Meta balls segfaulting copy-to-selected
Referenced by issue #98266, Regression: Crash when removing mesh from Mesh Boolean in Geometry Nodes
1 changed files with 10 additions and 5 deletions

View File

@ -56,15 +56,11 @@ static void node_init(bNodeTree *UNUSED(tree), bNode *node)
static void node_geo_exec(GeoNodeExecParams params)
{
#ifdef WITH_GMP
GeometryNodeBooleanOperation operation = (GeometryNodeBooleanOperation)params.node().custom1;
const bool use_self = params.get_input<bool>("Self Intersection");
const bool hole_tolerant = params.get_input<bool>("Hole Tolerant");
#ifndef WITH_GMP
params.error_message_add(NodeWarningType::Error,
TIP_("Disabled, Blender was compiled without GMP"));
#endif
Vector<const Mesh *> meshes;
Vector<const float4x4 *> transforms;
@ -132,6 +128,10 @@ static void node_geo_exec(GeoNodeExecParams params)
use_self,
hole_tolerant,
operation);
if (!result) {
params.set_default_remaining_outputs();
return;
}
MEM_SAFE_FREE(result->mat);
result->mat = (Material **)MEM_malloc_arrayN(materials.size(), sizeof(Material *), __func__);
@ -139,6 +139,11 @@ static void node_geo_exec(GeoNodeExecParams params)
MutableSpan(result->mat, result->totcol).copy_from(materials);
params.set_output("Mesh", GeometrySet::create_with_mesh(result));
#else
params.error_message_add(NodeWarningType::Error,
TIP_("Disabled, Blender was compiled without GMP"));
params.set_default_remaining_outputs();
#endif
}
} // namespace blender::nodes::node_geo_boolean_cc