[Bf-blender-cvs] [f0dc4d67e56] master: Geometry Nodes: support storing 2d vector attributes

Jacques Lucke noreply at git.blender.org
Wed Dec 14 16:46:39 CET 2022


Commit: f0dc4d67e56dbdd13feb6ae09d584974b8b567ad
Author: Jacques Lucke
Date:   Wed Dec 14 16:43:38 2022 +0100
Branches: master
https://developer.blender.org/rBf0dc4d67e56dbdd13feb6ae09d584974b8b567ad

Geometry Nodes: support storing 2d vector attributes

This allows choosing the 2d vector type in the Store Named Attribute
node. Similar to byte-colors, there is not a special socket type for this
(currently). In geometry nodes itself, vectors are all still 3d.

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

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

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

diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index 6d827cf757a..4a977f09884 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -2175,6 +2175,7 @@ static bool generic_attribute_type_supported(const EnumPropertyItem *item)
 {
   return ELEM(item->value,
               CD_PROP_FLOAT,
+              CD_PROP_FLOAT2,
               CD_PROP_FLOAT3,
               CD_PROP_COLOR,
               CD_PROP_BOOL,
@@ -2192,7 +2193,8 @@ static const EnumPropertyItem *rna_GeometryNodeAttributeType_type_itemf(bContext
 
 static bool generic_attribute_type_supported_with_socket(const EnumPropertyItem *item)
 {
-  return generic_attribute_type_supported(item) && !ELEM(item->value, CD_PROP_BYTE_COLOR);
+  return generic_attribute_type_supported(item) &&
+         !ELEM(item->value, CD_PROP_BYTE_COLOR, CD_PROP_FLOAT2);
 }
 static const EnumPropertyItem *rna_GeometryNodeAttributeType_type_with_socket_itemf(
     bContext *UNUSED(C), PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free)
diff --git a/source/blender/nodes/geometry/nodes/node_geo_store_named_attribute.cc b/source/blender/nodes/geometry/nodes/node_geo_store_named_attribute.cc
index 50f066a647c..4970a926445 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_store_named_attribute.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_store_named_attribute.cc
@@ -59,7 +59,7 @@ static void node_update(bNodeTree *ntree, bNode *node)
   bNodeSocket *socket_boolean = socket_color4f->next;
   bNodeSocket *socket_int32 = socket_boolean->next;
 
-  nodeSetSocketAvailability(ntree, socket_vector, data_type == CD_PROP_FLOAT3);
+  nodeSetSocketAvailability(ntree, socket_vector, ELEM(data_type, CD_PROP_FLOAT2, CD_PROP_FLOAT3));
   nodeSetSocketAvailability(ntree, socket_float, data_type == CD_PROP_FLOAT);
   nodeSetSocketAvailability(
       ntree, socket_color4f, ELEM(data_type, CD_PROP_COLOR, CD_PROP_BYTE_COLOR));
@@ -113,6 +113,11 @@ static void node_geo_exec(GeoNodeExecParams params)
     case CD_PROP_FLOAT:
       field = params.get_input<Field<float>>("Value_Float");
       break;
+    case CD_PROP_FLOAT2: {
+      field = params.get_input<Field<float3>>("Value_Vector");
+      field = bke::get_implicit_type_conversions().try_convert(field, CPPType::get<float2>());
+      break;
+    }
     case CD_PROP_FLOAT3:
       field = params.get_input<Field<float3>>("Value_Vector");
       break;



More information about the Bf-blender-cvs mailing list