Fix: GPv3: Make sure to call `.save()` on attribute writer

In the draw tool in the `process_extension_sample` we would
create an `GSpanAttributeWriter` to initialize the default values for
the new points, but we would return early for curve attributes.
This return needs to happen before we create the `GSpanAttributeWriter`.
This commit is contained in:
Falk David 2023-10-23 10:43:09 +02:00
parent 036e494564
commit 567cc7cf9f
1 changed files with 11 additions and 15 deletions

View File

@ -441,21 +441,17 @@ struct PaintOperationExecutor {
/* Initialize the rest of the attributes with default values. */
Set<std::string> attributes_to_skip{{"position", "radius", "opacity", "vertex_color"}};
attributes.for_all(
[&](const bke::AttributeIDRef &id, const bke::AttributeMetaData /*meta_data*/) {
if (attributes_to_skip.contains(id.name())) {
return true;
}
bke::GSpanAttributeWriter attribute = attributes.lookup_for_write_span(id);
if (attribute.domain != ATTR_DOMAIN_POINT) {
return true;
}
const CPPType &type = attribute.span.type();
GMutableSpan new_data = attribute.span.slice(new_range);
type.fill_assign_n(type.default_value(), new_data.data(), new_data.size());
attribute.finish();
return true;
});
attributes.for_all([&](const bke::AttributeIDRef &id, const bke::AttributeMetaData meta_data) {
if (attributes_to_skip.contains(id.name()) || meta_data.domain != ATTR_DOMAIN_POINT) {
return true;
}
bke::GSpanAttributeWriter attribute = attributes.lookup_for_write_span(id);
const CPPType &type = attribute.span.type();
GMutableSpan new_data = attribute.span.slice(new_range);
type.fill_assign_n(type.default_value(), new_data.data(), new_data.size());
attribute.finish();
return true;
});
}
void execute(PaintOperation &self, const bContext &C, const InputSample &extension_sample)