Cleanup: Blendwrite: Move code deciding if an ID should be written out of ID callbacks.
This was not really useful, and added estra useless steps in case and ID should not actually be written. Further more, it prevented clearing the usercount on write, which can be cause a false positive 'chanhged' detection in undo/redo case.
This commit is contained in:
@@ -114,27 +114,26 @@ static void shapekey_blend_write(BlendWriter *writer, ID *id, const void *id_add
|
||||
{
|
||||
Key *key = (Key *)id;
|
||||
const bool is_undo = BLO_write_is_undo(writer);
|
||||
if (key->id.us > 0 || is_undo) {
|
||||
/* write LibData */
|
||||
BLO_write_id_struct(writer, Key, id_address, &key->id);
|
||||
BKE_id_blend_write(writer, &key->id);
|
||||
|
||||
if (key->adt) {
|
||||
BKE_animdata_blend_write(writer, key->adt);
|
||||
/* write LibData */
|
||||
BLO_write_id_struct(writer, Key, id_address, &key->id);
|
||||
BKE_id_blend_write(writer, &key->id);
|
||||
|
||||
if (key->adt) {
|
||||
BKE_animdata_blend_write(writer, key->adt);
|
||||
}
|
||||
|
||||
/* direct data */
|
||||
LISTBASE_FOREACH (KeyBlock *, kb, &key->block) {
|
||||
KeyBlock tmp_kb = *kb;
|
||||
/* Do not store actual geometry data in case this is a library override ID. */
|
||||
if (ID_IS_OVERRIDE_LIBRARY(key) && !is_undo) {
|
||||
tmp_kb.totelem = 0;
|
||||
tmp_kb.data = NULL;
|
||||
}
|
||||
|
||||
/* direct data */
|
||||
LISTBASE_FOREACH (KeyBlock *, kb, &key->block) {
|
||||
KeyBlock tmp_kb = *kb;
|
||||
/* Do not store actual geometry data in case this is a library override ID. */
|
||||
if (ID_IS_OVERRIDE_LIBRARY(key) && !is_undo) {
|
||||
tmp_kb.totelem = 0;
|
||||
tmp_kb.data = NULL;
|
||||
}
|
||||
BLO_write_struct_at_address(writer, KeyBlock, kb, &tmp_kb);
|
||||
if (tmp_kb.data != NULL) {
|
||||
BLO_write_raw(writer, tmp_kb.totelem * key->elemsize, tmp_kb.data);
|
||||
}
|
||||
BLO_write_struct_at_address(writer, KeyBlock, kb, &tmp_kb);
|
||||
if (tmp_kb.data != NULL) {
|
||||
BLO_write_raw(writer, tmp_kb.totelem * key->elemsize, tmp_kb.data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user