[Bf-blender-cvs] [2da0f3e523f] master: Geometry Nodes: Support integer type in the Attribute Fill Node

Hans Goudey noreply at git.blender.org
Wed Feb 17 07:01:41 CET 2021


Commit: 2da0f3e523f723743f73895941072b301edb596e
Author: Hans Goudey
Date:   Wed Feb 17 00:01:33 2021 -0600
Branches: master
https://developer.blender.org/rB2da0f3e523f723743f73895941072b301edb596e

Geometry Nodes: Support integer type in the Attribute Fill Node

This will be used by the material index attribute when it is added.

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

M	source/blender/makesrna/intern/rna_nodetree.c
M	source/blender/nodes/geometry/nodes/node_geo_attribute_fill.cc

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

diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index e72f50e813d..b372ff4c273 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -1931,7 +1931,8 @@ static void rna_GeometryNodeAttributeRandomize_data_type_update(Main *bmain,
 
 static bool attribute_fill_type_supported(const EnumPropertyItem *item)
 {
-  return ELEM(item->value, CD_PROP_FLOAT, CD_PROP_FLOAT3, CD_PROP_COLOR, CD_PROP_BOOL);
+  return ELEM(
+      item->value, CD_PROP_FLOAT, CD_PROP_FLOAT3, CD_PROP_COLOR, CD_PROP_BOOL, CD_PROP_INT32);
 }
 static const EnumPropertyItem *rna_GeometryNodeAttributeFill_type_itemf(bContext *UNUSED(C),
                                                                         PointerRNA *UNUSED(ptr),
diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_fill.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_fill.cc
index d2a7e40877f..e4cdd04b46b 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_attribute_fill.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_fill.cc
@@ -31,6 +31,7 @@ static bNodeSocketTemplate geo_node_attribute_fill_in[] = {
     {SOCK_FLOAT, N_("Value"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX},
     {SOCK_RGBA, N_("Value"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX},
     {SOCK_BOOLEAN, N_("Value"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX},
+    {SOCK_INT, N_("Value"), 0, 0, 0, 0, -10000000.0f, 10000000.0f},
     {-1, ""},
 };
 
@@ -56,6 +57,7 @@ static void geo_node_attribute_fill_update(bNodeTree *UNUSED(ntree), bNode *node
   bNodeSocket *socket_value_float = socket_value_vector->next;
   bNodeSocket *socket_value_color4f = socket_value_float->next;
   bNodeSocket *socket_value_boolean = socket_value_color4f->next;
+  bNodeSocket *socket_value_int32 = socket_value_boolean->next;
 
   const CustomDataType data_type = static_cast<CustomDataType>(node->custom1);
 
@@ -63,6 +65,7 @@ static void geo_node_attribute_fill_update(bNodeTree *UNUSED(ntree), bNode *node
   nodeSetSocketAvailability(socket_value_float, data_type == CD_PROP_FLOAT);
   nodeSetSocketAvailability(socket_value_color4f, data_type == CD_PROP_COLOR);
   nodeSetSocketAvailability(socket_value_boolean, data_type == CD_PROP_BOOL);
+  nodeSetSocketAvailability(socket_value_int32, data_type == CD_PROP_INT32);
 }
 
 namespace blender::nodes {
@@ -124,6 +127,11 @@ static void fill_attribute(GeometryComponent &component, const GeoNodeExecParams
       attribute_span.fill(value);
       break;
     }
+    case CD_PROP_INT32: {
+      const int value = params.get_input<int>("Value_004");
+      MutableSpan<int> attribute_span = attribute->get_span_for_write_only<int>();
+      attribute_span.fill(value);
+    }
     default:
       break;
   }



More information about the Bf-blender-cvs mailing list