[Bf-blender-cvs] [b3fc6ac07aa] geometry-nodes-curve-support: Geometry Nodes Curves: Allow attribute nodes to run on curves

Hans Goudey noreply at git.blender.org
Sun Apr 4 16:30:43 CEST 2021


Commit: b3fc6ac07aa38519ef577e8ace115072e6a6bd42
Author: Hans Goudey
Date:   Sun Apr 4 09:30:35 2021 -0500
Branches: geometry-nodes-curve-support
https://developer.blender.org/rBb3fc6ac07aa38519ef577e8ace115072e6a6bd42

Geometry Nodes Curves: Allow attribute nodes to run on curves

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

M	source/blender/blenkernel/BKE_geometry_set.hh
M	source/blender/blenkernel/intern/geometry_set.cc
M	source/blender/makesrna/intern/rna_attribute.c
M	source/blender/nodes/geometry/nodes/node_geo_align_rotation_to_vector.cc
M	source/blender/nodes/geometry/nodes/node_geo_attribute_clamp.cc
M	source/blender/nodes/geometry/nodes/node_geo_attribute_color_ramp.cc
M	source/blender/nodes/geometry/nodes/node_geo_attribute_combine_xyz.cc
M	source/blender/nodes/geometry/nodes/node_geo_attribute_compare.cc
M	source/blender/nodes/geometry/nodes/node_geo_attribute_convert.cc
M	source/blender/nodes/geometry/nodes/node_geo_attribute_fill.cc
M	source/blender/nodes/geometry/nodes/node_geo_attribute_map_range.cc
M	source/blender/nodes/geometry/nodes/node_geo_attribute_math.cc
M	source/blender/nodes/geometry/nodes/node_geo_attribute_mix.cc
M	source/blender/nodes/geometry/nodes/node_geo_attribute_proximity.cc
M	source/blender/nodes/geometry/nodes/node_geo_attribute_randomize.cc
M	source/blender/nodes/geometry/nodes/node_geo_attribute_remove.cc
M	source/blender/nodes/geometry/nodes/node_geo_attribute_sample_texture.cc
M	source/blender/nodes/geometry/nodes/node_geo_attribute_separate_xyz.cc
M	source/blender/nodes/geometry/nodes/node_geo_attribute_vector_math.cc

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

diff --git a/source/blender/blenkernel/BKE_geometry_set.hh b/source/blender/blenkernel/BKE_geometry_set.hh
index 09c1249d2fb..2565c5cdb99 100644
--- a/source/blender/blenkernel/BKE_geometry_set.hh
+++ b/source/blender/blenkernel/BKE_geometry_set.hh
@@ -308,6 +308,7 @@ struct GeometrySet {
   void add(const GeometryComponent &component);
 
   blender::Vector<const GeometryComponent *> get_components_for_read() const;
+  blender::Vector<GeometryComponent *> get_components_for_write();
 
   void compute_boundbox_without_instances(blender::float3 *r_min, blender::float3 *r_max) const;
 
diff --git a/source/blender/blenkernel/intern/geometry_set.cc b/source/blender/blenkernel/intern/geometry_set.cc
index 872794f01b9..564f1e0222f 100644
--- a/source/blender/blenkernel/intern/geometry_set.cc
+++ b/source/blender/blenkernel/intern/geometry_set.cc
@@ -175,6 +175,18 @@ Vector<const GeometryComponent *> GeometrySet::get_components_for_read() const
   return components;
 }
 
