Geometry Nodes: Add more warnings for out of bounds parameters

Add warning(info) to nodes that don't work when an input value is
out of range. For example, the grid node doesn't work with Vertices X
or Verices Y less than 2.

These are purposefully added as "Info" warnings, because they don't
show in the modifier and they aren't printed to the terminal.

Differential Revision: https://developer.blender.org/D11923
This commit is contained in:
Eitan 2021-08-05 10:44:59 -05:00 committed by Hans Goudey
parent c15635bd8d
commit bd44e82b25
5 changed files with 15 additions and 0 deletions

View File

@ -211,6 +211,7 @@ static void geo_node_mesh_primitive_circle_exec(GeoNodeExecParams params)
const float radius = params.extract_input<float>("Radius");
const int verts_num = params.extract_input<int>("Vertices");
if (verts_num < 3) {
params.error_message_add(NodeWarningType::Info, TIP_("Vertices must be at least 3"));
params.set_output("Geometry", GeometrySet());
return;
}

View File

@ -551,6 +551,7 @@ static void geo_node_mesh_primitive_cone_exec(GeoNodeExecParams params)
const int verts_num = params.extract_input<int>("Vertices");
if (verts_num < 3) {
params.error_message_add(NodeWarningType::Info, TIP_("Vertices must be at least 3"));
params.set_output("Geometry", GeometrySet());
return;
}

View File

@ -70,6 +70,7 @@ static void geo_node_mesh_primitive_cylinder_exec(GeoNodeExecParams params)
const float depth = params.extract_input<float>("Depth");
const int verts_num = params.extract_input<int>("Vertices");
if (verts_num < 3) {
params.error_message_add(NodeWarningType::Info, TIP_("Vertices must be at least 3"));
params.set_output("Geometry", GeometrySet());
return;
}

View File

@ -162,6 +162,12 @@ static void geo_node_mesh_primitive_grid_exec(GeoNodeExecParams params)
const int verts_x = params.extract_input<int>("Vertices X");
const int verts_y = params.extract_input<int>("Vertices Y");
if (verts_x < 2 || verts_y < 2) {
if (verts_x < 2) {
params.error_message_add(NodeWarningType::Info, TIP_("Vertices X must be at least 2"));
}
if (verts_y < 2) {
params.error_message_add(NodeWarningType::Info, TIP_("Vertices Y must be at least 2"));
}
params.set_output("Geometry", GeometrySet());
return;
}

View File

@ -291,6 +291,12 @@ static void geo_node_mesh_primitive_uv_sphere_exec(GeoNodeExecParams params)
const int segments_num = params.extract_input<int>("Segments");
const int rings_num = params.extract_input<int>("Rings");
if (segments_num < 3 || rings_num < 2) {
if (segments_num < 3) {
params.error_message_add(NodeWarningType::Info, TIP_("Segments must be at least 3"));
}
if (rings_num < 3) {
params.error_message_add(NodeWarningType::Info, TIP_("Rings must be at least 3"));
}
params.set_output("Geometry", GeometrySet());
return;
}