[Bf-blender-cvs] [76f38d19ef9] temp-geometry-nodes-mix-attributes: rename sockets
Jacques Lucke
noreply at git.blender.org
Wed Dec 9 15:03:31 CET 2020
Commit: 76f38d19ef93d5aa6929c59502ce0469e4e7bc20
Author: Jacques Lucke
Date: Wed Dec 9 14:43:47 2020 +0100
Branches: temp-geometry-nodes-mix-attributes
https://developer.blender.org/rB76f38d19ef93d5aa6929c59502ce0469e4e7bc20
rename sockets
===================================================================
M source/blender/editors/space_node/drawnode.c
M source/blender/nodes/geometry/nodes/node_geo_attribute_mix.cc
===================================================================
diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c
index 6315c7c067a..068ea603a49 100644
--- a/source/blender/editors/space_node/drawnode.c
+++ b/source/blender/editors/space_node/drawnode.c
@@ -3188,9 +3188,9 @@ static void node_geometry_buts_attribute_mix(uiLayout *layout,
{
uiItemR(layout, ptr, "blend_type", DEFAULT_FLAGS, "", ICON_NONE);
uiLayout *col = uiLayoutColumn(layout, false);
- uiItemR(col, ptr, "input_type_factor", DEFAULT_FLAGS, IFACE_("Type Factor"), ICON_NONE);
- uiItemR(col, ptr, "input_type_a", DEFAULT_FLAGS, IFACE_("Type A"), ICON_NONE);
- uiItemR(col, ptr, "input_type_b", DEFAULT_FLAGS, IFACE_("Type B"), ICON_NONE);
+ uiItemR(col, ptr, "input_type_factor", DEFAULT_FLAGS, IFACE_("Factor"), ICON_NONE);
+ uiItemR(col, ptr, "input_type_a", DEFAULT_FLAGS, IFACE_("A"), ICON_NONE);
+ uiItemR(col, ptr, "input_type_b", DEFAULT_FLAGS, IFACE_("B"), ICON_NONE);
}
static void node_geometry_set_butfunc(bNodeType *ntype)
diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_mix.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_mix.cc
index b2075f9d8f7..259453a4a1d 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_attribute_mix.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_mix.cc
@@ -22,14 +22,14 @@ static bNodeSocketTemplate geo_node_attribute_mix_in[] = {
{SOCK_GEOMETRY, N_("Geometry")},
{SOCK_STRING, N_("Factor")},
{SOCK_FLOAT, N_("Factor"), 0.5, 0.0, 0.0, 0.0, 0.0, 1.0, PROP_FACTOR},
- {SOCK_STRING, N_("Attribute A")},
- {SOCK_FLOAT, N_("Attribute A"), 0.0, 0.0, 0.0, 0.0, -FLT_MAX, FLT_MAX},
- {SOCK_VECTOR, N_("Attribute A"), 0.0, 0.0, 0.0, 0.0, -FLT_MAX, FLT_MAX},
- {SOCK_RGBA, N_("Attribute A"), 0.5, 0.5, 0.5, 1.0},
- {SOCK_STRING, N_("Attribute B")},
- {SOCK_FLOAT, N_("Attribute B"), 0.0, 0.0, 0.0, 0.0, -FLT_MAX, FLT_MAX},
- {SOCK_VECTOR, N_("Attribute B"), 0.0, 0.0, 0.0, 0.0, -FLT_MAX, FLT_MAX},
- {SOCK_RGBA, N_("Attribute B"), 0.5, 0.5, 0.5, 1.0},
+ {SOCK_STRING, N_("A")},
+ {SOCK_FLOAT, N_("A"), 0.0, 0.0, 0.0, 0.0, -FLT_MAX, FLT_MAX},
+ {SOCK_VECTOR, N_("A"), 0.0, 0.0, 0.0, 0.0, -FLT_MAX, FLT_MAX},
+ {SOCK_RGBA, N_("A"), 0.5, 0.5, 0.5, 1.0},
+ {SOCK_STRING, N_("B")},
+ {SOCK_FLOAT, N_("B"), 0.0, 0.0, 0.0, 0.0, -FLT_MAX, FLT_MAX},
+ {SOCK_VECTOR, N_("B"), 0.0, 0.0, 0.0, 0.0, -FLT_MAX, FLT_MAX},
+ {SOCK_RGBA, N_("B"), 0.5, 0.5, 0.5, 1.0},
{SOCK_STRING, N_("Result")},
{-1, ""},
};
@@ -94,7 +94,7 @@ static ReadAttributePtr get_input_attribute(const GeometryComponent &component,
const GeoNodeExecParams ¶ms,
const AttributeDomain result_domain,
const CustomDataType result_type,
- const char *prefix)
+ const StringRef name)
{
const bNode &node = params.node();
const bNodeSocket *found_socket = nullptr;
@@ -102,7 +102,7 @@ static ReadAttributePtr get_input_attribute(const GeometryComponent &component,
if ((socket->flag & SOCK_UNAVAIL) != 0) {
continue;
}
- if (BLI_str_startswith(socket->name, prefix)) {
+ if (name == socket->name) {
found_socket = socket;
break;
}
@@ -163,10 +163,10 @@ static void attribute_mix_calc(GeometryComponent &component, const GeoNodeExecPa
}();
ReadAttributePtr attribute_a = get_input_attribute(
- component, params, result_domain, result_type, "Attribute A");
+ component, params, result_domain, result_type, "A");
ReadAttributePtr attribute_b = get_input_attribute(
- component, params, result_domain, result_type, "Attribute B");
+ component, params, result_domain, result_type, "B");
if (result_type == CD_PROP_FLOAT) {
FloatReadAttribute attribute_a_float = std::move(attribute_a);
@@ -226,12 +226,12 @@ static void geo_node_attribute_mix_init(bNodeTree *UNUSED(ntree), bNode *node)
}
static void update_attribute_input_socket_availabilities(bNode &node,
- const char *prefix,
+ const StringRef name,
const uint8_t mode)
{
const GeometryNodeAttributeInputMode mode_ = (GeometryNodeAttributeInputMode)mode;
LISTBASE_FOREACH (bNodeSocket *, socket, &node.inputs) {
- if (BLI_str_startswith(socket->name, prefix)) {
+ if (name == socket->name) {
const bool is_available =
((socket->type == SOCK_STRING && mode_ == GEO_NODE_ATTRIBUTE_INPUT__ATTRIBUTE) ||
(socket->type == SOCK_FLOAT && mode_ == GEO_NODE_ATTRIBUTE_INPUT__FLOAT) ||
@@ -246,8 +246,8 @@ static void geo_node_attribute_mix_update(bNodeTree *UNUSED(ntree), bNode *node)
{
NodeAttributeMix *node_storage = (NodeAttributeMix *)node->storage;
update_attribute_input_socket_availabilities(*node, "Factor", node_storage->input_type_factor);
- update_attribute_input_socket_availabilities(*node, "Attribute A", node_storage->input_type_a);
- update_attribute_input_socket_availabilities(*node, "Attribute B", node_storage->input_type_b);
+ update_attribute_input_socket_availabilities(*node, "A", node_storage->input_type_a);
+ update_attribute_input_socket_availabilities(*node, "B", node_storage->input_type_b);
}
} // namespace blender::nodes
More information about the Bf-blender-cvs
mailing list