diff options
author | Charlie Jolly <charlie> | 2021-07-27 16:17:09 +0300 |
---|---|---|
committer | Charlie Jolly <mistajolly@gmail.com> | 2021-07-27 16:34:08 +0300 |
commit | 766e67e55db4d5235f66ec8e320e23cd0def6de9 (patch) | |
tree | 52e517ac371943a283751a59630e205cf054f598 /source/blender/nodes/geometry | |
parent | 07688ca2d2d6af5ec2de4905fafb2b5b65733afe (diff) |
Geometry Nodes: Add node labels to Attribute maths nodes
This adds the operator name to the node label which is consistent with the shading nodes.
The vector node has `Vector` as a prefix.
The Attribute nodes already have a different coloured header.
The same label is used when collapsing nodes, this helps readability.
Reviewed By: pablovazquez
Differential Revision: https://developer.blender.org/D10749
Diffstat (limited to 'source/blender/nodes/geometry')
-rw-r--r-- | source/blender/nodes/geometry/nodes/node_geo_attribute_math.cc | 14 | ||||
-rw-r--r-- | source/blender/nodes/geometry/nodes/node_geo_attribute_vector_math.cc | 17 |
2 files changed, 31 insertions, 0 deletions
diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_math.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_math.cc index 9309863f4e9..368c4025eb7 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_attribute_math.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_math.cc @@ -16,6 +16,8 @@ #include "BLI_task.hh" +#include "RNA_enum_types.h" + #include "UI_interface.h" #include "UI_resources.h" @@ -132,6 +134,17 @@ static void geo_node_attribute_math_init(bNodeTree *UNUSED(tree), bNode *node) namespace blender::nodes { +static void geo_node_math_label(bNodeTree *UNUSED(ntree), bNode *node, char *label, int maxlen) +{ + NodeAttributeMath &node_storage = *(NodeAttributeMath *)node->storage; + const char *name; + bool enum_label = RNA_enum_name(rna_enum_node_math_items, node_storage.operation, &name); + if (!enum_label) { + name = "Unknown"; + } + BLI_strncpy(label, IFACE_(name), maxlen); +} + static void geo_node_attribute_math_update(bNodeTree *UNUSED(ntree), bNode *node) { NodeAttributeMath &node_storage = *(NodeAttributeMath *)node->storage; @@ -296,6 +309,7 @@ void register_node_type_geo_attribute_math() node_type_socket_templates(&ntype, geo_node_attribute_math_in, geo_node_attribute_math_out); ntype.geometry_node_execute = blender::nodes::geo_node_attribute_math_exec; ntype.draw_buttons = geo_node_attribute_math_layout; + node_type_label(&ntype, blender::nodes::geo_node_math_label); node_type_update(&ntype, blender::nodes::geo_node_attribute_math_update); node_type_init(&ntype, geo_node_attribute_math_init); node_type_storage( diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_vector_math.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_vector_math.cc index e017786ae89..be70ebdebfe 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_attribute_vector_math.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_vector_math.cc @@ -17,6 +17,8 @@ #include "BLI_math_base_safe.h" #include "BLI_task.hh" +#include "RNA_enum_types.h" + #include "UI_interface.h" #include "UI_resources.h" @@ -154,6 +156,20 @@ static CustomDataType operation_get_result_type(const NodeVectorMathOperation op namespace blender::nodes { +static void geo_node_vector_math_label(bNodeTree *UNUSED(ntree), + bNode *node, + char *label, + int maxlen) +{ + NodeAttributeMath &node_storage = *(NodeAttributeMath *)node->storage; + const char *name; + bool enum_label = RNA_enum_name(rna_enum_node_vec_math_items, node_storage.operation, &name); + if (!enum_label) { + name = "Unknown"; + } + BLI_snprintf(label, maxlen, IFACE_("Vector %s"), IFACE_(name)); +} + static void geo_node_attribute_vector_math_update(bNodeTree *UNUSED(ntree), bNode *node) { const NodeAttributeVectorMath *node_storage = (NodeAttributeVectorMath *)node->storage; @@ -549,6 +565,7 @@ void register_node_type_geo_attribute_vector_math() &ntype, geo_node_attribute_vector_math_in, geo_node_attribute_vector_math_out); ntype.geometry_node_execute = blender::nodes::geo_node_attribute_vector_math_exec; ntype.draw_buttons = geo_node_attribute_vector_math_layout; + node_type_label(&ntype, blender::nodes::geo_node_vector_math_label); node_type_update(&ntype, blender::nodes::geo_node_attribute_vector_math_update); node_type_init(&ntype, geo_node_attribute_vector_math_init); node_type_storage( |