[Bf-blender-cvs] [ceb500df038] blender-v2.92-release: Geometry Nodes: fix losing data when attribute has incorrect type
Jacques Lucke
noreply at git.blender.org
Thu Jan 21 17:03:01 CET 2021
Commit: ceb500df0384dee3bda07f10a0a93acf40ac25c9
Author: Jacques Lucke
Date: Thu Jan 21 16:55:44 2021 +0100
Branches: blender-v2.92-release
https://developer.blender.org/rBceb500df0384dee3bda07f10a0a93acf40ac25c9
Geometry Nodes: fix losing data when attribute has incorrect type
Differential Revision: https://developer.blender.org/D10165
===================================================================
M source/blender/blenkernel/intern/attribute_access.cc
===================================================================
diff --git a/source/blender/blenkernel/intern/attribute_access.cc b/source/blender/blenkernel/intern/attribute_access.cc
index 2e1094364fd..e1e8d06b9ec 100644
--- a/source/blender/blenkernel/intern/attribute_access.cc
+++ b/source/blender/blenkernel/intern/attribute_access.cc
@@ -862,10 +862,19 @@ OutputAttributePtr::OutputAttributePtr(GeometryComponent &component,
const int domain_size = component.attribute_domain_size(domain);
void *buffer = MEM_malloc_arrayN(domain_size, cpp_type->size(), __func__);
- cpp_type->construct_default_n(buffer, domain_size);
+ GMutableSpan new_span{*cpp_type, buffer, domain_size};
+
+ /* Copy converted values from conflicting attribute, in case the value is read.
+ * TODO: An optimization could be to not do this, when the caller says that the attribute will
+ * only be written. */
+ ReadAttributePtr src_attribute = component.attribute_get_for_read(
+ final_name, domain, data_type, nullptr);
+ for (const int i : blender::IndexRange(domain_size)) {
+ src_attribute->get(i, new_span[i]);
+ }
attribute_ = std::make_unique<blender::bke::TemporaryWriteAttribute>(
- domain, GMutableSpan{*cpp_type, buffer, domain_size}, component, std::move(final_name));
+ domain, new_span, component, std::move(final_name));
}
/* Store the computed attribute. If it was stored from the beginning already, nothing is done. This
More information about the Bf-blender-cvs
mailing list