From d3de5d7ca5608c53418ce4284cefe7e7d66a6b33 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Tue, 16 Jun 2020 16:59:52 +0200 Subject: Refactor: Move curvemapping .blend read/write to blenkernel This is necessary so that it can be accessed from `blendWrite` and `blendRead` callbacks from modifiers. --- source/blender/blenloader/intern/readfile.c | 11 +---------- source/blender/blenloader/intern/writefile.c | 9 +++------ 2 files changed, 4 insertions(+), 16 deletions(-) (limited to 'source/blender/blenloader') diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index f3b92b1f6a4..2e7532c5b46 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -2887,16 +2887,7 @@ static void direct_link_id_common( /* cuma itself has been read! */ static void direct_link_curvemapping(BlendDataReader *reader, CurveMapping *cumap) { - int a; - - /* flag seems to be able to hang? Maybe old files... not bad to clear anyway */ - cumap->flag &= ~CUMA_PREMULLED; - - for (a = 0; a < CM_TOT; a++) { - BLO_read_data_address(reader, &cumap->cm[a].curve); - cumap->cm[a].table = NULL; - cumap->cm[a].premultable = NULL; - } + BKE_curvemapping_blend_read(reader, cumap); } /** \} */ diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 2cc6cecd815..909a12a48aa 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -155,6 +155,7 @@ #include "BKE_blender_version.h" #include "BKE_bpath.h" #include "BKE_collection.h" +#include "BKE_colortools.h" #include "BKE_constraint.h" #include "BKE_curve.h" #include "BKE_fcurve.h" @@ -969,16 +970,12 @@ static void write_animdata(BlendWriter *writer, AnimData *adt) static void write_curvemapping_curves(BlendWriter *writer, CurveMapping *cumap) { - for (int a = 0; a < CM_TOT; a++) { - BLO_write_struct_array(writer, CurveMapPoint, cumap->cm[a].totpoint, cumap->cm[a].curve); - } + BKE_curvemapping_curves_blend_write(writer, cumap); } static void write_curvemapping(BlendWriter *writer, CurveMapping *cumap) { - BLO_write_struct(writer, CurveMapping, cumap); - - write_curvemapping_curves(writer, cumap); + BKE_curvemapping_blend_write(writer, cumap); } static void write_CurveProfile(BlendWriter *writer, CurveProfile *profile) -- cgit v1.2.3 From 25a1ed993a794d67ee1624cdcfba0f1dc5ffb200 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Tue, 16 Jun 2020 17:04:03 +0200 Subject: Cleanup: remove unnecessary indirection for .blend read/write of curvemapping --- source/blender/blenloader/intern/readfile.c | 108 +++++++++++-------------- source/blender/blenloader/intern/writefile.c | 115 +++++++++++++-------------- 2 files changed, 103 insertions(+), 120 deletions(-) (limited to 'source/blender/blenloader') diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 2e7532c5b46..e72cad47c0a 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -2880,18 +2880,6 @@ static void direct_link_id_common( /** \} */ -/* -------------------------------------------------------------------- */ -/** \name Read CurveMapping - * \{ */ - -/* cuma itself has been read! */ -static void direct_link_curvemapping(BlendDataReader *reader, CurveMapping *cumap) -{ - BKE_curvemapping_blend_read(reader, cumap); -} - -/** \} */ - /* -------------------------------------------------------------------- */ /** \name Read CurveProfile * \{ */ @@ -2945,7 +2933,7 @@ static void direct_link_brush(BlendDataReader *reader, Brush *brush) BLO_read_data_address(reader, &brush->gradient); if (brush->curve) { - direct_link_curvemapping(reader, brush->curve); + BKE_curvemapping_blend_read(reader, brush->curve); } else { BKE_brush_curve_preset(brush, CURVE_PRESET_SHARP); @@ -2966,39 +2954,39 @@ static void direct_link_brush(BlendDataReader *reader, Brush *brush) BLO_read_data_address(reader, &brush->gpencil_settings->curve_rand_value); if (brush->gpencil_settings->curve_sensitivity) { - direct_link_curvemapping(reader, brush->gpencil_settings->curve_sensitivity); + BKE_curvemapping_blend_read(reader, brush->gpencil_settings->curve_sensitivity); } if (brush->gpencil_settings->curve_strength) { - direct_link_curvemapping(reader, brush->gpencil_settings->curve_strength); + BKE_curvemapping_blend_read(reader, brush->gpencil_settings->curve_strength); } if (brush->gpencil_settings->curve_jitter) { - direct_link_curvemapping(reader, brush->gpencil_settings->curve_jitter); + BKE_curvemapping_blend_read(reader, brush->gpencil_settings->curve_jitter); } if (brush->gpencil_settings->curve_rand_pressure) { - direct_link_curvemapping(reader, brush->gpencil_settings->curve_rand_pressure); + BKE_curvemapping_blend_read(reader, brush->gpencil_settings->curve_rand_pressure); } if (brush->gpencil_settings->curve_rand_strength) { - direct_link_curvemapping(reader, brush->gpencil_settings->curve_rand_strength); + BKE_curvemapping_blend_read(reader, brush->gpencil_settings->curve_rand_strength); } if (brush->gpencil_settings->curve_rand_uv) { - direct_link_curvemapping(reader, brush->gpencil_settings->curve_rand_uv); + BKE_curvemapping_blend_read(reader, brush->gpencil_settings->curve_rand_uv); } if (brush->gpencil_settings->curve_rand_hue) { - direct_link_curvemapping(reader, brush->gpencil_settings->curve_rand_hue); + BKE_curvemapping_blend_read(reader, brush->gpencil_settings->curve_rand_hue); } if (brush->gpencil_settings->curve_rand_saturation) { - direct_link_curvemapping(reader, brush->gpencil_settings->curve_rand_saturation); + BKE_curvemapping_blend_read(reader, brush->gpencil_settings->curve_rand_saturation); } if (brush->gpencil_settings->curve_rand_value) { - direct_link_curvemapping(reader, brush->gpencil_settings->curve_rand_value); + BKE_curvemapping_blend_read(reader, brush->gpencil_settings->curve_rand_value); } } @@ -3711,7 +3699,7 @@ static void direct_link_nodetree(BlendDataReader *reader, bNodeTree *ntree) case CMP_NODE_HUECORRECT: case TEX_NODE_CURVE_RGB: case TEX_NODE_CURVE_TIME: { - direct_link_curvemapping(reader, node->storage); + BKE_curvemapping_blend_read(reader, node->storage); break; } case SH_NODE_SCRIPT: { @@ -4091,7 +4079,7 @@ static void direct_link_light(BlendDataReader *reader, Light *la) BLO_read_data_address(reader, &la->curfalloff); if (la->curfalloff) { - direct_link_curvemapping(reader, la->curfalloff); + BKE_curvemapping_blend_read(reader, la->curfalloff); } la->preview = direct_link_preview_image(reader, la->preview); @@ -4703,15 +4691,15 @@ static void direct_link_particlesettings(BlendDataReader *reader, ParticleSettin BLO_read_data_address(reader, &part->clumpcurve); if (part->clumpcurve) { - direct_link_curvemapping(reader, part->clumpcurve); + BKE_curvemapping_blend_read(reader, part->clumpcurve); } BLO_read_data_address(reader, &part->roughcurve); if (part->roughcurve) { - direct_link_curvemapping(reader, part->roughcurve); + BKE_curvemapping_blend_read(reader, part->roughcurve); } BLO_read_data_address(reader, &part->twistcurve); if (part->twistcurve) { - direct_link_curvemapping(reader, part->twistcurve); + BKE_curvemapping_blend_read(reader, part->twistcurve); } BLO_read_data_address(reader, &part->effector_weights); @@ -5771,7 +5759,7 @@ static void direct_link_modifiers(BlendDataReader *reader, ListBase *lb, Object BLO_read_data_address(reader, &hmd->curfalloff); if (hmd->curfalloff) { - direct_link_curvemapping(reader, hmd->curfalloff); + BKE_curvemapping_blend_read(reader, hmd->curfalloff); } } else if (md->type == eModifierType_ParticleSystem) { @@ -5811,7 +5799,7 @@ static void direct_link_modifiers(BlendDataReader *reader, ListBase *lb, Object BLO_read_data_address(reader, &tmd->curfalloff); if (tmd->curfalloff) { - direct_link_curvemapping(reader, tmd->curfalloff); + BKE_curvemapping_blend_read(reader, tmd->curfalloff); } } else if (md->type == eModifierType_WeightVGEdit) { @@ -5819,7 +5807,7 @@ static void direct_link_modifiers(BlendDataReader *reader, ListBase *lb, Object BLO_read_data_address(reader, &wmd->cmap_curve); if (wmd->cmap_curve) { - direct_link_curvemapping(reader, wmd->cmap_curve); + BKE_curvemapping_blend_read(reader, wmd->cmap_curve); } } else if (md->type == eModifierType_CorrectiveSmooth) { @@ -5902,7 +5890,7 @@ static void direct_link_gpencil_modifiers(BlendDataReader *reader, ListBase *lb) BLO_read_data_address(reader, &hmd->curfalloff); if (hmd->curfalloff) { - direct_link_curvemapping(reader, hmd->curfalloff); + BKE_curvemapping_blend_read(reader, hmd->curfalloff); } } else if (md->type == eGpencilModifierType_Noise) { @@ -5910,7 +5898,7 @@ static void direct_link_gpencil_modifiers(BlendDataReader *reader, ListBase *lb) BLO_read_data_address(reader, &gpmd->curve_intensity); if (gpmd->curve_intensity) { - direct_link_curvemapping(reader, gpmd->curve_intensity); + BKE_curvemapping_blend_read(reader, gpmd->curve_intensity); /* initialize the curve. Maybe this could be moved to modififer logic */ BKE_curvemapping_initialize(gpmd->curve_intensity); } @@ -5920,7 +5908,7 @@ static void direct_link_gpencil_modifiers(BlendDataReader *reader, ListBase *lb) BLO_read_data_address(reader, &gpmd->curve_thickness); if (gpmd->curve_thickness) { - direct_link_curvemapping(reader, gpmd->curve_thickness); + BKE_curvemapping_blend_read(reader, gpmd->curve_thickness); BKE_curvemapping_initialize(gpmd->curve_thickness); } } @@ -5929,7 +5917,7 @@ static void direct_link_gpencil_modifiers(BlendDataReader *reader, ListBase *lb) BLO_read_data_address(reader, &gpmd->colorband); BLO_read_data_address(reader, &gpmd->curve_intensity); if (gpmd->curve_intensity) { - direct_link_curvemapping(reader, gpmd->curve_intensity); + BKE_curvemapping_blend_read(reader, gpmd->curve_intensity); BKE_curvemapping_initialize(gpmd->curve_intensity); } } @@ -5937,7 +5925,7 @@ static void direct_link_gpencil_modifiers(BlendDataReader *reader, ListBase *lb) SmoothGpencilModifierData *gpmd = (SmoothGpencilModifierData *)md; BLO_read_data_address(reader, &gpmd->curve_intensity); if (gpmd->curve_intensity) { - direct_link_curvemapping(reader, gpmd->curve_intensity); + BKE_curvemapping_blend_read(reader, gpmd->curve_intensity); BKE_curvemapping_initialize(gpmd->curve_intensity); } } @@ -5945,7 +5933,7 @@ static void direct_link_gpencil_modifiers(BlendDataReader *reader, ListBase *lb) ColorGpencilModifierData *gpmd = (ColorGpencilModifierData *)md; BLO_read_data_address(reader, &gpmd->curve_intensity); if (gpmd->curve_intensity) { - direct_link_curvemapping(reader, gpmd->curve_intensity); + BKE_curvemapping_blend_read(reader, gpmd->curve_intensity); BKE_curvemapping_initialize(gpmd->curve_intensity); } } @@ -5953,7 +5941,7 @@ static void direct_link_gpencil_modifiers(BlendDataReader *reader, ListBase *lb) OpacityGpencilModifierData *gpmd = (OpacityGpencilModifierData *)md; BLO_read_data_address(reader, &gpmd->curve_intensity); if (gpmd->curve_intensity) { - direct_link_curvemapping(reader, gpmd->curve_intensity); + BKE_curvemapping_blend_read(reader, gpmd->curve_intensity); BKE_curvemapping_initialize(gpmd->curve_intensity); } } @@ -6187,7 +6175,7 @@ static void direct_link_view_settings(BlendDataReader *reader, BLO_read_data_address(reader, &view_settings->curve_mapping); if (view_settings->curve_mapping) { - direct_link_curvemapping(reader, view_settings->curve_mapping); + BKE_curvemapping_blend_read(reader, view_settings->curve_mapping); } } @@ -6716,7 +6704,7 @@ static void direct_link_paint(BlendDataReader *reader, const Scene *scene, Paint BLO_read_data_address(reader, &p->cavity_curve); if (p->cavity_curve) { - direct_link_curvemapping(reader, p->cavity_curve); + BKE_curvemapping_blend_read(reader, p->cavity_curve); } else { BKE_paint_cavity_curve_preset(p, CURVE_PRESET_LINE); @@ -6758,12 +6746,12 @@ static void direct_link_sequence_modifiers(BlendDataReader *reader, ListBase *lb if (smd->type == seqModifierType_Curves) { CurvesModifierData *cmd = (CurvesModifierData *)smd; - direct_link_curvemapping(reader, &cmd->curve_mapping); + BKE_curvemapping_blend_read(reader, &cmd->curve_mapping); } else if (smd->type == seqModifierType_HueCorrect) { HueCorrectModifierData *hcmd = (HueCorrectModifierData *)smd; - direct_link_curvemapping(reader, &hcmd->curve_mapping); + BKE_curvemapping_blend_read(reader, &hcmd->curve_mapping); } } } @@ -6826,17 +6814,17 @@ static void direct_link_scene(BlendDataReader *reader, Scene *sce) /* relink grease pencil interpolation curves */ BLO_read_data_address(reader, &sce->toolsettings->gp_interpolate.custom_ipo); if (sce->toolsettings->gp_interpolate.custom_ipo) { - direct_link_curvemapping(reader, sce->toolsettings->gp_interpolate.custom_ipo); + BKE_curvemapping_blend_read(reader, sce->toolsettings->gp_interpolate.custom_ipo); } /* relink grease pencil multiframe falloff curve */ BLO_read_data_address(reader, &sce->toolsettings->gp_sculpt.cur_falloff); if (sce->toolsettings->gp_sculpt.cur_falloff) { - direct_link_curvemapping(reader, sce->toolsettings->gp_sculpt.cur_falloff); + BKE_curvemapping_blend_read(reader, sce->toolsettings->gp_sculpt.cur_falloff); } /* relink grease pencil primitive curve */ BLO_read_data_address(reader, &sce->toolsettings->gp_sculpt.cur_primitive); if (sce->toolsettings->gp_sculpt.cur_primitive) { - direct_link_curvemapping(reader, sce->toolsettings->gp_sculpt.cur_primitive); + BKE_curvemapping_blend_read(reader, sce->toolsettings->gp_sculpt.cur_primitive); } /* Relink toolsettings curve profile */ @@ -7041,7 +7029,7 @@ static void direct_link_scene(BlendDataReader *reader, Scene *sce) sce->preview = direct_link_preview_image(reader, sce->preview); - direct_link_curvemapping(reader, &sce->r.mblur_shutter_curve); + BKE_curvemapping_blend_read(reader, &sce->r.mblur_shutter_curve); #ifdef USE_COLLECTION_COMPAT_28 /* this runs before the very first doversion */ @@ -8861,51 +8849,51 @@ static void direct_link_linestyle_alpha_modifier(BlendDataReader *reader, case LS_MODIFIER_ALONG_STROKE: { LineStyleAlphaModifier_AlongStroke *m = (LineStyleAlphaModifier_AlongStroke *)modifier; BLO_read_data_address(reader, &m->curve); - direct_link_curvemapping(reader, m->curve); + BKE_curvemapping_blend_read(reader, m->curve); break; } case LS_MODIFIER_DISTANCE_FROM_CAMERA: { LineStyleAlphaModifier_DistanceFromCamera *m = (LineStyleAlphaModifier_DistanceFromCamera *) modifier; BLO_read_data_address(reader, &m->curve); - direct_link_curvemapping(reader, m->curve); + BKE_curvemapping_blend_read(reader, m->curve); break; } case LS_MODIFIER_DISTANCE_FROM_OBJECT: { LineStyleAlphaModifier_DistanceFromObject *m = (LineStyleAlphaModifier_DistanceFromObject *) modifier; BLO_read_data_address(reader, &m->curve); - direct_link_curvemapping(reader, m->curve); + BKE_curvemapping_blend_read(reader, m->curve); break; } case LS_MODIFIER_MATERIAL: { LineStyleAlphaModifier_Material *m = (LineStyleAlphaModifier_Material *)modifier; BLO_read_data_address(reader, &m->curve); - direct_link_curvemapping(reader, m->curve); + BKE_curvemapping_blend_read(reader, m->curve); break; } case LS_MODIFIER_TANGENT: { LineStyleAlphaModifier_Tangent *m = (LineStyleAlphaModifier_Tangent *)modifier; BLO_read_data_address(reader, &m->curve); - direct_link_curvemapping(reader, m->curve); + BKE_curvemapping_blend_read(reader, m->curve); break; } case LS_MODIFIER_NOISE: { LineStyleAlphaModifier_Noise *m = (LineStyleAlphaModifier_Noise *)modifier; BLO_read_data_address(reader, &m->curve); - direct_link_curvemapping(reader, m->curve); + BKE_curvemapping_blend_read(reader, m->curve); break; } case LS_MODIFIER_CREASE_ANGLE: { LineStyleAlphaModifier_CreaseAngle *m = (LineStyleAlphaModifier_CreaseAngle *)modifier; BLO_read_data_address(reader, &m->curve); - direct_link_curvemapping(reader, m->curve); + BKE_curvemapping_blend_read(reader, m->curve); break; } case LS_MODIFIER_CURVATURE_3D: { LineStyleAlphaModifier_Curvature_3D *m = (LineStyleAlphaModifier_Curvature_3D *)modifier; BLO_read_data_address(reader, &m->curve); - direct_link_curvemapping(reader, m->curve); + BKE_curvemapping_blend_read(reader, m->curve); break; } } @@ -8919,47 +8907,47 @@ static void direct_link_linestyle_thickness_modifier(BlendDataReader *reader, LineStyleThicknessModifier_AlongStroke *m = (LineStyleThicknessModifier_AlongStroke *) modifier; BLO_read_data_address(reader, &m->curve); - direct_link_curvemapping(reader, m->curve); + BKE_curvemapping_blend_read(reader, m->curve); break; } case LS_MODIFIER_DISTANCE_FROM_CAMERA: { LineStyleThicknessModifier_DistanceFromCamera *m = (LineStyleThicknessModifier_DistanceFromCamera *)modifier; BLO_read_data_address(reader, &m->curve); - direct_link_curvemapping(reader, m->curve); + BKE_curvemapping_blend_read(reader, m->curve); break; } case LS_MODIFIER_DISTANCE_FROM_OBJECT: { LineStyleThicknessModifier_DistanceFromObject *m = (LineStyleThicknessModifier_DistanceFromObject *)modifier; BLO_read_data_address(reader, &m->curve); - direct_link_curvemapping(reader, m->curve); + BKE_curvemapping_blend_read(reader, m->curve); break; } case LS_MODIFIER_MATERIAL: { LineStyleThicknessModifier_Material *m = (LineStyleThicknessModifier_Material *)modifier; BLO_read_data_address(reader, &m->curve); - direct_link_curvemapping(reader, m->curve); + BKE_curvemapping_blend_read(reader, m->curve); break; } case LS_MODIFIER_TANGENT: { LineStyleThicknessModifier_Tangent *m = (LineStyleThicknessModifier_Tangent *)modifier; BLO_read_data_address(reader, &m->curve); - direct_link_curvemapping(reader, m->curve); + BKE_curvemapping_blend_read(reader, m->curve); break; } case LS_MODIFIER_CREASE_ANGLE: { LineStyleThicknessModifier_CreaseAngle *m = (LineStyleThicknessModifier_CreaseAngle *) modifier; BLO_read_data_address(reader, &m->curve); - direct_link_curvemapping(reader, m->curve); + BKE_curvemapping_blend_read(reader, m->curve); break; } case LS_MODIFIER_CURVATURE_3D: { LineStyleThicknessModifier_Curvature_3D *m = (LineStyleThicknessModifier_Curvature_3D *) modifier; BLO_read_data_address(reader, &m->curve); - direct_link_curvemapping(reader, m->curve); + BKE_curvemapping_blend_read(reader, m->curve); break; } } diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 909a12a48aa..fbd11ef5323 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -968,16 +968,6 @@ static void write_animdata(BlendWriter *writer, AnimData *adt) write_nladata(writer, &adt->nla_tracks); } -static void write_curvemapping_curves(BlendWriter *writer, CurveMapping *cumap) -{ - BKE_curvemapping_curves_blend_write(writer, cumap); -} - -static void write_curvemapping(BlendWriter *writer, CurveMapping *cumap) -{ - BKE_curvemapping_blend_write(writer, cumap); -} - static void write_CurveProfile(BlendWriter *writer, CurveProfile *profile) { BLO_write_struct(writer, CurveProfile, profile); @@ -1084,7 +1074,7 @@ static void write_nodetree_nolib(BlendWriter *writer, bNodeTree *ntree) /* could be handlerized at some point, now only 1 exception still */ if ((ntree->type == NTREE_SHADER) && ELEM(node->type, SH_NODE_CURVE_VEC, SH_NODE_CURVE_RGB)) { - write_curvemapping(writer, node->storage); + BKE_curvemapping_blend_write(writer, node->storage); } else if (ntree->type == NTREE_SHADER && (node->type == SH_NODE_SCRIPT)) { NodeShaderScript *nss = (NodeShaderScript *)node->storage; @@ -1098,11 +1088,11 @@ static void write_nodetree_nolib(BlendWriter *writer, bNodeTree *ntree) CMP_NODE_CURVE_VEC, CMP_NODE_CURVE_RGB, CMP_NODE_HUECORRECT)) { - write_curvemapping(writer, node->storage); + BKE_curvemapping_blend_write(writer, node->storage); } else if ((ntree->type == NTREE_TEXTURE) && (node->type == TEX_NODE_CURVE_RGB || node->type == TEX_NODE_CURVE_TIME)) { - write_curvemapping(writer, node->storage); + BKE_curvemapping_blend_write(writer, node->storage); } else if ((ntree->type == NTREE_COMPOSIT) && (node->type == CMP_NODE_MOVIEDISTORTION)) { /* pass */ @@ -1433,13 +1423,13 @@ static void write_particlesettings(BlendWriter *writer, BLO_write_struct(writer, EffectorWeights, part->effector_weights); if (part->clumpcurve) { - write_curvemapping(writer, part->clumpcurve); + BKE_curvemapping_blend_write(writer, part->clumpcurve); } if (part->roughcurve) { - write_curvemapping(writer, part->roughcurve); + BKE_curvemapping_blend_write(writer, part->roughcurve); } if (part->twistcurve) { - write_curvemapping(writer, part->twistcurve); + BKE_curvemapping_blend_write(writer, part->twistcurve); } LISTBASE_FOREACH (ParticleDupliWeight *, dw, &part->instance_weights) { @@ -1680,7 +1670,7 @@ static void write_modifiers(BlendWriter *writer, ListBase *modbase) HookModifierData *hmd = (HookModifierData *)md; if (hmd->curfalloff) { - write_curvemapping(writer, hmd->curfalloff); + BKE_curvemapping_blend_write(writer, hmd->curfalloff); } BLO_write_int32_array(writer, hmd->totindex, hmd->indexar); @@ -1781,14 +1771,14 @@ static void write_modifiers(BlendWriter *writer, ListBase *modbase) else if (md->type == eModifierType_Warp) { WarpModifierData *tmd = (WarpModifierData *)md; if (tmd->curfalloff) { - write_curvemapping(writer, tmd->curfalloff); + BKE_curvemapping_blend_write(writer, tmd->curfalloff); } } else if (md->type == eModifierType_WeightVGEdit) { WeightVGEditModifierData *wmd = (WeightVGEditModifierData *)md; if (wmd->cmap_curve) { - write_curvemapping(writer, wmd->cmap_curve); + BKE_curvemapping_blend_write(writer, wmd->cmap_curve); } } else if (md->type == eModifierType_CorrectiveSmooth) { @@ -1858,21 +1848,21 @@ static void write_gpencil_modifiers(BlendWriter *writer, ListBase *modbase) ThickGpencilModifierData *gpmd = (ThickGpencilModifierData *)md; if (gpmd->curve_thickness) { - write_curvemapping(writer, gpmd->curve_thickness); + BKE_curvemapping_blend_write(writer, gpmd->curve_thickness); } } else if (md->type == eGpencilModifierType_Noise) { NoiseGpencilModifierData *gpmd = (NoiseGpencilModifierData *)md; if (gpmd->curve_intensity) { - write_curvemapping(writer, gpmd->curve_intensity); + BKE_curvemapping_blend_write(writer, gpmd->curve_intensity); } } else if (md->type == eGpencilModifierType_Hook) { HookGpencilModifierData *gpmd = (HookGpencilModifierData *)md; if (gpmd->curfalloff) { - write_curvemapping(writer, gpmd->curfalloff); + BKE_curvemapping_blend_write(writer, gpmd->curfalloff); } } else if (md->type == eGpencilModifierType_Tint) { @@ -1881,25 +1871,25 @@ static void write_gpencil_modifiers(BlendWriter *writer, ListBase *modbase) BLO_write_struct(writer, ColorBand, gpmd->colorband); } if (gpmd->curve_intensity) { - write_curvemapping(writer, gpmd->curve_intensity); + BKE_curvemapping_blend_write(writer, gpmd->curve_intensity); } } else if (md->type == eGpencilModifierType_Smooth) { SmoothGpencilModifierData *gpmd = (SmoothGpencilModifierData *)md; if (gpmd->curve_intensity) { - write_curvemapping(writer, gpmd->curve_intensity); + BKE_curvemapping_blend_write(writer, gpmd->curve_intensity); } } else if (md->type == eGpencilModifierType_Color) { ColorGpencilModifierData *gpmd = (ColorGpencilModifierData *)md; if (gpmd->curve_intensity) { - write_curvemapping(writer, gpmd->curve_intensity); + BKE_curvemapping_blend_write(writer, gpmd->curve_intensity); } } else if (md->type == eGpencilModifierType_Opacity) { OpacityGpencilModifierData *gpmd = (OpacityGpencilModifierData *)md; if (gpmd->curve_intensity) { - write_curvemapping(writer, gpmd->curve_intensity); + BKE_curvemapping_blend_write(writer, gpmd->curve_intensity); } } } @@ -2454,7 +2444,7 @@ static void write_light(BlendWriter *writer, Light *la, const void *id_address) } if (la->curfalloff) { - write_curvemapping(writer, la->curfalloff); + BKE_curvemapping_blend_write(writer, la->curfalloff); } /* Node-tree is integral part of lights, no libdata. */ @@ -2511,12 +2501,12 @@ static void write_sequence_modifiers(BlendWriter *writer, ListBase *modbase) if (smd->type == seqModifierType_Curves) { CurvesModifierData *cmd = (CurvesModifierData *)smd; - write_curvemapping(writer, &cmd->curve_mapping); + BKE_curvemapping_blend_write(writer, &cmd->curve_mapping); } else if (smd->type == seqModifierType_HueCorrect) { HueCorrectModifierData *hcmd = (HueCorrectModifierData *)smd; - write_curvemapping(writer, &hcmd->curve_mapping); + BKE_curvemapping_blend_write(writer, &hcmd->curve_mapping); } } else { @@ -2528,7 +2518,7 @@ static void write_sequence_modifiers(BlendWriter *writer, ListBase *modbase) static void write_view_settings(BlendWriter *writer, ColorManagedViewSettings *view_settings) { if (view_settings->curve_mapping) { - write_curvemapping(writer, view_settings->curve_mapping); + BKE_curvemapping_blend_write(writer, view_settings->curve_mapping); } } @@ -2542,7 +2532,7 @@ static void write_view3dshading(BlendWriter *writer, View3DShading *shading) static void write_paint(BlendWriter *writer, Paint *p) { if (p->cavity_curve) { - write_curvemapping(writer, p->cavity_curve); + BKE_curvemapping_blend_write(writer, p->cavity_curve); } BLO_write_struct_array(writer, PaintToolSlot, p->tool_slots_len, p->tool_slots); } @@ -2659,15 +2649,15 @@ static void write_scene(BlendWriter *writer, Scene *sce, const void *id_address) } /* write grease-pencil custom ipo curve to file */ if (tos->gp_interpolate.custom_ipo) { - write_curvemapping(writer, tos->gp_interpolate.custom_ipo); + BKE_curvemapping_blend_write(writer, tos->gp_interpolate.custom_ipo); } /* write grease-pencil multiframe falloff curve to file */ if (tos->gp_sculpt.cur_falloff) { - write_curvemapping(writer, tos->gp_sculpt.cur_falloff); + BKE_curvemapping_blend_write(writer, tos->gp_sculpt.cur_falloff); } /* write grease-pencil primitive curve to file */ if (tos->gp_sculpt.cur_primitive) { - write_curvemapping(writer, tos->gp_sculpt.cur_primitive); + BKE_curvemapping_blend_write(writer, tos->gp_sculpt.cur_primitive); } /* Write the curve profile to the file. */ if (tos->custom_bevel_profile_preset) { @@ -2813,7 +2803,7 @@ static void write_scene(BlendWriter *writer, Scene *sce, const void *id_address) } write_previews(writer, sce->preview); - write_curvemapping_curves(writer, &sce->r.mblur_shutter_curve); + BKE_curvemapping_curves_blend_write(writer, &sce->r.mblur_shutter_curve); LISTBASE_FOREACH (ViewLayer *, view_layer, &sce->view_layers) { write_view_layer(writer, view_layer); @@ -3317,38 +3307,38 @@ static void write_brush(BlendWriter *writer, Brush *brush, const void *id_addres write_iddata(writer, &brush->id); if (brush->curve) { - write_curvemapping(writer, brush->curve); + BKE_curvemapping_blend_write(writer, brush->curve); } if (brush->gpencil_settings) { BLO_write_struct(writer, BrushGpencilSettings, brush->gpencil_settings); if (brush->gpencil_settings->curve_sensitivity) { - write_curvemapping(writer, brush->gpencil_settings->curve_sensitivity); + BKE_curvemapping_blend_write(writer, brush->gpencil_settings->curve_sensitivity); } if (brush->gpencil_settings->curve_strength) { - write_curvemapping(writer, brush->gpencil_settings->curve_strength); + BKE_curvemapping_blend_write(writer, brush->gpencil_settings->curve_strength); } if (brush->gpencil_settings->curve_jitter) { - write_curvemapping(writer, brush->gpencil_settings->curve_jitter); + BKE_curvemapping_blend_write(writer, brush->gpencil_settings->curve_jitter); } if (brush->gpencil_settings->curve_rand_pressure) { - write_curvemapping(writer, brush->gpencil_settings->curve_rand_pressure); + BKE_curvemapping_blend_write(writer, brush->gpencil_settings->curve_rand_pressure); } if (brush->gpencil_settings->curve_rand_strength) { - write_curvemapping(writer, brush->gpencil_settings->curve_rand_strength); + BKE_curvemapping_blend_write(writer, brush->gpencil_settings->curve_rand_strength); } if (brush->gpencil_settings->curve_rand_uv) { - write_curvemapping(writer, brush->gpencil_settings->curve_rand_uv); + BKE_curvemapping_blend_write(writer, brush->gpencil_settings->curve_rand_uv); } if (brush->gpencil_settings->curve_rand_hue) { - write_curvemapping(writer, brush->gpencil_settings->curve_rand_hue); + BKE_curvemapping_blend_write(writer, brush->gpencil_settings->curve_rand_hue); } if (brush->gpencil_settings->curve_rand_saturation) { - write_curvemapping(writer, brush->gpencil_settings->curve_rand_saturation); + BKE_curvemapping_blend_write(writer, brush->gpencil_settings->curve_rand_saturation); } if (brush->gpencil_settings->curve_rand_value) { - write_curvemapping(writer, brush->gpencil_settings->curve_rand_value); + BKE_curvemapping_blend_write(writer, brush->gpencil_settings->curve_rand_value); } } if (brush->gradient) { @@ -3609,28 +3599,30 @@ static void write_linestyle_alpha_modifiers(BlendWriter *writer, ListBase *modif for (m = modifiers->first; m; m = m->next) { switch (m->type) { case LS_MODIFIER_ALONG_STROKE: - write_curvemapping(writer, ((LineStyleAlphaModifier_AlongStroke *)m)->curve); + BKE_curvemapping_blend_write(writer, ((LineStyleAlphaModifier_AlongStroke *)m)->curve); break; case LS_MODIFIER_DISTANCE_FROM_CAMERA: - write_curvemapping(writer, ((LineStyleAlphaModifier_DistanceFromCamera *)m)->curve); + BKE_curvemapping_blend_write(writer, + ((LineStyleAlphaModifier_DistanceFromCamera *)m)->curve); break; case LS_MODIFIER_DISTANCE_FROM_OBJECT: - write_curvemapping(writer, ((LineStyleAlphaModifier_DistanceFromObject *)m)->curve); + BKE_curvemapping_blend_write(writer, + ((LineStyleAlphaModifier_DistanceFromObject *)m)->curve); break; case LS_MODIFIER_MATERIAL: - write_curvemapping(writer, ((LineStyleAlphaModifier_Material *)m)->curve); + BKE_curvemapping_blend_write(writer, ((LineStyleAlphaModifier_Material *)m)->curve); break; case LS_MODIFIER_TANGENT: - write_curvemapping(writer, ((LineStyleAlphaModifier_Tangent *)m)->curve); + BKE_curvemapping_blend_write(writer, ((LineStyleAlphaModifier_Tangent *)m)->curve); break; case LS_MODIFIER_NOISE: - write_curvemapping(writer, ((LineStyleAlphaModifier_Noise *)m)->curve); + BKE_curvemapping_blend_write(writer, ((LineStyleAlphaModifier_Noise *)m)->curve); break; case LS_MODIFIER_CREASE_ANGLE: - write_curvemapping(writer, ((LineStyleAlphaModifier_CreaseAngle *)m)->curve); + BKE_curvemapping_blend_write(writer, ((LineStyleAlphaModifier_CreaseAngle *)m)->curve); break; case LS_MODIFIER_CURVATURE_3D: - write_curvemapping(writer, ((LineStyleAlphaModifier_Curvature_3D *)m)->curve); + BKE_curvemapping_blend_write(writer, ((LineStyleAlphaModifier_Curvature_3D *)m)->curve); break; } } @@ -3678,25 +3670,28 @@ static void write_linestyle_thickness_modifiers(BlendWriter *writer, ListBase *m for (m = modifiers->first; m; m = m->next) { switch (m->type) { case LS_MODIFIER_ALONG_STROKE: - write_curvemapping(writer, ((LineStyleThicknessModifier_AlongStroke *)m)->curve); + BKE_curvemapping_blend_write(writer, ((LineStyleThicknessModifier_AlongStroke *)m)->curve); break; case LS_MODIFIER_DISTANCE_FROM_CAMERA: - write_curvemapping(writer, ((LineStyleThicknessModifier_DistanceFromCamera *)m)->curve); + BKE_curvemapping_blend_write(writer, + ((LineStyleThicknessModifier_DistanceFromCamera *)m)->curve); break; case LS_MODIFIER_DISTANCE_FROM_OBJECT: - write_curvemapping(writer, ((LineStyleThicknessModifier_DistanceFromObject *)m)->curve); + BKE_curvemapping_blend_write(writer, + ((LineStyleThicknessModifier_DistanceFromObject *)m)->curve); break; case LS_MODIFIER_MATERIAL: - write_curvemapping(writer, ((LineStyleThicknessModifier_Material *)m)->curve); + BKE_curvemapping_blend_write(writer, ((LineStyleThicknessModifier_Material *)m)->curve); break; case LS_MODIFIER_TANGENT: - write_curvemapping(writer, ((LineStyleThicknessModifier_Tangent *)m)->curve); + BKE_curvemapping_blend_write(writer, ((LineStyleThicknessModifier_Tangent *)m)->curve); break; case LS_MODIFIER_CREASE_ANGLE: - write_curvemapping(writer, ((LineStyleThicknessModifier_CreaseAngle *)m)->curve); + BKE_curvemapping_blend_write(writer, ((LineStyleThicknessModifier_CreaseAngle *)m)->curve); break; case LS_MODIFIER_CURVATURE_3D: - write_curvemapping(writer, ((LineStyleThicknessModifier_Curvature_3D *)m)->curve); + BKE_curvemapping_blend_write(writer, + ((LineStyleThicknessModifier_Curvature_3D *)m)->curve); break; } } -- cgit v1.2.3 From 2e5ef864ab17fbfdb50531a77ee8e1637b8efef6 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Tue, 16 Jun 2020 17:17:43 +0200 Subject: Refactor: move .blend read/write of mesh deform modifier to MOD_meshdeform.c --- source/blender/blenloader/intern/readfile.c | 13 ------------- source/blender/blenloader/intern/writefile.c | 11 ----------- 2 files changed, 24 deletions(-) (limited to 'source/blender/blenloader') diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index e72cad47c0a..5b5cf8e6232 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -5776,19 +5776,6 @@ static void direct_link_modifiers(BlendDataReader *reader, ListBase *lb, Object psmd->facepa = NULL; } - else if (md->type == eModifierType_MeshDeform) { - MeshDeformModifierData *mmd = (MeshDeformModifierData *)md; - - BLO_read_data_address(reader, &mmd->bindinfluences); - BLO_read_int32_array(reader, mmd->totvert + 1, &mmd->bindoffsets); - BLO_read_float3_array(reader, mmd->totcagevert, &mmd->bindcagecos); - BLO_read_data_address(reader, &mmd->dyngrid); - BLO_read_data_address(reader, &mmd->dyninfluences); - BLO_read_int32_array(reader, mmd->totvert, &mmd->dynverts); - - BLO_read_float_array(reader, mmd->totvert, &mmd->bindweights); - BLO_read_float3_array(reader, mmd->totcagevert, &mmd->bindcos); - } else if (md->type == eModifierType_Ocean) { OceanModifierData *omd = (OceanModifierData *)md; omd->oceancache = NULL; diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index fbd11ef5323..a40cc4c3ad2 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -1757,17 +1757,6 @@ static void write_modifiers(BlendWriter *writer, ListBase *modbase) writestruct(wd, DATA, MFace, collmd->numfaces, collmd->mfaces); #endif } - else if (md->type == eModifierType_MeshDeform) { - MeshDeformModifierData *mmd = (MeshDeformModifierData *)md; - int size = mmd->dyngridsize; - - BLO_write_struct_array(writer, MDefInfluence, mmd->totinfluence, mmd->bindinfluences); - BLO_write_int32_array(writer, mmd->totvert + 1, mmd->bindoffsets); - BLO_write_float3_array(writer, mmd->totcagevert, mmd->bindcagecos); - BLO_write_struct_array(writer, MDefCell, size * size * size, mmd->dyngrid); - BLO_write_struct_array(writer, MDefInfluence, mmd->totinfluence, mmd->dyninfluences); - BLO_write_int32_array(writer, mmd->totvert, mmd->dynverts); - } else if (md->type == eModifierType_Warp) { WarpModifierData *tmd = (WarpModifierData *)md; if (tmd->curfalloff) { -- cgit v1.2.3 From 3aa1143d57bc8e35622f02e9bc570135a472af77 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 18 Jun 2020 12:21:38 +1000 Subject: Cleanup: redundant parenthesis --- source/blender/blenloader/intern/versioning_250.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/blenloader') diff --git a/source/blender/blenloader/intern/versioning_250.c b/source/blender/blenloader/intern/versioning_250.c index eaeef0d52c1..2c3b047af46 100644 --- a/source/blender/blenloader/intern/versioning_250.c +++ b/source/blender/blenloader/intern/versioning_250.c @@ -308,7 +308,7 @@ static void area_add_window_regions(ScrArea *area, SpaceLink *sl, ListBase *lb) region->v2d.tot.ymax = 0.0f; region->v2d.scroll |= (V2D_SCROLL_BOTTOM | V2D_SCROLL_HORIZONTAL_HANDLES); - region->v2d.scroll |= (V2D_SCROLL_RIGHT); + region->v2d.scroll |= V2D_SCROLL_RIGHT; region->v2d.align = V2D_ALIGN_NO_POS_Y; region->v2d.flag |= V2D_VIEWSYNC_AREA_VERTICAL; break; @@ -334,7 +334,7 @@ static void area_add_window_regions(ScrArea *area, SpaceLink *sl, ListBase *lb) region->v2d.minzoom = 0.01f; region->v2d.maxzoom = 50; region->v2d.scroll = (V2D_SCROLL_BOTTOM | V2D_SCROLL_HORIZONTAL_HANDLES); - region->v2d.scroll |= (V2D_SCROLL_RIGHT); + region->v2d.scroll |= V2D_SCROLL_RIGHT; region->v2d.keepzoom = V2D_LOCKZOOM_Y; region->v2d.align = V2D_ALIGN_NO_POS_Y; region->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL; -- cgit v1.2.3 From 3ada1949f8633293b4a424bf20789d94cf924c43 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 18 Jun 2020 15:25:22 +1000 Subject: Python API: path mapping options for library writing function When "Relative Remap" option was added, the intention was only to remap paths that were already relative. However it remapped all paths. This was reported as T62612 and fixed recently, however some Python script authors depended on the old behavior. For users, it's reasonable to use the existing operators to make paths absolute/relative. For scripts however it's useful to be able to write out individual data-blocks with the ability to make all paths relative. Now `bpy.data.libraries.write()` takes a path_remap argument which can be `NONE/RELATIVE/RELATIVE_ALL/ABSOLUTE` allowing the script author to choose how paths are handled when writing out data-blocks. Addresses T77768. --- source/blender/blenloader/BLO_writefile.h | 27 ++++++++-- source/blender/blenloader/intern/writefile.c | 73 +++++++++++++++++++++------- 2 files changed, 80 insertions(+), 20 deletions(-) (limited to 'source/blender/blenloader') diff --git a/source/blender/blenloader/BLO_writefile.h b/source/blender/blenloader/BLO_writefile.h index d83abf7f9ed..18783474392 100644 --- a/source/blender/blenloader/BLO_writefile.h +++ b/source/blender/blenloader/BLO_writefile.h @@ -30,11 +30,32 @@ struct Main; struct MemFile; struct ReportList; +/** + * Adjust paths when saving (kept unless #G_FILE_SAVE_COPY is set). + */ +typedef enum eBLO_WritePathRemap { + /** No path manipulation. */ + BLO_WRITE_PATH_REMAP_NONE = 1, + /** Remap existing relative paths (default). */ + BLO_WRITE_PATH_REMAP_RELATIVE = 2, + /** Remap paths making all paths relative to the new location. */ + BLO_WRITE_PATH_REMAP_RELATIVE_ALL = 3, + /** Make all paths absolute. */ + BLO_WRITE_PATH_REMAP_ABSOLUTE = 4, +} eBLO_WritePathRemap; + +extern bool BLO_write_file_ex(struct Main *mainvar, + const char *filepath, + const int write_flags, + struct ReportList *reports, + /* Extra arguments. */ + eBLO_WritePathRemap remap_mode, + const struct BlendThumbnail *thumb); extern bool BLO_write_file(struct Main *mainvar, const char *filepath, - int write_flags, - struct ReportList *reports, - const struct BlendThumbnail *thumb); + const int write_flags, + struct ReportList *reports); + extern bool BLO_write_file_mem(struct Main *mainvar, struct MemFile *compare, struct MemFile *current, diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index a40cc4c3ad2..1cda22de941 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -4400,11 +4400,13 @@ static bool do_history(const char *name, ReportList *reports) /** * \return Success. */ -bool BLO_write_file(Main *mainvar, - const char *filepath, - int write_flags, - ReportList *reports, - const BlendThumbnail *thumb) +bool BLO_write_file_ex(Main *mainvar, + const char *filepath, + const int write_flags, + ReportList *reports, + /* Extra arguments. */ + eBLO_WritePathRemap remap_mode, + const BlendThumbnail *thumb) { char tempname[FILE_MAX + 1]; eWriteWrapType ww_type; @@ -4439,7 +4441,15 @@ bool BLO_write_file(Main *mainvar, } /* Remapping of relative paths to new file location. */ - if (write_flags & G_FILE_RELATIVE_REMAP) { + if (remap_mode != BLO_WRITE_PATH_REMAP_NONE) { + + if (remap_mode == BLO_WRITE_PATH_REMAP_RELATIVE) { + /* Make all relative as none of the existing paths can be relative in an unsaved document. */ + if (G.relbase_valid == false) { + remap_mode = BLO_WRITE_PATH_REMAP_RELATIVE_ALL; + } + } + char dir_src[FILE_MAX]; char dir_dst[FILE_MAX]; BLI_split_dir_part(mainvar->name, dir_src, sizeof(dir_src)); @@ -4449,23 +4459,43 @@ bool BLO_write_file(Main *mainvar, BLI_path_normalize(mainvar->name, dir_dst); BLI_path_normalize(mainvar->name, dir_src); - if (G.relbase_valid && (BLI_path_cmp(dir_dst, dir_src) == 0)) { - /* Saved to same path. Nothing to do. */ - write_flags &= ~G_FILE_RELATIVE_REMAP; + /* Only for relative, not relative-all, as this means making existing paths relative. */ + if (remap_mode == BLO_WRITE_PATH_REMAP_RELATIVE) { + if (G.relbase_valid && (BLI_path_cmp(dir_dst, dir_src) == 0)) { + /* Saved to same path. Nothing to do. */ + remap_mode = BLO_WRITE_PATH_REMAP_NONE; + } } - else { + else if (remap_mode == BLO_WRITE_PATH_REMAP_ABSOLUTE) { + if (G.relbase_valid == false) { + /* Unsaved, all paths are absolute.Even if the user manages to set a relative path, + * there is no base-path that can be used to make it absolute. */ + remap_mode = BLO_WRITE_PATH_REMAP_NONE; + } + } + + if (remap_mode != BLO_WRITE_PATH_REMAP_NONE) { /* Check if we need to backup and restore paths. */ if (UNLIKELY(G_FILE_SAVE_COPY & write_flags)) { path_list_backup = BKE_bpath_list_backup(mainvar, path_list_flag); } - if (G.relbase_valid) { - /* Saved, make relative paths relative to new location (if possible). */ - BKE_bpath_relative_rebase(mainvar, dir_src, dir_dst, NULL); - } - else { - /* Unsaved, make all relative. */ - BKE_bpath_relative_convert(mainvar, dir_dst, NULL); + switch (remap_mode) { + case BLO_WRITE_PATH_REMAP_RELATIVE: + /* Saved, make relative paths relative to new location (if possible). */ + BKE_bpath_relative_rebase(mainvar, dir_src, dir_dst, NULL); + break; + case BLO_WRITE_PATH_REMAP_RELATIVE_ALL: + /* Make all relative (when requested or unsaved). */ + BKE_bpath_relative_convert(mainvar, dir_dst, NULL); + break; + case BLO_WRITE_PATH_REMAP_ABSOLUTE: + /* Make all absolute (when requested or unsaved). */ + BKE_bpath_absolute_convert(mainvar, dir_src, NULL); + break; + case BLO_WRITE_PATH_REMAP_NONE: + BLI_assert(0); /* Unreachable. */ + break; } } } @@ -4510,6 +4540,15 @@ bool BLO_write_file(Main *mainvar, return 1; } +bool BLO_write_file(Main *mainvar, + const char *filepath, + const int write_flags, + ReportList *reports) +{ + return BLO_write_file_ex( + mainvar, filepath, write_flags, reports, BLO_WRITE_PATH_REMAP_NONE, NULL); +} + /** * \return Success. */ -- cgit v1.2.3 From fade37ff07ab3b62844068a1a5d60dd74ea787f6 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 19 Jun 2020 15:41:07 +1000 Subject: Writefile: move file flags to BlendFileWriteParams This removes G_FILE_HISTORY, G_FILE_SAVE_COPY & G_FILE_USERPREFS. Using file-flags made logic harder to follow since it's not so clear which flags are expected to be in G.fileflags & which are meant to be set and passed as arguments, these are shared between read & write functions too. Add BlendFileWriteParams so options which don't need to be stored aren't mixed up with flags that are stored for reuse. --- source/blender/blenloader/BLO_writefile.h | 27 ++++++++++-------- source/blender/blenloader/intern/writefile.c | 41 +++++++++++++--------------- 2 files changed, 35 insertions(+), 33 deletions(-) (limited to 'source/blender/blenloader') diff --git a/source/blender/blenloader/BLO_writefile.h b/source/blender/blenloader/BLO_writefile.h index 18783474392..32cb6633c12 100644 --- a/source/blender/blenloader/BLO_writefile.h +++ b/source/blender/blenloader/BLO_writefile.h @@ -35,25 +35,30 @@ struct ReportList; */ typedef enum eBLO_WritePathRemap { /** No path manipulation. */ - BLO_WRITE_PATH_REMAP_NONE = 1, + BLO_WRITE_PATH_REMAP_NONE = 0, /** Remap existing relative paths (default). */ - BLO_WRITE_PATH_REMAP_RELATIVE = 2, + BLO_WRITE_PATH_REMAP_RELATIVE = 1, /** Remap paths making all paths relative to the new location. */ - BLO_WRITE_PATH_REMAP_RELATIVE_ALL = 3, + BLO_WRITE_PATH_REMAP_RELATIVE_ALL = 2, /** Make all paths absolute. */ - BLO_WRITE_PATH_REMAP_ABSOLUTE = 4, + BLO_WRITE_PATH_REMAP_ABSOLUTE = 3, } eBLO_WritePathRemap; -extern bool BLO_write_file_ex(struct Main *mainvar, - const char *filepath, - const int write_flags, - struct ReportList *reports, - /* Extra arguments. */ - eBLO_WritePathRemap remap_mode, - const struct BlendThumbnail *thumb); +/** Similar to #BlendFileReadParams. */ +struct BlendFileWriteParams { + eBLO_WritePathRemap remap_mode; + /** Save `.blend1`, `.blend2`... etc. */ + uint use_save_versions : 1; + /** On write, restore paths after editing them (see #BLO_WRITE_PATH_REMAP_RELATIVE). */ + uint use_save_as_copy : 1; + uint use_userdef : 1; + const struct BlendThumbnail *thumb; +}; + extern bool BLO_write_file(struct Main *mainvar, const char *filepath, const int write_flags, + const struct BlendFileWriteParams *params, struct ReportList *reports); extern bool BLO_write_file_mem(struct Main *mainvar, diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 1cda22de941..77c7410615e 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -4076,6 +4076,7 @@ static bool write_file_handle(Main *mainvar, MemFile *compare, MemFile *current, int write_flags, + bool use_userdef, const BlendThumbnail *thumb) { BHead bhead; @@ -4329,7 +4330,7 @@ static bool write_file_handle(Main *mainvar, /* So changes above don't cause a 'DNA1' to be detected as changed on undo. */ mywrite_flush(wd); - if (write_flags & G_FILE_USERPREFS) { + if (use_userdef) { write_userdef(&writer, &U); } @@ -4400,18 +4401,22 @@ static bool do_history(const char *name, ReportList *reports) /** * \return Success. */ -bool BLO_write_file_ex(Main *mainvar, - const char *filepath, - const int write_flags, - ReportList *reports, - /* Extra arguments. */ - eBLO_WritePathRemap remap_mode, - const BlendThumbnail *thumb) +bool BLO_write_file(Main *mainvar, + const char *filepath, + const int write_flags, + const struct BlendFileWriteParams *params, + ReportList *reports) { char tempname[FILE_MAX + 1]; eWriteWrapType ww_type; WriteWrap ww; + eBLO_WritePathRemap remap_mode = params->remap_mode; + const bool use_save_versions = params->use_save_versions; + const bool use_save_as_copy = params->use_save_as_copy; + const bool use_userdef = params->use_userdef; + const BlendThumbnail *thumb = params->thumb; + /* path backup/restore */ void *path_list_backup = NULL; const int path_list_flag = (BKE_BPATH_TRAVERSE_SKIP_LIBRARY | BKE_BPATH_TRAVERSE_SKIP_MULTIFILE); @@ -4476,7 +4481,7 @@ bool BLO_write_file_ex(Main *mainvar, if (remap_mode != BLO_WRITE_PATH_REMAP_NONE) { /* Check if we need to backup and restore paths. */ - if (UNLIKELY(G_FILE_SAVE_COPY & write_flags)) { + if (UNLIKELY(use_save_as_copy)) { path_list_backup = BKE_bpath_list_backup(mainvar, path_list_flag); } @@ -4501,7 +4506,7 @@ bool BLO_write_file_ex(Main *mainvar, } /* actual file writing */ - const bool err = write_file_handle(mainvar, &ww, NULL, NULL, write_flags, thumb); + const bool err = write_file_handle(mainvar, &ww, NULL, NULL, write_flags, use_userdef, thumb); ww.close(&ww); @@ -4519,7 +4524,7 @@ bool BLO_write_file_ex(Main *mainvar, /* file save to temporary file was successful */ /* now do reverse file history (move .blend1 -> .blend2, .blend -> .blend1) */ - if (write_flags & G_FILE_HISTORY) { + if (use_save_versions) { const bool err_hist = do_history(filepath, reports); if (err_hist) { BKE_report(reports, RPT_ERROR, "Version backup failed (file saved with @)"); @@ -4540,23 +4545,15 @@ bool BLO_write_file_ex(Main *mainvar, return 1; } -bool BLO_write_file(Main *mainvar, - const char *filepath, - const int write_flags, - ReportList *reports) -{ - return BLO_write_file_ex( - mainvar, filepath, write_flags, reports, BLO_WRITE_PATH_REMAP_NONE, NULL); -} - /** * \return Success. */ bool BLO_write_file_mem(Main *mainvar, MemFile *compare, MemFile *current, int write_flags) { - write_flags &= ~G_FILE_USERPREFS; + bool use_userdef = false; - const bool err = write_file_handle(mainvar, NULL, compare, current, write_flags, NULL); + const bool err = write_file_handle( + mainvar, NULL, compare, current, write_flags, use_userdef, NULL); return (err == 0); } -- cgit v1.2.3 From 9e7012995249281b041d55607e7e7408857aa8c4 Mon Sep 17 00:00:00 2001 From: Alexander Gavrilov Date: Fri, 12 Jun 2020 21:33:38 +0300 Subject: Cloth: allow forces to act parallel to cloth. Currently all force effectors can only act on cloth when the force is perpendicular to the surface. This makes sense for wind, but not for other forces; and the user may want even wind to have some friction. This changes effector code to output two force vectors - although you of course can pass the same pointer for both. The force is split between the two outputs based on a new per-effector setting. Differential Revision: https://developer.blender.org/D8017 --- source/blender/blenloader/intern/versioning_280.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'source/blender/blenloader') diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index 6211c58d7d4..0648264466d 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -5075,6 +5075,23 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) * \note Keep this message at the bottom of the function. */ { + /* Set the cloth wind factor to 1 for old forces. */ + if (!DNA_struct_elem_find(fd->filesdna, "PartDeflect", "float", "f_wind_factor")) { + LISTBASE_FOREACH (Object *, ob, &bmain->objects) { + if (ob->pd) { + ob->pd->f_wind_factor = 1.0f; + } + } + LISTBASE_FOREACH (ParticleSettings *, part, &bmain->particles) { + if (part->pd) { + part->pd->f_wind_factor = 1.0f; + } + if (part->pd2) { + part->pd2->f_wind_factor = 1.0f; + } + } + } + /* Keep this block, even when empty. */ } } -- cgit v1.2.3 From f84414d6e14c42bf0f96b128c35d29bc2da59087 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Fri, 19 Jun 2020 17:02:55 +0200 Subject: EEEVEE: Object Motion Blur: Initial Implementation This adds object motion blur vectors for EEVEE as well as better noise reduction for it. For TAA reprojection we just compute the motion vector on the fly based on camera motion and depth buffer. This makes possible to store another motion vector only for the blurring which is not useful for TAA history fetching. Motion Data is saved per object & per geometry if using deformation blur. We support deformation motion blur by saving previous VBO and modifying the actual GPUBatch for the geometry to include theses VBOs. We store Previous and Next frame motion in the same motion vector buffer (RG for prev and BA for next). This makes non linear motion blur (like rotating objects) less prone to outward/inward blur. We also improve the motion blur post process to expand outside the objects border. We use a tile base approach and the max size of the blur is set via a new render setting. We use a background reconstruction method that needs another setting (Background Separation). Sampling is done using a fixed 8 dithered samples per direction. The final render samples will clear the noise like other stochastic effects. One caveat is that hair particles are not yet supported. Support will come in another patch. Reviewed By: jbakker Differential Revision: https://developer.blender.org/D7297 --- source/blender/blenloader/intern/versioning_290.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'source/blender/blenloader') diff --git a/source/blender/blenloader/intern/versioning_290.c b/source/blender/blenloader/intern/versioning_290.c index c5628b43960..8d57ef25c4d 100644 --- a/source/blender/blenloader/intern/versioning_290.c +++ b/source/blender/blenloader/intern/versioning_290.c @@ -279,5 +279,13 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain) } } } + + /* EEVEE Motion blur new parameters. */ + if (!DNA_struct_elem_find(fd->filesdna, "SceneEEVEE", "float", "motion_blur_depth_scale")) { + LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) { + scene->eevee.motion_blur_depth_scale = 100.0f; + scene->eevee.motion_blur_max = 32; + } + } } } -- cgit v1.2.3 From eaa44afe703eeb785f4590719b39392b66d6a312 Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Fri, 19 Jun 2020 12:40:48 -0400 Subject: UI: Drag and Drop Constraints, Layout Updates This patch implements the list panel system D7490 for constraints. In this case the panels are still defined in Python. The layouts are also updated to use subpanels and the a more organized single column layout. There may be more tweaks necessary for the layouts. Reviewed By: Severin, billreynish, Mets Differential Revision: https://developer.blender.org/D7499 --- source/blender/blenloader/intern/versioning_290.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'source/blender/blenloader') diff --git a/source/blender/blenloader/intern/versioning_290.c b/source/blender/blenloader/intern/versioning_290.c index 8d57ef25c4d..0dd1ecd0008 100644 --- a/source/blender/blenloader/intern/versioning_290.c +++ b/source/blender/blenloader/intern/versioning_290.c @@ -24,6 +24,7 @@ #include "BLI_utildefines.h" #include "DNA_brush_types.h" +#include "DNA_constraint_types.h" #include "DNA_genfile.h" #include "DNA_gpencil_modifier_types.h" #include "DNA_modifier_types.h" @@ -287,5 +288,19 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain) scene->eevee.motion_blur_max = 32; } } + + /* Transition to saving expansion for all of a constraint's subpanels. */ + if (!DNA_struct_elem_find(fd->filesdna, "bConstraint", "short", "ui_expand_flag")) { + for (Object *object = bmain->objects.first; object != NULL; object = object->id.next) { + LISTBASE_FOREACH (bConstraint *, con, &object->constraints) { + if (con->flag & CONSTRAINT_EXPAND_DEPRECATED) { + con->ui_expand_flag = 1; + } + else { + con->ui_expand_flag = 0; + } + } + } + } } } -- cgit v1.2.3 From ec963d9d7d179e3ba12f5bdf748818939c2f17d8 Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Fri, 19 Jun 2020 14:42:08 -0400 Subject: UI: Grease Pencil Modifier Drag and Drop, Layout Changes This patch implements the list panel system D7490 for grease pencil modifiers. It also moves their drawing to a callback in GpencilModifierTypeInfo in line with the extensible architecture refactoring goal T75724. This also adds the "set_error" function for grease pencil modifiers, which hadn't been copied from mesh modifiers yet. The implementation is basically exactly the same as for the modifier patch (9b099c86123fc82). Thanks to Matias Mendiola (mendio) for providing mockups for many of the layout changes. Differential Revision: https://developer.blender.org/D7978 --- source/blender/blenloader/intern/versioning_290.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'source/blender/blenloader') diff --git a/source/blender/blenloader/intern/versioning_290.c b/source/blender/blenloader/intern/versioning_290.c index 0dd1ecd0008..00c73ebe9a7 100644 --- a/source/blender/blenloader/intern/versioning_290.c +++ b/source/blender/blenloader/intern/versioning_290.c @@ -268,6 +268,7 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain) { /* Keep this block, even when empty. */ + /* Transition to saving expansion for all of a modifier's subpanels. */ if (!DNA_struct_elem_find(fd->filesdna, "ModifierData", "short", "ui_expand_flag")) { for (Object *object = bmain->objects.first; object != NULL; object = object->id.next) { LISTBASE_FOREACH (ModifierData *, md, &object->modifiers) { @@ -302,5 +303,19 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain) } } } + + /* Transition to saving expansion for all of grease pencil modifier's subpanels. */ + if (!DNA_struct_elem_find(fd->filesdna, "GpencilModifierData", "short", "ui_expand_flag")) { + for (Object *object = bmain->objects.first; object != NULL; object = object->id.next) { + LISTBASE_FOREACH (GpencilModifierData *, md, &object->greasepencil_modifiers) { + if (md->mode & eGpencilModifierMode_Expanded_DEPRECATED) { + md->ui_expand_flag = 1; + } + else { + md->ui_expand_flag = 0; + } + } + } + } } } -- cgit v1.2.3 From bb4cef71eeaf36aa61187d47b8a8ae06ba55f7c0 Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Fri, 19 Jun 2020 15:07:13 -0400 Subject: UI: ShaderFx Drag and Drop, Layout Updates This patch implements the list panel system D7490 for grease pencil shader effects. It also moves their drawing to a callback in ShaderFxTypeInfo in line with the extensible architecture refactoring goal T75724. The implementation is basically exactly the same as for the modifier patch (9b099c86123fc82). Thanks to Matias Mendiola (@mendio) for helping to develop the layout changes. Differential Revision: https://developer.blender.org/D7985 --- source/blender/blenloader/intern/versioning_290.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'source/blender/blenloader') diff --git a/source/blender/blenloader/intern/versioning_290.c b/source/blender/blenloader/intern/versioning_290.c index 00c73ebe9a7..bf4ed270e33 100644 --- a/source/blender/blenloader/intern/versioning_290.c +++ b/source/blender/blenloader/intern/versioning_290.c @@ -30,6 +30,7 @@ #include "DNA_modifier_types.h" #include "DNA_object_types.h" #include "DNA_screen_types.h" +#include "DNA_shader_fx_types.h" #include "BKE_collection.h" #include "BKE_colortools.h" @@ -317,5 +318,19 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain) } } } + + /* Transition to saving expansion for all of an effect's subpanels. */ + if (!DNA_struct_elem_find(fd->filesdna, "ShaderFxData", "short", "ui_expand_flag")) { + for (Object *object = bmain->objects.first; object != NULL; object = object->id.next) { + LISTBASE_FOREACH (ShaderFxData *, fx, &object->shader_fx) { + if (fx->mode & eShaderFxMode_Expanded_DEPRECATED) { + fx->ui_expand_flag = 1; + } + else { + fx->ui_expand_flag = 0; + } + } + } + } } } -- cgit v1.2.3 From a573d7e8a14ce5e49b8c05ff762a00e181e905aa Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 23 Jun 2020 09:54:07 +1000 Subject: Cleanup: rename Library.filepath to filepath_abs Make it clear that this is the absolute path, allow the 'name' to be renamed to 'filepath'. Rename is safe since this is only for run-time. --- source/blender/blenloader/intern/blend_validate.c | 4 +-- source/blender/blenloader/intern/readfile.c | 38 +++++++++++------------ source/blender/blenloader/intern/writefile.c | 2 +- 3 files changed, 22 insertions(+), 22 deletions(-) (limited to 'source/blender/blenloader') diff --git a/source/blender/blenloader/intern/blend_validate.c b/source/blender/blenloader/intern/blend_validate.c index 33c5e3ac197..133811bdc01 100644 --- a/source/blender/blenloader/intern/blend_validate.c +++ b/source/blender/blenloader/intern/blend_validate.c @@ -83,14 +83,14 @@ bool BLO_main_validate_libraries(Main *bmain, ReportList *reports) } BKE_library_filepath_set(bmain, curlib, curlib->name); - BlendHandle *bh = BLO_blendhandle_from_file(curlib->filepath, reports); + BlendHandle *bh = BLO_blendhandle_from_file(curlib->filepath_abs, reports); if (bh == NULL) { BKE_reportf(reports, RPT_ERROR, "Library ID %s not found at expected path %s!", curlib->id.name, - curlib->filepath); + curlib->filepath_abs); continue; } diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 5b5cf8e6232..872c2bf23e8 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -310,7 +310,7 @@ void blo_reportf_wrap(ReportList *reports, ReportType type, const char *format, /* for reporting linking messages */ static const char *library_parent_filepath(Library *lib) { - return lib->parent ? lib->parent->filepath : ""; + return lib->parent ? lib->parent->filepath_abs : ""; } /* -------------------------------------------------------------------- */ @@ -673,7 +673,7 @@ static Main *blo_find_main(FileData *fd, const char *filepath, const char *relab // printf("blo_find_main: converted to %s\n", name1); for (m = mainlist->first; m; m = m->next) { - const char *libname = (m->curlib) ? m->curlib->filepath : m->name; + const char *libname = (m->curlib) ? m->curlib->filepath_abs : m->name; if (BLI_path_cmp(name1, libname) == 0) { if (G.debug & G_DEBUG) { @@ -697,7 +697,7 @@ static Main *blo_find_main(FileData *fd, const char *filepath, const char *relab id_us_ensure_real(&lib->id); BLI_strncpy(lib->name, filepath, sizeof(lib->name)); - BLI_strncpy(lib->filepath, name1, sizeof(lib->filepath)); + BLI_strncpy(lib->filepath_abs, name1, sizeof(lib->filepath_abs)); m->curlib = lib; @@ -8356,12 +8356,12 @@ static void direct_link_library(FileData *fd, Library *lib, Main *main) /* check if the library was already read */ for (newmain = fd->mainlist->first; newmain; newmain = newmain->next) { if (newmain->curlib) { - if (BLI_path_cmp(newmain->curlib->filepath, lib->filepath) == 0) { + if (BLI_path_cmp(newmain->curlib->filepath_abs, lib->filepath_abs) == 0) { blo_reportf_wrap(fd->reports, RPT_WARNING, TIP_("Library '%s', '%s' had multiple instances, save and reload!"), lib->name, - lib->filepath); + lib->filepath_abs); change_link_placeholder_to_real_ID_pointer(fd->mainlist, fd, lib, newmain->curlib); /* change_link_placeholder_to_real_ID_pointer_fd(fd, lib, newmain->curlib); */ @@ -8383,12 +8383,12 @@ static void direct_link_library(FileData *fd, Library *lib, Main *main) } } - /* make sure we have full path in lib->filepath */ - BLI_strncpy(lib->filepath, lib->name, sizeof(lib->name)); - BLI_path_normalize(fd->relabase, lib->filepath); + /* Make sure we have full path in lib->filepath_abs */ + BLI_strncpy(lib->filepath_abs, lib->name, sizeof(lib->name)); + BLI_path_normalize(fd->relabase, lib->filepath_abs); // printf("direct_link_library: name %s\n", lib->name); - // printf("direct_link_library: filepath %s\n", lib->filepath); + // printf("direct_link_library: filepath %s\n", lib->filepath_abs); BlendDataReader reader = {fd}; lib->packedfile = direct_link_packedfile(&reader, lib->packedfile); @@ -8421,7 +8421,7 @@ static void fix_relpaths_library(const char *basepath, Main *main) * link into an unsaved blend file. See [#27405]. * The remap relative option will make it relative again on save - campbell */ if (BLI_path_is_rel(lib->name)) { - BLI_strncpy(lib->name, lib->filepath, sizeof(lib->name)); + BLI_strncpy(lib->name, lib->filepath_abs, sizeof(lib->name)); } } } @@ -8431,7 +8431,7 @@ static void fix_relpaths_library(const char *basepath, Main *main) * relative to the blend file since indirectly linked libs will be * relative to their direct linked library. */ if (BLI_path_is_rel(lib->name)) { /* if this is relative to begin with? */ - BLI_strncpy(lib->name, lib->filepath, sizeof(lib->name)); + BLI_strncpy(lib->name, lib->filepath_abs, sizeof(lib->name)); BLI_path_rel(lib->name, basepath); } } @@ -10545,7 +10545,7 @@ static void expand_doit_library(void *fdhandle, Main *mainvar, void *old) RPT_WARNING, TIP_("LIB: Data refers to main .blend file: '%s' from %s"), idname, - mainvar->curlib->filepath); + mainvar->curlib->filepath_abs); return; } @@ -12105,7 +12105,7 @@ static void library_link_end(Main *mainl, /* make the lib path relative if required */ if (flag & FILE_RELPATH) { /* use the full path, this could have been read by other library even */ - BLI_strncpy(curlib->name, curlib->filepath, sizeof(curlib->name)); + BLI_strncpy(curlib->name, curlib->filepath_abs, sizeof(curlib->name)); /* uses current .blend file as reference */ BLI_path_rel(curlib->name, BKE_main_blendfile_path_from_global()); @@ -12255,7 +12255,7 @@ static void read_library_linked_id( "non-linkable data type"), BKE_idtype_idcode_to_name(GS(id->name)), id->name + 2, - mainvar->curlib->filepath, + mainvar->curlib->filepath_abs, library_parent_filepath(mainvar->curlib)); } @@ -12273,7 +12273,7 @@ static void read_library_linked_id( TIP_("LIB: %s: '%s' missing from '%s', parent '%s'"), BKE_idtype_idcode_to_name(GS(id->name)), id->name + 2, - mainvar->curlib->filepath, + mainvar->curlib->filepath_abs, library_parent_filepath(mainvar->curlib)); /* Generate a placeholder for this ID (simplified version of read_libblock actually...). */ @@ -12381,17 +12381,17 @@ static FileData *read_library_file_data(FileData *basefd, fd = blo_filedata_from_memory(pf->data, pf->size, basefd->reports); /* Needed for library_append and read_libraries. */ - BLI_strncpy(fd->relabase, mainptr->curlib->filepath, sizeof(fd->relabase)); + BLI_strncpy(fd->relabase, mainptr->curlib->filepath_abs, sizeof(fd->relabase)); } else { /* Read file on disk. */ blo_reportf_wrap(basefd->reports, RPT_INFO, TIP_("Read library: '%s', '%s', parent '%s'"), - mainptr->curlib->filepath, + mainptr->curlib->filepath_abs, mainptr->curlib->name, library_parent_filepath(mainptr->curlib)); - fd = blo_filedata_from_file(mainptr->curlib->filepath, basefd->reports); + fd = blo_filedata_from_file(mainptr->curlib->filepath_abs, basefd->reports); } if (fd) { @@ -12428,7 +12428,7 @@ static FileData *read_library_file_data(FileData *basefd, if (fd == NULL) { blo_reportf_wrap( - basefd->reports, RPT_WARNING, TIP_("Cannot find lib '%s'"), mainptr->curlib->filepath); + basefd->reports, RPT_WARNING, TIP_("Cannot find lib '%s'"), mainptr->curlib->filepath_abs); } return fd; diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 77c7410615e..2402afbccd5 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -3989,7 +3989,7 @@ static void write_libraries(WriteData *wd, Main *main) "ERROR: write file: data-block '%s' from lib '%s' is not linkable " "but is flagged as directly linked", id->name, - main->curlib->filepath); + main->curlib->filepath_abs); BLI_assert(0); } writestruct(wd, ID_LINK_PLACEHOLDER, ID, 1, id); -- cgit v1.2.3 From 716a8241d387180fd8ad69cdec33633bc7a0f963 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 23 Jun 2020 09:54:14 +1000 Subject: Cleanup: rename 'name' to 'filepath' for DNA types Using 'name' for the full path of a file reads badly, especially when id.name is used in related code. --- source/blender/blenloader/intern/blend_validate.c | 10 ++--- source/blender/blenloader/intern/readfile.c | 50 +++++++++++----------- source/blender/blenloader/intern/versioning_270.c | 2 +- .../blender/blenloader/intern/versioning_legacy.c | 8 ++-- source/blender/blenloader/intern/writefile.c | 6 +-- 5 files changed, 38 insertions(+), 38 deletions(-) (limited to 'source/blender/blenloader') diff --git a/source/blender/blenloader/intern/blend_validate.c b/source/blender/blenloader/intern/blend_validate.c index 133811bdc01..0a5d8d332aa 100644 --- a/source/blender/blenloader/intern/blend_validate.c +++ b/source/blender/blenloader/intern/blend_validate.c @@ -70,7 +70,7 @@ bool BLO_main_validate_libraries(Main *bmain, ReportList *reports) RPT_ERROR, "ID %s is in local database while being linked from library %s!", id->name, - id->lib->name); + id->lib->filepath); } } } @@ -82,7 +82,7 @@ bool BLO_main_validate_libraries(Main *bmain, ReportList *reports) continue; } - BKE_library_filepath_set(bmain, curlib, curlib->name); + BKE_library_filepath_set(bmain, curlib, curlib->filepath); BlendHandle *bh = BLO_blendhandle_from_file(curlib->filepath_abs, reports); if (bh == NULL) { @@ -107,7 +107,7 @@ bool BLO_main_validate_libraries(Main *bmain, ReportList *reports) RPT_ERROR, "Library ID %s in library %s, this should not happen!", id->name, - curlib->name); + curlib->filepath); continue; } @@ -120,7 +120,7 @@ bool BLO_main_validate_libraries(Main *bmain, ReportList *reports) RPT_ERROR, "ID %s has NULL lib pointer while being in library %s!", id->name, - curlib->name); + curlib->filepath); continue; } if (id->lib != curlib) { @@ -143,7 +143,7 @@ bool BLO_main_validate_libraries(Main *bmain, ReportList *reports) RPT_ERROR, "ID %s not found in library %s anymore!", id->name, - id->lib->name); + id->lib->filepath); continue; } } diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 872c2bf23e8..b46ee660a08 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -696,7 +696,7 @@ static Main *blo_find_main(FileData *fd, const char *filepath, const char *relab /* Matches direct_link_library(). */ id_us_ensure_real(&lib->id); - BLI_strncpy(lib->name, filepath, sizeof(lib->name)); + BLI_strncpy(lib->filepath, filepath, sizeof(lib->filepath)); BLI_strncpy(lib->filepath_abs, name1, sizeof(lib->filepath_abs)); m->curlib = lib; @@ -4242,7 +4242,7 @@ static void direct_link_text(BlendDataReader *reader, Text *text) { TextLine *ln; - BLO_read_data_address(reader, &text->name); + BLO_read_data_address(reader, &text->filepath); text->compiled = NULL; @@ -5206,7 +5206,7 @@ static void lib_link_object(FileData *fd, Main *bmain, Object *ob) ob->proxy = NULL; if (ob->id.lib) { - printf("Proxy lost from object %s lib %s\n", ob->id.name + 2, ob->id.lib->name); + printf("Proxy lost from object %s lib %s\n", ob->id.name + 2, ob->id.lib->filepath); } else { printf("Proxy lost from object %s lib \n", ob->id.name + 2); @@ -5224,7 +5224,7 @@ static void lib_link_object(FileData *fd, Main *bmain, Object *ob) if (ob->data == NULL && poin != NULL) { if (ob->id.lib) { - printf("Can't find obdata of %s lib %s\n", ob->id.name + 2, ob->id.lib->name); + printf("Can't find obdata of %s lib %s\n", ob->id.name + 2, ob->id.lib->filepath); } else { printf("Object %s lost data.\n", ob->id.name + 2); @@ -8360,7 +8360,7 @@ static void direct_link_library(FileData *fd, Library *lib, Main *main) blo_reportf_wrap(fd->reports, RPT_WARNING, TIP_("Library '%s', '%s' had multiple instances, save and reload!"), - lib->name, + lib->filepath, lib->filepath_abs); change_link_placeholder_to_real_ID_pointer(fd->mainlist, fd, lib, newmain->curlib); @@ -8384,11 +8384,11 @@ static void direct_link_library(FileData *fd, Library *lib, Main *main) } /* Make sure we have full path in lib->filepath_abs */ - BLI_strncpy(lib->filepath_abs, lib->name, sizeof(lib->name)); + BLI_strncpy(lib->filepath_abs, lib->filepath, sizeof(lib->filepath)); BLI_path_normalize(fd->relabase, lib->filepath_abs); - // printf("direct_link_library: name %s\n", lib->name); - // printf("direct_link_library: filepath %s\n", lib->filepath_abs); + // printf("direct_link_library: filepath %s\n", lib->filepath); + // printf("direct_link_library: filepath_abs %s\n", lib->filepath_abs); BlendDataReader reader = {fd}; lib->packedfile = direct_link_packedfile(&reader, lib->packedfile); @@ -8420,8 +8420,8 @@ static void fix_relpaths_library(const char *basepath, Main *main) * it absolute. This can happen when appending an object with a relative * link into an unsaved blend file. See [#27405]. * The remap relative option will make it relative again on save - campbell */ - if (BLI_path_is_rel(lib->name)) { - BLI_strncpy(lib->name, lib->filepath_abs, sizeof(lib->name)); + if (BLI_path_is_rel(lib->filepath)) { + BLI_strncpy(lib->filepath, lib->filepath_abs, sizeof(lib->filepath)); } } } @@ -8430,9 +8430,9 @@ static void fix_relpaths_library(const char *basepath, Main *main) /* Libraries store both relative and abs paths, recreate relative paths, * relative to the blend file since indirectly linked libs will be * relative to their direct linked library. */ - if (BLI_path_is_rel(lib->name)) { /* if this is relative to begin with? */ - BLI_strncpy(lib->name, lib->filepath_abs, sizeof(lib->name)); - BLI_path_rel(lib->name, basepath); + if (BLI_path_is_rel(lib->filepath)) { /* if this is relative to begin with? */ + BLI_strncpy(lib->filepath, lib->filepath_abs, sizeof(lib->filepath)); + BLI_path_rel(lib->filepath, basepath); } } } @@ -9448,7 +9448,7 @@ static bool read_libblock_undo_restore_linked(FileData *fd, Main *main, const ID DEBUG_PRINTF("UNDO: restore linked datablock %s\n", id->name); DEBUG_PRINTF(" from %s (%s): ", main->curlib ? main->curlib->id.name : "", - main->curlib ? main->curlib->name : ""); + main->curlib ? main->curlib->filepath : ""); ID *id_old = BKE_libblock_find_name(main, GS(id->name), id->name + 2); if (id_old != NULL) { @@ -9885,8 +9885,8 @@ static void do_versions(FileData *fd, Library *lib, Main *main) static void do_versions_after_linking(Main *main, ReportList *reports) { - // printf("%s for %s (%s), %d.%d\n", __func__, main->curlib ? main->curlib->name : main->name, - // main->curlib ? "LIB" : "MAIN", main->versionfile, main->subversionfile); + // printf("%s for %s (%s), %d.%d\n", __func__, main->curlib ? main->curlib->filepath : + // main->name, main->curlib ? "LIB" : "MAIN", main->versionfile, main->subversionfile); /* Don't allow versioning to create new data-blocks. */ main->is_locked_for_linking = true; @@ -10536,7 +10536,7 @@ static void expand_doit_library(void *fdhandle, Main *mainvar, void *old) } Library *lib = read_struct(fd, bheadlib, "Library"); - Main *libmain = blo_find_main(fd, lib->name, fd->relabase); + Main *libmain = blo_find_main(fd, lib->filepath, fd->relabase); if (libmain->curlib == NULL) { const char *idname = blo_bhead_id_name(fd, bhead); @@ -10556,7 +10556,7 @@ static void expand_doit_library(void *fdhandle, Main *mainvar, void *old) * library it belongs to, so that it will be read later. */ read_libblock(fd, libmain, bhead, LIB_TAG_INDIRECT, false, NULL); // commented because this can print way too much - // if (G.debug & G_DEBUG) printf("expand_doit: other lib %s\n", lib->name); + // if (G.debug & G_DEBUG) printf("expand_doit: other lib %s\n", lib->filepath); /* for outliner dependency only */ libmain->curlib->parent = mainvar->curlib; @@ -10593,7 +10593,7 @@ static void expand_doit_library(void *fdhandle, Main *mainvar, void *old) /* Commented because this can print way too much. */ #if 0 if (G.debug & G_DEBUG) { - printf("expand_doit: already linked: %s lib: %s\n", id->name, lib->name); + printf("expand_doit: already linked: %s lib: %s\n", id->name, lib->filepath); } #endif } @@ -12044,7 +12044,7 @@ static Main *library_link_begin(Main *mainvar, FileData **fd, const char *filepa * \param mainvar: The current main database, e.g. #G_MAIN or #CTX_data_main(C). * \param bh: A blender file handle as returned by * #BLO_blendhandle_from_file or #BLO_blendhandle_from_memory. - * \param filepath: Used for relative linking, copied to the \a lib->name. + * \param filepath: Used for relative linking, copied to the `lib->filepath`. * \return the library Main, to be passed to #BLO_library_append_named_part as \a mainl. */ Main *BLO_library_link_begin(Main *mainvar, BlendHandle **bh, const char *filepath) @@ -12105,10 +12105,10 @@ static void library_link_end(Main *mainl, /* make the lib path relative if required */ if (flag & FILE_RELPATH) { /* use the full path, this could have been read by other library even */ - BLI_strncpy(curlib->name, curlib->filepath_abs, sizeof(curlib->name)); + BLI_strncpy(curlib->filepath, curlib->filepath_abs, sizeof(curlib->filepath)); /* uses current .blend file as reference */ - BLI_path_rel(curlib->name, BKE_main_blendfile_path_from_global()); + BLI_path_rel(curlib->filepath, BKE_main_blendfile_path_from_global()); } blo_join_main((*fd)->mainlist); @@ -12376,7 +12376,7 @@ static FileData *read_library_file_data(FileData *basefd, blo_reportf_wrap(basefd->reports, RPT_INFO, TIP_("Read packed library: '%s', parent '%s'"), - mainptr->curlib->name, + mainptr->curlib->filepath, library_parent_filepath(mainptr->curlib)); fd = blo_filedata_from_memory(pf->data, pf->size, basefd->reports); @@ -12389,7 +12389,7 @@ static FileData *read_library_file_data(FileData *basefd, RPT_INFO, TIP_("Read library: '%s', '%s', parent '%s'"), mainptr->curlib->filepath_abs, - mainptr->curlib->name, + mainptr->curlib->filepath, library_parent_filepath(mainptr->curlib)); fd = blo_filedata_from_file(mainptr->curlib->filepath_abs, basefd->reports); } @@ -12460,7 +12460,7 @@ static void read_libraries(FileData *basefd, ListBase *mainlist) #if 0 printf("Reading linked data-blocks from %s (%s)\n", mainptr->curlib->id.name, - mainptr->curlib->name); + mainptr->curlib->filepath); #endif /* Open file if it has not been done yet. */ diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c index 2a468026ac5..496c8353f85 100644 --- a/source/blender/blenloader/intern/versioning_270.c +++ b/source/blender/blenloader/intern/versioning_270.c @@ -981,7 +981,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain) BLI_addtail(&ima->packedfiles, imapf); imapf->packedfile = ima->packedfile; - BLI_strncpy(imapf->filepath, ima->name, FILE_MAX); + BLI_strncpy(imapf->filepath, ima->filepath, FILE_MAX); ima->packedfile = NULL; } } diff --git a/source/blender/blenloader/intern/versioning_legacy.c b/source/blender/blenloader/intern/versioning_legacy.c index 2cc811e213f..ce472a97337 100644 --- a/source/blender/blenloader/intern/versioning_legacy.c +++ b/source/blender/blenloader/intern/versioning_legacy.c @@ -856,8 +856,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain) if (bmain->versionfile <= 223) { VFont *vf; for (vf = bmain->fonts.first; vf; vf = vf->id.next) { - if (STREQ(vf->name + strlen(vf->name) - 6, ".Bfont")) { - strcpy(vf->name, FO_BUILTIN_NAME); + if (STREQ(vf->filepath + strlen(vf->filepath) - 6, ".Bfont")) { + strcpy(vf->filepath, FO_BUILTIN_NAME); } } } @@ -1643,9 +1643,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain) if (bmain->versionfile == 241) { Image *ima; for (ima = bmain->images.first; ima; ima = ima->id.next) { - if (STREQ(ima->name, "Compositor")) { + if (STREQ(ima->filepath, "Compositor")) { strcpy(ima->id.name + 2, "Viewer Node"); - strcpy(ima->name, "Viewer Node"); + strcpy(ima->filepath, "Viewer Node"); } } } diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 2402afbccd5..0c57621e742 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -3206,8 +3206,8 @@ static void write_text(BlendWriter *writer, Text *text, const void *id_address) BLO_write_id_struct(writer, Text, id_address, &text->id); write_iddata(writer, &text->id); - if (text->name) { - BLO_write_string(writer, text->name); + if (text->filepath) { + BLO_write_string(writer, text->filepath); } if (!(text->flags & TXT_ISEXT)) { @@ -3974,7 +3974,7 @@ static void write_libraries(WriteData *wd, Main *main) writestruct(wd, DATA, PackedFile, 1, pf); writedata(wd, DATA, pf->size, pf->data); if (wd->use_memfile == false) { - printf("write packed .blend: %s\n", main->curlib->name); + printf("write packed .blend: %s\n", main->curlib->filepath); } } -- cgit v1.2.3 From 6703c7f7f1f68ae59f9ccbf4fcabc3c035d648bf Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Mon, 22 Jun 2020 22:25:55 -0400 Subject: Bevel: Refactor profile type input to use an enum This will allow the easier addition of a constant radius mode in the future and some changes in the UI to mirror the recent similar change from "Only Vertices" to the "Affect" enum. --- source/blender/blenloader/intern/versioning_290.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'source/blender/blenloader') diff --git a/source/blender/blenloader/intern/versioning_290.c b/source/blender/blenloader/intern/versioning_290.c index bf4ed270e33..843bf4c98d9 100644 --- a/source/blender/blenloader/intern/versioning_290.c +++ b/source/blender/blenloader/intern/versioning_290.c @@ -333,4 +333,18 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain) } } } + + /* Refactor bevel profile type to use an enum. */ + if (!DNA_struct_elem_find(fd->filesdna, "BevelModifier", "short", "profile_type")) { + for (Object *object = bmain->objects.first; object != NULL; object = object->id.next) { + LISTBASE_FOREACH (ModifierData *, md, &object->modifiers) { + if (md->type == eModifierType_Bevel) { + BevelModifierData *bmd = (BevelModifierData *)md; + bool use_custom_profile = bmd->flags & MOD_BEVEL_CUSTOM_PROFILE_DEPRECATED; + bmd->profile_type = use_custom_profile ? MOD_BEVEL_PROFILE_CUSTOM : + MOD_BEVEL_PROFILE_SUPERELLIPSE; + } + } + } + } } -- cgit v1.2.3 From 4040cb438f8929da6a1c29ba7c9c8288c1f05a5a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 23 Jun 2020 16:38:52 +1000 Subject: Cleanup: use doxy sections for BLI read/write headers Add reference between the read/write functions too. --- source/blender/blenloader/BLO_readfile.h | 26 +++++++++++++++++++------- source/blender/blenloader/BLO_writefile.h | 8 ++++++++ 2 files changed, 27 insertions(+), 7 deletions(-) (limited to 'source/blender/blenloader') diff --git a/source/blender/blenloader/BLO_readfile.h b/source/blender/blenloader/BLO_readfile.h index 8495caa91b5..e4908eb7257 100644 --- a/source/blender/blenloader/BLO_readfile.h +++ b/source/blender/blenloader/BLO_readfile.h @@ -48,6 +48,18 @@ struct wmWindowManager; typedef struct BlendHandle BlendHandle; +typedef struct WorkspaceConfigFileData { + struct Main *main; /* has to be freed when done reading file data */ + + struct ListBase workspaces; +} WorkspaceConfigFileData; + +/* -------------------------------------------------------------------- */ +/** \name BLO Read File API + * + * \see #BLO_write_file for file writing. + * \{ */ + typedef enum eBlenFileType { BLENFILETYPE_BLEND = 1, /* BLENFILETYPE_PUB = 2, */ /* UNUSED */ @@ -69,12 +81,6 @@ typedef struct BlendFileData { eBlenFileType type; } BlendFileData; -typedef struct WorkspaceConfigFileData { - struct Main *main; /* has to be freed when done reading file data */ - - struct ListBase workspaces; -} WorkspaceConfigFileData; - struct BlendFileReadParams { uint skip_flags : 3; /* eBLOReadSkip */ uint is_startup : 1; @@ -108,6 +114,12 @@ BlendFileData *BLO_read_from_memfile(struct Main *oldmain, void BLO_blendfiledata_free(BlendFileData *bfd); +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name BLO Blend File Handle API + * \{ */ + BlendHandle *BLO_blendhandle_from_file(const char *filepath, struct ReportList *reports); BlendHandle *BLO_blendhandle_from_memory(const void *mem, int memsize); @@ -119,7 +131,7 @@ struct LinkNode *BLO_blendhandle_get_linkable_groups(BlendHandle *bh); void BLO_blendhandle_close(BlendHandle *bh); -/***/ +/** \} */ #define BLO_GROUP_MAX 32 #define BLO_EMBEDDED_STARTUP_BLEND "" diff --git a/source/blender/blenloader/BLO_writefile.h b/source/blender/blenloader/BLO_writefile.h index 32cb6633c12..f9eada96308 100644 --- a/source/blender/blenloader/BLO_writefile.h +++ b/source/blender/blenloader/BLO_writefile.h @@ -30,6 +30,12 @@ struct Main; struct MemFile; struct ReportList; +/* -------------------------------------------------------------------- */ +/** \name BLO Write File API + * + * \see #BLO_read_from_file for file reading. + * \{ */ + /** * Adjust paths when saving (kept unless #G_FILE_SAVE_COPY is set). */ @@ -66,4 +72,6 @@ extern bool BLO_write_file_mem(struct Main *mainvar, struct MemFile *current, int write_flags); +/** \} */ + #endif -- cgit v1.2.3 From 439b40e601f8cdae9a12fc3f503e9e6acdd596d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Tue, 23 Jun 2020 13:59:55 +0200 Subject: EEVEE: Motion Blur: Add accumulation motion blur for better precision This revisit the render pipeline to support time slicing for better motion blur. We support accumulation with or without the Post-process motion blur. If using the post-process, we reuse last step next motion data to avoid another scene reevaluation. This also adds support for hair motion blur which is handled in a similar way as mesh motion blur. The total number of samples is distributed evenly accross all timesteps to avoid sampling weighting issues. For this reason, the sample count is (internally) rounded up to the next multiple of the step count. Only FX Motion BLur: {F8632258} FX Motion Blur + 4 time steps: {F8632260} FX Motion Blur + 32 time steps: {F8632261} Reviewed By: jbakker Differential Revision: https://developer.blender.org/D8079 --- source/blender/blenloader/intern/versioning_290.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source/blender/blenloader') diff --git a/source/blender/blenloader/intern/versioning_290.c b/source/blender/blenloader/intern/versioning_290.c index 843bf4c98d9..c1bbb4a6fff 100644 --- a/source/blender/blenloader/intern/versioning_290.c +++ b/source/blender/blenloader/intern/versioning_290.c @@ -291,6 +291,12 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain) } } + if (!DNA_struct_elem_find(fd->filesdna, "SceneEEVEE", "int", "motion_blur_steps")) { + LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) { + scene->eevee.motion_blur_steps = 1; + } + } + /* Transition to saving expansion for all of a constraint's subpanels. */ if (!DNA_struct_elem_find(fd->filesdna, "bConstraint", "short", "ui_expand_flag")) { for (Object *object = bmain->objects.first; object != NULL; object = object->id.next) { -- cgit v1.2.3 From 4284ddefab20c1e092871941c3e79aa307ecc1e9 Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Tue, 23 Jun 2020 10:07:22 -0400 Subject: Fix mistake in bevel versioning Use the correct modifier struct name --- source/blender/blenloader/intern/versioning_290.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenloader') diff --git a/source/blender/blenloader/intern/versioning_290.c b/source/blender/blenloader/intern/versioning_290.c index c1bbb4a6fff..a9e0f8fb568 100644 --- a/source/blender/blenloader/intern/versioning_290.c +++ b/source/blender/blenloader/intern/versioning_290.c @@ -341,7 +341,7 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain) } /* Refactor bevel profile type to use an enum. */ - if (!DNA_struct_elem_find(fd->filesdna, "BevelModifier", "short", "profile_type")) { + if (!DNA_struct_elem_find(fd->filesdna, "BevelModifierData", "short", "profile_type")) { for (Object *object = bmain->objects.first; object != NULL; object = object->id.next) { LISTBASE_FOREACH (ModifierData *, md, &object->modifiers) { if (md->type == eModifierType_Bevel) { -- cgit v1.2.3 From f7bbc7cdbb6cb0d28504c6a8dd51bee5330d1f17 Mon Sep 17 00:00:00 2001 From: Pablo Dobarro Date: Mon, 22 Jun 2020 20:05:28 +0200 Subject: Sculpt Vertex Colors: Initial implementation Sculpt Vertex Colors is a painting system that runs inside sculpt mode, reusing all its tools and optimizations. This provides much better performance, easier to maintain code and more advanced features (new brush engine, filters, symmetry options, masks and face sets compatibility...). This is also the initial step for future features like vertex painting in Multires and brushes that can sculpt and paint at the same time. This commit includes: - SCULPT_UNDO_COLOR for undo support in sculpt mode - SCULPT_UPDATE_COLOR and PBVH flags and rendering - Sculpt Color API functions - Sculpt capability for sculpt tools (only enabled in the Paint Brush for now) - Rendering support in workbench (default to Sculpt Vertex Colors except in Vertex Paint) - Conversion operator between MPropCol (Sculpt Vertex Colors) and MLoopCol (Vertex Paint) - Remesher reprojection in the Voxel Remehser - Paint Brush and Smear Brush with color smoothing in alt-smooth mode - Parameters for the new brush engine (density, opacity, flow, wet paint mixing, tip scale) implemented in Sculpt Vertex Colors - Color Filter - Color picker (uses S shortcut, replaces smooth) - Color selector in the top bar Reviewed By: brecht Maniphest Tasks: T72866 Differential Revision: https://developer.blender.org/D5975 --- source/blender/blenloader/intern/versioning_280.c | 12 +++++++++++- source/blender/blenloader/intern/versioning_defaults.c | 16 ++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) (limited to 'source/blender/blenloader') diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index 0648264466d..890be9ff3ef 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -1749,6 +1749,16 @@ void do_versions_after_linking_280(Main *bmain, ReportList *UNUSED(reports)) */ { /* Keep this block, even when empty. */ + /* Paint Brush. This ensure that the brush paints by default. Used during the develpment and + * patch review of the initial Sculpt Vertex Colors implementation (D5975) */ + LISTBASE_FOREACH (Brush *, brush, &bmain->brushes) { + if (brush->ob_mode & OB_MODE_SCULPT && brush->sculpt_tool == SCULPT_TOOL_PAINT) { + brush->tip_roundness = 1.0f; + brush->flow = 1.0f; + brush->density = 1.0f; + brush->tip_scale_x = 1.0f; + } + } } } @@ -3474,7 +3484,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) for (Mesh *me = bmain->meshes.first; me; me = me->id.next) { me->flag &= ~(ME_FLAG_UNUSED_0 | ME_FLAG_UNUSED_1 | ME_FLAG_UNUSED_3 | ME_FLAG_UNUSED_4 | - ME_FLAG_UNUSED_6 | ME_FLAG_UNUSED_7 | ME_FLAG_UNUSED_8); + ME_FLAG_UNUSED_6 | ME_FLAG_UNUSED_7 | ME_REMESH_REPROJECT_VERTEX_COLORS); } for (Material *mat = bmain->materials.first; mat; mat = mat->id.next) { diff --git a/source/blender/blenloader/intern/versioning_defaults.c b/source/blender/blenloader/intern/versioning_defaults.c index 91d89254c90..1217b69f1b5 100644 --- a/source/blender/blenloader/intern/versioning_defaults.c +++ b/source/blender/blenloader/intern/versioning_defaults.c @@ -682,6 +682,22 @@ void BLO_update_defaults_startup_blend(Main *bmain, const char *app_template) brush->sculpt_tool = SCULPT_TOOL_SLIDE_RELAX; } + brush_name = "Paint"; + brush = BLI_findstring(&bmain->brushes, brush_name, offsetof(ID, name) + 2); + if (!brush) { + brush = BKE_brush_add(bmain, brush_name, OB_MODE_SCULPT); + id_us_min(&brush->id); + brush->sculpt_tool = SCULPT_TOOL_PAINT; + } + + brush_name = "Smear"; + brush = BLI_findstring(&bmain->brushes, brush_name, offsetof(ID, name) + 2); + if (!brush) { + brush = BKE_brush_add(bmain, brush_name, OB_MODE_SCULPT); + id_us_min(&brush->id); + brush->sculpt_tool = SCULPT_TOOL_SMEAR; + } + brush_name = "Simplify"; brush = BLI_findstring(&bmain->brushes, brush_name, offsetof(ID, name) + 2); if (!brush) { -- cgit v1.2.3 From 8b59b97c10ecbab6e1062335d1c376b4c0fb9879 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Tue, 23 Jun 2020 16:42:00 +0200 Subject: Refactor: move more blenloader code into modifier files --- source/blender/blenloader/intern/readfile.c | 36 ---------------------------- source/blender/blenloader/intern/writefile.c | 31 +----------------------- 2 files changed, 1 insertion(+), 66 deletions(-) (limited to 'source/blender/blenloader') 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; -- cgit v1.2.3 From adcb7a2ce7c3ec79f2b30cc1cef02aa1ea9e7690 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Tue, 23 Jun 2020 16:51:43 +0200 Subject: Refactor: move blenloader code of surface deform modifier --- source/blender/blenloader/intern/readfile.c | 27 --------------------------- source/blender/blenloader/intern/writefile.c | 27 --------------------------- 2 files changed, 54 deletions(-) (limited to 'source/blender/blenloader') diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index b5055111a30..8c02b067d35 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -5777,33 +5777,6 @@ static void direct_link_modifiers(BlendDataReader *reader, ListBase *lb, Object msmcd->reader = NULL; msmcd->reader_object_path[0] = '\0'; } - else if (md->type == eModifierType_SurfaceDeform) { - SurfaceDeformModifierData *smd = (SurfaceDeformModifierData *)md; - - BLO_read_data_address(reader, &smd->verts); - - if (smd->verts) { - for (int i = 0; i < smd->numverts; i++) { - BLO_read_data_address(reader, &smd->verts[i].binds); - - if (smd->verts[i].binds) { - for (int j = 0; j < smd->verts[i].numbinds; j++) { - BLO_read_uint32_array( - reader, smd->verts[i].binds[j].numverts, &smd->verts[i].binds[j].vert_inds); - - if (smd->verts[i].binds[j].mode == MOD_SDEF_MODE_CENTROID || - smd->verts[i].binds[j].mode == MOD_SDEF_MODE_LOOPTRI) { - BLO_read_float3_array(reader, 1, &smd->verts[i].binds[j].vert_weights); - } - else { - BLO_read_float_array( - reader, smd->verts[i].binds[j].numverts, &smd->verts[i].binds[j].vert_weights); - } - } - } - } - } - } else if (md->type == eModifierType_Bevel) { BevelModifierData *bmd = (BevelModifierData *)md; BLO_read_data_address(reader, &bmd->custom_profile); diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 6aeb0746d21..8f87ff78ab5 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -1748,33 +1748,6 @@ static void write_modifiers(BlendWriter *writer, ListBase *modbase) writestruct(wd, DATA, MFace, collmd->numfaces, collmd->mfaces); #endif } - else if (md->type == eModifierType_SurfaceDeform) { - SurfaceDeformModifierData *smd = (SurfaceDeformModifierData *)md; - - BLO_write_struct_array(writer, SDefVert, smd->numverts, smd->verts); - - if (smd->verts) { - for (int i = 0; i < smd->numverts; i++) { - BLO_write_struct_array(writer, SDefBind, smd->verts[i].numbinds, smd->verts[i].binds); - - if (smd->verts[i].binds) { - for (int j = 0; j < smd->verts[i].numbinds; j++) { - BLO_write_uint32_array( - writer, smd->verts[i].binds[j].numverts, smd->verts[i].binds[j].vert_inds); - - if (smd->verts[i].binds[j].mode == MOD_SDEF_MODE_CENTROID || - smd->verts[i].binds[j].mode == MOD_SDEF_MODE_LOOPTRI) { - BLO_write_float3_array(writer, 1, smd->verts[i].binds[j].vert_weights); - } - else { - BLO_write_float_array( - writer, smd->verts[i].binds[j].numverts, smd->verts[i].binds[j].vert_weights); - } - } - } - } - } - } else if (md->type == eModifierType_Bevel) { BevelModifierData *bmd = (BevelModifierData *)md; if (bmd->custom_profile) { -- cgit v1.2.3 From 56f95297754dae0562c107737fd3e8a85b9c34df Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Tue, 23 Jun 2020 17:02:49 +0200 Subject: Refactor: move blenloader code of curve profile to blenkernel --- source/blender/blenloader/intern/readfile.c | 18 +++--------------- source/blender/blenloader/intern/writefile.c | 11 +++-------- 2 files changed, 6 insertions(+), 23 deletions(-) (limited to 'source/blender/blenloader') diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 8c02b067d35..e90849fdf18 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -118,6 +118,7 @@ #include "BKE_colortools.h" #include "BKE_constraint.h" #include "BKE_curve.h" +#include "BKE_curveprofile.h" #include "BKE_effect.h" #include "BKE_fcurve_driver.h" #include "BKE_fluid.h" @@ -2880,19 +2881,6 @@ static void direct_link_id_common( /** \} */ -/* -------------------------------------------------------------------- */ -/** \name Read CurveProfile - * \{ */ - -static void direct_link_curveprofile(BlendDataReader *reader, CurveProfile *profile) -{ - BLO_read_data_address(reader, &profile->path); - profile->table = NULL; - profile->segments = NULL; -} - -/** \} */ - /* -------------------------------------------------------------------- */ /** \name Read ID: Brush * \{ */ @@ -5781,7 +5769,7 @@ static void direct_link_modifiers(BlendDataReader *reader, ListBase *lb, Object BevelModifierData *bmd = (BevelModifierData *)md; BLO_read_data_address(reader, &bmd->custom_profile); if (bmd->custom_profile) { - direct_link_curveprofile(reader, bmd->custom_profile); + BKE_curveprofile_blend_read(reader, bmd->custom_profile); } } @@ -6754,7 +6742,7 @@ static void direct_link_scene(BlendDataReader *reader, Scene *sce) /* Relink toolsettings curve profile */ BLO_read_data_address(reader, &sce->toolsettings->custom_bevel_profile_preset); if (sce->toolsettings->custom_bevel_profile_preset) { - direct_link_curveprofile(reader, sce->toolsettings->custom_bevel_profile_preset); + BKE_curveprofile_blend_read(reader, sce->toolsettings->custom_bevel_profile_preset); } } diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 8f87ff78ab5..898e43a2c44 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -158,6 +158,7 @@ #include "BKE_colortools.h" #include "BKE_constraint.h" #include "BKE_curve.h" +#include "BKE_curveprofile.h" #include "BKE_fcurve.h" #include "BKE_fcurve_driver.h" #include "BKE_global.h" // for G @@ -968,12 +969,6 @@ static void write_animdata(BlendWriter *writer, AnimData *adt) write_nladata(writer, &adt->nla_tracks); } -static void write_CurveProfile(BlendWriter *writer, CurveProfile *profile) -{ - BLO_write_struct(writer, CurveProfile, profile); - BLO_write_struct_array(writer, CurveProfilePoint, profile->path_len, profile->path); -} - static void write_node_socket_default_value(BlendWriter *writer, bNodeSocket *sock) { if (sock->default_value == NULL) { @@ -1751,7 +1746,7 @@ static void write_modifiers(BlendWriter *writer, ListBase *modbase) else if (md->type == eModifierType_Bevel) { BevelModifierData *bmd = (BevelModifierData *)md; if (bmd->custom_profile) { - write_CurveProfile(writer, bmd->custom_profile); + BKE_curveprofile_blend_write(writer, bmd->custom_profile); } } @@ -2594,7 +2589,7 @@ static void write_scene(BlendWriter *writer, Scene *sce, const void *id_address) } /* Write the curve profile to the file. */ if (tos->custom_bevel_profile_preset) { - write_CurveProfile(writer, tos->custom_bevel_profile_preset); + BKE_curveprofile_blend_write(writer, tos->custom_bevel_profile_preset); } write_paint(writer, &tos->imapaint.paint); -- cgit v1.2.3 From 9ef5cc44a6c33445960f118ad2415345e174d7b7 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Tue, 23 Jun 2020 17:08:26 +0200 Subject: Refactor: move blenloader code of bevel modifier --- source/blender/blenloader/intern/readfile.c | 7 ------- source/blender/blenloader/intern/writefile.c | 6 ------ 2 files changed, 13 deletions(-) (limited to 'source/blender/blenloader') diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index e90849fdf18..15dbef5fdc5 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -5765,13 +5765,6 @@ static void direct_link_modifiers(BlendDataReader *reader, ListBase *lb, Object msmcd->reader = NULL; msmcd->reader_object_path[0] = '\0'; } - else if (md->type == eModifierType_Bevel) { - BevelModifierData *bmd = (BevelModifierData *)md; - BLO_read_data_address(reader, &bmd->custom_profile); - if (bmd->custom_profile) { - BKE_curveprofile_blend_read(reader, bmd->custom_profile); - } - } if (mti->blendRead != NULL) { mti->blendRead(reader, md); diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 898e43a2c44..83c587cc446 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -1743,12 +1743,6 @@ static void write_modifiers(BlendWriter *writer, ListBase *modbase) writestruct(wd, DATA, MFace, collmd->numfaces, collmd->mfaces); #endif } - else if (md->type == eModifierType_Bevel) { - BevelModifierData *bmd = (BevelModifierData *)md; - if (bmd->custom_profile) { - BKE_curveprofile_blend_write(writer, bmd->custom_profile); - } - } if (mti->blendWrite != NULL) { mti->blendWrite(writer, md); -- cgit v1.2.3 From 1e0426da7c735b5d59f23b2b9303d9c1d72ca7f8 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Tue, 23 Jun 2020 17:25:44 +0200 Subject: Refactor: move more modifier specific code out of readfile.c --- source/blender/blenloader/intern/readfile.c | 69 ----------------------------- 1 file changed, 69 deletions(-) (limited to 'source/blender/blenloader') diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 15dbef5fdc5..e9bd6c9c0d4 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -5557,16 +5557,6 @@ static void direct_link_modifiers(BlendDataReader *reader, ListBase *lb, Object if (is_allocated) { /* All the fields has been properly allocated. */ } - else if (md->type == eModifierType_Subsurf) { - SubsurfModifierData *smd = (SubsurfModifierData *)md; - - smd->emCache = smd->mCache = NULL; - } - else if (md->type == eModifierType_Armature) { - ArmatureModifierData *amd = (ArmatureModifierData *)md; - - amd->vert_coords_prev = NULL; - } else if (md->type == eModifierType_Cloth) { ClothModifierData *clmd = (ClothModifierData *)md; @@ -5706,65 +5696,6 @@ static void direct_link_modifiers(BlendDataReader *reader, ListBase *lb, Object BLO_read_data_address(reader, &pmd->brush->vel_ramp); } } - else if (md->type == eModifierType_Collision) { - CollisionModifierData *collmd = (CollisionModifierData *)md; -#if 0 - // TODO: CollisionModifier should use pointcache - // + have proper reset events before enabling this - collmd->x = newdataadr(fd, collmd->x); - collmd->xnew = newdataadr(fd, collmd->xnew); - collmd->mfaces = newdataadr(fd, collmd->mfaces); - - collmd->current_x = MEM_calloc_arrayN(collmd->numverts, sizeof(MVert), "current_x"); - collmd->current_xnew = MEM_calloc_arrayN(collmd->numverts, sizeof(MVert), "current_xnew"); - collmd->current_v = MEM_calloc_arrayN(collmd->numverts, sizeof(MVert), "current_v"); -#endif - - collmd->x = NULL; - collmd->xnew = NULL; - collmd->current_x = NULL; - collmd->current_xnew = NULL; - collmd->current_v = NULL; - collmd->time_x = collmd->time_xnew = -1000; - collmd->mvert_num = 0; - collmd->tri_num = 0; - collmd->is_static = false; - collmd->bvhtree = NULL; - collmd->tri = NULL; - } - else if (md->type == eModifierType_Surface) { - SurfaceModifierData *surmd = (SurfaceModifierData *)md; - - surmd->mesh = NULL; - surmd->bvhtree = NULL; - surmd->x = NULL; - surmd->v = NULL; - surmd->numverts = 0; - } - else if (md->type == eModifierType_ParticleSystem) { - ParticleSystemModifierData *psmd = (ParticleSystemModifierData *)md; - - psmd->mesh_final = NULL; - psmd->mesh_original = NULL; - BLO_read_data_address(reader, &psmd->psys); - psmd->flag &= ~eParticleSystemFlag_psys_updated; - psmd->flag |= eParticleSystemFlag_file_loaded; - } - else if (md->type == eModifierType_Explode) { - ExplodeModifierData *psmd = (ExplodeModifierData *)md; - - psmd->facepa = NULL; - } - else if (md->type == eModifierType_Ocean) { - OceanModifierData *omd = (OceanModifierData *)md; - omd->oceancache = NULL; - omd->ocean = NULL; - } - else if (md->type == eModifierType_MeshSequenceCache) { - MeshSeqCacheModifierData *msmcd = (MeshSeqCacheModifierData *)md; - msmcd->reader = NULL; - msmcd->reader_object_path[0] = '\0'; - } if (mti->blendRead != NULL) { mti->blendRead(reader, md); -- cgit v1.2.3 From f3a8192ef78100dc03e00be6cd75e35d10e98fd2 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Tue, 23 Jun 2020 17:53:40 +0200 Subject: Refactor: use new api for lib linking mask, windowmanager and screen This is part of T76372. --- source/blender/blenloader/intern/readfile.c | 110 +++++++++++++++------------- 1 file changed, 59 insertions(+), 51 deletions(-) (limited to 'source/blender/blenloader') diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index e9bd6c9c0d4..9c30f0c5ebd 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -3527,10 +3527,13 @@ static void direct_link_workspace(BlendDataReader *reader, WorkSpace *workspace, id_us_ensure_real(&workspace->id); } -static void lib_link_workspace_instance_hook(FileData *fd, WorkSpaceInstanceHook *hook, ID *id) +static void lib_link_workspace_instance_hook(BlendLibReader *reader, + WorkSpaceInstanceHook *hook, + ID *id) { WorkSpace *workspace = BKE_workspace_active_get(hook); - BKE_workspace_active_set(hook, newlibadr(fd, id->lib, workspace)); + BLO_read_id_address(reader, id->lib, &workspace); + BKE_workspace_active_set(hook, workspace); } /** \} */ @@ -7330,9 +7333,9 @@ static void direct_link_area(BlendDataReader *reader, ScrArea *area) BLO_read_data_address(reader, &area->v4); } -static void lib_link_area(FileData *fd, ID *parent_id, ScrArea *area) +static void lib_link_area(BlendLibReader *reader, ID *parent_id, ScrArea *area) { - area->full = newlibadr(fd, parent_id->lib, area->full); + BLO_read_id_address(reader, parent_id->lib, &area->full); memset(&area->runtime, 0x0, sizeof(area->runtime)); @@ -7341,11 +7344,11 @@ static void lib_link_area(FileData *fd, ID *parent_id, ScrArea *area) case SPACE_VIEW3D: { View3D *v3d = (View3D *)sl; - v3d->camera = newlibadr(fd, parent_id->lib, v3d->camera); - v3d->ob_center = newlibadr(fd, parent_id->lib, v3d->ob_center); + BLO_read_id_address(reader, parent_id->lib, &v3d->camera); + BLO_read_id_address(reader, parent_id->lib, &v3d->ob_center); if (v3d->localvd) { - v3d->localvd->camera = newlibadr(fd, parent_id->lib, v3d->localvd->camera); + BLO_read_id_address(reader, parent_id->lib, &v3d->localvd->camera); } break; } @@ -7354,14 +7357,14 @@ static void lib_link_area(FileData *fd, ID *parent_id, ScrArea *area) bDopeSheet *ads = sipo->ads; if (ads) { - ads->source = newlibadr(fd, parent_id->lib, ads->source); - ads->filter_grp = newlibadr(fd, parent_id->lib, ads->filter_grp); + BLO_read_id_address(reader, parent_id->lib, &ads->source); + BLO_read_id_address(reader, parent_id->lib, &ads->filter_grp); } break; } case SPACE_PROPERTIES: { SpaceProperties *sbuts = (SpaceProperties *)sl; - sbuts->pinid = newlibadr(fd, parent_id->lib, sbuts->pinid); + BLO_read_id_address(reader, parent_id->lib, &sbuts->pinid); if (sbuts->pinid == NULL) { sbuts->flag &= ~SB_PIN_CONTEXT; } @@ -7374,23 +7377,23 @@ static void lib_link_area(FileData *fd, ID *parent_id, ScrArea *area) bDopeSheet *ads = &saction->ads; if (ads) { - ads->source = newlibadr(fd, parent_id->lib, ads->source); - ads->filter_grp = newlibadr(fd, parent_id->lib, ads->filter_grp); + BLO_read_id_address(reader, parent_id->lib, &ads->source); + BLO_read_id_address(reader, parent_id->lib, &ads->filter_grp); } - saction->action = newlibadr(fd, parent_id->lib, saction->action); + BLO_read_id_address(reader, parent_id->lib, &saction->action); break; } case SPACE_IMAGE: { SpaceImage *sima = (SpaceImage *)sl; - sima->image = newlibadr(fd, parent_id->lib, sima->image); - sima->mask_info.mask = newlibadr(fd, parent_id->lib, sima->mask_info.mask); + BLO_read_id_address(reader, parent_id->lib, &sima->image); + BLO_read_id_address(reader, parent_id->lib, &sima->mask_info.mask); /* NOTE: pre-2.5, this was local data not lib data, but now we need this as lib data * so fingers crossed this works fine! */ - sima->gpd = newlibadr(fd, parent_id->lib, sima->gpd); + BLO_read_id_address(reader, parent_id->lib, &sima->gpd); break; } case SPACE_SEQ: { @@ -7399,7 +7402,7 @@ static void lib_link_area(FileData *fd, ID *parent_id, ScrArea *area) /* NOTE: pre-2.5, this was local data not lib data, but now we need this as lib data * so fingers crossed this works fine! */ - sseq->gpd = newlibadr(fd, parent_id->lib, sseq->gpd); + BLO_read_id_address(reader, parent_id->lib, &sseq->gpd); break; } case SPACE_NLA: { @@ -7407,22 +7410,22 @@ static void lib_link_area(FileData *fd, ID *parent_id, ScrArea *area) bDopeSheet *ads = snla->ads; if (ads) { - ads->source = newlibadr(fd, parent_id->lib, ads->source); - ads->filter_grp = newlibadr(fd, parent_id->lib, ads->filter_grp); + BLO_read_id_address(reader, parent_id->lib, &ads->source); + BLO_read_id_address(reader, parent_id->lib, &ads->filter_grp); } break; } case SPACE_TEXT: { SpaceText *st = (SpaceText *)sl; - st->text = newlibadr(fd, parent_id->lib, st->text); + BLO_read_id_address(reader, parent_id->lib, &st->text); break; } case SPACE_SCRIPT: { SpaceScript *scpt = (SpaceScript *)sl; /*scpt->script = NULL; - 2.45 set to null, better re-run the script */ if (scpt->script) { - scpt->script = newlibadr(fd, parent_id->lib, scpt->script); + BLO_read_id_address(reader, parent_id->lib, &scpt->script); if (scpt->script) { SCRIPT_SET_NULL(scpt->script); } @@ -7431,7 +7434,7 @@ static void lib_link_area(FileData *fd, ID *parent_id, ScrArea *area) } case SPACE_OUTLINER: { SpaceOutliner *so = (SpaceOutliner *)sl; - so->search_tse.id = newlibadr(fd, NULL, so->search_tse.id); + BLO_read_id_address(reader, NULL, &so->search_tse.id); if (so->treestore) { TreeStoreElem *tselem; @@ -7439,7 +7442,7 @@ static void lib_link_area(FileData *fd, ID *parent_id, ScrArea *area) BLI_mempool_iternew(so->treestore, &iter); while ((tselem = BLI_mempool_iterstep(&iter))) { - tselem->id = newlibadr(fd, NULL, tselem->id); + BLO_read_id_address(reader, NULL, &tselem->id); } if (so->treehash) { /* rebuild hash table, because it depends on ids too */ @@ -7451,14 +7454,18 @@ static void lib_link_area(FileData *fd, ID *parent_id, ScrArea *area) case SPACE_NODE: { SpaceNode *snode = (SpaceNode *)sl; bNodeTreePath *path, *path_next; - bNodeTree *ntree; /* node tree can be stored locally in id too, link this first */ - snode->id = newlibadr(fd, parent_id->lib, snode->id); - snode->from = newlibadr(fd, parent_id->lib, snode->from); + BLO_read_id_address(reader, parent_id->lib, &snode->id); + BLO_read_id_address(reader, parent_id->lib, &snode->from); - ntree = snode->id ? ntreeFromID(snode->id) : NULL; - snode->nodetree = ntree ? ntree : newlibadr(fd, parent_id->lib, snode->nodetree); + bNodeTree *ntree = snode->id ? ntreeFromID(snode->id) : NULL; + if (ntree) { + snode->nodetree = ntree; + } + else { + BLO_read_id_address(reader, parent_id->lib, &snode->nodetree); + } for (path = snode->treepath.first; path; path = path->next) { if (path == snode->treepath.first) { @@ -7466,7 +7473,7 @@ static void lib_link_area(FileData *fd, ID *parent_id, ScrArea *area) path->nodetree = snode->nodetree; } else { - path->nodetree = newlibadr(fd, parent_id->lib, path->nodetree); + BLO_read_id_address(reader, parent_id->lib, &path->nodetree); } if (!path->nodetree) { @@ -7495,8 +7502,8 @@ static void lib_link_area(FileData *fd, ID *parent_id, ScrArea *area) } case SPACE_CLIP: { SpaceClip *sclip = (SpaceClip *)sl; - sclip->clip = newlibadr(fd, parent_id->lib, sclip->clip); - sclip->mask_info.mask = newlibadr(fd, parent_id->lib, sclip->mask_info.mask); + BLO_read_id_address(reader, parent_id->lib, &sclip->clip); + BLO_read_id_address(reader, parent_id->lib, &sclip->mask_info.mask); break; } default: @@ -7544,10 +7551,9 @@ static void direct_link_wm_xr_data(BlendDataReader *reader, wmXrData *xr_data) direct_link_view3dshading(reader, &xr_data->session_settings.shading); } -static void lib_link_wm_xr_data(FileData *fd, ID *parent_id, wmXrData *xr_data) +static void lib_link_wm_xr_data(BlendLibReader *reader, ID *parent_id, wmXrData *xr_data) { - xr_data->session_settings.base_pose_object = newlibadr( - fd, parent_id->lib, xr_data->session_settings.base_pose_object); + BLO_read_id_address(reader, parent_id->lib, &xr_data->session_settings.base_pose_object); } /** \} */ @@ -7633,21 +7639,21 @@ static void direct_link_windowmanager(BlendDataReader *reader, wmWindowManager * wm->is_interface_locked = 0; } -static void lib_link_windowmanager(FileData *fd, Main *UNUSED(bmain), wmWindowManager *wm) +static void lib_link_windowmanager(BlendLibReader *reader, wmWindowManager *wm) { LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { if (win->workspace_hook) { /* NULL for old files */ - lib_link_workspace_instance_hook(fd, win->workspace_hook, &wm->id); + lib_link_workspace_instance_hook(reader, win->workspace_hook, &wm->id); } - win->scene = newlibadr(fd, wm->id.lib, win->scene); + BLO_read_id_address(reader, wm->id.lib, &win->scene); /* deprecated, but needed for versioning (will be NULL'ed then) */ - win->screen = newlibadr(fd, NULL, win->screen); + BLO_read_id_address(reader, NULL, &win->screen); LISTBASE_FOREACH (ScrArea *, area, &win->global_areas.areabase) { - lib_link_area(fd, &wm->id, area); + lib_link_area(reader, &wm->id, area); } - lib_link_wm_xr_data(fd, &wm->id, &wm->xr); + lib_link_wm_xr_data(reader, &wm->id, &wm->xr); } } @@ -7659,17 +7665,17 @@ static void lib_link_windowmanager(FileData *fd, Main *UNUSED(bmain), wmWindowMa /* note: file read without screens option G_FILE_NO_UI; * check lib pointers in call below */ -static void lib_link_screen(FileData *fd, Main *UNUSED(bmain), bScreen *screen) +static void lib_link_screen(BlendLibReader *reader, bScreen *screen) { /* deprecated, but needed for versioning (will be NULL'ed then) */ - screen->scene = newlibadr(fd, screen->id.lib, screen->scene); + BLO_read_id_address(reader, screen->id.lib, &screen->scene); screen->animtimer = NULL; /* saved in rare cases */ screen->tool_tip = NULL; screen->scrubbing = false; LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { - lib_link_area(fd, &screen->id, area); + lib_link_area(reader, &screen->id, area); } } @@ -8553,12 +8559,12 @@ static void direct_link_mask(BlendDataReader *reader, Mask *mask) } } -static void lib_link_mask_parent(FileData *fd, Mask *mask, MaskParent *parent) +static void lib_link_mask_parent(BlendLibReader *reader, Mask *mask, MaskParent *parent) { - parent->id = newlibadr(fd, mask->id.lib, parent->id); + BLO_read_id_address(reader, mask->id.lib, &parent->id); } -static void lib_link_mask(FileData *fd, Main *UNUSED(bmain), Mask *mask) +static void lib_link_mask(BlendLibReader *reader, Mask *mask) { LISTBASE_FOREACH (MaskLayer *, masklay, &mask->masklayers) { MaskSpline *spline; @@ -8570,10 +8576,10 @@ static void lib_link_mask(FileData *fd, Main *UNUSED(bmain), Mask *mask) for (i = 0; i < spline->tot_point; i++) { MaskSplinePoint *point = &spline->points[i]; - lib_link_mask_parent(fd, mask, &point->parent); + lib_link_mask_parent(reader, mask, &point->parent); } - lib_link_mask_parent(fd, mask, &spline->parent); + lib_link_mask_parent(reader, mask, &spline->parent); spline = spline->next; } @@ -9760,6 +9766,8 @@ static void lib_link_all(FileData *fd, Main *bmain) { const bool do_partial_undo = (fd->skip_flags & BLO_READ_SKIP_UNDO_OLD_MAIN) == 0; + BlendLibReader reader = {fd, bmain}; + ID *id; FOREACH_MAIN_ID_BEGIN (bmain, id) { if ((id->tag & LIB_TAG_NEED_LINK) == 0) { @@ -9788,10 +9796,10 @@ static void lib_link_all(FileData *fd, Main *bmain) * whether something is wrong then. */ switch (GS(id->name)) { case ID_MSK: - lib_link_mask(fd, bmain, (Mask *)id); + lib_link_mask(&reader, (Mask *)id); break; case ID_WM: - lib_link_windowmanager(fd, bmain, (wmWindowManager *)id); + lib_link_windowmanager(&reader, (wmWindowManager *)id); break; case ID_WS: /* Could we skip WS in undo case? */ @@ -9809,7 +9817,7 @@ static void lib_link_all(FileData *fd, Main *bmain) case ID_SCR: /* DO NOT skip screens here, * 3D viewport may contains pointers to other ID data (like bgpic)! See T41411. */ - lib_link_screen(fd, bmain, (bScreen *)id); + lib_link_screen(&reader, (bScreen *)id); break; case ID_MC: lib_link_movieclip(fd, bmain, (MovieClip *)id); -- cgit v1.2.3 From 0a3bde63006c66b8b8531ed5eccca9bdf5e5dc20 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sun, 31 May 2020 23:49:10 +0200 Subject: Cycles: add denoising settings to the render properties Enabling render and viewport denoising is now both done from the render properties. View layers still can individually be enabled/disabled for denoising and have their own denoising parameters. Note that the denoising engine also affects how denoising data passes are output even if no denoising happens on the render itself, to make the passes compatible with the engine. This includes internal refactoring for how denoising parameters are passed along, trying to avoid code duplication and unclear naming. Ref T76259 --- .../blender/blenloader/intern/versioning_cycles.c | 77 +++++++++++++++++++++- 1 file changed, 74 insertions(+), 3 deletions(-) (limited to 'source/blender/blenloader') diff --git a/source/blender/blenloader/intern/versioning_cycles.c b/source/blender/blenloader/intern/versioning_cycles.c index ff3d4574561..72ee4c5ec4d 100644 --- a/source/blender/blenloader/intern/versioning_cycles.c +++ b/source/blender/blenloader/intern/versioning_cycles.c @@ -78,22 +78,45 @@ static IDProperty *cycles_properties_from_ID(ID *id) return (idprop) ? IDP_GetPropertyTypeFromGroup(idprop, "cycles", IDP_GROUP) : NULL; } +static IDProperty *cycles_properties_from_view_layer(ViewLayer *view_layer) +{ + IDProperty *idprop = view_layer->id_properties; + return (idprop) ? IDP_GetPropertyTypeFromGroup(idprop, "cycles", IDP_GROUP) : NULL; +} + static float cycles_property_float(IDProperty *idprop, const char *name, float default_value) { IDProperty *prop = IDP_GetPropertyTypeFromGroup(idprop, name, IDP_FLOAT); return (prop) ? IDP_Float(prop) : default_value; } -static float cycles_property_int(IDProperty *idprop, const char *name, int default_value) +static int cycles_property_int(IDProperty *idprop, const char *name, int default_value) { IDProperty *prop = IDP_GetPropertyTypeFromGroup(idprop, name, IDP_INT); return (prop) ? IDP_Int(prop) : default_value; } -static bool cycles_property_boolean(IDProperty *idprop, const char *name, bool default_value) +static void cycles_property_int_set(IDProperty *idprop, const char *name, int value) { IDProperty *prop = IDP_GetPropertyTypeFromGroup(idprop, name, IDP_INT); - return (prop) ? IDP_Int(prop) : default_value; + if (prop) { + IDP_Int(prop) = value; + } + else { + IDPropertyTemplate val = {0}; + val.i = value; + IDP_AddToGroup(idprop, IDP_New(IDP_INT, &val, name)); + } +} + +static bool cycles_property_boolean(IDProperty *idprop, const char *name, bool default_value) +{ + return cycles_property_int(idprop, name, default_value); +} + +static void cycles_property_boolean_set(IDProperty *idprop, const char *name, bool value) +{ + cycles_property_int_set(idprop, name, value); } static void displacement_node_insert(bNodeTree *ntree) @@ -1524,4 +1547,52 @@ void do_versions_after_linking_cycles(Main *bmain) } FOREACH_NODETREE_END; } + + if (!MAIN_VERSION_ATLEAST(bmain, 290, 5)) { + /* New denoiser settings. */ + for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) { + IDProperty *cscene = cycles_properties_from_ID(&scene->id); + + /* Check if any view layers had (optix) denoising enabled. */ + bool use_optix = false; + bool use_denoising = false; + for (ViewLayer *view_layer = scene->view_layers.first; view_layer; + view_layer = view_layer->next) { + IDProperty *cview_layer = cycles_properties_from_view_layer(view_layer); + if (cview_layer) { + use_denoising = use_denoising || + cycles_property_boolean(cview_layer, "use_denoising", false); + use_optix = use_optix || + cycles_property_boolean(cview_layer, "use_optix_denoising", false); + } + } + + if (cscene) { + const int DENOISER_NLM = 1; + const int DENOISER_OPTIX = 2; + + /* Enable denoiser if it was enabled for one view layer before. */ + cycles_property_int_set(cscene, "denoiser", (use_optix) ? DENOISER_OPTIX : DENOISER_NLM); + cycles_property_boolean_set(cscene, "use_denoising", use_denoising); + + /* Migrate Optix denoiser to new settings. */ + if (cycles_property_int(cscene, "preview_denoising", 0)) { + cycles_property_boolean_set(cscene, "use_preview_denoising", true); + cycles_property_boolean_set(cscene, "preview_denoiser", DENOISER_OPTIX); + } + } + + /* Enable denoising in all view layer if there was no denoising before, + * so that enabling the scene settings auto enables it for all view layers. */ + if (!use_denoising) { + for (ViewLayer *view_layer = scene->view_layers.first; view_layer; + view_layer = view_layer->next) { + IDProperty *cview_layer = cycles_properties_from_view_layer(view_layer); + if (cview_layer) { + cycles_property_boolean_set(cview_layer, "use_denoising", true); + } + } + } + } + } } -- cgit v1.2.3 From fd5c185bebd5a418634b2a8846f0aeea86327b20 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 25 Jun 2020 23:13:02 +1000 Subject: Cleanup: spelling --- source/blender/blenloader/intern/versioning_280.c | 2 +- source/blender/blenloader/intern/versioning_290.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'source/blender/blenloader') diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index 890be9ff3ef..d5ca47d726c 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -1749,7 +1749,7 @@ void do_versions_after_linking_280(Main *bmain, ReportList *UNUSED(reports)) */ { /* Keep this block, even when empty. */ - /* Paint Brush. This ensure that the brush paints by default. Used during the develpment and + /* Paint Brush. This ensure that the brush paints by default. Used during the development and * patch review of the initial Sculpt Vertex Colors implementation (D5975) */ LISTBASE_FOREACH (Brush *, brush, &bmain->brushes) { if (brush->ob_mode & OB_MODE_SCULPT && brush->sculpt_tool == SCULPT_TOOL_PAINT) { diff --git a/source/blender/blenloader/intern/versioning_290.c b/source/blender/blenloader/intern/versioning_290.c index a9e0f8fb568..2e93df09e1e 100644 --- a/source/blender/blenloader/intern/versioning_290.c +++ b/source/blender/blenloader/intern/versioning_290.c @@ -269,7 +269,7 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain) { /* Keep this block, even when empty. */ - /* Transition to saving expansion for all of a modifier's subpanels. */ + /* Transition to saving expansion for all of a modifier's sub-panels. */ if (!DNA_struct_elem_find(fd->filesdna, "ModifierData", "short", "ui_expand_flag")) { for (Object *object = bmain->objects.first; object != NULL; object = object->id.next) { LISTBASE_FOREACH (ModifierData *, md, &object->modifiers) { @@ -297,7 +297,7 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain) } } - /* Transition to saving expansion for all of a constraint's subpanels. */ + /* Transition to saving expansion for all of a constraint's sub-panels. */ if (!DNA_struct_elem_find(fd->filesdna, "bConstraint", "short", "ui_expand_flag")) { for (Object *object = bmain->objects.first; object != NULL; object = object->id.next) { LISTBASE_FOREACH (bConstraint *, con, &object->constraints) { @@ -311,7 +311,7 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain) } } - /* Transition to saving expansion for all of grease pencil modifier's subpanels. */ + /* Transition to saving expansion for all of grease pencil modifier's sub-panels. */ if (!DNA_struct_elem_find(fd->filesdna, "GpencilModifierData", "short", "ui_expand_flag")) { for (Object *object = bmain->objects.first; object != NULL; object = object->id.next) { LISTBASE_FOREACH (GpencilModifierData *, md, &object->greasepencil_modifiers) { @@ -325,7 +325,7 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain) } } - /* Transition to saving expansion for all of an effect's subpanels. */ + /* Transition to saving expansion for all of an effect's sub-panels. */ if (!DNA_struct_elem_find(fd->filesdna, "ShaderFxData", "short", "ui_expand_flag")) { for (Object *object = bmain->objects.first; object != NULL; object = object->id.next) { LISTBASE_FOREACH (ShaderFxData *, fx, &object->shader_fx) { -- cgit v1.2.3 From 79c2581bfaf0612f44c44cd09533fc8d231a2d49 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 25 Jun 2020 15:14:30 +0200 Subject: Fix T78238: issue loading existing .blend files with Optix viewport denoiser Also add additional validation to ensure the denoiser is supported before trying to use it. --- source/blender/blenloader/intern/versioning_cycles.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source/blender/blenloader') diff --git a/source/blender/blenloader/intern/versioning_cycles.c b/source/blender/blenloader/intern/versioning_cycles.c index 72ee4c5ec4d..46faddf6e5a 100644 --- a/source/blender/blenloader/intern/versioning_cycles.c +++ b/source/blender/blenloader/intern/versioning_cycles.c @@ -1568,6 +1568,7 @@ void do_versions_after_linking_cycles(Main *bmain) } if (cscene) { + const int DENOISER_AUTO = 0; const int DENOISER_NLM = 1; const int DENOISER_OPTIX = 2; @@ -1578,7 +1579,7 @@ void do_versions_after_linking_cycles(Main *bmain) /* Migrate Optix denoiser to new settings. */ if (cycles_property_int(cscene, "preview_denoising", 0)) { cycles_property_boolean_set(cscene, "use_preview_denoising", true); - cycles_property_boolean_set(cscene, "preview_denoiser", DENOISER_OPTIX); + cycles_property_int_set(cscene, "preview_denoiser", DENOISER_AUTO); } } -- cgit v1.2.3 From ede6e739ddd39c5905cf8fd0d76f91e0e82a7076 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Fri, 26 Jun 2020 13:56:14 +0200 Subject: Refactor: use new api for lib linking collection, scene and workspaces --- source/blender/blenloader/intern/readfile.c | 177 ++++++++++++++-------------- 1 file changed, 88 insertions(+), 89 deletions(-) (limited to 'source/blender/blenloader') diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 9c30f0c5ebd..b121fa04238 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -2657,10 +2657,12 @@ static PreviewImage *direct_link_preview_image(BlendDataReader *reader, PreviewI static void lib_link_id(FileData *fd, Main *bmain, ID *id); static void lib_link_nodetree(FileData *fd, Main *bmain, bNodeTree *ntree); -static void lib_link_collection(FileData *fd, Main *bmain, Collection *collection); +static void lib_link_collection(BlendLibReader *reader, Collection *collection); static void lib_link_id_embedded_id(FileData *fd, Main *bmain, ID *id) { + BlendLibReader reader = {fd, bmain}; + /* Handle 'private IDs'. */ bNodeTree *nodetree = ntreeFromID(id); if (nodetree != NULL) { @@ -2672,7 +2674,7 @@ static void lib_link_id_embedded_id(FileData *fd, Main *bmain, ID *id) Scene *scene = (Scene *)id; if (scene->master_collection != NULL) { lib_link_id(fd, bmain, &scene->master_collection->id); - lib_link_collection(fd, bmain, scene->master_collection); + lib_link_collection(&reader, scene->master_collection); } } } @@ -3360,7 +3362,7 @@ static void direct_link_nladata(BlendDataReader *reader, ListBase *list) /* ------- */ -static void lib_link_keyingsets(FileData *fd, ID *id, ListBase *list) +static void lib_link_keyingsets(BlendLibReader *reader, ID *id, ListBase *list) { KeyingSet *ks; KS_Path *ksp; @@ -3368,7 +3370,7 @@ static void lib_link_keyingsets(FileData *fd, ID *id, ListBase *list) /* here, we're only interested in the ID pointer stored in some of the paths */ for (ks = list->first; ks; ks = ks->next) { for (ksp = ks->paths.first; ksp; ksp = ksp->next) { - ksp->id = newlibadr(fd, id->lib, ksp->id); + BLO_read_id_address(reader, id->lib, &ksp->id); } } } @@ -3471,26 +3473,26 @@ static void direct_link_cachefile(BlendDataReader *reader, CacheFile *cache_file /** \name Read ID: WorkSpace * \{ */ -static void lib_link_workspaces(FileData *fd, Main *bmain, WorkSpace *workspace) +static void lib_link_workspaces(BlendLibReader *reader, WorkSpace *workspace) { ID *id = (ID *)workspace; LISTBASE_FOREACH_MUTABLE (WorkSpaceLayout *, layout, &workspace->layouts) { - layout->screen = newlibadr(fd, id->lib, layout->screen); + BLO_read_id_address(reader, id->lib, &layout->screen); if (layout->screen) { if (ID_IS_LINKED(id)) { layout->screen->winid = 0; if (layout->screen->temp) { /* delete temp layouts when appending */ - BKE_workspace_layout_remove(bmain, workspace, layout); + BKE_workspace_layout_remove(reader->main, workspace, layout); } } } else { /* If we're reading a layout without screen stored, it's useless and we shouldn't keep it * around. */ - BKE_workspace_layout_remove(bmain, workspace, layout); + BKE_workspace_layout_remove(reader->main, workspace, layout); } } } @@ -6061,39 +6063,39 @@ static void direct_link_view_layer(BlendDataReader *reader, ViewLayer *view_laye view_layer->object_bases_hash = NULL; } -static void lib_link_layer_collection(FileData *fd, +static void lib_link_layer_collection(BlendLibReader *reader, Library *lib, LayerCollection *layer_collection, bool master) { /* Master collection is not a real data-lock. */ if (!master) { - layer_collection->collection = newlibadr(fd, lib, layer_collection->collection); + BLO_read_id_address(reader, lib, &layer_collection->collection); } for (LayerCollection *layer_collection_nested = layer_collection->layer_collections.first; layer_collection_nested != NULL; layer_collection_nested = layer_collection_nested->next) { - lib_link_layer_collection(fd, lib, layer_collection_nested, false); + lib_link_layer_collection(reader, lib, layer_collection_nested, false); } } -static void lib_link_view_layer(FileData *fd, Library *lib, ViewLayer *view_layer) +static void lib_link_view_layer(BlendLibReader *reader, Library *lib, ViewLayer *view_layer) { LISTBASE_FOREACH (FreestyleModuleConfig *, fmc, &view_layer->freestyle_config.modules) { - fmc->script = newlibadr(fd, lib, fmc->script); + BLO_read_id_address(reader, lib, &fmc->script); } LISTBASE_FOREACH (FreestyleLineSet *, fls, &view_layer->freestyle_config.linesets) { - fls->linestyle = newlibadr(fd, lib, fls->linestyle); - fls->group = newlibadr(fd, lib, fls->group); + BLO_read_id_address(reader, lib, &fls->linestyle); + BLO_read_id_address(reader, lib, &fls->group); } for (Base *base = view_layer->object_bases.first, *base_next = NULL; base; base = base_next) { base_next = base->next; /* we only bump the use count for the collection objects */ - base->object = newlibadr(fd, lib, base->object); + BLO_read_id_address(reader, lib, &base->object); if (base->object == NULL) { /* Free in case linked object got lost. */ @@ -6107,12 +6109,12 @@ static void lib_link_view_layer(FileData *fd, Library *lib, ViewLayer *view_laye for (LayerCollection *layer_collection = view_layer->layer_collections.first; layer_collection != NULL; layer_collection = layer_collection->next) { - lib_link_layer_collection(fd, lib, layer_collection, true); + lib_link_layer_collection(reader, lib, layer_collection, true); } - view_layer->mat_override = newlibadr(fd, lib, view_layer->mat_override); + BLO_read_id_address(reader, lib, &view_layer->mat_override); - IDP_LibLinkProperty(view_layer->id_properties, fd); + IDP_LibLinkProperty(view_layer->id_properties, reader->fd); } /** \} */ @@ -6132,15 +6134,15 @@ static void direct_link_scene_collection(BlendDataReader *reader, SceneCollectio } } -static void lib_link_scene_collection(FileData *fd, Library *lib, SceneCollection *sc) +static void lib_link_scene_collection(BlendLibReader *reader, Library *lib, SceneCollection *sc) { LISTBASE_FOREACH (LinkData *, link, &sc->objects) { - link->data = newlibadr(fd, lib, link->data); + BLO_read_id_address(reader, lib, &link->data); BLI_assert(link->data); } LISTBASE_FOREACH (SceneCollection *, nsc, &sc->scene_collections) { - lib_link_scene_collection(fd, lib, nsc); + lib_link_scene_collection(reader, lib, nsc); } } #endif @@ -6171,11 +6173,11 @@ static void direct_link_collection(BlendDataReader *reader, Collection *collecti #endif } -static void lib_link_collection_data(FileData *fd, Library *lib, Collection *collection) +static void lib_link_collection_data(BlendLibReader *reader, Library *lib, Collection *collection) { for (CollectionObject *cob = collection->gobject.first, *cob_next = NULL; cob; cob = cob_next) { cob_next = cob->next; - cob->ob = newlibadr(fd, lib, cob->ob); + BLO_read_id_address(reader, lib, &cob->ob); if (cob->ob == NULL) { BLI_freelinkN(&collection->gobject, cob); @@ -6183,23 +6185,23 @@ static void lib_link_collection_data(FileData *fd, Library *lib, Collection *col } for (CollectionChild *child = collection->children.first; child != NULL; child = child->next) { - child->collection = newlibadr(fd, lib, child->collection); + BLO_read_id_address(reader, lib, &child->collection); } } -static void lib_link_collection(FileData *fd, Main *UNUSED(bmain), Collection *collection) +static void lib_link_collection(BlendLibReader *reader, Collection *collection) { #ifdef USE_COLLECTION_COMPAT_28 if (collection->collection) { - lib_link_scene_collection(fd, collection->id.lib, collection->collection); + lib_link_scene_collection(reader, collection->id.lib, collection->collection); } if (collection->view_layer) { - lib_link_view_layer(fd, collection->id.lib, collection->view_layer); + lib_link_view_layer(reader, collection->id.lib, collection->view_layer); } #endif - lib_link_collection_data(fd, collection->id.lib, collection); + lib_link_collection_data(reader, collection->id.lib, collection); } /** \} */ @@ -6220,29 +6222,29 @@ static void composite_patch(bNodeTree *ntree, Scene *scene) } } -static void link_paint(FileData *fd, Scene *sce, Paint *p) +static void link_paint(BlendLibReader *reader, Scene *sce, Paint *p) { if (p) { - p->brush = newlibadr(fd, sce->id.lib, p->brush); + BLO_read_id_address(reader, sce->id.lib, &p->brush); for (int i = 0; i < p->tool_slots_len; i++) { if (p->tool_slots[i].brush != NULL) { - p->tool_slots[i].brush = newlibadr(fd, sce->id.lib, p->tool_slots[i].brush); + BLO_read_id_address(reader, sce->id.lib, &p->tool_slots[i].brush); } } - p->palette = newlibadr(fd, sce->id.lib, p->palette); + BLO_read_id_address(reader, sce->id.lib, &p->palette); p->paint_cursor = NULL; BKE_paint_runtime_init(sce->toolsettings, p); } } -static void lib_link_sequence_modifiers(FileData *fd, Scene *scene, ListBase *lb) +static void lib_link_sequence_modifiers(BlendLibReader *reader, Scene *scene, ListBase *lb) { SequenceModifierData *smd; for (smd = lb->first; smd; smd = smd->next) { if (smd->mask_id) { - smd->mask_id = newlibadr(fd, scene->id.lib, smd->mask_id); + BLO_read_id_address(reader, scene->id.lib, &smd->mask_id); } } } @@ -6323,76 +6325,72 @@ static bool scene_validate_setscene__liblink(Scene *sce, const int totscene) } #endif -static void lib_link_scene(FileData *fd, Main *UNUSED(bmain), Scene *sce) +static void lib_link_scene(BlendLibReader *reader, Scene *sce) { - lib_link_keyingsets(fd, &sce->id, &sce->keyingsets); + lib_link_keyingsets(reader, &sce->id, &sce->keyingsets); - sce->camera = newlibadr(fd, sce->id.lib, sce->camera); - sce->world = newlibadr(fd, sce->id.lib, sce->world); - sce->set = newlibadr(fd, sce->id.lib, sce->set); - sce->gpd = newlibadr(fd, sce->id.lib, sce->gpd); + BLO_read_id_address(reader, sce->id.lib, &sce->camera); + BLO_read_id_address(reader, sce->id.lib, &sce->world); + BLO_read_id_address(reader, sce->id.lib, &sce->set); + BLO_read_id_address(reader, sce->id.lib, &sce->gpd); - link_paint(fd, sce, &sce->toolsettings->imapaint.paint); + link_paint(reader, sce, &sce->toolsettings->imapaint.paint); if (sce->toolsettings->sculpt) { - link_paint(fd, sce, &sce->toolsettings->sculpt->paint); + link_paint(reader, sce, &sce->toolsettings->sculpt->paint); } if (sce->toolsettings->vpaint) { - link_paint(fd, sce, &sce->toolsettings->vpaint->paint); + link_paint(reader, sce, &sce->toolsettings->vpaint->paint); } if (sce->toolsettings->wpaint) { - link_paint(fd, sce, &sce->toolsettings->wpaint->paint); + link_paint(reader, sce, &sce->toolsettings->wpaint->paint); } if (sce->toolsettings->uvsculpt) { - link_paint(fd, sce, &sce->toolsettings->uvsculpt->paint); + link_paint(reader, sce, &sce->toolsettings->uvsculpt->paint); } if (sce->toolsettings->gp_paint) { - link_paint(fd, sce, &sce->toolsettings->gp_paint->paint); + link_paint(reader, sce, &sce->toolsettings->gp_paint->paint); } if (sce->toolsettings->gp_vertexpaint) { - link_paint(fd, sce, &sce->toolsettings->gp_vertexpaint->paint); + link_paint(reader, sce, &sce->toolsettings->gp_vertexpaint->paint); } if (sce->toolsettings->gp_sculptpaint) { - link_paint(fd, sce, &sce->toolsettings->gp_sculptpaint->paint); + link_paint(reader, sce, &sce->toolsettings->gp_sculptpaint->paint); } if (sce->toolsettings->gp_weightpaint) { - link_paint(fd, sce, &sce->toolsettings->gp_weightpaint->paint); + link_paint(reader, sce, &sce->toolsettings->gp_weightpaint->paint); } if (sce->toolsettings->sculpt) { - sce->toolsettings->sculpt->gravity_object = newlibadr( - fd, sce->id.lib, sce->toolsettings->sculpt->gravity_object); + BLO_read_id_address(reader, sce->id.lib, &sce->toolsettings->sculpt->gravity_object); } if (sce->toolsettings->imapaint.stencil) { - sce->toolsettings->imapaint.stencil = newlibadr( - fd, sce->id.lib, sce->toolsettings->imapaint.stencil); + BLO_read_id_address(reader, sce->id.lib, &sce->toolsettings->imapaint.stencil); } if (sce->toolsettings->imapaint.clone) { - sce->toolsettings->imapaint.clone = newlibadr( - fd, sce->id.lib, sce->toolsettings->imapaint.clone); + BLO_read_id_address(reader, sce->id.lib, &sce->toolsettings->imapaint.clone); } if (sce->toolsettings->imapaint.canvas) { - sce->toolsettings->imapaint.canvas = newlibadr( - fd, sce->id.lib, sce->toolsettings->imapaint.canvas); + BLO_read_id_address(reader, sce->id.lib, &sce->toolsettings->imapaint.canvas); } - sce->toolsettings->particle.shape_object = newlibadr( - fd, sce->id.lib, sce->toolsettings->particle.shape_object); + BLO_read_id_address(reader, sce->id.lib, &sce->toolsettings->particle.shape_object); - sce->toolsettings->gp_sculpt.guide.reference_object = newlibadr( - fd, sce->id.lib, sce->toolsettings->gp_sculpt.guide.reference_object); + BLO_read_id_address(reader, sce->id.lib, &sce->toolsettings->gp_sculpt.guide.reference_object); for (Base *base_legacy_next, *base_legacy = sce->base.first; base_legacy; base_legacy = base_legacy_next) { base_legacy_next = base_legacy->next; - base_legacy->object = newlibadr(fd, sce->id.lib, base_legacy->object); + BLO_read_id_address(reader, sce->id.lib, &base_legacy->object); if (base_legacy->object == NULL) { - blo_reportf_wrap( - fd->reports, RPT_WARNING, TIP_("LIB: object lost from scene: '%s'"), sce->id.name + 2); + blo_reportf_wrap(reader->fd->reports, + RPT_WARNING, + TIP_("LIB: object lost from scene: '%s'"), + sce->id.name + 2); BLI_remlink(&sce->base, base_legacy); if (base_legacy == sce->basact) { sce->basact = NULL; @@ -6403,24 +6401,25 @@ static void lib_link_scene(FileData *fd, Main *UNUSED(bmain), Scene *sce) Sequence *seq; SEQ_BEGIN (sce->ed, seq) { - IDP_LibLinkProperty(seq->prop, fd); + IDP_LibLinkProperty(seq->prop, reader->fd); if (seq->ipo) { - seq->ipo = newlibadr(fd, sce->id.lib, seq->ipo); // XXX deprecated - old animation system + BLO_read_id_address( + reader, sce->id.lib, &seq->ipo); // XXX deprecated - old animation system } seq->scene_sound = NULL; if (seq->scene) { - seq->scene = newlibadr(fd, sce->id.lib, seq->scene); + BLO_read_id_address(reader, sce->id.lib, &seq->scene); seq->scene_sound = NULL; } if (seq->clip) { - seq->clip = newlibadr(fd, sce->id.lib, seq->clip); + BLO_read_id_address(reader, sce->id.lib, &seq->clip); } if (seq->mask) { - seq->mask = newlibadr(fd, sce->id.lib, seq->mask); + BLO_read_id_address(reader, sce->id.lib, &seq->mask); } if (seq->scene_camera) { - seq->scene_camera = newlibadr(fd, sce->id.lib, seq->scene_camera); + BLO_read_id_address(reader, sce->id.lib, &seq->scene_camera); } if (seq->sound) { seq->scene_sound = NULL; @@ -6428,7 +6427,7 @@ static void lib_link_scene(FileData *fd, Main *UNUSED(bmain), Scene *sce) seq->type = SEQ_TYPE_SOUND_RAM; } else { - seq->sound = newlibadr(fd, sce->id.lib, seq->sound); + BLO_read_id_address(reader, sce->id.lib, &seq->sound); } if (seq->sound) { id_us_plus_no_lib((ID *)seq->sound); @@ -6437,17 +6436,17 @@ static void lib_link_scene(FileData *fd, Main *UNUSED(bmain), Scene *sce) } if (seq->type == SEQ_TYPE_TEXT) { TextVars *t = seq->effectdata; - t->text_font = newlibadr(fd, sce->id.lib, t->text_font); + BLO_read_id_address(reader, sce->id.lib, &t->text_font); } BLI_listbase_clear(&seq->anims); - lib_link_sequence_modifiers(fd, sce, &seq->modifiers); + lib_link_sequence_modifiers(reader, sce, &seq->modifiers); } SEQ_END; LISTBASE_FOREACH (TimeMarker *, marker, &sce->markers) { if (marker->camera) { - marker->camera = newlibadr(fd, sce->id.lib, marker->camera); + BLO_read_id_address(reader, sce->id.lib, &marker->camera); } } @@ -6455,13 +6454,13 @@ static void lib_link_scene(FileData *fd, Main *UNUSED(bmain), Scene *sce) if (sce->rigidbody_world) { RigidBodyWorld *rbw = sce->rigidbody_world; if (rbw->group) { - rbw->group = newlibadr(fd, sce->id.lib, rbw->group); + BLO_read_id_address(reader, sce->id.lib, &rbw->group); } if (rbw->constraints) { - rbw->constraints = newlibadr(fd, sce->id.lib, rbw->constraints); + BLO_read_id_address(reader, sce->id.lib, &rbw->constraints); } if (rbw->effector_weights) { - rbw->effector_weights->group = newlibadr(fd, sce->id.lib, rbw->effector_weights->group); + BLO_read_id_address(reader, sce->id.lib, &rbw->effector_weights->group); } } @@ -6470,30 +6469,30 @@ static void lib_link_scene(FileData *fd, Main *UNUSED(bmain), Scene *sce) } LISTBASE_FOREACH (SceneRenderLayer *, srl, &sce->r.layers) { - srl->mat_override = newlibadr(fd, sce->id.lib, srl->mat_override); + BLO_read_id_address(reader, sce->id.lib, &srl->mat_override); LISTBASE_FOREACH (FreestyleModuleConfig *, fmc, &srl->freestyleConfig.modules) { - fmc->script = newlibadr(fd, sce->id.lib, fmc->script); + BLO_read_id_address(reader, sce->id.lib, &fmc->script); } LISTBASE_FOREACH (FreestyleLineSet *, fls, &srl->freestyleConfig.linesets) { - fls->linestyle = newlibadr(fd, sce->id.lib, fls->linestyle); - fls->group = newlibadr(fd, sce->id.lib, fls->group); + BLO_read_id_address(reader, sce->id.lib, &fls->linestyle); + BLO_read_id_address(reader, sce->id.lib, &fls->group); } } /* Motion Tracking */ - sce->clip = newlibadr(fd, sce->id.lib, sce->clip); + BLO_read_id_address(reader, sce->id.lib, &sce->clip); #ifdef USE_COLLECTION_COMPAT_28 if (sce->collection) { - lib_link_scene_collection(fd, sce->id.lib, sce->collection); + lib_link_scene_collection(reader, sce->id.lib, sce->collection); } #endif LISTBASE_FOREACH (ViewLayer *, view_layer, &sce->view_layers) { - lib_link_view_layer(fd, sce->id.lib, view_layer); + lib_link_view_layer(reader, sce->id.lib, view_layer); } if (sce->r.bake.cage_object) { - sce->r.bake.cage_object = newlibadr(fd, sce->id.lib, sce->r.bake.cage_object); + BLO_read_id_address(reader, sce->id.lib, &sce->r.bake.cage_object); } #ifdef USE_SETSCENE_CHECK @@ -9803,10 +9802,10 @@ static void lib_link_all(FileData *fd, Main *bmain) break; case ID_WS: /* Could we skip WS in undo case? */ - lib_link_workspaces(fd, bmain, (WorkSpace *)id); + lib_link_workspaces(&reader, (WorkSpace *)id); break; case ID_SCE: - lib_link_scene(fd, bmain, (Scene *)id); + lib_link_scene(&reader, (Scene *)id); break; case ID_LS: lib_link_linestyle(fd, bmain, (FreestyleLineStyle *)id); @@ -9841,7 +9840,7 @@ static void lib_link_all(FileData *fd, Main *bmain) lib_link_brush(fd, bmain, (Brush *)id); break; case ID_GR: - lib_link_collection(fd, bmain, (Collection *)id); + lib_link_collection(&reader, (Collection *)id); break; case ID_SO: lib_link_sound(fd, bmain, (bSound *)id); -- cgit v1.2.3 From 1ce24575519ef922a2796164fef869692d049092 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Fri, 26 Jun 2020 14:40:47 +0200 Subject: Refactor: use new api for lib linking linestyle, object, nodetree and action --- source/blender/blenloader/intern/readfile.c | 301 ++++++++++++++-------------- 1 file changed, 151 insertions(+), 150 deletions(-) (limited to 'source/blender/blenloader') diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index b121fa04238..56afbad40c0 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -262,7 +262,7 @@ static BHead *find_bhead_from_idname(FileData *fd, const char *idname); static void expand_scene_collection(FileData *fd, Main *mainvar, SceneCollection *sc); #endif static void direct_link_animdata(BlendDataReader *reader, AnimData *adt); -static void lib_link_animdata(FileData *fd, ID *id, AnimData *adt); +static void lib_link_animdata(BlendLibReader *reader, ID *id, AnimData *adt); typedef struct BHeadN { struct BHeadN *next, *prev; @@ -2655,47 +2655,46 @@ static PreviewImage *direct_link_preview_image(BlendDataReader *reader, PreviewI /** \name Read ID * \{ */ -static void lib_link_id(FileData *fd, Main *bmain, ID *id); -static void lib_link_nodetree(FileData *fd, Main *bmain, bNodeTree *ntree); +static void lib_link_id(BlendLibReader *reader, ID *id); +static void lib_link_nodetree(BlendLibReader *reader, bNodeTree *ntree); static void lib_link_collection(BlendLibReader *reader, Collection *collection); -static void lib_link_id_embedded_id(FileData *fd, Main *bmain, ID *id) +static void lib_link_id_embedded_id(BlendLibReader *reader, ID *id) { - BlendLibReader reader = {fd, bmain}; /* Handle 'private IDs'. */ bNodeTree *nodetree = ntreeFromID(id); if (nodetree != NULL) { - lib_link_id(fd, bmain, &nodetree->id); - lib_link_nodetree(fd, bmain, nodetree); + lib_link_id(reader, &nodetree->id); + lib_link_nodetree(reader, nodetree); } if (GS(id->name) == ID_SCE) { Scene *scene = (Scene *)id; if (scene->master_collection != NULL) { - lib_link_id(fd, bmain, &scene->master_collection->id); - lib_link_collection(&reader, scene->master_collection); + lib_link_id(reader, &scene->master_collection->id); + lib_link_collection(reader, scene->master_collection); } } } -static void lib_link_id(FileData *fd, Main *bmain, ID *id) +static void lib_link_id(BlendLibReader *reader, ID *id) { /* Note: WM IDProperties are never written to file, hence they should always be NULL here. */ BLI_assert((GS(id->name) != ID_WM) || id->properties == NULL); - IDP_LibLinkProperty(id->properties, fd); + IDP_LibLinkProperty(id->properties, reader->fd); AnimData *adt = BKE_animdata_from_id(id); if (adt != NULL) { - lib_link_animdata(fd, id, adt); + lib_link_animdata(reader, id, adt); } if (id->override_library) { - id->override_library->reference = newlibadr(fd, id->lib, id->override_library->reference); - id->override_library->storage = newlibadr(fd, id->lib, id->override_library->storage); + BLO_read_id_address(reader, id->lib, &id->override_library->reference); + BLO_read_id_address(reader, id->lib, &id->override_library->storage); } - lib_link_id_embedded_id(fd, bmain, id); + lib_link_id_embedded_id(reader, id); } static void direct_link_id_override_property_operation_cb(BlendDataReader *reader, void *data) @@ -3064,17 +3063,17 @@ static void direct_link_ipo(BlendDataReader *reader, Ipo *ipo) } // XXX deprecated - old animation system -static void lib_link_nlastrips(FileData *fd, ID *id, ListBase *striplist) +static void lib_link_nlastrips(BlendLibReader *reader, ID *id, ListBase *striplist) { bActionStrip *strip; bActionModifier *amod; for (strip = striplist->first; strip; strip = strip->next) { - strip->object = newlibadr(fd, id->lib, strip->object); - strip->act = newlibadr(fd, id->lib, strip->act); - strip->ipo = newlibadr(fd, id->lib, strip->ipo); + BLO_read_id_address(reader, id->lib, &strip->object); + BLO_read_id_address(reader, id->lib, &strip->act); + BLO_read_id_address(reader, id->lib, &strip->ipo); for (amod = strip->modifiers.first; amod; amod = amod->next) { - amod->ob = newlibadr(fd, id->lib, amod->ob); + BLO_read_id_address(reader, id->lib, &amod->ob); } } } @@ -3092,12 +3091,12 @@ static void direct_link_nlastrips(BlendDataReader *reader, ListBase *strips) } // XXX deprecated - old animation system -static void lib_link_constraint_channels(FileData *fd, ID *id, ListBase *chanbase) +static void lib_link_constraint_channels(BlendLibReader *reader, ID *id, ListBase *chanbase) { bConstraintChannel *chan; for (chan = chanbase->first; chan; chan = chan->next) { - chan->ipo = newlibadr(fd, id->lib, chan->ipo); + BLO_read_id_address(reader, id->lib, &chan->ipo); } } @@ -3107,7 +3106,7 @@ static void lib_link_constraint_channels(FileData *fd, ID *id, ListBase *chanbas /** \name Read ID: Action * \{ */ -static void lib_link_fmodifiers(FileData *fd, ID *id, ListBase *list) +static void lib_link_fmodifiers(BlendLibReader *reader, ID *id, ListBase *list) { FModifier *fcm; @@ -3116,7 +3115,7 @@ static void lib_link_fmodifiers(FileData *fd, ID *id, ListBase *list) switch (fcm->type) { case FMODIFIER_TYPE_PYTHON: { FMod_Python *data = (FMod_Python *)fcm->data; - data->script = newlibadr(fd, id->lib, data->script); + BLO_read_id_address(reader, id->lib, &data->script); break; } @@ -3124,7 +3123,7 @@ static void lib_link_fmodifiers(FileData *fd, ID *id, ListBase *list) } } -static void lib_link_fcurves(FileData *fd, ID *id, ListBase *list) +static void lib_link_fcurves(BlendLibReader *reader, ID *id, ListBase *list) { FCurve *fcu; @@ -3143,7 +3142,7 @@ static void lib_link_fcurves(FileData *fd, ID *id, ListBase *list) DRIVER_TARGETS_LOOPER_BEGIN (dvar) { /* only relink if still used */ if (tarIndex < dvar->num_targets) { - dtar->id = newlibadr(fd, id->lib, dtar->id); + BLO_read_id_address(reader, id->lib, &dtar->id); } else { dtar->id = NULL; @@ -3154,7 +3153,7 @@ static void lib_link_fcurves(FileData *fd, ID *id, ListBase *list) } /* modifiers */ - lib_link_fmodifiers(fd, id, &fcu->modifiers); + lib_link_fmodifiers(reader, id, &fcu->modifiers); } } @@ -3254,20 +3253,20 @@ static void direct_link_fcurves(BlendDataReader *reader, ListBase *list) } } -static void lib_link_action(FileData *fd, Main *UNUSED(bmain), bAction *act) +static void lib_link_action(BlendLibReader *reader, bAction *act) { // XXX deprecated - old animation system <<< LISTBASE_FOREACH (bActionChannel *, chan, &act->chanbase) { - chan->ipo = newlibadr(fd, act->id.lib, chan->ipo); - lib_link_constraint_channels(fd, &act->id, &chan->constraintChannels); + BLO_read_id_address(reader, act->id.lib, &chan->ipo); + lib_link_constraint_channels(reader, &act->id, &chan->constraintChannels); } // >>> XXX deprecated - old animation system - lib_link_fcurves(fd, &act->id, &act->curves); + lib_link_fcurves(reader, &act->id, &act->curves); LISTBASE_FOREACH (TimeMarker *, marker, &act->markers) { if (marker->camera) { - marker->camera = newlibadr(fd, act->id.lib, marker->camera); + BLO_read_id_address(reader, act->id.lib, &marker->camera); } } } @@ -3298,29 +3297,29 @@ static void direct_link_action(BlendDataReader *reader, bAction *act) } } -static void lib_link_nladata_strips(FileData *fd, ID *id, ListBase *list) +static void lib_link_nladata_strips(BlendLibReader *reader, ID *id, ListBase *list) { NlaStrip *strip; for (strip = list->first; strip; strip = strip->next) { /* check strip's children */ - lib_link_nladata_strips(fd, id, &strip->strips); + lib_link_nladata_strips(reader, id, &strip->strips); /* check strip's F-Curves */ - lib_link_fcurves(fd, id, &strip->fcurves); + lib_link_fcurves(reader, id, &strip->fcurves); /* reassign the counted-reference to action */ - strip->act = newlibadr(fd, id->lib, strip->act); + BLO_read_id_address(reader, id->lib, &strip->act); } } -static void lib_link_nladata(FileData *fd, ID *id, ListBase *list) +static void lib_link_nladata(BlendLibReader *reader, ID *id, ListBase *list) { NlaTrack *nlt; /* we only care about the NLA strips inside the tracks */ for (nlt = list->first; nlt; nlt = nlt->next) { - lib_link_nladata_strips(fd, id, &nlt->strips); + lib_link_nladata_strips(reader, id, &nlt->strips); } } @@ -3395,23 +3394,23 @@ static void direct_link_keyingsets(BlendDataReader *reader, ListBase *list) /* ------- */ -static void lib_link_animdata(FileData *fd, ID *id, AnimData *adt) +static void lib_link_animdata(BlendLibReader *reader, ID *id, AnimData *adt) { if (adt == NULL) { return; } /* link action data */ - adt->action = newlibadr(fd, id->lib, adt->action); - adt->tmpact = newlibadr(fd, id->lib, adt->tmpact); + BLO_read_id_address(reader, id->lib, &adt->action); + BLO_read_id_address(reader, id->lib, &adt->tmpact); /* link drivers */ - lib_link_fcurves(fd, id, &adt->drivers); + lib_link_fcurves(reader, id, &adt->drivers); /* overrides don't have lib-link for now, so no need to do anything */ /* link NLA-data */ - lib_link_nladata(fd, id, &adt->nla_tracks); + lib_link_nladata(reader, id, &adt->nla_tracks); } static void direct_link_animdata(BlendDataReader *reader, AnimData *adt) @@ -3544,19 +3543,19 @@ static void lib_link_workspace_instance_hook(BlendLibReader *reader, /** \name Read ID: Node Tree * \{ */ -static void lib_link_node_socket(FileData *fd, Library *lib, bNodeSocket *sock) +static void lib_link_node_socket(BlendLibReader *reader, Library *lib, bNodeSocket *sock) { - IDP_LibLinkProperty(sock->prop, fd); + IDP_LibLinkProperty(sock->prop, reader->fd); switch ((eNodeSocketDatatype)sock->type) { case SOCK_OBJECT: { bNodeSocketValueObject *default_value = sock->default_value; - default_value->value = newlibadr(fd, lib, default_value->value); + BLO_read_id_address(reader, lib, &default_value->value); break; } case SOCK_IMAGE: { bNodeSocketValueImage *default_value = sock->default_value; - default_value->value = newlibadr(fd, lib, default_value->value); + BLO_read_id_address(reader, lib, &default_value->value); break; } case SOCK_FLOAT: @@ -3576,33 +3575,33 @@ static void lib_link_node_socket(FileData *fd, Library *lib, bNodeSocket *sock) } } -static void lib_link_node_sockets(FileData *fd, Library *lib, ListBase *sockets) +static void lib_link_node_sockets(BlendLibReader *reader, Library *lib, ListBase *sockets) { LISTBASE_FOREACH (bNodeSocket *, sock, sockets) { - lib_link_node_socket(fd, lib, sock); + lib_link_node_socket(reader, lib, sock); } } /* Single node tree (also used for material/scene trees), ntree is not NULL */ -static void lib_link_ntree(FileData *fd, Library *lib, bNodeTree *ntree) +static void lib_link_ntree(BlendLibReader *reader, Library *lib, bNodeTree *ntree) { ntree->id.lib = lib; - ntree->gpd = newlibadr(fd, lib, ntree->gpd); + BLO_read_id_address(reader, lib, &ntree->gpd); LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { /* Link ID Properties -- and copy this comment EXACTLY for easy finding * of library blocks that implement this.*/ - IDP_LibLinkProperty(node->prop, fd); + IDP_LibLinkProperty(node->prop, reader->fd); - node->id = newlibadr(fd, lib, node->id); + BLO_read_id_address(reader, lib, &node->id); - lib_link_node_sockets(fd, lib, &node->inputs); - lib_link_node_sockets(fd, lib, &node->outputs); + lib_link_node_sockets(reader, lib, &node->inputs); + lib_link_node_sockets(reader, lib, &node->outputs); } - lib_link_node_sockets(fd, lib, &ntree->inputs); - lib_link_node_sockets(fd, lib, &ntree->outputs); + lib_link_node_sockets(reader, lib, &ntree->inputs); + lib_link_node_sockets(reader, lib, &ntree->outputs); /* Set node->typeinfo pointers. This is done in lib linking, after the * first versioning that can change types still without functions that @@ -3612,7 +3611,7 @@ static void lib_link_ntree(FileData *fd, Library *lib, bNodeTree *ntree) /* For nodes with static socket layout, add/remove sockets as needed * to match the static layout. */ - if (fd->memfile == NULL) { + if (reader->fd->memfile == NULL) { LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { node_verify_socket_templates(ntree, node); } @@ -3620,9 +3619,9 @@ static void lib_link_ntree(FileData *fd, Library *lib, bNodeTree *ntree) } /* library ntree linking after fileread */ -static void lib_link_nodetree(FileData *fd, Main *UNUSED(bmain), bNodeTree *ntree) +static void lib_link_nodetree(BlendLibReader *reader, bNodeTree *ntree) { - lib_link_ntree(fd, ntree->id.lib, ntree); + lib_link_ntree(reader, ntree->id.lib, ntree); } static void direct_link_node_socket(BlendDataReader *reader, bNodeSocket *sock) @@ -3808,7 +3807,7 @@ static void direct_link_nodetree(BlendDataReader *reader, bNodeTree *ntree) /* temp struct used to transport needed info to lib_link_constraint_cb() */ typedef struct tConstraintLinkData { - FileData *fd; + BlendLibReader *reader; ID *id; } tConstraintLinkData; /* callback function used to relink constraint ID-links */ @@ -3818,10 +3817,10 @@ static void lib_link_constraint_cb(bConstraint *UNUSED(con), void *userdata) { tConstraintLinkData *cld = (tConstraintLinkData *)userdata; - *idpoin = newlibadr(cld->fd, cld->id->lib, *idpoin); + BLO_read_id_address(cld->reader, cld->id->lib, idpoin); } -static void lib_link_constraints(FileData *fd, ID *id, ListBase *conlist) +static void lib_link_constraints(BlendLibReader *reader, ID *id, ListBase *conlist) { tConstraintLinkData cld; bConstraint *con; @@ -3834,7 +3833,7 @@ static void lib_link_constraints(FileData *fd, ID *id, ListBase *conlist) con->type = CONSTRAINT_TYPE_NULL; } /* own ipo, all constraints have it */ - con->ipo = newlibadr(fd, id->lib, con->ipo); // XXX deprecated - old animation system + BLO_read_id_address(reader, id->lib, &con->ipo); // XXX deprecated - old animation system /* If linking from a library, clear 'local' library override flag. */ if (id->lib != NULL) { @@ -3843,7 +3842,7 @@ static void lib_link_constraints(FileData *fd, ID *id, ListBase *conlist) } /* relink all ID-blocks used by the constraints */ - cld.fd = fd; + cld.reader = reader; cld.id = id; BKE_constraints_id_loop(conlist, lib_link_constraint_cb, &cld); @@ -3906,7 +3905,7 @@ static void direct_link_constraints(BlendDataReader *reader, ListBase *lb) } } -static void lib_link_pose(FileData *fd, Main *bmain, Object *ob, bPose *pose) +static void lib_link_pose(BlendLibReader *reader, Object *ob, bPose *pose) { bArmature *arm = ob->data; @@ -3917,7 +3916,7 @@ static void lib_link_pose(FileData *fd, Main *bmain, Object *ob, bPose *pose) /* always rebuild to match proxy or lib changes, but on Undo */ bool rebuild = false; - if (fd->memfile == NULL) { + if (reader->fd->memfile == NULL) { if (ob->proxy || ob->id.lib != arm->id.lib) { rebuild = true; } @@ -3939,13 +3938,13 @@ static void lib_link_pose(FileData *fd, Main *bmain, Object *ob, bPose *pose) } LISTBASE_FOREACH (bPoseChannel *, pchan, &pose->chanbase) { - lib_link_constraints(fd, (ID *)ob, &pchan->constraints); + lib_link_constraints(reader, (ID *)ob, &pchan->constraints); pchan->bone = BKE_armature_find_bone_name(arm, pchan->name); - IDP_LibLinkProperty(pchan->prop, fd); + IDP_LibLinkProperty(pchan->prop, reader->fd); - pchan->custom = newlibadr(fd, arm->id.lib, pchan->custom); + BLO_read_id_address(reader, arm->id.lib, &pchan->custom); if (UNLIKELY(pchan->bone == NULL)) { rebuild = true; } @@ -3958,8 +3957,8 @@ static void lib_link_pose(FileData *fd, Main *bmain, Object *ob, bPose *pose) if (rebuild) { DEG_id_tag_update_ex( - bmain, &ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION); - BKE_pose_tag_recalc(bmain, pose); + reader->main, &ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION); + BKE_pose_tag_recalc(reader->main, pose); } } @@ -4592,31 +4591,31 @@ static void direct_link_pointcache_list(BlendDataReader *reader, } } -static void lib_link_partdeflect(FileData *fd, ID *id, PartDeflect *pd) +static void lib_link_partdeflect(BlendLibReader *reader, ID *id, PartDeflect *pd) { if (pd && pd->tex) { - pd->tex = newlibadr(fd, id->lib, pd->tex); + BLO_read_id_address(reader, id->lib, &pd->tex); } if (pd && pd->f_source) { - pd->f_source = newlibadr(fd, id->lib, pd->f_source); + BLO_read_id_address(reader, id->lib, &pd->f_source); } } -static void lib_link_particlesettings(FileData *fd, Main *UNUSED(bmain), ParticleSettings *part) +static void lib_link_particlesettings(BlendLibReader *reader, ParticleSettings *part) { - part->ipo = newlibadr(fd, part->id.lib, part->ipo); // XXX deprecated - old animation system + BLO_read_id_address(reader, part->id.lib, &part->ipo); // XXX deprecated - old animation system - part->instance_object = newlibadr(fd, part->id.lib, part->instance_object); - part->instance_collection = newlibadr(fd, part->id.lib, part->instance_collection); - part->force_group = newlibadr(fd, part->id.lib, part->force_group); - part->bb_ob = newlibadr(fd, part->id.lib, part->bb_ob); - part->collision_group = newlibadr(fd, part->id.lib, part->collision_group); + BLO_read_id_address(reader, part->id.lib, &part->instance_object); + BLO_read_id_address(reader, part->id.lib, &part->instance_collection); + BLO_read_id_address(reader, part->id.lib, &part->force_group); + BLO_read_id_address(reader, part->id.lib, &part->bb_ob); + BLO_read_id_address(reader, part->id.lib, &part->collision_group); - lib_link_partdeflect(fd, &part->id, part->pd); - lib_link_partdeflect(fd, &part->id, part->pd2); + lib_link_partdeflect(reader, &part->id, part->pd); + lib_link_partdeflect(reader, &part->id, part->pd2); if (part->effector_weights) { - part->effector_weights->group = newlibadr(fd, part->id.lib, part->effector_weights->group); + BLO_read_id_address(reader, part->id.lib, &part->effector_weights->group); } else { part->effector_weights = BKE_effector_add_weights(part->force_group); @@ -4624,7 +4623,7 @@ static void lib_link_particlesettings(FileData *fd, Main *UNUSED(bmain), Particl if (part->instance_weights.first && part->instance_collection) { LISTBASE_FOREACH (ParticleDupliWeight *, dw, &part->instance_weights) { - dw->ob = newlibadr(fd, part->id.lib, dw->ob); + BLO_read_id_address(reader, part->id.lib, &dw->ob); } } else { @@ -4641,12 +4640,12 @@ static void lib_link_particlesettings(FileData *fd, Main *UNUSED(bmain), Particl case eBoidRuleType_Goal: case eBoidRuleType_Avoid: { BoidRuleGoalAvoid *brga = (BoidRuleGoalAvoid *)rule; - brga->ob = newlibadr(fd, part->id.lib, brga->ob); + BLO_read_id_address(reader, part->id.lib, &brga->ob); break; } case eBoidRuleType_FollowLeader: { BoidRuleFollowLeader *brfl = (BoidRuleFollowLeader *)rule; - brfl->ob = newlibadr(fd, part->id.lib, brfl->ob); + BLO_read_id_address(reader, part->id.lib, &brfl->ob); break; } } @@ -4657,8 +4656,8 @@ static void lib_link_particlesettings(FileData *fd, Main *UNUSED(bmain), Particl for (int a = 0; a < MAX_MTEX; a++) { MTex *mtex = part->mtex[a]; if (mtex) { - mtex->tex = newlibadr(fd, part->id.lib, mtex->tex); - mtex->object = newlibadr(fd, part->id.lib, mtex->object); + BLO_read_id_address(reader, part->id.lib, &mtex->tex); + BLO_read_id_address(reader, part->id.lib, &mtex->object); } } } @@ -4723,30 +4722,33 @@ static void direct_link_particlesettings(BlendDataReader *reader, ParticleSettin CLAMP(part->trail_count, 1, 100000); } -static void lib_link_particlesystems(FileData *fd, Object *ob, ID *id, ListBase *particles) +static void lib_link_particlesystems(BlendLibReader *reader, + Object *ob, + ID *id, + ListBase *particles) { ParticleSystem *psys, *psysnext; for (psys = particles->first; psys; psys = psysnext) { psysnext = psys->next; - psys->part = newlibadr(fd, id->lib, psys->part); + BLO_read_id_address(reader, id->lib, &psys->part); if (psys->part) { ParticleTarget *pt = psys->targets.first; for (; pt; pt = pt->next) { - pt->ob = newlibadr(fd, id->lib, pt->ob); + BLO_read_id_address(reader, id->lib, &pt->ob); } - psys->parent = newlibadr(fd, id->lib, psys->parent); - psys->target_ob = newlibadr(fd, id->lib, psys->target_ob); + BLO_read_id_address(reader, id->lib, &psys->parent); + BLO_read_id_address(reader, id->lib, &psys->target_ob); if (psys->clmd) { /* XXX - from reading existing code this seems correct but intended usage of * pointcache /w cloth should be added in 'ParticleSystem' - campbell */ psys->clmd->point_cache = psys->pointcache; psys->clmd->ptcaches.first = psys->clmd->ptcaches.last = NULL; - psys->clmd->coll_parms->group = newlibadr(fd, id->lib, psys->clmd->coll_parms->group); + BLO_read_id_address(reader, id->lib, &psys->clmd->coll_parms->group); psys->clmd->modifier.error = NULL; } } @@ -5114,17 +5116,17 @@ static void direct_link_latt(BlendDataReader *reader, Lattice *lt) static void lib_link_modifiers_common(void *userData, Object *ob, ID **idpoin, int cb_flag) { - FileData *fd = userData; + BlendLibReader *reader = userData; - *idpoin = newlibadr(fd, ob->id.lib, *idpoin); + BLO_read_id_address(reader, ob->id.lib, idpoin); if (*idpoin != NULL && (cb_flag & IDWALK_CB_USER) != 0) { id_us_plus_no_lib(*idpoin); } } -static void lib_link_modifiers(FileData *fd, Object *ob) +static void lib_link_modifiers(BlendLibReader *reader, Object *ob) { - BKE_modifiers_foreach_ID_link(ob, lib_link_modifiers_common, fd); + BKE_modifiers_foreach_ID_link(ob, lib_link_modifiers_common, reader); /* If linking from a library, clear 'local' library override flag. */ if (ob->id.lib != NULL) { @@ -5134,9 +5136,9 @@ static void lib_link_modifiers(FileData *fd, Object *ob) } } -static void lib_link_gpencil_modifiers(FileData *fd, Object *ob) +static void lib_link_gpencil_modifiers(BlendLibReader *reader, Object *ob) { - BKE_gpencil_modifiers_foreach_ID_link(ob, lib_link_modifiers_common, fd); + BKE_gpencil_modifiers_foreach_ID_link(ob, lib_link_modifiers_common, reader); /* If linking from a library, clear 'local' library override flag. */ if (ob->id.lib != NULL) { @@ -5147,9 +5149,9 @@ static void lib_link_gpencil_modifiers(FileData *fd, Object *ob) } } -static void lib_link_shaderfxs(FileData *fd, Object *ob) +static void lib_link_shaderfxs(BlendLibReader *reader, Object *ob) { - BKE_shaderfx_foreach_ID_link(ob, lib_link_modifiers_common, fd); + BKE_shaderfx_foreach_ID_link(ob, lib_link_modifiers_common, reader); /* If linking from a library, clear 'local' library override flag. */ if (ob->id.lib != NULL) { @@ -5159,28 +5161,28 @@ static void lib_link_shaderfxs(FileData *fd, Object *ob) } } -static void lib_link_object(FileData *fd, Main *bmain, Object *ob) +static void lib_link_object(BlendLibReader *reader, Object *ob) { bool warn = false; int a; // XXX deprecated - old animation system <<< - ob->ipo = newlibadr(fd, ob->id.lib, ob->ipo); - ob->action = newlibadr(fd, ob->id.lib, ob->action); + BLO_read_id_address(reader, ob->id.lib, &ob->ipo); + BLO_read_id_address(reader, ob->id.lib, &ob->action); // >>> XXX deprecated - old animation system - ob->parent = newlibadr(fd, ob->id.lib, ob->parent); - ob->track = newlibadr(fd, ob->id.lib, ob->track); - ob->poselib = newlibadr(fd, ob->id.lib, ob->poselib); + BLO_read_id_address(reader, ob->id.lib, &ob->parent); + BLO_read_id_address(reader, ob->id.lib, &ob->track); + BLO_read_id_address(reader, ob->id.lib, &ob->poselib); /* 2.8x drops support for non-empty dupli instances. */ if (ob->type == OB_EMPTY) { - ob->instance_collection = newlibadr(fd, ob->id.lib, ob->instance_collection); + BLO_read_id_address(reader, ob->id.lib, &ob->instance_collection); } else { if (ob->instance_collection != NULL) { - ID *id = newlibadr(fd, ob->id.lib, ob->instance_collection); - blo_reportf_wrap(fd->reports, + ID *id = BLO_read_get_new_id_address(reader, ob->id.lib, &ob->instance_collection->id); + blo_reportf_wrap(reader->fd->reports, RPT_WARNING, TIP_("Non-Empty object '%s' cannot duplicate collection '%s' " "anymore in Blender 2.80, removed instancing"), @@ -5191,7 +5193,7 @@ static void lib_link_object(FileData *fd, Main *bmain, Object *ob) ob->transflag &= ~OB_DUPLICOLLECTION; } - ob->proxy = newlibadr(fd, ob->id.lib, ob->proxy); + BLO_read_id_address(reader, ob->id.lib, &ob->proxy); if (ob->proxy) { /* paranoia check, actually a proxy_from pointer should never be written... */ if (ob->proxy->id.lib == NULL) { @@ -5210,10 +5212,10 @@ static void lib_link_object(FileData *fd, Main *bmain, Object *ob) ob->proxy->proxy_from = ob; } } - ob->proxy_group = newlibadr(fd, ob->id.lib, ob->proxy_group); + BLO_read_id_address(reader, ob->id.lib, &ob->proxy_group); void *poin = ob->data; - ob->data = newlibadr(fd, ob->id.lib, ob->data); + BLO_read_id_address(reader, ob->id.lib, &ob->data); if (ob->data == NULL && poin != NULL) { if (ob->id.lib) { @@ -5242,7 +5244,7 @@ static void lib_link_object(FileData *fd, Main *bmain, Object *ob) } } for (a = 0; a < ob->totcol; a++) { - ob->mat[a] = newlibadr(fd, ob->id.lib, ob->mat[a]); + BLO_read_id_address(reader, ob->id.lib, &ob->mat[a]); } /* When the object is local and the data is library its possible @@ -5252,26 +5254,26 @@ static void lib_link_object(FileData *fd, Main *bmain, Object *ob) /* Only expand so as not to loose any object materials that might be set. */ if (totcol_data && (*totcol_data > ob->totcol)) { /* printf("'%s' %d -> %d\n", ob->id.name, ob->totcol, *totcol_data); */ - BKE_object_material_resize(bmain, ob, *totcol_data, false); + BKE_object_material_resize(reader->main, ob, *totcol_data, false); } } - ob->gpd = newlibadr(fd, ob->id.lib, ob->gpd); + BLO_read_id_address(reader, ob->id.lib, &ob->gpd); /* if id.us==0 a new base will be created later on */ /* WARNING! Also check expand_object(), should reflect the stuff below. */ - lib_link_pose(fd, bmain, ob, ob->pose); - lib_link_constraints(fd, &ob->id, &ob->constraints); + lib_link_pose(reader, ob, ob->pose); + lib_link_constraints(reader, &ob->id, &ob->constraints); // XXX deprecated - old animation system <<< - lib_link_constraint_channels(fd, &ob->id, &ob->constraintChannels); - lib_link_nlastrips(fd, &ob->id, &ob->nlastrips); + lib_link_constraint_channels(reader, &ob->id, &ob->constraintChannels); + lib_link_nlastrips(reader, &ob->id, &ob->nlastrips); // >>> XXX deprecated - old animation system LISTBASE_FOREACH (PartEff *, paf, &ob->effect) { if (paf->type == EFF_PARTICLE) { - paf->group = newlibadr(fd, ob->id.lib, paf->group); + BLO_read_id_address(reader, ob->id.lib, &paf->group); } } @@ -5280,8 +5282,8 @@ static void lib_link_object(FileData *fd, Main *bmain, Object *ob) ob, eModifierType_Fluidsim); if (fluidmd && fluidmd->fss) { - fluidmd->fss->ipo = newlibadr( - fd, ob->id.lib, fluidmd->fss->ipo); // XXX deprecated - old animation system + BLO_read_id_address( + reader, ob->id.lib, &fluidmd->fss->ipo); // XXX deprecated - old animation system } } @@ -5303,30 +5305,29 @@ static void lib_link_object(FileData *fd, Main *bmain, Object *ob) /* texture field */ if (ob->pd) { - lib_link_partdeflect(fd, &ob->id, ob->pd); + lib_link_partdeflect(reader, &ob->id, ob->pd); } if (ob->soft) { - ob->soft->collision_group = newlibadr(fd, ob->id.lib, ob->soft->collision_group); + BLO_read_id_address(reader, ob->id.lib, &ob->soft->collision_group); - ob->soft->effector_weights->group = newlibadr( - fd, ob->id.lib, ob->soft->effector_weights->group); + BLO_read_id_address(reader, ob->id.lib, &ob->soft->effector_weights->group); } - lib_link_particlesystems(fd, ob, &ob->id, &ob->particlesystem); - lib_link_modifiers(fd, ob); - lib_link_gpencil_modifiers(fd, ob); - lib_link_shaderfxs(fd, ob); + lib_link_particlesystems(reader, ob, &ob->id, &ob->particlesystem); + lib_link_modifiers(reader, ob); + lib_link_gpencil_modifiers(reader, ob); + lib_link_shaderfxs(reader, ob); if (ob->rigidbody_constraint) { - ob->rigidbody_constraint->ob1 = newlibadr(fd, ob->id.lib, ob->rigidbody_constraint->ob1); - ob->rigidbody_constraint->ob2 = newlibadr(fd, ob->id.lib, ob->rigidbody_constraint->ob2); + BLO_read_id_address(reader, ob->id.lib, &ob->rigidbody_constraint->ob1); + BLO_read_id_address(reader, ob->id.lib, &ob->rigidbody_constraint->ob2); } { LodLevel *level; for (level = ob->lodlevels.first; level; level = level->next) { - level->source = newlibadr(fd, ob->id.lib, level->source); + BLO_read_id_address(reader, ob->id.lib, &level->source); if (!level->source && level == ob->lodlevels.first) { level->source = ob; @@ -5335,7 +5336,7 @@ static void lib_link_object(FileData *fd, Main *bmain, Object *ob) } if (warn) { - BKE_report(fd->reports, RPT_WARNING, "Warning in console"); + BKE_report(reader->fd->reports, RPT_WARNING, "Warning in console"); } } @@ -8591,7 +8592,7 @@ static void lib_link_mask(BlendLibReader *reader, Mask *mask) /** \name Read ID: Line Style * \{ */ -static void lib_link_linestyle(FileData *fd, Main *UNUSED(bmain), FreestyleLineStyle *linestyle) +static void lib_link_linestyle(BlendLibReader *reader, FreestyleLineStyle *linestyle) { LineStyleModifier *m; @@ -8600,7 +8601,7 @@ static void lib_link_linestyle(FileData *fd, Main *UNUSED(bmain), FreestyleLineS case LS_MODIFIER_DISTANCE_FROM_OBJECT: { LineStyleColorModifier_DistanceFromObject *cm = (LineStyleColorModifier_DistanceFromObject *)m; - cm->target = newlibadr(fd, linestyle->id.lib, cm->target); + BLO_read_id_address(reader, linestyle->id.lib, &cm->target); break; } } @@ -8610,7 +8611,7 @@ static void lib_link_linestyle(FileData *fd, Main *UNUSED(bmain), FreestyleLineS case LS_MODIFIER_DISTANCE_FROM_OBJECT: { LineStyleAlphaModifier_DistanceFromObject *am = (LineStyleAlphaModifier_DistanceFromObject *)m; - am->target = newlibadr(fd, linestyle->id.lib, am->target); + BLO_read_id_address(reader, linestyle->id.lib, &am->target); break; } } @@ -8620,7 +8621,7 @@ static void lib_link_linestyle(FileData *fd, Main *UNUSED(bmain), FreestyleLineS case LS_MODIFIER_DISTANCE_FROM_OBJECT: { LineStyleThicknessModifier_DistanceFromObject *tm = (LineStyleThicknessModifier_DistanceFromObject *)m; - tm->target = newlibadr(fd, linestyle->id.lib, tm->target); + BLO_read_id_address(reader, linestyle->id.lib, &tm->target); break; } } @@ -8628,8 +8629,8 @@ static void lib_link_linestyle(FileData *fd, Main *UNUSED(bmain), FreestyleLineS for (int a = 0; a < MAX_MTEX; a++) { MTex *mtex = linestyle->mtex[a]; if (mtex) { - mtex->tex = newlibadr(fd, linestyle->id.lib, mtex->tex); - mtex->object = newlibadr(fd, linestyle->id.lib, mtex->object); + BLO_read_id_address(reader, linestyle->id.lib, &mtex->tex); + BLO_read_id_address(reader, linestyle->id.lib, &mtex->object); } } } @@ -9787,7 +9788,7 @@ static void lib_link_all(FileData *fd, Main *bmain) continue; } - lib_link_id(fd, bmain, id); + lib_link_id(&reader, id); /* Note: ID types are processed in reverse order as defined by INDEX_ID_XXX enums in DNA_ID.h. * This ensures handling of most dependencies in proper order, as elsewhere in code. @@ -9808,10 +9809,10 @@ static void lib_link_all(FileData *fd, Main *bmain) lib_link_scene(&reader, (Scene *)id); break; case ID_LS: - lib_link_linestyle(fd, bmain, (FreestyleLineStyle *)id); + lib_link_linestyle(&reader, (FreestyleLineStyle *)id); break; case ID_OB: - lib_link_object(fd, bmain, (Object *)id); + lib_link_object(&reader, (Object *)id); break; case ID_SCR: /* DO NOT skip screens here, @@ -9831,7 +9832,7 @@ static void lib_link_all(FileData *fd, Main *bmain) lib_link_speaker(fd, bmain, (Speaker *)id); break; case ID_PA: - lib_link_particlesettings(fd, bmain, (ParticleSettings *)id); + lib_link_particlesettings(&reader, (ParticleSettings *)id); break; case ID_PC: lib_link_paint_curve(fd, bmain, (PaintCurve *)id); @@ -9895,7 +9896,7 @@ static void lib_link_all(FileData *fd, Main *bmain) break; case ID_NT: /* Has to be done after node users (scene/materials/...), this will verify group nodes. */ - lib_link_nodetree(fd, bmain, (bNodeTree *)id); + lib_link_nodetree(&reader, (bNodeTree *)id); break; case ID_GD: lib_link_gpencil(fd, bmain, (bGPdata *)id); @@ -9907,7 +9908,7 @@ static void lib_link_all(FileData *fd, Main *bmain) lib_link_key(fd, bmain, (Key *)id); break; case ID_AC: - lib_link_action(fd, bmain, (bAction *)id); + lib_link_action(&reader, (bAction *)id); break; case ID_SIM: lib_link_simulation(fd, bmain, (Simulation *)id); -- cgit v1.2.3 From 9ec6b69ed15677107a34bd6c7d87f7101652f961 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Fri, 26 Jun 2020 15:05:25 +0200 Subject: Refactor: use new api for lib linking movieclip, world, lightprobe, speaker, paint curve and brush --- source/blender/blenloader/intern/readfile.c | 63 +++++++++++++++-------------- 1 file changed, 32 insertions(+), 31 deletions(-) (limited to 'source/blender/blenloader') diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 56afbad40c0..122b978fc41 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -2887,20 +2887,19 @@ static void direct_link_id_common( * \{ */ /* library brush linking after fileread */ -static void lib_link_brush(FileData *fd, Main *UNUSED(bmain), Brush *brush) +static void lib_link_brush(BlendLibReader *reader, Brush *brush) { /* brush->(mask_)mtex.obj is ignored on purpose? */ - brush->mtex.tex = newlibadr(fd, brush->id.lib, brush->mtex.tex); - brush->mask_mtex.tex = newlibadr(fd, brush->id.lib, brush->mask_mtex.tex); - brush->clone.image = newlibadr(fd, brush->id.lib, brush->clone.image); - brush->toggle_brush = newlibadr(fd, brush->id.lib, brush->toggle_brush); - brush->paint_curve = newlibadr(fd, brush->id.lib, brush->paint_curve); + BLO_read_id_address(reader, brush->id.lib, &brush->mtex.tex); + BLO_read_id_address(reader, brush->id.lib, &brush->mask_mtex.tex); + BLO_read_id_address(reader, brush->id.lib, &brush->clone.image); + BLO_read_id_address(reader, brush->id.lib, &brush->toggle_brush); + BLO_read_id_address(reader, brush->id.lib, &brush->paint_curve); /* link default grease pencil palette */ if (brush->gpencil_settings != NULL) { if (brush->gpencil_settings->flag & GP_BRUSH_MATERIAL_PINNED) { - brush->gpencil_settings->material = newlibadr( - fd, brush->id.lib, brush->gpencil_settings->material); + BLO_read_id_address(reader, brush->id.lib, &brush->gpencil_settings->material); if (!brush->gpencil_settings->material) { brush->gpencil_settings->flag &= ~GP_BRUSH_MATERIAL_PINNED; @@ -3000,7 +2999,7 @@ static void direct_link_palette(BlendDataReader *reader, Palette *palette) BLO_read_list(reader, &palette->colors); } -static void lib_link_paint_curve(FileData *UNUSED(fd), Main *UNUSED(bmain), PaintCurve *UNUSED(pc)) +static void lib_link_paint_curve(BlendLibReader *UNUSED(reader), PaintCurve *UNUSED(pc)) { } @@ -4189,9 +4188,9 @@ static void direct_link_mball(BlendDataReader *reader, MetaBall *mb) /** \name Read ID: World * \{ */ -static void lib_link_world(FileData *fd, Main *UNUSED(bmain), World *wrld) +static void lib_link_world(BlendLibReader *reader, World *wrld) { - wrld->ipo = newlibadr(fd, wrld->id.lib, wrld->ipo); // XXX deprecated - old animation system + BLO_read_id_address(reader, wrld->id.lib, &wrld->ipo); // XXX deprecated - old animation system } static void direct_link_world(BlendDataReader *reader, World *wrld) @@ -8299,9 +8298,9 @@ static void fix_relpaths_library(const char *basepath, Main *main) /** \name Read ID: Light Probe * \{ */ -static void lib_link_lightprobe(FileData *fd, Main *UNUSED(bmain), LightProbe *prb) +static void lib_link_lightprobe(BlendLibReader *reader, LightProbe *prb) { - prb->visibility_grp = newlibadr(fd, prb->id.lib, prb->visibility_grp); + BLO_read_id_address(reader, prb->id.lib, &prb->visibility_grp); } static void direct_link_lightprobe(BlendDataReader *reader, LightProbe *prb) @@ -8316,9 +8315,9 @@ static void direct_link_lightprobe(BlendDataReader *reader, LightProbe *prb) /** \name Read ID: Speaker * \{ */ -static void lib_link_speaker(FileData *fd, Main *UNUSED(bmain), Speaker *spk) +static void lib_link_speaker(BlendLibReader *reader, Speaker *spk) { - spk->sound = newlibadr(fd, spk->id.lib, spk->sound); + BLO_read_id_address(reader, spk->id.lib, &spk->sound); } static void direct_link_speaker(BlendDataReader *reader, Speaker *spk) @@ -8462,36 +8461,38 @@ static void direct_link_movieclip(BlendDataReader *reader, MovieClip *clip) } } -static void lib_link_movieTracks(FileData *fd, MovieClip *clip, ListBase *tracksbase) +static void lib_link_movieTracks(BlendLibReader *reader, MovieClip *clip, ListBase *tracksbase) { MovieTrackingTrack *track; for (track = tracksbase->first; track; track = track->next) { - track->gpd = newlibadr(fd, clip->id.lib, track->gpd); + BLO_read_id_address(reader, clip->id.lib, &track->gpd); } } -static void lib_link_moviePlaneTracks(FileData *fd, MovieClip *clip, ListBase *tracksbase) +static void lib_link_moviePlaneTracks(BlendLibReader *reader, + MovieClip *clip, + ListBase *tracksbase) { MovieTrackingPlaneTrack *plane_track; for (plane_track = tracksbase->first; plane_track; plane_track = plane_track->next) { - plane_track->image = newlibadr(fd, clip->id.lib, plane_track->image); + BLO_read_id_address(reader, clip->id.lib, &plane_track->image); } } -static void lib_link_movieclip(FileData *fd, Main *UNUSED(bmain), MovieClip *clip) +static void lib_link_movieclip(BlendLibReader *reader, MovieClip *clip) { MovieTracking *tracking = &clip->tracking; - clip->gpd = newlibadr(fd, clip->id.lib, clip->gpd); + BLO_read_id_address(reader, clip->id.lib, &clip->gpd); - lib_link_movieTracks(fd, clip, &tracking->tracks); - lib_link_moviePlaneTracks(fd, clip, &tracking->plane_tracks); + lib_link_movieTracks(reader, clip, &tracking->tracks); + lib_link_moviePlaneTracks(reader, clip, &tracking->plane_tracks); LISTBASE_FOREACH (MovieTrackingObject *, object, &tracking->objects) { - lib_link_movieTracks(fd, clip, &object->tracks); - lib_link_moviePlaneTracks(fd, clip, &object->plane_tracks); + lib_link_movieTracks(reader, clip, &object->tracks); + lib_link_moviePlaneTracks(reader, clip, &object->plane_tracks); } } @@ -9820,25 +9821,25 @@ static void lib_link_all(FileData *fd, Main *bmain) lib_link_screen(&reader, (bScreen *)id); break; case ID_MC: - lib_link_movieclip(fd, bmain, (MovieClip *)id); + lib_link_movieclip(&reader, (MovieClip *)id); break; case ID_WO: - lib_link_world(fd, bmain, (World *)id); + lib_link_world(&reader, (World *)id); break; case ID_LP: - lib_link_lightprobe(fd, bmain, (LightProbe *)id); + lib_link_lightprobe(&reader, (LightProbe *)id); break; case ID_SPK: - lib_link_speaker(fd, bmain, (Speaker *)id); + lib_link_speaker(&reader, (Speaker *)id); break; case ID_PA: lib_link_particlesettings(&reader, (ParticleSettings *)id); break; case ID_PC: - lib_link_paint_curve(fd, bmain, (PaintCurve *)id); + lib_link_paint_curve(&reader, (PaintCurve *)id); break; case ID_BR: - lib_link_brush(fd, bmain, (Brush *)id); + lib_link_brush(&reader, (Brush *)id); break; case ID_GR: lib_link_collection(&reader, (Collection *)id); -- cgit v1.2.3 From 65f07a39b5cd1ccd3bf322379521750a3320d707 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Fri, 26 Jun 2020 15:24:20 +0200 Subject: Refactor: use new api for lib linking sound, text, camera, light, latt and mball --- source/blender/blenloader/intern/readfile.c | 47 +++++++++++++++-------------- 1 file changed, 24 insertions(+), 23 deletions(-) (limited to 'source/blender/blenloader') diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 122b978fc41..a391e9e9dd8 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -4026,16 +4026,16 @@ static void direct_link_armature(BlendDataReader *reader, bArmature *arm) /** \name Read ID: Camera * \{ */ -static void lib_link_camera(FileData *fd, Main *UNUSED(bmain), Camera *ca) +static void lib_link_camera(BlendLibReader *reader, Camera *ca) { - ca->ipo = newlibadr(fd, ca->id.lib, ca->ipo); /* deprecated, for versioning */ + BLO_read_id_address(reader, ca->id.lib, &ca->ipo); /* deprecated, for versioning */ - ca->dof_ob = newlibadr(fd, ca->id.lib, ca->dof_ob); /* deprecated, for versioning */ - ca->dof.focus_object = newlibadr(fd, ca->id.lib, ca->dof.focus_object); + BLO_read_id_address(reader, ca->id.lib, &ca->dof_ob); /* deprecated, for versioning */ + BLO_read_id_address(reader, ca->id.lib, &ca->dof.focus_object); LISTBASE_FOREACH (CameraBGImage *, bgpic, &ca->bg_images) { - bgpic->ima = newlibadr(fd, ca->id.lib, bgpic->ima); - bgpic->clip = newlibadr(fd, ca->id.lib, bgpic->clip); + BLO_read_id_address(reader, ca->id.lib, &bgpic->ima); + BLO_read_id_address(reader, ca->id.lib, &bgpic->clip); } } @@ -4058,9 +4058,9 @@ static void direct_link_camera(BlendDataReader *reader, Camera *ca) /** \name Read ID: Light * \{ */ -static void lib_link_light(FileData *fd, Main *UNUSED(bmain), Light *la) +static void lib_link_light(BlendLibReader *reader, Light *la) { - la->ipo = newlibadr(fd, la->id.lib, la->ipo); // XXX deprecated - old animation system + BLO_read_id_address(reader, la->id.lib, &la->ipo); // XXX deprecated - old animation system } static void direct_link_light(BlendDataReader *reader, Light *la) @@ -4155,13 +4155,13 @@ static void direct_link_key(BlendDataReader *reader, Key *key) /** \name Read ID: Meta Ball * \{ */ -static void lib_link_mball(FileData *fd, Main *UNUSED(bmain), MetaBall *mb) +static void lib_link_mball(BlendLibReader *reader, MetaBall *mb) { for (int a = 0; a < mb->totcol; a++) { - mb->mat[a] = newlibadr(fd, mb->id.lib, mb->mat[a]); + BLO_read_id_address(reader, mb->id.lib, &mb->mat[a]); } - mb->ipo = newlibadr(fd, mb->id.lib, mb->ipo); // XXX deprecated - old animation system + BLO_read_id_address(reader, mb->id.lib, &mb->ipo); // XXX deprecated - old animation system } static void direct_link_mball(BlendDataReader *reader, MetaBall *mb) @@ -4225,7 +4225,7 @@ static void direct_link_vfont(BlendDataReader *reader, VFont *vf) /** \name Read ID: Text * \{ */ -static void lib_link_text(FileData *UNUSED(fd), Main *UNUSED(bmain), Text *UNUSED(text)) +static void lib_link_text(BlendLibReader *UNUSED(reader), Text *UNUSED(text)) { } @@ -5087,10 +5087,10 @@ static void direct_link_mesh(BlendDataReader *reader, Mesh *mesh) /** \name Read ID: Lattice * \{ */ -static void lib_link_latt(FileData *fd, Main *UNUSED(bmain), Lattice *lt) +static void lib_link_latt(BlendLibReader *reader, Lattice *lt) { - lt->ipo = newlibadr(fd, lt->id.lib, lt->ipo); // XXX deprecated - old animation system - lt->key = newlibadr(fd, lt->id.lib, lt->key); + BLO_read_id_address(reader, lt->id.lib, <->ipo); // XXX deprecated - old animation system + BLO_read_id_address(reader, lt->id.lib, <->key); } static void direct_link_latt(BlendDataReader *reader, Lattice *lt) @@ -8367,9 +8367,10 @@ static void direct_link_sound(BlendDataReader *reader, bSound *sound) sound->newpackedfile = direct_link_packedfile(reader, sound->newpackedfile); } -static void lib_link_sound(FileData *fd, Main *UNUSED(bmain), bSound *sound) +static void lib_link_sound(BlendLibReader *reader, bSound *sound) { - sound->ipo = newlibadr(fd, sound->id.lib, sound->ipo); // XXX deprecated - old animation system + BLO_read_id_address( + reader, sound->id.lib, &sound->ipo); // XXX deprecated - old animation system } /** \} */ @@ -9845,22 +9846,22 @@ static void lib_link_all(FileData *fd, Main *bmain) lib_link_collection(&reader, (Collection *)id); break; case ID_SO: - lib_link_sound(fd, bmain, (bSound *)id); + lib_link_sound(&reader, (bSound *)id); break; case ID_TXT: - lib_link_text(fd, bmain, (Text *)id); + lib_link_text(&reader, (Text *)id); break; case ID_CA: - lib_link_camera(fd, bmain, (Camera *)id); + lib_link_camera(&reader, (Camera *)id); break; case ID_LA: - lib_link_light(fd, bmain, (Light *)id); + lib_link_light(&reader, (Light *)id); break; case ID_LT: - lib_link_latt(fd, bmain, (Lattice *)id); + lib_link_latt(&reader, (Lattice *)id); break; case ID_MB: - lib_link_mball(fd, bmain, (MetaBall *)id); + lib_link_mball(&reader, (MetaBall *)id); break; case ID_CU: lib_link_curve(fd, bmain, (Curve *)id); -- cgit v1.2.3 From 96d657cb84e387cd8ec3666a9f2048d2c173c277 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Fri, 26 Jun 2020 15:30:19 +0200 Subject: Refactor: use new api for lib linking curve, mesh, cachefiles, armature and vfont --- source/blender/blenloader/intern/readfile.c | 58 ++++++++++++++--------------- 1 file changed, 28 insertions(+), 30 deletions(-) (limited to 'source/blender/blenloader') diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index a391e9e9dd8..7f71844770f 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -3447,9 +3447,7 @@ static void direct_link_animdata(BlendDataReader *reader, AnimData *adt) /** \name Read ID: CacheFiles * \{ */ -static void lib_link_cachefiles(FileData *UNUSED(fd), - Main *UNUSED(bmain), - CacheFile *UNUSED(cache_file)) +static void lib_link_cachefiles(BlendLibReader *UNUSED(reader), CacheFile *UNUSED(cache_file)) { } @@ -3961,19 +3959,19 @@ static void lib_link_pose(BlendLibReader *reader, Object *ob, bPose *pose) } } -static void lib_link_bones(FileData *fd, Bone *bone) +static void lib_link_bones(BlendLibReader *reader, Bone *bone) { - IDP_LibLinkProperty(bone->prop, fd); + IDP_LibLinkProperty(bone->prop, reader->fd); LISTBASE_FOREACH (Bone *, curbone, &bone->childbase) { - lib_link_bones(fd, curbone); + lib_link_bones(reader, curbone); } } -static void lib_link_armature(FileData *fd, Main *UNUSED(bmain), bArmature *arm) +static void lib_link_armature(BlendLibReader *reader, bArmature *arm) { LISTBASE_FOREACH (Bone *, curbone, &arm->bonebase) { - lib_link_bones(fd, curbone); + lib_link_bones(reader, curbone); } } @@ -4208,7 +4206,7 @@ static void direct_link_world(BlendDataReader *reader, World *wrld) /** \name Read ID: VFont * \{ */ -static void lib_link_vfont(FileData *UNUSED(fd), Main *UNUSED(bmain), VFont *UNUSED(vf)) +static void lib_link_vfont(BlendLibReader *UNUSED(reader), VFont *UNUSED(vf)) { } @@ -4349,22 +4347,22 @@ static void direct_link_image(BlendDataReader *reader, Image *ima) /** \name Read ID: Curve * \{ */ -static void lib_link_curve(FileData *fd, Main *UNUSED(bmain), Curve *cu) +static void lib_link_curve(BlendLibReader *reader, Curve *cu) { for (int a = 0; a < cu->totcol; a++) { - cu->mat[a] = newlibadr(fd, cu->id.lib, cu->mat[a]); + BLO_read_id_address(reader, cu->id.lib, &cu->mat[a]); } - cu->bevobj = newlibadr(fd, cu->id.lib, cu->bevobj); - cu->taperobj = newlibadr(fd, cu->id.lib, cu->taperobj); - cu->textoncurve = newlibadr(fd, cu->id.lib, cu->textoncurve); - cu->vfont = newlibadr(fd, cu->id.lib, cu->vfont); - cu->vfontb = newlibadr(fd, cu->id.lib, cu->vfontb); - cu->vfonti = newlibadr(fd, cu->id.lib, cu->vfonti); - cu->vfontbi = newlibadr(fd, cu->id.lib, cu->vfontbi); + BLO_read_id_address(reader, cu->id.lib, &cu->bevobj); + BLO_read_id_address(reader, cu->id.lib, &cu->taperobj); + BLO_read_id_address(reader, cu->id.lib, &cu->textoncurve); + BLO_read_id_address(reader, cu->id.lib, &cu->vfont); + BLO_read_id_address(reader, cu->id.lib, &cu->vfontb); + BLO_read_id_address(reader, cu->id.lib, &cu->vfonti); + BLO_read_id_address(reader, cu->id.lib, &cu->vfontbi); - cu->ipo = newlibadr(fd, cu->id.lib, cu->ipo); // XXX deprecated - old animation system - cu->key = newlibadr(fd, cu->id.lib, cu->key); + BLO_read_id_address(reader, cu->id.lib, &cu->ipo); // XXX deprecated - old animation system + BLO_read_id_address(reader, cu->id.lib, &cu->key); } static void switch_endian_knots(Nurb *nu) @@ -4858,21 +4856,21 @@ static void direct_link_particlesystems(BlendDataReader *reader, ListBase *parti /** \name Read ID: Mesh * \{ */ -static void lib_link_mesh(FileData *fd, Main *UNUSED(bmain), Mesh *me) +static void lib_link_mesh(BlendLibReader *reader, Mesh *me) { /* this check added for python created meshes */ if (me->mat) { for (int i = 0; i < me->totcol; i++) { - me->mat[i] = newlibadr(fd, me->id.lib, me->mat[i]); + BLO_read_id_address(reader, me->id.lib, &me->mat[i]); } } else { me->totcol = 0; } - me->ipo = newlibadr(fd, me->id.lib, me->ipo); // XXX: deprecated: old anim sys - me->key = newlibadr(fd, me->id.lib, me->key); - me->texcomesh = newlibadr(fd, me->id.lib, me->texcomesh); + BLO_read_id_address(reader, me->id.lib, &me->ipo); // XXX: deprecated: old anim sys + BLO_read_id_address(reader, me->id.lib, &me->key); + BLO_read_id_address(reader, me->id.lib, &me->texcomesh); } static void direct_link_dverts(BlendDataReader *reader, int count, MDeformVert *mdverts) @@ -9864,19 +9862,19 @@ static void lib_link_all(FileData *fd, Main *bmain) lib_link_mball(&reader, (MetaBall *)id); break; case ID_CU: - lib_link_curve(fd, bmain, (Curve *)id); + lib_link_curve(&reader, (Curve *)id); break; case ID_ME: - lib_link_mesh(fd, bmain, (Mesh *)id); + lib_link_mesh(&reader, (Mesh *)id); break; case ID_CF: - lib_link_cachefiles(fd, bmain, (CacheFile *)id); + lib_link_cachefiles(&reader, (CacheFile *)id); break; case ID_AR: - lib_link_armature(fd, bmain, (bArmature *)id); + lib_link_armature(&reader, (bArmature *)id); break; case ID_VF: - lib_link_vfont(fd, bmain, (VFont *)id); + lib_link_vfont(&reader, (VFont *)id); break; case ID_HA: lib_link_hair(fd, bmain, (Hair *)id); -- cgit v1.2.3 From 14e313bbb200411b6c6ce7f8d90734b58b6cfefd Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Fri, 26 Jun 2020 15:38:50 +0200 Subject: Refactor: use new api for lib linking hair, pointclout, volume, material, texture and image --- source/blender/blenloader/intern/readfile.c | 40 ++++++++++++++--------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'source/blender/blenloader') diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 7f71844770f..b28aa386bfc 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -4268,7 +4268,7 @@ static void direct_link_text(BlendDataReader *reader, Text *text) /** \name Read ID: Image * \{ */ -static void lib_link_image(FileData *UNUSED(fd), Main *UNUSED(bmain), Image *UNUSED(ima)) +static void lib_link_image(BlendLibReader *UNUSED(reader), Image *UNUSED(ima)) { } @@ -4441,10 +4441,10 @@ static void direct_link_curve(BlendDataReader *reader, Curve *cu) /** \name Read ID: Texture * \{ */ -static void lib_link_texture(FileData *fd, Main *UNUSED(bmain), Tex *tex) +static void lib_link_texture(BlendLibReader *reader, Tex *tex) { - tex->ima = newlibadr(fd, tex->id.lib, tex->ima); - tex->ipo = newlibadr(fd, tex->id.lib, tex->ipo); // XXX deprecated - old animation system + BLO_read_id_address(reader, tex->id.lib, &tex->ima); + BLO_read_id_address(reader, tex->id.lib, &tex->ipo); // XXX deprecated - old animation system } static void direct_link_texture(BlendDataReader *reader, Tex *tex) @@ -4466,18 +4466,18 @@ static void direct_link_texture(BlendDataReader *reader, Tex *tex) /** \name Read ID: Material * \{ */ -static void lib_link_material(FileData *fd, Main *UNUSED(bmain), Material *ma) +static void lib_link_material(BlendLibReader *reader, Material *ma) { - ma->ipo = newlibadr(fd, ma->id.lib, ma->ipo); // XXX deprecated - old animation system + BLO_read_id_address(reader, ma->id.lib, &ma->ipo); // XXX deprecated - old animation system /* relink grease pencil settings */ if (ma->gp_style != NULL) { MaterialGPencilStyle *gp_style = ma->gp_style; if (gp_style->sima != NULL) { - gp_style->sima = newlibadr(fd, ma->id.lib, gp_style->sima); + BLO_read_id_address(reader, ma->id.lib, &gp_style->sima); } if (gp_style->ima != NULL) { - gp_style->ima = newlibadr(fd, ma->id.lib, gp_style->ima); + BLO_read_id_address(reader, ma->id.lib, &gp_style->ima); } } } @@ -8834,10 +8834,10 @@ static void direct_link_linestyle(BlendDataReader *reader, FreestyleLineStyle *l /** \name Read ID: Hair * \{ */ -static void lib_link_hair(FileData *fd, Main *UNUSED(main), Hair *hair) +static void lib_link_hair(BlendLibReader *reader, Hair *hair) { for (int a = 0; a < hair->totcol; a++) { - hair->mat[a] = newlibadr(fd, hair->id.lib, hair->mat[a]); + BLO_read_id_address(reader, hair->id.lib, &hair->mat[a]); } } @@ -8861,10 +8861,10 @@ static void direct_link_hair(BlendDataReader *reader, Hair *hair) /** \name Read ID: Point Cloud * \{ */ -static void lib_link_pointcloud(FileData *fd, Main *UNUSED(main), PointCloud *pointcloud) +static void lib_link_pointcloud(BlendLibReader *reader, PointCloud *pointcloud) { for (int a = 0; a < pointcloud->totcol; a++) { - pointcloud->mat[a] = newlibadr(fd, pointcloud->id.lib, pointcloud->mat[a]); + BLO_read_id_address(reader, pointcloud->id.lib, &pointcloud->mat[a]); } } @@ -8887,10 +8887,10 @@ static void direct_link_pointcloud(BlendDataReader *reader, PointCloud *pointclo /** \name Read ID: Volume * \{ */ -static void lib_link_volume(FileData *fd, Main *UNUSED(main), Volume *volume) +static void lib_link_volume(BlendLibReader *reader, Volume *volume) { for (int a = 0; a < volume->totcol; a++) { - volume->mat[a] = newlibadr(fd, volume->id.lib, volume->mat[a]); + BLO_read_id_address(reader, volume->id.lib, &volume->mat[a]); } } @@ -9877,22 +9877,22 @@ static void lib_link_all(FileData *fd, Main *bmain) lib_link_vfont(&reader, (VFont *)id); break; case ID_HA: - lib_link_hair(fd, bmain, (Hair *)id); + lib_link_hair(&reader, (Hair *)id); break; case ID_PT: - lib_link_pointcloud(fd, bmain, (PointCloud *)id); + lib_link_pointcloud(&reader, (PointCloud *)id); break; case ID_VO: - lib_link_volume(fd, bmain, (Volume *)id); + lib_link_volume(&reader, (Volume *)id); break; case ID_MA: - lib_link_material(fd, bmain, (Material *)id); + lib_link_material(&reader, (Material *)id); break; case ID_TE: - lib_link_texture(fd, bmain, (Tex *)id); + lib_link_texture(&reader, (Tex *)id); break; case ID_IM: - lib_link_image(fd, bmain, (Image *)id); + lib_link_image(&reader, (Image *)id); break; case ID_NT: /* Has to be done after node users (scene/materials/...), this will verify group nodes. */ -- cgit v1.2.3 From ea4fa8abb0b78f570b588830a35a2119db234c8c Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Fri, 26 Jun 2020 15:44:56 +0200 Subject: Refactor: use new api for lib linking gpencil, palette, key, simulation, ipo and library --- source/blender/blenloader/intern/readfile.c | 36 ++++++++++++++--------------- 1 file changed, 17 insertions(+), 19 deletions(-) (limited to 'source/blender/blenloader') diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index b28aa386bfc..fd6f2bf3624 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -2988,7 +2988,7 @@ static void direct_link_brush(BlendDataReader *reader, Brush *brush) /** \name Read ID: Palette * \{ */ -static void lib_link_palette(FileData *UNUSED(fd), Main *UNUSED(bmain), Palette *UNUSED(palette)) +static void lib_link_palette(BlendLibReader *UNUSED(reader), Palette *UNUSED(palette)) { } @@ -3038,11 +3038,11 @@ static PackedFile *direct_link_packedfile(BlendDataReader *reader, PackedFile *o * \{ */ // XXX deprecated - old animation system -static void lib_link_ipo(FileData *fd, Main *UNUSED(bmain), Ipo *ipo) +static void lib_link_ipo(BlendLibReader *reader, Ipo *ipo) { LISTBASE_FOREACH (IpoCurve *, icu, &ipo->curve) { if (icu->driver) { - icu->driver->ob = newlibadr(fd, ipo->id.lib, icu->driver->ob); + BLO_read_id_address(reader, ipo->id.lib, &icu->driver->ob); } } } @@ -4090,12 +4090,12 @@ void blo_do_versions_key_uidgen(Key *key) } } -static void lib_link_key(FileData *fd, Main *UNUSED(bmain), Key *key) +static void lib_link_key(BlendLibReader *reader, Key *key) { BLI_assert((key->id.tag & LIB_TAG_EXTERN) == 0); - key->ipo = newlibadr(fd, key->id.lib, key->ipo); // XXX deprecated - old animation system - key->from = newlibadr(fd, key->id.lib, key->from); + BLO_read_id_address(reader, key->id.lib, &key->ipo); // XXX deprecated - old animation system + BLO_read_id_address(reader, key->id.lib, &key->from); } static void switch_endian_keyblock(Key *key, KeyBlock *kb) @@ -6912,18 +6912,18 @@ static void direct_link_scene(BlendDataReader *reader, Scene *sce) * \{ */ /* relink's grease pencil data's refs */ -static void lib_link_gpencil(FileData *fd, Main *UNUSED(bmain), bGPdata *gpd) +static void lib_link_gpencil(BlendLibReader *reader, bGPdata *gpd) { /* Relink all data-lock linked by GP data-lock */ /* Layers */ LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) { /* Layer -> Parent References */ - gpl->parent = newlibadr(fd, gpd->id.lib, gpl->parent); + BLO_read_id_address(reader, gpd->id.lib, &gpl->parent); } /* materials */ for (int a = 0; a < gpd->totcol; a++) { - gpd->mat[a] = newlibadr(fd, gpd->id.lib, gpd->mat[a]); + BLO_read_id_address(reader, gpd->id.lib, &gpd->mat[a]); } } @@ -8255,7 +8255,7 @@ static void direct_link_library(FileData *fd, Library *lib, Main *main) id_us_ensure_real(&lib->id); } -static void lib_link_library(FileData *UNUSED(fd), Main *UNUSED(bmain), Library *UNUSED(lib)) +static void lib_link_library(BlendLibReader *UNUSED(reader), Library *UNUSED(lib)) { } @@ -8916,9 +8916,7 @@ static void direct_link_volume(BlendDataReader *reader, Volume *volume) /** \name Read ID: Simulation * \{ */ -static void lib_link_simulation(FileData *UNUSED(fd), - Main *UNUSED(main), - Simulation *UNUSED(simulation)) +static void lib_link_simulation(BlendLibReader *UNUSED(reader), Simulation *UNUSED(simulation)) { } @@ -9899,26 +9897,26 @@ static void lib_link_all(FileData *fd, Main *bmain) lib_link_nodetree(&reader, (bNodeTree *)id); break; case ID_GD: - lib_link_gpencil(fd, bmain, (bGPdata *)id); + lib_link_gpencil(&reader, (bGPdata *)id); break; case ID_PAL: - lib_link_palette(fd, bmain, (Palette *)id); + lib_link_palette(&reader, (Palette *)id); break; case ID_KE: - lib_link_key(fd, bmain, (Key *)id); + lib_link_key(&reader, (Key *)id); break; case ID_AC: lib_link_action(&reader, (bAction *)id); break; case ID_SIM: - lib_link_simulation(fd, bmain, (Simulation *)id); + lib_link_simulation(&reader, (Simulation *)id); break; case ID_IP: /* XXX deprecated... still needs to be maintained for version patches still. */ - lib_link_ipo(fd, bmain, (Ipo *)id); + lib_link_ipo(&reader, (Ipo *)id); break; case ID_LI: - lib_link_library(fd, bmain, (Library *)id); /* Only init users. */ + lib_link_library(&reader, (Library *)id); /* Only init users. */ break; } -- cgit v1.2.3 From d10990af7944202f7be9ab4f02bb8a2d07dd6ad2 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Fri, 26 Jun 2020 16:03:42 +0200 Subject: Refactor: use new api for lib linking id properties --- source/blender/blenloader/intern/readfile.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'source/blender/blenloader') diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index fd6f2bf3624..f9e60cd35cb 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -2452,7 +2452,7 @@ static void link_glob_list(FileData *fd, ListBase *lb) /* for glob data */ * \{ */ static void IDP_DirectLinkProperty(IDProperty *prop, BlendDataReader *reader); -static void IDP_LibLinkProperty(IDProperty *prop, FileData *fd); +static void IDP_LibLinkProperty(IDProperty *prop, BlendLibReader *reader); static void IDP_DirectLinkIDPArray(IDProperty *prop, BlendDataReader *reader) { @@ -2588,7 +2588,7 @@ static void _IDP_DirectLinkGroup_OrFree(IDProperty **prop, } } -static void IDP_LibLinkProperty(IDProperty *prop, FileData *fd) +static void IDP_LibLinkProperty(IDProperty *prop, BlendLibReader *reader) { if (!prop) { return; @@ -2597,7 +2597,7 @@ static void IDP_LibLinkProperty(IDProperty *prop, FileData *fd) switch (prop->type) { case IDP_ID: /* PointerProperty */ { - void *newaddr = newlibadr(fd, NULL, IDP_Id(prop)); + void *newaddr = BLO_read_get_new_id_address(reader, NULL, IDP_Id(prop)); if (IDP_Id(prop) && !newaddr && G.debug) { printf("Error while loading \"%s\". Data not found in file!\n", prop->name); } @@ -2608,14 +2608,14 @@ static void IDP_LibLinkProperty(IDProperty *prop, FileData *fd) { IDProperty *idp_array = IDP_IDPArray(prop); for (int i = 0; i < prop->len; i++) { - IDP_LibLinkProperty(&(idp_array[i]), fd); + IDP_LibLinkProperty(&(idp_array[i]), reader); } break; } case IDP_GROUP: /* PointerProperty */ { LISTBASE_FOREACH (IDProperty *, loop, &prop->data.group) { - IDP_LibLinkProperty(loop, fd); + IDP_LibLinkProperty(loop, reader); } break; } @@ -2682,7 +2682,7 @@ static void lib_link_id(BlendLibReader *reader, ID *id) { /* Note: WM IDProperties are never written to file, hence they should always be NULL here. */ BLI_assert((GS(id->name) != ID_WM) || id->properties == NULL); - IDP_LibLinkProperty(id->properties, reader->fd); + IDP_LibLinkProperty(id->properties, reader); AnimData *adt = BKE_animdata_from_id(id); if (adt != NULL) { @@ -3542,7 +3542,7 @@ static void lib_link_workspace_instance_hook(BlendLibReader *reader, static void lib_link_node_socket(BlendLibReader *reader, Library *lib, bNodeSocket *sock) { - IDP_LibLinkProperty(sock->prop, reader->fd); + IDP_LibLinkProperty(sock->prop, reader); switch ((eNodeSocketDatatype)sock->type) { case SOCK_OBJECT: { @@ -3589,7 +3589,7 @@ static void lib_link_ntree(BlendLibReader *reader, Library *lib, bNodeTree *ntre LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { /* Link ID Properties -- and copy this comment EXACTLY for easy finding * of library blocks that implement this.*/ - IDP_LibLinkProperty(node->prop, reader->fd); + IDP_LibLinkProperty(node->prop, reader); BLO_read_id_address(reader, lib, &node->id); @@ -3939,7 +3939,7 @@ static void lib_link_pose(BlendLibReader *reader, Object *ob, bPose *pose) pchan->bone = BKE_armature_find_bone_name(arm, pchan->name); - IDP_LibLinkProperty(pchan->prop, reader->fd); + IDP_LibLinkProperty(pchan->prop, reader); BLO_read_id_address(reader, arm->id.lib, &pchan->custom); if (UNLIKELY(pchan->bone == NULL)) { @@ -3961,7 +3961,7 @@ static void lib_link_pose(BlendLibReader *reader, Object *ob, bPose *pose) static void lib_link_bones(BlendLibReader *reader, Bone *bone) { - IDP_LibLinkProperty(bone->prop, reader->fd); + IDP_LibLinkProperty(bone->prop, reader); LISTBASE_FOREACH (Bone *, curbone, &bone->childbase) { lib_link_bones(reader, curbone); @@ -6112,7 +6112,7 @@ static void lib_link_view_layer(BlendLibReader *reader, Library *lib, ViewLayer BLO_read_id_address(reader, lib, &view_layer->mat_override); - IDP_LibLinkProperty(view_layer->id_properties, reader->fd); + IDP_LibLinkProperty(view_layer->id_properties, reader); } /** \} */ @@ -6399,7 +6399,7 @@ static void lib_link_scene(BlendLibReader *reader, Scene *sce) Sequence *seq; SEQ_BEGIN (sce->ed, seq) { - IDP_LibLinkProperty(seq->prop, reader->fd); + IDP_LibLinkProperty(seq->prop, reader); if (seq->ipo) { BLO_read_id_address( -- cgit v1.2.3 From 4006cd2d2cf5c8ab23d60f160ea884e6fd3fc01f Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Fri, 26 Jun 2020 16:52:44 +0200 Subject: Refactor: use new api for expand in blenloader This is part of T76372. --- source/blender/blenloader/intern/readfile.c | 570 +++++++++++++--------------- 1 file changed, 266 insertions(+), 304 deletions(-) (limited to 'source/blender/blenloader') diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index f9e60cd35cb..82b6b25a679 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -259,7 +259,7 @@ static BHead *find_bhead_from_code_name(FileData *fd, const short idcode, const static BHead *find_bhead_from_idname(FileData *fd, const char *idname); #ifdef USE_COLLECTION_COMPAT_28 -static void expand_scene_collection(FileData *fd, Main *mainvar, SceneCollection *sc); +static void expand_scene_collection(BlendExpander *expander, SceneCollection *sc); #endif static void direct_link_animdata(BlendDataReader *reader, AnimData *adt); static void lib_link_animdata(BlendLibReader *reader, ID *id, AnimData *adt); @@ -10486,26 +10486,26 @@ static void expand_doit_library(void *fdhandle, Main *mainvar, void *old) static BLOExpandDoitCallback expand_doit; // XXX deprecated - old animation system -static void expand_ipo(FileData *fd, Main *mainvar, Ipo *ipo) +static void expand_ipo(BlendExpander *expander, Ipo *ipo) { IpoCurve *icu; for (icu = ipo->curve.first; icu; icu = icu->next) { if (icu->driver) { - expand_doit(fd, mainvar, icu->driver->ob); + BLO_expand(expander, icu->driver->ob); } } } // XXX deprecated - old animation system -static void expand_constraint_channels(FileData *fd, Main *mainvar, ListBase *chanbase) +static void expand_constraint_channels(BlendExpander *expander, ListBase *chanbase) { bConstraintChannel *chan; for (chan = chanbase->first; chan; chan = chan->next) { - expand_doit(fd, mainvar, chan->ipo); + BLO_expand(expander, chan->ipo); } } -static void expand_fmodifiers(FileData *fd, Main *mainvar, ListBase *list) +static void expand_fmodifiers(BlendExpander *expander, ListBase *list) { FModifier *fcm; @@ -10515,7 +10515,7 @@ static void expand_fmodifiers(FileData *fd, Main *mainvar, ListBase *list) case FMODIFIER_TYPE_PYTHON: { FMod_Python *data = (FMod_Python *)fcm->data; - expand_doit(fd, mainvar, data->script); + BLO_expand(expander, data->script); break; } @@ -10523,7 +10523,7 @@ static void expand_fmodifiers(FileData *fd, Main *mainvar, ListBase *list) } } -static void expand_fcurves(FileData *fd, Main *mainvar, ListBase *list) +static void expand_fcurves(BlendExpander *expander, ListBase *list) { FCurve *fcu; @@ -10536,54 +10536,54 @@ static void expand_fcurves(FileData *fd, Main *mainvar, ListBase *list) for (dvar = driver->variables.first; dvar; dvar = dvar->next) { DRIVER_TARGETS_LOOPER_BEGIN (dvar) { // TODO: only expand those that are going to get used? - expand_doit(fd, mainvar, dtar->id); + BLO_expand(expander, dtar->id); } DRIVER_TARGETS_LOOPER_END; } } /* F-Curve Modifiers */ - expand_fmodifiers(fd, mainvar, &fcu->modifiers); + expand_fmodifiers(expander, &fcu->modifiers); } } -static void expand_animdata_nlastrips(FileData *fd, Main *mainvar, ListBase *list) +static void expand_animdata_nlastrips(BlendExpander *expander, ListBase *list) { NlaStrip *strip; for (strip = list->first; strip; strip = strip->next) { /* check child strips */ - expand_animdata_nlastrips(fd, mainvar, &strip->strips); + expand_animdata_nlastrips(expander, &strip->strips); /* check F-Curves */ - expand_fcurves(fd, mainvar, &strip->fcurves); + expand_fcurves(expander, &strip->fcurves); /* check F-Modifiers */ - expand_fmodifiers(fd, mainvar, &strip->modifiers); + expand_fmodifiers(expander, &strip->modifiers); /* relink referenced action */ - expand_doit(fd, mainvar, strip->act); + BLO_expand(expander, strip->act); } } -static void expand_animdata(FileData *fd, Main *mainvar, AnimData *adt) +static void expand_animdata(BlendExpander *expander, AnimData *adt) { NlaTrack *nlt; /* own action */ - expand_doit(fd, mainvar, adt->action); - expand_doit(fd, mainvar, adt->tmpact); + BLO_expand(expander, adt->action); + BLO_expand(expander, adt->tmpact); /* drivers - assume that these F-Curves have driver data to be in this list... */ - expand_fcurves(fd, mainvar, &adt->drivers); + expand_fcurves(expander, &adt->drivers); /* nla-data - referenced actions */ for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) { - expand_animdata_nlastrips(fd, mainvar, &nlt->strips); + expand_animdata_nlastrips(expander, &nlt->strips); } } -static void expand_idprops(FileData *fd, Main *mainvar, IDProperty *prop) +static void expand_idprops(BlendExpander *expander, IDProperty *prop) { if (!prop) { return; @@ -10591,84 +10591,84 @@ static void expand_idprops(FileData *fd, Main *mainvar, IDProperty *prop) switch (prop->type) { case IDP_ID: - expand_doit(fd, mainvar, IDP_Id(prop)); + BLO_expand(expander, IDP_Id(prop)); break; case IDP_IDPARRAY: { IDProperty *idp_array = IDP_IDPArray(prop); for (int i = 0; i < prop->len; i++) { - expand_idprops(fd, mainvar, &idp_array[i]); + expand_idprops(expander, &idp_array[i]); } break; } case IDP_GROUP: LISTBASE_FOREACH (IDProperty *, loop, &prop->data.group) { - expand_idprops(fd, mainvar, loop); + expand_idprops(expander, loop); } break; } } -static void expand_id(FileData *fd, Main *mainvar, ID *id); -static void expand_nodetree(FileData *fd, Main *mainvar, bNodeTree *ntree); -static void expand_collection(FileData *fd, Main *mainvar, Collection *collection); +static void expand_id(BlendExpander *expander, ID *id); +static void expand_nodetree(BlendExpander *expander, bNodeTree *ntree); +static void expand_collection(BlendExpander *expander, Collection *collection); -static void expand_id_embedded_id(FileData *fd, Main *mainvar, ID *id) +static void expand_id_embedded_id(BlendExpander *expander, ID *id) { /* Handle 'private IDs'. */ bNodeTree *nodetree = ntreeFromID(id); if (nodetree != NULL) { - expand_id(fd, mainvar, &nodetree->id); - expand_nodetree(fd, mainvar, nodetree); + expand_id(expander, &nodetree->id); + expand_nodetree(expander, nodetree); } if (GS(id->name) == ID_SCE) { Scene *scene = (Scene *)id; if (scene->master_collection != NULL) { - expand_id(fd, mainvar, &scene->master_collection->id); - expand_collection(fd, mainvar, scene->master_collection); + expand_id(expander, &scene->master_collection->id); + expand_collection(expander, scene->master_collection); } } } -static void expand_id(FileData *fd, Main *mainvar, ID *id) +static void expand_id(BlendExpander *expander, ID *id) { - expand_idprops(fd, mainvar, id->properties); + expand_idprops(expander, id->properties); if (id->override_library) { - expand_doit(fd, mainvar, id->override_library->reference); - expand_doit(fd, mainvar, id->override_library->storage); + BLO_expand(expander, id->override_library->reference); + BLO_expand(expander, id->override_library->storage); } AnimData *adt = BKE_animdata_from_id(id); if (adt != NULL) { - expand_animdata(fd, mainvar, adt); + expand_animdata(expander, adt); } - expand_id_embedded_id(fd, mainvar, id); + expand_id_embedded_id(expander, id); } -static void expand_action(FileData *fd, Main *mainvar, bAction *act) +static void expand_action(BlendExpander *expander, bAction *act) { bActionChannel *chan; // XXX deprecated - old animation system -------------- for (chan = act->chanbase.first; chan; chan = chan->next) { - expand_doit(fd, mainvar, chan->ipo); - expand_constraint_channels(fd, mainvar, &chan->constraintChannels); + BLO_expand(expander, chan->ipo); + expand_constraint_channels(expander, &chan->constraintChannels); } // --------------------------------------------------- /* F-Curves in Action */ - expand_fcurves(fd, mainvar, &act->curves); + expand_fcurves(expander, &act->curves); LISTBASE_FOREACH (TimeMarker *, marker, &act->markers) { if (marker->camera) { - expand_doit(fd, mainvar, marker->camera); + BLO_expand(expander, marker->camera); } } } -static void expand_keyingsets(FileData *fd, Main *mainvar, ListBase *list) +static void expand_keyingsets(BlendExpander *expander, ListBase *list) { KeyingSet *ks; KS_Path *ksp; @@ -10676,39 +10676,39 @@ static void expand_keyingsets(FileData *fd, Main *mainvar, ListBase *list) /* expand the ID-pointers in KeyingSets's paths */ for (ks = list->first; ks; ks = ks->next) { for (ksp = ks->paths.first; ksp; ksp = ksp->next) { - expand_doit(fd, mainvar, ksp->id); + BLO_expand(expander, ksp->id); } } } -static void expand_particlesettings(FileData *fd, Main *mainvar, ParticleSettings *part) +static void expand_particlesettings(BlendExpander *expander, ParticleSettings *part) { int a; - expand_doit(fd, mainvar, part->instance_object); - expand_doit(fd, mainvar, part->instance_collection); - expand_doit(fd, mainvar, part->force_group); - expand_doit(fd, mainvar, part->bb_ob); - expand_doit(fd, mainvar, part->collision_group); + BLO_expand(expander, part->instance_object); + BLO_expand(expander, part->instance_collection); + BLO_expand(expander, part->force_group); + BLO_expand(expander, part->bb_ob); + BLO_expand(expander, part->collision_group); for (a = 0; a < MAX_MTEX; a++) { if (part->mtex[a]) { - expand_doit(fd, mainvar, part->mtex[a]->tex); - expand_doit(fd, mainvar, part->mtex[a]->object); + BLO_expand(expander, part->mtex[a]->tex); + BLO_expand(expander, part->mtex[a]->object); } } if (part->effector_weights) { - expand_doit(fd, mainvar, part->effector_weights->group); + BLO_expand(expander, part->effector_weights->group); } if (part->pd) { - expand_doit(fd, mainvar, part->pd->tex); - expand_doit(fd, mainvar, part->pd->f_source); + BLO_expand(expander, part->pd->tex); + BLO_expand(expander, part->pd->f_source); } if (part->pd2) { - expand_doit(fd, mainvar, part->pd2->tex); - expand_doit(fd, mainvar, part->pd2->f_source); + BLO_expand(expander, part->pd2->tex); + BLO_expand(expander, part->pd2->f_source); } if (part->boids) { @@ -10719,58 +10719,58 @@ static void expand_particlesettings(FileData *fd, Main *mainvar, ParticleSetting for (rule = state->rules.first; rule; rule = rule->next) { if (rule->type == eBoidRuleType_Avoid) { BoidRuleGoalAvoid *gabr = (BoidRuleGoalAvoid *)rule; - expand_doit(fd, mainvar, gabr->ob); + BLO_expand(expander, gabr->ob); } else if (rule->type == eBoidRuleType_FollowLeader) { BoidRuleFollowLeader *flbr = (BoidRuleFollowLeader *)rule; - expand_doit(fd, mainvar, flbr->ob); + BLO_expand(expander, flbr->ob); } } } } LISTBASE_FOREACH (ParticleDupliWeight *, dw, &part->instance_weights) { - expand_doit(fd, mainvar, dw->ob); + BLO_expand(expander, dw->ob); } } -static void expand_collection(FileData *fd, Main *mainvar, Collection *collection) +static void expand_collection(BlendExpander *expander, Collection *collection) { LISTBASE_FOREACH (CollectionObject *, cob, &collection->gobject) { - expand_doit(fd, mainvar, cob->ob); + BLO_expand(expander, cob->ob); } LISTBASE_FOREACH (CollectionChild *, child, &collection->children) { - expand_doit(fd, mainvar, child->collection); + BLO_expand(expander, child->collection); } #ifdef USE_COLLECTION_COMPAT_28 if (collection->collection != NULL) { - expand_scene_collection(fd, mainvar, collection->collection); + expand_scene_collection(expander, collection->collection); } #endif } -static void expand_key(FileData *fd, Main *mainvar, Key *key) +static void expand_key(BlendExpander *expander, Key *key) { - expand_doit(fd, mainvar, key->ipo); // XXX deprecated - old animation system + BLO_expand(expander, key->ipo); // XXX deprecated - old animation system } -static void expand_node_socket(FileData *fd, Main *mainvar, bNodeSocket *sock) +static void expand_node_socket(BlendExpander *expander, bNodeSocket *sock) { - expand_idprops(fd, mainvar, sock->prop); + expand_idprops(expander, sock->prop); if (sock->default_value != NULL) { switch ((eNodeSocketDatatype)sock->type) { case SOCK_OBJECT: { bNodeSocketValueObject *default_value = sock->default_value; - expand_doit(fd, mainvar, default_value->value); + BLO_expand(expander, default_value->value); break; } case SOCK_IMAGE: { bNodeSocketValueImage *default_value = sock->default_value; - expand_doit(fd, mainvar, default_value->value); + BLO_expand(expander, default_value->value); break; } case SOCK_FLOAT: @@ -10791,155 +10791,145 @@ static void expand_node_socket(FileData *fd, Main *mainvar, bNodeSocket *sock) } } -static void expand_node_sockets(FileData *fd, Main *mainvar, ListBase *sockets) +static void expand_node_sockets(BlendExpander *expander, ListBase *sockets) { LISTBASE_FOREACH (bNodeSocket *, sock, sockets) { - expand_node_socket(fd, mainvar, sock); + expand_node_socket(expander, sock); } } -static void expand_nodetree(FileData *fd, Main *mainvar, bNodeTree *ntree) +static void expand_nodetree(BlendExpander *expander, bNodeTree *ntree) { bNode *node; if (ntree->gpd) { - expand_doit(fd, mainvar, ntree->gpd); + BLO_expand(expander, ntree->gpd); } for (node = ntree->nodes.first; node; node = node->next) { if (node->id && node->type != CMP_NODE_R_LAYERS) { - expand_doit(fd, mainvar, node->id); + BLO_expand(expander, node->id); } - expand_idprops(fd, mainvar, node->prop); + expand_idprops(expander, node->prop); - expand_node_sockets(fd, mainvar, &node->inputs); - expand_node_sockets(fd, mainvar, &node->outputs); + expand_node_sockets(expander, &node->inputs); + expand_node_sockets(expander, &node->outputs); } - expand_node_sockets(fd, mainvar, &ntree->inputs); - expand_node_sockets(fd, mainvar, &ntree->outputs); + expand_node_sockets(expander, &ntree->inputs); + expand_node_sockets(expander, &ntree->outputs); } -static void expand_texture(FileData *fd, Main *mainvar, Tex *tex) +static void expand_texture(BlendExpander *expander, Tex *tex) { - expand_doit(fd, mainvar, tex->ima); - expand_doit(fd, mainvar, tex->ipo); // XXX deprecated - old animation system + BLO_expand(expander, tex->ima); + BLO_expand(expander, tex->ipo); // XXX deprecated - old animation system } -static void expand_brush(FileData *fd, Main *mainvar, Brush *brush) +static void expand_brush(BlendExpander *expander, Brush *brush) { - expand_doit(fd, mainvar, brush->mtex.tex); - expand_doit(fd, mainvar, brush->mask_mtex.tex); - expand_doit(fd, mainvar, brush->clone.image); - expand_doit(fd, mainvar, brush->paint_curve); + BLO_expand(expander, brush->mtex.tex); + BLO_expand(expander, brush->mask_mtex.tex); + BLO_expand(expander, brush->clone.image); + BLO_expand(expander, brush->paint_curve); if (brush->gpencil_settings != NULL) { - expand_doit(fd, mainvar, brush->gpencil_settings->material); + BLO_expand(expander, brush->gpencil_settings->material); } } -static void expand_material(FileData *fd, Main *mainvar, Material *ma) +static void expand_material(BlendExpander *expander, Material *ma) { - expand_doit(fd, mainvar, ma->ipo); // XXX deprecated - old animation system + BLO_expand(expander, ma->ipo); // XXX deprecated - old animation system if (ma->gp_style) { MaterialGPencilStyle *gp_style = ma->gp_style; - expand_doit(fd, mainvar, gp_style->sima); - expand_doit(fd, mainvar, gp_style->ima); + BLO_expand(expander, gp_style->sima); + BLO_expand(expander, gp_style->ima); } } -static void expand_light(FileData *fd, Main *mainvar, Light *la) +static void expand_light(BlendExpander *expander, Light *la) { - expand_doit(fd, mainvar, la->ipo); // XXX deprecated - old animation system + BLO_expand(expander, la->ipo); // XXX deprecated - old animation system } -static void expand_lattice(FileData *fd, Main *mainvar, Lattice *lt) +static void expand_lattice(BlendExpander *expander, Lattice *lt) { - expand_doit(fd, mainvar, lt->ipo); // XXX deprecated - old animation system - expand_doit(fd, mainvar, lt->key); + BLO_expand(expander, lt->ipo); // XXX deprecated - old animation system + BLO_expand(expander, lt->key); } -static void expand_world(FileData *fd, Main *mainvar, World *wrld) +static void expand_world(BlendExpander *expander, World *wrld) { - expand_doit(fd, mainvar, wrld->ipo); // XXX deprecated - old animation system + BLO_expand(expander, wrld->ipo); // XXX deprecated - old animation system } -static void expand_mball(FileData *fd, Main *mainvar, MetaBall *mb) +static void expand_mball(BlendExpander *expander, MetaBall *mb) { int a; for (a = 0; a < mb->totcol; a++) { - expand_doit(fd, mainvar, mb->mat[a]); + BLO_expand(expander, mb->mat[a]); } } -static void expand_curve(FileData *fd, Main *mainvar, Curve *cu) +static void expand_curve(BlendExpander *expander, Curve *cu) { int a; for (a = 0; a < cu->totcol; a++) { - expand_doit(fd, mainvar, cu->mat[a]); + BLO_expand(expander, cu->mat[a]); } - expand_doit(fd, mainvar, cu->vfont); - expand_doit(fd, mainvar, cu->vfontb); - expand_doit(fd, mainvar, cu->vfonti); - expand_doit(fd, mainvar, cu->vfontbi); - expand_doit(fd, mainvar, cu->key); - expand_doit(fd, mainvar, cu->ipo); // XXX deprecated - old animation system - expand_doit(fd, mainvar, cu->bevobj); - expand_doit(fd, mainvar, cu->taperobj); - expand_doit(fd, mainvar, cu->textoncurve); + BLO_expand(expander, cu->vfont); + BLO_expand(expander, cu->vfontb); + BLO_expand(expander, cu->vfonti); + BLO_expand(expander, cu->vfontbi); + BLO_expand(expander, cu->key); + BLO_expand(expander, cu->ipo); // XXX deprecated - old animation system + BLO_expand(expander, cu->bevobj); + BLO_expand(expander, cu->taperobj); + BLO_expand(expander, cu->textoncurve); } -static void expand_mesh(FileData *fd, Main *mainvar, Mesh *me) +static void expand_mesh(BlendExpander *expander, Mesh *me) { int a; for (a = 0; a < me->totcol; a++) { - expand_doit(fd, mainvar, me->mat[a]); + BLO_expand(expander, me->mat[a]); } - expand_doit(fd, mainvar, me->key); - expand_doit(fd, mainvar, me->texcomesh); + BLO_expand(expander, me->key); + BLO_expand(expander, me->texcomesh); } -/* temp struct used to transport needed info to expand_constraint_cb() */ -typedef struct tConstraintExpandData { - FileData *fd; - Main *mainvar; -} tConstraintExpandData; /* callback function used to expand constraint ID-links */ static void expand_constraint_cb(bConstraint *UNUSED(con), ID **idpoin, bool UNUSED(is_reference), void *userdata) { - tConstraintExpandData *ced = (tConstraintExpandData *)userdata; - expand_doit(ced->fd, ced->mainvar, *idpoin); + BlendExpander *expander = userdata; + BLO_expand(expander, *idpoin); } -static void expand_constraints(FileData *fd, Main *mainvar, ListBase *lb) +static void expand_constraints(BlendExpander *expander, ListBase *lb) { - tConstraintExpandData ced; bConstraint *curcon; - /* relink all ID-blocks used by the constraints */ - ced.fd = fd; - ced.mainvar = mainvar; - - BKE_constraints_id_loop(lb, expand_constraint_cb, &ced); + BKE_constraints_id_loop(lb, expand_constraint_cb, expander); /* deprecated manual expansion stuff */ for (curcon = lb->first; curcon; curcon = curcon->next) { if (curcon->ipo) { - expand_doit(fd, mainvar, curcon->ipo); // XXX deprecated - old animation system + BLO_expand(expander, curcon->ipo); // XXX deprecated - old animation system } } } -static void expand_pose(FileData *fd, Main *mainvar, bPose *pose) +static void expand_pose(BlendExpander *expander, bPose *pose) { bPoseChannel *chan; @@ -10948,25 +10938,25 @@ static void expand_pose(FileData *fd, Main *mainvar, bPose *pose) } for (chan = pose->chanbase.first; chan; chan = chan->next) { - expand_constraints(fd, mainvar, &chan->constraints); - expand_idprops(fd, mainvar, chan->prop); - expand_doit(fd, mainvar, chan->custom); + expand_constraints(expander, &chan->constraints); + expand_idprops(expander, chan->prop); + BLO_expand(expander, chan->custom); } } -static void expand_bones(FileData *fd, Main *mainvar, Bone *bone) +static void expand_bones(BlendExpander *expander, Bone *bone) { - expand_idprops(fd, mainvar, bone->prop); + expand_idprops(expander, bone->prop); LISTBASE_FOREACH (Bone *, curBone, &bone->childbase) { - expand_bones(fd, mainvar, curBone); + expand_bones(expander, curBone); } } -static void expand_armature(FileData *fd, Main *mainvar, bArmature *arm) +static void expand_armature(BlendExpander *expander, bArmature *arm) { LISTBASE_FOREACH (Bone *, curBone, &arm->bonebase) { - expand_bones(fd, mainvar, curBone); + expand_bones(expander, curBone); } } @@ -10975,298 +10965,268 @@ static void expand_object_expandModifiers(void *userData, ID **idpoin, int UNUSED(cb_flag)) { - struct { - FileData *fd; - Main *mainvar; - } *data = userData; - - FileData *fd = data->fd; - Main *mainvar = data->mainvar; - - expand_doit(fd, mainvar, *idpoin); + BlendExpander *expander = userData; + BLO_expand(expander, *idpoin); } -static void expand_object(FileData *fd, Main *mainvar, Object *ob) +static void expand_object(BlendExpander *expander, Object *ob) { ParticleSystem *psys; bActionStrip *strip; PartEff *paf; int a; - expand_doit(fd, mainvar, ob->data); + BLO_expand(expander, ob->data); /* expand_object_expandModifier() */ if (ob->modifiers.first) { - struct { - FileData *fd; - Main *mainvar; - } data; - data.fd = fd; - data.mainvar = mainvar; - - BKE_modifiers_foreach_ID_link(ob, expand_object_expandModifiers, (void *)&data); + BKE_modifiers_foreach_ID_link(ob, expand_object_expandModifiers, expander); } /* expand_object_expandModifier() */ if (ob->greasepencil_modifiers.first) { - struct { - FileData *fd; - Main *mainvar; - } data; - data.fd = fd; - data.mainvar = mainvar; - - BKE_gpencil_modifiers_foreach_ID_link(ob, expand_object_expandModifiers, (void *)&data); + BKE_gpencil_modifiers_foreach_ID_link(ob, expand_object_expandModifiers, expander); } /* expand_object_expandShaderFx() */ if (ob->shader_fx.first) { - struct { - FileData *fd; - Main *mainvar; - } data; - data.fd = fd; - data.mainvar = mainvar; - - BKE_shaderfx_foreach_ID_link(ob, expand_object_expandModifiers, (void *)&data); + BKE_shaderfx_foreach_ID_link(ob, expand_object_expandModifiers, expander); } - expand_pose(fd, mainvar, ob->pose); - expand_doit(fd, mainvar, ob->poselib); - expand_constraints(fd, mainvar, &ob->constraints); + expand_pose(expander, ob->pose); + BLO_expand(expander, ob->poselib); + expand_constraints(expander, &ob->constraints); - expand_doit(fd, mainvar, ob->gpd); + BLO_expand(expander, ob->gpd); // XXX deprecated - old animation system (for version patching only) - expand_doit(fd, mainvar, ob->ipo); - expand_doit(fd, mainvar, ob->action); + BLO_expand(expander, ob->ipo); + BLO_expand(expander, ob->action); - expand_constraint_channels(fd, mainvar, &ob->constraintChannels); + expand_constraint_channels(expander, &ob->constraintChannels); for (strip = ob->nlastrips.first; strip; strip = strip->next) { - expand_doit(fd, mainvar, strip->object); - expand_doit(fd, mainvar, strip->act); - expand_doit(fd, mainvar, strip->ipo); + BLO_expand(expander, strip->object); + BLO_expand(expander, strip->act); + BLO_expand(expander, strip->ipo); } // XXX deprecated - old animation system (for version patching only) for (a = 0; a < ob->totcol; a++) { - expand_doit(fd, mainvar, ob->mat[a]); + BLO_expand(expander, ob->mat[a]); } paf = blo_do_version_give_parteff_245(ob); if (paf && paf->group) { - expand_doit(fd, mainvar, paf->group); + BLO_expand(expander, paf->group); } if (ob->instance_collection) { - expand_doit(fd, mainvar, ob->instance_collection); + BLO_expand(expander, ob->instance_collection); } if (ob->proxy) { - expand_doit(fd, mainvar, ob->proxy); + BLO_expand(expander, ob->proxy); } if (ob->proxy_group) { - expand_doit(fd, mainvar, ob->proxy_group); + BLO_expand(expander, ob->proxy_group); } for (psys = ob->particlesystem.first; psys; psys = psys->next) { - expand_doit(fd, mainvar, psys->part); + BLO_expand(expander, psys->part); } if (ob->pd) { - expand_doit(fd, mainvar, ob->pd->tex); - expand_doit(fd, mainvar, ob->pd->f_source); + BLO_expand(expander, ob->pd->tex); + BLO_expand(expander, ob->pd->f_source); } if (ob->soft) { - expand_doit(fd, mainvar, ob->soft->collision_group); + BLO_expand(expander, ob->soft->collision_group); if (ob->soft->effector_weights) { - expand_doit(fd, mainvar, ob->soft->effector_weights->group); + BLO_expand(expander, ob->soft->effector_weights->group); } } if (ob->rigidbody_constraint) { - expand_doit(fd, mainvar, ob->rigidbody_constraint->ob1); - expand_doit(fd, mainvar, ob->rigidbody_constraint->ob2); + BLO_expand(expander, ob->rigidbody_constraint->ob1); + BLO_expand(expander, ob->rigidbody_constraint->ob2); } if (ob->currentlod) { LodLevel *level; for (level = ob->lodlevels.first; level; level = level->next) { - expand_doit(fd, mainvar, level->source); + BLO_expand(expander, level->source); } } } #ifdef USE_COLLECTION_COMPAT_28 -static void expand_scene_collection(FileData *fd, Main *mainvar, SceneCollection *sc) +static void expand_scene_collection(BlendExpander *expander, SceneCollection *sc) { LISTBASE_FOREACH (LinkData *, link, &sc->objects) { - expand_doit(fd, mainvar, link->data); + BLO_expand(expander, link->data); } LISTBASE_FOREACH (SceneCollection *, nsc, &sc->scene_collections) { - expand_scene_collection(fd, mainvar, nsc); + expand_scene_collection(expander, nsc); } } #endif -static void expand_scene(FileData *fd, Main *mainvar, Scene *sce) +static void expand_scene(BlendExpander *expander, Scene *sce) { SceneRenderLayer *srl; FreestyleModuleConfig *module; FreestyleLineSet *lineset; LISTBASE_FOREACH (Base *, base_legacy, &sce->base) { - expand_doit(fd, mainvar, base_legacy->object); + BLO_expand(expander, base_legacy->object); } - expand_doit(fd, mainvar, sce->camera); - expand_doit(fd, mainvar, sce->world); + BLO_expand(expander, sce->camera); + BLO_expand(expander, sce->world); - expand_keyingsets(fd, mainvar, &sce->keyingsets); + expand_keyingsets(expander, &sce->keyingsets); if (sce->set) { - expand_doit(fd, mainvar, sce->set); + BLO_expand(expander, sce->set); } for (srl = sce->r.layers.first; srl; srl = srl->next) { - expand_doit(fd, mainvar, srl->mat_override); + BLO_expand(expander, srl->mat_override); for (module = srl->freestyleConfig.modules.first; module; module = module->next) { if (module->script) { - expand_doit(fd, mainvar, module->script); + BLO_expand(expander, module->script); } } for (lineset = srl->freestyleConfig.linesets.first; lineset; lineset = lineset->next) { if (lineset->group) { - expand_doit(fd, mainvar, lineset->group); + BLO_expand(expander, lineset->group); } - expand_doit(fd, mainvar, lineset->linestyle); + BLO_expand(expander, lineset->linestyle); } } LISTBASE_FOREACH (ViewLayer *, view_layer, &sce->view_layers) { - expand_idprops(fd, mainvar, view_layer->id_properties); + expand_idprops(expander, view_layer->id_properties); for (module = view_layer->freestyle_config.modules.first; module; module = module->next) { if (module->script) { - expand_doit(fd, mainvar, module->script); + BLO_expand(expander, module->script); } } for (lineset = view_layer->freestyle_config.linesets.first; lineset; lineset = lineset->next) { if (lineset->group) { - expand_doit(fd, mainvar, lineset->group); + BLO_expand(expander, lineset->group); } - expand_doit(fd, mainvar, lineset->linestyle); + BLO_expand(expander, lineset->linestyle); } } if (sce->gpd) { - expand_doit(fd, mainvar, sce->gpd); + BLO_expand(expander, sce->gpd); } if (sce->ed) { Sequence *seq; SEQ_BEGIN (sce->ed, seq) { - expand_idprops(fd, mainvar, seq->prop); + expand_idprops(expander, seq->prop); if (seq->scene) { - expand_doit(fd, mainvar, seq->scene); + BLO_expand(expander, seq->scene); } if (seq->scene_camera) { - expand_doit(fd, mainvar, seq->scene_camera); + BLO_expand(expander, seq->scene_camera); } if (seq->clip) { - expand_doit(fd, mainvar, seq->clip); + BLO_expand(expander, seq->clip); } if (seq->mask) { - expand_doit(fd, mainvar, seq->mask); + BLO_expand(expander, seq->mask); } if (seq->sound) { - expand_doit(fd, mainvar, seq->sound); + BLO_expand(expander, seq->sound); } if (seq->type == SEQ_TYPE_TEXT && seq->effectdata) { TextVars *data = seq->effectdata; - expand_doit(fd, mainvar, data->text_font); + BLO_expand(expander, data->text_font); } } SEQ_END; } if (sce->rigidbody_world) { - expand_doit(fd, mainvar, sce->rigidbody_world->group); - expand_doit(fd, mainvar, sce->rigidbody_world->constraints); + BLO_expand(expander, sce->rigidbody_world->group); + BLO_expand(expander, sce->rigidbody_world->constraints); } LISTBASE_FOREACH (TimeMarker *, marker, &sce->markers) { if (marker->camera) { - expand_doit(fd, mainvar, marker->camera); + BLO_expand(expander, marker->camera); } } - expand_doit(fd, mainvar, sce->clip); + BLO_expand(expander, sce->clip); #ifdef USE_COLLECTION_COMPAT_28 if (sce->collection) { - expand_scene_collection(fd, mainvar, sce->collection); + expand_scene_collection(expander, sce->collection); } #endif if (sce->r.bake.cage_object) { - expand_doit(fd, mainvar, sce->r.bake.cage_object); + BLO_expand(expander, sce->r.bake.cage_object); } } -static void expand_camera(FileData *fd, Main *mainvar, Camera *ca) +static void expand_camera(BlendExpander *expander, Camera *ca) { - expand_doit(fd, mainvar, ca->ipo); // XXX deprecated - old animation system + BLO_expand(expander, ca->ipo); // XXX deprecated - old animation system LISTBASE_FOREACH (CameraBGImage *, bgpic, &ca->bg_images) { if (bgpic->source == CAM_BGIMG_SOURCE_IMAGE) { - expand_doit(fd, mainvar, bgpic->ima); + BLO_expand(expander, bgpic->ima); } else if (bgpic->source == CAM_BGIMG_SOURCE_MOVIE) { - expand_doit(fd, mainvar, bgpic->ima); + BLO_expand(expander, bgpic->ima); } } } -static void expand_cachefile(FileData *UNUSED(fd), - Main *UNUSED(mainvar), - CacheFile *UNUSED(cache_file)) +static void expand_cachefile(BlendExpander *UNUSED(expander), CacheFile *UNUSED(cache_file)) { } -static void expand_speaker(FileData *fd, Main *mainvar, Speaker *spk) +static void expand_speaker(BlendExpander *expander, Speaker *spk) { - expand_doit(fd, mainvar, spk->sound); + BLO_expand(expander, spk->sound); } -static void expand_sound(FileData *fd, Main *mainvar, bSound *snd) +static void expand_sound(BlendExpander *expander, bSound *snd) { - expand_doit(fd, mainvar, snd->ipo); // XXX deprecated - old animation system + BLO_expand(expander, snd->ipo); // XXX deprecated - old animation system } -static void expand_lightprobe(FileData *UNUSED(fd), Main *UNUSED(mainvar), LightProbe *UNUSED(prb)) +static void expand_lightprobe(BlendExpander *UNUSED(expander), LightProbe *UNUSED(prb)) { } -static void expand_movieclip(FileData *UNUSED(fd), Main *UNUSED(mainvar), MovieClip *UNUSED(clip)) +static void expand_movieclip(BlendExpander *UNUSED(expander), MovieClip *UNUSED(clip)) { } -static void expand_mask_parent(FileData *fd, Main *mainvar, MaskParent *parent) +static void expand_mask_parent(BlendExpander *expander, MaskParent *parent) { if (parent->id) { - expand_doit(fd, mainvar, parent->id); + BLO_expand(expander, parent->id); } } -static void expand_mask(FileData *fd, Main *mainvar, Mask *mask) +static void expand_mask(BlendExpander *expander, Mask *mask) { MaskLayer *mask_layer; @@ -11279,98 +11239,98 @@ static void expand_mask(FileData *fd, Main *mainvar, Mask *mask) for (i = 0; i < spline->tot_point; i++) { MaskSplinePoint *point = &spline->points[i]; - expand_mask_parent(fd, mainvar, &point->parent); + expand_mask_parent(expander, &point->parent); } - expand_mask_parent(fd, mainvar, &spline->parent); + expand_mask_parent(expander, &spline->parent); } } } -static void expand_linestyle(FileData *fd, Main *mainvar, FreestyleLineStyle *linestyle) +static void expand_linestyle(BlendExpander *expander, FreestyleLineStyle *linestyle) { int a; LineStyleModifier *m; for (a = 0; a < MAX_MTEX; a++) { if (linestyle->mtex[a]) { - expand_doit(fd, mainvar, linestyle->mtex[a]->tex); - expand_doit(fd, mainvar, linestyle->mtex[a]->object); + BLO_expand(expander, linestyle->mtex[a]->tex); + BLO_expand(expander, linestyle->mtex[a]->object); } } for (m = linestyle->color_modifiers.first; m; m = m->next) { if (m->type == LS_MODIFIER_DISTANCE_FROM_OBJECT) { - expand_doit(fd, mainvar, ((LineStyleColorModifier_DistanceFromObject *)m)->target); + BLO_expand(expander, ((LineStyleColorModifier_DistanceFromObject *)m)->target); } } for (m = linestyle->alpha_modifiers.first; m; m = m->next) { if (m->type == LS_MODIFIER_DISTANCE_FROM_OBJECT) { - expand_doit(fd, mainvar, ((LineStyleAlphaModifier_DistanceFromObject *)m)->target); + BLO_expand(expander, ((LineStyleAlphaModifier_DistanceFromObject *)m)->target); } } for (m = linestyle->thickness_modifiers.first; m; m = m->next) { if (m->type == LS_MODIFIER_DISTANCE_FROM_OBJECT) { - expand_doit(fd, mainvar, ((LineStyleThicknessModifier_DistanceFromObject *)m)->target); + BLO_expand(expander, ((LineStyleThicknessModifier_DistanceFromObject *)m)->target); } } } -static void expand_gpencil(FileData *fd, Main *mainvar, bGPdata *gpd) +static void expand_gpencil(BlendExpander *expander, bGPdata *gpd) { LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) { - expand_doit(fd, mainvar, gpl->parent); + BLO_expand(expander, gpl->parent); } for (int a = 0; a < gpd->totcol; a++) { - expand_doit(fd, mainvar, gpd->mat[a]); + BLO_expand(expander, gpd->mat[a]); } } -static void expand_workspace(FileData *fd, Main *mainvar, WorkSpace *workspace) +static void expand_workspace(BlendExpander *expander, WorkSpace *workspace) { LISTBASE_FOREACH (WorkSpaceLayout *, layout, &workspace->layouts) { - expand_doit(fd, mainvar, BKE_workspace_layout_screen_get(layout)); + BLO_expand(expander, BKE_workspace_layout_screen_get(layout)); } } -static void expand_hair(FileData *fd, Main *mainvar, Hair *hair) +static void expand_hair(BlendExpander *expander, Hair *hair) { for (int a = 0; a < hair->totcol; a++) { - expand_doit(fd, mainvar, hair->mat[a]); + BLO_expand(expander, hair->mat[a]); } if (hair->adt) { - expand_animdata(fd, mainvar, hair->adt); + expand_animdata(expander, hair->adt); } } -static void expand_pointcloud(FileData *fd, Main *mainvar, PointCloud *pointcloud) +static void expand_pointcloud(BlendExpander *expander, PointCloud *pointcloud) { for (int a = 0; a < pointcloud->totcol; a++) { - expand_doit(fd, mainvar, pointcloud->mat[a]); + BLO_expand(expander, pointcloud->mat[a]); } if (pointcloud->adt) { - expand_animdata(fd, mainvar, pointcloud->adt); + expand_animdata(expander, pointcloud->adt); } } -static void expand_volume(FileData *fd, Main *mainvar, Volume *volume) +static void expand_volume(BlendExpander *expander, Volume *volume) { for (int a = 0; a < volume->totcol; a++) { - expand_doit(fd, mainvar, volume->mat[a]); + BLO_expand(expander, volume->mat[a]); } if (volume->adt) { - expand_animdata(fd, mainvar, volume->adt); + expand_animdata(expander, volume->adt); } } -static void expand_simulation(FileData *fd, Main *mainvar, Simulation *simulation) +static void expand_simulation(BlendExpander *expander, Simulation *simulation) { if (simulation->adt) { - expand_animdata(fd, mainvar, simulation->adt); + expand_animdata(expander, simulation->adt); } } @@ -11399,6 +11359,8 @@ void BLO_expand_main(void *fdhandle, Main *mainvar) int a; bool do_it = true; + BlendExpander expander = {fd, mainvar}; + while (do_it) { do_it = false; @@ -11407,104 +11369,104 @@ void BLO_expand_main(void *fdhandle, Main *mainvar) id = lbarray[a]->first; while (id) { if (id->tag & LIB_TAG_NEED_EXPAND) { - expand_id(fd, mainvar, id); + expand_id(&expander, id); switch (GS(id->name)) { case ID_OB: - expand_object(fd, mainvar, (Object *)id); + expand_object(&expander, (Object *)id); break; case ID_ME: - expand_mesh(fd, mainvar, (Mesh *)id); + expand_mesh(&expander, (Mesh *)id); break; case ID_CU: - expand_curve(fd, mainvar, (Curve *)id); + expand_curve(&expander, (Curve *)id); break; case ID_MB: - expand_mball(fd, mainvar, (MetaBall *)id); + expand_mball(&expander, (MetaBall *)id); break; case ID_SCE: - expand_scene(fd, mainvar, (Scene *)id); + expand_scene(&expander, (Scene *)id); break; case ID_MA: - expand_material(fd, mainvar, (Material *)id); + expand_material(&expander, (Material *)id); break; case ID_TE: - expand_texture(fd, mainvar, (Tex *)id); + expand_texture(&expander, (Tex *)id); break; case ID_WO: - expand_world(fd, mainvar, (World *)id); + expand_world(&expander, (World *)id); break; case ID_LT: - expand_lattice(fd, mainvar, (Lattice *)id); + expand_lattice(&expander, (Lattice *)id); break; case ID_LA: - expand_light(fd, mainvar, (Light *)id); + expand_light(&expander, (Light *)id); break; case ID_KE: - expand_key(fd, mainvar, (Key *)id); + expand_key(&expander, (Key *)id); break; case ID_CA: - expand_camera(fd, mainvar, (Camera *)id); + expand_camera(&expander, (Camera *)id); break; case ID_SPK: - expand_speaker(fd, mainvar, (Speaker *)id); + expand_speaker(&expander, (Speaker *)id); break; case ID_SO: - expand_sound(fd, mainvar, (bSound *)id); + expand_sound(&expander, (bSound *)id); break; case ID_LP: - expand_lightprobe(fd, mainvar, (LightProbe *)id); + expand_lightprobe(&expander, (LightProbe *)id); break; case ID_AR: - expand_armature(fd, mainvar, (bArmature *)id); + expand_armature(&expander, (bArmature *)id); break; case ID_AC: - expand_action(fd, mainvar, (bAction *)id); // XXX deprecated - old animation system + expand_action(&expander, (bAction *)id); // XXX deprecated - old animation system break; case ID_GR: - expand_collection(fd, mainvar, (Collection *)id); + expand_collection(&expander, (Collection *)id); break; case ID_NT: - expand_nodetree(fd, mainvar, (bNodeTree *)id); + expand_nodetree(&expander, (bNodeTree *)id); break; case ID_BR: - expand_brush(fd, mainvar, (Brush *)id); + expand_brush(&expander, (Brush *)id); break; case ID_IP: - expand_ipo(fd, mainvar, (Ipo *)id); // XXX deprecated - old animation system + expand_ipo(&expander, (Ipo *)id); // XXX deprecated - old animation system break; case ID_PA: - expand_particlesettings(fd, mainvar, (ParticleSettings *)id); + expand_particlesettings(&expander, (ParticleSettings *)id); break; case ID_MC: - expand_movieclip(fd, mainvar, (MovieClip *)id); + expand_movieclip(&expander, (MovieClip *)id); break; case ID_MSK: - expand_mask(fd, mainvar, (Mask *)id); + expand_mask(&expander, (Mask *)id); break; case ID_LS: - expand_linestyle(fd, mainvar, (FreestyleLineStyle *)id); + expand_linestyle(&expander, (FreestyleLineStyle *)id); break; case ID_GD: - expand_gpencil(fd, mainvar, (bGPdata *)id); + expand_gpencil(&expander, (bGPdata *)id); break; case ID_CF: - expand_cachefile(fd, mainvar, (CacheFile *)id); + expand_cachefile(&expander, (CacheFile *)id); break; case ID_WS: - expand_workspace(fd, mainvar, (WorkSpace *)id); + expand_workspace(&expander, (WorkSpace *)id); break; case ID_HA: - expand_hair(fd, mainvar, (Hair *)id); + expand_hair(&expander, (Hair *)id); break; case ID_PT: - expand_pointcloud(fd, mainvar, (PointCloud *)id); + expand_pointcloud(&expander, (PointCloud *)id); break; case ID_VO: - expand_volume(fd, mainvar, (Volume *)id); + expand_volume(&expander, (Volume *)id); break; case ID_SIM: - expand_simulation(fd, mainvar, (Simulation *)id); + expand_simulation(&expander, (Simulation *)id); break; default: break; -- cgit v1.2.3 From 4b96f4783197c6bbf34230385b711d685df2b545 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 27 Jun 2020 14:34:16 +1000 Subject: Docs: correct invalid doxygen params & references --- source/blender/blenloader/BLO_writefile.h | 2 +- source/blender/blenloader/intern/readfile.c | 25 +++++++++++++------------ 2 files changed, 14 insertions(+), 13 deletions(-) (limited to 'source/blender/blenloader') diff --git a/source/blender/blenloader/BLO_writefile.h b/source/blender/blenloader/BLO_writefile.h index f9eada96308..8fe04e764f9 100644 --- a/source/blender/blenloader/BLO_writefile.h +++ b/source/blender/blenloader/BLO_writefile.h @@ -37,7 +37,7 @@ struct ReportList; * \{ */ /** - * Adjust paths when saving (kept unless #G_FILE_SAVE_COPY is set). + * Adjust paths when saving (kept unless #BlendFileWriteParams.use_save_as_copy is set). */ typedef enum eBLO_WritePathRemap { /** No path manipulation. */ diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 82b6b25a679..e9389561b47 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -11814,10 +11814,6 @@ ID *BLO_library_link_named_part(Main *mainl, * \param idcode: The kind of data-block to link. * \param name: The name of the data-block (without the 2 char ID prefix). * \param flag: Options for linking, used for instantiating. - * \param scene: The scene in which to instantiate objects/collections - * (if NULL, no instantiation is done). - * \param v3d: The active 3D viewport. - * (only to define active layers for instantiated objects & collections, can be NULL). * \return the linked ID when found. */ ID *BLO_library_link_named_part_ex( @@ -11856,13 +11852,13 @@ static Main *library_link_begin(Main *mainvar, FileData **fd, const char *filepa } /** - * Initialize the BlendHandle for linking library data. + * Initialize the #BlendHandle for linking library data. * * \param mainvar: The current main database, e.g. #G_MAIN or #CTX_data_main(C). * \param bh: A blender file handle as returned by * #BLO_blendhandle_from_file or #BLO_blendhandle_from_memory. * \param filepath: Used for relative linking, copied to the `lib->filepath`. - * \return the library Main, to be passed to #BLO_library_append_named_part as \a mainl. + * \return the library #Main, to be passed to #BLO_library_link_named_part_ex as \a mainl. */ Main *BLO_library_link_begin(Main *mainvar, BlendHandle **bh, const char *filepath) { @@ -11896,7 +11892,12 @@ static void split_main_newid(Main *mainptr, Main *main_newid) } } -/* scene and v3d may be NULL. */ +/** + * \param scene: The scene in which to instantiate objects/collections + * (if NULL, no instantiation is done). + * \param v3d: The active 3D viewport. + * (only to define active layers for instantiated objects & collections, can be NULL). + */ static void library_link_end(Main *mainl, FileData **fd, const short flag, @@ -11977,7 +11978,7 @@ static void library_link_end(Main *mainl, /* Give a base to loose objects and collections. * Only directly linked objects & collections are instantiated by - * `BLO_library_link_named_part_ex()` & co, + * #BLO_library_link_named_part_ex & co, * here we handle indirect ones and other possible edge-cases. */ if (scene) { add_collections_to_scene(mainvar, bmain, scene, view_layer, v3d, curlib, flag); @@ -12327,10 +12328,10 @@ static void read_libraries(FileData *basefd, ListBase *mainlist) lib_link_all(mainptr->curlib->filedata, mainptr); } - /* Note: No need to call `do_versions_after_linking()` or `BKE_main_id_refcount_recompute()` + /* Note: No need to call #do_versions_after_linking() or #BKE_main_id_refcount_recompute() * here, as this function is only called for library 'subset' data handling, as part of either - * full blendfile reading (`blo_read_file_internal()`), or libdata linking - * (`library_link_end()`). */ + * full blendfile reading (#blo_read_file_internal()), or library-data linking + * (#library_link_end()). */ /* Free file data we no longer need. */ if (mainptr->curlib->filedata) { @@ -12471,7 +12472,7 @@ void BLO_read_pointer_array(BlendDataReader *reader, void **ptr_p) int file_pointer_size = fd->filesdna->pointer_size; int current_pointer_size = fd->memsdna->pointer_size; - /* Overallocation is fine, but might be better to pass the length as parameter. */ + /* Over-allocation is fine, but might be better to pass the length as parameter. */ int array_size = MEM_allocN_len(orig_array) / file_pointer_size; void *final_array = NULL; -- cgit v1.2.3 From 1fa40c9f8a81036476d5051b09ff15e27b628012 Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Mon, 29 Jun 2020 15:00:25 -0400 Subject: UI: Add shortcuts for modifier panels The shortcuts act on the modifier with its panel under the mouse. The following shortcuts are enabled by default: - Remove modifier: X, Delete - Apply modifier: Ctrl A - Duplicate modifier: Shift D More shortcuts can be added in the keymap. Each panel can now store a custom data RNA pointer, and a new function is added to get the custom data for the panel under the cursor. This custom data could be used to refactor the "List Panel System" to generalize it and integrate it further with RNA. The same functionality will be added in further commits where it applies to constraints, grease pencil modifiers, and effects. Differential Revision: https://developer.blender.org/D8031 --- source/blender/blenloader/intern/readfile.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source/blender/blenloader') diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index e9389561b47..e4822c4cb7f 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -7015,6 +7015,7 @@ static void direct_link_panel_list(BlendDataReader *reader, ListBase *lb) panel->runtime_flag = 0; panel->activedata = NULL; panel->type = NULL; + panel->runtime.custom_data_ptr = NULL; direct_link_panel_list(reader, &panel->children); } } -- cgit v1.2.3 From 0b3313e53230914e79dd5c8f02b90fbaf6a8874b Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Tue, 30 Jun 2020 10:52:02 +0200 Subject: Cleanup: LibOverride: Replace raw pointers checks by proper macros. This is cleaner, but also crucial to avoid weird issues when behaviors of those checks are modified... --- source/blender/blenloader/intern/writefile.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source/blender/blenloader') diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 83c587cc446..86e878147e5 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -4070,7 +4070,8 @@ 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); - const bool do_override = !ELEM(override_storage, NULL, bmain) && id->override_library; + const bool do_override = !ELEM(override_storage, NULL, bmain) && + ID_IS_OVERRIDE_LIBRARY(id); if (do_override) { BKE_lib_override_library_operations_store_start(bmain, override_storage, id); -- cgit v1.2.3 From deb01eb1991e49fb912ede1ef036710e51b25fc5 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Tue, 30 Jun 2020 11:33:36 +0200 Subject: LibOverride: Add concept of 'embedded'/'virtual' override. IDs like embedded ones (master collections, root node trees) cannot be linked, and thus cannot be real override themselves. Since they are managed by their owner ID, that one will also have the overrides for their locally edited properties. We still need a way to mark them as overridden though, for various UI and override-internal purposes, this is done using a new ID flag. Note that since Shae Keys are not linkable, and their pointers are not editable in RNA, they are also considered as embedded from override point of view. --- source/blender/blenloader/intern/writefile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenloader') diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 86e878147e5..4e0325e72fa 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -4071,7 +4071,7 @@ static bool write_file_handle(Main *mainvar, (id->tag & (LIB_TAG_NO_MAIN | LIB_TAG_NO_USER_REFCOUNT | LIB_TAG_NOT_ALLOCATED)) == 0); const bool do_override = !ELEM(override_storage, NULL, bmain) && - ID_IS_OVERRIDE_LIBRARY(id); + ID_IS_OVERRIDE_LIBRARY_REAL(id); if (do_override) { BKE_lib_override_library_operations_store_start(bmain, override_storage, id); -- cgit v1.2.3 From 438bd823714a24475962ab89ad38b0d7e36349fe Mon Sep 17 00:00:00 2001 From: Pablo Dobarro Date: Tue, 23 Jun 2020 16:10:47 +0200 Subject: Sculpt: Pose Brush option to affect loose parts This option allows posing meshes with different disconnected elements using the Pose Brush. This is achieved by doing the following: - Creating an ID per vertex that stores the connected component of that vertex. - By using those IDs, one fake topology connection is created per vertex to the nearest vertex in a different ID. The maximum distance to create that connection is determined by the "Max Element Distance" property. These fake connectivity neighbors are used in the Sculpt API functions iterators, so all the algorithms of the Pose Brush can run without modifications as if everything was part of the same mesh. In order to make this work, the "Connected only" property of the Pose Brush needs to be disabled. This will add an extra performance cost to the Pose Brush and its preview. To achieve optimal results, max element distance should be as low as possible. Reviewed By: sergey, campbellbarton Differential Revision: https://developer.blender.org/D7282 --- source/blender/blenloader/intern/versioning_280.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'source/blender/blenloader') diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index d5ca47d726c..111ac728cc3 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -1759,6 +1759,14 @@ void do_versions_after_linking_280(Main *bmain, ReportList *UNUSED(reports)) brush->tip_scale_x = 1.0f; } } + + /* Pose Brush with support for loose parts. */ + LISTBASE_FOREACH (Brush *, brush, &bmain->brushes) { + if (brush->sculpt_tool == SCULPT_TOOL_POSE && brush->disconnected_distance_max == 0.0f) { + brush->flag2 |= BRUSH_USE_CONNECTED_ONLY; + brush->disconnected_distance_max = 0.1f; + } + } } } -- cgit v1.2.3