Fix: Geometry Nodes: Create instance attribute of the right type
`attributes_to_propagate` is map of all attributes to propagate from different components. For attribute propagation three different components is taken. Each one can have named attribute with specific type. Current implementation of propagation: Try to make implicit share attribute. Or create/copy. This doesn't takes into account `attributes_to_propagate`' data type info. So, this cause crash for case, there multiple component have same name attribute with different type. Fix: Try to make implicit share attribute with correct type. Or create, copy typed version. Pull Request: https://projects.blender.org/blender/blender/pulls/110146
This commit is contained in:
committed by
Hans Goudey
parent
b93dbaba1d
commit
690deeda18
@@ -161,25 +161,27 @@ static void add_instances_from_component(
|
||||
bke::MutableAttributeAccessor dst_attributes = dst_component.attributes_for_write();
|
||||
for (const auto item : attributes_to_propagate.items()) {
|
||||
const AttributeIDRef &id = item.key;
|
||||
const bke::GAttributeReader src = src_attributes.lookup(id, ATTR_DOMAIN_POINT);
|
||||
const eCustomDataType data_type = item.value.data_type;
|
||||
const bke::GAttributeReader src = src_attributes.lookup(id, ATTR_DOMAIN_POINT, data_type);
|
||||
if (!src) {
|
||||
/* Domain interpolation can fail if the source domain is empty. */
|
||||
continue;
|
||||
}
|
||||
|
||||
const eCustomDataType type = bke::cpp_type_to_custom_data_type(src.varray.type());
|
||||
if (src.varray.size() == dst_component.instances_num() && src.sharing_info &&
|
||||
src.varray.is_span()) {
|
||||
const bke::AttributeInitShared init(src.varray.get_internal_span().data(),
|
||||
*src.sharing_info);
|
||||
dst_attributes.add(id, ATTR_DOMAIN_INSTANCE, type, init);
|
||||
}
|
||||
else {
|
||||
GSpanAttributeWriter dst = dst_attributes.lookup_or_add_for_write_only_span(
|
||||
id, ATTR_DOMAIN_INSTANCE, type);
|
||||
array_utils::gather(src.varray, selection, dst.span.slice(start_len, select_len));
|
||||
dst.finish();
|
||||
if (!dst_attributes.contains(id)) {
|
||||
if (src.varray.size() == dst_component.instances_num() && src.sharing_info &&
|
||||
src.varray.is_span()) {
|
||||
const bke::AttributeInitShared init(src.varray.get_internal_span().data(),
|
||||
*src.sharing_info);
|
||||
dst_attributes.add(id, ATTR_DOMAIN_INSTANCE, data_type, init);
|
||||
continue;
|
||||
}
|
||||
dst_attributes.add(id, ATTR_DOMAIN_INSTANCE, data_type, bke::AttributeInitConstruct());
|
||||
}
|
||||
|
||||
GSpanAttributeWriter dst = dst_attributes.lookup_for_write_span(id);
|
||||
array_utils::gather(src.varray, selection, dst.span.slice(start_len, select_len));
|
||||
dst.finish();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user