diff options
author | Bastien Montagne <b.mont29@gmail.com> | 2020-02-05 18:18:17 +0300 |
---|---|---|
committer | Bastien Montagne <b.mont29@gmail.com> | 2020-02-05 18:18:17 +0300 |
commit | b841167ee35a483b34db343be7ac3291f162711b (patch) | |
tree | 3decd5f5e46e8dae3fa204ea186252dd1037d0e4 /source/blender/blenloader/intern/versioning_280.c | |
parent | c35d6b1854474ec02888f8812041651bdeb5145e (diff) |
Refactor readfile's liblink code.
Liblink specific ID type function was so far running a loop over all IDs
of relevant type, unlike almost any other 'ID-callback-like' functions
in Blender, which usually let the looping controll to calling code.
The latter approach is more convinient when one want to add generic
(i.e. type-agnostic) code, since it typically only has to change code in
one place (caller function) instead of tens of places (all the callback
functions).
This commit also changes/sanitizes a few things that had nothing to do
in main liblink code, like mesh conversion from tessfaces to polys
(which can be done in after-linking versionning code), or scenes' cycles
detection/check regarding background 'set' scenes.
Reviewed By: brecht
Differential Revision: https://developer.blender.org/D6727
Diffstat (limited to 'source/blender/blenloader/intern/versioning_280.c')
-rw-r--r-- | source/blender/blenloader/intern/versioning_280.c | 48 |
1 files changed, 36 insertions, 12 deletions
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index e92ae6e73cc..d8541975f86 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -70,6 +70,7 @@ #include "BKE_customdata.h" #include "BKE_fcurve.h" #include "BKE_freestyle.h" +#include "BKE_global.h" #include "BKE_idprop.h" #include "BKE_key.h" #include "BKE_library.h" @@ -1543,21 +1544,44 @@ void do_versions_after_linking_280(Main *bmain, ReportList *UNUSED(reports)) } } - { - /* Update all ruler layers to set new flag. */ - LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) { - bGPdata *gpd = scene->gpd; - if (gpd == NULL) { - continue; - } - for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) { - if (STREQ(gpl->info, "RulerData3D")) { - gpl->flag |= GP_LAYER_IS_RULER; - break; - } + /* Update all ruler layers to set new flag. */ + LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) { + bGPdata *gpd = scene->gpd; + if (gpd == NULL) { + continue; + } + for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) { + if (STREQ(gpl->info, "RulerData3D")) { + gpl->flag |= GP_LAYER_IS_RULER; + break; } } } + + /* This versionning could probably be done only on earlier versions, not sure however + * which exact version fully deprecated tessfaces, so think we can keep that one here, no + * harm to be expected anyway for being over-conservative. */ + for (Mesh *me = bmain->meshes.first; me != NULL; me = me->id.next) { + /*check if we need to convert mfaces to mpolys*/ + if (me->totface && !me->totpoly) { + /* temporarily switch main so that reading from + * external CustomData works */ + Main *gmain = G_MAIN; + G_MAIN = bmain; + + BKE_mesh_do_versions_convert_mfaces_to_mpolys(me); + + G_MAIN = gmain; + } + + /* Deprecated, only kept for conversion. */ + BKE_mesh_tessface_clear(me); + + /* Moved from do_versions because we need updated polygons for calculating normals. */ + if (MAIN_VERSION_OLDER(bmain, 256, 6)) { + BKE_mesh_calc_normals(me); + } + } } /** |