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