diff options
author | Bastien Montagne <bastien@blender.org> | 2021-08-19 12:13:55 +0300 |
---|---|---|
committer | Bastien Montagne <bastien@blender.org> | 2021-08-19 16:09:33 +0300 |
commit | 0f49e4832cf2afad437aa16ebbbe37191de9af71 (patch) | |
tree | b4b8aeb04e1aecc5246d11c240b740a88dcf9699 /source/blender/blenkernel/intern/mask.c | |
parent | d5776f48297e79467407164fe9cb4042dbeccb31 (diff) |
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.
Diffstat (limited to 'source/blender/blenkernel/intern/mask.c')
-rw-r--r-- | source/blender/blenkernel/intern/mask.c | 57 |
1 files changed, 28 insertions, 29 deletions
diff --git a/source/blender/blenkernel/intern/mask.c b/source/blender/blenkernel/intern/mask.c index f40d1db60ff..a93fcb6e8e0 100644 --- a/source/blender/blenkernel/intern/mask.c +++ b/source/blender/blenkernel/intern/mask.c @@ -101,48 +101,47 @@ static void mask_foreach_id(ID *id, LibraryForeachIDData *data) static void mask_blend_write(BlendWriter *writer, ID *id, const void *id_address) { Mask *mask = (Mask *)id; - if (mask->id.us > 0 || BLO_write_is_undo(writer)) { - MaskLayer *masklay; - BLO_write_id_struct(writer, Mask, id_address, &mask->id); - BKE_id_blend_write(writer, &mask->id); + MaskLayer *masklay; - if (mask->adt) { - BKE_animdata_blend_write(writer, mask->adt); - } + BLO_write_id_struct(writer, Mask, id_address, &mask->id); + BKE_id_blend_write(writer, &mask->id); - for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) { - MaskSpline *spline; - MaskLayerShape *masklay_shape; + if (mask->adt) { + BKE_animdata_blend_write(writer, mask->adt); + } - BLO_write_struct(writer, MaskLayer, masklay); + for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) { + MaskSpline *spline; + MaskLayerShape *masklay_shape; - for (spline = masklay->splines.first; spline; spline = spline->next) { - int i; + BLO_write_struct(writer, MaskLayer, masklay); - void *points_deform = spline->points_deform; - spline->points_deform = NULL; + for (spline = masklay->splines.first; spline; spline = spline->next) { + int i; - BLO_write_struct(writer, MaskSpline, spline); - BLO_write_struct_array(writer, MaskSplinePoint, spline->tot_point, spline->points); + void *points_deform = spline->points_deform; + spline->points_deform = NULL; - spline->points_deform = points_deform; + BLO_write_struct(writer, MaskSpline, spline); + BLO_write_struct_array(writer, MaskSplinePoint, spline->tot_point, spline->points); - for (i = 0; i < spline->tot_point; i++) { - MaskSplinePoint *point = &spline->points[i]; + spline->points_deform = points_deform; - if (point->tot_uw) { - BLO_write_struct_array(writer, MaskSplinePointUW, point->tot_uw, point->uw); - } + for (i = 0; i < spline->tot_point; i++) { + MaskSplinePoint *point = &spline->points[i]; + + if (point->tot_uw) { + BLO_write_struct_array(writer, MaskSplinePointUW, point->tot_uw, point->uw); } } + } - for (masklay_shape = masklay->splines_shapes.first; masklay_shape; - masklay_shape = masklay_shape->next) { - BLO_write_struct(writer, MaskLayerShape, masklay_shape); - BLO_write_float_array( - writer, masklay_shape->tot_vert * MASK_OBJECT_SHAPE_ELEM_SIZE, masklay_shape->data); - } + for (masklay_shape = masklay->splines_shapes.first; masklay_shape; + masklay_shape = masklay_shape->next) { + BLO_write_struct(writer, MaskLayerShape, masklay_shape); + BLO_write_float_array( + writer, masklay_shape->tot_vert * MASK_OBJECT_SHAPE_ELEM_SIZE, masklay_shape->data); } } } |