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
This commit is contained in:
Charlie Jolly 2021-07-27 14:17:09 +01:00 committed by Charlie Jolly
parent 07688ca2d2
commit 766e67e55d
2 changed files with 31 additions and 0 deletions

View File

@ -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(

View File

@ -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(