[Bf-blender-cvs] [368647bd25d] master: Geometry Nodes: move geometry component type enum to C

Jacques Lucke noreply at git.blender.org
Wed Mar 10 11:53:44 CET 2021


Commit: 368647bd25d6bb0b32f5e439838c06e0e46ac8da
Author: Jacques Lucke
Date:   Wed Mar 10 11:53:17 2021 +0100
Branches: master
https://developer.blender.org/rB368647bd25d6bb0b32f5e439838c06e0e46ac8da

Geometry Nodes: move geometry component type enum to C

This allows us to use it in rna for the spreadsheet editor.

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

M	source/blender/blenkernel/BKE_geometry_set.h
M	source/blender/blenkernel/BKE_geometry_set.hh
M	source/blender/blenkernel/intern/geometry_component_instances.cc
M	source/blender/blenkernel/intern/geometry_component_mesh.cc
M	source/blender/blenkernel/intern/geometry_component_pointcloud.cc
M	source/blender/blenkernel/intern/geometry_component_volume.cc
M	source/blender/blenkernel/intern/geometry_set.cc
M	source/blender/blenkernel/intern/geometry_set_instances.cc
M	source/blender/editors/space_spreadsheet/spreadsheet_from_geometry.cc
M	source/blender/nodes/geometry/nodes/node_geo_point_distribute.cc

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

diff --git a/source/blender/blenkernel/BKE_geometry_set.h b/source/blender/blenkernel/BKE_geometry_set.h
index ac42674654f..08b4a25d946 100644
--- a/source/blender/blenkernel/BKE_geometry_set.h
+++ b/source/blender/blenkernel/BKE_geometry_set.h
@@ -28,6 +28,16 @@ struct Collection;
 struct GeometrySet;
 struct Object;
 
+/* Each geometry component has a specific type. The type determines what kind of data the component
+ * stores. Functions modifying a geometry will usually just modify a subset of the component types.
+ */
+typedef enum GeometryComponentType {
+  GEO_COMPONENT_TYPE_MESH = 0,
+  GEO_COMPONENT_TYPE_POINT_CLOUD = 1,
+  GEO_COMPONENT_TYPE_INSTANCES = 2,
+  GEO_COMPONENT_TYPE_VOLUME = 3,
+} GeometryComponentType;
+
 void BKE_geometry_set_free(struct GeometrySet *geometry_set);
 
 bool BKE_geometry_set_has_instances(const struct GeometrySet *geometry_set);
diff --git a/source/blender/blenkernel/BKE_geometry_set.hh b/source/blender/blenkernel/BKE_geometry_set.hh
index ad01814ce82..632fff07575 100644
--- a/source/blender/blenkernel/BKE_geometry_set.hh
+++ b/source/blender/blenkernel/BKE_geometry_set.hh
@@ -40,16 +40,6 @@ struct Object;
 struct PointCloud;
 struct Volume;
 
