Blender V5.3
versioning_290.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/* allow readfile to use deprecated functionality */
9#define DNA_DEPRECATED_ALLOW
10
11#include <algorithm>
12
13#include "BLI_listbase.hh"
14#include "BLI_math_matrix_c.hh"
16#include "BLI_math_vector_c.hh"
17#include "BLI_string.hh"
18#include "BLI_string_utf8.hh"
19#include "BLI_utildefines.hh"
20
21/* Define macros in `DNA_genfile.h`. */
22#define DNA_GENFILE_VERSIONING_MACROS
23
24#include "DNA_anim_types.h"
25#include "DNA_armature_types.h"
26#include "DNA_brush_types.h"
27#include "DNA_cachefile_types.h"
30#include "DNA_fluid_types.h"
31#include "DNA_genfile.h"
34#include "DNA_light_types.h"
35#include "DNA_mesh_types.h"
36#include "DNA_meshdata_types.h"
37#include "DNA_modifier_types.h"
38#include "DNA_object_types.h"
39#include "DNA_particle_types.h"
41#include "DNA_rigidbody_types.h"
42#include "DNA_screen_types.h"
43#include "DNA_sequence_types.h"
44#include "DNA_shader_fx_types.h"
45#include "DNA_space_types.h"
46#include "DNA_text_types.h"
47#include "DNA_tracking_types.h"
48#include "DNA_userdef_types.h"
50#include "DNA_workspace_types.h"
51
52#undef DNA_GENFILE_VERSIONING_MACROS
53
54#include "BKE_annotations.h"
55#include "BKE_armature.hh"
56#include "BKE_collection.hh"
57#include "BKE_colortools.hh"
58#include "BKE_cryptomatte.h"
59#include "BKE_curve.hh"
60#include "BKE_customdata.hh"
61#include "BKE_fcurve.hh"
62#include "BKE_lib_id.hh"
63#include "BKE_main.hh"
64#include "BKE_mesh.hh"
66#include "BKE_multires.hh"
67#include "BKE_node.hh"
69#include "BKE_report.hh"
70
71#include "IMB_imbuf_enums.h"
72#include "MEM_guardedalloc.h"
73
74#include "SEQ_proxy.hh"
75#include "SEQ_sequencer.hh"
76
77#include "BLO_read_write.hh"
78#include "BLO_readfile.hh"
79#include "readfile.hh"
80#include "versioning_common.hh"
81
82#include "BLT_translation.hh"
83
84#include <fmt/format.h>
85
86namespace blender {
87
88/* Make preferences read-only, use `versioning_userdef.cc`. */
89#define U (*((const UserDef *)&U))
90
92{
94
95 for (bScreen &screen : bmain->screens) {
96 for (ScrArea &area : screen.areabase) {
97 for (SpaceLink &sl : area.spacedata) {
98 switch (sl.spacetype) {
99 case SPACE_SEQ: {
100 SpaceSeq *sseq = reinterpret_cast<SpaceSeq *>(&sl);
101 if (sseq->mainb == SEQ_DRAW_IMG_IMBUF) {
102 render_size = eSpaceSeq_Proxy_RenderSize(sseq->render_size);
103 break;
104 }
105 }
106 }
107 }
108 }
109 }
110
111 return render_size;
112}
113
114static bool can_use_proxy(const Strip *strip, IMB_Proxy_Size psize)
115{
116 if (strip->data->proxy == nullptr) {
117 return false;
118 }
119 short size_flags = strip->data->proxy->build_size_flags;
120 return (strip->flag & SEQ_USE_PROXY) != 0 && psize != IMB_PROXY_NONE &&
121 (size_flags & psize) != 0;
122}
123
124/* image_size is width or height depending what RNA property is converted - X or Y. */
126 const Scene *scene,
127 const char *path,
128 const int image_size,
129 const int scene_size)
130{
131 if (scene->adt == nullptr || scene->adt->action == nullptr) {
132 return;
133 }
134
135 /* Hardcoded legacy bit-flags which has been removed. */
136 const eStripFlag use_transform_flag = eStripFlag(1 << 16);
137 const eStripFlag use_crop_flag = eStripFlag(1 << 17);
138
139 /* Convert offset animation, but only if crop is not used. */
140 if ((strip->flag & use_transform_flag) != 0 && (strip->flag & use_crop_flag) == 0) {
141 FCurve *fcu = BKE_fcurve_find(&scene->adt->action->curves, path, 0);
142 if (fcu != nullptr && !BKE_fcurve_is_empty(fcu)) {
143 BezTriple *bezt = fcu->bezt;
144 for (int i = 0; i < fcu->totvert; i++, bezt++) {
145 /* Same math as with old_image_center_*, but simplified. */
146 bezt->vec[0][1] = (image_size - scene_size) / 2 + bezt->vec[0][1];
147 bezt->vec[1][1] = (image_size - scene_size) / 2 + bezt->vec[1][1];
148 bezt->vec[2][1] = (image_size - scene_size) / 2 + bezt->vec[2][1];
149 }
150 }
151 }
152 else { /* Else, remove offset animation. */
153 FCurve *fcu = BKE_fcurve_find(&scene->adt->action->curves, path, 0);
154 BLI_remlink(&scene->adt->action->curves, fcu);
155 BKE_fcurve_free(fcu);
156 }
157}
158
159static void strip_convert_transform_crop(const Scene *scene,
160 Strip *strip,
161 const eSpaceSeq_Proxy_RenderSize render_size)
162{
163 if (strip->data->transform == nullptr) {
164 strip->data->transform = MEM_new<StripTransform>(__func__);
165 }
166 if (strip->data->crop == nullptr) {
167 strip->data->crop = MEM_new<StripCrop>(__func__);
168 }
169
170 StripCrop *c = strip->data->crop;
171 StripTransform *t = strip->data->transform;
172 int old_image_center_x = scene->r.xsch / 2;
173 int old_image_center_y = scene->r.ysch / 2;
174 int image_size_x = scene->r.xsch;
175 int image_size_y = scene->r.ysch;
176
177 /* Hard-coded legacy bit-flags which have been removed. */
178 const eStripFlag use_transform_flag = eStripFlag(1 << 16);
179 const eStripFlag use_crop_flag = eStripFlag(1 << 17);
180
181 const StripElem *s_elem = strip->data->stripdata;
182 if (s_elem != nullptr) {
183 image_size_x = s_elem->orig_width;
184 image_size_y = s_elem->orig_height;
185
186 if (can_use_proxy(strip, seq::rendersize_to_proxysize(render_size))) {
187 image_size_x /= seq::rendersize_to_scale_factor(render_size);
188 image_size_y /= seq::rendersize_to_scale_factor(render_size);
189 }
190 }
191
192 /* Default scale. */
193 if (t->scale_x == 0.0f && t->scale_y == 0.0f) {
194 t->scale_x = 1.0f;
195 t->scale_y = 1.0f;
196 }
197
198 /* Clear crop if it was unused. This must happen before converting values. */
199 if ((strip->flag & use_crop_flag) == 0) {
200 c->bottom = c->top = c->left = c->right = 0;
201 }
202
203 if ((strip->flag & use_transform_flag) == 0) {
204 t->xofs = t->yofs = 0;
205
206 /* Reverse scale to fit for strips not using offset. */
207 float project_aspect = float(scene->r.xsch) / float(scene->r.ysch);
208 float image_aspect = float(image_size_x) / float(image_size_y);
209 if (project_aspect > image_aspect) {
210 t->scale_x = project_aspect / image_aspect;
211 }
212 else {
213 t->scale_y = image_aspect / project_aspect;
214 }
215 }
216
217 if ((strip->flag & use_crop_flag) != 0 && (strip->flag & use_transform_flag) == 0) {
218 /* Calculate image offset. */
219 float s_x = scene->r.xsch / image_size_x;
220 float s_y = scene->r.ysch / image_size_y;
221 old_image_center_x += c->right * s_x - c->left * s_x;
222 old_image_center_y += c->top * s_y - c->bottom * s_y;
223
224 /* Convert crop to scale. */
225 int cropped_image_size_x = image_size_x - c->right - c->left;
226 int cropped_image_size_y = image_size_y - c->top - c->bottom;
227 c->bottom = c->top = c->left = c->right = 0;
228 t->scale_x *= float(image_size_x) / float(cropped_image_size_x);
229 t->scale_y *= float(image_size_y) / float(cropped_image_size_y);
230 }
231
232 if ((strip->flag & use_transform_flag) != 0) {
233 /* Convert image offset. */
234 old_image_center_x = image_size_x / 2 - c->left + t->xofs;
235 old_image_center_y = image_size_y / 2 - c->bottom + t->yofs;
236
237 /* Preserve original image size. */
238 t->scale_x = t->scale_y = std::max(float(image_size_x) / float(scene->r.xsch),
239 float(image_size_y) / float(scene->r.ysch));
240
241 /* Convert crop. */
242 if ((strip->flag & use_crop_flag) != 0) {
243 c->top /= t->scale_x;
244 c->bottom /= t->scale_x;
245 c->left /= t->scale_x;
246 c->right /= t->scale_x;
247 }
248 }
249
250 t->xofs = old_image_center_x - scene->r.xsch / 2;
251 t->yofs = old_image_center_y - scene->r.ysch / 2;
252
253 char name_esc[(sizeof(strip->name) - 2) * 2], *path;
254 BLI_str_escape(name_esc, strip->name + 2, sizeof(name_esc));
255
256 path = BLI_sprintfN("sequence_editor.sequences_all[\"%s\"].transform.offset_x", name_esc);
257 strip_convert_transform_animation(strip, scene, path, image_size_x, scene->r.xsch);
258 MEM_delete(path);
259 path = BLI_sprintfN("sequence_editor.sequences_all[\"%s\"].transform.offset_y", name_esc);
260 strip_convert_transform_animation(strip, scene, path, image_size_y, scene->r.ysch);
261 MEM_delete(path);
262
263 strip->flag &= ~use_transform_flag;
264 strip->flag &= ~use_crop_flag;
265}
266
267static void strip_convert_transform_crop_lb(const Scene *scene,
268 const ListBaseT<Strip> *lb,
269 const eSpaceSeq_Proxy_RenderSize render_size)
270{
271
272 for (Strip &strip : *lb) {
273 if (!ELEM(strip.type, STRIP_TYPE_SOUND, STRIP_TYPE_SOUND_HD)) {
274 strip_convert_transform_crop(scene, &strip, render_size);
275 }
276 if (strip.type == STRIP_TYPE_META) {
277 strip_convert_transform_crop_lb(scene, &strip.seqbase, render_size);
278 }
279 }
280}
281
283 const char *path,
284 const float scale_to_fit_factor)
285{
286 if (scene->adt == nullptr || scene->adt->action == nullptr) {
287 return;
288 }
289
290 FCurve *fcu = BKE_fcurve_find(&scene->adt->action->curves, path, 0);
291 if (fcu != nullptr && !BKE_fcurve_is_empty(fcu)) {
292 BezTriple *bezt = fcu->bezt;
293 for (int i = 0; i < fcu->totvert; i++, bezt++) {
294 /* Same math as with old_image_center_*, but simplified. */
295 bezt->vec[0][1] *= scale_to_fit_factor;
296 bezt->vec[1][1] *= scale_to_fit_factor;
297 bezt->vec[2][1] *= scale_to_fit_factor;
298 }
299 }
300}
301
302static void strip_convert_transform_crop_2(const Scene *scene,
303 Strip *strip,
304 const eSpaceSeq_Proxy_RenderSize render_size)
305{
306 const StripElem *s_elem = strip->data->stripdata;
307 if (s_elem == nullptr) {
308 return;
309 }
310
311 StripCrop *c = strip->data->crop;
312 StripTransform *t = strip->data->transform;
313 int image_size_x = s_elem->orig_width;
314 int image_size_y = s_elem->orig_height;
315
316 if (can_use_proxy(strip, seq::rendersize_to_proxysize(render_size))) {
317 image_size_x /= seq::rendersize_to_scale_factor(render_size);
318 image_size_y /= seq::rendersize_to_scale_factor(render_size);
319 }
320
321 /* Calculate scale factor, so image fits in preview area with original aspect ratio. */
322 const float scale_to_fit_factor = std::min(float(scene->r.xsch) / float(image_size_x),
323 float(scene->r.ysch) / float(image_size_y));
324 t->scale_x *= scale_to_fit_factor;
325 t->scale_y *= scale_to_fit_factor;
326 c->top /= scale_to_fit_factor;
327 c->bottom /= scale_to_fit_factor;
328 c->left /= scale_to_fit_factor;
329 c->right /= scale_to_fit_factor;
330
331 char name_esc[(sizeof(strip->name) - 2) * 2], *path;
332 BLI_str_escape(name_esc, strip->name + 2, sizeof(name_esc));
333 path = BLI_sprintfN("sequence_editor.sequences_all[\"%s\"].transform.scale_x", name_esc);
334 strip_convert_transform_animation_2(scene, path, scale_to_fit_factor);
335 MEM_delete(path);
336 path = BLI_sprintfN("sequence_editor.sequences_all[\"%s\"].transform.scale_y", name_esc);
337 strip_convert_transform_animation_2(scene, path, scale_to_fit_factor);
338 MEM_delete(path);
339 path = BLI_sprintfN("sequence_editor.sequences_all[\"%s\"].crop.min_x", name_esc);
340 strip_convert_transform_animation_2(scene, path, 1 / scale_to_fit_factor);
341 MEM_delete(path);
342 path = BLI_sprintfN("sequence_editor.sequences_all[\"%s\"].crop.max_x", name_esc);
343 strip_convert_transform_animation_2(scene, path, 1 / scale_to_fit_factor);
344 MEM_delete(path);
345 path = BLI_sprintfN("sequence_editor.sequences_all[\"%s\"].crop.min_y", name_esc);
346 strip_convert_transform_animation_2(scene, path, 1 / scale_to_fit_factor);
347 MEM_delete(path);
348 path = BLI_sprintfN("sequence_editor.sequences_all[\"%s\"].crop.max_x", name_esc);
349 strip_convert_transform_animation_2(scene, path, 1 / scale_to_fit_factor);
350 MEM_delete(path);
351}
352
354 const ListBaseT<Strip> *lb,
355 const eSpaceSeq_Proxy_RenderSize render_size)
356{
357
358 for (Strip &strip : *lb) {
359 if (!ELEM(strip.type, STRIP_TYPE_SOUND, STRIP_TYPE_SOUND_HD)) {
360 strip_convert_transform_crop_2(scene, &strip, render_size);
361 }
362 if (strip.type == STRIP_TYPE_META) {
363 strip_convert_transform_crop_lb_2(scene, &strip.seqbase, render_size);
364 }
365 }
366}
367
369{
370 Editing *ed = seq::editing_get(scene);
371
372 if (ed == nullptr) {
373 return;
374 }
375
376 for (MetaStack &ms : ed->metastack.items_reversed()) {
377 /* Update ms->disp_range from meta. */
378 if (ms.disp_range[0] == ms.disp_range[1]) {
379 ms.disp_range[0] = ms.parent_strip->left_handle();
380 ms.disp_range[1] = ms.parent_strip->right_handle(scene);
381 }
382
383 /* Update meta strip endpoints. */
384 ms.parent_strip->left_handle_set(scene, ms.disp_range[0]);
385 ms.parent_strip->right_handle_set(scene, ms.disp_range[1]);
386
387 /* Recalculate effects using meta strip. */
388 ListBaseT<Strip> *old_seqbasep = ms.old_strip ? &ms.old_strip->seqbase : &ed->seqbase;
389 for (Strip &strip : *old_seqbasep) {
390 if (strip.input2) {
391 strip.start = strip.startdisp = max_ii(strip.input1->startdisp, strip.input2->startdisp);
392 strip.enddisp = min_ii(strip.input1->enddisp, strip.input2->enddisp);
393 }
394 }
395
397 active_ms->old_strip = ms.parent_strip;
398 }
399}
400
402 const int node_type,
403 const char *old_name,
404 const char *new_name)
405{
406 /* Duplicate a link going into the original socket. */
407 for (bNodeLink &link : ntree->links.items_mutable()) {
408 if (link.tonode->type_legacy == node_type) {
409 bNode *node = link.tonode;
410 bNodeSocket *dest_socket = bke::node_find_socket(*node, SOCK_IN, UString(new_name));
411 BLI_assert(dest_socket);
412 if (STREQ(link.tosock->name, old_name)) {
413 bke::node_add_link(*ntree, *link.fromnode, *link.fromsock, *node, *dest_socket);
414 }
415 }
416 }
417
418 /* Duplicate the default value from the old socket and assign it to the new socket. */
419 for (bNode &node : ntree->nodes) {
420 if (node.type_legacy == node_type) {
421 bNodeSocket *source_socket = bke::node_find_socket(node, SOCK_IN, UString(old_name));
422 bNodeSocket *dest_socket = bke::node_find_socket(node, SOCK_IN, UString(new_name));
423 BLI_assert(source_socket && dest_socket);
424 if (dest_socket->default_value) {
425 MEM_delete_void(dest_socket->default_value);
426 }
427 dest_socket->default_value = MEM_dupalloc_void(source_socket->default_value);
428 }
429 }
430}
431
433{
434 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 290, 1)) {
435 /* Patch old grease pencil modifiers material filter. */
436 for (Object &ob : bmain->objects) {
438 switch (md.type) {
440 ArrayGpencilModifierData *gpmd = reinterpret_cast<ArrayGpencilModifierData *>(&md);
441 if (gpmd->materialname[0] != '\0') {
442 gpmd->material = static_cast<Material *>(
443 BLI_findstring(&bmain->materials, gpmd->materialname, offsetof(ID, name) + 2));
444 gpmd->materialname[0] = '\0';
445 }
446 break;
447 }
449 ColorGpencilModifierData *gpmd = reinterpret_cast<ColorGpencilModifierData *>(&md);
450 if (gpmd->materialname[0] != '\0') {
451 gpmd->material = static_cast<Material *>(
452 BLI_findstring(&bmain->materials, gpmd->materialname, offsetof(ID, name) + 2));
453 gpmd->materialname[0] = '\0';
454 }
455 break;
456 }
458 HookGpencilModifierData *gpmd = reinterpret_cast<HookGpencilModifierData *>(&md);
459 if (gpmd->materialname[0] != '\0') {
460 gpmd->material = static_cast<Material *>(
461 BLI_findstring(&bmain->materials, gpmd->materialname, offsetof(ID, name) + 2));
462 gpmd->materialname[0] = '\0';
463 }
464 break;
465 }
467 LatticeGpencilModifierData *gpmd = reinterpret_cast<LatticeGpencilModifierData *>(&md);
468 if (gpmd->materialname[0] != '\0') {
469 gpmd->material = static_cast<Material *>(
470 BLI_findstring(&bmain->materials, gpmd->materialname, offsetof(ID, name) + 2));
471 gpmd->materialname[0] = '\0';
472 }
473 break;
474 }
476 MirrorGpencilModifierData *gpmd = reinterpret_cast<MirrorGpencilModifierData *>(&md);
477 if (gpmd->materialname[0] != '\0') {
478 gpmd->material = static_cast<Material *>(
479 BLI_findstring(&bmain->materials, gpmd->materialname, offsetof(ID, name) + 2));
480 gpmd->materialname[0] = '\0';
481 }
482 break;
483 }
486 &md);
487 if (gpmd->materialname[0] != '\0') {
488 gpmd->material = static_cast<Material *>(
489 BLI_findstring(&bmain->materials, gpmd->materialname, offsetof(ID, name) + 2));
490 gpmd->materialname[0] = '\0';
491 }
492 break;
493 }
495 NoiseGpencilModifierData *gpmd = reinterpret_cast<NoiseGpencilModifierData *>(&md);
496 if (gpmd->materialname[0] != '\0') {
497 gpmd->material = static_cast<Material *>(
498 BLI_findstring(&bmain->materials, gpmd->materialname, offsetof(ID, name) + 2));
499 gpmd->materialname[0] = '\0';
500 }
501 break;
502 }
504 OffsetGpencilModifierData *gpmd = reinterpret_cast<OffsetGpencilModifierData *>(&md);
505 if (gpmd->materialname[0] != '\0') {
506 gpmd->material = static_cast<Material *>(
507 BLI_findstring(&bmain->materials, gpmd->materialname, offsetof(ID, name) + 2));
508 gpmd->materialname[0] = '\0';
509 }
510 break;
511 }
513 OpacityGpencilModifierData *gpmd = reinterpret_cast<OpacityGpencilModifierData *>(&md);
514 if (gpmd->materialname[0] != '\0') {
515 gpmd->material = static_cast<Material *>(
516 BLI_findstring(&bmain->materials, gpmd->materialname, offsetof(ID, name) + 2));
517 gpmd->materialname[0] = '\0';
518 }
519 break;
520 }
523 &md);
524 if (gpmd->materialname[0] != '\0') {
525 gpmd->material = static_cast<Material *>(
526 BLI_findstring(&bmain->materials, gpmd->materialname, offsetof(ID, name) + 2));
527 gpmd->materialname[0] = '\0';
528 }
529 break;
530 }
532 SmoothGpencilModifierData *gpmd = reinterpret_cast<SmoothGpencilModifierData *>(&md);
533 if (gpmd->materialname[0] != '\0') {
534 gpmd->material = static_cast<Material *>(
535 BLI_findstring(&bmain->materials, gpmd->materialname, offsetof(ID, name) + 2));
536 gpmd->materialname[0] = '\0';
537 }
538 break;
539 }
541 SubdivGpencilModifierData *gpmd = reinterpret_cast<SubdivGpencilModifierData *>(&md);
542 if (gpmd->materialname[0] != '\0') {
543 gpmd->material = static_cast<Material *>(
544 BLI_findstring(&bmain->materials, gpmd->materialname, offsetof(ID, name) + 2));
545 gpmd->materialname[0] = '\0';
546 }
547 break;
548 }
550 TextureGpencilModifierData *gpmd = reinterpret_cast<TextureGpencilModifierData *>(&md);
551 if (gpmd->materialname[0] != '\0') {
552 gpmd->material = static_cast<Material *>(
553 BLI_findstring(&bmain->materials, gpmd->materialname, offsetof(ID, name) + 2));
554 gpmd->materialname[0] = '\0';
555 }
556 break;
557 }
559 ThickGpencilModifierData *gpmd = reinterpret_cast<ThickGpencilModifierData *>(&md);
560 if (gpmd->materialname[0] != '\0') {
561 gpmd->material = static_cast<Material *>(
562 BLI_findstring(&bmain->materials, gpmd->materialname, offsetof(ID, name) + 2));
563 gpmd->materialname[0] = '\0';
564 }
565 break;
566 }
567 default:
568 break;
569 }
570 }
571 }
572
573 /* Patch first frame for old files. */
574 Scene *scene = bmain->scenes.first();
575 if (scene != nullptr) {
576 for (Object &ob : bmain->objects) {
577 if (ob.type != OB_GPENCIL_LEGACY) {
578 continue;
579 }
580 bGPdata *gpd = id_cast<bGPdata *>(ob.data);
581 for (bGPDlayer &gpl : gpd->layers) {
582 bGPDframe *gpf = gpl.frames.first();
583 if (gpf && gpf->framenum > scene->r.sfra) {
584 bGPDframe *gpf_dup = BKE_annotations_frame_duplicate(gpf, true);
585 gpf_dup->framenum = scene->r.sfra;
586 BLI_addhead(&gpl.frames, gpf_dup);
587 }
588 }
589 }
590 }
591 }
592
593 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 291, 1)) {
594 for (Collection &collection : bmain->collections) {
595 if (BKE_collection_cycles_fix(bmain, &collection)) {
596 printf(
597 "WARNING: Cycle detected in collection '%s', fixed as best as possible.\n"
598 "You may have to reconstruct your View Layers...\n",
599 collection.id.name);
600 }
601 }
602 }
603
604 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 291, 8)) {
609
618 }
619
620 /* Convert all Multires displacement to Catmull-Clark subdivision limit surface. */
621 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 292, 1)) {
622 for (Object &ob : bmain->objects) {
623 for (ModifierData &md : ob.modifiers) {
624 if (md.type == eModifierType_Multires) {
625 MultiresModifierData *mmd = reinterpret_cast<MultiresModifierData *>(&md);
626 if (mmd->simple) {
628 }
629 }
630 }
631 }
632 }
633
634 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 292, 2)) {
635
637
638 for (Scene &scene : bmain->scenes) {
639 if (scene.ed != nullptr) {
640 strip_convert_transform_crop_lb(&scene, &scene.ed->seqbase, render_size);
641 }
642 }
643 }
644
645 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 292, 8)) {
646 /* Systematically rebuild pose-bones to ensure consistent ordering matching the one of bones in
647 * Armature obdata. */
648 for (Object &ob : bmain->objects) {
649 if (ob.type == OB_ARMATURE) {
650 BKE_pose_rebuild(bmain, &ob, id_cast<bArmature *>(ob.data), true);
651 }
652 }
653
654 /* Wet Paint Radius Factor */
655 for (Brush &br : bmain->brushes) {
656 if (br.ob_mode & OB_MODE_SCULPT && br.wet_paint_radius_factor == 0.0f) {
657 br.wet_paint_radius_factor = 1.0f;
658 }
659 }
660
662 for (Scene &scene : bmain->scenes) {
663 if (scene.ed != nullptr) {
664 strip_convert_transform_crop_lb_2(&scene, &scene.ed->seqbase, render_size);
665 }
666 }
667 }
668
669 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 293, 16)) {
670 for (Scene &scene : bmain->scenes) {
672 }
673
674 /* Add a separate socket for Grid node X and Y size. */
675 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
676 if (ntree->type == NTREE_GEOMETRY) {
678 }
680 }
681 }
682
683 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 293, 20)) {
684 /* Set zero user text objects to have a fake user. */
685 for (Text &text : bmain->texts) {
686 if (text.id.us == 0) {
687 id_fake_user_set(&text.id);
688 }
689 }
690 }
691
698}
699
701{
702 const bool was_closed_x = panel->flag & PNL_UNUSED_1;
703 const bool was_closed_y = panel->flag & PNL_CLOSED; /* That value was the Y closed flag. */
704
705 SET_FLAG_FROM_TEST(panel->flag, was_closed_x || was_closed_y, PNL_CLOSED);
706
707 /* Clear the old PNL_CLOSEDX flag. */
708 panel->flag &= ~PNL_UNUSED_1;
709
710 for (Panel &child_panel : panel->children) {
712 }
713}
714
716{
717 /* Change to generic named float/float3 attributes. */
718 constexpr eCustomDataType CD_LOCATION = eCustomDataType(43);
719 constexpr eCustomDataType CD_RADIUS = eCustomDataType(44);
720
721 for (int i = 0; i < pdata->totlayer; i++) {
722 CustomDataLayer *layer = &pdata->layers[i];
723 if (layer->type == CD_LOCATION) {
724 STRNCPY_UTF8(layer->name, "Position");
725 layer->type = CD_PROP_FLOAT3;
726 }
727 else if (layer->type == CD_RADIUS) {
728 STRNCPY_UTF8(layer->name, "Radius");
729 layer->type = CD_PROP_FLOAT;
730 }
731 }
732}
733
735{
736 /* Change from capital initial letter to lower case (#82693). */
737 for (int i = 0; i < pdata->totlayer; i++) {
738 CustomDataLayer *layer = &pdata->layers[i];
739 if (layer->type == CD_PROP_FLOAT3 && STREQ(layer->name, "Position")) {
740 STRNCPY_UTF8(layer->name, "position");
741 }
742 else if (layer->type == CD_PROP_FLOAT && STREQ(layer->name, "Radius")) {
743 STRNCPY_UTF8(layer->name, "radius");
744 }
745 }
746}
747
748/* Move FCurve handles towards the control point in such a way that the curve itself doesn't
749 * change. Since 2.91 FCurves are computed slightly differently, which requires this update to keep
750 * the same animation result. Previous versions scaled down overlapping handles during evaluation.
751 * This function applies the old correction to the actual animation data instead. */
753{
754 uint i = 1;
755 for (BezTriple *bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) {
756 /* Only adjust bezier key-frames. */
757 if (bezt->ipo != BEZT_IPO_BEZ) {
758 continue;
759 }
760
761 BezTriple *nextbezt = bezt + 1;
762 const float v1[2] = {bezt->vec[1][0], bezt->vec[1][1]};
763 const float v2[2] = {bezt->vec[2][0], bezt->vec[2][1]};
764 const float v3[2] = {nextbezt->vec[0][0], nextbezt->vec[0][1]};
765 const float v4[2] = {nextbezt->vec[1][0], nextbezt->vec[1][1]};
766
767 /* If the handles have no length, no need to do any corrections. */
768 if (v1[0] == v2[0] && v3[0] == v4[0]) {
769 continue;
770 }
771
772 /* Calculate handle deltas. */
773 float delta1[2], delta2[2];
774 sub_v2_v2v2(delta1, v1, v2);
775 sub_v2_v2v2(delta2, v4, v3);
776
777 const float len1 = fabsf(delta1[0]); /* Length of handle of first key. */
778 const float len2 = fabsf(delta2[0]); /* Length of handle of second key. */
779
780 /* Overlapping handles used to be internally scaled down in previous versions.
781 * We bake the handles onto these previously virtual values. */
782 const float time_delta = v4[0] - v1[0];
783 const float total_len = len1 + len2;
784 if (total_len <= time_delta) {
785 continue;
786 }
787
788 const float factor = time_delta / total_len;
789 /* Current key-frame's right handle: */
790 madd_v2_v2v2fl(bezt->vec[2], v1, delta1, -factor); /* vec[2] = v1 - factor * delta1 */
791 /* Next key-frame's left handle: */
792 madd_v2_v2v2fl(nextbezt->vec[0], v4, delta2, -factor); /* vec[0] = v4 - factor * delta2 */
793 }
794}
795
797{
798 for (bNodeLink &link : ntree->links.items_mutable()) {
799 if (link.tonode->type_legacy == GEO_NODE_JOIN_GEOMETRY &&
800 !(link.tosock->flag & SOCK_MULTI_INPUT))
801 {
802 link.tosock = link.tonode->inputs.first();
803 }
804 }
805 for (bNode &node : ntree->nodes) {
806 if (node.type_legacy == GEO_NODE_JOIN_GEOMETRY) {
807 bNodeSocket *socket = node.inputs.first();
808 socket->flag |= SOCK_MULTI_INPUT;
809 socket->limit = 4095;
810 bke::node_remove_socket(*ntree, node, *socket->next);
811 }
812 }
813}
814
815/* NOLINTNEXTLINE: readability-function-size */
816void blo_do_versions_290(FileData *fd, Library * /*lib*/, Main *bmain)
817{
818 UNUSED_VARS(fd);
819
820 if (MAIN_VERSION_FILE_ATLEAST(bmain, 290, 2) && MAIN_VERSION_FILE_OLDER(bmain, 291, 1)) {
821 /* In this range, the extrude manifold could generate meshes with degenerated face. */
822 for (Mesh &me : bmain->meshes) {
823 const MPoly *polys = static_cast<const MPoly *>(
824 CustomData_get_layer(&me.face_data, CD_MPOLY));
825 for (const int i : IndexRange(me.faces_num)) {
826 if (polys[i].totloop == 2) {
827 std::string message = fmt::format(
828 fmt::runtime(RPT_("Mesh %s has invalid faces, likely caused by the manifold extrude "
829 "tool in version 2.90.0. Opening and saving the file in a version "
830 "prior to 5.1 should resolve the issue\n")),
831 me.id.name + 2);
832 BLO_read_invalidate_message(reinterpret_cast<BlendHandle *>(fd), bmain, message.c_str());
833 break;
834 }
835 }
836 }
837 }
838
840 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 290, 2)) {
841 {
842 short id_codes[] = {ID_BR, ID_PAL};
843 for (int i = 0; i < ARRAY_SIZE(id_codes); i++) {
844 ListBaseT<ID> *lb = which_libbase(bmain, id_codes[i]);
846 }
847 }
848
849 if (!DNA_struct_member_exists(fd->filesdna, "SpaceImage", "float", "uv_opacity")) {
850 for (bScreen &screen : bmain->screens) {
851 for (ScrArea &area : screen.areabase) {
852 for (SpaceLink &sl : area.spacedata) {
853 if (sl.spacetype == SPACE_IMAGE) {
854 SpaceImage *sima = reinterpret_cast<SpaceImage *>(&sl);
855 sima->uv_opacity = 1.0f;
856 }
857 }
858 }
859 }
860 }
861
862 /* Init Grease Pencil new random curves. */
863 if (!DNA_struct_member_exists(fd->filesdna, "BrushGpencilSettings", "float", "random_hue")) {
864 for (Brush &brush : bmain->brushes) {
865 if ((brush.gpencil_settings) && (brush.gpencil_settings->curve_rand_pressure == nullptr)) {
866 brush.gpencil_settings->curve_rand_pressure = BKE_curvemapping_add(
867 1, 0.0f, 0.0f, 1.0f, 1.0f);
868 brush.gpencil_settings->curve_rand_strength = BKE_curvemapping_add(
869 1, 0.0f, 0.0f, 1.0f, 1.0f);
870 brush.gpencil_settings->curve_rand_uv = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
871 brush.gpencil_settings->curve_rand_hue = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
872 brush.gpencil_settings->curve_rand_saturation = BKE_curvemapping_add(
873 1, 0.0f, 0.0f, 1.0f, 1.0f);
874 brush.gpencil_settings->curve_rand_value = BKE_curvemapping_add(
875 1, 0.0f, 0.0f, 1.0f, 1.0f);
876 }
877 }
878 }
879 }
880
881 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 290, 4)) {
882 /* Clear old deprecated bit-flag from edit weights modifiers, we now use it for something else.
883 */
884 for (Object &ob : bmain->objects) {
885 for (ModifierData &md : ob.modifiers) {
887 (reinterpret_cast<WeightVGEditModifierData *>(&md))->edit_flags &=
889 }
890 }
891 }
892
893 /* Initialize parameters of the new Nishita sky model. */
894 if (!DNA_struct_member_exists(fd->filesdna, "NodeTexSky", "float", "sun_size")) {
895 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
896 if (ntree->type == NTREE_SHADER) {
897 for (bNode &node : ntree->nodes) {
898 if (node.type_legacy == SH_NODE_TEX_SKY && node.storage) {
899 NodeTexSky *tex = static_cast<NodeTexSky *>(node.storage);
900 tex->sun_disc = true;
901 tex->sun_size = DEG2RADF(0.545);
902 tex->sun_elevation = M_PI_2;
903 tex->sun_rotation = 0.0f;
904 tex->altitude = 0.0f;
905 tex->air_density = 1.0f;
906 tex->aerosol_density = 1.0f;
907 tex->ozone_density = 1.0f;
908 }
909 }
910 }
911 }
913 }
914 }
915
916 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 290, 5)) {
917 /* New denoiser settings. */
918 for (Scene &scene : bmain->scenes) {
920
921 /* Check if any view layers had (optix) denoising enabled.
922 * Both view and render layers because conversion only happens after linking. */
923 bool use_optix = false;
924 bool use_denoising = false;
925 for (ViewLayer &view_layer : scene.view_layers) {
926 IDProperty *cview_layer = version_cycles_properties_from_view_layer(&view_layer);
927 if (cview_layer) {
928 use_denoising = use_denoising ||
929 version_cycles_property_boolean(cview_layer, "use_denoising", false);
930 use_optix = use_optix ||
931 version_cycles_property_boolean(cview_layer, "use_optix_denoising", false);
932 }
933 }
934 for (SceneRenderLayer &render_layer : scene.r.layers) {
935 IDProperty *crender_layer = version_cycles_properties_from_render_layer(&render_layer);
936 if (crender_layer) {
937 use_denoising = use_denoising ||
938 version_cycles_property_boolean(crender_layer, "use_denoising", false);
939 use_optix = use_optix ||
940 version_cycles_property_boolean(crender_layer, "use_optix_denoising", false);
941 }
942 }
943
944 if (cscene) {
945 enum {
946 DENOISER_AUTO = 0,
947 DENOISER_NLM = 1,
948 DENOISER_OPTIX = 2,
949 };
950
951 /* Enable denoiser if it was enabled for one view layer before. */
953 cscene, "denoiser", (use_optix) ? DENOISER_OPTIX : DENOISER_NLM);
954 version_cycles_property_boolean_set(cscene, "use_denoising", use_denoising);
955
956 /* Migrate Optix denoiser to new settings. */
957 if (version_cycles_property_int(cscene, "preview_denoising", 0)) {
958 version_cycles_property_boolean_set(cscene, "use_preview_denoising", true);
959 version_cycles_property_int_set(cscene, "preview_denoiser", DENOISER_AUTO);
960 }
961 }
962
963 /* Enable denoising in all view layer if there was no denoising before,
964 * so that enabling the scene settings auto enables it for all view layers. */
965 if (!use_denoising) {
966 for (ViewLayer &view_layer : scene.view_layers) {
967 IDProperty *cview_layer = version_cycles_properties_from_view_layer(&view_layer);
968 if (cview_layer) {
969 version_cycles_property_boolean_set(cview_layer, "use_denoising", true);
970 }
971 }
972 for (SceneRenderLayer &render_layer : scene.r.layers) {
973 IDProperty *crender_layer = version_cycles_properties_from_render_layer(&render_layer);
974 if (crender_layer) {
975 version_cycles_property_boolean_set(crender_layer, "use_denoising", true);
976 }
977 }
978 }
979 }
980 }
981
982 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 290, 6)) {
983 /* Transition to saving expansion for all of a modifier's sub-panels. */
984 if (!DNA_struct_member_exists(fd->filesdna, "ModifierData", "short", "ui_expand_flag")) {
985 for (Object &object : bmain->objects) {
986 for (ModifierData &md : object.modifiers) {
987 if (md.mode & eModifierMode_Expanded_DEPRECATED) {
988 md.ui_expand_flag = UI_PANEL_DATA_EXPAND_ROOT;
989 }
990 else {
991 md.ui_expand_flag = 0;
992 }
993 }
994 }
995 }
996
997 /* EEVEE Motion blur new parameters. */
998 if (!DNA_struct_member_exists(fd->filesdna, "SceneEEVEE", "float", "motion_blur_depth_scale"))
999 {
1000 for (Scene &scene : bmain->scenes) {
1001 scene.eevee.motion_blur_depth_scale = 100.0f;
1002 scene.eevee.motion_blur_max = 32;
1003 }
1004 }
1005
1006 if (!DNA_struct_member_exists(fd->filesdna, "SceneEEVEE", "int", "motion_blur_steps")) {
1007 for (Scene &scene : bmain->scenes) {
1008 scene.eevee.motion_blur_steps = 1;
1009 }
1010 }
1011
1012 /* Transition to saving expansion for all of a constraint's sub-panels. */
1013 if (!DNA_struct_member_exists(fd->filesdna, "bConstraint", "short", "ui_expand_flag")) {
1014 for (Object &object : bmain->objects) {
1015 for (bConstraint &con : object.constraints) {
1016 if (con.flag & CONSTRAINT_EXPAND_DEPRECATED) {
1017 con.ui_expand_flag = UI_PANEL_DATA_EXPAND_ROOT;
1018 }
1019 else {
1020 con.ui_expand_flag = 0;
1021 }
1022 }
1023 }
1024 }
1025
1026 /* Transition to saving expansion for all of grease pencil modifier's sub-panels. */
1027 if (!DNA_struct_member_exists(fd->filesdna, "GpencilModifierData", "short", "ui_expand_flag"))
1028 {
1029 for (Object &object : bmain->objects) {
1030 for (GpencilModifierData &md : object.greasepencil_modifiers) {
1031 if (md.mode & eGpencilModifierMode_Expanded_DEPRECATED) {
1032 md.ui_expand_flag = UI_PANEL_DATA_EXPAND_ROOT;
1033 }
1034 else {
1035 md.ui_expand_flag = 0;
1036 }
1037 }
1038 }
1039 }
1040
1041 /* Transition to saving expansion for all of an effect's sub-panels. */
1042 if (!DNA_struct_member_exists(fd->filesdna, "ShaderFxData", "short", "ui_expand_flag")) {
1043 for (Object &object : bmain->objects) {
1044 for (ShaderFxData &fx : object.shader_fx) {
1045 if (fx.mode & eShaderFxMode_Expanded_DEPRECATED) {
1046 fx.ui_expand_flag = UI_PANEL_DATA_EXPAND_ROOT;
1047 }
1048 else {
1049 fx.ui_expand_flag = 0;
1050 }
1051 }
1052 }
1053 }
1054
1055 /* Refactor bevel profile type to use an enum. */
1056 if (!DNA_struct_member_exists(fd->filesdna, "BevelModifierData", "short", "profile_type")) {
1057 for (Object &object : bmain->objects) {
1058 for (ModifierData &md : object.modifiers) {
1059 if (md.type == eModifierType_Bevel) {
1060 BevelModifierData *bmd = reinterpret_cast<BevelModifierData *>(&md);
1061 bool use_custom_profile = bmd->flags & MOD_BEVEL_CUSTOM_PROFILE_DEPRECATED;
1062 bmd->profile_type = use_custom_profile ? MOD_BEVEL_PROFILE_CUSTOM :
1064 }
1065 }
1066 }
1067 }
1068
1069 /* Change ocean modifier values from [0, 10] to [0, 1] ranges. */
1070 for (Object &object : bmain->objects) {
1071 for (ModifierData &md : object.modifiers) {
1072 if (md.type == eModifierType_Ocean) {
1073 OceanModifierData *omd = reinterpret_cast<OceanModifierData *>(&md);
1074 omd->wave_alignment *= 0.1f;
1075 omd->sharpen_peak_jonswap *= 0.1f;
1076 }
1077 }
1078 }
1079 }
1080
1081 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 291, 1)) {
1082
1083 /* Initialize additional parameter of the Nishita sky model and change altitude unit. */
1084 if (!DNA_struct_member_exists(fd->filesdna, "NodeTexSky", "float", "sun_intensity")) {
1085 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
1086 if (ntree->type == NTREE_SHADER) {
1087 for (bNode &node : ntree->nodes) {
1088 if (node.type_legacy == SH_NODE_TEX_SKY && node.storage) {
1089 NodeTexSky *tex = static_cast<NodeTexSky *>(node.storage);
1090 tex->sun_intensity = 1.0f;
1091 tex->altitude *= 0.001f;
1092 }
1093 }
1094 }
1095 }
1097 }
1098
1099 /* Refactor bevel affect type to use an enum. */
1100 if (!DNA_struct_member_exists(fd->filesdna, "BevelModifierData", "char", "affect_type")) {
1101 for (Object &object : bmain->objects) {
1102 for (ModifierData &md : object.modifiers) {
1103 if (md.type == eModifierType_Bevel) {
1104 BevelModifierData *bmd = reinterpret_cast<BevelModifierData *>(&md);
1105 const bool use_vertex_bevel = bmd->flags & MOD_BEVEL_VERT_DEPRECATED;
1106 bmd->affect_type = use_vertex_bevel ? MOD_BEVEL_AFFECT_VERTICES :
1108 }
1109 }
1110 }
1111 }
1112
1113 /* Initialize additional velocity parameter for #CacheFile's. */
1114 if (!DNA_struct_member_exists(
1115 fd->filesdna, "MeshSeqCacheModifierData", "float", "velocity_scale"))
1116 {
1117 for (Object &object : bmain->objects) {
1118 for (ModifierData &md : object.modifiers) {
1119 if (md.type == eModifierType_MeshSequenceCache) {
1120 MeshSeqCacheModifierData *mcmd = reinterpret_cast<MeshSeqCacheModifierData *>(&md);
1121 mcmd->velocity_scale = 1.0f;
1122 }
1123 }
1124 }
1125 }
1126
1127 if (!DNA_struct_member_exists(fd->filesdna, "CacheFile", "char", "velocity_unit")) {
1128 for (CacheFile &cache_file : bmain->cachefiles) {
1129 STRNCPY_UTF8(cache_file.velocity_name, ".velocities");
1131 }
1132 }
1133
1134 if (!DNA_struct_member_exists(fd->filesdna, "OceanModifierData", "int", "viewport_resolution"))
1135 {
1136 for (Object &object : bmain->objects) {
1137 for (ModifierData &md : object.modifiers) {
1138 if (md.type == eModifierType_Ocean) {
1139 OceanModifierData *omd = reinterpret_cast<OceanModifierData *>(&md);
1140 omd->viewport_resolution = omd->resolution;
1141 }
1142 }
1143 }
1144 }
1145
1146 /* Remove panel X axis collapsing, a remnant of horizontal panel alignment. */
1147 for (bScreen &screen : bmain->screens) {
1148 for (ScrArea &area : screen.areabase) {
1149 for (ARegion &region : area.regionbase) {
1150 for (Panel &panel : region.panels) {
1152 }
1153 }
1154 }
1155 }
1156 }
1157
1158 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 291, 2)) {
1159 for (Scene &scene : bmain->scenes) {
1160 RigidBodyWorld *rbw = scene.rigidbody_world;
1161
1162 if (rbw == nullptr) {
1163 continue;
1164 }
1165
1166 /* The sub-step method changed from "per second" to "per frame".
1167 * To get the new value simply divide the old bullet sim FPS with the scene FPS. */
1168 rbw->substeps_per_frame /= scene.frames_per_second();
1169
1170 if (rbw->substeps_per_frame <= 0) {
1171 rbw->substeps_per_frame = 1;
1172 }
1173 }
1174
1175 /* PointCloud attributes. */
1176 for (PointCloud &pointcloud : bmain->pointclouds) {
1178 }
1179
1180 /* Show outliner mode column by default. */
1181 for (bScreen &screen : bmain->screens) {
1182 for (ScrArea &area : screen.areabase) {
1183 for (SpaceLink &space : area.spacedata) {
1184 if (space.spacetype == SPACE_OUTLINER) {
1185 SpaceOutliner *space_outliner = reinterpret_cast<SpaceOutliner *>(&space);
1186
1187 space_outliner->flag |= SO_MODE_COLUMN;
1188 }
1189 }
1190 }
1191 }
1192
1193 /* Solver and Collections for Boolean. */
1194 for (Object &object : bmain->objects) {
1195 for (ModifierData &md : object.modifiers) {
1196 if (md.type == eModifierType_Boolean) {
1197 BooleanModifierData *bmd = reinterpret_cast<BooleanModifierData *>(&md);
1200 }
1201 }
1202 }
1203 }
1204
1205 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 291, 5)) {
1206 /* Fix fcurves to allow for new bezier handles behavior (#75881 and D8752). */
1207 for (bAction &act : bmain->actions) {
1208 for (FCurve &fcu : act.curves) {
1209 /* Only need to fix Bezier curves with at least 2 key-frames. */
1210 if (fcu.totvert < 2 || fcu.bezt == nullptr) {
1211 continue;
1212 }
1214 }
1215 }
1216
1217 for (Collection &collection : bmain->collections) {
1218 collection.color_tag = COLLECTION_COLOR_NONE;
1219 }
1220 for (Scene &scene : bmain->scenes) {
1221 /* Old files do not have a master collection, but it will be created by
1222 * `BKE_collection_master_add()`. */
1223 if (scene.master_collection) {
1225 }
1226 }
1227
1228 /* Add custom profile and bevel mode to curve bevels. */
1229 if (!DNA_struct_member_exists(fd->filesdna, "Curve", "char", "bevel_mode")) {
1230 for (Curve &curve : bmain->curves) {
1231 if (curve.bevobj != nullptr) {
1233 }
1234 else {
1236 }
1237 }
1238 }
1239
1240 /* Ensure that new viewport display fields are initialized correctly. */
1241 for (Object &ob : bmain->objects) {
1242 for (ModifierData &md : ob.modifiers) {
1243 if (md.type == eModifierType_Fluid) {
1244 FluidModifierData *fmd = reinterpret_cast<FluidModifierData *>(&md);
1245 if (fmd->domain != nullptr) {
1246 if (!fmd->domain->coba_field && fmd->domain->type == FLUID_DOMAIN_TYPE_LIQUID) {
1248 }
1249 fmd->domain->grid_scale = 1.0;
1250 fmd->domain->gridlines_upper_bound = 1.0;
1252 const float grid_lines[4] = {1.0, 0.0, 0.0, 1.0};
1253 copy_v4_v4(fmd->domain->gridlines_range_color, grid_lines);
1254 }
1255 }
1256 }
1257 }
1258 }
1259
1260 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 291, 6)) {
1261 /* Darken Inactive Overlay. */
1262 if (!DNA_struct_member_exists(fd->filesdna, "View3DOverlay", "float", "fade_alpha")) {
1263 for (bScreen &screen : bmain->screens) {
1264 for (ScrArea &area : screen.areabase) {
1265 for (SpaceLink &sl : area.spacedata) {
1266 if (sl.spacetype == SPACE_VIEW3D) {
1267 View3D *v3d = reinterpret_cast<View3D *>(&sl);
1268 v3d->overlay.fade_alpha = 0.40f;
1270 }
1271 }
1272 }
1273 }
1274 }
1275
1276 /* Unify symmetry as a mesh property. */
1277 if (!DNA_struct_member_exists(fd->filesdna, "Mesh", "char", "symmetry")) {
1278 for (Mesh &mesh : bmain->meshes) {
1279 /* The previous flags used to store mesh symmetry in edit-mode match the new ones that are
1280 * used in #Mesh.symmetry. */
1281 mesh.symmetry = eMeshSymmetryType(int(mesh.editflag) &
1283 }
1284 }
1285
1286 /* Alembic importer: allow vertex interpolation by default. */
1287 for (Object &object : bmain->objects) {
1288 for (ModifierData &md : object.modifiers) {
1289 if (md.type != eModifierType_MeshSequenceCache) {
1290 continue;
1291 }
1292
1293 MeshSeqCacheModifierData *data = reinterpret_cast<MeshSeqCacheModifierData *>(&md);
1295 }
1296 }
1297 }
1298
1299 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 291, 7)) {
1300 for (Scene &scene : bmain->scenes) {
1301 scene.r.simplify_volumes = 1.0f;
1302 }
1303 }
1304
1305 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 291, 8)) {
1306 if (!DNA_struct_member_exists(fd->filesdna, "WorkSpaceDataRelation", "int", "parentid")) {
1307 for (WorkSpace &workspace : bmain->workspaces) {
1308 for (WorkSpaceDataRelation &relation : workspace.hook_layout_relations.items_mutable()) {
1309 relation.parent = blo_read_get_new_globaldata_address(fd, relation.parent);
1310 BLI_assert(relation.parentid == 0);
1311 if (relation.parent != nullptr) {
1312 for (wmWindowManager &wm : bmain->wm) {
1313 wmWindow *win = static_cast<wmWindow *>(
1314 BLI_findptr(&wm.windows, relation.parent, offsetof(wmWindow, workspace_hook)));
1315 if (win != nullptr) {
1316 relation.parentid = win->winid;
1317 break;
1318 }
1319 }
1320 if (relation.parentid == 0) {
1322 false,
1323 "Found a valid parent for workspace data relation, but no valid parent id.");
1324 }
1325 }
1326 if (relation.parentid == 0) {
1327 BLI_freelinkN(&workspace.hook_layout_relations, &relation);
1328 }
1329 }
1330 }
1331 }
1332
1333 /* UV/Image show overlay option. */
1334 if (!DNA_struct_exists(fd->filesdna, "SpaceImageOverlay")) {
1335 for (bScreen &screen : bmain->screens) {
1336 for (ScrArea &area : screen.areabase) {
1337 for (SpaceLink &space : area.spacedata) {
1338 if (space.spacetype == SPACE_IMAGE) {
1339 SpaceImage *sima = reinterpret_cast<SpaceImage *>(&space);
1341 }
1342 }
1343 }
1344 }
1345 }
1346
1347 /* Ensure that particle systems generated by fluid modifier have correct phystype. */
1348 for (ParticleSettings &part : bmain->particles) {
1350 part.phystype = PART_PHYS_NO;
1351 }
1352 }
1353 }
1354
1355 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 291, 9)) {
1356 /* Remove options of legacy UV/Image editor */
1357 for (bScreen &screen : bmain->screens) {
1358 for (ScrArea &area : screen.areabase) {
1359 for (SpaceLink &sl : area.spacedata) {
1360 switch (sl.spacetype) {
1361 case SPACE_IMAGE: {
1362 SpaceImage *sima = reinterpret_cast<SpaceImage *>(&sl);
1363 sima->flag &= ~SI_FLAG_UNUSED_20;
1364 break;
1365 }
1366 }
1367 }
1368 }
1369 }
1370
1371 if (!DNA_struct_member_exists(
1372 fd->filesdna, "FluidModifierData", "float", "fractions_distance"))
1373 {
1374 for (Object &ob : bmain->objects) {
1375 for (ModifierData &md : ob.modifiers) {
1376 if (md.type == eModifierType_Fluid) {
1377 FluidModifierData *fmd = reinterpret_cast<FluidModifierData *>(&md);
1378 if (fmd->domain) {
1379 fmd->domain->fractions_distance = 0.5;
1380 }
1381 }
1382 }
1383 }
1384 }
1385 }
1386
1387 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 292, 1)) {
1388 {
1389 const int LEGACY_REFINE_RADIAL_DISTORTION_K1 = (1 << 2);
1390
1391 for (MovieClip &clip : bmain->movieclips) {
1392 MovieTracking *tracking = &clip.tracking;
1393 MovieTrackingSettings *settings = &tracking->settings;
1394 TrackingRefineCameraFlag new_refine_camera_intrinsics = REFINE_NO_INTRINSICS;
1395
1397 new_refine_camera_intrinsics |= REFINE_FOCAL_LENGTH;
1398 }
1399
1401 new_refine_camera_intrinsics |= REFINE_PRINCIPAL_POINT;
1402 }
1403
1404 /* The end goal is to enable radial distortion refinement if either K1 or K2 were set for
1405 * refinement. It is enough to only check for L1 it was not possible to refine K2 without
1406 * K1. */
1407 if (settings->refine_camera_intrinsics & LEGACY_REFINE_RADIAL_DISTORTION_K1) {
1408 new_refine_camera_intrinsics |= REFINE_RADIAL_DISTORTION;
1409 }
1410
1411 settings->refine_camera_intrinsics = new_refine_camera_intrinsics;
1412 }
1413 }
1414 }
1415
1416 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 292, 5)) {
1417 /* Initialize the opacity of the overlay wireframe */
1418 if (!DNA_struct_member_exists(fd->filesdna, "View3DOverlay", "float", "wireframe_opacity")) {
1419 for (bScreen &screen : bmain->screens) {
1420 for (ScrArea &area : screen.areabase) {
1421 for (SpaceLink &sl : area.spacedata) {
1422 if (sl.spacetype == SPACE_VIEW3D) {
1423 View3D *v3d = reinterpret_cast<View3D *>(&sl);
1424 v3d->overlay.wireframe_opacity = 1.0f;
1425 }
1426 }
1427 }
1428 }
1429 }
1430
1431 /* Replace object hidden filter with inverted object visible filter. */
1432 for (bScreen &screen : bmain->screens) {
1433 for (ScrArea &area : screen.areabase) {
1434 for (SpaceLink &space : area.spacedata) {
1435 if (space.spacetype == SPACE_OUTLINER) {
1436 SpaceOutliner *space_outliner = reinterpret_cast<SpaceOutliner *>(&space);
1437 if (space_outliner->filter_state == SO_FILTER_OB_HIDDEN) {
1438 space_outliner->filter_state = SO_FILTER_OB_VISIBLE;
1439 space_outliner->filter |= SO_FILTER_OB_STATE_INVERSE;
1440 }
1441 }
1442 }
1443 }
1444 }
1445
1446 for (Object &ob : bmain->objects) {
1447 for (ModifierData &md : ob.modifiers) {
1450 &md);
1451 if (wmd->cmap_curve == nullptr) {
1452 wmd->cmap_curve = BKE_curvemapping_add(1, 0.0, 0.0, 1.0, 1.0);
1454 }
1455 }
1456 }
1457 }
1458
1459 /* PointCloud attributes names. */
1460 for (PointCloud &pointcloud : bmain->pointclouds) {
1462 }
1463
1464 /* Cryptomatte render pass */
1465 if (!DNA_struct_member_exists(fd->filesdna, "ViewLayer", "short", "cryptomatte_levels")) {
1466 for (Scene &scene : bmain->scenes) {
1467 for (ViewLayer &view_layer : scene.view_layers) {
1468 view_layer.cryptomatte_levels = 6;
1470 }
1471 }
1472 }
1473 }
1474
1475 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 292, 7)) {
1476 /* Make all IDProperties used as interface of geometry node trees overridable. */
1477 for (Object &ob : bmain->objects) {
1478 for (ModifierData &md : ob.modifiers) {
1479 if (md.type == eModifierType_Nodes) {
1480 NodesModifierData *nmd = reinterpret_cast<NodesModifierData *>(&md);
1481 IDProperty *nmd_properties = nmd->settings_legacy.properties;
1482
1483 BLI_assert(nmd_properties->type == IDP_GROUP);
1484 for (IDProperty &nmd_socket_idprop : nmd_properties->data.group) {
1485 nmd_socket_idprop.flag |= IDP_FLAG_OVERRIDABLE_LIBRARY;
1486 }
1487 }
1488 }
1489 }
1490
1491 /* EEVEE/Cycles Volumes consistency */
1492 for (Scene &scene : bmain->scenes) {
1493 /* Remove Volume Transmittance render pass from each view layer. */
1494 for (ViewLayer &view_layer : scene.view_layers) {
1496 }
1497
1498 /* Rename Render-layer Socket `VolumeScatterCol` to `VolumeDir`. */
1499 if (scene.nodetree) {
1500 for (bNode &node : scene.nodetree->nodes) {
1501 if (node.type_legacy == CMP_NODE_R_LAYERS) {
1502 for (bNodeSocket &output_socket : node.outputs) {
1503 const char *volume_scatter = "VolumeScatterCol";
1504 if (STREQLEN(output_socket.name, volume_scatter, MAX_NAME)) {
1506 }
1507 }
1508 }
1509 }
1510 }
1511 }
1512
1513 /* Convert `NodeCryptomatte->storage->matte_id` to `NodeCryptomatte->storage->entries` */
1514 if (!DNA_struct_exists(fd->filesdna, "CryptomatteEntry")) {
1515 for (Scene &scene : bmain->scenes) {
1516 if (scene.nodetree) {
1517 for (bNode &node : scene.nodetree->nodes) {
1518 if (node.type_legacy == CMP_NODE_CRYPTOMATTE_LEGACY) {
1520 NodeCryptomatte *storage = static_cast<NodeCryptomatte *>(node.storage);
1521 char *matte_id = storage->matte_id;
1522 if ((matte_id == nullptr) || (storage->matte_id[0] == '\0')) {
1523 continue;
1524 }
1526 }
1527 }
1528 }
1529 }
1530 }
1531 }
1532
1533 /* Overlay elements in the sequencer. */
1534 for (bScreen &screen : bmain->screens) {
1535 for (ScrArea &area : screen.areabase) {
1536 for (SpaceLink &sl : area.spacedata) {
1537 if (sl.spacetype == SPACE_SEQ) {
1538 SpaceSeq *sseq = reinterpret_cast<SpaceSeq *>(&sl);
1539 sseq->flag |= SEQ_SHOW_OVERLAY;
1543 }
1544 }
1545 }
1546 }
1547 }
1548
1549 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 292, 8)) {
1550 for (bNodeTree &ntree : bmain->nodetrees) {
1551 for (bNode &node : ntree.nodes) {
1552 if (STREQ(node.idname, "GeometryNodeRandomAttribute")) {
1553 STRNCPY_UTF8(node.idname, "GeometryLegacyNodeAttributeRandomize");
1554 }
1555 }
1556 }
1557
1558 for (Scene &scene : bmain->scenes) {
1559 if (scene.toolsettings->sequencer_tool_settings == nullptr) {
1561 }
1562 }
1563 }
1564
1565 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 292, 9)) {
1566 /* Default properties editors to auto outliner sync. */
1567 for (bScreen &screen : bmain->screens) {
1568 for (ScrArea &area : screen.areabase) {
1569 for (SpaceLink &space : area.spacedata) {
1570 if (space.spacetype == SPACE_PROPERTIES) {
1571 SpaceProperties *space_properties = reinterpret_cast<SpaceProperties *>(&space);
1572 space_properties->outliner_sync = PROPERTIES_SYNC_AUTO;
1573 }
1574 }
1575 }
1576 }
1577
1578 /* Ensure that new viscosity strength field is initialized correctly. */
1579 if (!DNA_struct_member_exists(fd->filesdna, "FluidModifierData", "float", "viscosity_value")) {
1580 for (Object &ob : bmain->objects) {
1581 for (ModifierData &md : ob.modifiers) {
1582 if (md.type == eModifierType_Fluid) {
1583 FluidModifierData *fmd = reinterpret_cast<FluidModifierData *>(&md);
1584 if (fmd->domain != nullptr) {
1585 fmd->domain->viscosity_value = 0.05;
1586 }
1587 }
1588 }
1589 }
1590 }
1591 }
1592
1593 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 292, 10)) {
1594 if (!DNA_struct_exists(fd->filesdna, "NodeSetAlpha")) {
1595 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
1596 if (ntree->type != NTREE_COMPOSIT) {
1597 continue;
1598 }
1599 for (bNode &node : ntree->nodes) {
1600 if (node.type_legacy != CMP_NODE_SETALPHA) {
1601 continue;
1602 }
1603 NodeSetAlpha *storage = MEM_new<NodeSetAlpha>("NodeSetAlpha");
1605 node.storage = storage;
1606 }
1607 }
1609 }
1610
1611 for (Scene &scene : bmain->scenes) {
1612 Editing *ed = seq::editing_get(&scene);
1613 if (ed == nullptr) {
1614 continue;
1615 }
1617 }
1618 }
1619
1620 /* Enable "Save as Render" option for file output node by default (apply view transform to image
1621 * on save) */
1622 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 292, 11)) {
1623 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
1624 if (ntree->type == NTREE_COMPOSIT) {
1625 for (bNode &node : ntree->nodes) {
1626 if (node.type_legacy == CMP_NODE_OUTPUT_FILE) {
1627 for (bNodeSocket &sock : node.inputs) {
1629 sock.storage);
1630 simf->save_as_render = true;
1631 }
1632 }
1633 }
1634 }
1635 }
1637 }
1638
1639 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 293, 1)) {
1640 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
1641 if (ntree->type == NTREE_GEOMETRY) {
1642 version_node_socket_name(ntree, GEO_NODE_MESH_BOOLEAN, "Geometry A", "Geometry 1");
1643 version_node_socket_name(ntree, GEO_NODE_MESH_BOOLEAN, "Geometry B", "Geometry 2");
1644 }
1645 }
1647
1648 /* Init grease pencil default curve resolution. */
1649 if (!DNA_struct_member_exists(fd->filesdna, "bGPdata", "int", "curve_edit_resolution")) {
1650 for (bGPdata &gpd : bmain->gpencils) {
1653 }
1654 }
1655 /* Init grease pencil curve editing error threshold. */
1656 if (!DNA_struct_member_exists(fd->filesdna, "bGPdata", "float", "curve_edit_threshold")) {
1657 for (bGPdata &gpd : bmain->gpencils) {
1660 }
1661 }
1662 }
1663
1664 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 292, 14) ||
1665 ((bmain->versionfile == 293) && !MAIN_VERSION_FILE_ATLEAST(bmain, 293, 1)))
1666 {
1667 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
1668 if (ntree->type != NTREE_GEOMETRY) {
1669 continue;
1670 }
1671 for (bNode &node : ntree->nodes) {
1672 if (node.type_legacy == GEO_NODE_OBJECT_INFO && node.storage == nullptr) {
1673 NodeGeometryObjectInfo *data = MEM_new<NodeGeometryObjectInfo>(__func__);
1674 data->transform_space = GEO_NODE_TRANSFORM_SPACE_RELATIVE;
1675 node.storage = data;
1676 }
1677 }
1678 }
1680 }
1681
1682 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 293, 1)) {
1683 /* Grease pencil layer transform matrix. */
1684 if (!DNA_struct_member_exists(fd->filesdna, "bGPDlayer", "float", "location[0]")) {
1685 for (bGPdata &gpd : bmain->gpencils) {
1686 for (bGPDlayer &gpl : gpd.layers) {
1687 zero_v3(gpl.location);
1688 zero_v3(gpl.rotation);
1689 copy_v3_fl(gpl.scale, 1.0f);
1692 }
1693 }
1694 }
1695 /* Fix Fill factor for grease pencil fill brushes. */
1696 for (Brush &brush : bmain->brushes) {
1697 if ((brush.gpencil_settings) && (brush.gpencil_settings->fill_factor == 0.0f)) {
1698 brush.gpencil_settings->fill_factor = 1.0f;
1699 }
1700 }
1701 }
1702
1703 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 293, 5)) {
1704 /* Change Nishita sky model Altitude unit. */
1705 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
1706 if (ntree->type == NTREE_SHADER) {
1707 for (bNode &node : ntree->nodes) {
1708 if (node.type_legacy == SH_NODE_TEX_SKY && node.storage) {
1710 NodeTexSky *tex = static_cast<NodeTexSky *>(node.storage);
1711 tex->altitude *= 1000.0f;
1712 }
1713 }
1714 }
1715 }
1716 }
1718 }
1719
1720 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 293, 6)) {
1721 for (bScreen &screen : bmain->screens) {
1722 for (ScrArea &area : screen.areabase) {
1723 for (SpaceLink &space : area.spacedata) {
1724 /* Enable Outliner render visibility column. */
1725 if (space.spacetype == SPACE_OUTLINER) {
1726 SpaceOutliner *space_outliner = reinterpret_cast<SpaceOutliner *>(&space);
1727 space_outliner->show_restrict_flags |= SO_RESTRICT_RENDER;
1728 }
1729 }
1730 }
1731 }
1732 }
1733
1734 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 293, 7)) {
1735 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
1736 if (ntree->type == NTREE_GEOMETRY) {
1738 }
1739 }
1741 }
1742
1743 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 293, 9)) {
1744 if (!DNA_struct_member_exists(fd->filesdna, "SceneEEVEE", "float", "bokeh_overblur")) {
1745 for (Scene &scene : bmain->scenes) {
1746 scene.eevee.bokeh_neighbor_max = 10.0f;
1747 scene.eevee.bokeh_overblur = 5.0f;
1748 }
1749 }
1750
1751 /* Add sub-panels for FModifiers, which requires a field to store expansion. */
1752 if (!DNA_struct_member_exists(fd->filesdna, "FModifier", "short", "ui_expand_flag")) {
1753 for (bAction &act : bmain->actions) {
1754 for (FCurve &fcu : act.curves) {
1755 for (FModifier &fcm : fcu.modifiers) {
1757 fcm.ui_expand_flag, fcm.flag & FMODIFIER_FLAG_EXPANDED, UI_PANEL_DATA_EXPAND_ROOT);
1758 }
1759 }
1760 }
1761 }
1762 }
1763
1764 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 293, 10)) {
1765 for (Scene &scene : bmain->scenes) {
1766 /* Fix old scene with too many samples that were not being used.
1767 * Now they are properly used and might produce a huge slowdown.
1768 * So we clamp to what the old max actual was. */
1770 }
1771 }
1772
1773 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 293, 11)) {
1774 for (bNodeTree &ntree : bmain->nodetrees) {
1775 if (ntree.type == NTREE_GEOMETRY) {
1776 for (bNode &node : ntree.nodes) {
1777 if (STREQ(node.idname, "GeometryNodeSubdivisionSurfaceSimple")) {
1778 STRNCPY_UTF8(node.idname, "GeometryNodeSubdivide");
1779 }
1780 if (STREQ(node.idname, "GeometryNodeSubdivisionSurface")) {
1781 STRNCPY_UTF8(node.idname, "GeometryNodeSubdivideSmooth");
1782 }
1783 }
1784 }
1785 }
1786 }
1787
1788 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 293, 12)) {
1789 for (bScreen &screen : bmain->screens) {
1790 for (ScrArea &area : screen.areabase) {
1791 for (SpaceLink &sl : area.spacedata) {
1792 switch (sl.spacetype) {
1793 case SPACE_SEQ: {
1794 SpaceSeq *sseq = reinterpret_cast<SpaceSeq *>(&sl);
1795 if (ELEM(sseq->render_size,
1800 {
1801 sseq->flag |= SEQ_USE_PROXIES;
1802 }
1805 }
1806 }
1807 }
1808 }
1809 }
1810 }
1811
1812 for (bScreen &screen : bmain->screens) {
1813 for (ScrArea &area : screen.areabase) {
1814 for (SpaceLink &sl : area.spacedata) {
1815 if (sl.spacetype == SPACE_SPREADSHEET) {
1816 ListBaseT<ARegion> *regionbase = (&sl == area.spacedata.first_) ? &area.regionbase :
1817 &sl.regionbase;
1819 regionbase, RGN_TYPE_FOOTER, "footer for spreadsheet", RGN_TYPE_HEADER);
1820 if (new_footer != nullptr) {
1821 new_footer->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_TOP :
1823 }
1824 }
1825 }
1826 }
1827 }
1828 }
1829
1830 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 293, 13)) {
1831 for (bNodeTree &ntree : bmain->nodetrees) {
1832 if (ntree.type == NTREE_GEOMETRY) {
1833 for (bNode &node : ntree.nodes) {
1834 if (STREQ(node.idname, "GeometryNodeSubdivideSmooth")) {
1835 STRNCPY_UTF8(node.idname, "GeometryNodeSubdivisionSurface");
1836 }
1837 }
1838 }
1839 }
1840 }
1841
1842 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 293, 14)) {
1843 if (!DNA_struct_member_exists(fd->filesdna, "Light", "float", "diff_fac")) {
1844 for (Light &light : bmain->lights) {
1845 light.diff_fac = 1.0f;
1846 light.volume_fac = 1.0f;
1847 }
1848 }
1849 }
1850
1851 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 293, 15)) {
1852 for (bNodeTree &ntree : bmain->nodetrees) {
1853 if (ntree.type == NTREE_GEOMETRY) {
1854 for (bNode &node : ntree.nodes) {
1855 if (STREQ(node.idname, "GeometryNodeMeshPlane")) {
1856 STRNCPY(node.idname, "GeometryNodeMeshGrid");
1857 }
1858 }
1859 }
1860 }
1861 }
1862
1863 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 293, 16)) {
1864 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
1865 if (ntree->type == NTREE_GEOMETRY) {
1867 }
1869 }
1870
1871 /* The CU_2D flag has been removed. */
1872 for (Curve &cu : bmain->curves) {
1873#define CU_2D (1 << 3)
1874 ListBaseT<Nurb> *nurbs = BKE_curve_nurbs_get(&cu);
1875 bool is_2d = true;
1876
1877 for (Nurb &nu : *nurbs) {
1878 if (nu.flag & CU_2D) {
1879 nu.flag &= ~eNurbFlag(CU_2D);
1880 }
1881 else {
1882 is_2d = false;
1883 }
1884 }
1885#undef CU_2D
1886 if (!is_2d && CU_IS_2D(&cu)) {
1887 cu.flag |= CU_3D;
1888 }
1889 }
1890 }
1891
1892 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 293, 18)) {
1893 if (!DNA_struct_member_exists(fd->filesdna, "bArmature", "float", "axes_position")) {
1894 /* Convert the axes draw position to its old default (tip of bone). */
1895 for (bArmature &arm : bmain->armatures) {
1896 arm.axes_position = 1.0;
1897 }
1898 }
1899
1900 /* Initialize the spread parameter for area lights. */
1901 if (!DNA_struct_member_exists(fd->filesdna, "Light", "float", "area_spread")) {
1902 for (Light &la : bmain->lights) {
1903 la.area_spread = DEG2RADF(180.0f);
1904 }
1905 }
1906
1907 for (bScreen &screen : bmain->screens) {
1908 for (ScrArea &area : screen.areabase) {
1909 for (SpaceLink &sl : area.spacedata) {
1910 if (sl.spacetype == SPACE_NODE) {
1911 SpaceNode *snode = reinterpret_cast<SpaceNode *>(&sl);
1912 for (bNodeTreePath &path : snode->treepath) {
1914 }
1915 }
1916 }
1917 }
1918 }
1919 }
1920
1921 /* Set default value for the new bisect_threshold parameter in the mirror modifier. */
1922 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 293, 19)) {
1923 for (Object &ob : bmain->objects) {
1924 for (ModifierData &md : ob.modifiers) {
1925 if (md.type == eModifierType_Mirror) {
1926 MirrorModifierData *mmd = reinterpret_cast<MirrorModifierData *>(&md);
1927 /* This was the previous hard-coded value. */
1928 mmd->bisect_threshold = 0.001f;
1929 }
1930 }
1931 }
1932
1933 for (Curve &cu : bmain->curves) {
1934 /* Turn on clamping as this was implicit before. */
1935 cu.flag |= CU_PATH_CLAMP;
1936 }
1937 }
1938
1945}
1946
1947} // namespace blender
#define CU_IS_2D(cu)
Definition BKE_curve.hh:93
CustomData interface, see also DNA_customdata_types.h.
#define MAIN_VERSION_FILE_ATLEAST(main, ver, subver)
Definition BKE_main.hh:949
#define MAIN_VERSION_FILE_OLDER(main, ver, subver)
Definition BKE_main.hh:953
#define FOREACH_NODETREE_END
Definition BKE_node.hh:936
#define FOREACH_NODETREE_BEGIN(bmain, _nodetree, _id)
Definition BKE_node.hh:926
#define GEO_NODE_OBJECT_INFO
#define SH_NODE_BSDF_PRINCIPLED
#define GEO_NODE_MESH_BOOLEAN
#define SH_NODE_TEX_SKY
#define CMP_NODE_CRYPTOMATTE_LEGACY
#define GEO_NODE_MESH_PRIMITIVE_GRID
#define CMP_NODE_OUTPUT_FILE
#define CMP_NODE_SETALPHA
#define CMP_NODE_R_LAYERS
#define GEO_NODE_JOIN_GEOMETRY
#define DEG2RADF(_deg)
#define M_PI_2
#define STRNCPY_UTF8(dst, src)
external readfile function prototypes.
#define RPT_(msgid)
Object groups, one object can be in many groups at once.
#define MAX_NAME
Definition DNA_defs.h:63
blenloader genfile private function prototypes
#define GP_DEFAULT_CURVE_EDIT_CORNER_ANGLE
#define GP_DEFAULT_CURVE_RESOLUTION
#define GP_DEFAULT_CURVE_ERROR
Object is a sort of wrapper for general info.
Types and defines for representing Rigid Body entities.
#define RE_PASSNAME_VOLUME_LIGHT
Read Blender memory allocation and freeing.
#define UNUSED_VARS(...)
#define STREQLEN(a, b, n)
#define SET_FLAG_FROM_TEST(value, test, flag)
#define ELEM(...)
#define BLI_assert_msg(a, msg)
#define STREQ(a, b)
btSequentialImpulseConstraintSolverMt int btPersistentManifold int btTypedConstraint ** constraints
constexpr IndexRange()=default
UString()=default
const T & data(const Action &owning_action) const
@ DENOISER_OPTIX
Definition denoise.h:12
#define offsetof(t, d)
#define storage(slot, qualifiers)
#define layer
void node_remove_socket(bNodeTree &ntree, bNode &node, bNodeSocket &sock)
Definition node.cc:4015
bNodeLink & node_add_link(bNodeTree &ntree, bNode &fromnode, bNodeSocket &fromsock, bNode &tonode, bNodeSocket &tosock)
Definition node.cc:4638
bNodeSocket * node_find_socket(bNode &node, eNodeSocketInOut in_out, UString identifier)
Definition node.cc:3036
SequencerToolSettings * tool_settings_init()
Definition sequencer.cc:375
IMB_Proxy_Size rendersize_to_proxysize(eSpaceSeq_Proxy_RenderSize render_size)
Definition proxy.cc:137
Editing * editing_get(const Scene *scene)
Definition sequencer.cc:304
MetaStack * meta_stack_active_get(const Editing *ed)
Definition sequencer.cc:484
float rendersize_to_scale_factor(eSpaceSeq_Proxy_RenderSize render_size)
Definition proxy.cc:153
BMesh Iterators.
bool version_node_ensure_storage_or_invalidate(bNode &node)
static eSpaceSeq_Proxy_RenderSize get_sequencer_render_size(Main *bmain)
@ V3D_OVERLAY_FADE_INACTIVE
@ FLUID_DOMAIN_FIELD_PHI
CurveMapping * BKE_curvemapping_add(int tot, float minx, float miny, float maxx, float maxy)
Definition colortools.cc:99
void * BLI_findptr(const ListBase *listbase, const void *ptr, int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition listbase.cc:710
UserDef U
Definition blender.cc:58
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
@ SEQ_RENDER_SIZE_PROXY_75
@ SEQ_RENDER_SIZE_PROXY_50
@ SEQ_RENDER_SIZE_PROXY_100
@ SEQ_RENDER_SIZE_PROXY_25
@ SEQ_RENDER_SIZE_FULL_DEPRECATED
@ SO_FILTER_OB_STATE_INVERSE
@ UI_PANEL_DATA_EXPAND_ROOT
char * STRNCPY(char(&dst)[N], const char *src)
static void version_node_join_geometry_for_multi_input_socket(bNodeTree *ntree)
@ SEQ_TIMELINE_SHOW_STRIP_DURATION
@ SEQ_TIMELINE_SHOW_STRIP_NAME
@ SEQ_TIMELINE_SHOW_STRIP_SOURCE
void multires_do_versions_simple_to_catmull_clark(Object *object, MultiresModifierData *mmd)
void BKE_pose_rebuild(Main *bmain, Object *ob, bArmature *arm, bool do_id_user)
unsigned int uint
Definition BKE_text.h:55
void BLI_addhead(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:98
static void strip_convert_transform_crop_lb(const Scene *scene, const ListBaseT< Strip > *lb, const eSpaceSeq_Proxy_RenderSize render_size)
ListBaseT< Nurb > * BKE_curve_nurbs_get(Curve *cu)
Definition curve.cc:4992
static void strip_convert_transform_crop_2(const Scene *scene, Strip *strip, const eSpaceSeq_Proxy_RenderSize render_size)
void * blo_read_get_new_globaldata_address(FileData *fd, const void *adr)
Definition readfile.cc:1523
static void strip_convert_transform_animation(const Strip *strip, const Scene *scene, const char *path, const int image_size, const int scene_size)
bool invert_m4_m4(float inverse[4][4], const float mat[4][4])
@ eModifierType_WeightVGEdit
@ eModifierType_MeshSequenceCache
@ eModifierType_WeightVGProximity
static void strip_convert_transform_crop_lb_2(const Scene *scene, const ListBaseT< Strip > *lb, const eSpaceSeq_Proxy_RenderSize render_size)
static void panels_remove_x_closed_flag_recursive(Panel *panel)
void version_cycles_property_boolean_set(IDProperty *idprop, const char *name, bool value)
char * BLI_sprintfN(const char *__restrict format,...) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC ATTR_PRINTF_FORMAT(1
void * BLI_findstring(const ListBase *listbase, const char *id, int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition listbase.cc:615
MINLINE void sub_v2_v2v2(float r[2], const float a[2], const float b[2])
MINLINE int max_ii(int a, int b)
static void do_versions_291_fcurve_handles_limit(FCurve *fcu)
@ SI_OVERLAY_SHOW_OVERLAYS
void BKE_main_id_repair_duplicate_names_listbase(Main *bmain, ListBaseT< ID > *lb)
Definition lib_id.cc:1348
static void version_node_socket_duplicate(bNodeTree *ntree, const int node_type, const char *old_name, const char *new_name)
void id_fake_user_set(ID *id)
Definition lib_id.cc:471
IDProperty * version_cycles_properties_from_render_layer(SceneRenderLayer *render_layer)
void MEM_delete_void(void *vmemh)
bool BKE_collection_cycles_fix(Main *bmain, Collection *collection)
int version_cycles_property_int(IDProperty *idprop, const char *name, int default_value)
static bool can_use_proxy(const Strip *strip, IMB_Proxy_Size psize)
@ CMP_NODE_SETALPHA_MODE_REPLACE_ALPHA
void BKE_curvemapping_init(CurveMapping *cumap)
void * MEM_dupalloc_void(const void *vmemh) ATTR_WARN_UNUSED_RESULT
static void strip_convert_transform_animation_2(const Scene *scene, const char *path, const float scale_to_fit_factor)
void loc_eul_size_to_mat4(float R[4][4], const float loc[3], const float eul[3], const float size[3])
@ IDP_FLAG_OVERRIDABLE_LIBRARY
void BLI_remlink(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:138
BMesh const char void * data
char char size_t BLI_str_escape(char *__restrict dst, StringRef src, size_t dst_maxncpy) ATTR_NONNULL(1)
void version_cycles_property_int_set(IDProperty *idprop, const char *name, int value)
void BLI_freelinkN(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:277
constexpr size_t ARRAY_SIZE(const T(&arg)[N]) noexcept
@ CACHEFILE_VELOCITY_UNIT_SECOND
void blo_do_versions_290(FileData *fd, Library *lib, Main *bmain)
const void * CustomData_get_layer(const CustomData *data, eCustomDataType type)
@ MOD_WVG_EDIT_WEIGHTS_NORMALIZE
@ MOD_MESHSEQ_INTERPOLATE_VERTICES
MINLINE void zero_v3(float r[3])
@ GEO_NODE_TRANSFORM_SPACE_RELATIVE
bool version_cycles_property_boolean(IDProperty *idprop, const char *name, bool default_value)
@ MOD_BEVEL_PROFILE_SUPERELLIPSE
void BKE_fcurve_free(FCurve *fcu)
ATTR_WARN_UNUSED_RESULT const BMVert * v2
MINLINE void copy_v3_fl(float r[3], float f)
@ EEVEE_RENDER_PASS_UNUSED_8
IDProperty * version_cycles_properties_from_ID(ID *id)
@ VIEW_LAYER_CRYPTOMATTE_ACCURATE
MINLINE void copy_v4_v4(float r[4], const float a[4])
ARegion * do_versions_add_region_if_not_found(ListBaseT< ARegion > *regionbase, int region_type, const char *, int link_after_region_type)
bool BKE_fcurve_is_empty(const FCurve *fcu)
static void strip_convert_transform_crop(const Scene *scene, Strip *strip, const eSpaceSeq_Proxy_RenderSize render_size)
static void do_versions_point_attributes(CustomData *pdata)
FCurve * BKE_fcurve_find(ListBaseT< FCurve > *list, const char rna_path[], int array_index)
static void seq_update_meta_disp_range(Scene *scene)
void version_node_socket_index_animdata(Main *bmain, const int node_tree_type, const int node_type, const int socket_index_orig, const int socket_index_offset, const int total_number_of_sockets)
IDProperty * version_cycles_properties_from_view_layer(ViewLayer *view_layer)
void do_versions_after_linking_290(FileData *fd, Main *bmain)
MINLINE int min_ii(int a, int b)
void BLO_read_invalidate_message(BlendHandle *bh, Main *bmain, const char *message)
@ FLUID_DOMAIN_TYPE_LIQUID
static void do_versions_point_attribute_names(CustomData *pdata)
void version_node_socket_name(bNodeTree *ntree, const int node_type, const char *old_name, const char *new_name)
MINLINE void madd_v2_v2v2fl(float r[2], const float a[2], const float b[2], float f)
ListBaseT< ID > * which_libbase(Main *bmain, short type)
Definition main.cc:1073
void BKE_cryptomatte_matte_id_to_entries(struct NodeCryptomatte *node_storage, const char *matte_id)
struct bGPDframe * BKE_annotations_frame_duplicate(const struct bGPDframe *gpf_src, bool dup_strokes)
#define fabsf
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
ListBaseT< Panel > panels
eRegion_Alignment alignment
BevelModifierAffectType affect_type
BevelModifierProfileType profile_type
float wet_paint_radius_factor
eCacheFile_VelocityUnit velocity_unit
CollectionColorTag color_tag
eCurveBevelMode bevel_mode
struct Object * bevobj
ListBaseT< Strip > seqbase
ListBaseT< FModifier > modifiers
unsigned int totvert
eFModifier_Flags flag
std::unique_ptr< SDNA > filesdna
Definition readfile.hh:111
eFluidDomain_CobaField coba_field
struct FluidDomainSettings * domain
ListBaseT< struct IDProperty > group
Definition DNA_ID.h:133
eIDPropertyFlag flag
Definition DNA_ID.h:151
eIDPropertyType type
Definition DNA_ID.h:145
IDPropertyData data
Definition DNA_ID.h:157
char name[258]
Definition DNA_ID.h:433
ListBaseT< wmWindowManager > wm
Definition BKE_main.hh:415
ListBaseT< Collection > collections
Definition BKE_main.hh:406
ListBaseT< bArmature > armatures
Definition BKE_main.hh:407
ListBaseT< bGPdata > gpencils
Definition BKE_main.hh:417
ListBaseT< bNodeTree > nodetrees
Definition BKE_main.hh:409
ListBaseT< Text > texts
Definition BKE_main.hh:402
ListBaseT< Light > lights
Definition BKE_main.hh:396
ListBaseT< PointCloud > pointclouds
Definition BKE_main.hh:429
short versionfile
Definition BKE_main.hh:269
ListBaseT< MovieClip > movieclips
Definition BKE_main.hh:419
ListBaseT< Brush > brushes
Definition BKE_main.hh:410
ListBaseT< Material > materials
Definition BKE_main.hh:392
ListBaseT< Object > objects
Definition BKE_main.hh:388
ListBaseT< CacheFile > cachefiles
Definition BKE_main.hh:422
ListBaseT< Curve > curves
Definition BKE_main.hh:390
ListBaseT< Mesh > meshes
Definition BKE_main.hh:389
ListBaseT< WorkSpace > workspaces
Definition BKE_main.hh:423
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< bScreen > screens
Definition BKE_main.hh:400
CustomData face_data
struct MovieTracking tracking
TrackingRefineCameraFlag refine_camera_intrinsics
MovieTrackingSettings settings
struct NodesModifierSettings settings_legacy
ListBaseT< ModifierData > modifiers
ListBaseT< GpencilModifierData > greasepencil_modifiers
ListBaseT< Panel > children
eParticlePhysicsType phystype
struct CustomData pdata_legacy
ListBaseT< SceneRenderLayer > layers
ListBaseT< ViewLayer > view_layers
struct Editing * ed
struct Collection * master_collection
struct AnimData * adt
DNA_DEPRECATED struct bNodeTree * nodetree
struct RenderData r
struct SceneEEVEE eevee
struct ToolSettings * toolsettings
struct RigidBodyWorld * rigidbody_world
ListBaseT< ARegion > regionbase
ListBaseT< SpaceLink > spacedata
eSpaceSeq_SequencerTimelineOverlay_Flag flag
eSpaceImageOverlay_Flag flag
SpaceImageOverlay overlay
eSpaceImage_Flag flag
ListBaseT< bNodeTreePath > treepath
eSpaceOutliner_Flag flag
eSpaceOutliner_Filter filter
eSpaceOutliner_StateFilter filter_state
eSpaceOutliner_ShowRestrictFlag show_restrict_flags
eSpaceButtons_OutlinerSync outliner_sync
eSpaceSeq_Flag flag
eSpaceSeq_Proxy_RenderSize render_size
struct SequencerTimelineOverlay timeline_overlay
eSpaceSeq_RegionType mainb
struct SequencerToolSettings * sequencer_tool_settings
eView3DOverlay_Flag flag
View3DOverlay overlay
eViewLayerEEVEEPassType render_passes
struct ViewLayerEEVEE eevee
eViewLayerCryptomatteFlags cryptomatte_flag
ListBaseT< struct WorkSpaceDataRelation > hook_layout_relations
ListBaseT< FCurve > curves
ListBaseT< bGPDframe > frames
ListBaseT< bGPDlayer > layers
struct bNodeSocket * next
ListBaseT< bNodeLink > links
eNodeTree_Type type
ListBaseT< bNode > nodes
ListBaseT< struct ScrArea > areabase
#define CU_2D