diff options
author | Joshua Leung <aligorith@gmail.com> | 2018-04-20 17:12:36 +0300 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2018-04-20 19:54:41 +0300 |
commit | 7be36661c2144936e349433c637835dac288a641 (patch) | |
tree | e26401af8b1d23306d93ec2a367802bdb23679ac /source | |
parent | 60e2c60be711a892459953b8788494fe869164e8 (diff) |
Dopesheet-Timeline: Somewhat hacky version-patching code to switch old timelines to dopesheet-timelines
After a lot of failed attempts and head banging working trying to find a way to reuse
the standard editor-switching/creation code, I've just hacked in a temporary solution
here so that users can load old files and see the old timeline instances replaced
with Dopesheet-Timelines.
Note: This is not nice code, and copies a lot of the standard initialisation code,
but it works well enough for now. We can revisit this later when the other mode changes
come along.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/BKE_blender_version.h | 2 | ||||
-rw-r--r-- | source/blender/blenloader/intern/versioning_280.c | 114 |
2 files changed, 115 insertions, 1 deletions
diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h index a16bdbb0683..a28c3cef199 100644 --- a/source/blender/blenkernel/BKE_blender_version.h +++ b/source/blender/blenkernel/BKE_blender_version.h @@ -28,7 +28,7 @@ * and keep comment above the defines. * Use STRINGIFY() rather than defining with quotes */ #define BLENDER_VERSION 280 -#define BLENDER_SUBVERSION 8 +#define BLENDER_SUBVERSION 9 /* Several breakages with 270, e.g. constraint deg vs rad */ #define BLENDER_MINVERSION 270 #define BLENDER_MINSUBVERSION 6 diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index 18eff782d99..9a46bff6644 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -29,6 +29,7 @@ #define DNA_DEPRECATED_ALLOW #include <string.h> +#include <float.h> #include "BLI_listbase.h" #include "BLI_mempool.h" @@ -624,6 +625,119 @@ void do_versions_after_linking_280(Main *main) } } } + + if (!MAIN_VERSION_ATLEAST(main, 280, 9)) { + /* Timeline Editor -> Dopesheet Timeline subeditor-mode */ + /* XXX: The code here is hacky, as the editor manipulation API's + * were only ever meant to be called from the UI (e.g. ED_area_newspace()) + */ + SpaceType *st = BKE_spacetype_from_id(SPACE_ACTION); + + for (bScreen *sc = main->screen.first; sc; sc = sc->id.next) { + for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) { + /* Convert timelines to dopesheet editors with timelines */ + if (sa->spacetype == SPACE_TIME) { + SpaceTime *stime = sa->spacedata.first; + ARegion *main_region = NULL; + ARegion *ar = NULL; + + /* manually init spaceaction settings + * NOTE: This duplicates action_new(), but it prevents compatability problems later + * XXX: We assume it's ok to just create another action edit instance, even if one existed + */ + SpaceAction *saction = MEM_callocN(sizeof(SpaceAction), "converted timeline"); + + saction->spacetype = SPACE_ACTION; + saction->mode = SACTCONT_TIMELINE; + + saction->autosnap = SACTSNAP_FRAME; + + saction->ads.filterflag |= ADS_FILTER_SUMMARY; + saction->ads.flag |= ADS_FLAG_SUMMARY_COLLAPSED; + + /* - enable all the cache settings */ + saction->cache_display |= TIME_CACHE_DISPLAY; + saction->cache_display |= (TIME_CACHE_SOFTBODY | TIME_CACHE_PARTICLES); + saction->cache_display |= (TIME_CACHE_CLOTH | TIME_CACHE_SMOKE | TIME_CACHE_DYNAMICPAINT); + saction->cache_display |= TIME_CACHE_RIGIDBODY; + + /* fix region settings */ + for (ar = sa->regionbase.first; ar; ar = ar->next) { + if (ar->regiontype == RGN_TYPE_WINDOW) { + main_region = ar; + break; + } + } + + if (ar) { + /* set normal view2D settings on the view2d bounds, so that dopesheet drawing works */ + /* see space_action.c::action_new() */ + BLI_assert(ar->regiontype == RGN_TYPE_WINDOW); + + ar->v2d.tot.ymin = ar->v2d.cur.ymin = (float)(-sa->winy) / 3.0f; + ar->v2d.tot.ymax = ar->v2d.cur.ymax = 0.0f; + + ar->v2d.min[0] = 0.0f; + ar->v2d.min[1] = 0.0f; + + ar->v2d.max[0] = MAXFRAMEF; + ar->v2d.max[1] = FLT_MAX; + + ar->v2d.minzoom = 0.01f; + ar->v2d.maxzoom = 50; + ar->v2d.scroll = (V2D_SCROLL_BOTTOM | V2D_SCROLL_SCALE_HORIZONTAL); + ar->v2d.scroll |= (V2D_SCROLL_RIGHT); + ar->v2d.keepzoom = V2D_LOCKZOOM_Y; + ar->v2d.keepofs = V2D_KEEPOFS_Y; + ar->v2d.align = V2D_ALIGN_NO_POS_Y; + ar->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL; + + /* add channel list region (see space_action.c) */ + ar = MEM_callocN(sizeof(ARegion), "channel region for action (versionpatch)"); + BLI_insertlinkbefore(&sa->regionbase, main_region, ar); + ar->regiontype = RGN_TYPE_CHANNELS; + ar->flag = RGN_FLAG_HIDDEN; + ar->alignment = RGN_ALIGN_LEFT; + ar->v2d.scroll = V2D_SCROLL_BOTTOM; + ar->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL; + + /* ui buttons (see space_action.c) */ + ar = MEM_callocN(sizeof(ARegion), "buttons region for action"); + BLI_insertlinkbefore(&sa->regionbase, main_region, ar); + ar->regiontype = RGN_TYPE_UI; + ar->alignment = RGN_ALIGN_RIGHT; + ar->flag = RGN_FLAG_HIDDEN; + } + + /* swap out action for time */ + /* NOTE: it should be fine to just free time spacedata, + * as all regions are currently hooked to action anyway + */ + BLI_freelinkN(&sa->spacedata, stime); + BLI_addhead(&sa->spacedata, saction); + + sa->spacetype = SPACE_ACTION; + sa->butspacetype = SPACE_ACTION; + + sa->type = st; + } + + /* Delete all saved spaces too */ + SpaceLink *sl_first = sa->spacedata.first; + SpaceLink *sl_next; + for (SpaceLink *sl = sl_first->next; sl; sl = sl_next) { + sl_next = sl->next; + if (sl->spacetype == SPACE_TIME) { + /* free regions for pushed spaces */ + BLI_freelistN(&sl->regionbase); + + /* free this stored space */ + BLI_freelinkN(&sa->spacedata, sl); + } + } + } + } + } } static void do_version_layer_collections_idproperties(ListBase *lb) |