[Bf-blender-cvs] [6baf71adfa9] temp-compact-node-prototype: more nodes

Jacques Lucke noreply at git.blender.org
Thu Mar 25 16:11:07 CET 2021


Commit: 6baf71adfa9e1d1a7ef65cf5bb81124d645f9ba9
Author: Jacques Lucke
Date:   Thu Mar 25 14:10:28 2021 +0100
Branches: temp-compact-node-prototype
https://developer.blender.org/rB6baf71adfa9e1d1a7ef65cf5bb81124d645f9ba9

more nodes

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

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

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

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 8b6960a05a6..ee2fd763ead 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
@@ -70,27 +70,6 @@ static bool operation_use_input_c(const NodeVectorMathOperation operation)
       operation, NODE_VECTOR_MATH_WRAP, NODE_VECTOR_MATH_REFRACT, NODE_VECTOR_MATH_FACEFORWARD);
 }
 
-static void geo_node_attribute_vector_math_layout(uiLayout *layout,
-                                                  bContext *UNUSED(C),
-                                                  PointerRNA *ptr)
-{
-  bNode *node = (bNode *)ptr->data;
-  const NodeAttributeVectorMath &node_storage = *(NodeAttributeVectorMath *)node->storage;
-  const NodeVectorMathOperation operation = (const NodeVectorMathOperation)node_storage.operation;
-
-  uiItemR(layout, ptr, "operation", 0, "", ICON_NONE);
-
-  uiLayoutSetPropSep(layout, true);
-  uiLayoutSetPropDecorate(layout, false);
-  uiItemR(layout, ptr, "input_type_a", 0, IFACE_("A"), ICON_NONE);
-  if (operation_use_input_b(operation)) {
-    uiItemR(layout, ptr, "input_type_b", 0, IFACE_("B"), ICON_NONE);
-  }
-  if (operation_use_input_c(operation)) {
-    uiItemR(layout, ptr, "input_type_c", 0, IFACE_("C"), ICON_NONE);
-  }
-}
-
 static CustomDataType operation_get_read_type_b(const NodeVectorMathOperation operation)
 {
   if (operation == NODE_VECTOR_MATH_SCALE) {
@@ -116,6 +95,12 @@ static void geo_node_attribute_vector_math_init(bNodeTree *UNUSED(tree), bNode *
   data->input_type_a = GEO_NODE_ATTRIBUTE_INPUT_ATTRIBUTE;
   data->input_type_b = GEO_NODE_ATTRIBUTE_INPUT_ATTRIBUTE;
   node->storage = data;
+
+  LISTBASE_FOREACH (bNodeSocket *, socket, &node->inputs) {
+    if (socket->type != SOCK_GEOMETRY) {
+      socket->flag |= SOCK_HIDDEN;
+    }
+  }
 }
 
 static CustomDataType operation_get_result_type(const NodeVectorMathOperation operation)
@@ -157,6 +142,27 @@ static CustomDataType operation_get_result_type(const NodeVectorMathOperation op
 
 namespace blender::nodes {
 
+static void geo_node_attribute_vector_math_layout(uiLayout *layout, bContext *C, PointerRNA *ptr)
+{
+  bNode *node = (bNode *)ptr->data;
+  const NodeAttributeVectorMath &node_storage = *(NodeAttributeVectorMath *)node->storage;
+  const NodeVectorMathOperation operation = (const NodeVectorMathOperation)node_storage.operation;
+
+  uiItemR(layout, ptr, "operation", 0, "", ICON_NONE);
+
+  draw_input_socket(C, layout, ptr, "A", "input_type_a");
+  if (operation_use_input_b(operation)) {
+    draw_input_socket(C, layout, ptr, "B", "input_type_b");
+  }
+  if (operation_use_input_c(operation)) {
+    draw_input_socket(C, layout, ptr, "C", "input_type_c");
+  }
+
+  uiItemS(layout);
+
+  draw_input_socket(C, layout, ptr, "Result");
+}
+
 static void geo_node_attribute_vector_math_update(bNodeTree *UNUSED(ntree), bNode *node)
 {
   const NodeAttributeVectorMath *node_storage = (NodeAttributeVectorMath *)node->storage;
@@ -516,7 +522,7 @@ void register_node_type_geo_attribute_vector_math()
   node_type_socket_templates(
       &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;
+  ntype.draw_buttons_ex = blender::nodes::geo_node_attribute_vector_math_layout;
   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(
diff --git a/source/blender/nodes/geometry/nodes/node_geo_transform.cc b/source/blender/nodes/geometry/nodes/node_geo_transform.cc
index ef6f0be40f2..842a78b839a 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_transform.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_transform.cc
@@ -45,6 +45,22 @@ static bNodeSocketTemplate geo_node_transform_out[] = {
 
 namespace blender::nodes {
 
+static void geo_node_transform_layout(uiLayout *layout, bContext *C, PointerRNA *ptr)
+{
+  draw_input_socket(C, layout, ptr, "Translation");
+  draw_input_socket(C, layout, ptr, "Rotation");
+  draw_input_socket(C, layout, ptr, "Scale");
+}
+
+static void geo_node_transform_init(bNodeTree *UNUSED(tree), bNode *node)
+{
+  LISTBASE_FOREACH (bNodeSocket *, socket, &node->inputs) {
+    if (socket->type != SOCK_GEOMETRY) {
+      socket->flag |= SOCK_HIDDEN;
+    }
+  }
+}
+
 static bool use_translate(const float3 rotation, const float3 scale)
 {
   if (compare_ff(rotation.length_squared(), 0.0f, 1e-9f) != 1) {
@@ -193,6 +209,8 @@ void register_node_type_geo_transform()
 
   geo_node_type_base(&ntype, GEO_NODE_TRANSFORM, "Transform", NODE_CLASS_GEOMETRY, 0);
   node_type_socket_templates(&ntype, geo_node_transform_in, geo_node_transform_out);
+  node_type_init(&ntype, blender::nodes::geo_node_transform_init);
   ntype.geometry_node_execute = blender::nodes::geo_node_transform_exec;
+  ntype.draw_buttons_ex = blender::nodes::geo_node_transform_layout;
   nodeRegisterType(&ntype);
 }



More information about the Bf-blender-cvs mailing list