diff options
author | Jacques Lucke <jacques@blender.org> | 2021-03-10 13:53:17 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2021-03-10 13:53:31 +0300 |
commit | 368647bd25d6bb0b32f5e439838c06e0e46ac8da (patch) | |
tree | c7c427ef51416358d34413b67f74836db3f96e47 | |
parent | 122fefcc8589a09d4e89ed3045f29f07ec6564e9 (diff) |
Geometry Nodes: move geometry component type enum to C
This allows us to use it in rna for the spreadsheet editor.
10 files changed, 35 insertions, 35 deletions
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 attributes that are stored directly in the mesh data structs. */ @@ -402,9 +402,9 @@ static void join_instance_groups_pointcloud(Span<GeometryInstanceGroup> set_grou PointCloud *pointcloud = BKE_pointcloud_new_nomain(totpoint); dst_component.replace(pointcloud); Map<std::string, AttributeKind> attributes; - gather_attribute_info(attributes, {GeometryComponentType::PointCloud}, set_groups, {}); + gather_attribute_info(attributes, {GEO_COMPONENT_TYPE_POINT_CLOUD}, set_groups, {}); join_attributes(set_groups, - {GeometryComponentType::PointCloud}, + {GEO_COMPONENT_TYPE_POINT_CLOUD}, attributes, static_cast<GeometryComponent &>(dst_component)); } diff --git a/source/blender/editors/space_spreadsheet/spreadsheet_from_geometry.cc b/source/blender/editors/space_spreadsheet/spreadsheet_from_geometry.cc index fa1a3549b86..8459973ed4a 100644 --- a/source/blender/editors/space_spreadsheet/spreadsheet_from_geometry.cc +++ b/source/blender/editors/space_spreadsheet/spreadsheet_from_geometry.cc @@ -408,7 +408,7 @@ std::unique_ptr<SpreadsheetDrawer> spreadsheet_drawer_from_geometry_attributes(c "geometry set"); const AttributeDomain domain = ATTR_DOMAIN_POINT; - const GeometryComponentType component_type = GeometryComponentType::Mesh; + const GeometryComponentType component_type = GEO_COMPONENT_TYPE_MESH; const GeometryComponent *component = geometry_set.get_component_for_read(component_type); if (component == nullptr) { return {}; @@ -425,7 +425,7 @@ std::unique_ptr<SpreadsheetDrawer> spreadsheet_drawer_from_geometry_attributes(c } /* The filter below only works for mesh vertices currently. */ - BLI_assert(domain == ATTR_DOMAIN_POINT && component_type == GeometryComponentType::Mesh); + BLI_assert(domain == ATTR_DOMAIN_POINT && component_type == GEO_COMPONENT_TYPE_MESH); Span<int64_t> visible_rows = filter_visible_mesh_vertex_rows( C, object_eval, static_cast<const MeshComponent *>(component), *resources); 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 742383f5b46..19dd8564a38 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_point_distribute.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_point_distribute.cc @@ -695,7 +695,7 @@ static void geo_node_point_distribute_exec(GeoNodeExecParams params) Map<std::string, AttributeKind> attributes; bke::gather_attribute_info( - attributes, {GeometryComponentType::Mesh}, set_groups, {"position", "normal", "id"}); + attributes, {GEO_COMPONENT_TYPE_MESH}, set_groups, {"position", "normal", "id"}); add_remaining_point_attributes(set_groups, instance_start_offsets, attributes, |