[Bf-blender-cvs] [14103793de4] temp-geometry-nodes-expandable-geometry-socket-prototype: support lists in point translate node

Jacques Lucke noreply at git.blender.org
Fri Aug 6 16:15:55 CEST 2021


Commit: 14103793de46ab3915e19b0f1e29c2e0c3c75ef9
Author: Jacques Lucke
Date:   Fri Aug 6 16:14:42 2021 +0200
Branches: temp-geometry-nodes-expandable-geometry-socket-prototype
https://developer.blender.org/rB14103793de46ab3915e19b0f1e29c2e0c3c75ef9

support lists in point translate node

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

M	source/blender/nodes/geometry/nodes/node_geo_point_translate.cc

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

diff --git a/source/blender/nodes/geometry/nodes/node_geo_point_translate.cc b/source/blender/nodes/geometry/nodes/node_geo_point_translate.cc
index 293f151fe19..02026d25204 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_point_translate.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_point_translate.cc
@@ -21,7 +21,6 @@
 
 static bNodeSocketTemplate geo_node_point_translate_in[] = {
     {SOCK_GEOMETRY, N_("Geometry")},
-    {SOCK_STRING, N_("Translation")},
     {SOCK_VECTOR, N_("Translation"), 0.0f, 0.0f, 0.0f, 1.0f, -FLT_MAX, FLT_MAX, PROP_TRANSLATION},
     {-1, ""},
 };
@@ -31,13 +30,6 @@ static bNodeSocketTemplate geo_node_point_translate_out[] = {
     {-1, ""},
 };
 
-static void geo_node_point_translate_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
-{
-  uiLayoutSetPropSep(layout, true);
-  uiLayoutSetPropDecorate(layout, false);
-  uiItemR(layout, ptr, "input_type", 0, IFACE_("Type"), ICON_NONE);
-}
-
 namespace blender::nodes {
 
 static void execute_on_component(GeoNodeExecParams params, GeometryComponent &component)
@@ -47,11 +39,15 @@ static void execute_on_component(GeoNodeExecParams params, GeometryComponent &co
   if (!position_attribute) {
     return;
   }
-  GVArray_Typed<float3> attribute = params.get_input_attribute<float3>(
-      "Translation", component, ATTR_DOMAIN_POINT, {0, 0, 0});
 
-  for (const int i : IndexRange(attribute.size())) {
-    position_attribute->set(i, position_attribute->get(i) + attribute[i]);
+  const int domain_size = component.attribute_domain_size(ATTR_DOMAIN_POINT);
+
+  const Array<float3> &translations_array = params.get_input<Array<float3>>("Translation");
+  fn::GVArray_For_RepeatedGSpan repeated_translation{domain_size, translations_array.as_span()};
+  fn::GVArray_Typed<float3> translations{repeated_translation};
+
+  for (const int i : IndexRange(domain_size)) {
+    position_attribute->set(i, position_attribute->get(i) + translations[i]);
   }
 
   position_attribute.save();
@@ -76,23 +72,6 @@ static void geo_node_point_translate_exec(GeoNodeExecParams params)
   params.set_output("Geometry", std::move(geometry_set));
 }
 
-static void geo_node_point_translate_init(bNodeTree *UNUSED(tree), bNode *node)
-{
-  NodeGeometryPointTranslate *data = (NodeGeometryPointTranslate *)MEM_callocN(
-      sizeof(NodeGeometryPointTranslate), __func__);
-
-  data->input_type = GEO_NODE_ATTRIBUTE_INPUT_VECTOR;
-  node->storage = data;
-}
-
-static void geo_node_point_translate_update(bNodeTree *UNUSED(ntree), bNode *node)
-{
-  NodeGeometryPointTranslate &node_storage = *(NodeGeometryPointTranslate *)node->storage;
-
-  update_attribute_input_socket_availabilities(
-      *node, "Translation", (GeometryNodeAttributeInputMode)node_storage.input_type);
-}
-
 }  // namespace blender::nodes
 
 void register_node_type_geo_point_translate()
@@ -101,13 +80,6 @@ void register_node_type_geo_point_translate()
 
   geo_node_type_base(&ntype, GEO_NODE_POINT_TRANSLATE, "Point Translate", NODE_CLASS_GEOMETRY, 0);
   node_type_socket_templates(&ntype, geo_node_point_translate_in, geo_node_point_translate_out);
-  node_type_init(&ntype, blender::nodes::geo_node_point_translate_init);
-  node_type_update(&ntype, blender::nodes::geo_node_point_translate_update);
-  node_type_storage(&ntype,
-                    "NodeGeometryPointTranslate",
-                    node_free_standard_storage,
-                    node_copy_standard_storage);
   ntype.geometry_node_execute = blender::nodes::geo_node_point_translate_exec;
-  ntype.draw_buttons = geo_node_point_translate_layout;
   nodeRegisterType(&ntype);
 }



More information about the Bf-blender-cvs mailing list