Commit: 0d24c6f0d034d277feeff2650a8165294a259691
Author: Sergey Sharybin
Date:   Fri Nov 29 23:16:13 2013 +0600
http://developer.blender.org/rB0d24c6f0d034d277feeff2650a8165294a259691

Move 2.6x versioning code to own file

Summary:
Makes readfile.c more clear and easier to navigate in.
We would need to do such a move when we'll do 2.70 bump
anyway. So better be prepared.

In fact, as soon 2.70 bumo is done i would think we'd
better create versioning_270 file and do version code
there. Otherwise readfile.c will grow up dramatically
again.

Reviewers: brecht, campbellbarton

Reviewed By: brecht

Differential Revision: http://developer.blender.org/D60

===================================================================

M       source/blender/blenloader/CMakeLists.txt
M       source/blender/blenloader/intern/readfile.c
M       source/blender/blenloader/intern/readfile.h
A       source/blender/blenloader/intern/versioning_260.c

===================================================================

diff --git a/source/blender/blenloader/CMakeLists.txt 
b/source/blender/blenloader/CMakeLists.txt
index 24b8df7..ba87a43 100644
--- a/source/blender/blenloader/CMakeLists.txt
+++ b/source/blender/blenloader/CMakeLists.txt
@@ -46,6 +46,7 @@ set(SRC
        intern/runtime.c
        intern/undofile.c
        intern/versioning_250.c
+       intern/versioning_260.c
        intern/versioning_defaults.c
        intern/versioning_legacy.c
        intern/writefile.c
diff --git a/source/blender/blenloader/intern/readfile.c 
b/source/blender/blenloader/intern/readfile.c
index 1773538..d0eb0ed 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -252,8 +252,7 @@ static void convert_tface_mt(FileData *fd, Main *main);
  * we could alternatively have a versions of a report function which forces 
printing - campbell
  */
 
-static void BKE_reportf_wrap(ReportList *reports, ReportType type, const char 
*format, ...) ATTR_PRINTF_FORMAT(3, 4);
-static void BKE_reportf_wrap(ReportList *reports, ReportType type, const char 
*format, ...)
+void blo_reportf_wrap(ReportList *reports, ReportType type, const char 
*format, ...)
 {
        char fixed_buf[1024]; /* should be long enough */
        
@@ -3026,7 +3025,7 @@ static void direct_link_lamp(FileData *fd, Lamp *la)
 
 /* ************ READ keys ***************** */
 
-static void do_versions_key_uidgen(Key *key)
+void blo_do_versions_key_uidgen(Key *key)
 {
        KeyBlock *block;
 
@@ -3043,7 +3042,7 @@ static void lib_link_key(FileData *fd, Main *main)
        for (key = main->key.first; key; key = key->id.next) {
                /*check if we need to generate unique ids for the shapekeys*/
                if (!key->uidgen) {
-                       do_versions_key_uidgen(key);
+                       blo_do_versions_key_uidgen(key);
                }
                
                if (key->id.flag & LIB_NEED_LINK) {
@@ -5130,7 +5129,7 @@ static void lib_link_scene(FileData *fd, Main *main)
                                base->object = newlibadr_us(fd, sce->id.lib, 
base->object);
                                
                                if (base->object == NULL) {
-                                       BKE_reportf_wrap(fd->reports, 
RPT_WARNING, TIP_("LIB ERROR: object lost from scene: '%s'"),
+                                       blo_reportf_wrap(fd->reports, 
RPT_WARNING, TIP_("LIB ERROR: object lost from scene: '%s'"),
                                                         sce->id.name + 2);
                                        BLI_remlink(&sce->base, base);
                                        if (base == sce->basact) sce->basact = 
NULL;
@@ -6523,7 +6522,7 @@ static void direct_link_library(FileData *fd, Library 
*lib, Main *main)
        for (newmain = fd->mainlist->first; newmain; newmain = newmain->next) {
                if (newmain->curlib) {
                        if (BLI_path_cmp(newmain->curlib->filepath, 
lib->filepath) == 0) {
-                               BKE_reportf_wrap(fd->reports, RPT_WARNING,
+                               blo_reportf_wrap(fd->reports, RPT_WARNING,
                                                 TIP_("Library '%s', '%s' had 
multiple instances, save and reload!"),
                                                 lib->name, lib->filepath);
                                
@@ -7370,552 +7369,6 @@ static void convert_tface_mt(FileData *fd, Main *main)
        }
 }
 
-static void do_versions_nodetree_image_default_alpha_output(bNodeTree *ntree)
-{
-       bNode *node;
-       bNodeSocket *sock;
-       
-       for (node = ntree->nodes.first; node; node = node->next) {
-               if (ELEM(node->type, CMP_NODE_IMAGE, CMP_NODE_R_LAYERS)) {
-                       /* default Image output value should have 0 alpha */
-                       sock = node->outputs.first;
-                       ((bNodeSocketValueRGBA 
*)(sock->default_value))->value[3] = 0.0f;
-               }
-       }
-}
-
-static void do_versions_nodetree_convert_angle(bNodeTree *ntree)
-{
-       bNode *node;
-       for (node=ntree->nodes.first; node; node=node->next) {
-               if (node->type == CMP_NODE_ROTATE) {
-                       /* Convert degrees to radians. */
-                       bNodeSocket *sock = 
((bNodeSocket*)node->inputs.first)->next;
-                       ((bNodeSocketValueFloat*)sock->default_value)->value = 
DEG2RADF(((bNodeSocketValueFloat*)sock->default_value)->value);
-               }
-               else if (node->type == CMP_NODE_DBLUR) {
-                       /* Convert degrees to radians. */
-                       NodeDBlurData *ndbd= node->storage;
-                       ndbd->angle = DEG2RADF(ndbd->angle);
-                       ndbd->spin = DEG2RADF(ndbd->spin);
-               }
-               else if (node->type == CMP_NODE_DEFOCUS) {
-                       /* Convert degrees to radians. */
-                       NodeDefocus *nqd = node->storage;
-                       /* XXX DNA char to float conversion seems to map the 
char value into the [0.0f, 1.0f] range... */
-                       nqd->rotation = DEG2RADF(nqd->rotation * 255.0f);
-               }
-               else if (node->type == CMP_NODE_CHROMA_MATTE) {
-                       /* Convert degrees to radians. */
-                       NodeChroma *ndc = node->storage;
-                       ndc->t1 = DEG2RADF(ndc->t1);
-                       ndc->t2 = DEG2RADF(ndc->t2);
-               }
-               else if (node->type == CMP_NODE_GLARE) {
-                       /* Convert degrees to radians. */
-                       NodeGlare *ndg = node->storage;
-                       /* XXX DNA char to float conversion seems to map the 
char value into the [0.0f, 1.0f] range... */
-                       ndg->angle_ofs = DEG2RADF(ndg->angle_ofs * 255.0f);
-               }
-               /* XXX TexMapping struct is used by other nodes too (at least 
node_composite_mapValue),
-                *     but not the rot part...
-                */
-               else if (node->type == SH_NODE_MAPPING) {
-                       /* Convert degrees to radians. */
-                       TexMapping *tmap = node->storage;
-                       tmap->rot[0] = DEG2RADF(tmap->rot[0]);
-                       tmap->rot[1] = DEG2RADF(tmap->rot[1]);
-                       tmap->rot[2] = DEG2RADF(tmap->rot[2]);
-               }
-       }
-}
-
-static void do_versions_image_settings_2_60(Scene *sce)
-{
-       /* note: rd->subimtype is moved into individual settings now and no 
longer
-        * exists */
-       RenderData *rd = &sce->r;
-       ImageFormatData *imf = &sce->r.im_format;
-
-       /* we know no data loss happens here, the old values were in char range 
*/
-       imf->imtype =   (char)rd->imtype;
-       imf->planes =   (char)rd->planes;
-       imf->compress = (char)rd->quality;
-       imf->quality =  (char)rd->quality;
-
-       /* default, was stored in multiple places, may override later */
-       imf->depth = R_IMF_CHAN_DEPTH_8;
-
-       /* openexr */
-       imf->exr_codec = rd->quality & 7; /* strange but true! 0-4 are valid 
values, OPENEXR_COMPRESS */
-
-       switch (imf->imtype) {
-       case R_IMF_IMTYPE_OPENEXR:
-               imf->depth =  (rd->subimtype & R_OPENEXR_HALF) ? 
R_IMF_CHAN_DEPTH_16 : R_IMF_CHAN_DEPTH_32;
-               if (rd->subimtype & R_PREVIEW_JPG) {
-                       imf->flag |= R_IMF_FLAG_PREVIEW_JPG;
-               }
-               if (rd->subimtype & R_OPENEXR_ZBUF) {
-                       imf->flag |= R_IMF_FLAG_ZBUF;
-               }
-               break;
-       case R_IMF_IMTYPE_TIFF:
-               if (rd->subimtype & R_TIFF_16BIT) {
-                       imf->depth= R_IMF_CHAN_DEPTH_16;
-               }
-               break;
-       case R_IMF_IMTYPE_JP2:
-               if (rd->subimtype & R_JPEG2K_16BIT) {
-                       imf->depth= R_IMF_CHAN_DEPTH_16;
-               }
-               else if (rd->subimtype & R_JPEG2K_12BIT) {
-                       imf->depth= R_IMF_CHAN_DEPTH_12;
-               }
-
-               if (rd->subimtype & R_JPEG2K_YCC) {
-                       imf->jp2_flag |= R_IMF_JP2_FLAG_YCC;
-               }
-               if (rd->subimtype & R_JPEG2K_CINE_PRESET) {
-                       imf->jp2_flag |= R_IMF_JP2_FLAG_CINE_PRESET;
-               }
-               if (rd->subimtype & R_JPEG2K_CINE_48FPS) {
-                       imf->jp2_flag |= R_IMF_JP2_FLAG_CINE_48;
-               }
-               break;
-       case R_IMF_IMTYPE_CINEON:
-       case R_IMF_IMTYPE_DPX:
-               if (rd->subimtype & R_CINEON_LOG) {
-                       imf->cineon_flag |= R_IMF_CINEON_FLAG_LOG;
-               }
-               break;
-       }
-
-}
-
-/* socket use flags were only temporary before */
-static void do_versions_nodetree_socket_use_flags_2_62(bNodeTree *ntree)
-{
-       bNode *node;
-       bNodeSocket *sock;
-       bNodeLink *link;
-       
-       for (node = ntree->nodes.first; node; node = node->next) {
-               for (sock = node->inputs.first; sock; sock = sock->next)
-                       sock->flag &= ~SOCK_IN_USE;
-               for (sock = node->outputs.first; sock; sock = sock->next)
-                       sock->flag &= ~SOCK_IN_USE;
-       }
-       for (sock = ntree->inputs.first; sock; sock = sock->next)
-               sock->flag &= ~SOCK_IN_USE;
-       for (sock = ntree->outputs.first; sock; sock = sock->next)
-               sock->flag &= ~SOCK_IN_USE;
-       
-       for (link = ntree->links.first; link; link = link->next) {
-               link->fromsock->flag |= SOCK_IN_USE;
-               link->tosock->flag |= SOCK_IN_USE;
-       }
-}
-
-static void do_versions_nodetree_multi_file_output_format_2_62_1(Scene *sce, 
bNodeTree *ntree)
-{
-       bNode *node;
-       
-       for (node = ntree->nodes.first; node; node = node->next) {
-               if (node->type == CMP_NODE_OUTPUT_FILE) {
-                       /* previous CMP_NODE_OUTPUT_FILE nodes get converted to 
multi-file outputs */
-                       NodeImageFile *old_data = node->storage;
-                       NodeImageMultiFile *nimf= 
MEM_callocN(sizeof(NodeImageMultiFile), "node image multi file");
-                       bNodeSocket *old_image = BLI_findlink(&node->inputs, 0);
-                       bNodeSocket *old_z = BLI_findlink(&node->inputs, 1);
-                       bNodeSocket *sock;
-                       char filename[FILE_MAXFILE];
-                       
-                       /* ugly, need to remove the old inputs list to avoid 
bad pointer checks when adding new sockets.
-                        * sock->storage is expected to contain path info in 
ntreeCompositOutputFileAddSocket.
-                        */
-                       node->inputs.first = node->inputs.last = NULL;
-                       
-                       node->storage = nimf;
-                       
-                       /* looks like storage data can be messed up somehow, 
stupid check here */
-                       if (old_data) {
-                               char basepath[FILE_MAXDIR];
-
-                               /* split off filename from the old path, to be 
used as socket sub-path */
-                               BLI_split_dirfile(old_data->name, basepath, 
filename, sizeof(basepath), sizeof(filename));
-                               
-                               BLI_strncpy(nimf->base_path, basepath, 
sizeof(nimf->base_path));
-                               nimf->format = old_data->im_format;
-                       }
-                       else {
-                               BLI_strncpy(filename, old_image->name, 
sizeof(filename));
-                       }
-                       
-                       /* if z buffer is saved, change the image type to 
multilayer exr.
-                        * XXX this is slightly messy, Z buffer was ignored 
before for anything but EXR and IRIS ...
-                        * i'm just assuming here that IRIZ means IRIS with z 
buffer ...
-                        */
-                       if (old_data && ELEM(old_data->im_format.imtype, 
R_IMF_IMTYPE_IRIZ, R_IMF_IMTYPE_OPENEXR)) {
-                               char sockpath[FILE_MAX];
-                               
-                               nimf->format.imtype = R_IMF_IMTYPE_MULTILAYER;
-                               
-                               BLI_snprintf(sockpath, sizeof(sockpath), 
"%s_Image", filename);
-                               sock = ntreeCompositOutputFileAddSocket(ntree, 
node, sockpath, &nimf->format);
-                               /* XXX later do_versions copies path from 
socket name, need to set this explicitely */
-                               BLI_strncpy(sock->name, sockpath, 
sizeof(sock->name));
-                               if (old_image->link) {
-                                       old_image->link->tosock = sock;
-                                       sock->link = old_image->link;
-                               }
-                               
-                               BLI_snprintf(sockpath, sizeof(sockpath), 
"%s_Z", filename);
-                               sock = ntreeCompositOutputFileAddSocket(ntree, 
node, sockpath, &nimf->format);
-                               /* XXX later do_versions copies path from 
socket name, need to set this explicitely */
-                               BLI_strncpy(sock->name, sockpath, 
sizeof(sock->name));
-                               if (old_z->link) {
-                                       old_z->link->tosock = sock;
-

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to