diff options
author | Antonio Vazquez <blendergit@gmail.com> | 2020-08-06 18:27:45 +0300 |
---|---|---|
committer | Antonio Vazquez <blendergit@gmail.com> | 2020-08-06 18:28:59 +0300 |
commit | 96e460ed9b301b5a83399435bbf662a6258b243a (patch) | |
tree | c97f397dfc944497a70d441eb0f3e0146f04736a /source/blender | |
parent | bc8168f4a2795d65cbe3afc02e09582d43e337c5 (diff) |
GPencil: Patch old files after the change in how the first frame is used
This patching duplicates the first frame of the layer if the first frame number is not equals to the scene first frame number.
Related to T79567
Differential Revision: https://developer.blender.org/D8486
Some minor cleanup in the patch.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenloader/intern/versioning_290.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/source/blender/blenloader/intern/versioning_290.c b/source/blender/blenloader/intern/versioning_290.c index b6caa018756..a96b82e2e91 100644 --- a/source/blender/blenloader/intern/versioning_290.c +++ b/source/blender/blenloader/intern/versioning_290.c @@ -28,6 +28,7 @@ #include "DNA_constraint_types.h" #include "DNA_genfile.h" #include "DNA_gpencil_modifier_types.h" +#include "DNA_gpencil_types.h" #include "DNA_modifier_types.h" #include "DNA_object_types.h" #include "DNA_screen_types.h" @@ -35,6 +36,7 @@ #include "BKE_collection.h" #include "BKE_colortools.h" +#include "BKE_gpencil.h" #include "BKE_lib_id.h" #include "BKE_main.h" #include "BKE_node.h" @@ -183,6 +185,23 @@ void do_versions_after_linking_290(Main *bmain, ReportList *UNUSED(reports)) } } } + + /* Patch first frame for old files. */ + Scene *scene = bmain->scenes.first; + LISTBASE_FOREACH (Object *, ob, &bmain->objects) { + if (ob->type != OB_GPENCIL) { + continue; + } + bGPdata *gpd = ob->data; + LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) { + bGPDframe *gpf = gpl->frames.first; + if (gpf && gpf->framenum > scene->r.sfra) { + bGPDframe *gpf_dup = BKE_gpencil_frame_duplicate(gpf); + gpf_dup->framenum = scene->r.sfra; + BLI_addhead(&gpl->frames, gpf_dup); + } + } + } } /** |