-/* Each geometry component has a specific type. The type determines what kind of data the component
- * stores. Functions modifying a geometry will usually just modify a subset of the component types.
- */
-enum class GeometryComponentType {
-  Mesh = 0,
-  PointCloud = 1,
-  Instances = 2,
-  Volume = 3,
-};
-
 enum class GeometryOwnershipType {
   /* The geometry is owned. This implies that it can be changed. */
   Owned = 0,
@@ -392,7 +382,7 @@ class MeshComponent : public GeometryComponent {
 
   bool is_empty() const final;
 
-  static constexpr inline GeometryComponentType static_type = GeometryComponentType::Mesh;
+  static constexpr inline GeometryComponentType static_type = GEO_COMPONENT_TYPE_MESH;
 
  private:
   const blender::bke::ComponentAttributeProviders *get_attribute_providers() const final;
@@ -422,7 +412,7 @@ class PointCloudComponent : public GeometryComponent {
 
   bool is_empty() const final;
 
-  static constexpr inline GeometryComponentType static_type = GeometryComponentType::PointCloud;
+  static constexpr inline GeometryComponentType static_type = GEO_COMPONENT_TYPE_POINT_CLOUD;
 
  private:
   const blender::bke::ComponentAttributeProviders *get_attribute_providers() const final;
@@ -462,7 +452,7 @@ class InstancesComponent : public GeometryComponent {
 
   bool is_empty() const final;
 
-  static constexpr inline GeometryComponentType static_type = GeometryComponentType::Instances;
+  static constexpr inline GeometryComponentType static_type = GEO_COMPONENT_TYPE_INSTANCES;
 };
 
 /** A geometry component that stores volume grids. */
@@ -484,5 +474,5 @@ class VolumeComponent : public GeometryComponent {
   const Volume *get_for_read() const;
   Volume *get_for_write();
 
-  static constexpr inline GeometryComponentType static_type = GeometryComponentType::Volume;
+  static constexpr inline GeometryComponentType static_type = GEO_COMPONENT_TYPE_VOLUME;
 };
diff --git a/source/blender/blenkernel/intern/geometry_component_instances.cc b/source/blender/blenkernel/intern/geometry_component_instances.cc
index a6ee7a1b918..68c551645d2 100644
--- a/source/blender/blenkernel/intern/geometry_component_instances.cc
+++ b/source/blender/blenkernel/intern/geometry_component_instances.cc
@@ -35,7 +35,7 @@ using blender::Span;
 /** \name Geometry Component Implementation
  * \{ */
 
-InstancesComponent::InstancesComponent() : GeometryComponent(GeometryComponentType::Instances)
+InstancesComponent::InstancesComponent() : GeometryComponent(GEO_COMPONENT_TYPE_INSTANCES)
 {
 }
 
diff --git a/source/blender/blenkernel/intern/geometry_component_mesh.cc b/source/blender/blenkernel/intern/geometry_component_mesh.cc
index 53defc89b7e..4019ceb123f 100644
--- a/source/blender/blenkernel/intern/geometry_component_mesh.cc
+++ b/source/blender/blenkernel/intern/geometry_component_mesh.cc
@@ -39,7 +39,7 @@ using blender::bke::ReadAttributePtr;
 /** \name Geometry Component Implementation
  * \{ */
 
-MeshComponent::MeshComponent() : GeometryComponent(GeometryComponentType::Mesh)
+MeshComponent::MeshComponent() : GeometryComponent(GEO_COMPONENT_TYPE_MESH)
 {
 }
 
@@ -466,14 +466,14 @@ ReadAttributePtr MeshComponent::attribute_try_adapt_domain(ReadAttributePtr attr
 
 static Mesh *get_mesh_from_component_for_write(GeometryComponent &component)
 {
-  BLI_assert(component.type() == GeometryComponentType::Mesh);
+  BLI_assert(component.type() == GEO_COMPONENT_TYPE_MESH);
   MeshComponent &mesh_component = static_cast<MeshComponent &>(component);
   return mesh_component.get_for_write();
 }
 
 static const Mesh *get_mesh_from_component_for_read(const GeometryComponent &component)
 {
-  BLI_assert(component.type() == GeometryComponentType::Mesh);
+  BLI_assert(component.type() == GEO_COMPONENT_TYPE_MESH);
   const MeshComponent &mesh_component = static_cast<const MeshComponent &>(component);
   return mesh_component.get_for_read();
 }
@@ -713,7 +713,7 @@ class VertexGroupsAttributeProvider final : public DynamicAttributesProvider {
   ReadAttributePtr try_get_for_read(const GeometryComponent &component,
                                     const StringRef attribute_name) const final
   {
-    BLI_assert(component.type() == GeometryComponentType::Mesh);
+    BLI_assert(component.type() == GEO_COMPONENT_TYPE_MESH);
     const MeshComponent &mesh_component = static_cast<const MeshComponent &>(component);
     const Mesh *mesh = mesh_component.get_for_read();
     const int vertex_group_index = mesh_component.vertex_group_names().lookup_default_as(
@@ -733,7 +733,7 @@ class VertexGroupsAttributeProvider final : public DynamicAttributesProvider {
   WriteAttributePtr try_get_for_write(GeometryComponent &component,
                                       const StringRef attribute_name) const final
   {
-    BLI_assert(component.type() == GeometryComponentType::Mesh);
+    BLI_assert(component.type() == GEO_COMPONENT_TYPE_MESH);
     MeshComponent &mesh_component = static_cast<MeshComponent &>(component);
     Mesh *mesh = mesh_component.get_for_write();
     if (mesh == nullptr) {
@@ -758,7 +758,7 @@ class VertexGroupsAttributeProvider final : public DynamicAttributesProvider {
 
   bool try_delete(GeometryComponent &component, const StringRef attribute_name) const final
   {
-    BLI_assert(component.type() == GeometryComponentType::Mesh);
+    BLI_assert(component.type() == GEO_COMPONENT_TYPE_MESH);
     MeshComponent &mesh_component = static_cast<MeshComponent &>(component);
 
     const int vertex_group_index = mesh_component.vertex_group_names().pop_default_as(
@@ -783,7 +783,7 @@ class VertexGroupsAttributeProvider final : public DynamicAttributesProvider {
   bool foreach_attribute(const GeometryComponent &component,
                          const AttributeForeachCallback callback) const final
   {
-    BLI_assert(component.type() == GeometryComponentType::Mesh);
+    BLI_assert(component.type() == GEO_COMPONENT_TYPE_MESH);
     const MeshComponent &mesh_component = static_cast<const MeshComponent &>(component);
     for (const auto item : mesh_component.vertex_group_names().items()) {
       const StringRefNull name = item.key;
diff --git a/source/blender/blenkernel/intern/geometry_component_pointcloud.cc b/source/blender/blenkernel/intern/geometry_component_pointcloud.cc
index d7f0bf55bc9..c428e93cfa9 100644
--- a/source/blender/blenkernel/intern/geometry_component_pointcloud.cc
+++ b/source/blender/blenkernel/intern/geometry_component_pointcloud.cc
@@ -27,7 +27,7 @@
 /** \name Geometry Component Implementation
  * \{ */
 
-PointCloudComponent::PointCloudComponent() : GeometryComponent(GeometryComponentType::PointCloud)
+PointCloudComponent::PointCloudComponent() : GeometryComponent(GEO_COMPONENT_TYPE_POINT_CLOUD)
 {
 }
 
diff --git a/source/blender/blenkernel/intern/geometry_component_volume.cc b/source/blender/blenkernel/intern/geometry_component_volume.cc
index 5e35a10fe3d..fd2327e0bf5 100644
--- a/source/blender/blenkernel/intern/geometry_component_volume.cc
+++ b/source/blender/blenkernel/intern/geometry_component_volume.cc
@@ -24,7 +24,7 @@
 /** \name Geometry Component Implementation
  * \{ */
 
-VolumeComponent::VolumeComponent() : GeometryComponent(GeometryComponentType::Volume)
+VolumeComponent::VolumeComponent() : GeometryComponent(GEO_COMPONENT_TYPE_VOLUME)
 {
 }
 
diff --git a/source/blender/blenkernel/intern/geometry_set.cc b/source/blender/blenkernel/intern/geometry_set.cc
index e7fb184023d..f47d88cbeed 100644
--- a/source/blender/blenkernel/intern/geometry_set.cc
+++ b/source/blender/blenkernel/intern/geometry_set.cc
@@ -56,13 +56,13 @@ GeometryComponent ::~GeometryComponent()
 GeometryComponent *GeometryComponent::create(GeometryComponentType component_type)
 {
   switch (component_type) {
-    case GeometryComponentType::Mesh:
+    case GEO_COMPONENT_TYPE_MESH:
       return new MeshComponent();
-    case GeometryComponentType::PointCloud:
+    case GEO_COMPONENT_TYPE_POINT_CLOUD:
       return new PointCloudComponent();
-    case GeometryComponentType::Instances:
+    case GEO_COMPONENT_TYPE_INSTANCES:
       return new InstancesComponent();
-    case GeometryComponentType::Volume:
+    case GEO_COMPONENT_TYPE_VOLUME:
       return new VolumeComponent();
   }
   BLI_assert(false);
diff --git a/source/blender/blenkernel/intern/geometry_set_instances.cc b/source/blender/blenkernel/intern/geometry_set_instances.cc
index f3006385da3..70b48a253ed 100644
--- a/source/blender/blenkernel/intern/geometry_set_instances.cc
+++ b/source/blender/blenkernel/intern/geometry_set_instances.cc
@@ -371,9 +371,9 @@ static void join_instance_groups_mesh(Span<GeometryInstanceGroup> set_groups,
   dst_component.replace(new_mesh);
 
   Vector<GeometryComponentType> component_types;
-  component_types.append(GeometryComponentType::Mesh);
+  component_types.append(GEO_COMPONENT_TYPE_MESH);
   if (convert_points_to_vertices) {
-    component_types.append(GeometryComponentType::PointCloud);
+    component_types.append(GEO_COMPONENT_TYPE_POINT_CLOUD);
   }
 
   /* Don't copy attr

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list