[Bf-blender-cvs] [d216ac4d21c] soc-2021-curve-fillet: Switched radius mode to take a field input

dilithjay noreply at git.blender.org
Mon Sep 20 06:20:52 CEST 2021


Commit: d216ac4d21c341ef92637f78121d85d01349601c
Author: dilithjay
Date:   Tue Sep 14 14:30:48 2021 +0530
Branches: soc-2021-curve-fillet
https://developer.blender.org/rBd216ac4d21c341ef92637f78121d85d01349601c

Switched radius mode to take a field input

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

M	source/blender/makesdna/DNA_node_types.h
M	source/blender/makesrna/intern/rna_nodetree.c
M	source/blender/nodes/geometry/nodes/node_geo_curve_fillet.cc

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

diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h
index 844e790f1ff..9cbdacb038b 100644
--- a/source/blender/makesdna/DNA_node_types.h
+++ b/source/blender/makesdna/DNA_node_types.h
@@ -1414,8 +1414,6 @@ typedef struct NodeGeometryCurveSubdivide {
 typedef struct NodeGeometryCurveFillet {
   /* GeometryNodeCurveFilletMode. */
   uint8_t mode;
-  /* GeometryNodeCurveFilletRadiusMode. */
-  uint8_t radius_mode;
 } NodeGeometryCurveFillet;
 
 typedef struct NodeGeometryCurveTrim {
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index 65081aceff2..3ca1f71bdde 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -10149,31 +10149,12 @@ static void def_geo_curve_fillet(StructRNA *srna)
       {0, NULL, 0, NULL, NULL},
   };
 
-  static EnumPropertyItem radius_mode_items[] = {
-      {GEO_NODE_ATTRIBUTE_INPUT_FLOAT,
-       "FLOAT",
-       0,
-       "Float",
-       "Define a common radius for all points."},
-      {GEO_NODE_ATTRIBUTE_INPUT_ATTRIBUTE,
-       "ATTRIBUTE",
-       0,
-       "Attribute",
-       "Specify radius based on an attribute"},
-      {0, NULL, 0, NULL, NULL},
-  };
-
   RNA_def_struct_sdna_from(srna, "NodeGeometryCurveFillet", "storage");
 
   prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
   RNA_def_property_enum_items(prop, mode_items);
   RNA_def_property_ui_text(prop, "Mode", "How to choose number of vertices on fillet");
   RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_socket_update");
-
-  prop = RNA_def_property(srna, "radius_mode", PROP_ENUM, PROP_NONE);
-  RNA_def_property_enum_items(prop, radius_mode_items);
-  RNA_def_property_ui_text(prop, "Radius Mode", "How the radius of the curvature is defined");
-  RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_socket_update");
 }
 
 static void def_geo_curve_to_points(StructRNA *srna)
diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_fillet.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_fillet.cc
index 2a8a12bae77..656e4400d2e 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_curve_fillet.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_curve_fillet.cc
@@ -36,7 +36,6 @@ static void geo_node_curve_fillet_declare(NodeDeclarationBuilder &b)
       .max(FLT_MAX)
       .subtype(PropertySubType::PROP_DISTANCE)
       .default_value(0.2f);
-  b.add_input<decl::String>("Radius");
   b.add_input<decl::Bool>("Limit Radius");
   b.add_output<decl::Geometry>("Curve");
 }
@@ -46,7 +45,6 @@ static void geo_node_curve_fillet_layout(uiLayout *layout, bContext *UNUSED(C),
   uiLayoutSetPropSep(layout, true);
   uiLayoutSetPropDecorate(layout, false);
   uiItemR(layout, ptr, "mode", 0, IFACE_("Mode"), ICON_NONE);
-  uiItemR(layout, ptr, "radius_mode", 0, IFACE_("Radius Mode"), ICON_NONE);
 }
 
 static void geo_node_curve_fillet_init(bNodeTree *UNUSED(tree), bNode *node)
@@ -55,8 +53,6 @@ static void geo_node_curve_fillet_init(bNodeTree *UNUSED(tree), bNode *node)
       sizeof(NodeGeometryCurveFillet), __func__);
 
   data->mode = GEO_NODE_CURVE_FILLET_BEZIER;
