diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h index 0ae342c7859..fc1cfda4e2d 100644 --- a/source/blender/blenkernel/BKE_blender_version.h +++ b/source/blender/blenkernel/BKE_blender_version.h @@ -27,7 +27,7 @@ /* Blender file format version. */ #define BLENDER_FILE_VERSION BLENDER_VERSION -#define BLENDER_FILE_SUBVERSION 13 +#define BLENDER_FILE_SUBVERSION 14 /* Minimum Blender version that supports reading file written with the current * version. Older Blender versions will test this and cancel loading the file, showing a warning to diff --git a/source/blender/blenkernel/intern/fmodifier.cc b/source/blender/blenkernel/intern/fmodifier.cc index ce6b8ff4162..1a5b6257c91 100644 --- a/source/blender/blenkernel/intern/fmodifier.cc +++ b/source/blender/blenkernel/intern/fmodifier.cc @@ -839,7 +839,7 @@ static void fcm_noise_evaluate(const FCurve * /*fcu*/, /* Using float2 to generate a phase offset. Offsetting the evaltime by `offset` to ensure that * the noise at full frames isn't always at 0. */ noise = blender::noise::perlin_fbm( - blender::float2(evaltime * scale - data->offset + offset, data->phase), + blender::float2((evaltime - data->offset) * scale + offset, data->phase), data->depth, data->roughness, data->lacunarity, diff --git a/source/blender/blenloader/intern/versioning_400.cc b/source/blender/blenloader/intern/versioning_400.cc index 9bc9614ec1b..7c6514aadb3 100644 --- a/source/blender/blenloader/intern/versioning_400.cc +++ b/source/blender/blenloader/intern/versioning_400.cc @@ -136,6 +136,34 @@ static void version_fcurve_noise_modifier(FCurve &fcurve) } } +static void version_fix_fcurve_noise_offset(FCurve &fcurve) +{ + LISTBASE_FOREACH (FModifier *, fcurve_modifier, &fcurve.modifiers) { + if (fcurve_modifier->type != FMODIFIER_TYPE_NOISE) { + continue; + } + FMod_Noise *data = static_cast(fcurve_modifier->data); + if (data->legacy_noise) { + /* We don't want to modify anything if the noise is set to legacy, because the issue only + * occurred on the new style noise. */ + continue; + } + data->offset *= data->size; + } +} + +static void nlastrips_apply_fcurve_versioning(ListBase &strips) +{ + LISTBASE_FOREACH (NlaStrip *, strip, &strips) { + LISTBASE_FOREACH (FCurve *, fcurve, &strip->fcurves) { + version_fix_fcurve_noise_offset(*fcurve); + } + + /* Check sub-strips (if meta-strips). */ + nlastrips_apply_fcurve_versioning(strip->strips); + } +} + /* Move bone-group color to the individual bones. */ static void version_bonegroup_migrate_color(Main *bmain) { @@ -2136,6 +2164,23 @@ void do_versions_after_linking_400(FileData *fd, Main *bmain) } } + if (!MAIN_VERSION_FILE_ATLEAST(bmain, 405, 14)) { + LISTBASE_FOREACH (bAction *, dna_action, &bmain->actions) { + blender::animrig::Action &action = dna_action->wrap(); + blender::animrig::foreach_fcurve_in_action( + action, [&](FCurve &fcurve) { version_fix_fcurve_noise_offset(fcurve); }); + } + + BKE_animdata_main_cb(bmain, [](ID * /* id */, AnimData *adt) { + LISTBASE_FOREACH (FCurve *, fcurve, &adt->drivers) { + version_fix_fcurve_noise_offset(*fcurve); + } + LISTBASE_FOREACH (NlaTrack *, track, &adt->nla_tracks) { + nlastrips_apply_fcurve_versioning(track->strips); + } + }); + } + /** * Always bump subversion in BKE_blender_version.h when adding versioning * code here, and wrap it inside a MAIN_VERSION_FILE_ATLEAST check.