diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index b46ee660a08..b5055111a30 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -5753,15 +5753,6 @@ static void direct_link_modifiers(BlendDataReader *reader, ListBase *lb, Object surmd->v = NULL; surmd->numverts = 0; } - else if (md->type == eModifierType_Hook) { - HookModifierData *hmd = (HookModifierData *)md; - BLO_read_int32_array(reader, hmd->totindex, &hmd->indexar); - - BLO_read_data_address(reader, &hmd->curfalloff); - if (hmd->curfalloff) { - BKE_curvemapping_blend_read(reader, hmd->curfalloff); - } - } else if (md->type == eModifierType_ParticleSystem) { ParticleSystemModifierData *psmd = (ParticleSystemModifierData *)md; @@ -5781,33 +5772,6 @@ static void direct_link_modifiers(BlendDataReader *reader, ListBase *lb, Object omd->oceancache = NULL; omd->ocean = NULL; } - else if (md->type == eModifierType_Warp) { - WarpModifierData *tmd = (WarpModifierData *)md; - - BLO_read_data_address(reader, &tmd->curfalloff); - if (tmd->curfalloff) { - BKE_curvemapping_blend_read(reader, tmd->curfalloff); - } - } - else if (md->type == eModifierType_WeightVGEdit) { - WeightVGEditModifierData *wmd = (WeightVGEditModifierData *)md; - - BLO_read_data_address(reader, &wmd->cmap_curve); - if (wmd->cmap_curve) { - BKE_curvemapping_blend_read(reader, wmd->cmap_curve); - } - } - else if (md->type == eModifierType_CorrectiveSmooth) { - CorrectiveSmoothModifierData *csmd = (CorrectiveSmoothModifierData *)md; - - if (csmd->bind_coords) { - BLO_read_float3_array(reader, csmd->bind_coords_num, (float **)&csmd->bind_coords); - } - - /* runtime only */ - csmd->delta_cache.deltas = NULL; - csmd->delta_cache.totverts = 0; - } else if (md->type == eModifierType_MeshSequenceCache) { MeshSeqCacheModifierData *msmcd = (MeshSeqCacheModifierData *)md; msmcd->reader = NULL; diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 0c57621e742..6aeb0746d21 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -1666,16 +1666,7 @@ static void write_modifiers(BlendWriter *writer, ListBase *modbase) BLO_write_struct_by_name(writer, mti->structName, md); - if (md->type == eModifierType_Hook) { - HookModifierData *hmd = (HookModifierData *)md; - - if (hmd->curfalloff) { - BKE_curvemapping_blend_write(writer, hmd->curfalloff); - } - - BLO_write_int32_array(writer, hmd->totindex, hmd->indexar); - } - else if (md->type == eModifierType_Cloth) { + if (md->type == eModifierType_Cloth) { ClothModifierData *clmd = (ClothModifierData *)md; BLO_write_struct(writer, ClothSimSettings, clmd->sim_parms); @@ -1757,26 +1748,6 @@ static void write_modifiers(BlendWriter *writer, ListBase *modbase) writestruct(wd, DATA, MFace, collmd->numfaces, collmd->mfaces); #endif } - else if (md->type == eModifierType_Warp) { - WarpModifierData *tmd = (WarpModifierData *)md; - if (tmd->curfalloff) { - BKE_curvemapping_blend_write(writer, tmd->curfalloff); - } - } - else if (md->type == eModifierType_WeightVGEdit) { - WeightVGEditModifierData *wmd = (WeightVGEditModifierData *)md; - - if (wmd->cmap_curve) { - BKE_curvemapping_blend_write(writer, wmd->cmap_curve); - } - } - else if (md->type == eModifierType_CorrectiveSmooth) { - CorrectiveSmoothModifierData *csmd = (CorrectiveSmoothModifierData *)md; - - if (csmd->bind_coords) { - BLO_write_float3_array(writer, csmd->bind_coords_num, (float *)csmd->bind_coords); - } - } else if (md->type == eModifierType_SurfaceDeform) { SurfaceDeformModifierData *smd = (SurfaceDeformModifierData *)md; diff --git a/source/blender/modifiers/intern/MOD_correctivesmooth.c b/source/blender/modifiers/intern/MOD_correctivesmooth.c index ba343854d41..ac91056ed7d 100644 --- a/source/blender/modifiers/intern/MOD_correctivesmooth.c +++ b/source/blender/modifiers/intern/MOD_correctivesmooth.c @@ -54,6 +54,8 @@ #include "MOD_ui_common.h" #include "MOD_util.h" +#include "BLO_read_write.h" + #include "BLI_strict_flags.h" #include "DEG_depsgraph_query.h" @@ -817,6 +819,28 @@ static void panelRegister(ARegionType *region_type) modifier_panel_register(region_type, eModifierType_CorrectiveSmooth, panel_draw); } +static void blendWrite(BlendWriter *writer, const ModifierData *md) +{ + const CorrectiveSmoothModifierData *csmd = (const CorrectiveSmoothModifierData *)md; + + if (csmd->bind_coords) { + BLO_write_float3_array(writer, (int)csmd->bind_coords_num, (float *)csmd->bind_coords); + } +} + +static void blendRead(BlendDataReader *reader, ModifierData *md) +{ + CorrectiveSmoothModifierData *csmd = (CorrectiveSmoothModifierData *)md; + + if (csmd->bind_coords) { + BLO_read_float3_array(reader, (int)csmd->bind_coords_num, (float **)&csmd->bind_coords); + } + + /* runtime only */ + csmd->delta_cache.deltas = NULL; + csmd->delta_cache.totverts = 0; +} + ModifierTypeInfo modifierType_CorrectiveSmooth = { /* name */ "CorrectiveSmooth", /* structName */ "CorrectiveSmoothModifierData", @@ -847,6 +871,6 @@ ModifierTypeInfo modifierType_CorrectiveSmooth = { /* foreachTexLink */ NULL, /* freeRuntimeData */ NULL, /* panelRegister */ panelRegister, - /* blendWrite */ NULL, - /* blendRead */ NULL, + /* blendWrite */ blendWrite, + /* blendRead */ blendRead, }; diff --git a/source/blender/modifiers/intern/MOD_hook.c b/source/blender/modifiers/intern/MOD_hook.c index 4305c32071d..c8cfc07562f 100644 --- a/source/blender/modifiers/intern/MOD_hook.c +++ b/source/blender/modifiers/intern/MOD_hook.c @@ -46,6 +46,8 @@ #include "UI_interface.h" #include "UI_resources.h" +#include "BLO_read_write.h" + #include "RNA_access.h" #include "DEG_depsgraph_query.h" @@ -468,6 +470,29 @@ static void panelRegister(ARegionType *region_type) region_type, "falloff", "Falloff", NULL, falloff_panel_draw, panel_type); } +static void blendWrite(BlendWriter *writer, const ModifierData *md) +{ + const HookModifierData *hmd = (const HookModifierData *)md; + + if (hmd->curfalloff) { + BKE_curvemapping_blend_write(writer, hmd->curfalloff); + } + + BLO_write_int32_array(writer, hmd->totindex, hmd->indexar); +} + +static void blendRead(BlendDataReader *reader, ModifierData *md) +{ + HookModifierData *hmd = (HookModifierData *)md; + + BLO_read_data_address(reader, &hmd->curfalloff); + if (hmd->curfalloff) { + BKE_curvemapping_blend_read(reader, hmd->curfalloff); + } + + BLO_read_int32_array(reader, hmd->totindex, &hmd->indexar); +} + ModifierTypeInfo modifierType_Hook = { /* name */ "Hook", /* structName */ "HookModifierData", @@ -498,6 +523,6 @@ ModifierTypeInfo modifierType_Hook = { /* foreachTexLink */ NULL, /* freeRuntimeData */ NULL, /* panelRegister */ panelRegister, - /* blendWrite */ NULL, - /* blendRead */ NULL, + /* blendWrite */ blendWrite, + /* blendRead */ blendRead, }; diff --git a/source/blender/modifiers/intern/MOD_warp.c b/source/blender/modifiers/intern/MOD_warp.c index b32efa3fb8f..2b67b26e620 100644 --- a/source/blender/modifiers/intern/MOD_warp.c +++ b/source/blender/modifiers/intern/MOD_warp.c @@ -49,6 +49,8 @@ #include "UI_interface.h" #include "UI_resources.h" +#include "BLO_read_write.h" + #include "RNA_access.h" #include "DEG_depsgraph.h" @@ -510,6 +512,25 @@ static void panelRegister(ARegionType *region_type) region_type, "texture", "Texture", NULL, texture_panel_draw, panel_type); } +static void blendWrite(BlendWriter *writer, const ModifierData *md) +{ + const WarpModifierData *tmd = (const WarpModifierData *)md; + + if (tmd->curfalloff) { + BKE_curvemapping_blend_write(writer, tmd->curfalloff); + } +} + +static void blendRead(BlendDataReader *reader, ModifierData *md) +{ + WarpModifierData *tmd = (WarpModifierData *)md; + + BLO_read_data_address(reader, &tmd->curfalloff); + if (tmd->curfalloff) { + BKE_curvemapping_blend_read(reader, tmd->curfalloff); + } +} + ModifierTypeInfo modifierType_Warp = { /* name */ "Warp", /* structName */ "WarpModifierData", @@ -540,6 +561,6 @@ ModifierTypeInfo modifierType_Warp = { /* foreachTexLink */ foreachTexLink, /* freeRuntimeData */ NULL, /* panelRegister */ panelRegister, - /* blendWrite */ NULL, - /* blendRead */ NULL, + /* blendWrite */ blendWrite, + /* blendRead */ blendRead, }; diff --git a/source/blender/modifiers/intern/MOD_weightvgedit.c b/source/blender/modifiers/intern/MOD_weightvgedit.c index 9dfc2f653cd..8039856172a 100644 --- a/source/blender/modifiers/intern/MOD_weightvgedit.c +++ b/source/blender/modifiers/intern/MOD_weightvgedit.c @@ -47,6 +47,8 @@ #include "UI_interface.h" #include "UI_resources.h" +#include "BLO_read_write.h" + #include "RNA_access.h" #include "DEG_depsgraph_build.h" @@ -399,6 +401,25 @@ static void panelRegister(ARegionType *region_type) region_type, "influence", "Influence", NULL, influence_panel_draw, panel_type); } +static void blendWrite(BlendWriter *writer, const ModifierData *md) +{ + const WeightVGEditModifierData *wmd = (const WeightVGEditModifierData *)md; + + if (wmd->cmap_curve) { + BKE_curvemapping_blend_write(writer, wmd->cmap_curve); + } +} + +static void blendRead(BlendDataReader *reader, ModifierData *md) +{ + WeightVGEditModifierData *wmd = (WeightVGEditModifierData *)md; + + BLO_read_data_address(reader, &wmd->cmap_curve); + if (wmd->cmap_curve) { + BKE_curvemapping_blend_read(reader, wmd->cmap_curve); + } +} + ModifierTypeInfo modifierType_WeightVGEdit = { /* name */ "VertexWeightEdit", /* structName */ "WeightVGEditModifierData", @@ -430,6 +451,6 @@ ModifierTypeInfo modifierType_WeightVGEdit = { /* foreachTexLink */ foreachTexLink, /* freeRuntimeData */ NULL, /* panelRegister */ panelRegister, - /* blendWrite */ NULL, - /* blendRead */ NULL, + /* blendWrite */ blendWrite, + /* blendRead */ blendRead, };