[Bf-blender-cvs] [58893eaef84] master: Cleanup: Use consistent order for functions in node files

Hans Goudey noreply at git.blender.org
Wed May 19 22:13:14 CEST 2021


Commit: 58893eaef8414d27815fb20b049db14333bb4eb2
Author: Hans Goudey
Date:   Wed May 19 16:13:05 2021 -0400
Branches: master
https://developer.blender.org/rB58893eaef8414d27815fb20b049db14333bb4eb2

Cleanup: Use consistent order for functions in node files

After this commit, all geometry node "init" and "update" functions are
at the top of each file, right below the "layout" function. This means
you can always scroll to the bottom of the file to see the entry point,
and the boring boilerplate code is grouped in one section.

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

M	source/blender/nodes/geometry/nodes/node_geo_align_rotation_to_vector.cc
M	source/blender/nodes/geometry/nodes/node_geo_attribute_color_ramp.cc
M	source/blender/nodes/geometry/nodes/node_geo_attribute_mix.cc
M	source/blender/nodes/geometry/nodes/node_geo_collection_info.cc
M	source/blender/nodes/geometry/nodes/node_geo_edge_split.cc
M	source/blender/nodes/geometry/nodes/node_geo_point_instance.cc
M	source/blender/nodes/geometry/nodes/node_geo_point_rotate.cc
M	source/blender/nodes/geometry/nodes/node_geo_point_scale.cc
M	source/blender/nodes/geometry/nodes/node_geo_points_to_volume.cc
M	source/blender/nodes/geometry/nodes/node_geo_switch.cc
M	source/blender/nodes/geometry/nodes/node_geo_transform.cc

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

