Blender V5.0
versioning_250.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#ifndef WIN32
10# include <unistd.h> /* for read close */
11#else
12# include "BLI_winstuff.h"
13# include "winsock2.h"
14# include <io.h> /* for open close read */
15#endif
16
17/* allow readfile to use deprecated functionality */
18#define DNA_DEPRECATED_ALLOW
19
20#include "DNA_anim_types.h"
21#include "DNA_armature_types.h"
22#include "DNA_brush_types.h"
23#include "DNA_camera_types.h"
24#include "DNA_cloth_types.h"
26#include "DNA_fluid_types.h"
27#include "DNA_key_types.h"
28#include "DNA_lattice_types.h"
29#include "DNA_material_types.h"
30#include "DNA_mesh_types.h"
31#include "DNA_meshdata_types.h"
32#include "DNA_node_types.h"
35#include "DNA_object_types.h"
36#include "DNA_screen_types.h"
37#include "DNA_sequence_types.h"
38#include "DNA_sound_types.h"
39#include "DNA_space_types.h"
40#include "DNA_userdef_types.h"
41#include "DNA_view3d_types.h"
42
43#include "MEM_guardedalloc.h"
44
45#include "BLI_listbase.h"
46#include "BLI_math_color.h"
47#include "BLI_math_matrix.h"
48#include "BLI_math_rotation.h"
49#include "BLI_math_vector.h"
50#include "BLI_path_utils.hh"
51#include "BLI_string.h"
52#include "BLI_string_utf8.h"
53#include "BLI_utildefines.h"
54
55#include "BKE_anim_data.hh"
57#include "BKE_armature.hh"
58#include "BKE_colortools.hh"
59#include "BKE_customdata.hh"
60#include "BKE_global.hh" /* for G */
61#include "BKE_lib_id.hh"
62#include "BKE_main.hh"
63#include "BKE_modifier.hh"
64#include "BKE_node.hh"
67#include "BKE_particle.h"
68#include "BKE_screen.hh"
69#include "BKE_texture.h"
70
71#include "SEQ_iterator.hh"
72
73#include "BLO_readfile.hh"
74
75#include "readfile.hh"
76
77#include "versioning_common.hh"
78
79#include <algorithm>
80#include <cerrno>
81
82/* Make preferences read-only, use `versioning_userdef.cc`. */
83#define U (*((const UserDef *)&U))
84
85/* 2.50 patch */
87{
88 ARegion *region = BKE_area_region_new();
89
90 BLI_addtail(lb, region);
92 if (area->headertype == 1) {
94 }
95 else {
96 region->alignment = RGN_ALIGN_TOP;
97 }
98
99 /* initialize view2d data for header region, to allow panning */
100 /* is copy from ui_view2d.c */
102 region->v2d.keepofs = V2D_LOCKOFS_Y;
106}
107
109{
110 /* XXX a bit ugly still, copied from space_sequencer */
111 /* NOTE: if you change values here, also change them in `space_sequencer.cc`, sequencer_new */
113 region->alignment = RGN_ALIGN_TOP;
114 region->flag &= ~RGN_FLAG_HIDDEN;
116 region->v2d.minzoom = 0.001f;
117 region->v2d.maxzoom = 1000.0f;
118 region->v2d.tot.xmin = -960.0f; /* 1920 width centered */
119 region->v2d.tot.ymin = -540.0f; /* 1080 height centered */
120 region->v2d.tot.xmax = 960.0f;
121 region->v2d.tot.ymax = 540.0f;
122 region->v2d.min[0] = 0.0f;
123 region->v2d.min[1] = 0.0f;
124 region->v2d.max[0] = 12000.0f;
125 region->v2d.max[1] = 12000.0f;
126 region->v2d.cur = region->v2d.tot;
127 region->v2d.align = V2D_ALIGN_FREE; /* `(V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_NEG_Y)` */
128 region->v2d.keeptot = V2D_KEEPTOT_FREE;
129}
130
132{
133 ARegion *region;
134
135 if (sl) {
136 /* first channels for ipo action nla... */
137 switch (sl->spacetype) {
138 case SPACE_GRAPH:
139 region = BKE_area_region_new();
140 BLI_addtail(lb, region);
142 region->alignment = RGN_ALIGN_LEFT;
144
145 /* for some reason, this doesn't seem to go auto like for NLA... */
146 region = BKE_area_region_new();
147 BLI_addtail(lb, region);
148 region->regiontype = RGN_TYPE_UI;
149 region->alignment = RGN_ALIGN_RIGHT;
150 region->v2d.scroll = V2D_SCROLL_RIGHT;
151 region->v2d.flag = RGN_FLAG_HIDDEN;
152 break;
153
154 case SPACE_ACTION:
155 region = BKE_area_region_new();
156 BLI_addtail(lb, region);
158 region->alignment = RGN_ALIGN_LEFT;
159 region->v2d.scroll = V2D_SCROLL_BOTTOM;
161 break;
162
163 case SPACE_NLA:
164 region = BKE_area_region_new();
165 BLI_addtail(lb, region);
167 region->alignment = RGN_ALIGN_LEFT;
168 region->v2d.scroll = V2D_SCROLL_BOTTOM;
170
171 /* for some reason, some files still don't get this auto */
172 region = BKE_area_region_new();
173 BLI_addtail(lb, region);
174 region->regiontype = RGN_TYPE_UI;
175 region->alignment = RGN_ALIGN_RIGHT;
176 region->v2d.scroll = V2D_SCROLL_RIGHT;
177 region->v2d.flag = RGN_FLAG_HIDDEN;
178 break;
179
180 case SPACE_NODE:
181 region = BKE_area_region_new();
182 BLI_addtail(lb, region);
183 region->regiontype = RGN_TYPE_UI;
184 region->alignment = RGN_ALIGN_LEFT;
187 /* temporarily hide it */
188 region->flag = RGN_FLAG_HIDDEN;
189 break;
190 case SPACE_FILE:
191 region = BKE_area_region_new();
192 BLI_addtail(lb, region);
194 region->alignment = RGN_ALIGN_LEFT;
195
196 region = BKE_area_region_new();
197 BLI_addtail(lb, region);
198 region->regiontype = RGN_TYPE_UI;
199 region->alignment = RGN_ALIGN_TOP;
200 break;
201 case SPACE_SEQ: {
202 ARegion *region_main = nullptr;
203 LISTBASE_FOREACH (ARegion *, region_iter, lb) {
204 if (region_iter->regiontype == RGN_TYPE_WINDOW) {
205 region_main = region_iter;
206 break;
207 }
208 }
209 region = BKE_area_region_new();
210 BLI_insertlinkbefore(lb, region_main, region);
212 break;
213 }
214 case SPACE_VIEW3D:
215 /* toolbar */
216 region = BKE_area_region_new();
217
218 BLI_addtail(lb, region);
219 region->regiontype = RGN_TYPE_TOOLS;
220 region->alignment = RGN_ALIGN_LEFT;
221 region->flag = RGN_FLAG_HIDDEN;
222
223 /* tool properties */
224 region = BKE_area_region_new();
225
226 BLI_addtail(lb, region);
229 region->flag = RGN_FLAG_HIDDEN;
230
231 /* buttons/list view */
232 region = BKE_area_region_new();
233
234 BLI_addtail(lb, region);
235 region->regiontype = RGN_TYPE_UI;
236 region->alignment = RGN_ALIGN_RIGHT;
237 region->flag = RGN_FLAG_HIDDEN;
238#if 0
239 case SPACE_PROPERTIES:
240 /* context UI region */
241 region = BKE_area_region_new();
242 BLI_addtail(lb, region);
243 region->regiontype = RGN_TYPE_UI;
244 region->alignment = RGN_ALIGN_RIGHT;
245
246 break;
247#endif
248 }
249 }
250
251 /* main region */
252 region = BKE_area_region_new();
253
254 BLI_addtail(lb, region);
255 region->winrct = area->totrct;
256
257 region->regiontype = RGN_TYPE_WINDOW;
258
259 if (sl) {
260 /* if active spacetype has view2d data, copy that over to main region */
261 /* and we split view3d */
262 switch (sl->spacetype) {
263 case SPACE_VIEW3D:
265 break;
266
267 case SPACE_OUTLINER: {
268 SpaceOutliner *space_outliner = (SpaceOutliner *)sl;
269
270 memcpy(&region->v2d, &space_outliner->v2d, sizeof(View2D));
271
272 region->v2d.scroll &= ~V2D_SCROLL_LEFT;
277 region->v2d.minzoom = region->v2d.maxzoom = 1.0f;
278 // region->v2d.flag |= V2D_IS_INIT;
279 break;
280 }
281 case SPACE_GRAPH: {
282 SpaceGraph *sipo = (SpaceGraph *)sl;
283 memcpy(&region->v2d, &sipo->v2d, sizeof(View2D));
284
285 /* Initialize main-area view2d. */
288
289 region->v2d.min[0] = FLT_MIN;
290 region->v2d.min[1] = FLT_MIN;
291
292 region->v2d.max[0] = MAXFRAMEF;
293 region->v2d.max[1] = FLT_MAX;
294
295 // region->v2d.flag |= V2D_IS_INIT;
296 break;
297 }
298 case SPACE_NLA: {
299 SpaceNla *snla = (SpaceNla *)sl;
300 memcpy(&region->v2d, &snla->v2d, sizeof(View2D));
301
302 region->v2d.tot.ymin = float(-area->winy) / 3.0f;
303 region->v2d.tot.ymax = 0.0f;
304
306 region->v2d.scroll |= V2D_SCROLL_RIGHT;
307 region->v2d.align = V2D_ALIGN_NO_POS_Y;
309 break;
310 }
311 case SPACE_ACTION: {
312 SpaceAction *saction = (SpaceAction *)sl;
313
314 /* We totally reinitialize the view for the Action Editor,
315 * as some old instances had some weird cruft set. */
316 region->v2d.tot.xmin = -20.0f;
317 region->v2d.tot.ymin = float(-area->winy) / 3.0f;
318 region->v2d.tot.xmax = float((area->winx > 120) ? (area->winx) : 120);
319 region->v2d.tot.ymax = 0.0f;
320
321 region->v2d.cur = region->v2d.tot;
322
323 region->v2d.min[0] = 0.0f;
324 region->v2d.min[1] = 0.0f;
325
326 region->v2d.max[0] = MAXFRAMEF;
327 region->v2d.max[1] = FLT_MAX;
328
329 region->v2d.minzoom = 0.01f;
330 region->v2d.maxzoom = 50;
332 region->v2d.scroll |= V2D_SCROLL_RIGHT;
333 region->v2d.keepzoom = V2D_LOCKZOOM_Y;
334 region->v2d.align = V2D_ALIGN_NO_POS_Y;
336
337 /* for old files with ShapeKey editors open + an action set, clear the action as
338 * it doesn't make sense in the new system (i.e. violates concept that ShapeKey edit
339 * only shows ShapeKey-rooted actions only)
340 */
341 if (saction->mode == SACTCONT_SHAPEKEY) {
342 saction->action = nullptr;
343 }
344 break;
345 }
346 case SPACE_SEQ: {
347 SpaceSeq *sseq = (SpaceSeq *)sl;
348 memcpy(&region->v2d, &sseq->v2d, sizeof(View2D));
349
352 region->v2d.align = V2D_ALIGN_NO_NEG_Y;
353 region->v2d.flag |= V2D_IS_INIT;
354 break;
355 }
356 case SPACE_NODE: {
357 SpaceNode *snode = (SpaceNode *)sl;
358 memcpy(&region->v2d, &snode->v2d, sizeof(View2D));
359
362 break;
363 }
364 case SPACE_PROPERTIES: {
365 SpaceProperties *sbuts = (SpaceProperties *)sl;
366 memcpy(&region->v2d, &sbuts->v2d, sizeof(View2D));
367
369 break;
370 }
371 case SPACE_FILE: {
372 // SpaceFile *sfile = (SpaceFile *)sl;
373 region->v2d.tot.xmin = region->v2d.tot.ymin = 0;
374 region->v2d.tot.xmax = region->winx;
375 region->v2d.tot.ymax = region->winy;
376 region->v2d.cur = region->v2d.tot;
377 region->regiontype = RGN_TYPE_WINDOW;
381 break;
382 }
383 case SPACE_TEXT: {
384 SpaceText *st = (SpaceText *)sl;
385 st->flags |= ST_FIND_WRAP;
386 }
387 // case SPACE_XXX: // FIXME... add other ones
388 // memcpy(&region->v2d, &((SpaceXxx *)sl)->v2d, sizeof(View2D));
389 // break;
390 }
391 }
392}
393
395{
396 /* add regions */
397 LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
398 /* we keep headertype variable to convert old files only */
399 if (area->headertype) {
400 area_add_header_region(area, &area->regionbase);
401 }
402
404 area, static_cast<SpaceLink *>(area->spacedata.first), &area->regionbase);
405
406 /* Space image-select is deprecated. */
407 LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
408 if (sl->spacetype == SPACE_IMASEL) {
409 sl->spacetype = SPACE_EMPTY; /* spacedata then matches */
410 }
411 }
412
413 /* space sound is deprecated */
414 LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
415 if (sl->spacetype == SPACE_SOUND) {
416 sl->spacetype = SPACE_EMPTY; /* spacedata then matches */
417 }
418 }
419
420 /* pushed back spaces also need regions! */
421 if (area->spacedata.first) {
422 SpaceLink *sl = static_cast<SpaceLink *>(area->spacedata.first);
423 for (sl = sl->next; sl; sl = sl->next) {
424 if (area->headertype) {
426 }
427 area_add_window_regions(area, sl, &sl->regionbase);
428 }
429 }
430 }
431}
432
433static void versions_gpencil_add_main(Main *bmain, ListBase *lb, ID *id, const char *name)
434{
435 BLI_addtail(lb, id);
436 id->us = 1;
437 id->flag = ID_FLAG_FAKEUSER;
438 *((short *)id->name) = ID_GD_LEGACY;
439
441 /* alphabetic insertion: is in BKE_id_new_name_validate */
442
443 if ((id->tag & ID_TAG_TEMP_MAIN) == 0) {
445 }
446
447 if (G.debug & G_DEBUG) {
448 printf("Converted GPencil to ID: %s\n", id->name + 2);
449 }
450}
451
453{
454 /* add regions */
455 LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
456 LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
457 if (sl->spacetype == SPACE_VIEW3D) {
458 View3D *v3d = (View3D *)sl;
459 if (v3d->gpd) {
460 versions_gpencil_add_main(main, &main->gpencils, (ID *)v3d->gpd, "GPencil View3D");
461 v3d->gpd = nullptr;
462 }
463 }
464 else if (sl->spacetype == SPACE_NODE) {
465 SpaceNode *snode = (SpaceNode *)sl;
466 if (snode->gpd) {
467 versions_gpencil_add_main(main, &main->gpencils, (ID *)snode->gpd, "GPencil Node");
468 snode->gpd = nullptr;
469 }
470 }
471 else if (sl->spacetype == SPACE_SEQ) {
472 SpaceSeq *sseq = (SpaceSeq *)sl;
473 if (sseq->gpd) {
474 versions_gpencil_add_main(main, &main->gpencils, (ID *)sseq->gpd, "GPencil Node");
475 sseq->gpd = nullptr;
476 }
477 }
478 else if (sl->spacetype == SPACE_IMAGE) {
479 SpaceImage *sima = (SpaceImage *)sl;
480#if 0 /* see comment on r28002 */
481 if (sima->gpd) {
482 versions_gpencil_add_main(main, &main->gpencil, (ID *)sima->gpd, "GPencil Image");
483 sima->gpd = nullptr;
484 }
485#else
486 sima->gpd = nullptr;
487#endif
488 }
489 }
490 }
491}
492
494{
495 LISTBASE_FOREACH (Object *, ob, &main->objects) {
496 LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) {
497 if (md->type == eModifierType_MeshDeform) {
499
500 if (mmd->bindcos) {
501 /* make bindcos nullptr in order to trick older versions
502 * into thinking that the mesh was not bound yet */
503 mmd->bindcagecos = mmd->bindcos;
504 mmd->bindcos = nullptr;
505
507 }
508 }
509 }
510 }
511}
512
514{
515 LISTBASE_FOREACH (bConstraint *, con, lb) {
516 if (con->type == CONSTRAINT_TYPE_KINEMATIC) {
517 bKinematicConstraint *data = static_cast<bKinematicConstraint *>(con->data);
518 data->poleangle *= float(M_PI / 180.0);
519 }
520 else if (con->type == CONSTRAINT_TYPE_ROTLIMIT) {
521 bRotLimitConstraint *data = static_cast<bRotLimitConstraint *>(con->data);
522
523 data->xmin *= float(M_PI / 180.0);
524 data->xmax *= float(M_PI / 180.0);
525 data->ymin *= float(M_PI / 180.0);
526 data->ymax *= float(M_PI / 180.0);
527 data->zmin *= float(M_PI / 180.0);
528 data->zmax *= float(M_PI / 180.0);
529 }
530 }
531}
532
534{
535 float submat[3][3];
536
537 copy_m3_m4(submat, bone->arm_mat);
538 mat3_to_vec_roll(submat, nullptr, &bone->arm_roll);
539
540 LISTBASE_FOREACH (Bone *, child, &bone->childbase) {
542 }
543}
544
545/* deprecated, only keep this for `readfile.cc` */
546/* XXX Deprecated function to add a socket in ntree->inputs/ntree->outputs list
547 * (previously called node_group_add_socket). This function has been superseded
548 * by the implementation of proxy nodes. It is still necessary though
549 * for do_versions of pre-2.56.2 code (r35033), so later proxy nodes
550 * can be generated consistently from ntree socket lists.
551 */
553 const char *name,
554 int type,
555 int in_out)
556{
557 // bNodeSocketType *stype = ntreeGetSocketType(type);
558 bNodeSocket *gsock = MEM_callocN<bNodeSocket>("bNodeSocket");
559
560 STRNCPY_UTF8(gsock->name, name);
561 gsock->type = type;
562
563 gsock->next = gsock->prev = nullptr;
564 gsock->link = nullptr;
565 /* assign new unique index */
566 gsock->own_index = ngroup->cur_index++;
567 gsock->limit = (in_out == SOCK_IN ? 0xFFF : 1);
568
569 // if (stype->value_structsize > 0)
570 // gsock->default_value = MEM_callocN(stype->value_structsize, "default socket value");
571
572 BLI_addtail(in_out == SOCK_IN ? &ngroup->inputs_legacy : &ngroup->outputs_legacy, gsock);
573
574 ngroup->tree_interface.tag_items_changed();
575
576 return gsock;
577}
578
579/* Create default_value structs for node sockets from the internal bNodeStack value.
580 * These structs were used from 2.59.2 on, but are replaced in the subsequent do_versions for
581 * custom nodes by generic ID property values. This conversion happened _after_ do_versions
582 * originally due to messy type initialization for node sockets.
583 * Now created here intermediately for convenience and to keep do_versions consistent.
584 *
585 * Node compatibility code is gross ...
586 */
588{
589 bNodeSocketValueFloat *valfloat;
590 bNodeSocketValueVector *valvector;
591 bNodeSocketValueRGBA *valrgba;
592
593 if (sock->default_value) {
594 return;
595 }
596
597 switch (sock->type) {
598 case SOCK_FLOAT:
599 valfloat = MEM_callocN<bNodeSocketValueFloat>("default socket value");
600 valfloat->value = sock->ns.vec[0];
601 valfloat->min = sock->ns.min;
602 valfloat->max = sock->ns.max;
603 valfloat->subtype = PROP_NONE;
604 sock->default_value = valfloat;
605 break;
606 case SOCK_VECTOR:
607 valvector = MEM_callocN<bNodeSocketValueVector>("default socket value");
608 copy_v3_v3(valvector->value, sock->ns.vec);
609 valvector->min = sock->ns.min;
610 valvector->max = sock->ns.max;
611 valvector->subtype = PROP_NONE;
612 sock->default_value = valvector;
613 break;
614 case SOCK_RGBA:
615 valrgba = MEM_callocN<bNodeSocketValueRGBA>("default socket value");
616 copy_v4_v4(valrgba->value, sock->ns.vec);
617 sock->default_value = valrgba;
618 break;
619 }
620}
621
622static bool strip_sound_proxy_update_cb(Strip *strip, void * /*user_data*/)
623{
624#define STRIP_USE_PROXY_CUSTOM_DIR (1 << 19)
625#define STRIP_USE_PROXY_CUSTOM_FILE (1 << 21)
626 /* don't know, if anybody used that this way, but just in case, upgrade to new way... */
627 if ((strip->flag & STRIP_USE_PROXY_CUSTOM_FILE) && !(strip->flag & STRIP_USE_PROXY_CUSTOM_DIR)) {
628 SNPRINTF(strip->data->proxy->dirpath, "%s" SEP_STR "BL_proxy", strip->data->dirpath);
629 }
630#undef STRIP_USE_PROXY_CUSTOM_DIR
631#undef STRIP_USE_PROXY_CUSTOM_FILE
632 return true;
633}
634
635static bool strip_set_volume_cb(Strip *strip, void * /*user_data*/)
636{
637 strip->volume = 1.0f;
638 return true;
639}
640
641static bool strip_set_sat_cb(Strip *strip, void * /*user_data*/)
642{
643 if (strip->sat == 0.0f) {
644 strip->sat = 1.0f;
645 }
646 return true;
647}
648
649static bool strip_set_pitch_cb(Strip *strip, void * /*user_data*/)
650{
651 strip->pitch_legacy = 1.0f;
652 return true;
653}
654
655/* NOLINTNEXTLINE: readability-function-size */
656void blo_do_versions_250(FileData *fd, Library * /*lib*/, Main *bmain)
657{
658 /* WATCH IT!!!: pointers from libdata have not been converted */
659
660 if (bmain->versionfile < 250) {
661#if 0
662 ListBase pidlist;
663#endif
664
665 LISTBASE_FOREACH (bSound *, sound, &bmain->sounds) {
666 if (sound->newpackedfile) {
667 sound->packedfile = sound->newpackedfile;
668 sound->newpackedfile = nullptr;
669 }
670 }
671
672 LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
673 if (scene->ed) {
674 blender::seq::foreach_strip(&scene->ed->seqbase, strip_sound_proxy_update_cb, bmain);
675 }
676 }
677
678 LISTBASE_FOREACH (bScreen *, screen, &bmain->screens) {
680 do_versions_gpencil_2_50(bmain, screen);
681 }
682
683 /* shader, composite and texture node trees have id.name empty, put something in
684 * to have them show in RNA viewer and accessible otherwise.
685 */
686 LISTBASE_FOREACH (Material *, ma, &bmain->materials) {
687 if (ma->nodetree && ma->nodetree->id.name[0] == '\0') {
688 STRNCPY_UTF8(ma->nodetree->id.name, "NTShader Nodetree");
689 }
690 }
691
692 /* and composite trees */
693 LISTBASE_FOREACH (Scene *, sce, &bmain->scenes) {
694 enum { R_PANORAMA = (1 << 10) };
695 if (sce->nodetree && sce->nodetree->id.name[0] == '\0') {
696 STRNCPY_UTF8(sce->nodetree->id.name, "NTCompositing Nodetree");
697 }
698
699 /* move to cameras */
700 if (sce->r.mode & R_PANORAMA) {
701 LISTBASE_FOREACH (Base *, base, &sce->base) {
702 Object *ob = static_cast<Object *>(
703 blo_do_versions_newlibadr(fd, &sce->id, ID_IS_LINKED(sce), base->object));
704 if (ob->type == OB_CAMERA && !ob->id.lib) {
705 Camera *cam = static_cast<Camera *>(
706 blo_do_versions_newlibadr(fd, &ob->id, ID_IS_LINKED(ob), ob->data));
707 cam->flag |= CAM_PANORAMA;
708 }
709 }
710
711 sce->r.mode &= ~R_PANORAMA;
712 }
713 }
714
715 /* and texture trees */
716 LISTBASE_FOREACH (Tex *, tx, &bmain->textures) {
717 if (tx->nodetree) {
718 if (tx->nodetree->id.name[0] == '\0') {
719 STRNCPY_UTF8(tx->nodetree->id.name, "NTTexture Nodetree");
720 }
721
722 /* which_output 0 is now "not specified" */
723 LISTBASE_FOREACH (bNode *, node, &tx->nodetree->nodes) {
724 if (node->type_legacy == TEX_NODE_OUTPUT) {
725 node->custom1++;
726 }
727 }
728 }
729 }
730
731 /* particle draw and render types */
732 LISTBASE_FOREACH (ParticleSettings *, part, &bmain->particles) {
733 if (part->draw_as) {
734 if (part->draw_as == PART_DRAW_DOT) {
735 part->ren_as = PART_DRAW_HALO;
736 part->draw_as = PART_DRAW_REND;
737 }
738 else if (part->draw_as <= PART_DRAW_AXIS) {
739 part->ren_as = PART_DRAW_HALO;
740 }
741 else {
742 part->ren_as = part->draw_as;
743 part->draw_as = PART_DRAW_REND;
744 }
745 }
746 part->path_end = 1.0f;
747 part->clength = 1.0f;
748 }
749
750 /* Set old point-caches to have disk cache flag. */
751 LISTBASE_FOREACH (Object *, ob, &bmain->objects) {
752
753#if 0
754 BKE_ptcache_ids_from_object(&pidlist, ob);
755
756 LISTBASE_FOREACH (PTCacheID *, pid, &pidlist) {
757 pid->cache->flag |= PTCACHE_DISK_CACHE;
758 }
759
760 BLI_freelistN(&pidlist);
761#endif
762 }
763
764 /* type was a mixed flag & enum. move the 2d flag elsewhere */
765 LISTBASE_FOREACH (Curve *, cu, &bmain->curves) {
766 LISTBASE_FOREACH (Nurb *, nu, &cu->nurb) {
767 nu->type &= CU_TYPE;
768 }
769 }
770 }
771
772 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 250, 1)) {
773#if 0
774 ListBase pidlist;
775#endif
776
777 LISTBASE_FOREACH (Object *, ob, &bmain->objects) {
778#if 0
779 BKE_ptcache_ids_from_object(&pidlist, ob);
780
781 LISTBASE_FOREACH (PTCacheID *, pid, &pidlist) {
782 if (BLI_listbase_is_empty(pid->ptcaches)) {
783 pid->ptcaches->first = pid->ptcaches->last = pid->cache;
784 }
785 }
786
787 BLI_freelistN(&pidlist);
788#endif
789
790 if (ob->totcol && ob->matbits == nullptr) {
791 int a;
792
793 ob->matbits = MEM_calloc_arrayN<char>(ob->totcol, "ob->matbits");
794 for (a = 0; a < ob->totcol; a++) {
795 ob->matbits[a] = (ob->colbits & (1 << a)) != 0;
796 }
797 }
798 }
799
800 LISTBASE_FOREACH (Scene *, sce, &bmain->scenes) {
801 ToolSettings *ts = sce->toolsettings;
802 if (!ts->uv_selectmode || ts->vgroup_weight == 0.0f) {
804
805 /* The auto-keying setting should be taken from the user-preferences
806 * but the user-preferences version may not have correct flags set
807 * (i.e. will result in blank box when enabled). */
808 ts->autokey_mode = U.autokey_mode;
809 if (ts->autokey_mode == 0) {
810 ts->autokey_mode = 2; /* 'add/replace' but not on */
811 }
813 ts->vgroup_weight = 1.0f;
814 }
815 }
816 }
817
818 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 250, 2)) {
819 LISTBASE_FOREACH (Object *, ob, &bmain->objects) {
820 if (ob->flag & 8192) { /* OB_POSEMODE = 8192. */
821 ob->mode |= OB_MODE_POSE;
822 }
823 }
824 }
825
826 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 250, 4)) {
827 bool do_gravity = false;
828
829 LISTBASE_FOREACH (Scene *, sce, &bmain->scenes) {
830 if (sce->unit.scale_length == 0.0f) {
831 sce->unit.scale_length = 1.0f;
832 }
833 }
834
835 LISTBASE_FOREACH (Object *, ob, &bmain->objects) {
836 /* fluid-sim stuff */
839 if (fluidmd) {
840 fluidmd->fss->fmd = fluidmd;
841 }
842
843 /* rotation modes were added,
844 * but old objects would now default to being 'quaternion based' */
845 ob->rotmode = ROT_MODE_EUL;
846 }
847
848 LISTBASE_FOREACH (Scene *, sce, &bmain->scenes) {
849 if (sce->audio.main == 0.0f) {
850 sce->audio.main = 1.0f;
851 }
852
853 sce->r.ffcodecdata.audio_mixrate = sce->audio.mixrate;
854 sce->r.ffcodecdata.audio_volume = sce->audio.main;
855 sce->audio.distance_model = 2;
856 sce->audio.doppler_factor = 1.0f;
857 sce->audio.speed_of_sound = 343.3f;
858 }
859
860 /* Add default gravity to scenes */
861 LISTBASE_FOREACH (Scene *, sce, &bmain->scenes) {
862 if ((sce->physics_settings.flag & PHYS_GLOBAL_GRAVITY) == 0 &&
863 is_zero_v3(sce->physics_settings.gravity))
864 {
865 sce->physics_settings.gravity[0] = sce->physics_settings.gravity[1] = 0.0f;
866 sce->physics_settings.gravity[2] = -9.81f;
867 sce->physics_settings.flag = PHYS_GLOBAL_GRAVITY;
868 do_gravity = true;
869 }
870 }
871
872 /* Assign proper global gravity weights for dynamics
873 * (only z-coordinate is taken into account) */
874 if (do_gravity) {
875 LISTBASE_FOREACH (ParticleSettings *, part, &bmain->particles) {
876 part->effector_weights->global_gravity = part->acc[2] / -9.81f;
877 }
878 }
879
880 LISTBASE_FOREACH (Object *, ob, &bmain->objects) {
881 if (do_gravity) {
882 LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) {
885 if (clmd) {
887 -9.81f;
888 }
889 }
890
891 if (ob->soft) {
892 ob->soft->effector_weights->global_gravity = ob->soft->grav / 9.81f;
893 }
894 }
895
896 /* Normal wind shape is plane */
897 if (ob->pd) {
898 if (ob->pd->forcefield == PFIELD_WIND) {
899 ob->pd->shape = PFIELD_SHAPE_PLANE;
900 }
901
902 if (ob->pd->flag & PFIELD_PLANAR) {
903 ob->pd->shape = PFIELD_SHAPE_PLANE;
904 }
905 else if (ob->pd->flag & PFIELD_SURFACE) {
906 ob->pd->shape = PFIELD_SHAPE_SURFACE;
907 }
908
909 ob->pd->flag |= PFIELD_DO_LOCATION;
910 }
911 }
912 }
913
914 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 250, 6)) {
915 /* New variables for axis-angle rotations and/or quaternion rotations were added,
916 * and need proper initialization */
917 LISTBASE_FOREACH (Object *, ob, &bmain->objects) {
918 /* new variables for all objects */
919 ob->quat[0] = 1.0f;
920 ob->rotAxis[1] = 1.0f;
921
922 /* bones */
923 if (ob->pose) {
924 LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) {
925 /* Just need to initialize rotation axis properly. */
926 pchan->rotAxis[1] = 1.0f;
927 }
928 }
929 }
930 }
931
932 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 250, 7)) {
933 const float *data;
934 int a, tot;
935
936 /* shape keys are no longer applied to the mesh itself, but rather
937 * to the evaluated #Mesh, so here we ensure that the basis
938 * shape key is always set in the mesh coordinates. */
939 LISTBASE_FOREACH (Mesh *, me, &bmain->meshes) {
940 Key *key = static_cast<Key *>(
941 blo_do_versions_newlibadr(fd, &me->id, ID_IS_LINKED(me), me->key));
942 if (key && key->refkey) {
943 data = static_cast<const float *>(key->refkey->data);
944 tot = std::min(me->verts_num, key->refkey->totelem);
945 MVert *verts = (MVert *)CustomData_get_layer_for_write(
946 &me->vert_data, CD_MVERT, me->verts_num);
947 for (a = 0; a < tot; a++, data += 3) {
948 copy_v3_v3(verts[a].co_legacy, data);
949 }
950 }
951 }
952
953 LISTBASE_FOREACH (Lattice *, lt, &bmain->lattices) {
954 Key *key = static_cast<Key *>(
955 blo_do_versions_newlibadr(fd, &lt->id, ID_IS_LINKED(lt), lt->key));
956 if (key && key->refkey) {
957 data = static_cast<const float *>(key->refkey->data);
958 tot = std::min(lt->pntsu * lt->pntsv * lt->pntsw, key->refkey->totelem);
959
960 for (a = 0; a < tot; a++, data += 3) {
961 copy_v3_v3(lt->def[a].vec, data);
962 }
963 }
964 }
965
966 LISTBASE_FOREACH (Curve *, cu, &bmain->curves) {
967 Key *key = static_cast<Key *>(
968 blo_do_versions_newlibadr(fd, &cu->id, ID_IS_LINKED(cu), cu->key));
969 if (key && key->refkey) {
970 data = static_cast<const float *>(key->refkey->data);
971
972 LISTBASE_FOREACH (Nurb *, nu, &cu->nurb) {
973 if (nu->bezt) {
974 BezTriple *bezt = nu->bezt;
975
976 for (a = 0; a < nu->pntsu; a++, bezt++) {
977 copy_v3_v3(bezt->vec[0], data);
978 data += 3;
979 copy_v3_v3(bezt->vec[1], data);
980 data += 3;
981 copy_v3_v3(bezt->vec[2], data);
982 data += 3;
983 bezt->tilt = *data;
984 data++;
985 }
986 }
987 else if (nu->bp) {
988 BPoint *bp = nu->bp;
989
990 for (a = 0; a < nu->pntsu * nu->pntsv; a++, bp++) {
991 copy_v3_v3(bp->vec, data);
992 data += 3;
993 bp->tilt = *data;
994 data++;
995 }
996 }
997 }
998 }
999 }
1000 }
1001
1002 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 250, 8)) {
1003 {
1004 Scene *sce = static_cast<Scene *>(bmain->scenes.first);
1005 while (sce) {
1006 if (sce->r.frame_step == 0) {
1007 sce->r.frame_step = 1;
1008 }
1009
1010 sce = static_cast<Scene *>(sce->id.next);
1011 }
1012 }
1013
1014 {
1015 /* ensure all nodes have unique names */
1016 bNodeTree *ntree = static_cast<bNodeTree *>(bmain->nodetrees.first);
1017 while (ntree) {
1018 bNode *node = static_cast<bNode *>(ntree->nodes.first);
1019
1020 while (node) {
1021 blender::bke::node_unique_name(*ntree, *node);
1022 node = node->next;
1023 }
1024
1025 ntree = static_cast<bNodeTree *>(ntree->id.next);
1026 }
1027 }
1028
1029 {
1030 Object *ob = static_cast<Object *>(bmain->objects.first);
1031 while (ob) {
1032 /* shaded mode disabled for now */
1033 if (ob->dt == OB_MATERIAL) {
1034 ob->dt = OB_TEXTURE;
1035 }
1036 ob = static_cast<Object *>(ob->id.next);
1037 }
1038 }
1039
1040 {
1041 LISTBASE_FOREACH (bScreen *, screen, &bmain->screens) {
1042 LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
1043 LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
1044 if (sl->spacetype == SPACE_VIEW3D) {
1045 View3D *v3d = (View3D *)sl;
1046 if (v3d->drawtype == OB_MATERIAL) {
1047 v3d->drawtype = OB_SOLID;
1048 }
1049 }
1050 }
1051 }
1052 }
1053 }
1054
1055 /* only convert old 2.50 files with color management */
1056 if (bmain->versionfile == 250) {
1057 Scene *sce = static_cast<Scene *>(bmain->scenes.first);
1058 Material *ma = static_cast<Material *>(bmain->materials.first);
1059 Tex *tex = static_cast<Tex *>(bmain->textures.first);
1060 int i, convert = 0;
1061
1062 /* convert to new color management system:
1063 * while previously colors were stored as srgb,
1064 * now they are stored as linear internally,
1065 * with screen gamma correction in certain places in the UI. */
1066
1067 /* don't know what scene is active, so we'll convert if any scene has it enabled... */
1068 while (sce) {
1069 if (sce->r.color_mgt_flag & R_COLOR_MANAGEMENT) {
1070 convert = 1;
1071 }
1072 sce = static_cast<Scene *>(sce->id.next);
1073 }
1074
1075 if (convert) {
1076 while (ma) {
1077 srgb_to_linearrgb_v3_v3(&ma->r, &ma->r);
1079 ma = static_cast<Material *>(ma->id.next);
1080 }
1081
1082 while (tex) {
1083 if (tex->coba) {
1084 ColorBand *band = (ColorBand *)tex->coba;
1085 for (i = 0; i < band->tot; i++) {
1086 CBData *data = band->data + i;
1088 }
1089 }
1090 tex = static_cast<Tex *>(tex->id.next);
1091 }
1092 }
1093 }
1094 }
1095
1096 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 250, 9)) {
1097 LISTBASE_FOREACH (Scene *, sce, &bmain->scenes) {
1098 if (!sce->toolsettings->particle.selectmode) {
1099 sce->toolsettings->particle.selectmode = SCE_SELECT_PATH;
1100 }
1101 }
1102
1103 if (bmain->versionfile == 250 && bmain->subversionfile > 1) {
1104 LISTBASE_FOREACH (Mesh *, me, &bmain->meshes) {
1105 CustomData_free_layer_active(&me->fdata_legacy, CD_MDISPS);
1106 }
1107
1108 LISTBASE_FOREACH (Object *, ob, &bmain->objects) {
1111
1112 if (mmd) {
1113 mmd->totlvl--;
1114 mmd->lvl--;
1115 mmd->sculptlvl = mmd->lvl;
1116 mmd->renderlvl = mmd->lvl;
1117 }
1118 }
1119 }
1120 }
1121
1122 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 250, 10)) {
1123 /* Properly initialize hair cloth-simulation data on old files. */
1124 LISTBASE_FOREACH (Object *, ob, &bmain->objects) {
1125 LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) {
1126 if (md->type == eModifierType_Cloth) {
1128 if (clmd->sim_parms->velocity_smooth < 0.01f) {
1129 clmd->sim_parms->velocity_smooth = 0.0f;
1130 }
1131 }
1132 }
1133 }
1134 }
1135
1136 /* fix bad area setup in subversion 10 */
1137 if (bmain->versionfile == 250 && bmain->subversionfile == 10) {
1138 /* fix for new view type in sequencer */
1139 /* remove all preview window in wrong spaces */
1140 LISTBASE_FOREACH (bScreen *, screen, &bmain->screens) {
1141 LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
1142 LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
1143 if (sl->spacetype != SPACE_SEQ) {
1144 ListBase *regionbase;
1145
1146 if (sl == area->spacedata.first) {
1147 regionbase = &area->regionbase;
1148 }
1149 else {
1150 regionbase = &sl->regionbase;
1151 }
1152
1153 LISTBASE_FOREACH (ARegion *, region, regionbase) {
1154 if (region->regiontype == RGN_TYPE_PREVIEW) {
1156 BKE_area_region_free(st, region);
1157 BLI_freelinkN(regionbase, region);
1158 break;
1159 }
1160 }
1161 }
1162 }
1163 }
1164 }
1165 }
1166
1167 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 250, 11)) {
1168 {
1169 /* fix for new view type in sequencer */
1170 LISTBASE_FOREACH (bScreen *, screen, &bmain->screens) {
1171 LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
1172 LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
1173 if (sl->spacetype == SPACE_SEQ) {
1174 ListBase *regionbase;
1175 SpaceSeq *sseq = (SpaceSeq *)sl;
1176
1177 if (sl == area->spacedata.first) {
1178 regionbase = &area->regionbase;
1179 }
1180 else {
1181 regionbase = &sl->regionbase;
1182 }
1183
1184 if (sseq->view == 0) {
1185 sseq->view = SEQ_VIEW_SEQUENCE;
1186 }
1187 if (sseq->mainb == 0) {
1188 sseq->mainb = SEQ_DRAW_IMG_IMBUF;
1189 }
1190
1191 ARegion *region_main = nullptr;
1192 LISTBASE_FOREACH (ARegion *, region, regionbase) {
1193 if (region->regiontype == RGN_TYPE_WINDOW) {
1194 region_main = region;
1195 break;
1196 }
1197 }
1198 ARegion *region = BKE_area_region_new();
1199 BLI_insertlinkbefore(regionbase, region_main, region);
1201 }
1202 }
1203 }
1204 }
1205 }
1206 }
1207
1208 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 250, 12)) {
1209 /* anim viz changes */
1210 LISTBASE_FOREACH (Object *, ob, &bmain->objects) {
1211 /* initialize object defaults */
1212 animviz_settings_init(&ob->avs);
1213
1214 /* if armature, copy settings for pose from armature data
1215 * performing initialization where appropriate
1216 */
1217 if (ob->pose && ob->data) {
1218 bArmature *arm = static_cast<bArmature *>(
1219 blo_do_versions_newlibadr(fd, &ob->id, ID_IS_LINKED(ob), ob->data));
1220 if (arm) { /* XXX: why does this fail in some cases? */
1221 bAnimVizSettings *avs = &ob->pose->avs;
1222
1223 /* path settings --------------------- */
1224 /* ranges */
1225 avs->path_bc = 10;
1226 avs->path_ac = 10;
1227
1228 avs->path_sf = 1;
1229 avs->path_ef = 250;
1230
1231 /* flags */
1232 if (arm->pathflag & ARM_PATH_FNUMS) {
1234 }
1235 if (arm->pathflag & ARM_PATH_KFRAS) {
1237 }
1238 if (arm->pathflag & ARM_PATH_KFNOS) {
1240 }
1241
1242 /* bake flags */
1243 if (arm->pathflag & ARM_PATH_HEADS) {
1245 }
1246
1247 /* type */
1248 if (arm->pathflag & ARM_PATH_ACFRA) {
1250 }
1251
1252 /* stepsize */
1253 avs->path_step = 1;
1254 }
1255 else {
1256 animviz_settings_init(&ob->pose->avs);
1257 }
1258 }
1259 }
1260
1261 /* brush texture changes */
1262 LISTBASE_FOREACH (Brush *, brush, &bmain->brushes) {
1263 BKE_texture_mtex_default(&brush->mtex);
1264 BKE_texture_mtex_default(&brush->mask_mtex);
1265 }
1266 }
1267
1268 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 250, 13)) {
1269 /* NOTE: if you do more conversion, be sure to do it outside of this and
1270 * increase subversion again, otherwise it will not be correct */
1271 /* convert degrees to radians for internal use */
1272 LISTBASE_FOREACH (Object *, ob, &bmain->objects) {
1274
1275 if (ob->pose) {
1276 LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) {
1277 pchan->limitmin[0] *= float(M_PI / 180.0);
1278 pchan->limitmin[1] *= float(M_PI / 180.0);
1279 pchan->limitmin[2] *= float(M_PI / 180.0);
1280 pchan->limitmax[0] *= float(M_PI / 180.0);
1281 pchan->limitmax[1] *= float(M_PI / 180.0);
1282 pchan->limitmax[2] *= float(M_PI / 180.0);
1283
1284 do_version_constraints_radians_degrees_250(&pchan->constraints);
1285 }
1286 }
1287 }
1288 }
1289
1290 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 250, 14)) {
1291 /* fix for bad View2D extents for Animation Editors */
1292 LISTBASE_FOREACH (bScreen *, screen, &bmain->screens) {
1293 LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
1294 LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
1295 ListBase *regionbase;
1296
1297 if (sl == area->spacedata.first) {
1298 regionbase = &area->regionbase;
1299 }
1300 else {
1301 regionbase = &sl->regionbase;
1302 }
1303
1304 if (ELEM(sl->spacetype, SPACE_ACTION, SPACE_NLA)) {
1305 LISTBASE_FOREACH (ARegion *, region, regionbase) {
1306 if (region->regiontype == RGN_TYPE_WINDOW) {
1307 region->v2d.cur.ymax = region->v2d.tot.ymax = 0.0f;
1308 region->v2d.cur.ymin = region->v2d.tot.ymin = float(-area->winy) / 3.0f;
1309 }
1310 }
1311 }
1312 }
1313 }
1314 }
1315 }
1316
1317 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 250, 17)) {
1318 /* initialize to sane default so toggling on border shows something */
1319 LISTBASE_FOREACH (Scene *, sce, &bmain->scenes) {
1320 if (sce->r.border.xmin == 0.0f && sce->r.border.ymin == 0.0f && sce->r.border.xmax == 0.0f &&
1321 sce->r.border.ymax == 0.0f)
1322 {
1323 sce->r.border.xmin = 0.0f;
1324 sce->r.border.ymin = 0.0f;
1325 sce->r.border.xmax = 1.0f;
1326 sce->r.border.ymax = 1.0f;
1327 }
1328
1329 if ((sce->r.ffcodecdata.flags & FFMPEG_MULTIPLEX_AUDIO) == 0) {
1330 sce->r.ffcodecdata.audio_codec = 0x0; /* `CODEC_ID_NONE` */
1331 }
1332 if (sce->ed) {
1333 blender::seq::foreach_strip(&sce->ed->seqbase, strip_set_volume_cb, nullptr);
1334 }
1335 }
1336
1337 /* particle brush strength factor was changed from int to float */
1338 LISTBASE_FOREACH (Scene *, sce, &bmain->scenes) {
1339 ParticleEditSettings *pset = &sce->toolsettings->particle;
1340 int a;
1341
1342 for (a = 0; a < ARRAY_SIZE(pset->brush); a++) {
1343 pset->brush[a].strength /= 100.0f;
1344 }
1345 }
1346
1347 /* sequencer changes */
1348 {
1349 LISTBASE_FOREACH (bScreen *, screen, &bmain->screens) {
1350 LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
1351 LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
1352 if (sl->spacetype == SPACE_SEQ) {
1353 ListBase *regionbase;
1354
1355 if (sl == area->spacedata.first) {
1356 regionbase = &area->regionbase;
1357 }
1358 else {
1359 regionbase = &sl->regionbase;
1360 }
1361
1362 LISTBASE_FOREACH (ARegion *, region_preview, regionbase) {
1363 if (region_preview->regiontype == RGN_TYPE_PREVIEW) {
1364 sequencer_init_preview_region(region_preview);
1365 break;
1366 }
1367 }
1368 }
1369 }
1370 }
1371 }
1372 } /* sequencer changes */
1373 }
1374
1375 if (bmain->versionfile <= 251) { /* 2.5.1 had no sub-versions */
1376 /* Blender 2.5.2 - subversion 0 introduced a new setting: V3D_HIDE_OVERLAYS.
1377 * This bit was used in the past for V3D_TRANSFORM_SNAP, which is now deprecated.
1378 * Here we clear it for old files so they don't come in with V3D_HIDE_OVERLAYS set,
1379 * which would cause cameras, lights, etc to become invisible */
1380 LISTBASE_FOREACH (bScreen *, screen, &bmain->screens) {
1381 LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
1382 LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
1383 if (sl->spacetype == SPACE_VIEW3D) {
1384 View3D *v3d = (View3D *)sl;
1385 v3d->flag2 &= ~V3D_HIDE_OVERLAYS;
1386 }
1387 }
1388 }
1389 }
1390 }
1391
1392 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 252, 1)) {
1393 LISTBASE_FOREACH (Brush *, brush, &bmain->brushes) {
1394 if (brush->curve_distance_falloff) {
1395 brush->curve_distance_falloff->preset = CURVE_PRESET_SMOOTH;
1396 }
1397 }
1398
1399 /* properly initialize active flag for fluidsim modifiers */
1400 LISTBASE_FOREACH (Object *, ob, &bmain->objects) {
1401 LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) {
1402 if (md->type == eModifierType_Fluidsim) {
1404 fmd->fss->flag |= OB_FLUIDSIM_ACTIVE;
1406 }
1407 }
1408 }
1409
1410 /* adjustment to color balance node values */
1411 LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
1412 if (scene->nodetree) {
1413 bNode *node = static_cast<bNode *>(scene->nodetree->nodes.first);
1414
1415 while (node) {
1416 if (node->type_legacy == CMP_NODE_COLORBALANCE) {
1418 n->lift[0] += 1.0f;
1419 n->lift[1] += 1.0f;
1420 n->lift[2] += 1.0f;
1421 }
1422 node = node->next;
1423 }
1424 }
1425 }
1426 /* check inside node groups too */
1427 LISTBASE_FOREACH (bNodeTree *, ntree, &bmain->nodetrees) {
1428 bNode *node = static_cast<bNode *>(ntree->nodes.first);
1429
1430 while (node) {
1431 if (node->type_legacy == CMP_NODE_COLORBALANCE) {
1433 n->lift[0] += 1.0f;
1434 n->lift[1] += 1.0f;
1435 n->lift[2] += 1.0f;
1436 }
1437
1438 node = node->next;
1439 }
1440 }
1441 }
1442
1443 /* old-track -> constraints (this time we're really doing it!) */
1444 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 252, 2)) {
1445 LISTBASE_FOREACH (Object *, ob, &bmain->objects) {
1447 }
1448 }
1449
1450 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 252, 5)) {
1451 /* Image editor scopes */
1452 LISTBASE_FOREACH (bScreen *, screen, &bmain->screens) {
1453 LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
1454 LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
1455 if (sl->spacetype == SPACE_IMAGE) {
1456 SpaceImage *sima = (SpaceImage *)sl;
1457 BKE_scopes_new(&sima->scopes);
1458 }
1459 }
1460 }
1461 }
1462 }
1463
1464 if (bmain->versionfile < 253) {
1465 LISTBASE_FOREACH (bScreen *, screen, &bmain->screens) {
1466 LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
1467 LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
1468 if (sl->spacetype == SPACE_NODE) {
1469 SpaceNode *snode = (SpaceNode *)sl;
1470 ListBase *regionbase;
1471
1472 if (sl == area->spacedata.first) {
1473 regionbase = &area->regionbase;
1474 }
1475 else {
1476 regionbase = &sl->regionbase;
1477 }
1478
1479 snode->v2d.minzoom = std::min(snode->v2d.minzoom, 0.09f);
1480 snode->v2d.maxzoom = std::max(snode->v2d.maxzoom, 2.31f);
1481
1482 LISTBASE_FOREACH (ARegion *, region, regionbase) {
1483 if (region->regiontype == RGN_TYPE_WINDOW) {
1484 region->v2d.minzoom = std::min(region->v2d.minzoom, 0.09f);
1485 region->v2d.maxzoom = std::max(region->v2d.maxzoom, 2.31f);
1486 }
1487 }
1488 }
1489 }
1490 }
1491 }
1492
1493 do_version_mdef_250(bmain);
1494
1495 /* parent type to modifier */
1496 LISTBASE_FOREACH (Object *, ob, &bmain->objects) {
1497 if (ob->parent) {
1499 fd, &ob->id, ID_IS_LINKED(ob), ob->parent);
1500 if (parent) { /* parent may not be in group */
1501 enum { PARCURVE = 1 };
1502 if (parent->type == OB_ARMATURE && ob->partype == PARSKEL) {
1505 fd, &parent->id, ID_IS_LINKED(parent), parent->data);
1506
1508 amd->object = ob->parent;
1509 BLI_addtail((&ob->modifiers), amd);
1510 amd->deformflag = arm->deformflag;
1511 ob->partype = PAROBJECT;
1512 }
1513 else if (parent->type == OB_LATTICE && ob->partype == PARSKEL) {
1515
1517 lmd->object = ob->parent;
1518 BLI_addtail((&ob->modifiers), lmd);
1519 ob->partype = PAROBJECT;
1520 }
1521 else if (parent->type == OB_CURVES_LEGACY && ob->partype == PARCURVE) {
1522 CurveModifierData *cmd;
1523
1525 cmd->object = ob->parent;
1526 BLI_addtail((&ob->modifiers), cmd);
1527 ob->partype = PAROBJECT;
1528 }
1529 }
1530 }
1531 }
1532
1533 /* initialize scene active layer */
1534 LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
1535 int i;
1536 for (i = 0; i < 20; i++) {
1537 if (scene->lay & (1 << i)) {
1538 scene->layact = 1 << i;
1539 break;
1540 }
1541 }
1542 }
1543
1544 LISTBASE_FOREACH (Tex *, tex, &bmain->textures) {
1545 /* If you're picky, this isn't correct until we do a version bump
1546 * since you could set saturation to be 0.0. */
1547 if (tex->saturation == 0.0f) {
1548 tex->saturation = 1.0f;
1549 }
1550 }
1551
1552 LISTBASE_FOREACH (Curve *, cu, &bmain->curves) {
1553 cu->smallcaps_scale = 0.75f;
1554 }
1555
1556 LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
1557 if (scene->ed) {
1558 blender::seq::foreach_strip(&scene->ed->seqbase, strip_set_sat_cb, nullptr);
1559 }
1560 }
1561
1562 /* GSOC 2010 Sculpt - New settings for Brush */
1563
1564 LISTBASE_FOREACH (Brush *, brush, &bmain->brushes) {
1565 /* Sanity Check */
1566
1567 /* infinite number of dabs */
1568 if (brush->spacing == 0) {
1569 brush->spacing = 10;
1570 }
1571
1572 /* will have no effect */
1573 if (brush->alpha == 0) {
1574 brush->alpha = 1.0f;
1575 }
1576
1577 /* bad radius */
1578 if (brush->unprojected_size == 0) {
1579 brush->unprojected_size = 0.125f;
1580 }
1581
1582 /* unusable size */
1583 if (brush->size == 0) {
1584 brush->size = 35;
1585 }
1586
1587 /* can't see overlay */
1588 if (brush->texture_overlay_alpha == 0) {
1589 brush->texture_overlay_alpha = 33;
1590 }
1591
1592 /* same as draw brush */
1593 if (brush->crease_pinch_factor == 0) {
1594 brush->crease_pinch_factor = 0.5f;
1595 }
1596
1597 /* will sculpt no vertices */
1598 if (brush->plane_trim == 0) {
1599 brush->plane_trim = 0.5f;
1600 }
1601
1602 /* same as smooth stroke off */
1603 if (brush->smooth_stroke_radius == 0) {
1604 brush->smooth_stroke_radius = 75;
1605 }
1606
1607 /* will keep cursor in one spot */
1608 if (brush->smooth_stroke_radius == 1) {
1609 brush->smooth_stroke_factor = 0.9f;
1610 }
1611
1612 /* same as dots */
1613 if (brush->rate == 0) {
1614 brush->rate = 0.1f;
1615 }
1616
1617 /* New Settings */
1618 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 252, 5)) {
1619 brush->flag |= BRUSH_SPACE_ATTEN; /* Explicitly enable adaptive space. */
1620
1621 /* spacing was originally in pixels, convert it to percentage for new version
1622 * size should not be zero due to sanity check above
1623 */
1624 brush->spacing = int(100 * float(brush->spacing) / float(brush->size));
1625
1626 if (brush->add_col[0] == 0 && brush->add_col[1] == 0 && brush->add_col[2] == 0) {
1627 brush->add_col[0] = 1.00f;
1628 brush->add_col[1] = 0.39f;
1629 brush->add_col[2] = 0.39f;
1630 }
1631
1632 if (brush->sub_col[0] == 0 && brush->sub_col[1] == 0 && brush->sub_col[2] == 0) {
1633 brush->sub_col[0] = 0.39f;
1634 brush->sub_col[1] = 0.39f;
1635 brush->sub_col[2] = 1.00f;
1636 }
1637 }
1638 }
1639 }
1640
1641 /* GSOC Sculpt 2010 - Sanity check on Sculpt/Paint settings */
1642 if (bmain->versionfile < 253) {
1643 LISTBASE_FOREACH (Scene *, sce, &bmain->scenes) {
1644 if (sce->toolsettings->sculpt_paint_unified_alpha == 0) {
1645 sce->toolsettings->sculpt_paint_unified_alpha = 0.5f;
1646 }
1647
1648 if (sce->toolsettings->sculpt_paint_unified_unprojected_radius == 0) {
1649 sce->toolsettings->sculpt_paint_unified_unprojected_radius = 0.125f;
1650 }
1651
1652 if (sce->toolsettings->sculpt_paint_unified_size == 0) {
1653 sce->toolsettings->sculpt_paint_unified_size = 35;
1654 }
1655 }
1656 }
1657
1658 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 253, 1)) {
1659 LISTBASE_FOREACH (Object *, ob, &bmain->objects) {
1660 LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) {
1661 if (md->type == eModifierType_Fluid) {
1663
1664 if ((fmd->type & MOD_FLUID_TYPE_DOMAIN) && fmd->domain) {
1665 fmd->domain->vorticity = 2.0f;
1666 fmd->domain->time_scale = 1.0f;
1667
1668 if (!(fmd->domain->flags & (1 << 4))) {
1669 continue;
1670 }
1671
1672 /* delete old MOD_SMOKE_INITVELOCITY flag */
1673 fmd->domain->flags &= ~(1 << 4);
1674
1675 /* for now just add it to all flow objects in the scene */
1676 LISTBASE_FOREACH (Object *, ob2, &bmain->objects) {
1677 LISTBASE_FOREACH (ModifierData *, md2, &ob2->modifiers) {
1678 if (md2->type == eModifierType_Fluid) {
1679 FluidModifierData *fmd2 = (FluidModifierData *)md2;
1680
1681 if ((fmd2->type & MOD_FLUID_TYPE_FLOW) && fmd2->flow) {
1683 }
1684 }
1685 }
1686 }
1687 }
1688 else if ((fmd->type & MOD_FLUID_TYPE_FLOW) && fmd->flow) {
1689 fmd->flow->vel_multi = 1.0f;
1690 }
1691 }
1692 }
1693 }
1694 }
1695
1696 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 255, 1)) {
1697 LISTBASE_FOREACH (Brush *, br, &bmain->brushes) {
1698 if (br->ob_mode == 0) {
1699 br->ob_mode = OB_MODE_ALL_PAINT;
1700 }
1701 }
1702
1703 LISTBASE_FOREACH (ParticleSettings *, part, &bmain->particles) {
1704 if (part->boids) {
1705 part->boids->pitch = 1.0f;
1706 }
1707
1708 part->flag &= ~PART_HAIR_REGROW; /* this was a deprecated flag before */
1709 part->kink_amp_clump = 1.0f; /* keep old files looking similar */
1710 }
1711
1712 LISTBASE_FOREACH (bScreen *, screen, &bmain->screens) {
1713 LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
1714 LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
1715 if (sl->spacetype == SPACE_INFO) {
1716 SpaceInfo *sinfo = (SpaceInfo *)sl;
1717
1718 sinfo->rpt_mask = INFO_RPT_OP;
1719
1720 LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
1721 if (region->regiontype == RGN_TYPE_WINDOW) {
1722 region->v2d.scroll = (V2D_SCROLL_RIGHT);
1723 region->v2d.align = V2D_ALIGN_NO_NEG_X |
1724 V2D_ALIGN_NO_NEG_Y; /* align bottom left */
1725 region->v2d.keepofs = V2D_LOCKOFS_X;
1726 region->v2d.keepzoom = (V2D_LOCKZOOM_X | V2D_LOCKZOOM_Y | V2D_LIMITZOOM |
1728 region->v2d.keeptot = V2D_KEEPTOT_BOUNDS;
1729 region->v2d.minzoom = region->v2d.maxzoom = 1.0f;
1730 }
1731 }
1732 }
1733 }
1734 }
1735 }
1736 }
1737
1738 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 255, 3)) {
1739 /* ocean res is now squared, reset old ones - will be massive */
1740 LISTBASE_FOREACH (Object *, ob, &bmain->objects) {
1741 LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) {
1742 if (md->type == eModifierType_Ocean) {
1744 omd->resolution = 7;
1745 omd->oceancache = nullptr;
1746 }
1747 }
1748 }
1749 }
1750
1751 if (bmain->versionfile < 256) {
1752 ScrArea *area;
1753
1754 /* Fix for sample line scope initializing with no height */
1755 LISTBASE_FOREACH (bScreen *, screen, &bmain->screens) {
1756 area = static_cast<ScrArea *>(screen->areabase.first);
1757 while (area) {
1758 LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
1759 if (sl->spacetype == SPACE_IMAGE) {
1760 SpaceImage *sima = (SpaceImage *)sl;
1761 if (sima->sample_line_hist.height == 0) {
1762 sima->sample_line_hist.height = 100;
1763 }
1764 }
1765 }
1766 area = area->next;
1767 }
1768 }
1769
1770 /* old files could have been saved with slidermin = slidermax = 0.0, but the UI in
1771 * 2.4x would never reveal this to users as a dummy value always ended up getting used
1772 * instead
1773 */
1774 LISTBASE_FOREACH (Key *, key, &bmain->shapekeys) {
1775 LISTBASE_FOREACH (KeyBlock *, kb, &key->block) {
1776 if (IS_EQF(kb->slidermin, kb->slidermax) && IS_EQF(kb->slidermax, 0.0f)) {
1777 kb->slidermax = kb->slidermin + 1.0f;
1778 }
1779 }
1780 }
1781 }
1782
1783 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 256, 1)) {
1784 /* fix for bones that didn't have arm_roll before */
1785 LISTBASE_FOREACH (bArmature *, arm, &bmain->armatures) {
1786 LISTBASE_FOREACH (Bone *, bone, &arm->bonebase) {
1788 }
1789 }
1790
1791 /* fix for objects which have zero dquat's
1792 * since this is multiplied with the quat rather than added */
1793 LISTBASE_FOREACH (Object *, ob, &bmain->objects) {
1794 if (is_zero_v4(ob->dquat)) {
1795 unit_qt(ob->dquat);
1796 }
1797 if (is_zero_v3(ob->drotAxis) && ob->drotAngle == 0.0f) {
1798 unit_axis_angle(ob->drotAxis, &ob->drotAngle);
1799 }
1800 }
1801 }
1802
1803 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 256, 2)) {
1804 /* node sockets are not exposed automatically any more,
1805 * this mimics the old behavior by adding all unlinked sockets to groups.
1806 */
1807 LISTBASE_FOREACH (bNodeTree *, ntree, &bmain->nodetrees) {
1808 /* this adds copies and links from all unlinked internal sockets to group inputs/outputs. */
1809
1810 /* first make sure the own_index for new sockets is valid */
1811 LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
1812 LISTBASE_FOREACH (bNodeSocket *, sock, &node->inputs) {
1813 if (sock->own_index >= ntree->cur_index) {
1814 ntree->cur_index = sock->own_index + 1;
1815 }
1816 }
1817 LISTBASE_FOREACH (bNodeSocket *, sock, &node->outputs) {
1818 if (sock->own_index >= ntree->cur_index) {
1819 ntree->cur_index = sock->own_index + 1;
1820 }
1821 }
1822 }
1823
1824 /* add ntree->inputs/ntree->outputs sockets for all unlinked sockets in the group tree. */
1825 LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
1826 LISTBASE_FOREACH (bNodeSocket *, sock, &node->inputs) {
1827 if (!sock->link && !((sock->flag & (SOCK_HIDDEN | SOCK_UNAVAIL)) != 0)) {
1828
1830 ntree, sock->name, sock->type, SOCK_IN);
1831
1832 /* initialize the default socket value */
1833 copy_v4_v4(gsock->ns.vec, sock->ns.vec);
1834
1835 /* XXX node_add_link does not work with incomplete (node==nullptr) links any longer,
1836 * have to create these directly here.
1837 * These links are updated again in subsequent do_version!
1838 */
1839 bNodeLink *link = MEM_callocN<bNodeLink>("link");
1840 BLI_addtail(&ntree->links, link);
1841 link->fromnode = nullptr;
1842 link->fromsock = gsock;
1843 link->tonode = node;
1844 link->tosock = sock;
1846
1847 sock->link = link;
1848 }
1849 }
1850 LISTBASE_FOREACH (bNodeSocket *, sock, &node->outputs) {
1851 if (blender::bke::node_count_socket_links(*ntree, *sock) == 0 &&
1852 !((sock->flag & (SOCK_HIDDEN | SOCK_UNAVAIL)) != 0))
1853 {
1855 ntree, sock->name, sock->type, SOCK_OUT);
1856
1857 /* initialize the default socket value */
1858 copy_v4_v4(gsock->ns.vec, sock->ns.vec);
1859
1860 /* XXX node_add_link does not work with incomplete (node==nullptr) links any longer,
1861 * have to create these directly here.
1862 * These links are updated again in subsequent do_version!
1863 */
1864 bNodeLink *link = MEM_callocN<bNodeLink>("link");
1865 BLI_addtail(&ntree->links, link);
1866 link->fromnode = node;
1867 link->fromsock = sock;
1868 link->tonode = nullptr;
1869 link->tosock = gsock;
1871
1872 gsock->link = link;
1873 }
1874 }
1875 }
1876
1877 /* External group node socket need to adjust their own_index to point at
1878 * associated 'ntree' inputs/outputs internal sockets. This happens in
1879 * do_versions_after_linking_250, after lib linking. */
1880 }
1881 }
1882
1883 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 256, 3)) {
1884 /* redraws flag in SpaceTime has been moved to Screen level */
1885 LISTBASE_FOREACH (bScreen *, screen, &bmain->screens) {
1886 if (screen->redraws_flag == 0) {
1887 /* just initialize to default? */
1888 /* XXX: we could also have iterated through areas,
1889 * and taken them from the first timeline available... */
1890 screen->redraws_flag = TIME_ALL_3D_WIN | TIME_ALL_ANIM_WIN;
1891 }
1892 }
1893
1894 LISTBASE_FOREACH (Brush *, brush, &bmain->brushes) {
1895 if (brush->height == 0) {
1896 brush->height = 0.4f;
1897 }
1898 }
1899
1900 /* Replace 'rim material' option for in offset. */
1901 LISTBASE_FOREACH (Object *, ob, &bmain->objects) {
1902 LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) {
1903 if (md->type == eModifierType_Solidify) {
1905 if (smd->flag & MOD_SOLIDIFY_RIM_MATERIAL) {
1906 smd->mat_ofs_rim = 1;
1907 smd->flag &= ~MOD_SOLIDIFY_RIM_MATERIAL;
1908 }
1909 }
1910 }
1911 }
1912
1913 /* particle draw color from material */
1914 LISTBASE_FOREACH (ParticleSettings *, part, &bmain->particles) {
1915 if (part->draw & PART_DRAW_MAT_COL) {
1916 part->draw_col = PART_DRAW_COL_MAT;
1917 }
1918 }
1919 }
1920
1921 if (false) {
1922 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 256, 6)) {
1923 LISTBASE_FOREACH (Mesh *, me, &bmain->meshes) {
1924 /* Vertex normal calculation from legacy 'MFace' has been removed.
1925 * update after calculating polygons in file reading code instead. */
1926 }
1927 }
1928 }
1929
1930 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 256, 2)) {
1931 /* update blur area sizes from 0..1 range to 0..100 percentage */
1932 LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
1933 if (scene->nodetree) {
1934 LISTBASE_FOREACH (bNode *, node, &scene->nodetree->nodes) {
1935 if (node->type_legacy == CMP_NODE_BLUR) {
1936 NodeBlurData *nbd = static_cast<NodeBlurData *>(node->storage);
1937 nbd->percentx *= 100.0f;
1938 nbd->percenty *= 100.0f;
1939 }
1940 }
1941 }
1942 }
1943 }
1944
1945 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 258, 1)) {
1946 /* screen view2d settings were not properly initialized #27164.
1947 * v2d->scroll caused the bug but best reset other values too
1948 * which are in old blend files only.
1949 * Need to make less ugly - possibly an iterator? */
1950 LISTBASE_FOREACH (bScreen *, screen, &bmain->screens) {
1951 /* add regions */
1952 LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
1953 SpaceLink *sl_first = static_cast<SpaceLink *>(area->spacedata.first);
1954 if (sl_first->spacetype == SPACE_IMAGE) {
1955 LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
1956 if (region->regiontype == RGN_TYPE_WINDOW) {
1957 View2D *v2d = &region->v2d;
1958 v2d->minzoom = v2d->maxzoom = v2d->scroll = v2d->keeptot = v2d->keepzoom =
1959 v2d->keepofs = v2d->align = 0;
1960 }
1961 }
1962 }
1963
1964 LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
1965 if (sl->spacetype == SPACE_IMAGE) {
1966 LISTBASE_FOREACH (ARegion *, region, &sl->regionbase) {
1967 if (region->regiontype == RGN_TYPE_WINDOW) {
1968 View2D *v2d = &region->v2d;
1969 v2d->minzoom = v2d->maxzoom = v2d->scroll = v2d->keeptot = v2d->keepzoom =
1970 v2d->keepofs = v2d->align = 0;
1971 }
1972 }
1973 }
1974 }
1975 }
1976 }
1977
1978 LISTBASE_FOREACH (ParticleSettings *, part, &bmain->particles) {
1979 /* Initialize particle billboard scale */
1980 part->bb_size[0] = part->bb_size[1] = 1.0f;
1981 }
1982 }
1983
1984 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 259, 1)) {
1985 LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
1986 scene->r.ffcodecdata.audio_channels = 2;
1987 scene->audio.volume = 1.0f;
1988 if (scene->ed) {
1989 blender::seq::foreach_strip(&scene->ed->seqbase, strip_set_pitch_cb, nullptr);
1990 }
1991 }
1992
1993 LISTBASE_FOREACH (bScreen *, screen, &bmain->screens) {
1994 /* add regions */
1995 LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
1996 SpaceLink *sl_first = static_cast<SpaceLink *>(area->spacedata.first);
1997 if (sl_first->spacetype == SPACE_SEQ) {
1998 LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
1999 if (region->regiontype == RGN_TYPE_WINDOW) {
2000 if (region->v2d.min[1] == 4.0f) {
2001 region->v2d.min[1] = 0.5f;
2002 }
2003 }
2004 }
2005 }
2006 LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
2007 if (sl->spacetype == SPACE_SEQ) {
2008 LISTBASE_FOREACH (ARegion *, region, &sl->regionbase) {
2009 if (region->regiontype == RGN_TYPE_WINDOW) {
2010 if (region->v2d.min[1] == 4.0f) {
2011 region->v2d.min[1] = 0.5f;
2012 }
2013 }
2014 }
2015 }
2016 }
2017 }
2018 }
2019
2020 /* Make "auto-clamped" handles a per-keyframe setting instead of per-FCurve
2021 *
2022 * We're only patching F-Curves in Actions here, since it is assumed that most
2023 * drivers out there won't be using this (and if they are, they're in the minority).
2024 * While we should aim to fix everything ideally, in practice it's far too hard
2025 * to get to every animdata block, not to mention the performance hit that'd have
2026 */
2027 LISTBASE_FOREACH (bAction *, act, &bmain->actions) {
2028 LISTBASE_FOREACH (FCurve *, fcu, &act->curves) {
2029 BezTriple *bezt;
2030 uint i = 0;
2031
2032 /* only need to touch curves that had this flag set */
2033 if ((fcu->flag & FCURVE_AUTO_HANDLES) == 0) {
2034 continue;
2035 }
2036 if ((fcu->totvert == 0) || (fcu->bezt == nullptr)) {
2037 continue;
2038 }
2039
2040 /* only change auto-handles to auto-clamped */
2041 for (bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) {
2042 if (bezt->h1 == HD_AUTO) {
2043 bezt->h1 = HD_AUTO_ANIM;
2044 }
2045 if (bezt->h2 == HD_AUTO) {
2046 bezt->h2 = HD_AUTO_ANIM;
2047 }
2048 }
2049
2050 fcu->flag &= ~FCURVE_AUTO_HANDLES;
2051 }
2052 }
2053 }
2054
2055 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 259, 2)) {
2056 {
2057 /* Convert default socket values from bNodeStack */
2058 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
2059 LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
2060 LISTBASE_FOREACH (bNodeSocket *, sock, &node->inputs) {
2062 }
2063 LISTBASE_FOREACH (bNodeSocket *, sock, &node->outputs) {
2065 }
2066 }
2067
2068 LISTBASE_FOREACH (bNodeSocket *, sock, &ntree->inputs_legacy) {
2070 }
2071 LISTBASE_FOREACH (bNodeSocket *, sock, &ntree->outputs_legacy) {
2073 }
2074
2076 }
2078 }
2079 }
2080
2081 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 259, 4)) {
2082 {
2083 /* Adaptive time step for particle systems */
2084 LISTBASE_FOREACH (ParticleSettings *, part, &bmain->particles) {
2085 part->courant_target = 0.2f;
2086 part->time_flag &= ~PART_TIME_AUTOSF;
2087 }
2088 }
2089 }
2090}
2091
2093{
2094 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 258, 0)) {
2095 /* Some very old (original comments claim pre-2.57) versioning that was wrongly done in
2096 * lib-linking code... Putting it here just to be sure (this is also checked at runtime anyway
2097 * by `action_idcode_patch_check`). */
2098 ID *id;
2099 FOREACH_MAIN_ID_BEGIN (bmain, id) {
2100 AnimData *adt = BKE_animdata_from_id(id);
2101 if (adt != nullptr) {
2102 /* Fix actions' id-roots (i.e. if they come from a pre 2.57 .blend file). */
2103 if ((adt->action) && (adt->action->idroot == 0)) {
2104 adt->action->idroot = GS(id->name);
2105 }
2106 if ((adt->tmpact) && (adt->tmpact->idroot == 0)) {
2107 adt->tmpact->idroot = GS(id->name);
2108 }
2109
2110 LISTBASE_FOREACH (NlaTrack *, nla_track, &adt->nla_tracks) {
2111 LISTBASE_FOREACH (NlaStrip *, nla_strip, &nla_track->strips) {
2112 if ((nla_strip->act) && (nla_strip->act->idroot == 0)) {
2113 nla_strip->act->idroot = GS(id->name);
2114 }
2115 }
2116 }
2117 }
2118 }
2120 }
2121}
AnimData * BKE_animdata_from_id(const ID *id)
Definition anim_data.cc:83
void animviz_settings_init(struct bAnimVizSettings *avs)
void mat3_to_vec_roll(const float mat[3][3], float r_vec[3], float *r_roll)
void BKE_scopes_new(Scopes *scopes)
CustomData interface, see also DNA_customdata_types.h.
void * CustomData_get_layer_for_write(CustomData *data, eCustomDataType type, int totelem)
bool CustomData_free_layer_active(CustomData *data, eCustomDataType type)
@ G_DEBUG
IDNewNameResult BKE_id_new_name_validate(Main &bmain, ListBase &lb, ID &id, const char *newname, IDNewNameMode mode, bool do_linked_data)
Definition lib_id.cc:1903
void BKE_lib_libblock_session_uid_ensure(ID *id)
Definition lib_id.cc:1477
#define FOREACH_MAIN_ID_END
Definition BKE_main.hh:583
#define MAIN_VERSION_FILE_ATLEAST(main, ver, subver)
Definition BKE_main.hh:658
#define FOREACH_MAIN_ID_BEGIN(_bmain, _id)
Definition BKE_main.hh:577
ModifierData * BKE_modifiers_findby_type(const Object *ob, ModifierType type)
void BKE_modifier_mdef_compact_influences(ModifierData *md)
ModifierData * BKE_modifier_new(int type)
#define FOREACH_NODETREE_END
Definition BKE_node.hh:881
#define FOREACH_NODETREE_BEGIN(bmain, _nodetree, _id)
Definition BKE_node.hh:871
#define CMP_NODE_COLORBALANCE
#define TEX_NODE_OUTPUT
#define CMP_NODE_BLUR
void BKE_ntree_update_tag_all(bNodeTree *ntree)
void BKE_ntree_update_tag_link_added(bNodeTree *ntree, bNodeLink *link)
void BKE_ptcache_ids_from_object(struct ListBase *lb, struct Object *ob, struct Scene *scene, int duplis)
ARegion * BKE_area_region_new()
Definition screen.cc:387
SpaceType * BKE_spacetype_from_id(int spaceid)
Definition screen.cc:257
void BKE_area_region_free(SpaceType *st, ARegion *region)
Definition screen.cc:597
void BKE_screen_view3d_do_versions_250(View3D *v3d, ListBase *regions)
Definition screen.cc:1329
void BKE_texture_mtex_default(struct MTex *mtex)
Definition texture.cc:381
#define LISTBASE_FOREACH(type, var, list)
BLI_INLINE bool BLI_listbase_is_empty(const ListBase *lb)
void BLI_freelinkN(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:270
void void BLI_freelistN(ListBase *listbase) ATTR_NONNULL(1)
Definition listbase.cc:497
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:111
void BLI_insertlinkbefore(ListBase *listbase, void *vnextlink, void *vnewlink) ATTR_NONNULL(1)
Definition listbase.cc:371
void srgb_to_linearrgb_v3_v3(float linear[3], const float srgb[3])
#define M_PI
void copy_m3_m4(float m1[3][3], const float m2[4][4])
void unit_qt(float q[4])
void unit_axis_angle(float axis[3], float *angle)
MINLINE void copy_v4_v4(float r[4], const float a[4])
MINLINE bool is_zero_v4(const float v[4]) ATTR_WARN_UNUSED_RESULT
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE bool is_zero_v3(const float v[3]) ATTR_WARN_UNUSED_RESULT
#define SNPRINTF(dst, format,...)
Definition BLI_string.h:604
#define STRNCPY_UTF8(dst, src)
unsigned int uint
#define ARRAY_SIZE(arr)
#define ELEM(...)
#define IS_EQF(a, b)
Compatibility-like things for windows.
external readfile function prototypes.
@ ID_TAG_TEMP_MAIN
Definition DNA_ID.h:971
#define ID_IS_LINKED(_id)
Definition DNA_ID.h:694
@ ID_FLAG_FAKEUSER
Definition DNA_ID.h:769
@ ID_GD_LEGACY
@ MOTIONPATH_BAKE_HEADS
@ MOTIONPATH_TYPE_ACFRA
@ MOTIONPATH_VIEW_KFNOS
@ MOTIONPATH_VIEW_FNUMS
@ MOTIONPATH_VIEW_KFRAS
@ ROT_MODE_EUL
@ SACTCONT_SHAPEKEY
@ BRUSH_SPACE_ATTEN
@ CAM_PANORAMA
@ CURVE_PRESET_SMOOTH
@ CONSTRAINT_TYPE_ROTLIMIT
@ CONSTRAINT_TYPE_KINEMATIC
@ CU_TYPE
@ HD_AUTO_ANIM
@ HD_AUTO
@ FLUID_FLOW_INITVELOCITY
@ MOD_FLUID_TYPE_DOMAIN
@ MOD_FLUID_TYPE_FLOW
@ eModifierType_MeshDeform
@ eModifierType_Solidify
@ eModifierType_Fluidsim
@ eModifierType_Curve
@ eModifierType_Lattice
@ eModifierType_Cloth
@ eModifierType_Fluid
@ eModifierType_Ocean
@ eModifierType_Armature
@ eModifierType_Multires
@ SOCK_OUT
@ SOCK_IN
@ SOCK_HIDDEN
@ SOCK_UNAVAIL
@ SOCK_VECTOR
@ SOCK_FLOAT
@ SOCK_RGBA
#define OB_MODE_ALL_PAINT
@ OB_TEXTURE
@ OB_SOLID
@ OB_MATERIAL
@ OB_MODE_POSE
@ OB_FLUIDSIM_OVERRIDE_TIME
@ PFIELD_DO_LOCATION
@ PFIELD_SHAPE_PLANE
@ PFIELD_SHAPE_SURFACE
Object is a sort of wrapper for general info.
@ PARSKEL
@ PAROBJECT
@ OB_LATTICE
@ OB_CAMERA
@ OB_ARMATURE
@ OB_CURVES_LEGACY
@ PART_HAIR_REGROW
@ PART_TIME_AUTOSF
@ PART_DRAW_MAT_COL
@ PART_DRAW_COL_MAT
@ PART_DRAW_AXIS
@ PART_DRAW_REND
@ PART_DRAW_HALO
@ PART_DRAW_DOT
@ PTCACHE_DISK_CACHE
@ UV_SELECT_VERT
#define MAXFRAMEF
@ R_COLOR_MANAGEMENT
@ PHYS_GLOBAL_GRAVITY
@ SCE_SELECT_PATH
@ SCE_SELECT_VERTEX
@ RGN_ALIGN_BOTTOM
@ RGN_ALIGN_LEFT
@ RGN_ALIGN_TOP
@ RGN_ALIGN_RIGHT
@ RGN_SPLIT_PREV
@ RGN_TYPE_CHANNELS
@ RGN_TYPE_UI
@ RGN_TYPE_WINDOW
@ RGN_TYPE_PREVIEW
@ RGN_TYPE_HEADER
@ RGN_TYPE_TOOLS
@ RGN_TYPE_TOOL_PROPS
@ RGN_FLAG_HIDDEN
@ TIME_ALL_3D_WIN
@ TIME_ALL_ANIM_WIN
@ SPACE_TEXT
@ SPACE_ACTION
@ SPACE_OUTLINER
@ SPACE_NODE
@ SPACE_FILE
@ SPACE_PROPERTIES
@ SPACE_NLA
@ SPACE_SEQ
@ SPACE_EMPTY
@ SPACE_IMAGE
@ SPACE_GRAPH
@ SPACE_VIEW3D
@ SPACE_INFO
@ SEQ_VIEW_SEQUENCE
@ INFO_RPT_OP
@ ST_FIND_WRAP
@ SEQ_DRAW_IMG_IMBUF
@ V2D_LOCKOFS_X
@ V2D_LOCKOFS_Y
@ V2D_PIXELOFS_X
@ V2D_IS_INIT
@ V2D_PIXELOFS_Y
@ V2D_VIEWSYNC_AREA_VERTICAL
@ V2D_KEEPTOT_BOUNDS
@ V2D_KEEPTOT_FREE
@ V2D_KEEPTOT_STRICT
@ V2D_LIMITZOOM
@ V2D_LOCKZOOM_X
@ V2D_KEEPZOOM
@ V2D_KEEPASPECT
@ V2D_LOCKZOOM_Y
@ V2D_SCROLL_LEFT
@ V2D_SCROLL_VERTICAL_HANDLES
@ V2D_SCROLL_RIGHT
@ V2D_SCROLL_BOTTOM
@ V2D_SCROLL_HORIZONTAL_HANDLES
@ V2D_ALIGN_NO_NEG_X
@ V2D_ALIGN_NO_NEG_Y
@ V2D_ALIGN_NO_POS_Y
@ V2D_ALIGN_FREE
@ V3D_HIDE_OVERLAYS
Read Guarded memory(de)allocation.
@ PROP_NONE
Definition RNA_types.hh:233
#define U
BMesh const char void * data
nullptr float
#define GS(x)
static float verts[][3]
#define main()
#define printf(...)
void * MEM_calloc_arrayN(size_t len, size_t size, const char *str)
Definition mallocn.cc:123
void * MEM_callocN(size_t len, const char *str)
Definition mallocn.cc:118
#define G(x, y, z)
int node_count_socket_links(const bNodeTree &ntree, const bNodeSocket &sock)
Definition node.cc:4674
void node_unique_name(bNodeTree &ntree, bNode &node)
Definition node.cc:3453
void foreach_strip(ListBase *seqbase, ForEachFunc callback, void *user_data)
Definition iterator.cc:59
const char * name
void * blo_do_versions_newlibadr(FileData *fd, ID *self_id, const bool is_linked_only, const void *adr)
Definition readfile.cc:1523
void blo_do_version_old_trackto_to_constraints(Object *ob)
#define FLT_MAX
Definition stdcycles.h:14
bAction * action
bAction * tmpact
ListBase nla_tracks
float vec[4]
float vec[3][3]
float arm_mat[4][4]
ListBase childbase
struct ClothSimSettings * sim_parms
struct EffectorWeights * effector_weights
CBData data[32]
struct Object * object
struct FluidDomainSettings * domain
struct FluidFlowSettings * flow
struct FluidsimSettings * fss
struct FluidsimModifierData * fmd
Definition DNA_ID.h:414
int tag
Definition DNA_ID.h:442
struct Library * lib
Definition DNA_ID.h:420
char name[258]
Definition DNA_ID.h:432
void * next
Definition DNA_ID.h:417
void * data
KeyBlock * refkey
void * first
ListBase brushes
Definition BKE_main.hh:302
ListBase scenes
Definition BKE_main.hh:278
short subversionfile
Definition BKE_main.hh:182
ListBase textures
Definition BKE_main.hh:285
ListBase actions
Definition BKE_main.hh:300
ListBase meshes
Definition BKE_main.hh:281
ListBase nodetrees
Definition BKE_main.hh:301
ListBase particles
Definition BKE_main.hh:303
ListBase materials
Definition BKE_main.hh:284
ListBase lattices
Definition BKE_main.hh:287
ListBase sounds
Definition BKE_main.hh:297
ListBase shapekeys
Definition BKE_main.hh:290
ListBase armatures
Definition BKE_main.hh:299
ListBase curves
Definition BKE_main.hh:282
ListBase screens
Definition BKE_main.hh:292
short versionfile
Definition BKE_main.hh:181
ListBase objects
Definition BKE_main.hh:280
ListBase strips
struct Object * parent
struct OceanCache * oceancache
ParticleBrushData brush[7]
struct RenderData r
ListBase spacedata
struct ScrArea * next
struct Scopes scopes
struct Histogram sample_line_hist
struct bGPdata * gpd
struct bGPdata * gpd
struct bGPdata * gpd
StripProxy * proxy
char dirpath[768]
StripData * data
struct ColorBand * coba
float minzoom
short keeptot
float max[2]
short keepzoom
short keepofs
float min[2]
float maxzoom
struct bNodeLink * link
struct bNodeSocket * next
struct bNodeSocket * prev
void * default_value
bNodeTreeInterface tree_interface
ListBase nodes
int16_t type_legacy
struct bNode * next
void * storage
ListBase areabase
float xmax
float xmin
float ymax
float ymin
i
Definition text_draw.cc:230
#define SEP_STR
Definition unit.cc:39
static void versions_gpencil_add_main(Main *bmain, ListBase *lb, ID *id, const char *name)
static void do_versions_windowmanager_2_50(bScreen *screen)
#define STRIP_USE_PROXY_CUSTOM_DIR
static bool strip_sound_proxy_update_cb(Strip *strip, void *)
void do_versions_after_linking_250(Main *bmain)
static bool strip_set_pitch_cb(Strip *strip, void *)
static bNodeSocket * do_versions_node_group_add_socket_2_56_2(bNodeTree *ngroup, const char *name, int type, int in_out)
static void do_versions_gpencil_2_50(Main *main, bScreen *screen)
#define STRIP_USE_PROXY_CUSTOM_FILE
static void do_version_constraints_radians_degrees_250(ListBase *lb)
static void area_add_window_regions(ScrArea *area, SpaceLink *sl, ListBase *lb)
static void do_version_bone_roll_256(Bone *bone)
static void do_version_mdef_250(Main *main)
void blo_do_versions_250(FileData *fd, Library *, Main *bmain)
static void do_versions_socket_default_value_259(bNodeSocket *sock)
static bool strip_set_volume_cb(Strip *strip, void *)
static void area_add_header_region(ScrArea *area, ListBase *lb)
void sequencer_init_preview_region(ARegion *region)
static bool strip_set_sat_cb(Strip *strip, void *)