[Bf-blender-cvs] [2f0f2696848] geometry-nodes-point-separate-node: Point Separate Node: Change has_attribute function
Hans Goudey
noreply at git.blender.org
Thu Dec 3 05:08:58 CET 2020
Commit: 2f0f2696848a3294731cf723040f3d33b4f1235d
Author: Hans Goudey
Date: Wed Dec 2 09:08:33 2020 -0500
Branches: geometry-nodes-point-separate-node
https://developer.blender.org/rB2f0f2696848a3294731cf723040f3d33b4f1235d
Point Separate Node: Change has_attribute function
===================================================================
M source/blender/blenkernel/BKE_geometry_set.hh
M source/blender/blenkernel/intern/attribute_access.cc
M source/blender/nodes/geometry/nodes/node_geo_point_separate.cc
===================================================================
diff --git a/source/blender/blenkernel/BKE_geometry_set.hh b/source/blender/blenkernel/BKE_geometry_set.hh
index bcf9bef4708..00f461bcd84 100644
--- a/source/blender/blenkernel/BKE_geometry_set.hh
+++ b/source/blender/blenkernel/BKE_geometry_set.hh
@@ -88,6 +88,8 @@ class GeometryComponent {
GeometryComponentType type() const;
+ bool attribute_exists(const blender::StringRef attribute_name) const;
+
/* Returns true when the geometry component supports this attribute domain. */
virtual bool attribute_domain_supported(const AttributeDomain domain) const;
/* Returns true when the given data type is supported in the given domain. */
@@ -122,7 +124,6 @@ class GeometryComponent {
const AttributeDomain domain,
const CustomDataType data_type);
- virtual bool has_attribute(const blender::StringRef attribute_name) const;
virtual blender::Set<std::string> attribute_names() const;
virtual bool is_empty() const;
@@ -294,7 +295,6 @@ class MeshComponent : public GeometryComponent {
const AttributeDomain domain,
const CustomDataType data_type) final;
- bool has_attribute(const blender::StringRef attribute_name) const;
blender::Set<std::string> attribute_names() const final;
bool is_empty() const final;
@@ -337,7 +337,6 @@ class PointCloudComponent : public GeometryComponent {
const AttributeDomain domain,
const CustomDataType data_type) final;
- bool has_attribute(const blender::StringRef attribute_name) const;
blender::Set<std::string> attribute_names() const final;
bool is_empty() const final;
diff --git a/source/blender/blenkernel/intern/attribute_access.cc b/source/blender/blenkernel/intern/attribute_access.cc
index adedf1a74cd..2edf3981c38 100644
--- a/source/blender/blenkernel/intern/attribute_access.cc
+++ b/source/blender/blenkernel/intern/attribute_access.cc
@@ -590,8 +590,12 @@ Set<std::string> GeometryComponent::attribute_names() const
return {};
}
-bool GeometryComponent::has_attribute(const blender::StringRef UNUSED(attribute_name)) const
+bool GeometryComponent::attribute_exists(const blender::StringRef attribute_name) const
{
+ ReadAttributePtr attribute = this->attribute_try_get_for_read(attribute_name);
+ if (attribute) {
+ return true;
+ }
return false;
}
@@ -808,11 +812,6 @@ bool PointCloudComponent::attribute_try_create(const StringRef attribute_name,
return true;
}
-bool PointCloudComponent::has_attribute(const blender::StringRef attribute_name) const
-{
- return custom_data_has_layer_with_name(pointcloud_->pdata, attribute_name);
-}
-
Set<std::string> PointCloudComponent::attribute_names() const
{
if (pointcloud_ == nullptr) {
@@ -1069,11 +1068,6 @@ bool MeshComponent::attribute_try_create(const StringRef attribute_name,
}
}
-bool MeshComponent::has_attribute(const blender::StringRef attribute_name) const
-{
- return custom_data_has_layer_with_name(mesh_->pdata, attribute_name);
-}
-
Set<std::string> MeshComponent::attribute_names() const
{
if (mesh_ == nullptr) {
diff --git a/source/blender/nodes/geometry/nodes/node_geo_point_separate.cc b/source/blender/nodes/geometry/nodes/node_geo_point_separate.cc
index 1fa2c87c95e..23e1c720161 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_point_separate.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_point_separate.cc
@@ -84,13 +84,13 @@ static void separate_component_attributes(const GeometryComponent &in_component,
* attributes will already exist on new components by definition. It should always be possible
* to recreate the attribute on the same component type. Also, if one of the new components
* has the attribute the other one should have it too, but check independently to be safe. */
- if (!out_component_a.has_attribute(name)) {
+ if (!out_component_a.attribute_exists(name)) {
if (!out_component_a.attribute_try_create(name, domain, data_type)) {
BLI_assert(false);
continue;
}
}
- if (!out_component_b.has_attribute(name)) {
+ if (!out_component_b.attribute_exists(name)) {
if (!out_component_b.attribute_try_create(name, domain, data_type)) {
BLI_assert(false);
continue;
@@ -146,7 +146,7 @@ static Array<bool> calculate_split(const GeometryComponent &component,
}
*r_b_total = in_total - *r_a_total;
- return a_or_b; /* TODO: Can't return a span here? How to do that? */
+ return a_or_b;
}
/* Much of the attribute code can be handled generically for every geometry component type. */
More information about the Bf-blender-cvs
mailing list