Simulation Nodes: bake simulation states to disk #106937
|
@ -308,19 +308,43 @@ static void load_attributes(const io::serialize::ArrayValue &io_attributes,
|
|||
|
||||
const eAttrDomain domain = get_domain_from_io_name(*domain_str);
|
||||
const eCustomDataType data_type = get_data_type_from_io_name(*type_str);
|
||||
|
||||
bke::GSpanAttributeWriter attribute = attributes.lookup_or_add_for_write_only_span(
|
||||
*name, domain, data_type);
|
||||
if (!attribute) {
|
||||
const CPPType *cpp_type = custom_data_type_to_cpp_type(data_type);
|
||||
if (!cpp_type) {
|
||||
continue;
|
||||
}
|
||||
const CPPType &cpp_type = attribute.span.type();
|
||||
if (attributes.contains(*name)) {
|
||||
bke::GSpanAttributeWriter attribute = attributes.lookup_or_add_for_write_only_span(
|
||||
*name, domain, data_type);
|
||||
if (!attribute) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!read_bdata_simple_gspan(bdata_reader, *io_data, attribute.span)) {
|
||||
cpp_type.value_initialize_n(attribute.span.data(), attribute.span.size());
|
||||
if (!read_bdata_simple_gspan(bdata_reader, *io_data, attribute.span)) {
|
||||
cpp_type->value_initialize_n(attribute.span.data(), attribute.span.size());
|
||||
}
|
||||
|
||||
attribute.finish();
|
||||
}
|
||||
else {
|
||||
const int domain_size = attributes.domain_size(domain);
|
||||
const std::optional<BDataSharing::SharingInfoWithData> data = bdata_sharing.read_shared(
|
||||
*io_data, [&]() {
|
||||
void *data_mem = MEM_mallocN_aligned(
|
||||
domain_size * cpp_type->size(), cpp_type->alignment(), __func__);
|
||||
if (!read_bdata_simple_gspan(
|
||||
bdata_reader, *io_data, {*cpp_type, data_mem, domain_size})) {
|
||||
cpp_type->value_initialize_n(data_mem, domain_size);
|
||||
}
|
||||
return BDataSharing::SharingInfoWithData{implicit_sharing::info_for_mem_free(data_mem),
|
||||
data_mem};
|
||||
});
|
||||
if (!data) {
|
||||
continue;
|
||||
}
|
||||
attributes.add(
|
||||
*name, domain, data_type, AttributeInitShared(data->data, *data->sharing_info));
|
||||
data->sharing_info->remove_user_and_delete_if_last();
|
||||
}
|
||||
|
||||
attribute.finish();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue