[Bf-blender-cvs] [eb4614ae1d1] temp-geometry-nodes-attribute-domain-conversion: Add integer attribute support in some places
Hans Goudey
noreply at git.blender.org
Mon Jan 25 06:07:40 CET 2021
Commit: eb4614ae1d1f9810d214eace40c39d1e4c5d0fb2
Author: Hans Goudey
Date: Sat Jan 23 21:31:45 2021 -0600
Branches: temp-geometry-nodes-attribute-domain-conversion
https://developer.blender.org/rBeb4614ae1d1f9810d214eace40c39d1e4c5d0fb2
Add integer attribute support in some places
===================================================================
M source/blender/makesdna/DNA_node_types.h
M source/blender/makesrna/intern/rna_nodetree.c
M source/blender/nodes/geometry/node_geometry_util.cc
M source/blender/nodes/geometry/nodes/node_geo_attribute_fill.cc
M source/blender/nodes/intern/node_geometry_exec.cc
===================================================================
diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h
index 4dba856b87b..9145b57c4d0 100644
--- a/source/blender/makesdna/DNA_node_types.h
+++ b/source/blender/makesdna/DNA_node_types.h
@@ -1605,6 +1605,7 @@ typedef enum GeometryNodeAttributeInputMode {
GEO_NODE_ATTRIBUTE_INPUT_VECTOR = 2,
GEO_NODE_ATTRIBUTE_INPUT_COLOR = 3,
GEO_NODE_ATTRIBUTE_INPUT_BOOLEAN = 4,
+ GEO_NODE_ATTRIBUTE_INPUT_INT = 5,
} GeometryNodeAttributeInputMode;
typedef enum GeometryNodePointDistributeMethod {
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index 355b1360ab0..f58f3eca692 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -463,6 +463,10 @@ static const EnumPropertyItem rna_node_geometry_point_distribute_method_items[]
{ \
GEO_NODE_ATTRIBUTE_INPUT_BOOLEAN, "BOOLEAN", 0, "Boolean", "" \
}
+#define ITEM_INT32 \
+ { \
+ GEO_NODE_ATTRIBUTE_INPUT_INT, "INT32", 0, "Integer", "" \
+ }
/* Used in both runtime and static code. */
static const EnumPropertyItem rna_node_geometry_attribute_input_type_items_any[] = {
@@ -471,6 +475,7 @@ static const EnumPropertyItem rna_node_geometry_attribute_input_type_items_any[]
ITEM_VECTOR,
ITEM_COLOR,
ITEM_BOOLEAN,
+ ITEM_INT32,
{0, NULL, 0, NULL, NULL},
};
@@ -491,6 +496,16 @@ static const EnumPropertyItem rna_node_geometry_attribute_input_type_items_no_bo
ITEM_FLOAT,
ITEM_VECTOR,
ITEM_COLOR,
+ ITEM_INT32,
+ {0, NULL, 0, NULL, NULL},
+};
+
+static const EnumPropertyItem rna_node_geometry_attribute_input_type_items_no_attribute[] = {
+ ITEM_FLOAT,
+ ITEM_VECTOR,
+ ITEM_COLOR,
+ ITEM_BOOLEAN,
+ ITEM_INT32,
{0, NULL, 0, NULL, NULL},
};
@@ -1958,7 +1973,8 @@ static const EnumPropertyItem *rna_GeometryNodeAttributeRandom_domain_itemf(
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/node_geometry_util.cc b/source/blender/nodes/geometry/node_geometry_util.cc
index 53af6073793..36a628643ba 100644
--- a/source/blender/nodes/geometry/node_geometry_util.cc
+++ b/source/blender/nodes/geometry/node_geometry_util.cc
@@ -39,7 +39,9 @@ void update_attribute_input_socket_availabilities(bNode &node,
((socket->type == SOCK_STRING && mode_ == GEO_NODE_ATTRIBUTE_INPUT_ATTRIBUTE) ||
(socket->type == SOCK_FLOAT && mode_ == GEO_NODE_ATTRIBUTE_INPUT_FLOAT) ||
(socket->type == SOCK_VECTOR && mode_ == GEO_NODE_ATTRIBUTE_INPUT_VECTOR) ||
- (socket->type == SOCK_RGBA && mode_ == GEO_NODE_ATTRIBUTE_INPUT_COLOR));
+ (socket->type == SOCK_RGBA && mode_ == GEO_NODE_ATTRIBUTE_INPUT_COLOR) ||
+ (socket->type == SOCK_BOOLEAN && mode_ == GEO_NODE_ATTRIBUTE_INPUT_BOOLEAN) ||
+ (socket->type == SOCK_INT && mode_ == GEO_NODE_ATTRIBUTE_INPUT_INT));
nodeSetSocketAvailability(socket, socket_is_available);
}
}
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 9cec4070f89..6b3150c7387 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_attribute_fill.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_fill.cc
@@ -27,7 +27,8 @@ static bNodeSocketTemplate geo_node_attribute_fill_in[] = {
{SOCK_VECTOR, N_("Value"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX},
{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_BOOLEAN, N_("Value")},
+ {SOCK_INT, N_("Value"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX},
{-1, ""},
};
@@ -99,6 +100,12 @@ 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);
+ break;
+ }
default:
break;
}
diff --git a/source/blender/nodes/intern/node_geometry_exec.cc b/source/blender/nodes/intern/node_geometry_exec.cc
index eef2c6c9125..7eed67fb935 100644
--- a/source/blender/nodes/intern/node_geometry_exec.cc
+++ b/source/blender/nodes/intern/node_geometry_exec.cc
@@ -64,6 +64,11 @@ ReadAttributePtr GeoNodeExecParams::get_input_attribute(const StringRef name,
return component.attribute_get_constant_for_read_converted(
domain, CD_PROP_COLOR, type, &value);
}
+ if (found_socket->type == SOCK_INT) {
+ const int value = this->get_input<int>(found_socket->identifier);
+ return component.attribute_get_constant_for_read_converted(
+ domain, CD_PROP_INT32, type, &value);
+ }
BLI_assert(false);
return component.attribute_get_constant_for_read(domain, type, default_value);
}
More information about the Bf-blender-cvs
mailing list