From 0f49e4832cf2afad437aa16ebbbe37191de9af71 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Thu, 19 Aug 2021 11:13:55 +0200 Subject: 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. --- source/blender/blenkernel/intern/armature.c | 31 ++++++++++++++--------------- 1 file changed, 15 insertions(+), 16 deletions(-) (limited to 'source/blender/blenkernel/intern/armature.c') diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 1f02b084534..87320c88b1b 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -212,25 +212,24 @@ static void write_bone(BlendWriter *writer, Bone *bone) static void armature_blend_write(BlendWriter *writer, ID *id, const void *id_address) { bArmature *arm = (bArmature *)id; - if (arm->id.us > 0 || BLO_write_is_undo(writer)) { - /* Clean up, important in undo case to reduce false detection of changed datablocks. */ - arm->bonehash = NULL; - arm->edbo = NULL; - /* Must always be cleared (armatures don't have their own edit-data). */ - arm->needs_flush_to_id = 0; - arm->act_edbone = NULL; - BLO_write_id_struct(writer, bArmature, id_address, &arm->id); - BKE_id_blend_write(writer, &arm->id); + /* Clean up, important in undo case to reduce false detection of changed datablocks. */ + arm->bonehash = NULL; + arm->edbo = NULL; + /* Must always be cleared (armatures don't have their own edit-data). */ + arm->needs_flush_to_id = 0; + arm->act_edbone = NULL; - if (arm->adt) { - BKE_animdata_blend_write(writer, arm->adt); - } + BLO_write_id_struct(writer, bArmature, id_address, &arm->id); + BKE_id_blend_write(writer, &arm->id); - /* Direct data */ - LISTBASE_FOREACH (Bone *, bone, &arm->bonebase) { - write_bone(writer, bone); - } + if (arm->adt) { + BKE_animdata_blend_write(writer, arm->adt); + } + + /* Direct data */ + LISTBASE_FOREACH (Bone *, bone, &arm->bonebase) { + write_bone(writer, bone); } } -- cgit v1.2.3