2 * This program is free software; you can redistribute it and/or
3 * modify it under the terms of the GNU General Public License
4 * as published by the Free Software Foundation; either version 2
5 * of the License, or (at your option) any later version.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software Foundation,
14 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 #include "BLI_utildefines.h"
23 /* allow readfile to use deprecated functionality */
24 #define DNA_DEPRECATED_ALLOW
26 #include "DNA_anim_types.h"
27 #include "DNA_brush_types.h"
28 #include "DNA_camera_types.h"
29 #include "DNA_cloth_types.h"
30 #include "DNA_constraint_types.h"
31 #include "DNA_fluid_types.h"
32 #include "DNA_genfile.h"
33 #include "DNA_key_types.h"
34 #include "DNA_light_types.h"
35 #include "DNA_linestyle_types.h"
36 #include "DNA_mesh_types.h"
37 #include "DNA_meshdata_types.h"
38 #include "DNA_object_fluidsim_types.h"
39 #include "DNA_object_types.h"
40 #include "DNA_screen_types.h"
41 #include "DNA_sdna_types.h"
42 #include "DNA_space_types.h"
43 #include "DNA_text_types.h"
44 #include "DNA_view3d_types.h"
45 #include "DNA_world_types.h"
47 #include "MEM_guardedalloc.h"
49 #include "BLI_blenlib.h"
51 #include "BLI_string_utils.h"
53 #include "BLT_translation.h"
55 #include "BKE_anim_visualization.h"
56 #include "BKE_image.h"
57 #include "BKE_main.h" // for Main
58 #include "BKE_mesh.h" // for ME_ defines (patching)
59 #include "BKE_modifier.h"
60 #include "BKE_particle.h"
61 #include "BKE_pointcache.h"
62 #include "BKE_scene.h"
63 #include "BKE_screen.h"
64 #include "BKE_sequencer.h"
65 #include "BKE_text.h" // for txt_extended_ascii_as_utf8
66 #include "BKE_texture.h"
67 #include "BKE_tracking.h"
70 # include "BKE_writeffmpeg.h"
73 #include "IMB_imbuf.h" // for proxy / timecode versioning stuff
75 #include "NOD_common.h"
76 #include "NOD_texture.h"
78 #include "BLO_readfile.h"
82 /* Make preferences read-only, use versioning_userdef.c. */
83 #define U (*((const UserDef *)&U))
85 static void do_versions_nodetree_image_default_alpha_output(bNodeTree *ntree)
90 for (node = ntree->nodes.first; node; node = node->next) {
91 if (ELEM(node->type, CMP_NODE_IMAGE, CMP_NODE_R_LAYERS)) {
92 /* default Image output value should have 0 alpha */
93 sock = node->outputs.first;
94 ((bNodeSocketValueRGBA *)(sock->default_value))->value[3] = 0.0f;
99 static void do_versions_nodetree_convert_angle(bNodeTree *ntree)
102 for (node = ntree->nodes.first; node; node = node->next) {
103 if (node->type == CMP_NODE_ROTATE) {
104 /* Convert degrees to radians. */
105 bNodeSocket *sock = ((bNodeSocket *)node->inputs.first)->next;
106 ((bNodeSocketValueFloat *)sock->default_value)->value = DEG2RADF(
107 ((bNodeSocketValueFloat *)sock->default_value)->value);
109 else if (node->type == CMP_NODE_DBLUR) {
110 /* Convert degrees to radians. */
111 NodeDBlurData *ndbd = node->storage;
112 ndbd->angle = DEG2RADF(ndbd->angle);
113 ndbd->spin = DEG2RADF(ndbd->spin);
115 else if (node->type == CMP_NODE_DEFOCUS) {
116 /* Convert degrees to radians. */
117 NodeDefocus *nqd = node->storage;
118 /* XXX DNA char to float conversion seems to map the char value
119 * into the [0.0f, 1.0f] range. */
120 nqd->rotation = DEG2RADF(nqd->rotation * 255.0f);
122 else if (node->type == CMP_NODE_CHROMA_MATTE) {
123 /* Convert degrees to radians. */
124 NodeChroma *ndc = node->storage;
125 ndc->t1 = DEG2RADF(ndc->t1);
126 ndc->t2 = DEG2RADF(ndc->t2);
128 else if (node->type == CMP_NODE_GLARE) {
129 /* Convert degrees to radians. */
130 NodeGlare *ndg = node->storage;
131 /* XXX DNA char to float conversion seems to map the char value
132 * into the [0.0f, 1.0f] range. */
133 ndg->angle_ofs = DEG2RADF(ndg->angle_ofs * 255.0f);
135 /* XXX TexMapping struct is used by other nodes too (at least node_composite_mapValue),
136 * but not the rot part...
138 else if (node->type == SH_NODE_MAPPING) {
139 /* Convert degrees to radians. */
140 TexMapping *tmap = node->storage;
141 tmap->rot[0] = DEG2RADF(tmap->rot[0]);
142 tmap->rot[1] = DEG2RADF(tmap->rot[1]);
143 tmap->rot[2] = DEG2RADF(tmap->rot[2]);
148 static void do_versions_image_settings_2_60(Scene *sce)
150 /* RenderData.subimtype flag options for imtype */
152 R_OPENEXR_HALF = (1 << 0),
153 R_OPENEXR_ZBUF = (1 << 1),
154 R_PREVIEW_JPG = (1 << 2),
155 R_CINEON_LOG = (1 << 3),
156 R_TIFF_16BIT = (1 << 4),
158 R_JPEG2K_12BIT = (1 << 5),
160 R_JPEG2K_16BIT = (1 << 6),
161 R_JPEG2K_YCC = (1 << 7),
162 /* when disabled use RGB */
163 R_JPEG2K_CINE_PRESET = (1 << 8),
164 R_JPEG2K_CINE_48FPS = (1 << 9),
167 /* note: rd->subimtype is moved into individual settings now and no longer
169 RenderData *rd = &sce->r;
170 ImageFormatData *imf = &sce->r.im_format;
172 /* we know no data loss happens here, the old values were in char range */
173 imf->imtype = (char)rd->imtype;
174 imf->planes = (char)rd->planes;
175 imf->compress = (char)rd->quality;
176 imf->quality = (char)rd->quality;
178 /* default, was stored in multiple places, may override later */
179 imf->depth = R_IMF_CHAN_DEPTH_8;
182 imf->exr_codec = rd->quality & 7; /* strange but true! 0-4 are valid values, OPENEXR_COMPRESS */
184 switch (imf->imtype) {
185 case R_IMF_IMTYPE_OPENEXR:
186 imf->depth = (rd->subimtype & R_OPENEXR_HALF) ? R_IMF_CHAN_DEPTH_16 : R_IMF_CHAN_DEPTH_32;
187 if (rd->subimtype & R_PREVIEW_JPG) {
188 imf->flag |= R_IMF_FLAG_PREVIEW_JPG;
190 if (rd->subimtype & R_OPENEXR_ZBUF) {
191 imf->flag |= R_IMF_FLAG_ZBUF;
194 case R_IMF_IMTYPE_TIFF:
195 if (rd->subimtype & R_TIFF_16BIT) {
196 imf->depth = R_IMF_CHAN_DEPTH_16;
199 case R_IMF_IMTYPE_JP2:
200 if (rd->subimtype & R_JPEG2K_16BIT) {
201 imf->depth = R_IMF_CHAN_DEPTH_16;
203 else if (rd->subimtype & R_JPEG2K_12BIT) {
204 imf->depth = R_IMF_CHAN_DEPTH_12;
207 if (rd->subimtype & R_JPEG2K_YCC) {
208 imf->jp2_flag |= R_IMF_JP2_FLAG_YCC;
210 if (rd->subimtype & R_JPEG2K_CINE_PRESET) {
211 imf->jp2_flag |= R_IMF_JP2_FLAG_CINE_PRESET;
213 if (rd->subimtype & R_JPEG2K_CINE_48FPS) {
214 imf->jp2_flag |= R_IMF_JP2_FLAG_CINE_48;
217 case R_IMF_IMTYPE_CINEON:
218 case R_IMF_IMTYPE_DPX:
219 if (rd->subimtype & R_CINEON_LOG) {
220 imf->cineon_flag |= R_IMF_CINEON_FLAG_LOG;
226 /* socket use flags were only temporary before */
227 static void do_versions_nodetree_socket_use_flags_2_62(bNodeTree *ntree)
233 for (node = ntree->nodes.first; node; node = node->next) {
234 for (sock = node->inputs.first; sock; sock = sock->next) {
235 sock->flag &= ~SOCK_IN_USE;
237 for (sock = node->outputs.first; sock; sock = sock->next) {
238 sock->flag &= ~SOCK_IN_USE;
241 for (sock = ntree->inputs.first; sock; sock = sock->next) {
242 sock->flag &= ~SOCK_IN_USE;
244 for (sock = ntree->outputs.first; sock; sock = sock->next) {
245 sock->flag &= ~SOCK_IN_USE;
248 for (link = ntree->links.first; link; link = link->next) {
249 link->fromsock->flag |= SOCK_IN_USE;
250 link->tosock->flag |= SOCK_IN_USE;
254 static void do_versions_nodetree_multi_file_output_format_2_62_1(Scene *sce, bNodeTree *ntree)
258 for (node = ntree->nodes.first; node; node = node->next) {
259 if (node->type == CMP_NODE_OUTPUT_FILE) {
260 /* previous CMP_NODE_OUTPUT_FILE nodes get converted to multi-file outputs */
261 NodeImageFile *old_data = node->storage;
262 NodeImageMultiFile *nimf = MEM_callocN(sizeof(NodeImageMultiFile), "node image multi file");
263 bNodeSocket *old_image = BLI_findlink(&node->inputs, 0);
264 bNodeSocket *old_z = BLI_findlink(&node->inputs, 1);
266 char filename[FILE_MAXFILE];
268 /* ugly, need to remove the old inputs list to avoid bad pointer
269 * checks when adding new sockets.
270 * sock->storage is expected to contain path info in ntreeCompositOutputFileAddSocket.
272 BLI_listbase_clear(&node->inputs);
274 node->storage = nimf;
276 /* looks like storage data can be messed up somehow, stupid check here */
278 char basepath[FILE_MAXDIR];
280 /* split off filename from the old path, to be used as socket sub-path */
281 BLI_split_dirfile(old_data->name, basepath, filename, sizeof(basepath), sizeof(filename));
283 BLI_strncpy(nimf->base_path, basepath, sizeof(nimf->base_path));
284 nimf->format = old_data->im_format;
287 BLI_strncpy(filename, old_image->name, sizeof(filename));
290 /* if z buffer is saved, change the image type to multilayer exr.
291 * XXX this is slightly messy, Z buffer was ignored before for anything but EXR and IRIS ...
292 * I'm just assuming here that IRIZ means IRIS with z buffer ...
294 if (old_data && ELEM(old_data->im_format.imtype, R_IMF_IMTYPE_IRIZ, R_IMF_IMTYPE_OPENEXR)) {
295 char sockpath[FILE_MAX];
297 nimf->format.imtype = R_IMF_IMTYPE_MULTILAYER;
299 BLI_snprintf(sockpath, sizeof(sockpath), "%s_Image", filename);
300 sock = ntreeCompositOutputFileAddSocket(ntree, node, sockpath, &nimf->format);
301 /* XXX later do_versions copies path from socket name, need to set this explicitly */
302 BLI_strncpy(sock->name, sockpath, sizeof(sock->name));
303 if (old_image->link) {
304 old_image->link->tosock = sock;
305 sock->link = old_image->link;
308 BLI_snprintf(sockpath, sizeof(sockpath), "%s_Z", filename);
309 sock = ntreeCompositOutputFileAddSocket(ntree, node, sockpath, &nimf->format);
310 /* XXX later do_versions copies path from socket name, need to set this explicitly */
311 BLI_strncpy(sock->name, sockpath, sizeof(sock->name));
313 old_z->link->tosock = sock;
314 sock->link = old_z->link;
318 sock = ntreeCompositOutputFileAddSocket(ntree, node, filename, &nimf->format);
319 /* XXX later do_versions copies path from socket name, need to set this explicitly */
320 BLI_strncpy(sock->name, filename, sizeof(sock->name));
321 if (old_image->link) {
322 old_image->link->tosock = sock;
323 sock->link = old_image->link;
327 nodeRemoveSocket(ntree, node, old_image);
328 nodeRemoveSocket(ntree, node, old_z);
333 else if (node->type == CMP_NODE_OUTPUT_MULTI_FILE__DEPRECATED) {
334 NodeImageMultiFile *nimf = node->storage;
337 /* CMP_NODE_OUTPUT_MULTI_FILE has been redeclared as CMP_NODE_OUTPUT_FILE */
338 node->type = CMP_NODE_OUTPUT_FILE;
340 /* initialize the node-wide image format from render data, if available */
342 nimf->format = sce->r.im_format;
345 /* transfer render format toggle to node format toggle */
346 for (sock = node->inputs.first; sock; sock = sock->next) {
347 NodeImageMultiFileSocket *simf = sock->storage;
348 simf->use_node_format = simf->use_render_format;
351 /* we do have preview now */
352 node->flag |= NODE_PREVIEW;
357 /* blue and red are swapped pre 2.62.1, be sane (red == red) now! */
358 static void do_versions_mesh_mloopcol_swap_2_62_1(Mesh *me)
360 CustomDataLayer *layer;
365 for (a = 0; a < me->ldata.totlayer; a++) {
366 layer = &me->ldata.layers[a];
368 if (layer->type == CD_MLOOPCOL) {
369 mloopcol = (MLoopCol *)layer->data;
370 for (i = 0; i < me->totloop; i++, mloopcol++) {
371 SWAP(uchar, mloopcol->r, mloopcol->b);
377 static void do_versions_nodetree_multi_file_output_path_2_63_1(bNodeTree *ntree)
381 for (node = ntree->nodes.first; node; node = node->next) {
382 if (node->type == CMP_NODE_OUTPUT_FILE) {
384 for (sock = node->inputs.first; sock; sock = sock->next) {
385 NodeImageMultiFileSocket *input = sock->storage;
386 /* input file path is stored in dedicated struct now instead socket name */
387 BLI_strncpy(input->path, sock->name, sizeof(input->path));
393 static void do_versions_nodetree_file_output_layers_2_64_5(bNodeTree *ntree)
397 for (node = ntree->nodes.first; node; node = node->next) {
398 if (node->type == CMP_NODE_OUTPUT_FILE) {
400 for (sock = node->inputs.first; sock; sock = sock->next) {
401 NodeImageMultiFileSocket *input = sock->storage;
403 /* multilayer names are stored as separate strings now,
404 * used the path string before, so copy it over.
406 BLI_strncpy(input->layer, input->path, sizeof(input->layer));
408 /* paths/layer names also have to be unique now, initial check */
409 ntreeCompositOutputFileUniquePath(&node->inputs, sock, input->path, '_');
410 ntreeCompositOutputFileUniqueLayer(&node->inputs, sock, input->layer, '_');
416 static void do_versions_nodetree_image_layer_2_64_5(bNodeTree *ntree)
420 for (node = ntree->nodes.first; node; node = node->next) {
421 if (node->type == CMP_NODE_IMAGE) {
423 for (sock = node->outputs.first; sock; sock = sock->next) {
424 NodeImageLayer *output = MEM_callocN(sizeof(NodeImageLayer), "node image layer");
426 /* take pass index both from current storage ptr (actually an int) */
427 output->pass_index = POINTER_AS_INT(sock->storage);
429 /* replace socket data pointer */
430 sock->storage = output;
436 static void do_versions_nodetree_frame_2_64_6(bNodeTree *ntree)
440 for (node = ntree->nodes.first; node; node = node->next) {
441 if (node->type == NODE_FRAME) {
442 /* initialize frame node storage data */
443 if (node->storage == NULL) {
444 NodeFrame *data = (NodeFrame *)MEM_callocN(sizeof(NodeFrame), "frame node storage");
445 node->storage = data;
447 /* copy current flags */
448 data->flag = node->custom1;
450 data->label_size = 20;
454 /* initialize custom node color */
455 node->color[0] = node->color[1] = node->color[2] = 0.608f; /* default theme color */
459 static void do_versions_affine_tracker_track(MovieTrackingTrack *track)
463 for (i = 0; i < track->markersnr; i++) {
464 MovieTrackingMarker *marker = &track->markers[i];
466 if (is_zero_v2(marker->pattern_corners[0]) && is_zero_v2(marker->pattern_corners[1]) &&
467 is_zero_v2(marker->pattern_corners[2]) && is_zero_v2(marker->pattern_corners[3])) {
468 marker->pattern_corners[0][0] = track->pat_min[0];
469 marker->pattern_corners[0][1] = track->pat_min[1];
471 marker->pattern_corners[1][0] = track->pat_max[0];
472 marker->pattern_corners[1][1] = track->pat_min[1];
474 marker->pattern_corners[2][0] = track->pat_max[0];
475 marker->pattern_corners[2][1] = track->pat_max[1];
477 marker->pattern_corners[3][0] = track->pat_min[0];
478 marker->pattern_corners[3][1] = track->pat_max[1];
481 if (is_zero_v2(marker->search_min) && is_zero_v2(marker->search_max)) {
482 copy_v2_v2(marker->search_min, track->search_min);
483 copy_v2_v2(marker->search_max, track->search_max);
488 static const char *node_get_static_idname(int type, int treetype)
490 /* use static type info header to map static int type to identifier string */
491 #define DefNode(Category, ID, DefFunc, EnumName, StructName, UIName, UIDesc) \
493 return #Category #StructName;
495 /* XXX hack, group types share a single static integer identifier,
496 * but are registered as separate types */
497 if (type == NODE_GROUP) {
500 return "CompositorNodeGroup";
502 return "ShaderNodeGroup";
504 return "TextureNodeGroup";
509 #include "NOD_static_types.h"
515 static const char *node_socket_get_static_idname(bNodeSocket *sock)
517 switch (sock->type) {
519 bNodeSocketValueFloat *dval = sock->default_value;
520 return nodeStaticSocketType(SOCK_FLOAT, dval->subtype);
523 bNodeSocketValueInt *dval = sock->default_value;
524 return nodeStaticSocketType(SOCK_INT, dval->subtype);
527 return nodeStaticSocketType(SOCK_BOOLEAN, PROP_NONE);
530 bNodeSocketValueVector *dval = sock->default_value;
531 return nodeStaticSocketType(SOCK_VECTOR, dval->subtype);
534 return nodeStaticSocketType(SOCK_RGBA, PROP_NONE);
537 bNodeSocketValueString *dval = sock->default_value;
538 return nodeStaticSocketType(SOCK_STRING, dval->subtype);
541 return nodeStaticSocketType(SOCK_SHADER, PROP_NONE);
547 static void do_versions_nodetree_customnodes(bNodeTree *ntree, int UNUSED(is_group))
549 /* initialize node tree type idname */
554 ntree->typeinfo = NULL;
556 /* tree type idname */
557 switch (ntree->type) {
559 strcpy(ntree->idname, "CompositorNodeTree");
562 strcpy(ntree->idname, "ShaderNodeTree");
565 strcpy(ntree->idname, "TextureNodeTree");
569 /* node type idname */
570 for (node = ntree->nodes.first; node; node = node->next) {
572 node->idname, node_get_static_idname(node->type, ntree->type), sizeof(node->idname));
574 /* existing old nodes have been initialized already */
575 node->flag |= NODE_INIT;
578 for (sock = node->inputs.first; sock; sock = sock->next) {
579 BLI_strncpy(sock->idname, node_socket_get_static_idname(sock), sizeof(sock->idname));
581 for (sock = node->outputs.first; sock; sock = sock->next) {
582 BLI_strncpy(sock->idname, node_socket_get_static_idname(sock), sizeof(sock->idname));
585 /* tree sockets idname */
586 for (sock = ntree->inputs.first; sock; sock = sock->next) {
587 BLI_strncpy(sock->idname, node_socket_get_static_idname(sock), sizeof(sock->idname));
589 for (sock = ntree->outputs.first; sock; sock = sock->next) {
590 BLI_strncpy(sock->idname, node_socket_get_static_idname(sock), sizeof(sock->idname));
594 /* initialize socket in_out values */
599 for (node = ntree->nodes.first; node; node = node->next) {
600 for (sock = node->inputs.first; sock; sock = sock->next) {
601 sock->in_out = SOCK_IN;
603 for (sock = node->outputs.first; sock; sock = sock->next) {
604 sock->in_out = SOCK_OUT;
607 for (sock = ntree->inputs.first; sock; sock = sock->next) {
608 sock->in_out = SOCK_IN;
610 for (sock = ntree->outputs.first; sock; sock = sock->next) {
611 sock->in_out = SOCK_OUT;
615 /* initialize socket identifier strings */
620 for (node = ntree->nodes.first; node; node = node->next) {
621 for (sock = node->inputs.first; sock; sock = sock->next) {
622 BLI_strncpy(sock->identifier, sock->name, sizeof(sock->identifier));
623 BLI_uniquename(&node->inputs,
627 offsetof(bNodeSocket, identifier),
628 sizeof(sock->identifier));
630 for (sock = node->outputs.first; sock; sock = sock->next) {
631 BLI_strncpy(sock->identifier, sock->name, sizeof(sock->identifier));
632 BLI_uniquename(&node->outputs,
636 offsetof(bNodeSocket, identifier),
637 sizeof(sock->identifier));
640 for (sock = ntree->inputs.first; sock; sock = sock->next) {
641 BLI_strncpy(sock->identifier, sock->name, sizeof(sock->identifier));
642 BLI_uniquename(&ntree->inputs,
646 offsetof(bNodeSocket, identifier),
647 sizeof(sock->identifier));
649 for (sock = ntree->outputs.first; sock; sock = sock->next) {
650 BLI_strncpy(sock->identifier, sock->name, sizeof(sock->identifier));
651 BLI_uniquename(&ntree->outputs,
655 offsetof(bNodeSocket, identifier),
656 sizeof(sock->identifier));
661 void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
663 if (bmain->versionfile < 260) {
665 /* set default alpha value of Image outputs in image and render layer nodes to 0 */
669 for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
670 /* there are files with invalid audio_channels value, the real cause
671 * is unknown, but we fix it here anyway to avoid crashes */
672 if (sce->r.ffcodecdata.audio_channels == 0) {
673 sce->r.ffcodecdata.audio_channels = 2;
677 do_versions_nodetree_image_default_alpha_output(sce->nodetree);
681 for (ntree = bmain->nodetrees.first; ntree; ntree = ntree->id.next) {
682 do_versions_nodetree_image_default_alpha_output(ntree);
687 /* support old particle dupliobject rotation settings */
688 ParticleSettings *part;
690 for (part = bmain->particles.first; part; part = part->id.next) {
691 if (ELEM(part->ren_as, PART_DRAW_OB, PART_DRAW_GR)) {
692 part->draw |= PART_DRAW_ROTATE_OB;
694 if (part->rotmode == 0) {
695 part->rotmode = PART_ROT_VEL;
702 if (bmain->versionfile < 260 || (bmain->versionfile == 260 && bmain->subversionfile < 1)) {
705 for (ob = bmain->objects.first; ob; ob = ob->id.next) {
706 ob->collision_boundtype = ob->boundtype;
711 for (cam = bmain->cameras.first; cam; cam = cam->id.next) {
712 if (cam->sensor_x < 0.01f) {
713 cam->sensor_x = DEFAULT_SENSOR_WIDTH;
716 if (cam->sensor_y < 0.01f) {
717 cam->sensor_y = DEFAULT_SENSOR_HEIGHT;
723 if (bmain->versionfile < 260 || (bmain->versionfile == 260 && bmain->subversionfile < 2)) {
724 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
725 if (ntree->type == NTREE_SHADER) {
727 for (node = ntree->nodes.first; node; node = node->next) {
728 if (node->type == SH_NODE_MAPPING) {
729 TexMapping *tex_mapping;
731 tex_mapping = node->storage;
732 tex_mapping->projx = PROJ_X;
733 tex_mapping->projy = PROJ_Y;
734 tex_mapping->projz = PROJ_Z;
739 FOREACH_NODETREE_END;
742 if (bmain->versionfile < 260 || (bmain->versionfile == 260 && bmain->subversionfile < 4)) {
744 /* Convert node angles to radians! */
749 for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
751 do_versions_nodetree_convert_angle(sce->nodetree);
755 for (mat = bmain->materials.first; mat; mat = mat->id.next) {
757 do_versions_nodetree_convert_angle(mat->nodetree);
761 for (ntree = bmain->nodetrees.first; ntree; ntree = ntree->id.next) {
762 do_versions_nodetree_convert_angle(ntree);
767 /* Tomato compatibility code. */
771 for (screen = bmain->screens.first; screen; screen = screen->id.next) {
773 for (area = screen->areabase.first; area; area = area->next) {
775 for (sl = area->spacedata.first; sl; sl = sl->next) {
776 if (sl->spacetype == SPACE_VIEW3D) {
777 View3D *v3d = (View3D *)sl;
778 if (v3d->bundle_size == 0.0f) {
779 v3d->bundle_size = 0.2f;
780 v3d->flag2 |= V3D_SHOW_RECONSTRUCTION;
783 if (v3d->bundle_drawtype == 0) {
784 v3d->bundle_drawtype = OB_PLAINAXES;
787 else if (sl->spacetype == SPACE_CLIP) {
788 SpaceClip *sclip = (SpaceClip *)sl;
789 if (sclip->scopes.track_preview_height == 0) {
790 sclip->scopes.track_preview_height = 120;
797 for (clip = bmain->movieclips.first; clip; clip = clip->id.next) {
798 MovieTrackingTrack *track;
800 if (clip->aspx < 1.0f) {
805 clip->proxy.build_tc_flag = IMB_TC_RECORD_RUN | IMB_TC_FREE_RUN |
806 IMB_TC_INTERPOLATED_REC_DATE_FREE_RUN;
808 if (clip->proxy.build_size_flag == 0) {
809 clip->proxy.build_size_flag = IMB_PROXY_25;
812 if (clip->proxy.quality == 0) {
813 clip->proxy.quality = 90;
816 if (clip->tracking.camera.pixel_aspect < 0.01f) {
817 clip->tracking.camera.pixel_aspect = 1.0f;
820 track = clip->tracking.tracks.first;
822 if (track->minimum_correlation == 0.0f) {
823 track->minimum_correlation = 0.75f;
832 if (bmain->versionfile < 260 || (bmain->versionfile == 260 && bmain->subversionfile < 6)) {
836 for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
837 do_versions_image_settings_2_60(sce);
840 for (clip = bmain->movieclips.first; clip; clip = clip->id.next) {
841 MovieTrackingSettings *settings = &clip->tracking.settings;
843 if (settings->default_pattern_size == 0.0f) {
844 settings->default_motion_model = TRACK_MOTION_MODEL_TRANSLATION;
845 settings->default_minimum_correlation = 0.75;
846 settings->default_pattern_size = 11;
847 settings->default_search_size = 51;
853 for (ob = bmain->objects.first; ob; ob = ob->id.next) {
854 /* convert delta addition into delta scale */
856 for (i = 0; i < 3; i++) {
857 if ((ob->dsize[i] == 0.0f) || /* simple case, user never touched dsize */
858 (ob->scale[i] == 0.0f)) /* cant scale the dsize to give a non zero result,
859 * so fallback to 1.0f */
861 ob->dscale[i] = 1.0f;
864 ob->dscale[i] = (ob->scale[i] + ob->dsize[i]) / ob->scale[i];
870 /* sigh, this dscale vs dsize version patching was not done right, fix for fix,
871 * this intentionally checks an exact subversion, also note this was never in a release,
872 * at some point this could be removed. */
873 else if (bmain->versionfile == 260 && bmain->subversionfile == 6) {
875 for (ob = bmain->objects.first; ob; ob = ob->id.next) {
876 if (is_zero_v3(ob->dscale)) {
877 copy_vn_fl(ob->dscale, 3, 1.0f);
882 if (bmain->versionfile < 260 || (bmain->versionfile == 260 && bmain->subversionfile < 8)) {
885 for (brush = bmain->brushes.first; brush; brush = brush->id.next) {
886 if (brush->sculpt_tool == SCULPT_TOOL_ROTATE) {
892 if (bmain->versionfile < 261 || (bmain->versionfile == 261 && bmain->subversionfile < 1)) {
894 /* update use flags for node sockets (was only temporary before) */
901 for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
903 do_versions_nodetree_socket_use_flags_2_62(sce->nodetree);
907 for (mat = bmain->materials.first; mat; mat = mat->id.next) {
909 do_versions_nodetree_socket_use_flags_2_62(mat->nodetree);
913 for (tex = bmain->textures.first; tex; tex = tex->id.next) {
915 do_versions_nodetree_socket_use_flags_2_62(tex->nodetree);
919 for (Light *la = bmain->lights.first; la; la = la->id.next) {
921 do_versions_nodetree_socket_use_flags_2_62(la->nodetree);
925 for (world = bmain->worlds.first; world; world = world->id.next) {
926 if (world->nodetree) {
927 do_versions_nodetree_socket_use_flags_2_62(world->nodetree);
931 for (ntree = bmain->nodetrees.first; ntree; ntree = ntree->id.next) {
932 do_versions_nodetree_socket_use_flags_2_62(ntree);
939 for (clip = bmain->movieclips.first; clip; clip = clip->id.next) {
940 MovieTracking *tracking = &clip->tracking;
941 MovieTrackingObject *tracking_object = tracking->objects.first;
943 clip->proxy.build_tc_flag |= IMB_TC_RECORD_RUN_NO_GAPS;
945 if (!tracking->settings.object_distance) {
946 tracking->settings.object_distance = 1.0f;
949 if (BLI_listbase_is_empty(&tracking->objects)) {
950 BKE_tracking_object_add(tracking, "Camera");
953 while (tracking_object) {
954 if (!tracking_object->scale) {
955 tracking_object->scale = 1.0f;
958 tracking_object = tracking_object->next;
962 for (ob = bmain->objects.first; ob; ob = ob->id.next) {
964 for (con = ob->constraints.first; con; con = con->next) {
965 if (con->type == CONSTRAINT_TYPE_OBJECTSOLVER) {
966 bObjectSolverConstraint *data = (bObjectSolverConstraint *)con->data;
968 if (data->invmat[3][3] == 0.0f) {
969 unit_m4(data->invmat);
977 if (bmain->versionfile < 261 || (bmain->versionfile == 261 && bmain->subversionfile < 2)) {
979 /* convert deprecated sculpt_paint_unified_* fields to
980 * UnifiedPaintSettings */
982 for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
983 ToolSettings *ts = scene->toolsettings;
984 UnifiedPaintSettings *ups = &ts->unified_paint_settings;
985 ups->size = ts->sculpt_paint_unified_size;
986 ups->unprojected_radius = ts->sculpt_paint_unified_unprojected_radius;
987 ups->alpha = ts->sculpt_paint_unified_alpha;
988 ups->flag = ts->sculpt_paint_settings;
993 if (bmain->versionfile < 261 || (bmain->versionfile == 261 && bmain->subversionfile < 3)) {
995 /* convert extended ascii to utf-8 for text editor */
997 for (text = bmain->texts.first; text; text = text->id.next) {
998 if (!(text->flags & TXT_ISEXT)) {
1001 for (tl = text->lines.first; tl; tl = tl->next) {
1002 int added = txt_extended_ascii_as_utf8(&tl->line);
1005 /* reset cursor position if line was changed */
1006 if (added && tl == text->curl) {
1014 /* set new dynamic paint values */
1016 for (ob = bmain->objects.first; ob; ob = ob->id.next) {
1018 for (md = ob->modifiers.first; md; md = md->next) {
1019 if (md->type == eModifierType_DynamicPaint) {
1020 DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md;
1022 DynamicPaintSurface *surface = pmd->canvas->surfaces.first;
1023 for (; surface; surface = surface->next) {
1024 surface->color_dry_threshold = 1.0f;
1025 surface->influence_scale = 1.0f;
1026 surface->radius_scale = 1.0f;
1027 surface->flags |= MOD_DPAINT_USE_DRYING;
1036 if (bmain->versionfile < 262) {
1038 for (ob = bmain->objects.first; ob; ob = ob->id.next) {
1041 for (md = ob->modifiers.first; md; md = md->next) {
1042 if (md->type == eModifierType_Cloth) {
1043 ClothModifierData *clmd = (ClothModifierData *)md;
1044 if (clmd->sim_parms) {
1045 clmd->sim_parms->vel_damping = 1.0f;
1052 if (bmain->versionfile < 263) {
1053 /* set fluidsim rate. the version patch for this in 2.62 was wrong, so
1054 * try to correct it, if rate is 0.0 that's likely not intentional */
1057 for (ob = bmain->objects.first; ob; ob = ob->id.next) {
1059 for (md = ob->modifiers.first; md; md = md->next) {
1060 if (md->type == eModifierType_Fluidsim) {
1061 FluidsimModifierData *fmd = (FluidsimModifierData *)md;
1062 if (fmd->fss->animRate == 0.0f) {
1063 fmd->fss->animRate = 1.0f;
1070 if (bmain->versionfile < 262 || (bmain->versionfile == 262 && bmain->subversionfile < 1)) {
1071 /* update use flags for node sockets (was only temporary before) */
1075 for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
1076 if (sce->nodetree) {
1077 do_versions_nodetree_multi_file_output_format_2_62_1(sce, sce->nodetree);
1081 /* XXX can't associate with scene for group nodes, image format will stay uninitialized */
1082 for (ntree = bmain->nodetrees.first; ntree; ntree = ntree->id.next) {
1083 do_versions_nodetree_multi_file_output_format_2_62_1(NULL, ntree);
1087 /* only swap for pre-release bmesh merge which had MLoopCol red/blue swap */
1088 if (bmain->versionfile == 262 && bmain->subversionfile == 1) {
1091 for (me = bmain->meshes.first; me; me = me->id.next) {
1092 do_versions_mesh_mloopcol_swap_2_62_1(me);
1097 if (bmain->versionfile < 262 || (bmain->versionfile == 262 && bmain->subversionfile < 2)) {
1098 /* Set new idname of keyingsets from their now "label-only" name. */
1100 for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
1102 for (ks = scene->keyingsets.first; ks; ks = ks->next) {
1103 if (!ks->idname[0]) {
1104 BLI_strncpy(ks->idname, ks->name, sizeof(ks->idname));
1110 if (bmain->versionfile < 262 || (bmain->versionfile == 262 && bmain->subversionfile < 3)) {
1114 for (ob = bmain->objects.first; ob; ob = ob->id.next) {
1115 for (md = ob->modifiers.first; md; md = md->next) {
1116 if (md->type == eModifierType_Lattice) {
1117 LatticeModifierData *lmd = (LatticeModifierData *)md;
1118 lmd->strength = 1.0f;
1124 if (bmain->versionfile < 262 || (bmain->versionfile == 262 && bmain->subversionfile < 4)) {
1125 /* Read Viscosity presets from older files */
1128 for (ob = bmain->objects.first; ob; ob = ob->id.next) {
1130 for (md = ob->modifiers.first; md; md = md->next) {
1131 if (md->type == eModifierType_Fluidsim) {
1132 FluidsimModifierData *fmd = (FluidsimModifierData *)md;
1133 if (fmd->fss->viscosityMode == 3) {
1134 fmd->fss->viscosityValue = 5.0;
1135 fmd->fss->viscosityExponent = 5;
1137 else if (fmd->fss->viscosityMode == 4) {
1138 fmd->fss->viscosityValue = 2.0;
1139 fmd->fss->viscosityExponent = 3;
1146 if (bmain->versionfile < 263) {
1147 /* Default for old files is to save particle rotations to pointcache */
1148 ParticleSettings *part;
1149 for (part = bmain->particles.first; part; part = part->id.next) {
1150 part->flag |= PART_ROTATIONS;
1154 if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 1)) {
1155 /* file output node paths are now stored in the file info struct instead socket name */
1159 for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
1160 if (sce->nodetree) {
1161 do_versions_nodetree_multi_file_output_path_2_63_1(sce->nodetree);
1164 for (ntree = bmain->nodetrees.first; ntree; ntree = ntree->id.next) {
1165 do_versions_nodetree_multi_file_output_path_2_63_1(ntree);
1169 if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 3)) {
1173 /* For weight paint, each brush now gets its own weight;
1174 * unified paint settings also have weight. Update unified
1175 * paint settings and brushes with a default weight value. */
1177 for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
1178 ToolSettings *ts = scene->toolsettings;
1180 ts->unified_paint_settings.weight = ts->vgroup_weight;
1181 ts->unified_paint_settings.flag |= UNIFIED_PAINT_WEIGHT;
1185 for (brush = bmain->brushes.first; brush; brush = brush->id.next) {
1186 brush->weight = 0.5;
1190 if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 2)) {
1193 for (screen = bmain->screens.first; screen; screen = screen->id.next) {
1195 for (area = screen->areabase.first; area; area = area->next) {
1198 for (sl = area->spacedata.first; sl; sl = sl->next) {
1199 if (sl->spacetype == SPACE_CLIP) {
1200 SpaceClip *sclip = (SpaceClip *)sl;
1204 for (region = area->regionbase.first; region; region = region->next) {
1205 if (region->regiontype == RGN_TYPE_PREVIEW) {
1206 if (region->alignment != RGN_ALIGN_NONE) {
1207 region->flag |= RGN_FLAG_HIDDEN;
1208 region->v2d.flag &= ~V2D_IS_INITIALISED;
1209 region->alignment = RGN_ALIGN_NONE;
1217 sclip->view = SC_VIEW_CLIP;
1225 if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 4)) {
1229 for (cam = bmain->cameras.first; cam; cam = cam->id.next) {
1230 if (cam->flag & CAM_PANORAMA) {
1231 cam->type = CAM_PANO;
1232 cam->flag &= ~CAM_PANORAMA;
1236 for (cu = bmain->curves.first; cu; cu = cu->id.next) {
1237 if (cu->bevfac2 == 0.0f) {
1244 if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 5)) {
1246 /* file output node paths are now stored in the file info struct instead socket name */
1250 for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
1251 if (sce->nodetree) {
1252 do_versions_nodetree_file_output_layers_2_64_5(sce->nodetree);
1253 do_versions_nodetree_image_layer_2_64_5(sce->nodetree);
1256 for (ntree = bmain->nodetrees.first; ntree; ntree = ntree->id.next) {
1257 do_versions_nodetree_file_output_layers_2_64_5(ntree);
1258 do_versions_nodetree_image_layer_2_64_5(ntree);
1263 if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 6)) {
1264 /* update use flags for node sockets (was only temporary before) */
1271 for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
1272 if (sce->nodetree) {
1273 do_versions_nodetree_frame_2_64_6(sce->nodetree);
1277 for (mat = bmain->materials.first; mat; mat = mat->id.next) {
1278 if (mat->nodetree) {
1279 do_versions_nodetree_frame_2_64_6(mat->nodetree);
1283 for (tex = bmain->textures.first; tex; tex = tex->id.next) {
1284 if (tex->nodetree) {
1285 do_versions_nodetree_frame_2_64_6(tex->nodetree);
1289 for (Light *la = bmain->lights.first; la; la = la->id.next) {
1291 do_versions_nodetree_frame_2_64_6(la->nodetree);
1295 for (world = bmain->worlds.first; world; world = world->id.next) {
1296 if (world->nodetree) {
1297 do_versions_nodetree_frame_2_64_6(world->nodetree);
1301 for (ntree = bmain->nodetrees.first; ntree; ntree = ntree->id.next) {
1302 do_versions_nodetree_frame_2_64_6(ntree);
1306 if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 7)) {
1309 for (ob = bmain->objects.first; ob; ob = ob->id.next) {
1311 for (md = ob->modifiers.first; md; md = md->next) {
1312 if (md->type == eModifierType_Fluid) {
1313 FluidModifierData *mmd = (FluidModifierData *)md;
1314 if ((mmd->type & MOD_FLUID_TYPE_DOMAIN) && mmd->domain) {
1315 int maxres = max_iii(mmd->domain->res[0], mmd->domain->res[1], mmd->domain->res[2]);
1316 mmd->domain->scale = mmd->domain->dx * maxres;
1317 mmd->domain->dx = 1.0f / mmd->domain->scale;
1324 if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 9)) {
1325 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
1326 if (ntree->type == NTREE_SHADER) {
1328 for (node = ntree->nodes.first; node; node = node->next) {
1329 if (ELEM(node->type, SH_NODE_TEX_IMAGE, SH_NODE_TEX_ENVIRONMENT)) {
1330 NodeTexImage *tex = node->storage;
1332 tex->iuser.frames = 1;
1333 tex->iuser.sfra = 1;
1339 FOREACH_NODETREE_END;
1342 if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 10)) {
1345 // composite redesign
1346 for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
1347 if (scene->nodetree) {
1348 if (scene->nodetree->chunksize == 0) {
1349 scene->nodetree->chunksize = 256;
1354 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
1355 if (ntree->type == NTREE_COMPOSIT) {
1357 for (node = ntree->nodes.first; node; node = node->next) {
1358 if (node->type == CMP_NODE_DEFOCUS) {
1359 NodeDefocus *data = node->storage;
1360 if (data->maxblur == 0.0f) {
1361 data->maxblur = 16.0f;
1367 FOREACH_NODETREE_END;
1373 for (screen = bmain->screens.first; screen; screen = screen->id.next) {
1376 for (area = screen->areabase.first; area; area = area->next) {
1379 for (sl = area->spacedata.first; sl; sl = sl->next) {
1380 if (sl->spacetype == SPACE_CLIP) {
1381 SpaceClip *sclip = (SpaceClip *)sl;
1383 if (sclip->around == 0) {
1384 sclip->around = V3D_AROUND_CENTER_MEDIAN;
1395 for (clip = bmain->movieclips.first; clip; clip = clip->id.next) {
1396 clip->start_frame = 1;
1401 if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 11)) {
1404 for (clip = bmain->movieclips.first; clip; clip = clip->id.next) {
1405 MovieTrackingTrack *track;
1407 track = clip->tracking.tracks.first;
1409 do_versions_affine_tracker_track(track);
1411 track = track->next;
1416 if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 13)) {
1417 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
1418 if (ntree->type == NTREE_COMPOSIT) {
1420 for (node = ntree->nodes.first; node; node = node->next) {
1421 if (node->type == CMP_NODE_DILATEERODE) {
1422 if (node->storage == NULL) {
1423 NodeDilateErode *data = MEM_callocN(sizeof(NodeDilateErode), __func__);
1424 data->falloff = PROP_SMOOTH;
1425 node->storage = data;
1431 FOREACH_NODETREE_END;
1434 if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 14)) {
1435 ParticleSettings *part;
1437 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
1438 if (ntree->type == NTREE_COMPOSIT) {
1440 for (node = ntree->nodes.first; node; node = node->next) {
1441 if (node->type == CMP_NODE_KEYING) {
1442 NodeKeyingData *data = node->storage;
1444 if (data->despill_balance == 0.0f) {
1445 data->despill_balance = 0.5f;
1451 FOREACH_NODETREE_END;
1453 /* keep compatibility for dupliobject particle size */
1454 for (part = bmain->particles.first; part; part = part->id.next) {
1455 if (ELEM(part->ren_as, PART_DRAW_OB, PART_DRAW_GR)) {
1456 if ((part->draw & PART_DRAW_ROTATE_OB) == 0) {
1457 part->draw |= PART_DRAW_NO_SCALE_OB;
1463 if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 17)) {
1464 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
1465 if (ntree->type == NTREE_COMPOSIT) {
1467 for (node = ntree->nodes.first; node; node = node->next) {
1468 if (node->type == CMP_NODE_MASK) {
1469 if (node->storage == NULL) {
1470 NodeMask *data = MEM_callocN(sizeof(NodeMask), __func__);
1471 /* move settings into own struct */
1472 data->size_x = (int)node->custom3;
1473 data->size_y = (int)node->custom4;
1474 node->custom3 = 0.5f; /* default shutter */
1475 node->storage = data;
1481 FOREACH_NODETREE_END;
1484 if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 18)) {
1487 for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
1491 SEQ_BEGIN (scene->ed, seq) {
1492 Strip *strip = seq->strip;
1494 if (strip && strip->color_balance) {
1495 SequenceModifierData *smd;
1496 ColorBalanceModifierData *cbmd;
1498 smd = BKE_sequence_modifier_new(seq, NULL, seqModifierType_ColorBalance);
1499 cbmd = (ColorBalanceModifierData *)smd;
1501 cbmd->color_balance = *strip->color_balance;
1503 /* multiplication with color balance used is handled differently,
1504 * so we need to move multiplication to modifier so files would be
1507 cbmd->color_multiply = seq->mul;
1510 MEM_freeN(strip->color_balance);
1511 strip->color_balance = NULL;
1519 /* color management pipeline changes compatibility code */
1520 if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 19)) {
1523 bool colormanagement_disabled = false;
1525 /* make scenes which are not using color management have got None as display device,
1526 * so they wouldn't perform linear-to-sRGB conversion on display
1528 for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
1529 if ((scene->r.color_mgt_flag & R_COLOR_MANAGEMENT) == 0) {
1530 ColorManagedDisplaySettings *display_settings = &scene->display_settings;
1532 if (display_settings->display_device[0] == 0) {
1533 BKE_scene_disable_color_management(scene);
1536 colormanagement_disabled = true;
1540 for (ima = bmain->images.first; ima; ima = ima->id.next) {
1541 if (ima->source == IMA_SRC_VIEWER) {
1542 ima->flag |= IMA_VIEW_AS_RENDER;
1544 else if (colormanagement_disabled) {
1545 /* if color-management not used, set image's color space to raw, so no sRGB->linear
1546 * conversion would happen on display and render there's no clear way to check whether
1547 * color management is enabled or not in render engine so set all images to raw if there's
1548 * at least one scene with color management disabled this would still behave incorrect in
1549 * cases when color management was used for only some of scenes, but such a setup is
1550 * crazy anyway and think it's fair enough to break compatibility in that cases.
1553 BLI_strncpy(ima->colorspace_settings.name, "Raw", sizeof(ima->colorspace_settings.name));
1558 if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 20)) {
1560 for (key = bmain->shapekeys.first; key; key = key->id.next) {
1561 blo_do_versions_key_uidgen(key);
1565 if (bmain->versionfile < 263 || (bmain->versionfile == 263 && bmain->subversionfile < 21)) {
1568 for (me = bmain->meshes.first; me; me = me->id.next) {
1569 CustomData_update_typemap(&me->vdata);
1570 CustomData_free_layers(&me->vdata, CD_MSTICKY, me->totvert);
1575 /* correction for files saved in blender version when BKE_pose_copy_data
1576 * didn't copy animation visualization, which lead to deadlocks on motion
1577 * path calculation for proxied armatures, see [#32742]
1579 if (bmain->versionfile < 264) {
1582 for (ob = bmain->objects.first; ob; ob = ob->id.next) {
1584 if (ob->pose->avs.path_step == 0) {
1585 animviz_settings_init(&ob->pose->avs);
1591 if (bmain->versionfile < 264 || (bmain->versionfile == 264 && bmain->subversionfile < 1)) {
1592 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
1593 if (ntree->type == NTREE_SHADER) {
1595 for (node = ntree->nodes.first; node; node = node->next) {
1596 if (node->type == SH_NODE_TEX_COORD) {
1597 node->flag |= NODE_OPTIONS;
1602 FOREACH_NODETREE_END;
1605 if (bmain->versionfile < 264 || (bmain->versionfile == 264 && bmain->subversionfile < 2)) {
1608 for (clip = bmain->movieclips.first; clip; clip = clip->id.next) {
1609 MovieTracking *tracking = &clip->tracking;
1610 MovieTrackingObject *tracking_object;
1612 for (tracking_object = tracking->objects.first; tracking_object;
1613 tracking_object = tracking_object->next) {
1614 if (tracking_object->keyframe1 == 0 && tracking_object->keyframe2 == 0) {
1615 tracking_object->keyframe1 = tracking->settings.keyframe1;
1616 tracking_object->keyframe2 = tracking->settings.keyframe2;
1622 if (bmain->versionfile < 264 || (bmain->versionfile == 264 && bmain->subversionfile < 3)) {
1627 for (ob = bmain->objects.first; ob; ob = ob->id.next) {
1629 for (md = ob->modifiers.first; md; md = md->next) {
1630 if (md->type == eModifierType_Fluid) {
1631 FluidModifierData *mmd = (FluidModifierData *)md;
1632 if ((mmd->type & MOD_FLUID_TYPE_DOMAIN) && mmd->domain) {
1633 /* keep branch saves if possible */
1634 if (!mmd->domain->flame_max_temp) {
1635 mmd->domain->burning_rate = 0.75f;
1636 mmd->domain->flame_smoke = 1.0f;
1637 mmd->domain->flame_vorticity = 0.5f;
1638 mmd->domain->flame_ignition = 1.25f;
1639 mmd->domain->flame_max_temp = 1.75f;
1640 mmd->domain->adapt_threshold = 0.02f;
1641 mmd->domain->adapt_margin = 4;
1642 mmd->domain->flame_smoke_color[0] = 0.7f;
1643 mmd->domain->flame_smoke_color[1] = 0.7f;
1644 mmd->domain->flame_smoke_color[2] = 0.7f;
1647 else if ((mmd->type & MOD_FLUID_TYPE_FLOW) && mmd->flow) {
1648 if (!mmd->flow->texture_size) {
1649 mmd->flow->fuel_amount = 1.0;
1650 mmd->flow->surface_distance = 1.5;
1651 mmd->flow->color[0] = 0.7f;
1652 mmd->flow->color[1] = 0.7f;
1653 mmd->flow->color[2] = 0.7f;
1654 mmd->flow->texture_size = 1.0f;
1662 /* render border for viewport */
1666 for (screen = bmain->screens.first; screen; screen = screen->id.next) {
1668 for (area = screen->areabase.first; area; area = area->next) {
1670 for (sl = area->spacedata.first; sl; sl = sl->next) {
1671 if (sl->spacetype == SPACE_VIEW3D) {
1672 View3D *v3d = (View3D *)sl;
1673 if (v3d->render_border.xmin == 0.0f && v3d->render_border.ymin == 0.0f &&
1674 v3d->render_border.xmax == 0.0f && v3d->render_border.ymax == 0.0f) {
1675 v3d->render_border.xmax = 1.0f;
1676 v3d->render_border.ymax = 1.0f;
1685 if (bmain->versionfile < 264 || (bmain->versionfile == 264 && bmain->subversionfile < 5)) {
1686 /* set a unwrapping margin and ABF by default */
1689 for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
1690 if (scene->toolsettings->uvcalc_margin == 0.0f) {
1691 scene->toolsettings->uvcalc_margin = 0.001f;
1692 scene->toolsettings->unwrapper = 0;
1697 if (bmain->versionfile < 264 || (bmain->versionfile == 264 && bmain->subversionfile < 6)) {
1698 /* Fix for bug #32982, internal_links list could get corrupted from r51630 onward.
1699 * Simply remove bad internal_links lists to avoid NULL pointers.
1701 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
1703 bNodeLink *link, *nextlink;
1705 for (node = ntree->nodes.first; node; node = node->next) {
1706 for (link = node->internal_links.first; link; link = nextlink) {
1707 nextlink = link->next;
1708 if (!link->fromnode || !link->fromsock || !link->tonode || !link->tosock) {
1709 BLI_remlink(&node->internal_links, link);
1714 FOREACH_NODETREE_END;
1717 if (bmain->versionfile < 264 || (bmain->versionfile == 264 && bmain->subversionfile < 7)) {
1718 /* convert tiles size from resolution and number of tiles */
1722 for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
1723 if (scene->r.tilex == 0 || scene->r.tiley == 1) {
1724 scene->r.tilex = scene->r.tiley = 64;
1729 /* collision masks */
1732 for (ob = bmain->objects.first; ob; ob = ob->id.next) {
1733 if (ob->col_group == 0) {
1734 ob->col_group = 0x01;
1735 ob->col_mask = 0xff;
1741 if (bmain->versionfile < 264 || (bmain->versionfile == 264 && bmain->subversionfile < 7)) {
1744 for (clip = bmain->movieclips.first; clip; clip = clip->id.next) {
1745 MovieTrackingTrack *track;
1746 MovieTrackingObject *object;
1748 for (track = clip->tracking.tracks.first; track; track = track->next) {
1749 do_versions_affine_tracker_track(track);
1752 for (object = clip->tracking.objects.first; object; object = object->next) {
1753 for (track = object->tracks.first; track; track = track->next) {
1754 do_versions_affine_tracker_track(track);
1760 if (bmain->versionfile < 265 || (bmain->versionfile == 265 && bmain->subversionfile < 3)) {
1762 for (screen = bmain->screens.first; screen; screen = screen->id.next) {
1764 for (area = screen->areabase.first; area; area = area->next) {
1766 for (sl = area->spacedata.first; sl; sl = sl->next) {
1767 switch (sl->spacetype) {
1768 case SPACE_VIEW3D: {
1769 View3D *v3d = (View3D *)sl;
1770 v3d->flag2 |= V3D_SHOW_ANNOTATION;
1774 SpaceSeq *sseq = (SpaceSeq *)sl;
1775 sseq->flag |= SEQ_SHOW_GPENCIL;
1779 SpaceImage *sima = (SpaceImage *)sl;
1780 sima->flag |= SI_SHOW_GPENCIL;
1784 SpaceNode *snode = (SpaceNode *)sl;
1785 snode->flag |= SNODE_SHOW_GPENCIL;
1789 SpaceClip *sclip = (SpaceClip *)sl;
1790 sclip->flag |= SC_SHOW_ANNOTATION;
1799 if (bmain->versionfile < 265 || (bmain->versionfile == 265 && bmain->subversionfile < 5)) {
1803 for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
1806 SEQ_BEGIN (scene->ed, seq) {
1807 enum { SEQ_MAKE_PREMUL = (1 << 6) };
1808 if (seq->flag & SEQ_MAKE_PREMUL) {
1809 seq->alpha_mode = SEQ_ALPHA_STRAIGHT;
1812 BKE_sequence_alpha_mode_from_extension(seq);
1817 if (scene->r.bake_samples == 0) {
1818 scene->r.bake_samples = 256;
1822 for (Image *image = bmain->images.first; image; image = image->id.next) {
1823 if (image->flag & IMA_DO_PREMUL) {
1824 image->alpha_mode = IMA_ALPHA_STRAIGHT;
1827 BKE_image_alpha_mode_from_extension(image);
1831 for (tex = bmain->textures.first; tex; tex = tex->id.next) {
1832 if (tex->type == TEX_IMAGE && (tex->imaflag & TEX_USEALPHA) == 0) {
1833 Image *image = blo_do_versions_newlibadr(fd, tex->id.lib, tex->ima);
1835 if (image && (image->flag & IMA_DO_PREMUL) == 0) {
1836 const int IMA_IGNORE_ALPHA = (1 << 12);
1837 image->flag |= IMA_IGNORE_ALPHA;
1842 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
1843 if (ntree->type == NTREE_COMPOSIT) {
1845 for (node = ntree->nodes.first; node; node = node->next) {
1846 if (node->type == CMP_NODE_IMAGE) {
1847 Image *image = blo_do_versions_newlibadr(fd, ntree->id.lib, node->id);
1850 if ((image->flag & IMA_DO_PREMUL) == 0 && image->alpha_mode == IMA_ALPHA_STRAIGHT) {
1851 node->custom1 |= CMP_NODE_IMAGE_USE_STRAIGHT_OUTPUT;
1858 FOREACH_NODETREE_END;
1860 else if (bmain->versionfile < 266 || (bmain->versionfile == 266 && bmain->subversionfile < 1)) {
1861 /* texture use alpha was removed for 2.66 but added back again for 2.66a,
1862 * for compatibility all textures assumed it to be enabled */
1865 for (tex = bmain->textures.first; tex; tex = tex->id.next) {
1866 if (tex->type == TEX_IMAGE) {
1867 tex->imaflag |= TEX_USEALPHA;
1872 if (bmain->versionfile < 265 || (bmain->versionfile == 265 && bmain->subversionfile < 7)) {
1875 for (cu = bmain->curves.first; cu; cu = cu->id.next) {
1876 if (cu->flag & (CU_FRONT | CU_BACK)) {
1877 if (cu->ext1 != 0.0f || cu->ext2 != 0.0f) {
1880 for (nu = cu->nurb.first; nu; nu = nu->next) {
1884 BezTriple *bezt = nu->bezt;
1888 bezt->radius = 1.0f;
1893 BPoint *bp = nu->bp;
1894 a = nu->pntsu * nu->pntsv;
1907 if (MAIN_VERSION_OLDER(bmain, 265, 9)) {
1909 for (me = bmain->meshes.first; me; me = me->id.next) {
1910 BKE_mesh_do_versions_cd_flag_init(me);
1914 if (MAIN_VERSION_OLDER(bmain, 265, 10)) {
1916 for (br = bmain->brushes.first; br; br = br->id.next) {
1917 if (br->ob_mode & OB_MODE_TEXTURE_PAINT) {
1918 br->mtex.brush_map_mode = MTEX_MAP_MODE_TILED;
1923 // add storage for compositor translate nodes when not existing
1924 if (MAIN_VERSION_OLDER(bmain, 265, 11)) {
1925 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
1926 if (ntree->type == NTREE_COMPOSIT) {
1928 for (node = ntree->nodes.first; node; node = node->next) {
1929 if (node->type == CMP_NODE_TRANSLATE && node->storage == NULL) {
1930 node->storage = MEM_callocN(sizeof(NodeTranslateData), "node translate data");
1935 FOREACH_NODETREE_END;
1938 if (MAIN_VERSION_OLDER(bmain, 266, 2)) {
1939 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
1940 do_versions_nodetree_customnodes(ntree, ((ID *)ntree == id));
1942 FOREACH_NODETREE_END;
1945 if (MAIN_VERSION_OLDER(bmain, 266, 2)) {
1947 for (screen = bmain->screens.first; screen; screen = screen->id.next) {
1949 for (area = screen->areabase.first; area; area = area->next) {
1951 for (sl = area->spacedata.first; sl; sl = sl->next) {
1952 if (sl->spacetype == SPACE_NODE) {
1953 SpaceNode *snode = (SpaceNode *)sl;
1955 /* reset pointers to force tree path update from context */
1956 snode->nodetree = NULL;
1957 snode->edittree = NULL;
1961 /* convert deprecated treetype setting to tree_idname */
1962 switch (snode->treetype) {
1963 case NTREE_COMPOSIT:
1964 strcpy(snode->tree_idname, "CompositorNodeTree");
1967 strcpy(snode->tree_idname, "ShaderNodeTree");
1970 strcpy(snode->tree_idname, "TextureNodeTree");
1979 if (MAIN_VERSION_OLDER(bmain, 266, 3)) {
1981 /* Fix for a very old issue:
1982 * Node names were nominally made unique in r24478 (2.50.8), but the do_versions check
1983 * to update existing node names only applied to bmain->nodetree (i.e. group nodes).
1984 * Uniqueness is now required for proper preview mapping,
1985 * so do this now to ensure old files don't break.
1988 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
1989 if (id == &ntree->id) {
1990 continue; /* already fixed for node groups */
1993 for (node = ntree->nodes.first; node; node = node->next) {
1994 nodeUniqueName(ntree, node);
1997 FOREACH_NODETREE_END;
2001 if (!MAIN_VERSION_ATLEAST(bmain, 266, 4)) {
2003 for (brush = bmain->brushes.first; brush; brush = brush->id.next) {
2004 BKE_texture_mtex_default(&brush->mask_mtex);
2006 if (brush->ob_mode & OB_MODE_TEXTURE_PAINT) {
2007 brush->spacing /= 2;
2012 if (!MAIN_VERSION_ATLEAST(bmain, 266, 6)) {
2014 #define BRUSH_TEXTURE_OVERLAY (1 << 21)
2016 for (brush = bmain->brushes.first; brush; brush = brush->id.next) {
2017 brush->overlay_flags = 0;
2018 if (brush->flag & BRUSH_TEXTURE_OVERLAY) {
2019 brush->overlay_flags |= (BRUSH_OVERLAY_PRIMARY | BRUSH_OVERLAY_CURSOR);
2022 #undef BRUSH_TEXTURE_OVERLAY
2025 if (bmain->versionfile < 267) {
2026 // if (!DNA_struct_elem_find(fd->filesdna, "Brush", "int", "stencil_pos")) {
2029 for (brush = bmain->brushes.first; brush; brush = brush->id.next) {
2030 if (brush->stencil_dimension[0] == 0) {
2031 brush->stencil_dimension[0] = 256;
2032 brush->stencil_dimension[1] = 256;
2033 brush->stencil_pos[0] = 256;
2034 brush->stencil_pos[1] = 256;
2036 if (brush->mask_stencil_dimension[0] == 0) {
2037 brush->mask_stencil_dimension[0] = 256;
2038 brush->mask_stencil_dimension[1] = 256;
2039 brush->mask_stencil_pos[0] = 256;
2040 brush->mask_stencil_pos[1] = 256;
2044 /* TIP: to initialize new variables added, use the new function
2045 * DNA_struct_elem_find(fd->filesdna, "structname", "typename", "varname")
2047 * if (!DNA_struct_elem_find(fd->filesdna, "UserDef", "short", "image_gpubuffer_limit"))
2048 * user->image_gpubuffer_limit = 10;
2052 /* default values in Freestyle settings */
2053 if (bmain->versionfile < 267) {
2055 SceneRenderLayer *srl;
2056 FreestyleLineStyle *linestyle;
2058 for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
2059 if (sce->r.line_thickness_mode == 0) {
2060 sce->r.line_thickness_mode = R_LINE_THICKNESS_ABSOLUTE;
2061 sce->r.unit_line_thickness = 1.0f;
2063 for (srl = sce->r.layers.first; srl; srl = srl->next) {
2064 if (srl->freestyleConfig.mode == 0) {
2065 srl->freestyleConfig.mode = FREESTYLE_CONTROL_EDITOR_MODE;
2067 if (srl->freestyleConfig.raycasting_algorithm ==
2068 FREESTYLE_ALGO_CULLED_ADAPTIVE_CUMULATIVE ||
2069 srl->freestyleConfig.raycasting_algorithm ==
2070 FREESTYLE_ALGO_CULLED_ADAPTIVE_TRADITIONAL) {
2071 srl->freestyleConfig.raycasting_algorithm = 0; /* deprecated */
2072 srl->freestyleConfig.flags |= FREESTYLE_CULLING;
2078 MeshStatVis *statvis = &sce->toolsettings->statvis;
2079 if (statvis->thickness_samples == 0) {
2080 statvis->overhang_axis = OB_NEGZ;
2081 statvis->overhang_min = 0;
2082 statvis->overhang_max = DEG2RADF(45.0f);
2084 statvis->thickness_max = 0.1f;
2085 statvis->thickness_samples = 1;
2087 statvis->distort_min = DEG2RADF(5.0f);
2088 statvis->distort_max = DEG2RADF(45.0f);
2090 statvis->sharp_min = DEG2RADF(90.0f);
2091 statvis->sharp_max = DEG2RADF(180.0f);
2095 for (linestyle = bmain->linestyles.first; linestyle; linestyle = linestyle->id.next) {
2097 /* disable the Misc panel for now */
2098 if (linestyle->panel == LS_PANEL_MISC) {
2099 linestyle->panel = LS_PANEL_STROKES;
2102 if (linestyle->thickness_position == 0) {
2103 linestyle->thickness_position = LS_THICKNESS_CENTER;
2104 linestyle->thickness_ratio = 0.5f;
2106 if (linestyle->chaining == 0) {
2107 linestyle->chaining = LS_CHAINING_PLAIN;
2109 if (linestyle->rounds == 0) {
2110 linestyle->rounds = 3;
2115 if (bmain->versionfile < 267) {
2116 /* Initialize the active_viewer_key for compositing */
2119 bNodeInstanceKey active_viewer_key = {0};
2120 /* simply pick the first node space and use that for the active viewer key */
2121 for (screen = bmain->screens.first; screen; screen = screen->id.next) {
2123 for (area = screen->areabase.first; area; area = area->next) {
2125 for (sl = area->spacedata.first; sl; sl = sl->next) {
2126 if (sl->spacetype == SPACE_NODE) {
2127 SpaceNode *snode = (SpaceNode *)sl;
2128 bNodeTreePath *path = snode->treepath.last;
2133 active_viewer_key = path->parent_key;
2137 if (active_viewer_key.value != 0) {
2141 if (active_viewer_key.value != 0) {
2146 for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
2147 /* NB: scene->nodetree is a local ID block, has been direct_link'ed */
2148 if (scene->nodetree) {
2149 scene->nodetree->active_viewer_key = active_viewer_key;
2154 if (MAIN_VERSION_OLDER(bmain, 267, 1)) {
2157 for (ob = bmain->objects.first; ob; ob = ob->id.next) {
2159 for (md = ob->modifiers.first; md; md = md->next) {
2160 if (md->type == eModifierType_Fluid) {
2161 FluidModifierData *mmd = (FluidModifierData *)md;
2162 if ((mmd->type & MOD_FLUID_TYPE_DOMAIN) && mmd->domain) {
2163 if (mmd->domain->flags & FLUID_DOMAIN_USE_HIGH_SMOOTH) {
2164 mmd->domain->highres_sampling = SM_HRES_LINEAR;
2167 mmd->domain->highres_sampling = SM_HRES_NEAREST;
2175 if (!MAIN_VERSION_ATLEAST(bmain, 268, 1)) {
2177 for (brush = bmain->brushes.first; brush; brush = brush->id.next) {
2178 brush->spacing = MAX2(1, brush->spacing);
2182 if (!MAIN_VERSION_ATLEAST(bmain, 268, 2)) {
2184 #define BRUSH_FIXED (1 << 6)
2185 for (brush = bmain->brushes.first; brush; brush = brush->id.next) {
2186 brush->flag &= ~BRUSH_FIXED;
2188 if (brush->cursor_overlay_alpha < 2) {
2189 brush->cursor_overlay_alpha = 33;
2191 if (brush->texture_overlay_alpha < 2) {
2192 brush->texture_overlay_alpha = 33;
2194 if (brush->mask_overlay_alpha < 2) {
2195 brush->mask_overlay_alpha = 33;
2201 if (!MAIN_VERSION_ATLEAST(bmain, 268, 4)) {
2205 for (ob = bmain->objects.first; ob; ob = ob->id.next) {
2207 for (con = ob->constraints.first; con; con = con->next) {
2208 if (con->type == CONSTRAINT_TYPE_SHRINKWRAP) {
2209 bShrinkwrapConstraint *data = (bShrinkwrapConstraint *)con->data;
2210 if (data->projAxis & MOD_SHRINKWRAP_PROJECT_OVER_X_AXIS) {
2211 data->projAxis = OB_POSX;
2213 else if (data->projAxis & MOD_SHRINKWRAP_PROJECT_OVER_Y_AXIS) {
2214 data->projAxis = OB_POSY;
2217 data->projAxis = OB_POSZ;
2219 data->projAxisSpace = CONSTRAINT_SPACE_LOCAL;
2224 for (ob = bmain->objects.first; ob; ob = ob->id.next) {
2226 for (md = ob->modifiers.first; md; md = md->next) {
2227 if (md->type == eModifierType_Fluid) {
2228 FluidModifierData *mmd = (FluidModifierData *)md;
2229 if ((mmd->type & MOD_FLUID_TYPE_FLOW) && mmd->flow) {
2230 if (!mmd->flow->particle_size) {
2231 mmd->flow->particle_size = 1.0f;
2239 * FIX some files have a zoom level of 0, and was checked during the drawing of the node space
2241 * We moved this check to the do versions to be sure the value makes any sense.
2243 for (screen = bmain->screens.first; screen; screen = screen->id.next) {
2245 for (area = screen->areabase.first; area; area = area->next) {
2247 for (sl = area->spacedata.first; sl; sl = sl->next) {
2248 if (sl->spacetype == SPACE_NODE) {
2249 SpaceNode *snode = (SpaceNode *)sl;
2250 if (snode->zoom < 0.02f) {
2259 if (!MAIN_VERSION_ATLEAST(bmain, 268, 5)) {
2263 /* add missing (+) expander in node editor */
2264 for (screen = bmain->screens.first; screen; screen = screen->id.next) {
2265 for (area = screen->areabase.first; area; area = area->next) {
2266 ARegion *region, *arnew;
2268 if (area->spacetype == SPACE_NODE) {
2269 region = BKE_area_find_region_type(area, RGN_TYPE_TOOLS);
2275 /* add subdiv level; after header */
2276 region = BKE_area_find_region_type(area, RGN_TYPE_HEADER);
2279 if (region == NULL) {
2283 arnew = MEM_callocN(sizeof(ARegion), "node tools");
2285 BLI_insertlinkafter(&area->regionbase, region, arnew);
2286 arnew->regiontype = RGN_TYPE_TOOLS;
2287 arnew->alignment = RGN_ALIGN_LEFT;
2289 arnew->flag = RGN_FLAG_HIDDEN;
2295 if (!MAIN_VERSION_ATLEAST(bmain, 269, 1)) {
2296 /* Removal of Cycles SSS Compatible falloff */
2297 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
2298 if (ntree->type == NTREE_SHADER) {
2300 for (node = ntree->nodes.first; node; node = node->next) {
2301 if (node->type == SH_NODE_SUBSURFACE_SCATTERING) {
2302 if (node->custom1 == SHD_SUBSURFACE_COMPATIBLE) {
2303 node->custom1 = SHD_SUBSURFACE_CUBIC;
2309 FOREACH_NODETREE_END;
2312 if (!MAIN_VERSION_ATLEAST(bmain, 269, 2)) {
2313 /* Initialize CDL settings for Color Balance nodes */
2314 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
2315 if (ntree->type == NTREE_COMPOSIT) {
2317 for (node = ntree->nodes.first; node; node = node->next) {
2318 if (node->type == CMP_NODE_COLORBALANCE) {
2319 NodeColorBalance *n = node->storage;
2320 if (node->custom1 == 0) {
2321 /* LGG mode stays the same, just init CDL settings */
2322 ntreeCompositColorBalanceSyncFromLGG(ntree, node);
2324 else if (node->custom1 == 1) {
2325 /* CDL previously used same variables as LGG, copy them over
2326 * and then sync LGG for comparable results in both modes.
2328 copy_v3_v3(n->offset, n->lift);
2329 copy_v3_v3(n->power, n->gamma);
2330 copy_v3_v3(n->slope, n->gain);
2331 ntreeCompositColorBalanceSyncFromCDL(ntree, node);
2337 FOREACH_NODETREE_END;
2340 if (!MAIN_VERSION_ATLEAST(bmain, 269, 3)) {
2346 /* Update files using invalid (outdated) outlinevis Outliner values. */
2347 for (screen = bmain->screens.first; screen; screen = screen->id.next) {
2348 for (area = screen->areabase.first; area; area = area->next) {
2349 for (sl = area->spacedata.first; sl; sl = sl->next) {
2350 if (sl->spacetype == SPACE_OUTLINER) {
2351 SpaceOutliner *so = (SpaceOutliner *)sl;
2353 if (!ELEM(so->outlinevis, SO_SCENES, SO_LIBRARIES, SO_SEQUENCE, SO_DATA_API)) {
2354 so->outlinevis = SO_SCENES;
2361 if (!DNA_struct_elem_find(fd->filesdna, "MovieTrackingTrack", "float", "weight")) {
2363 for (clip = bmain->movieclips.first; clip; clip = clip->id.next) {
2364 MovieTracking *tracking = &clip->tracking;
2365 MovieTrackingObject *tracking_object;
2366 for (tracking_object = tracking->objects.first; tracking_object;
2367 tracking_object = tracking_object->next) {
2368 ListBase *tracksbase = BKE_tracking_object_get_tracks(tracking, tracking_object);
2369 MovieTrackingTrack *track;
2370 for (track = tracksbase->first; track; track = track->next) {
2371 track->weight = 1.0f;
2377 if (!DNA_struct_elem_find(fd->filesdna, "TriangulateModifierData", "int", "quad_method")) {
2379 for (ob = bmain->objects.first; ob; ob = ob->id.next) {
2381 for (md = ob->modifiers.first; md; md = md->next) {
2382 if (md->type == eModifierType_Triangulate) {
2383 TriangulateModifierData *tmd = (TriangulateModifierData *)md;
2384 if ((tmd->flag & MOD_TRIANGULATE_BEAUTY)) {
2385 tmd->quad_method = MOD_TRIANGULATE_QUAD_BEAUTY;
2386 tmd->ngon_method = MOD_TRIANGULATE_NGON_BEAUTY;
2389 tmd->quad_method = MOD_TRIANGULATE_QUAD_FIXED;
2390 tmd->ngon_method = MOD_TRIANGULATE_NGON_EARCLIP;
2397 for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
2398 /* this can now be turned off */
2399 ToolSettings *ts = scene->toolsettings;
2401 ts->sculpt->flags |= SCULPT_DYNTOPO_SUBDIVIDE;
2404 /* 'Increment' mode disabled for nodes, use true grid snapping instead */
2405 if (scene->toolsettings->snap_node_mode == SCE_SNAP_MODE_INCREMENT) {
2406 scene->toolsettings->snap_node_mode = SCE_SNAP_MODE_GRID;
2410 /* Update for removed "sound-only" option in FFMPEG export settings. */
2411 if (scene->r.ffcodecdata.type >= FFMPEG_INVALID) {
2412 scene->r.ffcodecdata.type = FFMPEG_AVI;
2418 if (!MAIN_VERSION_ATLEAST(bmain, 269, 4)) {
2419 /* Internal degrees to radians conversions... */
2424 for (Light *la = bmain->lights.first; la; la = la->id.next) {
2425 la->spotsize = DEG2RADF(la->spotsize);
2428 for (ob = bmain->objects.first; ob; ob = ob->id.next) {
2431 for (md = ob->modifiers.first; md; md = md->next) {
2432 if (md->type == eModifierType_EdgeSplit) {
2433 EdgeSplitModifierData *emd = (EdgeSplitModifierData *)md;
2434 emd->split_angle = DEG2RADF(emd->split_angle);
2436 else if (md->type == eModifierType_Bevel) {
2437 BevelModifierData *bmd = (BevelModifierData *)md;
2438 bmd->bevel_angle = DEG2RADF(bmd->bevel_angle);
2443 for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
2445 SEQ_BEGIN (scene->ed, seq) {
2446 if (seq->type == SEQ_TYPE_WIPE) {
2447 WipeVars *wv = seq->effectdata;
2448 wv->angle = DEG2RADF(wv->angle);
2454 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
2455 if (ntree->type == NTREE_COMPOSIT) {
2457 for (node = ntree->nodes.first; node; node = node->next) {
2458 if (node->type == CMP_NODE_BOKEHIMAGE) {
2459 NodeBokehImage *n = node->storage;
2460 n->angle = DEG2RADF(n->angle);
2462 if (node->type == CMP_NODE_MASK_BOX) {
2463 NodeBoxMask *n = node->storage;
2464 n->rotation = DEG2RADF(n->rotation);
2466 if (node->type == CMP_NODE_MASK_ELLIPSE) {
2467 NodeEllipseMask *n = node->storage;
2468 n->rotation = DEG2RADF(n->rotation);
2473 FOREACH_NODETREE_END;
2476 if (!DNA_struct_elem_find(fd->filesdna, "MovieTrackingPlaneTrack", "float", "image_opacity")) {
2478 for (clip = bmain->movieclips.first; clip; clip = clip->id.next) {
2479 MovieTrackingPlaneTrack *plane_track;
2480 for (plane_track = clip->tracking.plane_tracks.first; plane_track;
2481 plane_track = plane_track->next) {
2482 plane_track->image_opacity = 1.0f;
2488 if (!MAIN_VERSION_ATLEAST(bmain, 269, 7)) {
2490 for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
2491 Sculpt *sd = scene->toolsettings->sculpt;
2495 SCULPT_SYMM_X = (1 << 0),
2496 SCULPT_SYMM_Y = (1 << 1),
2497 SCULPT_SYMM_Z = (1 << 2),
2498 SCULPT_SYMMETRY_FEATHER = (1 << 6),
2500 int symmetry_flags = sd->flags & 7;
2502 if (symmetry_flags & SCULPT_SYMM_X) {
2503 sd->paint.symmetry_flags |= PAINT_SYMM_X;
2505 if (symmetry_flags & SCULPT_SYMM_Y) {
2506 sd->paint.symmetry_flags |= PAINT_SYMM_Y;
2508 if (symmetry_flags & SCULPT_SYMM_Z) {
2509 sd->paint.symmetry_flags |= PAINT_SYMM_Z;
2511 if (symmetry_flags & SCULPT_SYMMETRY_FEATHER) {
2512 sd->paint.symmetry_flags |= PAINT_SYMMETRY_FEATHER;
2518 if (!MAIN_VERSION_ATLEAST(bmain, 269, 8)) {
2521 for (cu = bmain->curves.first; cu; cu = cu->id.next) {
2523 cu->len_wchar = BLI_strlen_utf8(cu->str);
2528 if (!MAIN_VERSION_ATLEAST(bmain, 269, 9)) {
2531 for (ob = bmain->objects.first; ob; ob = ob->id.next) {
2533 for (md = ob->modifiers.first; md; md = md->next) {
2534 if (md->type == eModifierType_Build) {
2535 BuildModifierData *bmd = (BuildModifierData *)md;
2536 if (bmd->randomize) {
2537 bmd->flag |= MOD_BUILD_FLAG_RANDOMIZE;
2544 if (!MAIN_VERSION_ATLEAST(bmain, 269, 11)) {
2547 for (screen = bmain->screens.first; screen; screen = screen->id.next) {
2549 for (area = screen->areabase.first; area; area = area->next) {
2550 SpaceLink *space_link;
2552 for (space_link = area->spacedata.first; space_link; space_link = space_link->next) {
2553 if (space_link->spacetype == SPACE_IMAGE) {
2557 if (space_link == area->spacedata.first) {
2558 lb = &area->regionbase;
2561 lb = &space_link->regionbase;
2564 for (region = lb->first; region; region = region->next) {
2565 if (region->regiontype == RGN_TYPE_PREVIEW) {
2566 region->regiontype = RGN_TYPE_TOOLS;
2567 region->alignment = RGN_ALIGN_LEFT;
2569 else if (region->regiontype == RGN_TYPE_UI) {
2570 region->alignment = RGN_ALIGN_RIGHT;
2580 void do_versions_after_linking_260(Main *bmain)
2582 /* Convert the previously used ntree->inputs/ntree->outputs lists to interface nodes.
2583 * Pre 2.56.2 node trees automatically have all unlinked sockets exposed already,
2584 * see do_versions_after_linking_250.
2586 * This assumes valid typeinfo pointers, as set in lib_link_ntree.
2588 * Note: theoretically only needed in node groups (main->nodetree),
2589 * but due to a temporary bug such links could have been added in all trees,
2590 * so have to clean up all of them ...
2592 * Note: this always runs, without it links with NULL fromnode and tonode remain
2593 * which causes problems.
2595 if (!MAIN_VERSION_ATLEAST(bmain, 266, 3)) {
2596 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
2597 bNode *input_node = NULL, *output_node = NULL;
2598 int num_inputs = 0, num_outputs = 0;
2599 bNodeLink *link, *next_link;
2600 /* Only create new interface nodes for actual older files.
2601 * New file versions already have input/output nodes with duplicate links,
2602 * in that case just remove the invalid links.
2604 const bool create_io_nodes = MAIN_VERSION_OLDER(bmain, 266, 2);
2606 float input_locx = 1000000.0f, input_locy = 0.0f;
2607 float output_locx = -1000000.0f, output_locy = 0.0f;
2608 /* rough guess, not nice but we don't have access to UI constants here ... */
2609 static const float offsetx = 42 + 3 * 20 + 20;
2610 /*static const float offsety = 0.0f;*/
2612 if (create_io_nodes) {
2613 if (ntree->inputs.first) {
2614 input_node = nodeAddStaticNode(NULL, ntree, NODE_GROUP_INPUT);
2617 if (ntree->outputs.first) {
2618 output_node = nodeAddStaticNode(NULL, ntree, NODE_GROUP_OUTPUT);
2622 /* Redirect links from/to the node tree interface to input/output node.
2623 * If the fromnode/tonode pointers are NULL, this means a link from/to
2624 * the ntree interface sockets, which need to be redirected to new interface nodes.
2626 for (link = ntree->links.first; link; link = next_link) {
2627 bool free_link = false;
2628 next_link = link->next;
2630 if (link->fromnode == NULL) {
2632 link->fromnode = input_node;
2633 link->fromsock = node_group_input_find_socket(input_node, link->fromsock->identifier);
2637 if (input_locx > link->tonode->locx - offsetx) {
2638 input_locx = link->tonode->locx - offsetx;
2640 input_locy += link->tonode->locy;
2648 if (link->tonode == NULL) {
2650 link->tonode = output_node;
2651 link->tosock = node_group_output_find_socket(output_node, link->tosock->identifier);
2654 if (link->fromnode) {
2655 if (output_locx < link->fromnode->locx + offsetx) {
2656 output_locx = link->fromnode->locx + offsetx;
2658 output_locy += link->fromnode->locy;
2667 nodeRemLink(ntree, link);
2671 if (num_inputs > 0) {
2672 input_locy /= num_inputs;
2673 input_node->locx = input_locx;
2674 input_node->locy = input_locy;
2676 if (num_outputs > 0) {
2677 output_locy /= num_outputs;
2678 output_node->locx = output_locx;
2679 output_node->locy = output_locy;
2682 FOREACH_NODETREE_END;
2685 if (!MAIN_VERSION_ATLEAST(bmain, 280, 60)) {
2686 /* From this point we no longer write incomplete links for forward
2687 * compatibility with 2.66, we have to clean them up for all previous
2689 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
2690 bNodeLink *link, *next_link;
2692 for (link = ntree->links.first; link; link = next_link) {
2693 next_link = link->next;
2694 if (link->fromnode == NULL || link->tonode == NULL) {
2695 nodeRemLink(ntree, link);
2699 FOREACH_NODETREE_END;