-  data->radius_mode = GEO_NODE_ATTRIBUTE_INPUT_FLOAT;
-
   node->storage = data;
 }
 
@@ -66,11 +62,11 @@ struct FilletParam {
   /* Number of points to be added. */
   GVArray_Typed<int> *counts;
 
-  /* Whether or not fillets are allowed to overlap. */
-  bool limit_radius;
-
   /* Radii for fillet arc at all vertices. */
   GVArray_Typed<float> *radii;
+
+  /* Whether or not fillets are allowed to overlap. */
+  bool limit_radius;
 };
 
 /* A data structure used to store fillet data about all vertices to be filleted. */
@@ -99,9 +95,6 @@ static void geo_node_curve_fillet_update(bNodeTree *UNUSED(ntree), bNode *node)
   bNodeSocket *poly_socket = ((bNodeSocket *)node->inputs.first)->next;
 
   nodeSetSocketAvailability(poly_socket, mode == GEO_NODE_CURVE_FILLET_POLY);
-
-  update_attribute_input_socket_availabilities(
-      *node, "Radius", (GeometryNodeAttributeInputMode)node_storage.radius_mode);
 }
 
 /* Function to get the center of a fillet. */
@@ -615,16 +608,15 @@ static void geo_node_fillet_exec(GeoNodeExecParams params)
 
   NodeGeometryCurveFillet &node_storage = *(NodeGeometryCurveFillet *)params.node().storage;
   const GeometryNodeCurveFilletMode mode = (GeometryNodeCurveFilletMode)node_storage.mode;
-  const GeometryNodeAttributeInputMode radius_mode = (GeometryNodeAttributeInputMode)
-                                                         node_storage.radius_mode;
   FilletParam fillet_param;
   fillet_param.mode = mode;
 
+  GeometryComponent &component = geometry_set.get_component_for_write(GEO_COMPONENT_TYPE_CURVE);
+  GeometryComponentFieldContext field_context{component, ATTR_DOMAIN_POINT};
+  const int domain_size = component.attribute_domain_size(ATTR_DOMAIN_POINT);
+
   if (mode == GEO_NODE_CURVE_FILLET_POLY) {
     Field<int> count_field = params.extract_input<Field<int>>("Count");
-    GeometryComponent &component = geometry_set.get_component_for_write(GEO_COMPONENT_TYPE_CURVE);
-    GeometryComponentFieldContext field_context{component, ATTR_DOMAIN_POINT};
-    const int domain_size = component.attribute_domain_size(ATTR_DOMAIN_POINT);
 
     fn::FieldEvaluator count_evaluator{field_context, domain_size};
     count_evaluator.add(count_field);
@@ -634,18 +626,21 @@ static void geo_node_fillet_exec(GeoNodeExecParams params)
     fillet_param.counts = &counts_array;
   }
 
-  fillet_param.limit_radius = params.extract_input<bool>("Limit Radius");
+  Field<float> radius_field = params.extract_input<Field<float>>("Radius");
+  fn::FieldEvaluator radius_evaluator{field_context, domain_size};
+  radius_evaluator.add(radius_field);
+  radius_evaluator.evaluate();
+  const GVArray &radius = radius_evaluator.get_evaluated(0);
+  GVArray_Typed<float> radius_array = GVArray_Typed<float>(radius);
+  fillet_param.radii = &radius_array;
 
-  GVArray_Typed<float> radii_array = params.get_input_attribute<float>(
-      "Radius", *geometry_set.get_component_for_read<CurveComponent>(), ATTR_DOMAIN_POINT, 0.0f);
+  fillet_param.limit_radius = params.extract_input<bool>("Limit Radius");
 
-  if (radii_array->is_single() && radii_array->get_internal_single() < 0) {
+  if (radius_array->is_single() && radius_array->get_internal_single() < 0) {
     params.set_output("Geometry", geometry_set);
     return;
   }
 
-  fillet_param.radii = &radii_array;
-
   const CurveEval &input_curve = *geometry_set.get_curve_for_read();
   std::unique_ptr<CurveEval> output_curve = fillet_curve(input_curve, fillet_param);



More information about the Bf-blender-cvs mailing list