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