Attributes: Reset various runtime data for writing files

These fields are always reset at runtime. Writing zeros should be easier
to compress since a lot of other data is zeroed, and it also makes it
easier for developers to filter out noise when looking at data buffers.

Pull Request: https://projects.blender.org/blender/blender/pulls/144582
This commit is contained in:
Hans Goudey
2025-08-14 23:39:16 +02:00
committed by Hans Goudey
parent 3846f0e0b0
commit 814d04aaf9
2 changed files with 7 additions and 0 deletions

View File

@@ -194,6 +194,7 @@ AttributeStorage::AttributeStorage()
{
this->dna_attributes = nullptr;
this->dna_attributes_num = 0;
memset(this->_pad, 0, sizeof(this->_pad));
this->runtime = MEM_new<AttributeStorageRuntime>(__func__);
}
@@ -600,6 +601,7 @@ void attribute_storage_blend_write_prepare(AttributeStorage &data,
write_data.attributes.append(attribute_dna);
});
data.runtime = nullptr;
}
static void write_shared_array(BlendWriter &writer,

View File

@@ -5141,6 +5141,11 @@ void CustomData_blend_write_prepare(CustomData &data,
}
data.totlayer = layers_to_write.size();
data.maxlayer = data.totlayer;
std::fill_n(data.typemap, CD_NUMTYPES, 0);
data.totsize = 0;
if (layers_to_write.is_empty()) {
data.layers = nullptr;
}
/* NOTE: `data->layers` may be null, this happens when adding
* a legacy #MPoly struct to a mesh with no other face attributes.