[Bf-blender-cvs] [f7d9bfafd99] geometry-nodes: Geometry Nodes: combine Vertex and Point domains

Jacques Lucke noreply at git.blender.org
Fri Nov 20 18:23:14 CET 2020


Commit: f7d9bfafd99c1df6ccca6a8752eda3f456a3e26c
Author: Jacques Lucke
Date:   Fri Nov 20 18:23:07 2020 +0100
Branches: geometry-nodes
https://developer.blender.org/rBf7d9bfafd99c1df6ccca6a8752eda3f456a3e26c

Geometry Nodes: combine Vertex and Point domains

Originally, there were technical reasons for why two different domains
were used. Those reasons have been lost unfortunately, and there
don't seem to be any issues with combining the domains now.

This reduces confusion when users have to select the domain type
in enums.

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

M	source/blender/blenkernel/BKE_attribute.h
M	source/blender/blenkernel/intern/attribute.c
M	source/blender/blenkernel/intern/attribute_access.cc
M	source/blender/makesrna/intern/rna_attribute.c
M	source/blender/makesrna/intern/rna_nodetree.c
M	source/blender/nodes/geometry/nodes/node_geo_point_distribute.cc
M	source/blender/nodes/geometry/nodes/node_geo_point_instance.cc

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

diff --git a/source/blender/blenkernel/BKE_attribute.h b/source/blender/blenkernel/BKE_attribute.h
index aab962d42a6..55a841d8fd1 100644
--- a/source/blender/blenkernel/BKE_attribute.h
+++ b/source/blender/blenkernel/BKE_attribute.h
@@ -40,13 +40,11 @@ struct ReportList;
 
 /* Attribute.domain */
 typedef enum AttributeDomain {
-  ATTR_DOMAIN_VERTEX = 0,  /* Mesh Vertex */
+  ATTR_DOMAIN_POINT = 0,   /* Mesh, Hair or PointCloud Point */
   ATTR_DOMAIN_EDGE = 1,    /* Mesh Edge */
   ATTR_DOMAIN_CORNER = 2,  /* Mesh Corner */
   ATTR_DOMAIN_POLYGON = 3, /* Mesh Polygon */
-
-  ATTR_DOMAIN_POINT = 4, /* Hair or PointCloud Point */
-  ATTR_DOMAIN_CURVE = 5, /* Hair Curve */
+  ATTR_DOMAIN_CURVE = 4,   /* Hair Curve */
 
   ATTR_DOMAIN_NUM
 } AttributeDomain;
diff --git a/source/blender/blenkernel/intern/attribute.c b/source/blender/blenkernel/intern/attribute.c
index 9ad73133f9e..d8fd3a19303 100644
--- a/source/blender/blenkernel/intern/attribute.c
+++ b/source/blender/blenkernel/intern/attribute.c
@@ -63,8 +63,8 @@ static void get_domains(ID *id, DomainInfo info[ATTR_DOMAIN_NUM])
     }
     case ID_ME: {
       Mesh *mesh = (Mesh *)id;
-      info[ATTR_DOMAIN_VERTEX].customdata = &mesh->vdata;
-      info[ATTR_DOMAIN_VERTEX].length = mesh->totvert;
+      info[ATTR_DOMAIN_POINT].customdata = &mesh->vdata;
+      info[ATTR_DOMAIN_POINT].length = mesh->totvert;
       info[ATTR_DOMAIN_EDGE].customdata = &mesh->edata;
       info[ATTR_DOMAIN_EDGE].length = mesh->totedge;
       info[ATTR_DOMAIN_CORNER].customdata = &mesh->ldata;
diff --git a/source/blender/blenkernel/intern/attribute_access.cc b/source/blender/blenkernel/intern/attribute_access.cc
index 5218230bfe0..9c900d963c6 100644
--- a/source/blender/blenkernel/intern/attribute_access.cc
+++ b/source/blender/blenkernel/intern/attribute_access.cc
@@ -52,7 +52,7 @@ class VertexWeightWriteAttribute final : public WriteAttribute {
 
  public:
   VertexWeightWriteAttribute(MDeformVert *dverts, const int totvert, const int dvert_index)
-      : WriteAttribute(ATTR_DOMAIN_VERTEX, CPPType::get<float>(), totvert),
+      : WriteAttribute(ATTR_DOMAIN_POINT, CPPType::get<float>(), totvert),
         dverts_(dverts, totvert),
         dvert_index_(dvert_index)
   {
@@ -92,7 +92,7 @@ class VertexWeightReadAttribute final : public ReadAttribute {
 
  public:
   VertexWeightReadAttribute(const MDeformVert *dverts, const int totvert, const int dvert_index)
-      : ReadAttribute(ATTR_DOMAIN_VERTEX, CPPType::get<float>(), totvert),
+      : ReadAttribute(ATTR_DOMAIN_POINT, CPPType::get<float>(), totvert),
         dverts_(dverts, totvert),
         dvert_index_(dvert_index)
   {
@@ -652,7 +652,7 @@ bool PointCloudComponent::attribute_try_create(const StringRef attribute_name,
 bool MeshComponent::attribute_domain_supported(const AttributeDomain domain) const
 {
   return ELEM(
-      domain, ATTR_DOMAIN_CORNER, ATTR_DOMAIN_VERTEX, ATTR_DOMAIN_EDGE, ATTR_DOMAIN_POLYGON);
+      domain, ATTR_DOMAIN_CORNER, ATTR_DOMAIN_POINT, ATTR_DOMAIN_EDGE, ATTR_DOMAIN_POLYGON);
 }
 
 bool MeshComponent::attribute_domain_with_type_supported(const AttributeDomain domain,
@@ -674,7 +674,7 @@ int MeshComponent::attribute_domain_size(const AttributeDomain domain) const
   switch (domain) {
     case ATTR_DOMAIN_CORNER:
       return mesh_->totloop;
-    case ATTR_DOMAIN_VERTEX:
+    case ATTR_DOMAIN_POINT:
       return mesh_->totvert;
     case ATTR_DOMAIN_EDGE:
       return mesh_->totedge;
@@ -702,7 +702,7 @@ ReadAttributePtr MeshComponent::attribute_try_get_for_read(const StringRef attri
     auto get_vertex_position = [](const MVert &vert) { return float3(vert.co); };
     return std::make_unique<
         blender::bke::DerivedArrayReadAttribute<MVert, float3, decltype(get_vertex_position)>>(
-        ATTR_DOMAIN_VERTEX, blender::Span(mesh_->mvert, mesh_->totvert), get_vertex_position);
+        ATTR_DOMAIN_POINT, blender::Span(mesh_->mvert, mesh_->totvert), get_vertex_position);
   }
 
   ReadAttributePtr corner_attribute = read_attribute_from_custom_data(
@@ -718,7 +718,7 @@ ReadAttributePtr MeshComponent::attribute_try_get_for_read(const StringRef attri
   }
 
   ReadAttributePtr vertex_attribute = read_attribute_from_custom_data(
-      mesh_->vdata, mesh_->totvert, attribute_name, ATTR_DOMAIN_VERTEX);
+      mesh_->vdata, mesh_->totvert, attribute_name, ATTR_DOMAIN_POINT);
   if (vertex_attribute) {
     return vertex_attribute;
   }
@@ -753,7 +753,7 @@ WriteAttributePtr MeshComponent::attribute_try_get_for_write(const StringRef att
                                                  float3,
                                                  decltype(get_vertex_position),
                                                  decltype(set_vertex_position)>>(
-        ATTR_DOMAIN_VERTEX,
+        ATTR_DOMAIN_POINT,
         blender::MutableSpan(mesh_->mvert, mesh_->totvert),
         get_vertex_position,
         set_vertex_position);
@@ -772,7 +772,7 @@ WriteAttributePtr MeshComponent::attribute_try_get_for_write(const StringRef att
   }
 
   WriteAttributePtr vertex_attribute = write_attribute_from_custom_data(
-      mesh_->vdata, mesh_->totvert, attribute_name, ATTR_DOMAIN_VERTEX);
+      mesh_->vdata, mesh_->totvert, attribute_name, ATTR_DOMAIN_POINT);
   if (vertex_attribute) {
     return vertex_attribute;
   }
@@ -846,7 +846,7 @@ bool MeshComponent::attribute_try_create(const StringRef attribute_name,
           &mesh->ldata, data_type, CD_DEFAULT, nullptr, mesh->totloop, attribute_name_c);
       return true;
     }
-    case ATTR_DOMAIN_VERTEX: {
+    case ATTR_DOMAIN_POINT: {
       if (custom_data_has_layer_with_name(mesh->vdata, attribute_name)) {
         return false;
       }
diff --git a/source/blender/makesrna/intern/rna_attribute.c b/source/blender/makesrna/intern/rna_attribute.c
index 7f0ab2df70d..ad615026343 100644
--- a/source/blender/makesrna/intern/rna_attribute.c
+++ b/source/blender/makesrna/intern/rna_attribute.c
@@ -50,13 +50,12 @@ const EnumPropertyItem rna_enum_attribute_type_items[] = {
 const EnumPropertyItem rna_enum_attribute_domain_items[] = {
     /* Not implement yet */
     // {ATTR_DOMAIN_GEOMETRY, "GEOMETRY", 0, "Geometry", "Attribute on (whole) geometry"},
-    {ATTR_DOMAIN_VERTEX, "VERTEX", 0, "Vertex", "Attribute on mesh vertex"},
+    {ATTR_DOMAIN_POINT, "POINT", 0, "Point", "Attribute on point"},
     {ATTR_DOMAIN_EDGE, "EDGE", 0, "Edge", "Attribute on mesh edge"},
     {ATTR_DOMAIN_CORNER, "CORNER", 0, "Corner", "Attribute on mesh polygon corner"},
     {ATTR_DOMAIN_POLYGON, "POLYGON", 0, "Polygon", "Attribute on mesh polygons"},
     /* Not implement yet */
     // {ATTR_DOMAIN_GRIDS, "GRIDS", 0, "Grids", "Attribute on mesh multires grids"},
-    {ATTR_DOMAIN_POINT, "POINT", 0, "Point", "Attribute on point"},
     {ATTR_DOMAIN_CURVE, "CURVE", 0, "Curve", "Attribute on hair curve"},
     {0, NULL, 0, NULL, NULL},
 };
@@ -117,7 +116,7 @@ const EnumPropertyItem *rna_enum_attribute_domain_itemf(ID *id, bool *r_free)
     if (id_type == ID_HA && !ELEM(domain_item->value, ATTR_DOMAIN_POINT, ATTR_DOMAIN_CURVE)) {
       continue;
     }
-    if (id_type == ID_ME && ELEM(domain_item->value, ATTR_DOMAIN_POINT, ATTR_DOMAIN_CURVE)) {
+    if (id_type == ID_ME && ELEM(domain_item->value, ATTR_DOMAIN_CURVE)) {
       continue;
     }
 
@@ -619,7 +618,7 @@ static void rna_def_attribute_group(BlenderRNA *brna)
   parm = RNA_def_enum(func,
                       "domain",
                       rna_enum_attribute_domain_items,
-                      ATTR_DOMAIN_VERTEX,
+                      ATTR_DOMAIN_POINT,
                       "Domain",
                       "Type of element that attribute is stored on");
   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index 37e23455234..7552ffdda85 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -1888,7 +1888,7 @@ static const EnumPropertyItem *rna_GeometryNodeAttributeRandom_type_itemf(
 
 static bool attribute_random_domain_supported(int value)
 {
-  return ELEM(value, ATTR_DOMAIN_VERTEX, ATTR_DOMAIN_POINT);
+  return value == ATTR_DOMAIN_POINT;
 }
 static const EnumPropertyItem *rna_GeometryNodeAttributeRandom_domain_itemf(
     bContext *UNUSED(C), PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free)
@@ -8334,7 +8334,7 @@ static void def_geo_attribute_create_common(StructRNA *srna,
   if (domain_items_func != NULL) {
     RNA_def_property_enum_funcs(prop, NULL, NULL, domain_items_func);
   }
-  RNA_def_property_enum_default(prop, ATTR_DOMAIN_VERTEX);
+  RNA_def_property_enum_default(prop, ATTR_DOMAIN_POINT);
   RNA_def_property_ui_text(prop, "Domain", "");
   RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
 }
diff --git a/source/blender/nodes/geometry/nodes/node_geo_point_distribute.cc b/source/blender/nodes/geometry/nodes/node_geo_point_distribute.cc
index 37f027a83d8..d8db45479c6 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_point_distribute.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_point_distribute.cc
@@ -113,7 +113,7 @@ static void geo_point_distribute_exec(GeoNodeExecParams params)
   const Mesh *mesh_in = mesh_component.get_for_read();
 
   const FloatReadAttribute density_factors = mesh_component.attribute_get_for_read<float>(
-      density_attribute, ATTR_DOMAIN_VERTEX, 1.0f);
+      density_attribute, ATTR_DOMAIN_POINT, 1.0f);
 
   Vector<float3> points = scatter_points_from_mesh(mesh_in, density, density_factors);
 
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 59bfd3d6389..c6840190046 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_point_instance.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_point_instance.cc
@@ -37,12 +37,12 @@ namespace blender::nodes {
 
 static void add_instances_from_geometry_component(InstancesComponent &instances,
                                                   const GeometryComponent &src_geometry,
-                                                  const AttributeDo

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list