Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/blender/blenkernel/intern/action.c21
-rw-r--r--source/blender/blenkernel/intern/armature.c31
-rw-r--r--source/blender/blenkernel/intern/brush.c73
-rw-r--r--source/blender/blenkernel/intern/cachefile.c21
-rw-r--r--source/blender/blenkernel/intern/camera.c19
-rw-r--r--source/blender/blenkernel/intern/collection.c23
-rw-r--r--source/blender/blenkernel/intern/curve.c69
-rw-r--r--source/blender/blenkernel/intern/font.c27
-rw-r--r--source/blender/blenkernel/intern/gpencil.c71
-rw-r--r--source/blender/blenkernel/intern/hair.c49
-rw-r--r--source/blender/blenkernel/intern/image.c57
-rw-r--r--source/blender/blenkernel/intern/key.c41
-rw-r--r--source/blender/blenkernel/intern/lattice.c33
-rw-r--r--source/blender/blenkernel/intern/light.c31
-rw-r--r--source/blender/blenkernel/intern/lightprobe.c15
-rw-r--r--source/blender/blenkernel/intern/linestyle.c35
-rw-r--r--source/blender/blenkernel/intern/mask.c57
-rw-r--r--source/blender/blenkernel/intern/material.c39
-rw-r--r--source/blender/blenkernel/intern/mball.c41
-rw-r--r--source/blender/blenkernel/intern/mesh.c143
-rw-r--r--source/blender/blenkernel/intern/movieclip.c45
-rw-r--r--source/blender/blenkernel/intern/node.cc21
-rw-r--r--source/blender/blenkernel/intern/object.c108
-rw-r--r--source/blender/blenkernel/intern/paint.c22
-rw-r--r--source/blender/blenkernel/intern/particle.c85
-rw-r--r--source/blender/blenkernel/intern/pointcloud.cc41
-rw-r--r--source/blender/blenkernel/intern/screen.c18
-rw-r--r--source/blender/blenkernel/intern/simulation.cc25
-rw-r--r--source/blender/blenkernel/intern/sound.c29
-rw-r--r--source/blender/blenkernel/intern/speaker.c15
-rw-r--r--source/blender/blenkernel/intern/text.c3
-rw-r--r--source/blender/blenkernel/intern/texture.c33
-rw-r--r--source/blender/blenkernel/intern/volume.cc31
-rw-r--r--source/blender/blenkernel/intern/world.c29
-rw-r--r--source/blender/blenloader/intern/writefile.c8
35 files changed, 687 insertions, 722 deletions
diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c
index d55f023d209..981815f400a 100644
--- a/source/blender/blenkernel/intern/action.c
+++ b/source/blender/blenkernel/intern/action.c
@@ -186,22 +186,21 @@ static void action_foreach_id(ID *id, LibraryForeachIDData *data)
static void action_blend_write(BlendWriter *writer, ID *id, const void *id_address)
{
bAction *act = (bAction *)id;
- if (act->id.us > 0 || BLO_write_is_undo(writer)) {
- BLO_write_id_struct(writer, bAction, id_address, &act->id);
- BKE_id_blend_write(writer, &act->id);
- BKE_fcurve_blend_write(writer, &act->curves);
+ BLO_write_id_struct(writer, bAction, id_address, &act->id);
+ BKE_id_blend_write(writer, &act->id);
- LISTBASE_FOREACH (bActionGroup *, grp, &act->groups) {
- BLO_write_struct(writer, bActionGroup, grp);
- }
+ BKE_fcurve_blend_write(writer, &act->curves);
- LISTBASE_FOREACH (TimeMarker *, marker, &act->markers) {
- BLO_write_struct(writer, TimeMarker, marker);
- }
+ LISTBASE_FOREACH (bActionGroup *, grp, &act->groups) {
+ BLO_write_struct(writer, bActionGroup, grp);
+ }
- BKE_previewimg_blend_write(writer, act->preview);
+ LISTBASE_FOREACH (TimeMarker *, marker, &act->markers) {
+ BLO_write_struct(writer, TimeMarker, marker);
}
+
+ BKE_previewimg_blend_write(writer, act->preview);
}
static void action_blend_read_data(BlendDataReader *reader, ID *id)
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);
}
}
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index 3418e37642c..7b81187be21 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -202,48 +202,47 @@ static void brush_foreach_id(ID *id, LibraryForeachIDData *data)
static void brush_blend_write(BlendWriter *writer, ID *id, const void *id_address)
{
Brush *brush = (Brush *)id;
- if (brush->id.us > 0 || BLO_write_is_undo(writer)) {
- BLO_write_id_struct(writer, Brush, id_address, &brush->id);
- BKE_id_blend_write(writer, &brush->id);
- if (brush->curve) {
- BKE_curvemapping_blend_write(writer, brush->curve);
- }
+ BLO_write_id_struct(writer, Brush, id_address, &brush->id);
+ BKE_id_blend_write(writer, &brush->id);
- if (brush->gpencil_settings) {
- BLO_write_struct(writer, BrushGpencilSettings, brush->gpencil_settings);
+ if (brush->curve) {
+ BKE_curvemapping_blend_write(writer, brush->curve);
+ }
- if (brush->gpencil_settings->curve_sensitivity) {
- BKE_curvemapping_blend_write(writer, brush->gpencil_settings->curve_sensitivity);
- }
- if (brush->gpencil_settings->curve_strength) {
- BKE_curvemapping_blend_write(writer, brush->gpencil_settings->curve_strength);
- }
- if (brush->gpencil_settings->curve_jitter) {
- BKE_curvemapping_blend_write(writer, brush->gpencil_settings->curve_jitter);
- }
- if (brush->gpencil_settings->curve_rand_pressure) {
- BKE_curvemapping_blend_write(writer, brush->gpencil_settings->curve_rand_pressure);
- }
- if (brush->gpencil_settings->curve_rand_strength) {
- BKE_curvemapping_blend_write(writer, brush->gpencil_settings->curve_rand_strength);
- }
- if (brush->gpencil_settings->curve_rand_uv) {
- BKE_curvemapping_blend_write(writer, brush->gpencil_settings->curve_rand_uv);
- }
- if (brush->gpencil_settings->curve_rand_hue) {
- BKE_curvemapping_blend_write(writer, brush->gpencil_settings->curve_rand_hue);
- }
- if (brush->gpencil_settings->curve_rand_saturation) {
- BKE_curvemapping_blend_write(writer, brush->gpencil_settings->curve_rand_saturation);
- }
- if (brush->gpencil_settings->curve_rand_value) {
- BKE_curvemapping_blend_write(writer, brush->gpencil_settings->curve_rand_value);
- }
+ if (brush->gpencil_settings) {
+ BLO_write_struct(writer, BrushGpencilSettings, brush->gpencil_settings);
+
+ if (brush->gpencil_settings->curve_sensitivity) {
+ BKE_curvemapping_blend_write(writer, brush->gpencil_settings->curve_sensitivity);
}
- if (brush->gradient) {
- BLO_write_struct(writer, ColorBand, brush->gradient);
+ if (brush->gpencil_settings->curve_strength) {
+ BKE_curvemapping_blend_write(writer, brush->gpencil_settings->curve_strength);
}
+ if (brush->gpencil_settings->curve_jitter) {
+ BKE_curvemapping_blend_write(writer, brush->gpencil_settings->curve_jitter);
+ }
+ if (brush->gpencil_settings->curve_rand_pressure) {
+ BKE_curvemapping_blend_write(writer, brush->gpencil_settings->curve_rand_pressure);
+ }
+ if (brush->gpencil_settings->curve_rand_strength) {
+ BKE_curvemapping_blend_write(writer, brush->gpencil_settings->curve_rand_strength);
+ }
+ if (brush->gpencil_settings->curve_rand_uv) {
+ BKE_curvemapping_blend_write(writer, brush->gpencil_settings->curve_rand_uv);
+ }
+ if (brush->gpencil_settings->curve_rand_hue) {
+ BKE_curvemapping_blend_write(writer, brush->gpencil_settings->curve_rand_hue);
+ }
+ if (brush->gpencil_settings->curve_rand_saturation) {
+ BKE_curvemapping_blend_write(writer, brush->gpencil_settings->curve_rand_saturation);
+ }
+ if (brush->gpencil_settings->curve_rand_value) {
+ BKE_curvemapping_blend_write(writer, brush->gpencil_settings->curve_rand_value);
+ }
+ }
+ if (brush->gradient) {
+ BLO_write_struct(writer, ColorBand, brush->gradient);
}
}
diff --git a/source/blender/blenkernel/intern/cachefile.c b/source/blender/blenkernel/intern/cachefile.c
index 8dd28c889f5..4a60564b4a1 100644
--- a/source/blender/blenkernel/intern/cachefile.c
+++ b/source/blender/blenkernel/intern/cachefile.c
@@ -97,19 +97,18 @@ static void cache_file_free_data(ID *id)
static void cache_file_blend_write(BlendWriter *writer, ID *id, const void *id_address)
{
CacheFile *cache_file = (CacheFile *)id;
- if (cache_file->id.us > 0 || BLO_write_is_undo(writer)) {
- /* Clean up, important in undo case to reduce false detection of changed datablocks. */
- BLI_listbase_clear(&cache_file->object_paths);
- cache_file->handle = NULL;
- memset(cache_file->handle_filepath, 0, sizeof(cache_file->handle_filepath));
- cache_file->handle_readers = NULL;
- BLO_write_id_struct(writer, CacheFile, id_address, &cache_file->id);
- BKE_id_blend_write(writer, &cache_file->id);
+ /* Clean up, important in undo case to reduce false detection of changed datablocks. */
+ BLI_listbase_clear(&cache_file->object_paths);
+ cache_file->handle = NULL;
+ memset(cache_file->handle_filepath, 0, sizeof(cache_file->handle_filepath));
+ cache_file->handle_readers = NULL;
- if (cache_file->adt) {
- BKE_animdata_blend_write(writer, cache_file->adt);
- }
+ BLO_write_id_struct(writer, CacheFile, id_address, &cache_file->id);
+ BKE_id_blend_write(writer, &cache_file->id);
+
+ if (cache_file->adt) {
+ BKE_animdata_blend_write(writer, cache_file->adt);
}
}
diff --git a/source/blender/blenkernel/intern/camera.c b/source/blender/blenkernel/intern/camera.c
index 5172b067eba..46b079fb42e 100644
--- a/source/blender/blenkernel/intern/camera.c
+++ b/source/blender/blenkernel/intern/camera.c
@@ -122,18 +122,17 @@ static void camera_foreach_id(ID *id, LibraryForeachIDData *data)
static void camera_blend_write(BlendWriter *writer, ID *id, const void *id_address)
{
Camera *cam = (Camera *)id;
- if (cam->id.us > 0 || BLO_write_is_undo(writer)) {
- /* write LibData */
- BLO_write_id_struct(writer, Camera, id_address, &cam->id);
- BKE_id_blend_write(writer, &cam->id);
- if (cam->adt) {
- BKE_animdata_blend_write(writer, cam->adt);
- }
+ /* write LibData */
+ BLO_write_id_struct(writer, Camera, id_address, &cam->id);
+ BKE_id_blend_write(writer, &cam->id);
- LISTBASE_FOREACH (CameraBGImage *, bgpic, &cam->bg_images) {
- BLO_write_struct(writer, CameraBGImage, bgpic);
- }
+ if (cam->adt) {
+ BKE_animdata_blend_write(writer, cam->adt);
+ }
+
+ LISTBASE_FOREACH (CameraBGImage *, bgpic, &cam->bg_images) {
+ BLO_write_struct(writer, CameraBGImage, bgpic);
}
}
diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c
index b62e33ff564..d36e9b67d00 100644
--- a/source/blender/blenkernel/intern/collection.c
+++ b/source/blender/blenkernel/intern/collection.c
@@ -214,20 +214,19 @@ void BKE_collection_blend_write_nolib(BlendWriter *writer, Collection *collectio
static void collection_blend_write(BlendWriter *writer, ID *id, const void *id_address)
{
Collection *collection = (Collection *)id;
- if (collection->id.us > 0 || BLO_write_is_undo(writer)) {
- /* Clean up, important in undo case to reduce false detection of changed data-blocks. */
- collection->flag &= ~COLLECTION_HAS_OBJECT_CACHE;
- collection->flag &= ~COLLECTION_HAS_OBJECT_CACHE_INSTANCED;
- collection->tag = 0;
- BLI_listbase_clear(&collection->object_cache);
- BLI_listbase_clear(&collection->object_cache_instanced);
- BLI_listbase_clear(&collection->parents);
- /* write LibData */
- BLO_write_id_struct(writer, Collection, id_address, &collection->id);
+ /* Clean up, important in undo case to reduce false detection of changed data-blocks. */
+ collection->flag &= ~COLLECTION_HAS_OBJECT_CACHE;
+ collection->flag &= ~COLLECTION_HAS_OBJECT_CACHE_INSTANCED;
+ collection->tag = 0;
+ BLI_listbase_clear(&collection->object_cache);
+ BLI_listbase_clear(&collection->object_cache_instanced);
+ BLI_listbase_clear(&collection->parents);
- BKE_collection_blend_write_nolib(writer, collection);
- }
+ /* write LibData */
+ BLO_write_id_struct(writer, Collection, id_address, &collection->id);
+
+ BKE_collection_blend_write_nolib(writer, collection);
}
#ifdef USE_COLLECTION_COMPAT_28
diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c
index c49788528a4..397838e6904 100644
--- a/source/blender/blenkernel/intern/curve.c
+++ b/source/blender/blenkernel/intern/curve.c
@@ -146,51 +146,50 @@ static void curve_foreach_id(ID *id, LibraryForeachIDData *data)
static void curve_blend_write(BlendWriter *writer, ID *id, const void *id_address)
{
Curve *cu = (Curve *)id;
- if (cu->id.us > 0 || BLO_write_is_undo(writer)) {
- /* Clean up, important in undo case to reduce false detection of changed datablocks. */
- cu->editnurb = NULL;
- cu->editfont = NULL;
- cu->batch_cache = NULL;
- /* write LibData */
- BLO_write_id_struct(writer, Curve, id_address, &cu->id);
- BKE_id_blend_write(writer, &cu->id);
+ /* Clean up, important in undo case to reduce false detection of changed datablocks. */
+ cu->editnurb = NULL;
+ cu->editfont = NULL;
+ cu->batch_cache = NULL;
- /* direct data */
- BLO_write_pointer_array(writer, cu->totcol, cu->mat);
- if (cu->adt) {
- BKE_animdata_blend_write(writer, cu->adt);
- }
+ /* write LibData */
+ BLO_write_id_struct(writer, Curve, id_address, &cu->id);
+ BKE_id_blend_write(writer, &cu->id);
- if (cu->vfont) {
- BLO_write_raw(writer, cu->len + 1, cu->str);
- BLO_write_struct_array(writer, CharInfo, cu->len_char32 + 1, cu->strinfo);
- BLO_write_struct_array(writer, TextBox, cu->totbox, cu->tb);
+ /* direct data */
+ BLO_write_pointer_array(writer, cu->totcol, cu->mat);
+ if (cu->adt) {
+ BKE_animdata_blend_write(writer, cu->adt);
+ }
+
+ if (cu->vfont) {
+ BLO_write_raw(writer, cu->len + 1, cu->str);
+ BLO_write_struct_array(writer, CharInfo, cu->len_char32 + 1, cu->strinfo);
+ BLO_write_struct_array(writer, TextBox, cu->totbox, cu->tb);
+ }
+ else {
+ /* is also the order of reading */
+ LISTBASE_FOREACH (Nurb *, nu, &cu->nurb) {
+ BLO_write_struct(writer, Nurb, nu);
}
- else {
- /* is also the order of reading */
- LISTBASE_FOREACH (Nurb *, nu, &cu->nurb) {
- BLO_write_struct(writer, Nurb, nu);
+ LISTBASE_FOREACH (Nurb *, nu, &cu->nurb) {
+ if (nu->type == CU_BEZIER) {
+ BLO_write_struct_array(writer, BezTriple, nu->pntsu, nu->bezt);
}
- LISTBASE_FOREACH (Nurb *, nu, &cu->nurb) {
- if (nu->type == CU_BEZIER) {
- BLO_write_struct_array(writer, BezTriple, nu->pntsu, nu->bezt);
+ else {
+ BLO_write_struct_array(writer, BPoint, nu->pntsu * nu->pntsv, nu->bp);
+ if (nu->knotsu) {
+ BLO_write_float_array(writer, KNOTSU(nu), nu->knotsu);
}
- else {
- BLO_write_struct_array(writer, BPoint, nu->pntsu * nu->pntsv, nu->bp);
- if (nu->knotsu) {
- BLO_write_float_array(writer, KNOTSU(nu), nu->knotsu);
- }
- if (nu->knotsv) {
- BLO_write_float_array(writer, KNOTSV(nu), nu->knotsv);
- }
+ if (nu->knotsv) {
+ BLO_write_float_array(writer, KNOTSV(nu), nu->knotsv);
}
}
}
+ }
- if (cu->bevel_profile != NULL) {
- BKE_curveprofile_blend_write(writer, cu->bevel_profile);
- }
+ if (cu->bevel_profile != NULL) {
+ BKE_curveprofile_blend_write(writer, cu->bevel_profile);
}
}
diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c
index 72add476bfe..c1765967238 100644
--- a/source/blender/blenkernel/intern/font.c
+++ b/source/blender/blenkernel/intern/font.c
@@ -126,23 +126,22 @@ static void vfont_blend_write(BlendWriter *writer, ID *id, const void *id_addres
{
VFont *vf = (VFont *)id;
const bool is_undo = BLO_write_is_undo(writer);
- if (vf->id.us > 0 || is_undo) {
- /* Clean up, important in undo case to reduce false detection of changed datablocks. */
- vf->data = NULL;
- vf->temp_pf = NULL;
-
- /* Do not store packed files in case this is a library override ID. */
- if (ID_IS_OVERRIDE_LIBRARY(vf) && !is_undo) {
- vf->packedfile = NULL;
- }
- /* write LibData */
- BLO_write_id_struct(writer, VFont, id_address, &vf->id);
- BKE_id_blend_write(writer, &vf->id);
+ /* Clean up, important in undo case to reduce false detection of changed datablocks. */
+ vf->data = NULL;
+ vf->temp_pf = NULL;
- /* direct data */
- BKE_packedfile_blend_write(writer, vf->packedfile);
+ /* Do not store packed files in case this is a library override ID. */
+ if (ID_IS_OVERRIDE_LIBRARY(vf) && !is_undo) {
+ vf->packedfile = NULL;
}
+
+ /* write LibData */
+ BLO_write_id_struct(writer, VFont, id_address, &vf->id);
+ BKE_id_blend_write(writer, &vf->id);
+
+ /* direct data */
+ BKE_packedfile_blend_write(writer, vf->packedfile);
}
static void vfont_blend_read_data(BlendDataReader *reader, ID *id)
diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index f566e18fb2f..9cdb7395925 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -150,47 +150,46 @@ static void greasepencil_foreach_id(ID *id, LibraryForeachIDData *data)
static void greasepencil_blend_write(BlendWriter *writer, ID *id, const void *id_address)
{
bGPdata *gpd = (bGPdata *)id;
- if (gpd->id.us > 0 || BLO_write_is_undo(writer)) {
- /* Clean up, important in undo case to reduce false detection of changed data-blocks. */
- /* XXX not sure why the whole run-time data is not cleared in reading code,
- * for now mimicking it here. */
- gpd->runtime.sbuffer = NULL;
- gpd->runtime.sbuffer_used = 0;
- gpd->runtime.sbuffer_size = 0;
- gpd->runtime.tot_cp_points = 0;
- /* write gpd data block to file */
- BLO_write_id_struct(writer, bGPdata, id_address, &gpd->id);
- BKE_id_blend_write(writer, &gpd->id);
+ /* Clean up, important in undo case to reduce false detection of changed data-blocks. */
+ /* XXX not sure why the whole run-time data is not cleared in reading code,
+ * for now mimicking it here. */
+ gpd->runtime.sbuffer = NULL;
+ gpd->runtime.sbuffer_used = 0;
+ gpd->runtime.sbuffer_size = 0;
+ gpd->runtime.tot_cp_points = 0;
- if (gpd->adt) {
- BKE_animdata_blend_write(writer, gpd->adt);
- }
+ /* write gpd data block to file */
+ BLO_write_id_struct(writer, bGPdata, id_address, &gpd->id);
+ BKE_id_blend_write(writer, &gpd->id);
- BKE_defbase_blend_write(writer, &gpd->vertex_group_names);
+ if (gpd->adt) {
+ BKE_animdata_blend_write(writer, gpd->adt);
+ }
- BLO_write_pointer_array(writer, gpd->totcol, gpd->mat);
+ BKE_defbase_blend_write(writer, &gpd->vertex_group_names);
- /* write grease-pencil layers to file */
- BLO_write_struct_list(writer, bGPDlayer, &gpd->layers);
- LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
- /* Write mask list. */
- BLO_write_struct_list(writer, bGPDlayer_Mask, &gpl->mask_layers);
- /* write this layer's frames to file */
- BLO_write_struct_list(writer, bGPDframe, &gpl->frames);
- LISTBASE_FOREACH (bGPDframe *, gpf, &gpl->frames) {
- /* write strokes */
- BLO_write_struct_list(writer, bGPDstroke, &gpf->strokes);
- LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) {
- BLO_write_struct_array(writer, bGPDspoint, gps->totpoints, gps->points);
- BLO_write_struct_array(writer, bGPDtriangle, gps->tot_triangles, gps->triangles);
- BKE_defvert_blend_write(writer, gps->totpoints, gps->dvert);
- if (gps->editcurve != NULL) {
- bGPDcurve *gpc = gps->editcurve;
- BLO_write_struct(writer, bGPDcurve, gpc);
- BLO_write_struct_array(
- writer, bGPDcurve_point, gpc->tot_curve_points, gpc->curve_points);
- }
+ BLO_write_pointer_array(writer, gpd->totcol, gpd->mat);
+
+ /* write grease-pencil layers to file */
+ BLO_write_struct_list(writer, bGPDlayer, &gpd->layers);
+ LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
+ /* Write mask list. */
+ BLO_write_struct_list(writer, bGPDlayer_Mask, &gpl->mask_layers);
+ /* write this layer's frames to file */
+ BLO_write_struct_list(writer, bGPDframe, &gpl->frames);
+ LISTBASE_FOREACH (bGPDframe *, gpf, &gpl->frames) {
+ /* write strokes */
+ BLO_write_struct_list(writer, bGPDstroke, &gpf->strokes);
+ LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) {
+ BLO_write_struct_array(writer, bGPDspoint, gps->totpoints, gps->points);
+ BLO_write_struct_array(writer, bGPDtriangle, gps->tot_triangles, gps->triangles);
+ BKE_defvert_blend_write(writer, gps->totpoints, gps->dvert);
+ if (gps->editcurve != NULL) {
+ bGPDcurve *gpc = gps->editcurve;
+ BLO_write_struct(writer, bGPDcurve, gpc);
+ BLO_write_struct_array(
+ writer, bGPDcurve_point, gpc->tot_curve_points, gpc->curve_points);
}
}
}
diff --git a/source/blender/blenkernel/intern/hair.c b/source/blender/blenkernel/intern/hair.c
index 2894d6daf23..af7cc0acb57 100644
--- a/source/blender/blenkernel/intern/hair.c
+++ b/source/blender/blenkernel/intern/hair.c
@@ -114,32 +114,31 @@ static void hair_foreach_id(ID *id, LibraryForeachIDData *data)
static void hair_blend_write(BlendWriter *writer, ID *id, const void *id_address)
{
Hair *hair = (Hair *)id;
- if (hair->id.us > 0 || BLO_write_is_undo(writer)) {
- CustomDataLayer *players = NULL, players_buff[CD_TEMP_CHUNK_SIZE];
- CustomDataLayer *clayers = NULL, clayers_buff[CD_TEMP_CHUNK_SIZE];
- CustomData_blend_write_prepare(&hair->pdata, &players, players_buff, ARRAY_SIZE(players_buff));
- CustomData_blend_write_prepare(&hair->cdata, &clayers, clayers_buff, ARRAY_SIZE(clayers_buff));
-
- /* Write LibData */
- BLO_write_id_struct(writer, Hair, id_address, &hair->id);
- BKE_id_blend_write(writer, &hair->id);
-
- /* Direct data */
- CustomData_blend_write(writer, &hair->pdata, players, hair->totpoint, CD_MASK_ALL, &hair->id);
- CustomData_blend_write(writer, &hair->cdata, clayers, hair->totcurve, CD_MASK_ALL, &hair->id);
-
- BLO_write_pointer_array(writer, hair->totcol, hair->mat);
- if (hair->adt) {
- BKE_animdata_blend_write(writer, hair->adt);
- }
- /* Remove temporary data. */
- if (players && players != players_buff) {
- MEM_freeN(players);
- }
- if (clayers && clayers != clayers_buff) {
- MEM_freeN(clayers);
- }
+ CustomDataLayer *players = NULL, players_buff[CD_TEMP_CHUNK_SIZE];
+ CustomDataLayer *clayers = NULL, clayers_buff[CD_TEMP_CHUNK_SIZE];
+ CustomData_blend_write_prepare(&hair->pdata, &players, players_buff, ARRAY_SIZE(players_buff));
+ CustomData_blend_write_prepare(&hair->cdata, &clayers, clayers_buff, ARRAY_SIZE(clayers_buff));
+
+ /* Write LibData */
+ BLO_write_id_struct(writer, Hair, id_address, &hair->id);
+ BKE_id_blend_write(writer, &hair->id);
+
+ /* Direct data */
+ CustomData_blend_write(writer, &hair->pdata, players, hair->totpoint, CD_MASK_ALL, &hair->id);
+ CustomData_blend_write(writer, &hair->cdata, clayers, hair->totcurve, CD_MASK_ALL, &hair->id);
+
+ BLO_write_pointer_array(writer, hair->totcol, hair->mat);
+ if (hair->adt) {
+ BKE_animdata_blend_write(writer, hair->adt);
+ }
+
+ /* Remove temporary data. */
+ if (players && players != players_buff) {
+ MEM_freeN(players);
+ }
+ if (clayers && clayers != clayers_buff) {
+ MEM_freeN(clayers);
}
}
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index d2ab54de697..de9f2a5a656 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -229,44 +229,43 @@ static void image_blend_write(BlendWriter *writer, ID *id, const void *id_addres
{
Image *ima = (Image *)id;
const bool is_undo = BLO_write_is_undo(writer);
- if (ima->id.us > 0 || is_undo) {
- ImagePackedFile *imapf;
- BLI_assert(ima->packedfile == NULL);
- /* Do not store packed files in case this is a library override ID. */
- if (ID_IS_OVERRIDE_LIBRARY(ima) && !is_undo) {
- BLI_listbase_clear(&ima->packedfiles);
- }
- else {
- /* Some trickery to keep forward compatibility of packed images. */
- if (ima->packedfiles.first != NULL) {
- imapf = ima->packedfiles.first;
- ima->packedfile = imapf->packedfile;
- }
+ ImagePackedFile *imapf;
+
+ BLI_assert(ima->packedfile == NULL);
+ /* Do not store packed files in case this is a library override ID. */
+ if (ID_IS_OVERRIDE_LIBRARY(ima) && !is_undo) {
+ BLI_listbase_clear(&ima->packedfiles);
+ }
+ else {
+ /* Some trickery to keep forward compatibility of packed images. */
+ if (ima->packedfiles.first != NULL) {
+ imapf = ima->packedfiles.first;
+ ima->packedfile = imapf->packedfile;
}
+ }
- /* write LibData */
- BLO_write_id_struct(writer, Image, id_address, &ima->id);
- BKE_id_blend_write(writer, &ima->id);
+ /* write LibData */
+ BLO_write_id_struct(writer, Image, id_address, &ima->id);
+ BKE_id_blend_write(writer, &ima->id);
- for (imapf = ima->packedfiles.first; imapf; imapf = imapf->next) {
- BLO_write_struct(writer, ImagePackedFile, imapf);
- BKE_packedfile_blend_write(writer, imapf->packedfile);
- }
+ for (imapf = ima->packedfiles.first; imapf; imapf = imapf->next) {
+ BLO_write_struct(writer, ImagePackedFile, imapf);
+ BKE_packedfile_blend_write(writer, imapf->packedfile);
+ }
- BKE_previewimg_blend_write(writer, ima->preview);
+ BKE_previewimg_blend_write(writer, ima->preview);
- LISTBASE_FOREACH (ImageView *, iv, &ima->views) {
- BLO_write_struct(writer, ImageView, iv);
- }
- BLO_write_struct(writer, Stereo3dFormat, ima->stereo3d_format);
+ LISTBASE_FOREACH (ImageView *, iv, &ima->views) {
+ BLO_write_struct(writer, ImageView, iv);
+ }
+ BLO_write_struct(writer, Stereo3dFormat, ima->stereo3d_format);
- BLO_write_struct_list(writer, ImageTile, &ima->tiles);
+ BLO_write_struct_list(writer, ImageTile, &ima->tiles);
- ima->packedfile = NULL;
+ ima->packedfile = NULL;
- BLO_write_struct_list(writer, RenderSlot, &ima->renderslots);
- }
+ BLO_write_struct_list(writer, RenderSlot, &ima->renderslots);
}
static void image_blend_read_data(BlendDataReader *reader, ID *id)
diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c
index 724216bee6c..b59f51c36f7 100644
--- a/source/blender/blenkernel/intern/key.c
+++ b/source/blender/blenkernel/intern/key.c
@@ -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);
- }
-
- /* 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);
- }
+
+ /* 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;
+ }
+ 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);
}
}
}
diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c
index 9875d776d33..e804f32e5a6 100644
--- a/source/blender/blenkernel/intern/lattice.c
+++ b/source/blender/blenkernel/intern/lattice.c
@@ -137,26 +137,25 @@ static void lattice_foreach_id(ID *id, LibraryForeachIDData *data)
static void lattice_blend_write(BlendWriter *writer, ID *id, const void *id_address)
{
Lattice *lt = (Lattice *)id;
- if (lt->id.us > 0 || BLO_write_is_undo(writer)) {
- /* Clean up, important in undo case to reduce false detection of changed datablocks. */
- lt->editlatt = NULL;
- lt->batch_cache = NULL;
-
- /* write LibData */
- BLO_write_id_struct(writer, Lattice, id_address, &lt->id);
- BKE_id_blend_write(writer, &lt->id);
-
- /* write animdata */
- if (lt->adt) {
- BKE_animdata_blend_write(writer, lt->adt);
- }
- /* direct data */
- BLO_write_struct_array(writer, BPoint, lt->pntsu * lt->pntsv * lt->pntsw, lt->def);
+ /* Clean up, important in undo case to reduce false detection of changed datablocks. */
+ lt->editlatt = NULL;
+ lt->batch_cache = NULL;
+
+ /* write LibData */
+ BLO_write_id_struct(writer, Lattice, id_address, &lt->id);
+ BKE_id_blend_write(writer, &lt->id);
- BKE_defbase_blend_write(writer, &lt->vertex_group_names);
- BKE_defvert_blend_write(writer, lt->pntsu * lt->pntsv * lt->pntsw, lt->dvert);
+ /* write animdata */
+ if (lt->adt) {
+ BKE_animdata_blend_write(writer, lt->adt);
}
+
+ /* direct data */
+ BLO_write_struct_array(writer, BPoint, lt->pntsu * lt->pntsv * lt->pntsw, lt->def);
+
+ BKE_defbase_blend_write(writer, &lt->vertex_group_names);
+ BKE_defvert_blend_write(writer, lt->pntsu * lt->pntsv * lt->pntsw, lt->dvert);
}
static void lattice_blend_read_data(BlendDataReader *reader, ID *id)
diff --git a/source/blender/blenkernel/intern/light.c b/source/blender/blenkernel/intern/light.c
index d91d80ac683..c2b71b85973 100644
--- a/source/blender/blenkernel/intern/light.c
+++ b/source/blender/blenkernel/intern/light.c
@@ -136,27 +136,26 @@ static void light_foreach_id(ID *id, LibraryForeachIDData *data)
static void light_blend_write(BlendWriter *writer, ID *id, const void *id_address)
{
Light *la = (Light *)id;
- if (la->id.us > 0 || BLO_write_is_undo(writer)) {
- /* write LibData */
- BLO_write_id_struct(writer, Light, id_address, &la->id);
- BKE_id_blend_write(writer, &la->id);
- if (la->adt) {
- BKE_animdata_blend_write(writer, la->adt);
- }
+ /* write LibData */
+ BLO_write_id_struct(writer, Light, id_address, &la->id);
+ BKE_id_blend_write(writer, &la->id);
- if (la->curfalloff) {
- BKE_curvemapping_blend_write(writer, la->curfalloff);
- }
+ if (la->adt) {
+ BKE_animdata_blend_write(writer, la->adt);
+ }
- /* Node-tree is integral part of lights, no libdata. */
- if (la->nodetree) {
- BLO_write_struct(writer, bNodeTree, la->nodetree);
- ntreeBlendWrite(writer, la->nodetree);
- }
+ if (la->curfalloff) {
+ BKE_curvemapping_blend_write(writer, la->curfalloff);
+ }
- BKE_previewimg_blend_write(writer, la->preview);
+ /* Node-tree is integral part of lights, no libdata. */
+ if (la->nodetree) {
+ BLO_write_struct(writer, bNodeTree, la->nodetree);
+ ntreeBlendWrite(writer, la->nodetree);
}
+
+ BKE_previewimg_blend_write(writer, la->preview);
}
static void light_blend_read_data(BlendDataReader *reader, ID *id)
diff --git a/source/blender/blenkernel/intern/lightprobe.c b/source/blender/blenkernel/intern/lightprobe.c
index b09aed82921..15733af8ef0 100644
--- a/source/blender/blenkernel/intern/lightprobe.c
+++ b/source/blender/blenkernel/intern/lightprobe.c
@@ -60,14 +60,13 @@ static void lightprobe_foreach_id(ID *id, LibraryForeachIDData *data)
static void lightprobe_blend_write(BlendWriter *writer, ID *id, const void *id_address)
{
LightProbe *prb = (LightProbe *)id;
- if (prb->id.us > 0 || BLO_write_is_undo(writer)) {
- /* write LibData */
- BLO_write_id_struct(writer, LightProbe, id_address, &prb->id);
- BKE_id_blend_write(writer, &prb->id);
-
- if (prb->adt) {
- BKE_animdata_blend_write(writer, prb->adt);
- }
+
+ /* write LibData */
+ BLO_write_id_struct(writer, LightProbe, id_address, &prb->id);
+ BKE_id_blend_write(writer, &prb->id);
+
+ if (prb->adt) {
+ BKE_animdata_blend_write(writer, prb->adt);
}
}
diff --git a/source/blender/blenkernel/intern/linestyle.c b/source/blender/blenkernel/intern/linestyle.c
index 26d9ab7a8c7..19030fca38b 100644
--- a/source/blender/blenkernel/intern/linestyle.c
+++ b/source/blender/blenkernel/intern/linestyle.c
@@ -457,28 +457,27 @@ static void write_linestyle_geometry_modifiers(BlendWriter *writer, ListBase *mo
static void linestyle_blend_write(BlendWriter *writer, ID *id, const void *id_address)
{
FreestyleLineStyle *linestyle = (FreestyleLineStyle *)id;
- if (linestyle->id.us > 0 || BLO_write_is_undo(writer)) {
- BLO_write_id_struct(writer, FreestyleLineStyle, id_address, &linestyle->id);
- BKE_id_blend_write(writer, &linestyle->id);
- if (linestyle->adt) {
- BKE_animdata_blend_write(writer, linestyle->adt);
- }
+ BLO_write_id_struct(writer, FreestyleLineStyle, id_address, &linestyle->id);
+ BKE_id_blend_write(writer, &linestyle->id);
- write_linestyle_color_modifiers(writer, &linestyle->color_modifiers);
- write_linestyle_alpha_modifiers(writer, &linestyle->alpha_modifiers);
- write_linestyle_thickness_modifiers(writer, &linestyle->thickness_modifiers);
- write_linestyle_geometry_modifiers(writer, &linestyle->geometry_modifiers);
- for (int a = 0; a < MAX_MTEX; a++) {
- if (linestyle->mtex[a]) {
- BLO_write_struct(writer, MTex, linestyle->mtex[a]);
- }
- }
- if (linestyle->nodetree) {
- BLO_write_struct(writer, bNodeTree, linestyle->nodetree);
- ntreeBlendWrite(writer, linestyle->nodetree);
+ if (linestyle->adt) {
+ BKE_animdata_blend_write(writer, linestyle->adt);
+ }
+
+ write_linestyle_color_modifiers(writer, &linestyle->color_modifiers);
+ write_linestyle_alpha_modifiers(writer, &linestyle->alpha_modifiers);
+ write_linestyle_thickness_modifiers(writer, &linestyle->thickness_modifiers);
+ write_linestyle_geometry_modifiers(writer, &linestyle->geometry_modifiers);
+ for (int a = 0; a < MAX_MTEX; a++) {
+ if (linestyle->mtex[a]) {
+ BLO_write_struct(writer, MTex, linestyle->mtex[a]);
}
}
+ if (linestyle->nodetree) {
+ BLO_write_struct(writer, bNodeTree, linestyle->nodetree);
+ ntreeBlendWrite(writer, linestyle->nodetree);
+ }
}
static void direct_link_linestyle_color_modifier(BlendDataReader *reader,
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);
}
}
}
diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c
index ca57038f1c4..13b5bca5638 100644
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@ -179,31 +179,30 @@ static void material_foreach_id(ID *id, LibraryForeachIDData *data)
static void material_blend_write(BlendWriter *writer, ID *id, const void *id_address)
{
Material *ma = (Material *)id;
- if (ma->id.us > 0 || BLO_write_is_undo(writer)) {
- /* Clean up, important in undo case to reduce false detection of changed datablocks. */
- ma->texpaintslot = NULL;
- BLI_listbase_clear(&ma->gpumaterial);
- /* write LibData */
- BLO_write_id_struct(writer, Material, id_address, &ma->id);
- BKE_id_blend_write(writer, &ma->id);
+ /* Clean up, important in undo case to reduce false detection of changed datablocks. */
+ ma->texpaintslot = NULL;
+ BLI_listbase_clear(&ma->gpumaterial);
- if (ma->adt) {
- BKE_animdata_blend_write(writer, ma->adt);
- }
+ /* write LibData */
+ BLO_write_id_struct(writer, Material, id_address, &ma->id);
+ BKE_id_blend_write(writer, &ma->id);
- /* nodetree is integral part of material, no libdata */
- if (ma->nodetree) {
- BLO_write_struct(writer, bNodeTree, ma->nodetree);
- ntreeBlendWrite(writer, ma->nodetree);
- }
+ if (ma->adt) {
+ BKE_animdata_blend_write(writer, ma->adt);
+ }
- BKE_previewimg_blend_write(writer, ma->preview);
+ /* nodetree is integral part of material, no libdata */
+ if (ma->nodetree) {
+ BLO_write_struct(writer, bNodeTree, ma->nodetree);
+ ntreeBlendWrite(writer, ma->nodetree);
+ }
- /* grease pencil settings */
- if (ma->gp_style) {
- BLO_write_struct(writer, MaterialGPencilStyle, ma->gp_style);
- }
+ BKE_previewimg_blend_write(writer, ma->preview);
+
+ /* grease pencil settings */
+ if (ma->gp_style) {
+ BLO_write_struct(writer, MaterialGPencilStyle, ma->gp_style);
}
}
diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c
index d6b189d484b..45cf0f17840 100644
--- a/source/blender/blenkernel/intern/mball.c
+++ b/source/blender/blenkernel/intern/mball.c
@@ -119,28 +119,27 @@ static void metaball_foreach_id(ID *id, LibraryForeachIDData *data)
static void metaball_blend_write(BlendWriter *writer, ID *id, const void *id_address)
{
MetaBall *mb = (MetaBall *)id;
- if (mb->id.us > 0 || BLO_write_is_undo(writer)) {
- /* Clean up, important in undo case to reduce false detection of changed datablocks. */
- BLI_listbase_clear(&mb->disp);
- mb->editelems = NULL;
- /* Must always be cleared (meta's don't have their own edit-data). */
- mb->needs_flush_to_id = 0;
- mb->lastelem = NULL;
- mb->batch_cache = NULL;
-
- /* write LibData */
- BLO_write_id_struct(writer, MetaBall, id_address, &mb->id);
- BKE_id_blend_write(writer, &mb->id);
-
- /* direct data */
- BLO_write_pointer_array(writer, mb->totcol, mb->mat);
- if (mb->adt) {
- BKE_animdata_blend_write(writer, mb->adt);
- }
- LISTBASE_FOREACH (MetaElem *, ml, &mb->elems) {
- BLO_write_struct(writer, MetaElem, ml);
- }
+ /* Clean up, important in undo case to reduce false detection of changed datablocks. */
+ BLI_listbase_clear(&mb->disp);
+ mb->editelems = NULL;
+ /* Must always be cleared (meta's don't have their own edit-data). */
+ mb->needs_flush_to_id = 0;
+ mb->lastelem = NULL;
+ mb->batch_cache = NULL;
+
+ /* write LibData */
+ BLO_write_id_struct(writer, MetaBall, id_address, &mb->id);
+ BKE_id_blend_write(writer, &mb->id);
+
+ /* direct data */
+ BLO_write_pointer_array(writer, mb->totcol, mb->mat);
+ if (mb->adt) {
+ BKE_animdata_blend_write(writer, mb->adt);
+ }
+
+ LISTBASE_FOREACH (MetaElem *, ml, &mb->elems) {
+ BLO_write_struct(writer, MetaElem, ml);
}
}
diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c
index e99670fc488..8257e54c618 100644
--- a/source/blender/blenkernel/intern/mesh.c
+++ b/source/blender/blenkernel/intern/mesh.c
@@ -179,95 +179,90 @@ static void mesh_blend_write(BlendWriter *writer, ID *id, const void *id_address
{
Mesh *mesh = (Mesh *)id;
const bool is_undo = BLO_write_is_undo(writer);
- if (mesh->id.us > 0 || is_undo) {
- CustomDataLayer *vlayers = NULL, vlayers_buff[CD_TEMP_CHUNK_SIZE];
- CustomDataLayer *elayers = NULL, elayers_buff[CD_TEMP_CHUNK_SIZE];
- CustomDataLayer *flayers = NULL, flayers_buff[CD_TEMP_CHUNK_SIZE];
- CustomDataLayer *llayers = NULL, llayers_buff[CD_TEMP_CHUNK_SIZE];
- CustomDataLayer *players = NULL, players_buff[CD_TEMP_CHUNK_SIZE];
-
- /* cache only - don't write */
- mesh->mface = NULL;
- mesh->totface = 0;
- memset(&mesh->fdata, 0, sizeof(mesh->fdata));
- memset(&mesh->runtime, 0, sizeof(mesh->runtime));
- flayers = flayers_buff;
-
- /* Do not store actual geometry data in case this is a library override ID. */
- if (ID_IS_OVERRIDE_LIBRARY(mesh) && !is_undo) {
- mesh->mvert = NULL;
- mesh->totvert = 0;
- memset(&mesh->vdata, 0, sizeof(mesh->vdata));
- vlayers = vlayers_buff;
-
- mesh->medge = NULL;
- mesh->totedge = 0;
- memset(&mesh->edata, 0, sizeof(mesh->edata));
- elayers = elayers_buff;
-
- mesh->mloop = NULL;
- mesh->totloop = 0;
- memset(&mesh->ldata, 0, sizeof(mesh->ldata));
- llayers = llayers_buff;
-
- mesh->mpoly = NULL;
- mesh->totpoly = 0;
- memset(&mesh->pdata, 0, sizeof(mesh->pdata));
- players = players_buff;
- }
- else {
- CustomData_blend_write_prepare(
- &mesh->vdata, &vlayers, vlayers_buff, ARRAY_SIZE(vlayers_buff));
- CustomData_blend_write_prepare(
- &mesh->edata, &elayers, elayers_buff, ARRAY_SIZE(elayers_buff));
- CustomData_blend_write_prepare(
- &mesh->ldata, &llayers, llayers_buff, ARRAY_SIZE(llayers_buff));
- CustomData_blend_write_prepare(
- &mesh->pdata, &players, players_buff, ARRAY_SIZE(players_buff));
- }
- BLO_write_id_struct(writer, Mesh, id_address, &mesh->id);
- BKE_id_blend_write(writer, &mesh->id);
+ CustomDataLayer *vlayers = NULL, vlayers_buff[CD_TEMP_CHUNK_SIZE];
+ CustomDataLayer *elayers = NULL, elayers_buff[CD_TEMP_CHUNK_SIZE];
+ CustomDataLayer *flayers = NULL, flayers_buff[CD_TEMP_CHUNK_SIZE];
+ CustomDataLayer *llayers = NULL, llayers_buff[CD_TEMP_CHUNK_SIZE];
+ CustomDataLayer *players = NULL, players_buff[CD_TEMP_CHUNK_SIZE];
- /* direct data */
- if (mesh->adt) {
- BKE_animdata_blend_write(writer, mesh->adt);
- }
+ /* cache only - don't write */
+ mesh->mface = NULL;
+ mesh->totface = 0;
+ memset(&mesh->fdata, 0, sizeof(mesh->fdata));
+ memset(&mesh->runtime, 0, sizeof(mesh->runtime));
+ flayers = flayers_buff;
+
+ /* Do not store actual geometry data in case this is a library override ID. */
+ if (ID_IS_OVERRIDE_LIBRARY(mesh) && !is_undo) {
+ mesh->mvert = NULL;
+ mesh->totvert = 0;
+ memset(&mesh->vdata, 0, sizeof(mesh->vdata));
+ vlayers = vlayers_buff;
+
+ mesh->medge = NULL;
+ mesh->totedge = 0;
+ memset(&mesh->edata, 0, sizeof(mesh->edata));
+ elayers = elayers_buff;
+
+ mesh->mloop = NULL;
+ mesh->totloop = 0;
+ memset(&mesh->ldata, 0, sizeof(mesh->ldata));
+ llayers = llayers_buff;
+
+ mesh->mpoly = NULL;
+ mesh->totpoly = 0;
+ memset(&mesh->pdata, 0, sizeof(mesh->pdata));
+ players = players_buff;
+ }
+ else {
+ CustomData_blend_write_prepare(&mesh->vdata, &vlayers, vlayers_buff, ARRAY_SIZE(vlayers_buff));
+ CustomData_blend_write_prepare(&mesh->edata, &elayers, elayers_buff, ARRAY_SIZE(elayers_buff));
+ CustomData_blend_write_prepare(&mesh->ldata, &llayers, llayers_buff, ARRAY_SIZE(llayers_buff));
+ CustomData_blend_write_prepare(&mesh->pdata, &players, players_buff, ARRAY_SIZE(players_buff));
+ }
+
+ BLO_write_id_struct(writer, Mesh, id_address, &mesh->id);
+ BKE_id_blend_write(writer, &mesh->id);
- BKE_defbase_blend_write(writer, &mesh->vertex_group_names);
+ /* direct data */
+ if (mesh->adt) {
+ BKE_animdata_blend_write(writer, mesh->adt);
+ }
+
+ BKE_defbase_blend_write(writer, &mesh->vertex_group_names);
- BLO_write_pointer_array(writer, mesh->totcol, mesh->mat);
- BLO_write_raw(writer, sizeof(MSelect) * mesh->totselect, mesh->mselect);
+ BLO_write_pointer_array(writer, mesh->totcol, mesh->mat);
+ BLO_write_raw(writer, sizeof(MSelect) * mesh->totselect, mesh->mselect);
- CustomData_blend_write(
- writer, &mesh->vdata, vlayers, mesh->totvert, CD_MASK_MESH.vmask, &mesh->id);
- CustomData_blend_write(
- writer, &mesh->edata, elayers, mesh->totedge, CD_MASK_MESH.emask, &mesh->id);
- /* fdata is really a dummy - written so slots align */
- CustomData_blend_write(
- writer, &mesh->fdata, flayers, mesh->totface, CD_MASK_MESH.fmask, &mesh->id);
- CustomData_blend_write(
- writer, &mesh->ldata, llayers, mesh->totloop, CD_MASK_MESH.lmask, &mesh->id);
- CustomData_blend_write(
- writer, &mesh->pdata, players, mesh->totpoly, CD_MASK_MESH.pmask, &mesh->id);
+ CustomData_blend_write(
+ writer, &mesh->vdata, vlayers, mesh->totvert, CD_MASK_MESH.vmask, &mesh->id);
+ CustomData_blend_write(
+ writer, &mesh->edata, elayers, mesh->totedge, CD_MASK_MESH.emask, &mesh->id);
+ /* fdata is really a dummy - written so slots align */
+ CustomData_blend_write(
+ writer, &mesh->fdata, flayers, mesh->totface, CD_MASK_MESH.fmask, &mesh->id);
+ CustomData_blend_write(
+ writer, &mesh->ldata, llayers, mesh->totloop, CD_MASK_MESH.lmask, &mesh->id);
+ CustomData_blend_write(
+ writer, &mesh->pdata, players, mesh->totpoly, CD_MASK_MESH.pmask, &mesh->id);
- /* Free temporary data */
+ /* Free temporary data */
-/* Free custom-data layers, when not assigned a buffer value. */
+ /* Free custom-data layers, when not assigned a buffer value. */
#define CD_LAYERS_FREE(id) \
if (id && id != id##_buff) { \
MEM_freeN(id); \
} \
((void)0)
- CD_LAYERS_FREE(vlayers);
- CD_LAYERS_FREE(elayers);
- // CD_LAYER_FREE(flayers); /* Never allocated. */
- CD_LAYERS_FREE(llayers);
- CD_LAYERS_FREE(players);
+ CD_LAYERS_FREE(vlayers);
+ CD_LAYERS_FREE(elayers);
+ // CD_LAYER_FREE(flayers); /* Never allocated. */
+ CD_LAYERS_FREE(llayers);
+ CD_LAYERS_FREE(players);
#undef CD_LAYERS_FREE
- }
}
static void mesh_blend_read_data(BlendDataReader *reader, ID *id)
diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c
index f32b0c434c1..e507252307b 100644
--- a/source/blender/blenkernel/intern/movieclip.c
+++ b/source/blender/blenkernel/intern/movieclip.c
@@ -206,36 +206,35 @@ static void write_movieReconstruction(BlendWriter *writer,
static void movieclip_blend_write(BlendWriter *writer, ID *id, const void *id_address)
{
MovieClip *clip = (MovieClip *)id;
- if (clip->id.us > 0 || BLO_write_is_undo(writer)) {
- /* Clean up, important in undo case to reduce false detection of changed datablocks. */
- clip->anim = NULL;
- clip->tracking_context = NULL;
- clip->tracking.stats = NULL;
- MovieTracking *tracking = &clip->tracking;
- MovieTrackingObject *object;
+ /* Clean up, important in undo case to reduce false detection of changed datablocks. */
+ clip->anim = NULL;
+ clip->tracking_context = NULL;
+ clip->tracking.stats = NULL;
- BLO_write_id_struct(writer, MovieClip, id_address, &clip->id);
- BKE_id_blend_write(writer, &clip->id);
+ MovieTracking *tracking = &clip->tracking;
+ MovieTrackingObject *object;
- if (clip->adt) {
- BKE_animdata_blend_write(writer, clip->adt);
- }
+ BLO_write_id_struct(writer, MovieClip, id_address, &clip->id);
+ BKE_id_blend_write(writer, &clip->id);
+
+ if (clip->adt) {
+ BKE_animdata_blend_write(writer, clip->adt);
+ }
- write_movieTracks(writer, &tracking->tracks);
- write_moviePlaneTracks(writer, &tracking->plane_tracks);
- write_movieReconstruction(writer, &tracking->reconstruction);
+ write_movieTracks(writer, &tracking->tracks);
+ write_moviePlaneTracks(writer, &tracking->plane_tracks);
+ write_movieReconstruction(writer, &tracking->reconstruction);
- object = tracking->objects.first;
- while (object) {
- BLO_write_struct(writer, MovieTrackingObject, object);
+ object = tracking->objects.first;
+ while (object) {
+ BLO_write_struct(writer, MovieTrackingObject, object);
- write_movieTracks(writer, &object->tracks);
- write_moviePlaneTracks(writer, &object->plane_tracks);
- write_movieReconstruction(writer, &object->reconstruction);
+ write_movieTracks(writer, &object->tracks);
+ write_moviePlaneTracks(writer, &object->plane_tracks);
+ write_movieReconstruction(writer, &object->reconstruction);
- object = object->next;
- }
+ object = object->next;
}
}
diff --git a/source/blender/blenkernel/intern/node.cc b/source/blender/blenkernel/intern/node.cc
index bd22f049a8b..2a0e05a2616 100644
--- a/source/blender/blenkernel/intern/node.cc
+++ b/source/blender/blenkernel/intern/node.cc
@@ -606,19 +606,18 @@ void ntreeBlendWrite(BlendWriter *writer, bNodeTree *ntree)
static void ntree_blend_write(BlendWriter *writer, ID *id, const void *id_address)
{
bNodeTree *ntree = (bNodeTree *)id;
- if (ntree->id.us > 0 || BLO_write_is_undo(writer)) {
- /* Clean up, important in undo case to reduce false detection of changed datablocks. */
- ntree->init = 0; /* to set callbacks and force setting types */
- ntree->is_updating = false;
- ntree->typeinfo = nullptr;
- ntree->interface_type = nullptr;
- ntree->progress = nullptr;
- ntree->execdata = nullptr;
- BLO_write_id_struct(writer, bNodeTree, id_address, &ntree->id);
+ /* Clean up, important in undo case to reduce false detection of changed datablocks. */
+ ntree->init = 0; /* to set callbacks and force setting types */
+ ntree->is_updating = false;
+ ntree->typeinfo = nullptr;
+ ntree->interface_type = nullptr;
+ ntree->progress = nullptr;
+ ntree->execdata = nullptr;
- ntreeBlendWrite(writer, ntree);
- }
+ BLO_write_id_struct(writer, bNodeTree, id_address, &ntree->id);
+
+ ntreeBlendWrite(writer, ntree);
}
static void direct_link_node_socket(BlendDataReader *reader, bNodeSocket *sock)
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 86db4b6ace8..1c08a46adc3 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -523,74 +523,72 @@ static void object_blend_write(BlendWriter *writer, ID *id, const void *id_addre
Object *ob = (Object *)id;
const bool is_undo = BLO_write_is_undo(writer);
- if (ob->id.us > 0 || is_undo) {
- /* Clean up, important in undo case to reduce false detection of changed data-blocks. */
- BKE_object_runtime_reset(ob);
- if (is_undo) {
- /* For undo we stay in object mode during undo presses, so keep edit-mode disabled on save as
- * well, can help reducing false detection of changed data-blocks. */
- ob->mode &= ~OB_MODE_EDIT;
- }
+ /* Clean up, important in undo case to reduce false detection of changed data-blocks. */
+ BKE_object_runtime_reset(ob);
+
+ if (is_undo) {
+ /* For undo we stay in object mode during undo presses, so keep edit-mode disabled on save as
+ * well, can help reducing false detection of changed data-blocks. */
+ ob->mode &= ~OB_MODE_EDIT;
+ }
- /* write LibData */
- BLO_write_id_struct(writer, Object, id_address, &ob->id);
- BKE_id_blend_write(writer, &ob->id);
+ /* write LibData */
+ BLO_write_id_struct(writer, Object, id_address, &ob->id);
+ BKE_id_blend_write(writer, &ob->id);
- if (ob->adt) {
- BKE_animdata_blend_write(writer, ob->adt);
- }
+ if (ob->adt) {
+ BKE_animdata_blend_write(writer, ob->adt);
+ }
- /* direct data */
- BLO_write_pointer_array(writer, ob->totcol, ob->mat);
- BLO_write_raw(writer, sizeof(char) * ob->totcol, ob->matbits);
+ /* direct data */
+ BLO_write_pointer_array(writer, ob->totcol, ob->mat);
+ BLO_write_raw(writer, sizeof(char) * ob->totcol, ob->matbits);
- bArmature *arm = NULL;
- if (ob->type == OB_ARMATURE) {
- arm = ob->data;
- if (arm && ob->pose && arm->act_bone) {
- BLI_strncpy(
- ob->pose->proxy_act_bone, arm->act_bone->name, sizeof(ob->pose->proxy_act_bone));
- }
+ bArmature *arm = NULL;
+ if (ob->type == OB_ARMATURE) {
+ arm = ob->data;
+ if (arm && ob->pose && arm->act_bone) {
+ BLI_strncpy(ob->pose->proxy_act_bone, arm->act_bone->name, sizeof(ob->pose->proxy_act_bone));
}
+ }
- BKE_pose_blend_write(writer, ob->pose, arm);
- write_fmaps(writer, &ob->fmaps);
- BKE_constraint_blend_write(writer, &ob->constraints);
- animviz_motionpath_blend_write(writer, ob->mpath);
+ BKE_pose_blend_write(writer, ob->pose, arm);
+ write_fmaps(writer, &ob->fmaps);
+ BKE_constraint_blend_write(writer, &ob->constraints);
+ animviz_motionpath_blend_write(writer, ob->mpath);
- BLO_write_struct(writer, PartDeflect, ob->pd);
- if (ob->soft) {
- /* Set deprecated pointers to prevent crashes of older Blenders */
- ob->soft->pointcache = ob->soft->shared->pointcache;
- ob->soft->ptcaches = ob->soft->shared->ptcaches;
- BLO_write_struct(writer, SoftBody, ob->soft);
- BLO_write_struct(writer, SoftBody_Shared, ob->soft->shared);
- BKE_ptcache_blend_write(writer, &(ob->soft->shared->ptcaches));
- BLO_write_struct(writer, EffectorWeights, ob->soft->effector_weights);
- }
+ BLO_write_struct(writer, PartDeflect, ob->pd);
+ if (ob->soft) {
+ /* Set deprecated pointers to prevent crashes of older Blenders */
+ ob->soft->pointcache = ob->soft->shared->pointcache;
+ ob->soft->ptcaches = ob->soft->shared->ptcaches;
+ BLO_write_struct(writer, SoftBody, ob->soft);
+ BLO_write_struct(writer, SoftBody_Shared, ob->soft->shared);
+ BKE_ptcache_blend_write(writer, &(ob->soft->shared->ptcaches));
+ BLO_write_struct(writer, EffectorWeights, ob->soft->effector_weights);
+ }
- if (ob->rigidbody_object) {
- /* TODO: if any extra data is added to handle duplis, will need separate function then */
- BLO_write_struct(writer, RigidBodyOb, ob->rigidbody_object);
- }
- if (ob->rigidbody_constraint) {
- BLO_write_struct(writer, RigidBodyCon, ob->rigidbody_constraint);
- }
+ if (ob->rigidbody_object) {
+ /* TODO: if any extra data is added to handle duplis, will need separate function then */
+ BLO_write_struct(writer, RigidBodyOb, ob->rigidbody_object);
+ }
+ if (ob->rigidbody_constraint) {
+ BLO_write_struct(writer, RigidBodyCon, ob->rigidbody_constraint);
+ }
- if (ob->type == OB_EMPTY && ob->empty_drawtype == OB_EMPTY_IMAGE) {
- BLO_write_struct(writer, ImageUser, ob->iuser);
- }
+ if (ob->type == OB_EMPTY && ob->empty_drawtype == OB_EMPTY_IMAGE) {
+ BLO_write_struct(writer, ImageUser, ob->iuser);
+ }
- BKE_particle_system_blend_write(writer, &ob->particlesystem);
- BKE_modifier_blend_write(writer, &ob->modifiers);
- BKE_gpencil_modifier_blend_write(writer, &ob->greasepencil_modifiers);
- BKE_shaderfx_blend_write(writer, &ob->shader_fx);
+ BKE_particle_system_blend_write(writer, &ob->particlesystem);
+ BKE_modifier_blend_write(writer, &ob->modifiers);
+ BKE_gpencil_modifier_blend_write(writer, &ob->greasepencil_modifiers);
+ BKE_shaderfx_blend_write(writer, &ob->shader_fx);
- BLO_write_struct_list(writer, LinkData, &ob->pc_ids);
+ BLO_write_struct_list(writer, LinkData, &ob->pc_ids);
- BKE_previewimg_blend_write(writer, ob->preview);
- }
+ BKE_previewimg_blend_write(writer, ob->preview);
}
/* XXX deprecated - old animation system */
diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c
index a1fa6aae1ce..d6030941c6d 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -108,14 +108,13 @@ static void palette_free_data(ID *id)
static void palette_blend_write(BlendWriter *writer, ID *id, const void *id_address)
{
Palette *palette = (Palette *)id;
- if (palette->id.us > 0 || BLO_write_is_undo(writer)) {
- PaletteColor *color;
- BLO_write_id_struct(writer, Palette, id_address, &palette->id);
- BKE_id_blend_write(writer, &palette->id);
- for (color = palette->colors.first; color; color = color->next) {
- BLO_write_struct(writer, PaletteColor, color);
- }
+ PaletteColor *color;
+ BLO_write_id_struct(writer, Palette, id_address, &palette->id);
+ BKE_id_blend_write(writer, &palette->id);
+
+ for (color = palette->colors.first; color; color = color->next) {
+ BLO_write_struct(writer, PaletteColor, color);
}
}
@@ -187,12 +186,11 @@ static void paint_curve_free_data(ID *id)
static void paint_curve_blend_write(BlendWriter *writer, ID *id, const void *id_address)
{
PaintCurve *pc = (PaintCurve *)id;
- if (pc->id.us > 0 || BLO_write_is_undo(writer)) {
- BLO_write_id_struct(writer, PaintCurve, id_address, &pc->id);
- BKE_id_blend_write(writer, &pc->id);
- BLO_write_struct_array(writer, PaintCurvePoint, pc->tot_points, pc->points);
- }
+ BLO_write_id_struct(writer, PaintCurve, id_address, &pc->id);
+ BKE_id_blend_write(writer, &pc->id);
+
+ BLO_write_struct_array(writer, PaintCurvePoint, pc->tot_points, pc->points);
}
static void paint_curve_blend_read_data(BlendDataReader *reader, ID *id)
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c
index cc8a051eceb..29849c69b6f 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -255,60 +255,59 @@ static void write_boid_state(BlendWriter *writer, BoidState *state)
static void particle_settings_blend_write(BlendWriter *writer, ID *id, const void *id_address)
{
ParticleSettings *part = (ParticleSettings *)id;
- if (part->id.us > 0 || BLO_write_is_undo(writer)) {
- /* write LibData */
- BLO_write_id_struct(writer, ParticleSettings, id_address, &part->id);
- BKE_id_blend_write(writer, &part->id);
- if (part->adt) {
- BKE_animdata_blend_write(writer, part->adt);
- }
- BLO_write_struct(writer, PartDeflect, part->pd);
- BLO_write_struct(writer, PartDeflect, part->pd2);
- BLO_write_struct(writer, EffectorWeights, part->effector_weights);
+ /* write LibData */
+ BLO_write_id_struct(writer, ParticleSettings, id_address, &part->id);
+ BKE_id_blend_write(writer, &part->id);
- if (part->clumpcurve) {
- BKE_curvemapping_blend_write(writer, part->clumpcurve);
- }
- if (part->roughcurve) {
- BKE_curvemapping_blend_write(writer, part->roughcurve);
- }
- if (part->twistcurve) {
- BKE_curvemapping_blend_write(writer, part->twistcurve);
- }
+ if (part->adt) {
+ BKE_animdata_blend_write(writer, part->adt);
+ }
+ BLO_write_struct(writer, PartDeflect, part->pd);
+ BLO_write_struct(writer, PartDeflect, part->pd2);
+ BLO_write_struct(writer, EffectorWeights, part->effector_weights);
- LISTBASE_FOREACH (ParticleDupliWeight *, dw, &part->instance_weights) {
- /* update indices, but only if dw->ob is set (can be NULL after loading e.g.) */
- if (dw->ob != NULL) {
- dw->index = 0;
- if (part->instance_collection) { /* can be NULL if lining fails or set to None */
- FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN (part->instance_collection, object) {
- if (object == dw->ob) {
- break;
- }
- dw->index++;
+ if (part->clumpcurve) {
+ BKE_curvemapping_blend_write(writer, part->clumpcurve);
+ }
+ if (part->roughcurve) {
+ BKE_curvemapping_blend_write(writer, part->roughcurve);
+ }
+ if (part->twistcurve) {
+ BKE_curvemapping_blend_write(writer, part->twistcurve);
+ }
+
+ LISTBASE_FOREACH (ParticleDupliWeight *, dw, &part->instance_weights) {
+ /* update indices, but only if dw->ob is set (can be NULL after loading e.g.) */
+ if (dw->ob != NULL) {
+ dw->index = 0;
+ if (part->instance_collection) { /* can be NULL if lining fails or set to None */
+ FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN (part->instance_collection, object) {
+ if (object == dw->ob) {
+ break;
}
- FOREACH_COLLECTION_OBJECT_RECURSIVE_END;
+ dw->index++;
}
+ FOREACH_COLLECTION_OBJECT_RECURSIVE_END;
}
- BLO_write_struct(writer, ParticleDupliWeight, dw);
}
+ BLO_write_struct(writer, ParticleDupliWeight, dw);
+ }
- if (part->boids && part->phystype == PART_PHYS_BOIDS) {
- BLO_write_struct(writer, BoidSettings, part->boids);
+ if (part->boids && part->phystype == PART_PHYS_BOIDS) {
+ BLO_write_struct(writer, BoidSettings, part->boids);
- LISTBASE_FOREACH (BoidState *, state, &part->boids->states) {
- write_boid_state(writer, state);
- }
- }
- if (part->fluid && part->phystype == PART_PHYS_FLUID) {
- BLO_write_struct(writer, SPHFluidSettings, part->fluid);
+ LISTBASE_FOREACH (BoidState *, state, &part->boids->states) {
+ write_boid_state(writer, state);
}
+ }
+ if (part->fluid && part->phystype == PART_PHYS_FLUID) {
+ BLO_write_struct(writer, SPHFluidSettings, part->fluid);
+ }
- for (int a = 0; a < MAX_MTEX; a++) {
- if (part->mtex[a]) {
- BLO_write_struct(writer, MTex, part->mtex[a]);
- }
+ for (int a = 0; a < MAX_MTEX; a++) {
+ if (part->mtex[a]) {
+ BLO_write_struct(writer, MTex, part->mtex[a]);
}
}
}
diff --git a/source/blender/blenkernel/intern/pointcloud.cc b/source/blender/blenkernel/intern/pointcloud.cc
index d9a7a376e2e..837a772607f 100644
--- a/source/blender/blenkernel/intern/pointcloud.cc
+++ b/source/blender/blenkernel/intern/pointcloud.cc
@@ -112,28 +112,27 @@ static void pointcloud_foreach_id(ID *id, LibraryForeachIDData *data)
static void pointcloud_blend_write(BlendWriter *writer, ID *id, const void *id_address)
{
PointCloud *pointcloud = (PointCloud *)id;
- if (pointcloud->id.us > 0 || BLO_write_is_undo(writer)) {
- CustomDataLayer *players = nullptr, players_buff[CD_TEMP_CHUNK_SIZE];
- CustomData_blend_write_prepare(
- &pointcloud->pdata, &players, players_buff, ARRAY_SIZE(players_buff));
-
- /* Write LibData */
- BLO_write_id_struct(writer, PointCloud, id_address, &pointcloud->id);
- BKE_id_blend_write(writer, &pointcloud->id);
-
- /* Direct data */
- CustomData_blend_write(
- writer, &pointcloud->pdata, players, pointcloud->totpoint, CD_MASK_ALL, &pointcloud->id);
-
- BLO_write_pointer_array(writer, pointcloud->totcol, pointcloud->mat);
- if (pointcloud->adt) {
- BKE_animdata_blend_write(writer, pointcloud->adt);
- }
- /* Remove temporary data. */
- if (players && players != players_buff) {
- MEM_freeN(players);
- }
+ CustomDataLayer *players = nullptr, players_buff[CD_TEMP_CHUNK_SIZE];
+ CustomData_blend_write_prepare(
+ &pointcloud->pdata, &players, players_buff, ARRAY_SIZE(players_buff));
+
+ /* Write LibData */
+ BLO_write_id_struct(writer, PointCloud, id_address, &pointcloud->id);
+ BKE_id_blend_write(writer, &pointcloud->id);
+
+ /* Direct data */
+ CustomData_blend_write(
+ writer, &pointcloud->pdata, players, pointcloud->totpoint, CD_MASK_ALL, &pointcloud->id);
+
+ BLO_write_pointer_array(writer, pointcloud->totcol, pointcloud->mat);
+ if (pointcloud->adt) {
+ BKE_animdata_blend_write(writer, pointcloud->adt);
+ }
+
+ /* Remove temporary data. */
+ if (players && players != players_buff) {
+ MEM_freeN(players);
}
}
diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c
index e44c5a6b40e..1e725a6afc4 100644
--- a/source/blender/blenkernel/intern/screen.c
+++ b/source/blender/blenkernel/intern/screen.c
@@ -255,18 +255,16 @@ static void screen_foreach_id(ID *id, LibraryForeachIDData *data)
static void screen_blend_write(BlendWriter *writer, ID *id, const void *id_address)
{
bScreen *screen = (bScreen *)id;
- /* Screens are reference counted, only saved if used by a workspace. */
- if (screen->id.us > 0 || BLO_write_is_undo(writer)) {
- /* write LibData */
- /* in 2.50+ files, the file identifier for screens is patched, forward compatibility */
- BLO_write_struct_at_address_with_filecode(writer, ID_SCRN, bScreen, id_address, screen);
- BKE_id_blend_write(writer, &screen->id);
- BKE_previewimg_blend_write(writer, screen->preview);
+ /* write LibData */
+ /* in 2.50+ files, the file identifier for screens is patched, forward compatibility */
+ BLO_write_struct_at_address_with_filecode(writer, ID_SCRN, bScreen, id_address, screen);
+ BKE_id_blend_write(writer, &screen->id);
- /* direct data */
- BKE_screen_area_map_blend_write(writer, AREAMAP_FROM_SCREEN(screen));
- }
+ BKE_previewimg_blend_write(writer, screen->preview);
+
+ /* direct data */
+ BKE_screen_area_map_blend_write(writer, AREAMAP_FROM_SCREEN(screen));
}
/* Cannot use IDTypeInfo callback yet, because of the return value. */
diff --git a/source/blender/blenkernel/intern/simulation.cc b/source/blender/blenkernel/intern/simulation.cc
index 216563b860d..5aac29c19a7 100644
--- a/source/blender/blenkernel/intern/simulation.cc
+++ b/source/blender/blenkernel/intern/simulation.cc
@@ -114,19 +114,18 @@ static void simulation_foreach_id(ID *id, LibraryForeachIDData *data)
static void simulation_blend_write(BlendWriter *writer, ID *id, const void *id_address)
{
Simulation *simulation = (Simulation *)id;
- if (simulation->id.us > 0 || BLO_write_is_undo(writer)) {
- BLO_write_id_struct(writer, Simulation, id_address, &simulation->id);
- BKE_id_blend_write(writer, &simulation->id);
-
- if (simulation->adt) {
- BKE_animdata_blend_write(writer, simulation->adt);
- }
-
- /* nodetree is integral part of simulation, no libdata */
- if (simulation->nodetree) {
- BLO_write_struct(writer, bNodeTree, simulation->nodetree);
- ntreeBlendWrite(writer, simulation->nodetree);
- }
+
+ BLO_write_id_struct(writer, Simulation, id_address, &simulation->id);
+ BKE_id_blend_write(writer, &simulation->id);
+
+ if (simulation->adt) {
+ BKE_animdata_blend_write(writer, simulation->adt);
+ }
+
+ /* nodetree is integral part of simulation, no libdata */
+ if (simulation->nodetree) {
+ BLO_write_struct(writer, bNodeTree, simulation->nodetree);
+ ntreeBlendWrite(writer, simulation->nodetree);
}
}
diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c
index 8730d2758e6..c61fa793367 100644
--- a/source/blender/blenkernel/intern/sound.c
+++ b/source/blender/blenkernel/intern/sound.c
@@ -137,24 +137,23 @@ static void sound_blend_write(BlendWriter *writer, ID *id, const void *id_addres
{
bSound *sound = (bSound *)id;
const bool is_undo = BLO_write_is_undo(writer);
- if (sound->id.us > 0 || is_undo) {
- /* Clean up, important in undo case to reduce false detection of changed datablocks. */
- sound->tags = 0;
- sound->handle = NULL;
- sound->playback_handle = NULL;
- sound->spinlock = NULL;
- /* Do not store packed files in case this is a library override ID. */
- if (ID_IS_OVERRIDE_LIBRARY(sound) && !is_undo) {
- sound->packedfile = NULL;
- }
-
- /* write LibData */
- BLO_write_id_struct(writer, bSound, id_address, &sound->id);
- BKE_id_blend_write(writer, &sound->id);
+ /* Clean up, important in undo case to reduce false detection of changed datablocks. */
+ sound->tags = 0;
+ sound->handle = NULL;
+ sound->playback_handle = NULL;
+ sound->spinlock = NULL;
- BKE_packedfile_blend_write(writer, sound->packedfile);
+ /* Do not store packed files in case this is a library override ID. */
+ if (ID_IS_OVERRIDE_LIBRARY(sound) && !is_undo) {
+ sound->packedfile = NULL;
}
+
+ /* write LibData */
+ BLO_write_id_struct(writer, bSound, id_address, &sound->id);
+ BKE_id_blend_write(writer, &sound->id);
+
+ BKE_packedfile_blend_write(writer, sound->packedfile);
}
static void sound_blend_read_data(BlendDataReader *reader, ID *id)
diff --git a/source/blender/blenkernel/intern/speaker.c b/source/blender/blenkernel/intern/speaker.c
index af9b2268879..4b10522c375 100644
--- a/source/blender/blenkernel/intern/speaker.c
+++ b/source/blender/blenkernel/intern/speaker.c
@@ -56,14 +56,13 @@ static void speaker_foreach_id(ID *id, LibraryForeachIDData *data)
static void speaker_blend_write(BlendWriter *writer, ID *id, const void *id_address)
{
Speaker *spk = (Speaker *)id;
- if (spk->id.us > 0 || BLO_write_is_undo(writer)) {
- /* write LibData */
- BLO_write_id_struct(writer, Speaker, id_address, &spk->id);
- BKE_id_blend_write(writer, &spk->id);
-
- if (spk->adt) {
- BKE_animdata_blend_write(writer, spk->adt);
- }
+
+ /* write LibData */
+ BLO_write_id_struct(writer, Speaker, id_address, &spk->id);
+ BKE_id_blend_write(writer, &spk->id);
+
+ if (spk->adt) {
+ BKE_animdata_blend_write(writer, spk->adt);
}
}
diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c
index 6048e823abb..275cf0d4c38 100644
--- a/source/blender/blenkernel/intern/text.c
+++ b/source/blender/blenkernel/intern/text.c
@@ -171,9 +171,6 @@ static void text_free_data(ID *id)
static void text_blend_write(BlendWriter *writer, ID *id, const void *id_address)
{
- if (id->us < 1 && !BLO_write_is_undo(writer)) {
- return;
- }
Text *text = (Text *)id;
/* NOTE: we are clearing local temp data here, *not* the flag in the actual 'real' ID. */
diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c
index beb92495d16..228e6fffdf7 100644
--- a/source/blender/blenkernel/intern/texture.c
+++ b/source/blender/blenkernel/intern/texture.c
@@ -150,28 +150,27 @@ static void texture_foreach_id(ID *id, LibraryForeachIDData *data)
static void texture_blend_write(BlendWriter *writer, ID *id, const void *id_address)
{
Tex *tex = (Tex *)id;
- if (tex->id.us > 0 || BLO_write_is_undo(writer)) {
- /* write LibData */
- BLO_write_id_struct(writer, Tex, id_address, &tex->id);
- BKE_id_blend_write(writer, &tex->id);
- if (tex->adt) {
- BKE_animdata_blend_write(writer, tex->adt);
- }
+ /* write LibData */
+ BLO_write_id_struct(writer, Tex, id_address, &tex->id);
+ BKE_id_blend_write(writer, &tex->id);
- /* direct data */
- if (tex->coba) {
- BLO_write_struct(writer, ColorBand, tex->coba);
- }
+ if (tex->adt) {
+ BKE_animdata_blend_write(writer, tex->adt);
+ }
- /* nodetree is integral part of texture, no libdata */
- if (tex->nodetree) {
- BLO_write_struct(writer, bNodeTree, tex->nodetree);
- ntreeBlendWrite(writer, tex->nodetree);
- }
+ /* direct data */
+ if (tex->coba) {
+ BLO_write_struct(writer, ColorBand, tex->coba);
+ }
- BKE_previewimg_blend_write(writer, tex->preview);
+ /* nodetree is integral part of texture, no libdata */
+ if (tex->nodetree) {
+ BLO_write_struct(writer, bNodeTree, tex->nodetree);
+ ntreeBlendWrite(writer, tex->nodetree);
}
+
+ BKE_previewimg_blend_write(writer, tex->preview);
}
static void texture_blend_read_data(BlendDataReader *reader, ID *id)
diff --git a/source/blender/blenkernel/intern/volume.cc b/source/blender/blenkernel/intern/volume.cc
index b28d17df814..69452d6896f 100644
--- a/source/blender/blenkernel/intern/volume.cc
+++ b/source/blender/blenkernel/intern/volume.cc
@@ -578,27 +578,26 @@ static void volume_blend_write(BlendWriter *writer, ID *id, const void *id_addre
{
Volume *volume = (Volume *)id;
const bool is_undo = BLO_write_is_undo(writer);
- if (volume->id.us > 0 || is_undo) {
- /* Clean up, important in undo case to reduce false detection of changed datablocks. */
- volume->runtime.grids = nullptr;
- /* Do not store packed files in case this is a library override ID. */
- if (ID_IS_OVERRIDE_LIBRARY(volume) && !is_undo) {
- volume->packedfile = nullptr;
- }
+ /* Clean up, important in undo case to reduce false detection of changed datablocks. */
+ volume->runtime.grids = nullptr;
- /* write LibData */
- BLO_write_id_struct(writer, Volume, id_address, &volume->id);
- BKE_id_blend_write(writer, &volume->id);
+ /* Do not store packed files in case this is a library override ID. */
+ if (ID_IS_OVERRIDE_LIBRARY(volume) && !is_undo) {
+ volume->packedfile = nullptr;
+ }
- /* direct data */
- BLO_write_pointer_array(writer, volume->totcol, volume->mat);
- if (volume->adt) {
- BKE_animdata_blend_write(writer, volume->adt);
- }
+ /* write LibData */
+ BLO_write_id_struct(writer, Volume, id_address, &volume->id);
+ BKE_id_blend_write(writer, &volume->id);
- BKE_packedfile_blend_write(writer, volume->packedfile);
+ /* direct data */
+ BLO_write_pointer_array(writer, volume->totcol, volume->mat);
+ if (volume->adt) {
+ BKE_animdata_blend_write(writer, volume->adt);
}
+
+ BKE_packedfile_blend_write(writer, volume->packedfile);
}
static void volume_blend_read_data(BlendDataReader *reader, ID *id)
diff --git a/source/blender/blenkernel/intern/world.c b/source/blender/blenkernel/intern/world.c
index e889d8af1d5..4abe1ff0f20 100644
--- a/source/blender/blenkernel/intern/world.c
+++ b/source/blender/blenkernel/intern/world.c
@@ -138,26 +138,25 @@ static void world_foreach_id(ID *id, LibraryForeachIDData *data)
static void world_blend_write(BlendWriter *writer, ID *id, const void *id_address)
{
World *wrld = (World *)id;
- if (wrld->id.us > 0 || BLO_write_is_undo(writer)) {
- /* Clean up, important in undo case to reduce false detection of changed datablocks. */
- BLI_listbase_clear(&wrld->gpumaterial);
- /* write LibData */
- BLO_write_id_struct(writer, World, id_address, &wrld->id);
- BKE_id_blend_write(writer, &wrld->id);
+ /* Clean up, important in undo case to reduce false detection of changed datablocks. */
+ BLI_listbase_clear(&wrld->gpumaterial);
- if (wrld->adt) {
- BKE_animdata_blend_write(writer, wrld->adt);
- }
+ /* write LibData */
+ BLO_write_id_struct(writer, World, id_address, &wrld->id);
+ BKE_id_blend_write(writer, &wrld->id);
- /* nodetree is integral part of world, no libdata */
- if (wrld->nodetree) {
- BLO_write_struct(writer, bNodeTree, wrld->nodetree);
- ntreeBlendWrite(writer, wrld->nodetree);
- }
+ if (wrld->adt) {
+ BKE_animdata_blend_write(writer, wrld->adt);
+ }
- BKE_previewimg_blend_write(writer, wrld->preview);
+ /* nodetree is integral part of world, no libdata */
+ if (wrld->nodetree) {
+ BLO_write_struct(writer, bNodeTree, wrld->nodetree);
+ ntreeBlendWrite(writer, wrld->nodetree);
}
+
+ BKE_previewimg_blend_write(writer, wrld->preview);
}
static void world_blend_read_data(BlendDataReader *reader, ID *id)
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index 225548f3832..337279ae84b 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -982,6 +982,14 @@ static bool write_file_handle(Main *mainvar,
BLI_assert(
(id->tag & (LIB_TAG_NO_MAIN | LIB_TAG_NO_USER_REFCOUNT | LIB_TAG_NOT_ALLOCATED)) == 0);
+ /* We only write unused IDs in undo case.
+ * NOTE: All Scenes, WindowManagers and WorkSpaces should always be written to disk, so
+ * their usercount should never be NULL currently. */
+ if (id->us == 0 && !wd->use_memfile) {
+ BLI_assert(!ELEM(GS(id->name), ID_SCE, ID_WM, ID_WS));
+ continue;
+ }
+
const bool do_override = !ELEM(override_storage, NULL, bmain) &&
ID_IS_OVERRIDE_LIBRARY_REAL(id);