[Bf-blender-cvs] [bd44e82b255] master: Geometry Nodes: Add more warnings for out of bounds parameters

Eitan noreply at git.blender.org
Thu Aug 5 17:45:14 CEST 2021


Commit: bd44e82b255a231242a1b7ddd59cee7830af20ea
Author: Eitan
Date:   Thu Aug 5 10:44:59 2021 -0500
Branches: master
https://developer.blender.org/rBbd44e82b255a231242a1b7ddd59cee7830af20ea

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

===================================================================

M	source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_circle.cc
M	source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cone.cc
M	source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cylinder.cc
M	source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_grid.cc
M	source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_uv_sphere.cc

===================================================================

diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_circle.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_circle.cc
index 667e1c931bd..96c6f073ab3 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_circle.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_circle.cc
@@ -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;
   }
diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cone.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cone.cc
index d46ea2d2050..790a518e584 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cone.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cone.cc
@@ -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;
   }
diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cylinder.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cylinder.cc
index 1767f765da4..b40cb478b03 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cylinder.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cylinder.cc
@@ -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;
   }
diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_grid.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_grid.cc
index ac2f5a23a4d..7a97ae8e318 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_grid.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_grid.cc
@@ -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;
   }
diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_uv_sphere.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_uv_sphere.cc
index 599c59e4a2e..fe456dc4564 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_uv_sphere.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_uv_sphere.cc
@@ -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;
   }



More information about the Bf-blender-cvs mailing list