[Bf-blender-cvs] [766e67e55db] master: Geometry Nodes: Add node labels to Attribute maths nodes

Charlie Jolly noreply at git.blender.org
Tue Jul 27 15:34:17 CEST 2021


Commit: 766e67e55db4d5235f66ec8e320e23cd0def6de9
Author: Charlie Jolly
Date:   Tue Jul 27 14:17:09 2021 +0100
Branches: master
https://developer.blender.org/rB766e67e55db4d5235f66ec8e320e23cd0def6de9

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

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

M	source/blender/nodes/geometry/nodes/node_geo_attribute_math.cc
M	source/blender/nodes/geometry/nodes/node_geo_attribute_vector_math.cc

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

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(



More information about the Bf-blender-cvs mailing list