diff --git a/source/blender/nodes/geometry/nodes/node_geo_align_rotation_to_vector.cc b/source/blender/nodes/geometry/nodes/node_geo_align_rotation_to_vector.cc
index 720ca9731a8..d1b71d6f2ba 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_align_rotation_to_vector.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_align_rotation_to_vector.cc
@@ -51,6 +51,28 @@ static void geo_node_align_rotation_to_vector_layout(uiLayout *layout,
 
 namespace blender::nodes {
 
+static void geo_node_align_rotation_to_vector_init(bNodeTree *UNUSED(ntree), bNode *node)
+{
+  NodeGeometryAlignRotationToVector *node_storage = (NodeGeometryAlignRotationToVector *)
+      MEM_callocN(sizeof(NodeGeometryAlignRotationToVector), __func__);
+
+  node_storage->axis = GEO_NODE_ALIGN_ROTATION_TO_VECTOR_AXIS_X;
+  node_storage->input_type_factor = GEO_NODE_ATTRIBUTE_INPUT_FLOAT;
+  node_storage->input_type_vector = GEO_NODE_ATTRIBUTE_INPUT_VECTOR;
+
+  node->storage = node_storage;
+}
+
+static void geo_node_align_rotation_to_vector_update(bNodeTree *UNUSED(ntree), bNode *node)
+{
+  NodeGeometryAlignRotationToVector *node_storage = (NodeGeometryAlignRotationToVector *)
+                                                        node->storage;
+  update_attribute_input_socket_availabilities(
+      *node, "Factor", (GeometryNodeAttributeInputMode)node_storage->input_type_factor);
+  update_attribute_input_socket_availabilities(
+      *node, "Vector", (GeometryNodeAttributeInputMode)node_storage->input_type_vector);
+}
+
 static void align_rotations_auto_pivot(const VArray<float3> &vectors,
                                        const VArray<float> &factors,
                                        const float3 local_main_axis,
@@ -195,28 +217,6 @@ static void geo_node_align_rotation_to_vector_exec(GeoNodeExecParams params)
   params.set_output("Geometry", geometry_set);
 }
 
-static void geo_node_align_rotation_to_vector_init(bNodeTree *UNUSED(ntree), bNode *node)
-{
-  NodeGeometryAlignRotationToVector *node_storage = (NodeGeometryAlignRotationToVector *)
-      MEM_callocN(sizeof(NodeGeometryAlignRotationToVector), __func__);
-
-  node_storage->axis = GEO_NODE_ALIGN_ROTATION_TO_VECTOR_AXIS_X;
-  node_storage->input_type_factor = GEO_NODE_ATTRIBUTE_INPUT_FLOAT;
-  node_storage->input_type_vector = GEO_NODE_ATTRIBUTE_INPUT_VECTOR;
-
-  node->storage = node_storage;
-}
-
-static void geo_node_align_rotation_to_vector_update(bNodeTree *UNUSED(ntree), bNode *node)
-{
-  NodeGeometryAlignRotationToVector *node_storage = (NodeGeometryAlignRotationToVector *)
-                                                        node->storage;
-  update_attribute_input_socket_availabilities(
-      *node, "Factor", (GeometryNodeAttributeInputMode)node_storage->input_type_factor);
-  update_attribute_input_socket_availabilities(
-      *node, "Vector", (GeometryNodeAttributeInputMode)node_storage->input_type_vector);
-}
-
 }  // namespace blender::nodes
 
 void register_node_type_geo_align_rotation_to_vector()
diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_color_ramp.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_color_ramp.cc
index 26ddb0da515..b13e82e676d 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_attribute_color_ramp.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_color_ramp.cc
@@ -44,6 +44,14 @@ static void geo_node_attribute_color_ramp_layout(uiLayout *layout,
 
 namespace blender::nodes {
 
+static void geo_node_attribute_color_ramp_init(bNodeTree *UNUSED(ntree), bNode *node)
+{
+  NodeAttributeColorRamp *node_storage = (NodeAttributeColorRamp *)MEM_callocN(
+      sizeof(NodeAttributeColorRamp), __func__);
+  BKE_colorband_init(&node_storage->color_ramp, true);
+  node->storage = node_storage;
+}
+
 static AttributeDomain get_result_domain(const GeometryComponent &component,
                                          StringRef input_name,
                                          StringRef result_name)
@@ -115,14 +123,6 @@ static void geo_node_attribute_color_ramp_exec(GeoNodeExecParams params)
   params.set_output("Geometry", std::move(geometry_set));
 }
 
-static void geo_node_attribute_color_ramp_init(bNodeTree *UNUSED(ntree), bNode *node)
-{
-  NodeAttributeColorRamp *node_storage = (NodeAttributeColorRamp *)MEM_callocN(
-      sizeof(NodeAttributeColorRamp), __func__);
-  BKE_colorband_init(&node_storage->color_ramp, true);
-  node->storage = node_storage;
-}
-
 }  // namespace blender::nodes
 
 void register_node_type_geo_attribute_color_ramp()
diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_mix.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_mix.cc
index 3e5326edbf6..e502a183ef5 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_attribute_mix.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_mix.cc
@@ -59,6 +59,28 @@ static void geo_node_attribute_mix_layout(uiLayout *layout, bContext *UNUSED(C),
 
 namespace blender::nodes {
 
+static void geo_node_attribute_mix_init(bNodeTree *UNUSED(ntree), bNode *node)
+{
+  NodeAttributeMix *data = (NodeAttributeMix *)MEM_callocN(sizeof(NodeAttributeMix),
+                                                           "attribute mix node");
+  data->blend_type = MA_RAMP_BLEND;
+  data->input_type_factor = GEO_NODE_ATTRIBUTE_INPUT_FLOAT;
+  data->input_type_a = GEO_NODE_ATTRIBUTE_INPUT_ATTRIBUTE;
+  data->input_type_b = GEO_NODE_ATTRIBUTE_INPUT_ATTRIBUTE;
+  node->storage = data;
+}
+
+static void geo_node_attribute_mix_update(bNodeTree *UNUSED(ntree), bNode *node)
+{
+  NodeAttributeMix *node_storage = (NodeAttributeMix *)node->storage;
+  update_attribute_input_socket_availabilities(
+      *node, "Factor", (GeometryNodeAttributeInputMode)node_storage->input_type_factor);
+  update_attribute_input_socket_availabilities(
+      *node, "A", (GeometryNodeAttributeInputMode)node_storage->input_type_a);
+  update_attribute_input_socket_availabilities(
+      *node, "B", (GeometryNodeAttributeInputMode)node_storage->input_type_b);
+}
+
 static void do_mix_operation_float(const int blend_mode,
                                    const VArray<float> &factors,
                                    const VArray<float> &inputs_a,
@@ -216,28 +238,6 @@ static void geo_node_attribute_mix_exec(GeoNodeExecParams params)
   params.set_output("Geometry", geometry_set);
 }
 
-static void geo_node_attribute_mix_init(bNodeTree *UNUSED(ntree), bNode *node)
-{
-  NodeAttributeMix *data = (NodeAttributeMix *)MEM_callocN(sizeof(NodeAttributeMix),
-                                                           "attribute mix node");
-  data->blend_type = MA_RAMP_BLEND;
-  data->input_type_factor = GEO_NODE_ATTRIBUTE_INPUT_FLOAT;
-  data->input_type_a = GEO_NODE_ATTRIBUTE_INPUT_ATTRIBUTE;
-  data->input_type_b = GEO_NODE_ATTRIBUTE_INPUT_ATTRIBUTE;
-  node->storage = data;
-}
-
-static void geo_node_attribute_mix_update(bNodeTree *UNUSED(ntree), bNode *node)
-{
-  NodeAttributeMix *node_storage = (NodeAttributeMix *)node->storage;
-  update_attribute_input_socket_availabilities(
-      *node, "Factor", (GeometryNodeAttributeInputMode)node_storage->input_type_factor);
-  update_attribute_input_socket_availabilities(
-      *node, "A", (GeometryNodeAttributeInputMode)node_storage->input_type_a);
-  update_attribute_input_socket_availabilities(
-      *node, "B", (GeometryNodeAttributeInputMode)node_storage->input_type_b);
-}
-
 }  // namespace blender::nodes
 
 void register_node_type_geo_attribute_mix()
diff --git a/source/blender/nodes/geometry/nodes/node_geo_collection_info.cc b/source/blender/nodes/geometry/nodes/node_geo_collection_info.cc
index bd4de710dbb..9bc8a4bb4be 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_collection_info.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_collection_info.cc
@@ -40,6 +40,14 @@ static void geo_node_collection_info_layout(uiLayout *layout, bContext *UNUSED(C
 
 namespace blender::nodes {
 
+static void geo_node_collection_info_node_init(bNodeTree *UNUSED(tree), bNode *node)
+{
+  NodeGeometryCollectionInfo *data = (NodeGeometryCollectionInfo *)MEM_callocN(
+      sizeof(NodeGeometryCollectionInfo), __func__);
+  data->transform_space = GEO_NODE_TRANSFORM_SPACE_ORIGINAL;
+  node->storage = data;
+}
+
 static void geo_node_collection_info_exec(GeoNodeExecParams params)
 {
   Collection *collection = params.get_input<Collection *>("Collection");
@@ -74,14 +82,6 @@ static void geo_node_collection_info_exec(GeoNodeExecParams params)
   params.set_output("Geometry", geometry_set_out);
 }
 
-static void geo_node_collection_info_node_init(bNodeTree *UNUSED(tree), bNode *node)
-{
-  NodeGeometryCollectionInfo *data = (NodeGeometryCollectionInfo *)MEM_callocN(
-      sizeof(NodeGeometryCollectionInfo), __func__);
-  data->transform_space = GEO_NODE_TRANSFORM_SPACE_ORIGINAL;
-  node->storage = data;
-}
-
 }  // namespace blender::nodes
 
 void register_node_type_geo_collection_info()
diff --git a/source/blender/nodes/geometry/nodes/node_geo_edge_split.cc b/source/blender/nodes/geometry/nodes/node_geo_edge_split.cc
index 534b7d754ec..740b828d503 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_edge_split.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_edge_split.cc
@@ -44,6 +44,7 @@ static bNodeSocketTemplate geo_node_edge_split_out[] = {
 };
 
 namespace blender::nodes {
+
 static void geo_node_edge_split_exec(GeoNodeExecParams params)
 {
   GeometrySet geometry_set = params.extract_input<GeometrySet>("Geometry");
@@ -82,6 +83,7 @@ static void geo_node_edge_split_exec(GeoNodeExecParams params)
 
   params.set_output("Geometry", std::move(geometry_set));
 }
+
 }  // namespace blender::nodes
 
 void register_node_type_geo_edge_split()
diff --git a/source/blender/nodes/geometry/nodes/node_geo_point_instance.cc b/source/blender/nodes/geometry/nodes/node_geo_point_instance.cc
index 6f66f2145fa..44b8b14f4e7 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_point_instance.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_point_instance.cc
@@ -47,6 +47,15 @@ static void geo_node_point_instance_layout(uiLayout *layout, bContext *UNUSED(C)
 
 namespace blender::nodes {
 
+static void geo_nod

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list