[Bf-blender-cvs] [bce42fbfe4b] geometry-nodes-point-separate-node: Attribute Access: Add a "has_attribute" method
Hans Goudey
noreply at git.blender.org
Wed Dec 2 04:35:05 CET 2020
Commit: bce42fbfe4b61d7351eac3f912729e721512f52a
Author: Hans Goudey
Date: Tue Dec 1 22:31:00 2020 -0500
Branches: geometry-nodes-point-separate-node
https://developer.blender.org/rBbce42fbfe4b61d7351eac3f912729e721512f52a
Attribute Access: Add a "has_attribute" method
===================================================================
M source/blender/blenkernel/BKE_geometry_set.hh
M source/blender/blenkernel/intern/attribute_access.cc
===================================================================
diff --git a/source/blender/blenkernel/BKE_geometry_set.hh b/source/blender/blenkernel/BKE_geometry_set.hh
index ef3ae3c381c..bcf9bef4708 100644
--- a/source/blender/blenkernel/BKE_geometry_set.hh
+++ b/source/blender/blenkernel/BKE_geometry_set.hh
@@ -122,6 +122,7 @@ 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;
@@ -293,6 +294,7 @@ 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;
@@ -335,6 +337,7 @@ 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 2345c834be4..adedf1a74cd 100644
--- a/source/blender/blenkernel/intern/attribute_access.cc
+++ b/source/blender/blenkernel/intern/attribute_access.cc
@@ -590,6 +590,11 @@ Set<std::string> GeometryComponent::attribute_names() const
return {};
}
+bool GeometryComponent::has_attribute(const blender::StringRef UNUSED(attribute_name)) const
+{
+ return false;
+}
+
static ReadAttributePtr try_adapt_data_type(ReadAttributePtr attribute,
const blender::fn::CPPType &to_type)
{
@@ -803,6 +808,11 @@ 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) {
@@ -1059,6 +1069,11 @@ 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) {
More information about the Bf-blender-cvs
mailing list