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