+/**
+ * Get all geometry components in this geometry set.
+ */
+Vector<GeometryComponent *> GeometrySet::get_components_for_write()
+{
+  Vector<GeometryComponent *> components;
+  for (GeometryComponentPtr &ptr : components_.values()) {
+    components.append(ptr.get());
+  }
+  return components;
+}
+
 void GeometrySet::compute_boundbox_without_instances(float3 *r_min, float3 *r_max) const
 {
   const PointCloud *pointcloud = this->get_pointcloud_for_read();
diff --git a/source/blender/makesrna/intern/rna_attribute.c b/source/blender/makesrna/intern/rna_attribute.c
index 872742507c7..ec29e81b07c 100644
--- a/source/blender/makesrna/intern/rna_attribute.c
+++ b/source/blender/makesrna/intern/rna_attribute.c
@@ -68,6 +68,7 @@ const EnumPropertyItem rna_enum_attribute_domain_with_auto_items[] = {
     {ATTR_DOMAIN_EDGE, "EDGE", 0, "Edge", "Attribute on mesh edge"},
     {ATTR_DOMAIN_FACE, "FACE", 0, "Face", "Attribute on mesh faces"},
     {ATTR_DOMAIN_CORNER, "CORNER", 0, "Face Corner", "Attribute on mesh face corner"},
+    {ATTR_DOMAIN_CURVE, "CURVE", 0, "Spline", "Attribute on spline"},
     {0, NULL, 0, NULL, NULL},
 };
 
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 fca460e3566..05a4c6a7dcd 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
@@ -176,12 +176,8 @@ static void geo_node_align_rotation_to_vector_exec(GeoNodeExecParams params)
 
   geometry_set = geometry_set_realize_instances(geometry_set);
 
-  if (geometry_set.has<MeshComponent>()) {
-    align_rotations_on_component(geometry_set.get_component_for_write<MeshComponent>(), params);
-  }
-  if (geometry_set.has<PointCloudComponent>()) {
-    align_rotations_on_component(geometry_set.get_component_for_write<PointCloudComponent>(),
-                                 params);
+  for (GeometryComponent *component : geometry_set.get_components_for_write()) {
+    align_rotations_on_component(*component, params);
   }
 
   params.set_output("Geometry", geometry_set);
diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_clamp.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_clamp.cc
index 93e4124bd70..3cd73d2f7c6 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_attribute_clamp.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_clamp.cc
@@ -250,11 +250,8 @@ static void geo_node_attribute_clamp_exec(GeoNodeExecParams params)
 
   geometry_set = geometry_set_realize_instances(geometry_set);
 
-  if (geometry_set.has<MeshComponent>()) {
-    clamp_attribute(geometry_set.get_component_for_write<MeshComponent>(), params);
-  }
-  if (geometry_set.has<PointCloudComponent>()) {
-    clamp_attribute(geometry_set.get_component_for_write<PointCloudComponent>(), params);
+  for (GeometryComponent *component : geometry_set.get_components_for_write()) {
+    clamp_attribute(*component, params);
   }
 
   params.set_output("Geometry", geometry_set);
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 98bf612f589..3a3bfb1fcc3 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
@@ -100,11 +100,8 @@ static void geo_node_attribute_color_ramp_exec(GeoNodeExecParams params)
 
   geometry_set = geometry_set_realize_instances(geometry_set);
 
-  if (geometry_set.has<MeshComponent>()) {
-    execute_on_component(params, geometry_set.get_component_for_write<MeshComponent>());
-  }
-  if (geometry_set.has<PointCloudComponent>()) {
-    execute_on_component(params, geometry_set.get_component_for_write<PointCloudComponent>());
+  for (GeometryComponent *component : geometry_set.get_components_for_write()) {
+    execute_on_component(params, *component);
   }
 
   params.set_output("Geometry", std::move(geometry_set));
diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_combine_xyz.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_combine_xyz.cc
index 9c5c7e270b1..8883f07172d 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_attribute_combine_xyz.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_combine_xyz.cc
@@ -123,11 +123,8 @@ static void geo_node_attribute_combine_xyz_exec(GeoNodeExecParams params)
 
   geometry_set = geometry_set_realize_instances(geometry_set);
 
-  if (geometry_set.has<MeshComponent>()) {
-    combine_attributes(geometry_set.get_component_for_write<MeshComponent>(), params);
-  }
-  if (geometry_set.has<PointCloudComponent>()) {
-    combine_attributes(geometry_set.get_component_for_write<PointCloudComponent>(), params);
+  for (GeometryComponent *component : geometry_set.get_components_for_write()) {
+    combine_attributes(*component, params);
   }
 
   params.set_output("Geometry", geometry_set);
diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_compare.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_compare.cc
index db1a5d18744..ba8f330496b 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_attribute_compare.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_compare.cc
@@ -333,11 +333,8 @@ static void geo_node_attribute_compare_exec(GeoNodeExecParams params)
 
   geometry_set = geometry_set_realize_instances(geometry_set);
 
-  if (geometry_set.has<MeshComponent>()) {
-    attribute_compare_calc(geometry_set.get_component_for_write<MeshComponent>(), params);
-  }
-  if (geometry_set.has<PointCloudComponent>()) {
-    attribute_compare_calc(geometry_set.get_component_for_write<PointCloudComponent>(), params);
+  for (GeometryComponent *component : geometry_set.get_components_for_write()) {
+    attribute_compare_calc(*component, params);
   }
 
   params.set_output("Geometry", geometry_set);
diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_convert.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_convert.cc
index 11d220dd903..8aabd505760 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_attribute_convert.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_convert.cc
@@ -124,21 +124,8 @@ static void geo_node_attribute_convert_exec(GeoNodeExecParams params)
     return;
   }
 
-  if (geometry_set.has<MeshComponent>()) {
-    attribute_convert_calc(geometry_set.get_component_for_write<MeshComponent>(),
-                           params,
-                           source_name,
-                           result_name,
-                           data_type,
-                           domain);
-  }
-  if (geometry_set.has<PointCloudComponent>()) {
-    attribute_convert_calc(geometry_set.get_component_for_write<PointCloudComponent>(),
-                           params,
-                           source_name,
-                           result_name,
-                           data_type,
-                           domain);
+  for (GeometryComponent *component : geometry_set.get_components_for_write()) {
+    attribute_convert_calc(*component, params, source_name, result_name, data_type, domain);
   }
 
   params.set_output("Geometry", geometry_set);
diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_fill.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_fill.cc
index 2139c5afa6b..b33691f4924 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_attribute_fill.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_fill.cc
@@ -147,11 +147,8 @@ static void geo_node_attribute_fill_exec(GeoNodeExecParams params)
 
   geometry_set = geometry_set_realize_instances(geometry_set);
 
-  if (geometry_set.has<MeshComponent>()) {
-    fill_attribute(geometry_set.get_component_for_write<MeshComponent>(), params);
-  }
-  if (geometry_set.has<PointCloudComponent>()) {
-    fill_attribute(geometry_set.get_component_for_write<PointCloudComponent>(), params);
+  for (GeometryComponent *component : geometry_set.get_components_for_write()) {
+    fill_attribute(*component, params);
   }
 
   params.set_output("Geometry", geometry_set);
diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_map_range.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_map_range.cc
index 4e0dfd3a636..413bd3cb765 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_attribute_map_range.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_map_range.cc
@@ -387,11 +387,8 @@ static void geo_node_attribute_map_range_exec(GeoNodeExecParams params)
 {
   GeometrySet geometry_set = params.extract_input<GeometrySet>("Geometry");
 
-  if (geometry_set.has<MeshComponent>()) {
-    map_range_attribute(geometry_set.get_component_for_write<MeshComponent>(), params);
-  }
-  if (geometry_set.has<PointCloudComponent>()) {
-    map_range_attribute(geometry_set.get_component_for_write<PointCloudComponent>(), params);
+  for (GeometryComponent *component : geometry_set.get_components_for_write()) {
+    map_range_attribute(*component, params);
   }
 
   params.set_output("Geometry", g

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list