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:
authorHans Goudey <h.goudey@me.com>2021-01-15 20:04:32 +0300
committerHans Goudey <h.goudey@me.com>2021-01-15 20:04:32 +0300
commit0b0e45252b11bbc1c0d96a3e04a4087d02f765e3 (patch)
tree63e8f90c56eed01c1d8c818af02c9984859575a0 /source/blender/blenkernel/intern/attribute_access.cc
parent3732508c64ad51c77a6fb83a2444af104d95cfd9 (diff)
Geometry Nodes: Use a default value in the point scale node
This commit adds the ability to provide a default value to `attribute_try_get_for_output` and uses it for the `Point Scale` node, which is important because the node uses multiplication. The idea is to keep "name-specific" functionality in nodes rather than in the attribute API, otherwise the complexity will be hard to keep track of. So this fix doesn't apply to the Attribute Vector Math node, but hopfully that is okay since that's now a lower level node for this purpose anyway. Differential Revision: https://developer.blender.org/D10115
Diffstat (limited to 'source/blender/blenkernel/intern/attribute_access.cc')
-rw-r--r--source/blender/blenkernel/intern/attribute_access.cc8
1 files changed, 7 insertions, 1 deletions
diff --git a/source/blender/blenkernel/intern/attribute_access.cc b/source/blender/blenkernel/intern/attribute_access.cc
index 6739294a2c4..a7939beae90 100644
--- a/source/blender/blenkernel/intern/attribute_access.cc
+++ b/source/blender/blenkernel/intern/attribute_access.cc
@@ -814,7 +814,8 @@ blender::bke::ReadAttributePtr GeometryComponent::attribute_get_constant_for_rea
OutputAttributePtr GeometryComponent::attribute_try_get_for_output(const StringRef attribute_name,
const AttributeDomain domain,
- const CustomDataType data_type)
+ const CustomDataType data_type,
+ const void *default_value)
{
BLI_assert(this->attribute_domain_with_type_supported(domain, data_type));
@@ -827,6 +828,11 @@ OutputAttributePtr GeometryComponent::attribute_try_get_for_output(const StringR
if (!attribute) {
this->attribute_try_create(attribute_name, domain, data_type);
attribute = this->attribute_try_get_for_write(attribute_name);
+ if (default_value != nullptr) {
+ void *data = attribute->get_span_for_write_only().data();
+ cpp_type->fill_initialized(default_value, data, attribute->size());
+ attribute->apply_span();
+ }
return OutputAttributePtr(std::move(attribute));
}