Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacques Lucke <jacques@blender.org>2020-12-09 18:20:48 +0300
committerJacques Lucke <jacques@blender.org>2020-12-09 18:20:57 +0300
commit4a5f36638b0244b586607e76451669ffbc3c1174 (patch)
treec38ffdd8035e029b0c0451d91336b58fdf6bdffe /source/blender/blenkernel/intern/attribute_access.cc
parent25e151cc34715f4f27f2cecad252b02d1498ba15 (diff)
Geometry Nodes: simplify supporting different input socket types for attributes
This is a non-functional change. The functionality introduced in this commit is not used in master yet. It is used by nodes that are being developed in other branches though.
Diffstat (limited to 'source/blender/blenkernel/intern/attribute_access.cc')
-rw-r--r--source/blender/blenkernel/intern/attribute_access.cc33
1 files changed, 33 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/attribute_access.cc b/source/blender/blenkernel/intern/attribute_access.cc
index 9f5795291f0..d79168d5443 100644
--- a/source/blender/blenkernel/intern/attribute_access.cc
+++ b/source/blender/blenkernel/intern/attribute_access.cc
@@ -668,6 +668,39 @@ blender::bke::ReadAttributePtr GeometryComponent::attribute_get_constant_for_rea
domain, domain_size, *cpp_type, value);
}
+blender::bke::ReadAttributePtr GeometryComponent::attribute_get_constant_for_read_converted(
+ const AttributeDomain domain,
+ const CustomDataType in_data_type,
+ const CustomDataType out_data_type,
+ const void *value) const
+{
+ BLI_assert(this->attribute_domain_supported(domain));
+ if (value == nullptr || in_data_type == out_data_type) {
+ return this->attribute_get_constant_for_read(domain, out_data_type, value);
+ }
+
+ const blender::fn::CPPType *in_cpp_type = blender::bke::custom_data_type_to_cpp_type(
+ in_data_type);
+ const blender::fn::CPPType *out_cpp_type = blender::bke::custom_data_type_to_cpp_type(
+ out_data_type);
+ BLI_assert(in_cpp_type != nullptr);
+ BLI_assert(out_cpp_type != nullptr);
+
+ const blender::nodes::DataTypeConversions &conversions =
+ blender::nodes::get_implicit_type_conversions();
+ BLI_assert(conversions.is_convertible(*in_cpp_type, *out_cpp_type));
+
+ void *out_value = alloca(out_cpp_type->size());
+ conversions.convert(*in_cpp_type, *out_cpp_type, value, out_value);
+
+ const int domain_size = this->attribute_domain_size(domain);
+ blender::bke::ReadAttributePtr attribute = std::make_unique<blender::bke::ConstantReadAttribute>(
+ domain, domain_size, *out_cpp_type, out_value);
+
+ out_cpp_type->destruct(out_value);
+ return attribute;
+}
+
WriteAttributePtr GeometryComponent::attribute_try_ensure_for_write(const StringRef attribute_name,
const AttributeDomain domain,
const CustomDataType data_type)