2 * ***** BEGIN GPL LICENSE BLOCK *****
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * Contributor(s): Blender Foundation
20 * ***** END GPL LICENSE BLOCK *****
24 /** \file blender/blenloader/intern/versioning_270.c
28 #include "BLI_utildefines.h"
29 #include "BLI_compiler_attrs.h"
31 /* for MinGW32 definition of NULL, could use BLI_blenlib.h instead too */
34 /* allow readfile to use deprecated functionality */
35 #define DNA_DEPRECATED_ALLOW
37 #include "DNA_anim_types.h"
38 #include "DNA_armature_types.h"
39 #include "DNA_brush_types.h"
40 #include "DNA_camera_types.h"
41 #include "DNA_cloth_types.h"
42 #include "DNA_constraint_types.h"
43 #include "DNA_gpencil_types.h"
44 #include "DNA_sdna_types.h"
45 #include "DNA_sequence_types.h"
46 #include "DNA_space_types.h"
47 #include "DNA_screen_types.h"
48 #include "DNA_object_force.h"
49 #include "DNA_object_types.h"
50 #include "DNA_mask_types.h"
51 #include "DNA_mesh_types.h"
52 #include "DNA_modifier_types.h"
53 #include "DNA_particle_types.h"
54 #include "DNA_linestyle_types.h"
55 #include "DNA_actuator_types.h"
56 #include "DNA_view3d_types.h"
57 #include "DNA_smoke_types.h"
58 #include "DNA_rigidbody_types.h"
60 #include "DNA_genfile.h"
62 #include "BKE_animsys.h"
63 #include "BKE_colortools.h"
64 #include "BKE_library.h"
67 #include "BKE_modifier.h"
69 #include "BKE_scene.h"
70 #include "BKE_sequencer.h"
71 #include "BKE_screen.h"
72 #include "BKE_tracking.h"
73 #include "BKE_gpencil.h"
76 #include "BLI_listbase.h"
77 #include "BLI_string.h"
79 #include "BLO_readfile.h"
81 #include "NOD_common.h"
82 #include "NOD_socket.h"
83 #include "NOD_composite.h"
87 #include "MEM_guardedalloc.h"
90 * Setup rotation stabilization from ancient single track spec.
91 * Former Version of 2D stabilization used a single tracking marker to determine the rotation
92 * to be compensated. Now several tracks can contribute to rotation detection and this feature
93 * is enabled by the MovieTrackingTrack#flag on a per track base.
95 static void migrate_single_rot_stabilization_track_settings(MovieTrackingStabilization *stab)
97 if (stab->rot_track) {
98 if (!(stab->rot_track->flag & TRACK_USE_2D_STAB_ROT)) {
99 stab->tot_rot_track++;
100 stab->rot_track->flag |= TRACK_USE_2D_STAB_ROT;
103 stab->rot_track = NULL; /* this field is now ignored */
106 static void do_version_constraints_radians_degrees_270_1(ListBase *lb)
110 for (con = lb->first; con; con = con->next) {
111 if (con->type == CONSTRAINT_TYPE_TRANSFORM) {
112 bTransformConstraint *data = (bTransformConstraint *)con->data;
113 const float deg_to_rad_f = DEG2RADF(1.0f);
115 if (data->from == TRANS_ROTATION) {
116 mul_v3_fl(data->from_min, deg_to_rad_f);
117 mul_v3_fl(data->from_max, deg_to_rad_f);
120 if (data->to == TRANS_ROTATION) {
121 mul_v3_fl(data->to_min, deg_to_rad_f);
122 mul_v3_fl(data->to_max, deg_to_rad_f);
128 static void do_version_constraints_radians_degrees_270_5(ListBase *lb)
132 for (con = lb->first; con; con = con->next) {
133 if (con->type == CONSTRAINT_TYPE_TRANSFORM) {
134 bTransformConstraint *data = (bTransformConstraint *)con->data;
136 if (data->from == TRANS_ROTATION) {
137 copy_v3_v3(data->from_min_rot, data->from_min);
138 copy_v3_v3(data->from_max_rot, data->from_max);
140 else if (data->from == TRANS_SCALE) {
141 copy_v3_v3(data->from_min_scale, data->from_min);
142 copy_v3_v3(data->from_max_scale, data->from_max);
145 if (data->to == TRANS_ROTATION) {
146 copy_v3_v3(data->to_min_rot, data->to_min);
147 copy_v3_v3(data->to_max_rot, data->to_max);
149 else if (data->to == TRANS_SCALE) {
150 copy_v3_v3(data->to_min_scale, data->to_min);
151 copy_v3_v3(data->to_max_scale, data->to_max);
157 static void do_version_constraints_stretch_to_limits(ListBase *lb)
161 for (con = lb->first; con; con = con->next) {
162 if (con->type == CONSTRAINT_TYPE_STRETCHTO) {
163 bStretchToConstraint *data = (bStretchToConstraint *)con->data;
164 data->bulge_min = 1.0f;
165 data->bulge_max = 1.0f;
170 static void do_version_action_editor_properties_region(ListBase *regionbase)
174 for (ar = regionbase->first; ar; ar = ar->next) {
175 if (ar->regiontype == RGN_TYPE_UI) {
179 else if (ar->regiontype == RGN_TYPE_WINDOW) {
180 /* add new region here */
181 ARegion *arnew = MEM_callocN(sizeof(ARegion), "buttons for action");
183 BLI_insertlinkbefore(regionbase, ar, arnew);
185 arnew->regiontype = RGN_TYPE_UI;
186 arnew->alignment = RGN_ALIGN_RIGHT;
187 arnew->flag = RGN_FLAG_HIDDEN;
194 static void do_version_bones_super_bbone(ListBase *lb)
196 for (Bone *bone = lb->first; bone; bone = bone->next) {
197 bone->scaleIn = 1.0f;
198 bone->scaleOut = 1.0f;
200 do_version_bones_super_bbone(&bone->childbase);
204 /* TODO(sergey): Consider making it somewhat more generic function in BLI_anim.h. */
205 static void anim_change_prop_name(FCurve *fcu,
207 const char *old_prop_name,
208 const char *new_prop_name)
210 const char *old_path = BLI_sprintfN("%s.%s", prefix, old_prop_name);
211 if (STREQ(fcu->rna_path, old_path)) {
212 MEM_freeN(fcu->rna_path);
213 fcu->rna_path = BLI_sprintfN("%s.%s", prefix, new_prop_name);
215 MEM_freeN((char *)old_path);
218 static void do_version_hue_sat_node(bNodeTree *ntree, bNode *node)
220 if (node->storage == NULL) {
224 /* Make sure new sockets are properly created. */
225 node_verify_socket_templates(ntree, node);
226 /* Convert value from old storage to new sockets. */
227 NodeHueSat *nhs = node->storage;
228 bNodeSocket *hue = nodeFindSocket(node, SOCK_IN, "Hue"),
229 *saturation = nodeFindSocket(node, SOCK_IN, "Saturation"),
230 *value = nodeFindSocket(node, SOCK_IN, "Value");
231 ((bNodeSocketValueFloat *)hue->default_value)->value = nhs->hue;
232 ((bNodeSocketValueFloat *)saturation->default_value)->value = nhs->sat;
233 ((bNodeSocketValueFloat *)value->default_value)->value = nhs->val;
234 /* Take care of possible animation. */
235 AnimData *adt = BKE_animdata_from_id(&ntree->id);
236 if (adt != NULL && adt->action != NULL) {
237 const char *prefix = BLI_sprintfN("nodes[\"%s\"]", node->name);
238 for (FCurve *fcu = adt->action->curves.first; fcu != NULL; fcu = fcu->next) {
239 if (STRPREFIX(fcu->rna_path, prefix)) {
240 anim_change_prop_name(fcu, prefix, "color_hue", "inputs[1].default_value");
241 anim_change_prop_name(fcu, prefix, "color_saturation", "inputs[2].default_value");
242 anim_change_prop_name(fcu, prefix, "color_value", "inputs[3].default_value");
245 MEM_freeN((char *)prefix);
247 /* Free storage, it is no longer used. */
248 MEM_freeN(node->storage);
249 node->storage = NULL;
252 static void do_versions_compositor_render_passes_storage(bNode *node)
255 const char *sockname;
256 for (bNodeSocket *sock = node->outputs.first; sock && pass_index < 31; sock = sock->next, pass_index++) {
257 if (sock->storage == NULL) {
258 NodeImageLayer *sockdata = MEM_callocN(sizeof(NodeImageLayer), "node image layer");
259 sock->storage = sockdata;
260 BLI_strncpy(sockdata->pass_name, node_cmp_rlayers_sock_to_pass(pass_index), sizeof(sockdata->pass_name));
262 if (pass_index == 0) sockname = "Image";
263 else if (pass_index == 1) sockname = "Alpha";
264 else sockname = node_cmp_rlayers_sock_to_pass(pass_index);
265 BLI_strncpy(sock->name, sockname, sizeof(sock->name));
270 static void do_versions_compositor_render_passes(bNodeTree *ntree)
272 for (bNode *node = ntree->nodes.first; node; node = node->next) {
273 if (node->type == CMP_NODE_R_LAYERS) {
274 /* First we make sure existing sockets have proper names.
275 * This is important because otherwise verification will
276 * drop links from sockets which were renamed.
278 do_versions_compositor_render_passes_storage(node);
279 /* Make sure new sockets are properly created. */
280 node_verify_socket_templates(ntree, node);
281 /* Make sure all possibly created sockets have proper storage. */
282 do_versions_compositor_render_passes_storage(node);
287 void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
289 if (!MAIN_VERSION_ATLEAST(main, 270, 0)) {
291 if (!DNA_struct_elem_find(fd->filesdna, "BevelModifierData", "float", "profile")) {
294 for (ob = main->object.first; ob; ob = ob->id.next) {
296 for (md = ob->modifiers.first; md; md = md->next) {
297 if (md->type == eModifierType_Bevel) {
298 BevelModifierData *bmd = (BevelModifierData *)md;
300 bmd->val_flags = MOD_BEVEL_AMT_OFFSET;
306 /* nodes don't use fixed node->id any more, clean up */
307 FOREACH_NODETREE(main, ntree, id) {
308 if (ntree->type == NTREE_COMPOSIT) {
310 for (node = ntree->nodes.first; node; node = node->next) {
311 if (ELEM(node->type, CMP_NODE_COMPOSITE, CMP_NODE_OUTPUT_FILE)) {
316 } FOREACH_NODETREE_END
321 for (screen = main->screen.first; screen; screen = screen->id.next) {
323 for (area = screen->areabase.first; area; area = area->next) {
324 SpaceLink *space_link;
325 for (space_link = area->spacedata.first; space_link; space_link = space_link->next) {
326 if (space_link->spacetype == SPACE_CLIP) {
327 SpaceClip *space_clip = (SpaceClip *) space_link;
328 if (space_clip->mode != SC_MODE_MASKEDIT) {
329 space_clip->mode = SC_MODE_TRACKING;
337 if (!DNA_struct_elem_find(fd->filesdna, "MovieTrackingSettings", "float", "default_weight")) {
339 for (clip = main->movieclip.first; clip; clip = clip->id.next) {
340 clip->tracking.settings.default_weight = 1.0f;
345 if (!MAIN_VERSION_ATLEAST(main, 270, 1)) {
349 /* Update Transform constraint (another deg -> rad stuff). */
350 for (ob = main->object.first; ob; ob = ob->id.next) {
351 do_version_constraints_radians_degrees_270_1(&ob->constraints);
354 /* Bones constraints! */
356 for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
357 do_version_constraints_radians_degrees_270_1(&pchan->constraints);
362 for (sce = main->scene.first; sce; sce = sce->id.next) {
363 if (sce->r.raytrace_structure == R_RAYSTRUCTURE_BLIBVH) {
364 sce->r.raytrace_structure = R_RAYSTRUCTURE_AUTO;
369 if (!MAIN_VERSION_ATLEAST(main, 270, 2)) {
372 /* Mesh smoothresh deg->rad. */
373 for (me = main->mesh.first; me; me = me->id.next) {
374 me->smoothresh = DEG2RADF(me->smoothresh);
378 if (!MAIN_VERSION_ATLEAST(main, 270, 3)) {
379 FreestyleLineStyle *linestyle;
381 for (linestyle = main->linestyle.first; linestyle; linestyle = linestyle->id.next) {
382 linestyle->flag |= LS_NO_SORTING;
383 linestyle->sort_key = LS_SORT_KEY_DISTANCE_FROM_CAMERA;
384 linestyle->integration_type = LS_INTEGRATION_MEAN;
388 if (!MAIN_VERSION_ATLEAST(main, 270, 4)) {
389 /* ui_previews were not handled correctly when copying areas, leading to corrupted files (see T39847).
390 * This will always reset situation to a valid state.
394 for (sc = main->screen.first; sc; sc = sc->id.next) {
396 for (sa = sc->areabase.first; sa; sa = sa->next) {
399 for (sl = sa->spacedata.first; sl; sl = sl->next) {
401 ListBase *lb = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase;
403 for (ar = lb->first; ar; ar = ar->next) {
404 BLI_listbase_clear(&ar->ui_previews);
411 if (!MAIN_VERSION_ATLEAST(main, 270, 5)) {
414 /* Update Transform constraint (again :|). */
415 for (ob = main->object.first; ob; ob = ob->id.next) {
416 do_version_constraints_radians_degrees_270_5(&ob->constraints);
419 /* Bones constraints! */
421 for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
422 do_version_constraints_radians_degrees_270_5(&pchan->constraints);
428 if (!MAIN_VERSION_ATLEAST(main, 271, 0)) {
429 if (!DNA_struct_elem_find(fd->filesdna, "Material", "int", "mode2")) {
432 for (ma = main->mat.first; ma; ma = ma->id.next)
433 ma->mode2 = MA_CASTSHADOW;
436 if (!DNA_struct_elem_find(fd->filesdna, "RenderData", "BakeData", "bake")) {
439 for (sce = main->scene.first; sce; sce = sce->id.next) {
440 sce->r.bake.flag = R_BAKE_CLEAR;
441 sce->r.bake.width = 512;
442 sce->r.bake.height = 512;
443 sce->r.bake.margin = 16;
444 sce->r.bake.normal_space = R_BAKE_SPACE_TANGENT;
445 sce->r.bake.normal_swizzle[0] = R_BAKE_POSX;
446 sce->r.bake.normal_swizzle[1] = R_BAKE_POSY;
447 sce->r.bake.normal_swizzle[2] = R_BAKE_POSZ;
448 BLI_strncpy(sce->r.bake.filepath, U.renderdir, sizeof(sce->r.bake.filepath));
450 sce->r.bake.im_format.planes = R_IMF_PLANES_RGBA;
451 sce->r.bake.im_format.imtype = R_IMF_IMTYPE_PNG;
452 sce->r.bake.im_format.depth = R_IMF_CHAN_DEPTH_8;
453 sce->r.bake.im_format.quality = 90;
454 sce->r.bake.im_format.compress = 15;
458 if (!DNA_struct_elem_find(fd->filesdna, "FreestyleLineStyle", "float", "texstep")) {
459 FreestyleLineStyle *linestyle;
461 for (linestyle = main->linestyle.first; linestyle; linestyle = linestyle->id.next) {
462 linestyle->flag |= LS_TEXTURE;
463 linestyle->texstep = 1.0;
469 for (scene = main->scene.first; scene; scene = scene->id.next) {
470 int num_layers = BLI_listbase_count(&scene->r.layers);
471 scene->r.actlay = min_ff(scene->r.actlay, num_layers - 1);
476 if (!MAIN_VERSION_ATLEAST(main, 271, 1)) {
477 if (!DNA_struct_elem_find(fd->filesdna, "Material", "float", "line_col[4]")) {
480 for (mat = main->mat.first; mat; mat = mat->id.next) {
481 mat->line_col[0] = mat->line_col[1] = mat->line_col[2] = 0.0f;
482 mat->line_col[3] = mat->alpha;
486 if (!DNA_struct_elem_find(fd->filesdna, "RenderData", "int", "preview_start_resolution")) {
488 for (scene = main->scene.first; scene; scene = scene->id.next) {
489 scene->r.preview_start_resolution = 64;
494 if (!MAIN_VERSION_ATLEAST(main, 271, 2)) {
495 /* init up & track axis property of trackto actuators */
498 for (ob = main->object.first; ob; ob = ob->id.next) {
500 for (act = ob->actuators.first; act; act = act->next) {
501 if (act->type == ACT_EDIT_OBJECT) {
502 bEditObjectActuator *eoact = act->data;
503 eoact->trackflag = ob->trackflag;
504 /* if trackflag is pointing +-Z axis then upflag should point Y axis.
505 * Rest of trackflag cases, upflag should be point z axis */
506 if ((ob->trackflag == OB_POSZ) || (ob->trackflag == OB_NEGZ)) {
517 if (!MAIN_VERSION_ATLEAST(main, 271, 3)) {
520 for (br = main->brush.first; br; br = br->id.next) {
521 br->fill_threshold = 0.2f;
524 if (!DNA_struct_elem_find(fd->filesdna, "BevelModifierData", "int", "mat")) {
526 for (ob = main->object.first; ob; ob = ob->id.next) {
529 for (md = ob->modifiers.first; md; md = md->next) {
530 if (md->type == eModifierType_Bevel) {
531 BevelModifierData *bmd = (BevelModifierData *)md;
539 if (!MAIN_VERSION_ATLEAST(main, 271, 6)) {
541 for (ob = main->object.first; ob; ob = ob->id.next) {
544 for (md = ob->modifiers.first; md; md = md->next) {
545 if (md->type == eModifierType_ParticleSystem) {
546 ParticleSystemModifierData *pmd = (ParticleSystemModifierData *)md;
547 if (pmd->psys && pmd->psys->clmd) {
548 pmd->psys->clmd->sim_parms->vel_damping = 1.0f;
555 if (!MAIN_VERSION_ATLEAST(main, 272, 0)) {
556 if (!DNA_struct_elem_find(fd->filesdna, "RenderData", "int", "preview_start_resolution")) {
558 for (scene = main->scene.first; scene; scene = scene->id.next) {
559 scene->r.preview_start_resolution = 64;
564 if (!MAIN_VERSION_ATLEAST(main, 272, 1)) {
566 for (br = main->brush.first; br; br = br->id.next) {
567 if ((br->ob_mode & OB_MODE_SCULPT) && ELEM(br->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_SNAKE_HOOK))
572 if (!MAIN_VERSION_ATLEAST(main, 272, 2)) {
573 if (!DNA_struct_elem_find(fd->filesdna, "Image", "float", "gen_color")) {
575 for (image = main->image.first; image != NULL; image = image->id.next) {
576 image->gen_color[3] = 1.0f;
580 if (!DNA_struct_elem_find(fd->filesdna, "bStretchToConstraint", "float", "bulge_min")) {
583 /* Update Transform constraint (again :|). */
584 for (ob = main->object.first; ob; ob = ob->id.next) {
585 do_version_constraints_stretch_to_limits(&ob->constraints);
588 /* Bones constraints! */
590 for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
591 do_version_constraints_stretch_to_limits(&pchan->constraints);
598 if (!MAIN_VERSION_ATLEAST(main, 273, 1)) {
599 #define BRUSH_RAKE (1 << 7)
600 #define BRUSH_RANDOM_ROTATION (1 << 25)
604 for (br = main->brush.first; br; br = br->id.next) {
605 if (br->flag & BRUSH_RAKE) {
606 br->mtex.brush_angle_mode |= MTEX_ANGLE_RAKE;
607 br->mask_mtex.brush_angle_mode |= MTEX_ANGLE_RAKE;
609 else if (br->flag & BRUSH_RANDOM_ROTATION) {
610 br->mtex.brush_angle_mode |= MTEX_ANGLE_RANDOM;
611 br->mask_mtex.brush_angle_mode |= MTEX_ANGLE_RANDOM;
613 br->mtex.random_angle = 2.0 * M_PI;
614 br->mask_mtex.random_angle = 2.0 * M_PI;
619 #undef BRUSH_RANDOM_ROTATION
621 /* Customizable Safe Areas */
622 if (!MAIN_VERSION_ATLEAST(main, 273, 2)) {
623 if (!DNA_struct_elem_find(fd->filesdna, "Scene", "DisplaySafeAreas", "safe_areas")) {
626 for (scene = main->scene.first; scene; scene = scene->id.next) {
627 copy_v2_fl2(scene->safe_areas.title, 3.5f / 100.0f, 3.5f / 100.0f);
628 copy_v2_fl2(scene->safe_areas.action, 10.0f / 100.0f, 5.0f / 100.0f);
629 copy_v2_fl2(scene->safe_areas.title_center, 17.5f / 100.0f, 5.0f / 100.0f);
630 copy_v2_fl2(scene->safe_areas.action_center, 15.0f / 100.0f, 5.0f / 100.0f);
635 if (!MAIN_VERSION_ATLEAST(main, 273, 3)) {
636 ParticleSettings *part;
637 for (part = main->particle.first; part; part = part->id.next) {
638 if (part->clumpcurve)
639 part->child_flag |= PART_CHILD_USE_CLUMP_CURVE;
640 if (part->roughcurve)
641 part->child_flag |= PART_CHILD_USE_ROUGH_CURVE;
645 if (!MAIN_VERSION_ATLEAST(main, 273, 6)) {
646 if (!DNA_struct_elem_find(fd->filesdna, "ClothSimSettings", "float", "bending_damping")) {
649 for (ob = main->object.first; ob; ob = ob->id.next) {
650 for (md = ob->modifiers.first; md; md = md->next) {
651 if (md->type == eModifierType_Cloth) {
652 ClothModifierData *clmd = (ClothModifierData *)md;
653 clmd->sim_parms->bending_damping = 0.5f;
655 else if (md->type == eModifierType_ParticleSystem) {
656 ParticleSystemModifierData *pmd = (ParticleSystemModifierData *)md;
657 if (pmd->psys->clmd) {
658 pmd->psys->clmd->sim_parms->bending_damping = 0.5f;
665 if (!DNA_struct_elem_find(fd->filesdna, "ParticleSettings", "float", "clump_noise_size")) {
666 ParticleSettings *part;
667 for (part = main->particle.first; part; part = part->id.next) {
668 part->clump_noise_size = 1.0f;
672 if (!DNA_struct_elem_find(fd->filesdna, "ParticleSettings", "int", "kink_extra_steps")) {
673 ParticleSettings *part;
674 for (part = main->particle.first; part; part = part->id.next) {
675 part->kink_extra_steps = 4;
679 if (!DNA_struct_elem_find(fd->filesdna, "MTex", "float", "kinkampfac")) {
680 ParticleSettings *part;
681 for (part = main->particle.first; part; part = part->id.next) {
683 for (a = 0; a < MAX_MTEX; a++) {
684 MTex *mtex = part->mtex[a];
686 mtex->kinkampfac = 1.0f;
692 if (!DNA_struct_elem_find(fd->filesdna, "HookModifierData", "char", "flag")) {
695 for (ob = main->object.first; ob; ob = ob->id.next) {
697 for (md = ob->modifiers.first; md; md = md->next) {
698 if (md->type == eModifierType_Hook) {
699 HookModifierData *hmd = (HookModifierData *)md;
700 hmd->falloff_type = eHook_Falloff_InvSquare;
706 if (!DNA_struct_elem_find(fd->filesdna, "NodePlaneTrackDeformData", "char", "flag")) {
707 FOREACH_NODETREE(main, ntree, id) {
708 if (ntree->type == NTREE_COMPOSIT) {
710 for (node = ntree->nodes.first; node; node = node->next) {
711 if (ELEM(node->type, CMP_NODE_PLANETRACKDEFORM)) {
712 NodePlaneTrackDeformData *data = node->storage;
714 data->motion_blur_samples = 16;
715 data->motion_blur_shutter = 0.5f;
723 if (!DNA_struct_elem_find(fd->filesdna, "Camera", "GPUDOFSettings", "gpu_dof")) {
725 for (ca = main->camera.first; ca; ca = ca->id.next) {
726 ca->gpu_dof.fstop = 128.0f;
727 ca->gpu_dof.focal_length = 1.0f;
728 ca->gpu_dof.focus_distance = 1.0f;
729 ca->gpu_dof.sensor = 1.0f;
734 if (!MAIN_VERSION_ATLEAST(main, 273, 8)) {
736 for (ob = main->object.first; ob != NULL; ob = ob->id.next) {
738 for (md = ob->modifiers.last; md != NULL; md = md->prev) {
739 if (modifier_unique_name(&ob->modifiers, md)) {
740 printf("Warning: Object '%s' had several modifiers with the "
741 "same name, renamed one of them to '%s'.\n",
742 ob->id.name + 2, md->name);
748 if (!MAIN_VERSION_ATLEAST(main, 273, 9)) {
754 /* Make sure sequencer preview area limits zoom */
755 for (scr = main->screen.first; scr; scr = scr->id.next) {
756 for (sa = scr->areabase.first; sa; sa = sa->next) {
757 for (sl = sa->spacedata.first; sl; sl = sl->next) {
758 if (sl->spacetype == SPACE_SEQ) {
759 for (ar = sl->regionbase.first; ar; ar = ar->next) {
760 if (ar->regiontype == RGN_TYPE_PREVIEW) {
761 ar->v2d.keepzoom |= V2D_LIMITZOOM;
762 ar->v2d.minzoom = 0.001f;
763 ar->v2d.maxzoom = 1000.0f;
773 if (!MAIN_VERSION_ATLEAST(main, 274, 1)) {
774 /* particle systems need to be forced to redistribute for jitter mode fix */
777 ParticleSystem *psys;
778 for (ob = main->object.first; ob; ob = ob->id.next) {
779 for (psys = ob->particlesystem.first; psys; psys = psys->next) {
780 if ((psys->pointcache->flag & PTCACHE_BAKED) == 0) {
781 psys->recalc |= PSYS_RECALC_RESET;
787 /* hysteresis setted to 10% but not actived */
788 if (!DNA_struct_elem_find(fd->filesdna, "LodLevel", "int", "obhysteresis")) {
790 for (ob = main->object.first; ob; ob = ob->id.next) {
792 for (level = ob->lodlevels.first; level; level = level->next) {
793 level->obhysteresis = 10;
798 if (!DNA_struct_elem_find(fd->filesdna, "GameData", "int", "scehysteresis")) {
800 for (scene = main->scene.first; scene; scene = scene->id.next) {
801 scene->gm.scehysteresis = 10;
806 if (!MAIN_VERSION_ATLEAST(main, 274, 2)) {
807 FOREACH_NODETREE(main, ntree, id) {
811 for (node = ntree->nodes.first; node; node = node->next) {
812 if (node->type == SH_NODE_MATERIAL) {
813 for (sock = node->inputs.first; sock; sock = sock->next) {
814 if (STREQ(sock->name, "Refl")) {
815 BLI_strncpy(sock->name, "DiffuseIntensity", sizeof(sock->name));
819 else if (node->type == SH_NODE_MATERIAL_EXT) {
820 for (sock = node->outputs.first; sock; sock = sock->next) {
821 if (STREQ(sock->name, "Refl")) {
822 BLI_strncpy(sock->name, "DiffuseIntensity", sizeof(sock->name));
824 else if (STREQ(sock->name, "Ray Mirror")) {
825 BLI_strncpy(sock->name, "Reflectivity", sizeof(sock->name));
830 } FOREACH_NODETREE_END
833 if (!MAIN_VERSION_ATLEAST(main, 274, 4)) {
834 SceneRenderView *srv;
842 for (scene = main->scene.first; scene; scene = scene->id.next) {
845 BKE_scene_add_render_view(scene, STEREO_LEFT_NAME);
846 srv = scene->r.views.first;
847 BLI_strncpy(srv->suffix, STEREO_LEFT_SUFFIX, sizeof(srv->suffix));
849 BKE_scene_add_render_view(scene, STEREO_RIGHT_NAME);
850 srv = scene->r.views.last;
851 BLI_strncpy(srv->suffix, STEREO_RIGHT_SUFFIX, sizeof(srv->suffix));
853 SEQ_BEGIN (scene->ed, seq)
855 seq->stereo3d_format = MEM_callocN(sizeof(Stereo3dFormat), "Stereo Display 3d Format");
857 #define SEQ_USE_PROXY_CUSTOM_DIR (1 << 19)
858 #define SEQ_USE_PROXY_CUSTOM_FILE (1 << 21)
859 if (seq->strip && seq->strip->proxy && !seq->strip->proxy->storage) {
860 if (seq->flag & SEQ_USE_PROXY_CUSTOM_DIR)
861 seq->strip->proxy->storage = SEQ_STORAGE_PROXY_CUSTOM_DIR;
862 if (seq->flag & SEQ_USE_PROXY_CUSTOM_FILE)
863 seq->strip->proxy->storage = SEQ_STORAGE_PROXY_CUSTOM_FILE;
865 #undef SEQ_USE_PROXY_CUSTOM_DIR
866 #undef SEQ_USE_PROXY_CUSTOM_FILE
872 for (screen = main->screen.first; screen; screen = screen->id.next) {
874 for (sa = screen->areabase.first; sa; sa = sa->next) {
877 for (sl = sa->spacedata.first; sl; sl = sl->next) {
878 switch (sl->spacetype) {
881 View3D *v3d = (View3D *)sl;
882 v3d->stereo3d_camera = STEREO_3D_ID;
883 v3d->stereo3d_flag |= V3D_S3D_DISPPLANE;
884 v3d->stereo3d_convergence_alpha = 0.15f;
885 v3d->stereo3d_volume_alpha = 0.05f;
890 SpaceImage *sima = (SpaceImage *) sl;
891 sima->iuser.flag |= IMA_SHOW_STEREO;
899 for (cam = main->camera.first; cam; cam = cam->id.next) {
900 cam->stereo.interocular_distance = 0.065f;
901 cam->stereo.convergence_distance = 30.0f * 0.065f;
904 for (ima = main->image.first; ima; ima = ima->id.next) {
905 ima->stereo3d_format = MEM_callocN(sizeof(Stereo3dFormat), "Image Stereo 3d Format");
907 if (ima->packedfile) {
908 ImagePackedFile *imapf = MEM_mallocN(sizeof(ImagePackedFile), "Image Packed File");
909 BLI_addtail(&ima->packedfiles, imapf);
911 imapf->packedfile = ima->packedfile;
912 BLI_strncpy(imapf->filepath, ima->name, FILE_MAX);
913 ima->packedfile = NULL;
917 for (wm = main->wm.first; wm; wm = wm->id.next) {
918 for (win = wm->windows.first; win; win = win->next) {
919 win->stereo3d_format = MEM_callocN(sizeof(Stereo3dFormat), "Stereo Display 3d Format");
924 if (!MAIN_VERSION_ATLEAST(main, 274, 6)) {
927 if (!DNA_struct_elem_find(fd->filesdna, "FileSelectParams", "int", "thumbnail_size")) {
928 for (screen = main->screen.first; screen; screen = screen->id.next) {
931 for (sa = screen->areabase.first; sa; sa = sa->next) {
934 for (sl = sa->spacedata.first; sl; sl = sl->next) {
935 if (sl->spacetype == SPACE_FILE) {
936 SpaceFile *sfile = (SpaceFile *)sl;
939 sfile->params->thumbnail_size = 128;
947 if (!DNA_struct_elem_find(fd->filesdna, "RenderData", "short", "simplify_subsurf_render")) {
949 for (scene = main->scene.first; scene != NULL; scene = scene->id.next) {
950 scene->r.simplify_subsurf_render = scene->r.simplify_subsurf;
951 scene->r.simplify_particles_render = scene->r.simplify_particles;
955 if (!DNA_struct_elem_find(fd->filesdna, "DecimateModifierData", "float", "defgrp_factor")) {
958 for (ob = main->object.first; ob; ob = ob->id.next) {
960 for (md = ob->modifiers.first; md; md = md->next) {
961 if (md->type == eModifierType_Decimate) {
962 DecimateModifierData *dmd = (DecimateModifierData *)md;
963 dmd->defgrp_factor = 1.0f;
970 if (!MAIN_VERSION_ATLEAST(main, 275, 3)) {
972 #define BRUSH_TORUS (1 << 1)
973 for (br = main->brush.first; br; br = br->id.next) {
974 br->flag &= ~BRUSH_TORUS;
979 if (!MAIN_VERSION_ATLEAST(main, 276, 2)) {
980 if (!DNA_struct_elem_find(fd->filesdna, "bPoseChannel", "float", "custom_scale")) {
983 for (ob = main->object.first; ob; ob = ob->id.next) {
986 for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
987 pchan->custom_scale = 1.0f;
995 #define RV3D_VIEW_PERSPORTHO 7
996 for (screen = main->screen.first; screen; screen = screen->id.next) {
998 for (sa = screen->areabase.first; sa; sa = sa->next) {
1000 for (sl = sa->spacedata.first; sl; sl = sl->next) {
1001 if (sl->spacetype == SPACE_VIEW3D) {
1003 ListBase *lb = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase;
1004 for (ar = lb->first; ar; ar = ar->next) {
1005 if (ar->regiontype == RGN_TYPE_WINDOW) {
1006 if (ar->regiondata) {
1007 RegionView3D *rv3d = ar->regiondata;
1008 if (rv3d->view == RV3D_VIEW_PERSPORTHO) {
1009 rv3d->view = RV3D_VIEW_USER;
1019 #undef RV3D_VIEW_PERSPORTHO
1024 #define LA_YF_PHOTON 5
1025 for (lamp = main->lamp.first; lamp; lamp = lamp->id.next) {
1026 if (lamp->type == LA_YF_PHOTON) {
1027 lamp->type = LA_LOCAL;
1035 for (ob = main->object.first; ob; ob = ob->id.next) {
1036 if (ob->body_type == OB_BODY_TYPE_CHARACTER && (ob->gameflag & OB_BOUNDS) && ob->collision_boundtype == OB_BOUND_TRIANGLE_MESH) {
1037 ob->boundtype = ob->collision_boundtype = OB_BOUND_BOX;
1044 if (!MAIN_VERSION_ATLEAST(main, 276, 3)) {
1045 if (!DNA_struct_elem_find(fd->filesdna, "RenderData", "CurveMapping", "mblur_shutter_curve")) {
1047 for (scene = main->scene.first; scene != NULL; scene = scene->id.next) {
1048 CurveMapping *curve_mapping = &scene->r.mblur_shutter_curve;
1049 curvemapping_set_defaults(curve_mapping, 1, 0.0f, 0.0f, 1.0f, 1.0f);
1050 curvemapping_initialize(curve_mapping);
1051 curvemap_reset(curve_mapping->cm,
1052 &curve_mapping->clipr,
1054 CURVEMAP_SLOPE_POS_NEG);
1059 if (!MAIN_VERSION_ATLEAST(main, 276, 4)) {
1060 for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
1061 ToolSettings *ts = scene->toolsettings;
1063 if (ts->gp_sculpt.brush[0].size == 0) {
1064 GP_BrushEdit_Settings *gset = &ts->gp_sculpt;
1065 GP_EditBrush_Data *brush;
1067 brush = &gset->brush[GP_EDITBRUSH_TYPE_SMOOTH];
1069 brush->strength = 0.3f;
1070 brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF | GP_EDITBRUSH_FLAG_SMOOTH_PRESSURE;
1072 brush = &gset->brush[GP_EDITBRUSH_TYPE_THICKNESS];
1074 brush->strength = 0.5f;
1075 brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF;
1077 brush = &gset->brush[GP_EDITBRUSH_TYPE_GRAB];
1079 brush->strength = 0.3f;
1080 brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF;
1082 brush = &gset->brush[GP_EDITBRUSH_TYPE_PUSH];
1084 brush->strength = 0.3f;
1085 brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF;
1087 brush = &gset->brush[GP_EDITBRUSH_TYPE_TWIST];
1089 brush->strength = 0.3f; // XXX?
1090 brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF;
1092 brush = &gset->brush[GP_EDITBRUSH_TYPE_PINCH];
1094 brush->strength = 0.5f; // XXX?
1095 brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF;
1097 brush = &gset->brush[GP_EDITBRUSH_TYPE_RANDOMIZE];
1099 brush->strength = 0.5f;
1100 brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF;
1102 brush = &gset->brush[GP_EDITBRUSH_TYPE_CLONE];
1104 brush->strength = 1.0f;
1107 if (!DNA_struct_elem_find(fd->filesdna, "ToolSettings", "char", "gpencil_v3d_align")) {
1108 #if 0 /* XXX: Cannot do this, as we get random crashes... */
1110 bGPdata *gpd = scene->gpd;
1112 /* Copy over the settings stored in the GP datablock linked to the scene, for minimal disruption */
1113 ts->gpencil_v3d_align = 0;
1115 if (gpd->flag & GP_DATA_VIEWALIGN) ts->gpencil_v3d_align |= GP_PROJECT_VIEWSPACE;
1116 if (gpd->flag & GP_DATA_DEPTH_VIEW) ts->gpencil_v3d_align |= GP_PROJECT_DEPTH_VIEW;
1117 if (gpd->flag & GP_DATA_DEPTH_STROKE) ts->gpencil_v3d_align |= GP_PROJECT_DEPTH_STROKE;
1119 if (gpd->flag & GP_DATA_DEPTH_STROKE_ENDPOINTS)
1120 ts->gpencil_v3d_align |= GP_PROJECT_DEPTH_STROKE_ENDPOINTS;
1123 /* Default to cursor for all standard 3D views */
1124 ts->gpencil_v3d_align = GP_PROJECT_VIEWSPACE;
1128 ts->gpencil_v3d_align = GP_PROJECT_VIEWSPACE;
1129 ts->gpencil_v2d_align = GP_PROJECT_VIEWSPACE;
1130 ts->gpencil_seq_align = GP_PROJECT_VIEWSPACE;
1131 ts->gpencil_ima_align = GP_PROJECT_VIEWSPACE;
1135 for (bGPdata *gpd = main->gpencil.first; gpd; gpd = gpd->id.next) {
1136 bool enabled = false;
1138 /* Ensure that the datablock's onionskinning toggle flag
1139 * stays in sync with the status of the actual layers
1141 for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
1142 if (gpl->flag & GP_LAYER_ONIONSKIN) {
1148 gpd->flag |= GP_DATA_SHOW_ONIONSKINS;
1150 gpd->flag &= ~GP_DATA_SHOW_ONIONSKINS;
1153 if (!DNA_struct_elem_find(fd->filesdna, "Object", "unsigned char", "max_jumps")) {
1154 for (Object *ob = main->object.first; ob; ob = ob->id.next) {
1159 if (!MAIN_VERSION_ATLEAST(main, 276, 5)) {
1160 ListBase *lbarray[MAX_LIBARRAY];
1163 /* Important to clear all non-persistent flags from older versions here, otherwise they could collide
1164 * with any new persistent flag we may add in the future. */
1165 a = set_listbasepointers(main, lbarray);
1167 for (ID *id = lbarray[a]->first; id; id = id->next) {
1168 id->flag &= LIB_FAKEUSER;
1173 if (!MAIN_VERSION_ATLEAST(main, 276, 7)) {
1175 for (scene = main->scene.first; scene != NULL; scene = scene->id.next) {
1176 scene->r.bake.pass_filter = R_BAKE_PASS_FILTER_ALL;
1180 if (!MAIN_VERSION_ATLEAST(main, 277, 1)) {
1181 for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
1182 ParticleEditSettings *pset = &scene->toolsettings->particle;
1183 for (int a = 0; a < PE_TOT_BRUSH; a++) {
1184 if (pset->brush[a].strength > 1.0f) {
1185 pset->brush[a].strength *= 0.01f;
1190 for (bScreen *screen = main->screen.first; screen; screen = screen->id.next) {
1191 for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
1192 for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
1193 ListBase *regionbase = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase;
1194 /* Bug: Was possible to add preview region to sequencer view by using AZones. */
1195 if (sl->spacetype == SPACE_SEQ) {
1196 SpaceSeq *sseq = (SpaceSeq *)sl;
1197 if (sseq->view == SEQ_VIEW_SEQUENCE) {
1198 for (ARegion *ar = regionbase->first; ar; ar = ar->next) {
1199 /* remove preview region for sequencer-only view! */
1200 if (ar->regiontype == RGN_TYPE_PREVIEW) {
1201 ar->flag |= RGN_FLAG_HIDDEN;
1202 ar->alignment = RGN_ALIGN_NONE;
1208 /* Remove old deprecated region from filebrowsers */
1209 else if (sl->spacetype == SPACE_FILE) {
1210 for (ARegion *ar = regionbase->first; ar; ar = ar->next) {
1211 if (ar->regiontype == RGN_TYPE_CHANNELS) {
1212 /* Free old deprecated 'channel' region... */
1213 BKE_area_region_free(NULL, ar);
1214 BLI_freelinkN(regionbase, ar);
1223 for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
1224 CurvePaintSettings *cps = &scene->toolsettings->curve_paint_settings;
1225 if (cps->error_threshold == 0) {
1226 cps->curve_type = CU_BEZIER;
1227 cps->flag |= CURVE_PAINT_FLAG_CORNERS_DETECT;
1228 cps->error_threshold = 8;
1229 cps->radius_max = 1.0f;
1230 cps->corner_angle = DEG2RADF(70.0f);
1234 for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
1237 SEQ_BEGIN (scene->ed, seq)
1239 if (seq->type == SEQ_TYPE_TEXT) {
1240 TextVars *data = seq->effectdata;
1241 if (data != NULL && data->color[3] == 0.0f) {
1242 copy_v4_fl(data->color, 1.0f);
1243 data->shadow_color[3] = 1.0f;
1250 /* Adding "Properties" region to DopeSheet */
1251 for (bScreen *screen = main->screen.first; screen; screen = screen->id.next) {
1252 for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
1253 /* handle pushed-back space data first */
1254 for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
1255 if (sl->spacetype == SPACE_ACTION) {
1256 SpaceAction *saction = (SpaceAction *)sl;
1257 do_version_action_editor_properties_region(&saction->regionbase);
1261 /* active spacedata info must be handled too... */
1262 if (sa->spacetype == SPACE_ACTION) {
1263 do_version_action_editor_properties_region(&sa->regionbase);
1269 if (!MAIN_VERSION_ATLEAST(main, 277, 2)) {
1270 if (!DNA_struct_elem_find(fd->filesdna, "Bone", "float", "scaleIn")) {
1271 for (bArmature *arm = main->armature.first; arm; arm = arm->id.next) {
1272 do_version_bones_super_bbone(&arm->bonebase);
1275 if (!DNA_struct_elem_find(fd->filesdna, "bPoseChannel", "float", "scaleIn")) {
1276 for (Object *ob = main->object.first; ob; ob = ob->id.next) {
1278 for (bPoseChannel *pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
1279 /* see do_version_bones_super_bbone()... */
1280 pchan->scaleIn = 1.0f;
1281 pchan->scaleOut = 1.0f;
1283 /* also make sure some legacy (unused for over a decade) flags are unset,
1284 * so that we can reuse them for stuff that matters now...
1285 * (i.e. POSE_IK_MAT, (unknown/unused x 4), POSE_HAS_IK)
1287 * These seem to have been runtime flags used by the IK solver, but that stuff
1288 * should be able to be recalculated automatically anyway, so it should be fine.
1290 pchan->flag &= ~((1 << 3) | (1 << 4) | (1 << 5) | (1 << 6) | (1 << 7) | (1 << 8));
1296 for (Camera *camera = main->camera.first; camera != NULL; camera = camera->id.next) {
1297 if (camera->stereo.pole_merge_angle_from == 0.0f &&
1298 camera->stereo.pole_merge_angle_to == 0.0f)
1300 camera->stereo.pole_merge_angle_from = DEG2RADF(60.0f);
1301 camera->stereo.pole_merge_angle_to = DEG2RADF(75.0f);
1305 if (!DNA_struct_elem_find(fd->filesdna, "NormalEditModifierData", "float", "mix_limit")) {
1308 for (ob = main->object.first; ob; ob = ob->id.next) {
1310 for (md = ob->modifiers.first; md; md = md->next) {
1311 if (md->type == eModifierType_NormalEdit) {
1312 NormalEditModifierData *nemd = (NormalEditModifierData *)md;
1313 nemd->mix_limit = DEG2RADF(180.0f);
1319 if (!DNA_struct_elem_find(fd->filesdna, "BooleanModifierData", "float", "double_threshold")) {
1321 for (ob = main->object.first; ob; ob = ob->id.next) {
1323 for (md = ob->modifiers.first; md; md = md->next) {
1324 if (md->type == eModifierType_Boolean) {
1325 BooleanModifierData *bmd = (BooleanModifierData *)md;
1326 bmd->double_threshold = 1e-6f;
1332 for (Brush *br = main->brush.first; br; br = br->id.next) {
1333 if (br->sculpt_tool == SCULPT_TOOL_FLATTEN) {
1334 br->flag |= BRUSH_ACCUMULATE;
1338 if (!DNA_struct_elem_find(fd->filesdna, "ClothSimSettings", "float", "time_scale")) {
1341 for (ob = main->object.first; ob; ob = ob->id.next) {
1342 for (md = ob->modifiers.first; md; md = md->next) {
1343 if (md->type == eModifierType_Cloth) {
1344 ClothModifierData *clmd = (ClothModifierData *)md;
1345 clmd->sim_parms->time_scale = 1.0f;
1347 else if (md->type == eModifierType_ParticleSystem) {
1348 ParticleSystemModifierData *pmd = (ParticleSystemModifierData *)md;
1349 if (pmd->psys->clmd) {
1350 pmd->psys->clmd->sim_parms->time_scale = 1.0f;
1358 if (!MAIN_VERSION_ATLEAST(main, 277, 3)) {
1359 /* ------- init of grease pencil initialization --------------- */
1360 if (!DNA_struct_elem_find(fd->filesdna, "bGPDstroke", "bGPDpalettecolor", "*palcolor")) {
1361 for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
1362 ToolSettings *ts = scene->toolsettings;
1363 /* initialize use position for sculpt brushes */
1364 ts->gp_sculpt.flag |= GP_BRUSHEDIT_FLAG_APPLY_POSITION;
1365 /* initialize selected vertices alpha factor */
1366 ts->gp_sculpt.alpha = 1.0f;
1368 /* new strength sculpt brush */
1369 if (ts->gp_sculpt.brush[0].size >= 11) {
1370 GP_BrushEdit_Settings *gset = &ts->gp_sculpt;
1371 GP_EditBrush_Data *brush;
1373 brush = &gset->brush[GP_EDITBRUSH_TYPE_STRENGTH];
1375 brush->strength = 0.5f;
1376 brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF;
1379 /* create a default grease pencil drawing brushes set */
1380 if (!BLI_listbase_is_empty(&main->gpencil)) {
1381 for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
1382 ToolSettings *ts = scene->toolsettings;
1383 if (BLI_listbase_is_empty(&ts->gp_brushes)) {
1384 BKE_gpencil_brush_init_presets(ts);
1388 /* Convert Grease Pencil to new palettes/brushes
1389 * Loop all strokes and create the palette and all colors
1391 for (bGPdata *gpd = main->gpencil.first; gpd; gpd = gpd->id.next) {
1392 if (BLI_listbase_is_empty(&gpd->palettes)) {
1393 /* create palette */
1394 bGPDpalette *palette = BKE_gpencil_palette_addnew(gpd, "GP_Palette", true);
1395 for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
1396 /* create color using layer name */
1397 bGPDpalettecolor *palcolor = BKE_gpencil_palettecolor_addnew(palette, gpl->info, true);
1398 if (palcolor != NULL) {
1399 /* set color attributes */
1400 copy_v4_v4(palcolor->color, gpl->color);
1401 copy_v4_v4(palcolor->fill, gpl->fill);
1403 if (gpl->flag & GP_LAYER_HIDE) palcolor->flag |= PC_COLOR_HIDE;
1404 if (gpl->flag & GP_LAYER_LOCKED) palcolor->flag |= PC_COLOR_LOCKED;
1405 if (gpl->flag & GP_LAYER_ONIONSKIN) palcolor->flag |= PC_COLOR_ONIONSKIN;
1406 if (gpl->flag & GP_LAYER_VOLUMETRIC) palcolor->flag |= PC_COLOR_VOLUMETRIC;
1407 if (gpl->flag & GP_LAYER_HQ_FILL) palcolor->flag |= PC_COLOR_HQ_FILL;
1409 /* set layer opacity to 1 */
1410 gpl->opacity = 1.0f;
1412 /* set tint color */
1413 ARRAY_SET_ITEMS(gpl->tintcolor, 0.0f, 0.0f, 0.0f, 0.0f);
1415 /* flush relevant layer-settings to strokes */
1416 for (bGPDframe *gpf = gpl->frames.first; gpf; gpf = gpf->next) {
1417 for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
1418 /* set stroke to palette and force recalculation */
1419 BLI_strncpy(gps->colorname, gpl->info, sizeof(gps->colorname));
1420 gps->palcolor = NULL;
1421 gps->flag |= GP_STROKE_RECALC_COLOR;
1422 gps->thickness = gpl->thickness;
1424 /* set alpha strength to 1 */
1425 for (int i = 0; i < gps->totpoints; i++) {
1426 gps->points[i].strength = 1.0f;
1432 /* set thickness to 0 (now it is a factor to override stroke thickness) */
1433 gpl->thickness = 0.0f;
1435 /* set first color as active */
1436 if (palette->colors.first)
1437 BKE_gpencil_palettecolor_setactive(palette, palette->colors.first);
1441 /* ------- end of grease pencil initialization --------------- */
1444 if (!MAIN_VERSION_ATLEAST(main, 278, 0)) {
1445 if (!DNA_struct_elem_find(fd->filesdna, "MovieTrackingTrack", "float", "weight_stab")) {
1447 for (clip = main->movieclip.first; clip; clip = clip->id.next) {
1448 MovieTracking *tracking = &clip->tracking;
1449 MovieTrackingObject *tracking_object;
1450 for (tracking_object = tracking->objects.first;
1451 tracking_object != NULL;
1452 tracking_object = tracking_object->next)
1454 ListBase *tracksbase = BKE_tracking_object_get_tracks(tracking, tracking_object);
1455 MovieTrackingTrack *track;
1456 for (track = tracksbase->first;
1458 track = track->next)
1460 track->weight_stab = track->weight;
1466 if (!DNA_struct_elem_find(fd->filesdna, "MovieTrackingStabilization", "int", "tot_rot_track")) {
1468 for (clip = main->movieclip.first; clip != NULL; clip = clip->id.next) {
1469 if (clip->tracking.stabilization.rot_track) {
1470 migrate_single_rot_stabilization_track_settings(&clip->tracking.stabilization);
1472 if (clip->tracking.stabilization.scale == 0.0f) {
1474 * Was previously used for autoscale only,
1475 * now used always (as "target scale") */
1476 clip->tracking.stabilization.scale = 1.0f;
1478 /* blender prefers 1-based frame counting;
1479 * thus using frame 1 as reference typically works best */
1480 clip->tracking.stabilization.anchor_frame = 1;
1481 /* by default show the track lists expanded, to improve "discoverability" */
1482 clip->tracking.stabilization.flag |= TRACKING_SHOW_STAB_TRACKS;
1483 /* deprecated, not used anymore */
1484 clip->tracking.stabilization.ok = false;
1488 if (!MAIN_VERSION_ATLEAST(main, 278, 2)) {
1489 if (!DNA_struct_elem_find(fd->filesdna, "FFMpegCodecData", "int", "ffmpeg_preset")) {
1490 for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
1491 /* "medium" is the preset FFmpeg uses when no presets are given. */
1492 scene->r.ffcodecdata.ffmpeg_preset = FFM_PRESET_MEDIUM;
1495 if (!DNA_struct_elem_find(fd->filesdna, "FFMpegCodecData", "int", "constant_rate_factor")) {
1496 for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
1497 /* fall back to behaviour from before we introduced CRF for old files */
1498 scene->r.ffcodecdata.constant_rate_factor = FFM_CRF_NONE;
1502 if (!DNA_struct_elem_find(fd->filesdna, "SmokeModifierData", "float", "slice_per_voxel")) {
1506 for (ob = main->object.first; ob; ob = ob->id.next) {
1507 for (md = ob->modifiers.first; md; md = md->next) {
1508 if (md->type == eModifierType_Smoke) {
1509 SmokeModifierData *smd = (SmokeModifierData *)md;
1511 smd->domain->slice_per_voxel = 5.0f;
1512 smd->domain->slice_depth = 0.5f;
1513 smd->domain->display_thickness = 1.0f;
1521 if (!MAIN_VERSION_ATLEAST(main, 278, 3)) {
1522 for (Scene *scene = main->scene.first; scene != NULL; scene = scene->id.next) {
1523 if (scene->toolsettings != NULL) {
1524 ToolSettings *ts = scene->toolsettings;
1525 ParticleEditSettings *pset = &ts->particle;
1526 for (int a = 0; a < PE_TOT_BRUSH; a++) {
1527 if (pset->brush[a].count == 0) {
1528 pset->brush[a].count = 10;
1534 if (!DNA_struct_elem_find(fd->filesdna, "RigidBodyCon", "float", "spring_stiffness_ang_x")) {
1536 for (ob = main->object.first; ob; ob = ob->id.next) {
1537 RigidBodyCon *rbc = ob->rigidbody_constraint;
1539 rbc->spring_stiffness_ang_x = 10.0;
1540 rbc->spring_stiffness_ang_y = 10.0;
1541 rbc->spring_stiffness_ang_z = 10.0;
1542 rbc->spring_damping_ang_x = 0.5;
1543 rbc->spring_damping_ang_y = 0.5;
1544 rbc->spring_damping_ang_z = 0.5;
1549 /* constant detail for sculpting is now a resolution value instead of
1550 * a percentage, we reuse old DNA struct member but convert it */
1551 for (Scene *scene = main->scene.first; scene != NULL; scene = scene->id.next) {
1552 if (scene->toolsettings != NULL) {
1553 ToolSettings *ts = scene->toolsettings;
1554 if (ts->sculpt && ts->sculpt->constant_detail != 0.0f) {
1555 ts->sculpt->constant_detail = 100.0f / ts->sculpt->constant_detail;
1561 if (!MAIN_VERSION_ATLEAST(main, 278, 4)) {
1562 const float sqrt_3 = (float)M_SQRT3;
1563 for (Brush *br = main->brush.first; br; br = br->id.next) {
1564 br->fill_threshold /= sqrt_3;
1567 /* Custom motion paths */
1568 if (!DNA_struct_elem_find(fd->filesdna, "bMotionPath", "int", "line_thickness")) {
1570 for (ob = main->object.first; ob; ob = ob->id.next) {
1572 bPoseChannel *pchan;
1575 mpath->color[0] = 1.0f;
1576 mpath->color[1] = 0.0f;
1577 mpath->color[2] = 0.0f;
1578 mpath->line_thickness = 1;
1579 mpath->flag |= MOTIONPATH_FLAG_LINES;
1581 /* bones motion path */
1583 for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
1584 mpath = pchan->mpath;
1586 mpath->color[0] = 1.0f;
1587 mpath->color[1] = 0.0f;
1588 mpath->color[2] = 0.0f;
1589 mpath->line_thickness = 1;
1590 mpath->flag |= MOTIONPATH_FLAG_LINES;
1598 if (!MAIN_VERSION_ATLEAST(main, 278, 5)) {
1599 /* Mask primitive adding code was not initializing correctly id_type of its points' parent. */
1600 for (Mask *mask = main->mask.first; mask; mask = mask->id.next) {
1601 for (MaskLayer *mlayer = mask->masklayers.first; mlayer; mlayer = mlayer->next) {
1602 for (MaskSpline *mspline = mlayer->splines.first; mspline; mspline = mspline->next) {
1604 for (MaskSplinePoint *mspoint = mspline->points; i < mspline->tot_point; mspoint++, i++) {
1605 if (mspoint->parent.id_type == 0) {
1606 BKE_mask_parent_init(&mspoint->parent);
1613 /* Fix for T50736, Glare comp node using same var for two different things. */
1614 if (!DNA_struct_elem_find(fd->filesdna, "NodeGlare", "char", "star_45")) {
1615 FOREACH_NODETREE(main, ntree, id) {
1616 if (ntree->type == NTREE_COMPOSIT) {
1617 ntreeSetTypes(NULL, ntree);
1618 for (bNode *node = ntree->nodes.first; node; node = node->next) {
1619 if (node->type == CMP_NODE_GLARE) {
1620 NodeGlare *ndg = node->storage;
1621 switch (ndg->type) {
1622 case 2: /* Grrrr! magic numbers :( */
1623 ndg->streaks = ndg->angle;
1626 ndg->star_45 = ndg->angle != 0;
1634 } FOREACH_NODETREE_END
1637 if (!DNA_struct_elem_find(fd->filesdna, "SurfaceDeformModifierData", "float", "mat[4][4]")) {
1638 for (Object *ob = main->object.first; ob; ob = ob->id.next) {
1639 for (ModifierData *md = ob->modifiers.first; md; md = md->next) {
1640 if (md->type == eModifierType_SurfaceDeform) {
1641 SurfaceDeformModifierData *smd = (SurfaceDeformModifierData *)md;
1648 FOREACH_NODETREE(main, ntree, id) {
1649 if (ntree->type == NTREE_COMPOSIT) {
1650 do_versions_compositor_render_passes(ntree);
1652 } FOREACH_NODETREE_END
1656 for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
1657 if (scene->r.im_format.exr_codec == R_IMF_EXR_CODEC_DWAB) {
1658 scene->r.im_format.exr_codec = R_IMF_EXR_CODEC_DWAA;
1662 /* Fix related to VGroup modifiers creating named defgroup CD layers! See T51520. */
1663 for (Mesh *me = main->mesh.first; me; me = me->id.next) {
1664 CustomData_set_layer_name(&me->vdata, CD_MDEFORMVERT, 0, "");
1669 void do_versions_after_linking_270(Main *main)
1671 /* To be added to next subversion bump! */
1673 FOREACH_NODETREE(main, ntree, id) {
1674 if (ntree->type == NTREE_COMPOSIT) {
1675 ntreeSetTypes(NULL, ntree);
1676 for (bNode *node = ntree->nodes.first; node; node = node->next) {
1677 if (node->type == CMP_NODE_HUE_SAT) {
1678 do_version_hue_sat_node(ntree, node);
1682 } FOREACH_NODETREE_END