Fix hair random rotation limited to 180 degrees
[blender.git] / source / blender / blenloader / intern / versioning_270.c
index 652a4525a7ea2bf96b13089567f3b1cefae516ba..49e81b1cfff2940fcd4d8d5655d0b7af07db9e38 100644 (file)
@@ -27,6 +27,7 @@
 
 #include "BLI_utildefines.h"
 #include "BLI_compiler_attrs.h"
+#include "BLI_string.h"
 
 /* for MinGW32 definition of NULL, could use BLI_blenlib.h instead too */
 #include <stddef.h>
 #define DNA_DEPRECATED_ALLOW
 
 #include "DNA_brush_types.h"
+#include "DNA_camera_types.h"
 #include "DNA_cloth_types.h"
 #include "DNA_constraint_types.h"
 #include "DNA_sdna_types.h"
+#include "DNA_sequence_types.h"
 #include "DNA_space_types.h"
 #include "DNA_screen_types.h"
 #include "DNA_object_types.h"
 #include "DNA_particle_types.h"
 #include "DNA_linestyle_types.h"
 #include "DNA_actuator_types.h"
+#include "DNA_camera_types.h"
+#include "DNA_view3d_types.h"
 
 #include "DNA_genfile.h"
 
 #include "BKE_main.h"
+#include "BKE_modifier.h"
 #include "BKE_node.h"
+#include "BKE_scene.h"
+#include "BKE_sequencer.h"
+#include "BKE_screen.h"
+#include "BKE_sequencer.h"
 
 #include "BLI_math.h"
 #include "BLI_listbase.h"
@@ -60,6 +70,7 @@
 
 #include "readfile.h"
 
+#include "MEM_guardedalloc.h"
 
 static void do_version_constraints_radians_degrees_270_1(ListBase *lb)
 {
@@ -451,13 +462,13 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
                                br->mtex.brush_angle_mode |= MTEX_ANGLE_RANDOM;
                                br->mask_mtex.brush_angle_mode |= MTEX_ANGLE_RANDOM;
                        }
-                       br->mtex.random_angle = 2.0f * M_PI;
-                       br->mask_mtex.random_angle = 2.0f * M_PI;
+                       br->mtex.random_angle = 2.0 * M_PI;
+                       br->mask_mtex.random_angle = 2.0 * M_PI;
                }
+       }
 
 #undef BRUSH_RAKE
 #undef BRUSH_RANDOM_ROTATION
-       }
 
        /* Customizable Safe Areas */
        if (!MAIN_VERSION_ATLEAST(main, 273, 2)) {
@@ -473,59 +484,327 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
                }
        }
        
-       if (!DNA_struct_elem_find(fd->filesdna, "ClothSimSettings", "float", "bending_damping")) {
-               Object *ob;
-               ModifierData *md;
-               for (ob = main->object.first; ob; ob = ob->id.next) {
-                       for (md = ob->modifiers.first; md; md = md->next) {
-                               if (md->type == eModifierType_Cloth) {
-                                       ClothModifierData *clmd = (ClothModifierData *)md;
-                                       clmd->sim_parms->bending_damping = 0.5f;
+       if (!MAIN_VERSION_ATLEAST(main, 273, 3)) {
+               ParticleSettings *part;
+               for (part = main->particle.first; part; part = part->id.next) {
+                       if (part->clumpcurve)
+                               part->child_flag |= PART_CHILD_USE_CLUMP_CURVE;
+                       if (part->roughcurve)
+                               part->child_flag |= PART_CHILD_USE_ROUGH_CURVE;
+               }
+       }
+
+       if (!MAIN_VERSION_ATLEAST(main, 273, 6)) {
+               if (!DNA_struct_elem_find(fd->filesdna, "ClothSimSettings", "float", "bending_damping")) {
+                       Object *ob;
+                       ModifierData *md;
+                       for (ob = main->object.first; ob; ob = ob->id.next) {
+                               for (md = ob->modifiers.first; md; md = md->next) {
+                                       if (md->type == eModifierType_Cloth) {
+                                               ClothModifierData *clmd = (ClothModifierData *)md;
+                                               clmd->sim_parms->bending_damping = 0.5f;
+                                       }
+                                       else if (md->type == eModifierType_ParticleSystem) {
+                                               ParticleSystemModifierData *pmd = (ParticleSystemModifierData *)md;
+                                               if (pmd->psys->clmd) {
+                                                       pmd->psys->clmd->sim_parms->bending_damping = 0.5f;
+                                               }
+                                       }
                                }
-                               else if (md->type == eModifierType_ParticleSystem) {
-                                       ParticleSystemModifierData *pmd = (ParticleSystemModifierData *)md;
-                                       if (pmd->psys->clmd) {
-                                               pmd->psys->clmd->sim_parms->bending_damping = 0.5f;
+                       }
+               }
+
+               if (!DNA_struct_elem_find(fd->filesdna, "ParticleSettings", "float", "clump_noise_size")) {
+                       ParticleSettings *part;
+                       for (part = main->particle.first; part; part = part->id.next) {
+                               part->clump_noise_size = 1.0f;
+                       }
+               }
+
+               if (!DNA_struct_elem_find(fd->filesdna, "ParticleSettings", "int", "kink_extra_steps")) {
+                       ParticleSettings *part;
+                       for (part = main->particle.first; part; part = part->id.next) {
+                               part->kink_extra_steps = 4;
+                       }
+               }
+
+               if (!DNA_struct_elem_find(fd->filesdna, "MTex", "float", "kinkampfac")) {
+                       ParticleSettings *part;
+                       for (part = main->particle.first; part; part = part->id.next) {
+                               int a;
+                               for (a = 0; a < MAX_MTEX; a++) {
+                                       MTex *mtex = part->mtex[a];
+                                       if (mtex) {
+                                               mtex->kinkampfac = 1.0f;
+                                       }
+                               }
+                       }
+               }
+
+               if (!DNA_struct_elem_find(fd->filesdna, "HookModifierData", "char", "flag")) {
+                       Object *ob;
+
+                       for (ob = main->object.first; ob; ob = ob->id.next) {
+                               ModifierData *md;
+                               for (md = ob->modifiers.first; md; md = md->next) {
+                                       if (md->type == eModifierType_Hook) {
+                                               HookModifierData *hmd = (HookModifierData *)md;
+                                               hmd->falloff_type = eHook_Falloff_InvSquare;
+                                       }
+                               }
+                       }
+               }
+
+               if (!DNA_struct_elem_find(fd->filesdna, "NodePlaneTrackDeformData", "char", "flag")) {
+                       FOREACH_NODETREE(main, ntree, id) {
+                               if (ntree->type == NTREE_COMPOSIT) {
+                                       bNode *node;
+                                       for (node = ntree->nodes.first; node; node = node->next) {
+                                               if (ELEM(node->type, CMP_NODE_PLANETRACKDEFORM)) {
+                                                       NodePlaneTrackDeformData *data = node->storage;
+                                                       data->flag = 0;
+                                                       data->motion_blur_samples = 16;
+                                                       data->motion_blur_shutter = 0.5f;
+                                               }
                                        }
                                }
                        }
+                       FOREACH_NODETREE_END
+               }
+
+               if (!DNA_struct_elem_find(fd->filesdna, "Camera", "GPUDOFSettings", "gpu_dof")) {
+                       Camera *ca;
+                       for (ca = main->camera.first; ca; ca = ca->id.next) {
+                               ca->gpu_dof.fstop = 128.0f;
+                               ca->gpu_dof.focal_length = 1.0f;
+                               ca->gpu_dof.focus_distance = 1.0f;
+                               ca->gpu_dof.sensor = 1.0f;
+                       }
                }
        }
 
-       if (!DNA_struct_elem_find(fd->filesdna, "ParticleSettings", "float", "clump_noise_size")) {
-               ParticleSettings *part;
-               for (part = main->particle.first; part; part = part->id.next) {
-                       part->clump_noise_size = 1.0f;
+       if (!MAIN_VERSION_ATLEAST(main, 273, 7)) {
+               bScreen *scr;
+               ScrArea *sa;
+               SpaceLink *sl;
+               ARegion *ar;
+
+               for (scr = main->screen.first; scr; scr = scr->id.next) {
+                       /* Remove old deprecated region from filebrowsers */
+                       for (sa = scr->areabase.first; sa; sa = sa->next) {
+                               for (sl = sa->spacedata.first; sl; sl = sl->next) {
+                                       if (sl->spacetype == SPACE_FILE) {
+                                               for (ar = sl->regionbase.first; ar; ar = ar->next) {
+                                                       if (ar->regiontype == RGN_TYPE_CHANNELS) {
+                                                               break;
+                                                       }
+                                               }
+
+                                               if (ar) {
+                                                       /* Free old deprecated 'channel' region... */
+                                                       BKE_area_region_free(NULL, ar);
+                                                       BLI_freelinkN(&sl->regionbase, ar);
+                                               }
+                                       }
+                               }
+                       }
                }
        }
 
-       if (!DNA_struct_elem_find(fd->filesdna, "ParticleSettings", "int", "kink_extra_steps")) {
-               ParticleSettings *part;
-               for (part = main->particle.first; part; part = part->id.next) {
-                       part->kink_extra_steps = 4;
+       if (!MAIN_VERSION_ATLEAST(main, 273, 8)) {
+               Object *ob;
+               for (ob = main->object.first; ob != NULL; ob = ob->id.next) {
+                       ModifierData *md;
+                       for (md = ob->modifiers.last; md != NULL; md = md->prev) {
+                               if (modifier_unique_name(&ob->modifiers, md)) {
+                                       printf("Warning: Object '%s' had several modifiers with the "
+                                              "same name, renamed one of them to '%s'.\n",
+                                              ob->id.name + 2, md->name);
+                               }
+                       }
                }
        }
 
-       if (!DNA_struct_elem_find(fd->filesdna, "MTex", "float", "kinkampfac")) {
-               ParticleSettings *part;
-               for (part = main->particle.first; part; part = part->id.next) {
-                       int a;
-                       for (a = 0; a < MAX_MTEX; a++) {
-                               MTex *mtex = part->mtex[a];
-                               if (mtex) {
-                                       mtex->kinkampfac = 1.0f;
+       if (!MAIN_VERSION_ATLEAST(main, 273, 9)) {
+               bScreen *scr;
+               ScrArea *sa;
+               SpaceLink *sl;
+               ARegion *ar;
+
+               /* Make sure sequencer preview area limits zoom */
+               for (scr = main->screen.first; scr; scr = scr->id.next) {
+                       for (sa = scr->areabase.first; sa; sa = sa->next) {
+                               for (sl = sa->spacedata.first; sl; sl = sl->next) {
+                                       if (sl->spacetype == SPACE_SEQ) {
+                                               for (ar = sl->regionbase.first; ar; ar = ar->next) {
+                                                       if (ar->regiontype == RGN_TYPE_PREVIEW) {
+                                                               ar->v2d.keepzoom |= V2D_LIMITZOOM;
+                                                               ar->v2d.minzoom = 0.001f;
+                                                               ar->v2d.maxzoom = 1000.0f;
+                                                               break;
+                                                       }
+                                               }
+                                       }
                                }
                        }
                }
        }
 
-       if (!MAIN_VERSION_ATLEAST(main, 273, 3)) {
+       if (!MAIN_VERSION_ATLEAST(main, 274, 1)) {
+               /* particle systems need to be forced to redistribute for jitter mode fix */
+               {
+                       Object *ob;
+                       ParticleSystem *psys;
+                       for (ob = main->object.first; ob; ob = ob->id.next) {
+                               for (psys = ob->particlesystem.first; psys; psys = psys->next) {
+                                       psys->recalc |= PSYS_RECALC_RESET;
+                               }
+                       }
+               }
+
+               /* hysteresis setted to 10% but not actived */
+               if (!DNA_struct_elem_find(fd->filesdna, "LodLevel", "int", "obhysteresis")) {
+                       Object *ob;
+                       for (ob = main->object.first; ob; ob = ob->id.next) {
+                               LodLevel *level;
+                               for (level = ob->lodlevels.first; level; level = level->next) {
+                                       level->obhysteresis = 10;
+                               }
+                       }
+               }
+
+               if (!DNA_struct_elem_find(fd->filesdna, "GameData", "int", "scehysteresis")) {
+                       Scene *scene;
+                       for (scene = main->scene.first; scene; scene = scene->id.next) {
+                               scene->gm.scehysteresis = 10;
+                       }
+               }
+       }
+
+       if (!MAIN_VERSION_ATLEAST(main, 274, 2)) {
+               FOREACH_NODETREE(main, ntree, id) {
+                       bNode *node;
+                       bNodeSocket *sock;
+
+                       for (node = ntree->nodes.first; node; node = node->next) {
+                               if (node->type == SH_NODE_MATERIAL) {
+                                       for (sock = node->inputs.first; sock; sock = sock->next) {
+                                               if (STREQ(sock->name, "Refl")) {
+                                                       BLI_strncpy(sock->name, "DiffuseIntensity", sizeof(sock->name));
+                                               }
+                                       }
+                               }
+                               else if (node->type == SH_NODE_MATERIAL_EXT) {
+                                       for (sock = node->outputs.first; sock; sock = sock->next) {
+                                               if (STREQ(sock->name, "Refl")) {
+                                                       BLI_strncpy(sock->name, "DiffuseIntensity", sizeof(sock->name));
+                                               }
+                                               else if (STREQ(sock->name, "Ray Mirror")) {
+                                                       BLI_strncpy(sock->name, "Reflectivity", sizeof(sock->name));
+                                               }
+                                       }
+                               }
+                       }
+               } FOREACH_NODETREE_END
+       }
+
+       if (!MAIN_VERSION_ATLEAST(main, 274, 4)) {
+               SceneRenderView *srv;
+               wmWindowManager *wm;
+               bScreen *screen;
+               wmWindow *win;
+               Scene *scene;
+               Camera *cam;
+               Image *ima;
+
+               for (scene = main->scene.first; scene; scene = scene->id.next) {
+                       Sequence *seq;
+
+                       BKE_scene_add_render_view(scene, STEREO_LEFT_NAME);
+                       srv = scene->r.views.first;
+                       BLI_strncpy(srv->suffix, STEREO_LEFT_SUFFIX, sizeof(srv->suffix));
+
+                       BKE_scene_add_render_view(scene, STEREO_RIGHT_NAME);
+                       srv = scene->r.views.last;
+                       BLI_strncpy(srv->suffix, STEREO_RIGHT_SUFFIX, sizeof(srv->suffix));
+
+                       SEQ_BEGIN (scene->ed, seq)
+                       {
+                               seq->stereo3d_format = MEM_callocN(sizeof(Stereo3dFormat), "Stereo Display 3d Format");
+
+#define SEQ_USE_PROXY_CUSTOM_DIR (1 << 19)
+#define SEQ_USE_PROXY_CUSTOM_FILE (1 << 21)
+                               if (seq->strip && seq->strip->proxy && !seq->strip->proxy->storage) {
+                                       if (seq->flag & SEQ_USE_PROXY_CUSTOM_DIR)
+                                               seq->strip->proxy->storage = SEQ_STORAGE_PROXY_CUSTOM_DIR;
+                                       if (seq->flag & SEQ_USE_PROXY_CUSTOM_FILE)
+                                               seq->strip->proxy->storage = SEQ_STORAGE_PROXY_CUSTOM_FILE;
+                               }
+#undef SEQ_USE_PROXY_CUSTOM_DIR
+#undef SEQ_USE_PROXY_CUSTOM_FILE
+
+                       }
+                       SEQ_END
+               }
+
+               for (screen = main->screen.first; screen; screen = screen->id.next) {
+                       ScrArea *sa;
+                       for (sa = screen->areabase.first; sa; sa = sa->next) {
+                               SpaceLink *sl;
+
+                               for (sl = sa->spacedata.first; sl; sl = sl->next) {
+                                       switch (sl->spacetype) {
+                                               case SPACE_VIEW3D:
+                                               {
+                                                       View3D *v3d = (View3D *)sl;
+                                                       v3d->stereo3d_camera = STEREO_3D_ID;
+                                                       v3d->stereo3d_flag |= V3D_S3D_DISPPLANE;
+                                                       v3d->stereo3d_convergence_alpha = 0.15f;
+                                                       v3d->stereo3d_volume_alpha = 0.05f;
+                                                       break;
+                                               }
+                                               case SPACE_IMAGE:
+                                               {
+                                                       SpaceImage *sima = (SpaceImage *) sl;
+                                                       sima->iuser.flag |= IMA_SHOW_STEREO;
+                                                       sima->iuser.passtype = SCE_PASS_COMBINED;
+                                                       break;
+                                               }
+                                       }
+                               }
+                       }
+               }
+
+               for (cam = main->camera.first; cam; cam = cam->id.next) {
+                       cam->stereo.interocular_distance = 0.065;
+                       cam->stereo.convergence_distance = 30.f * 0.065;
+               }
+
+               for (ima = main->image.first; ima; ima = ima->id.next) {
+                       ima->stereo3d_format = MEM_callocN(sizeof(Stereo3dFormat), "Image Stereo 3d Format");
+
+                       if (ima->packedfile) {
+                               ImagePackedFile *imapf = MEM_mallocN(sizeof(ImagePackedFile), "Image Packed File");
+                               BLI_addtail(&ima->packedfiles, imapf);
+
+                               imapf->packedfile = ima->packedfile;
+                               BLI_strncpy(imapf->filepath, ima->name, FILE_MAX);
+                               ima->packedfile = NULL;
+                       }
+               }
+
+               for (wm = main->wm.first; wm; wm = wm->id.next) {
+                       for (win = wm->windows.first; win; win = win->next) {
+                               win->stereo3d_format = MEM_callocN(sizeof(Stereo3dFormat), "Stereo Display 3d Format");
+                       }
+               }
+       }
+
+       if (!MAIN_VERSION_ATLEAST(main, 274, 5)) {
+               /* Particle random phase range doubled. */
                ParticleSettings *part;
                for (part = main->particle.first; part; part = part->id.next) {
-                       if (part->clumpcurve)
-                               part->child_flag |= PART_CHILD_USE_CLUMP_CURVE;
-                       if (part->roughcurve)
-                               part->child_flag |= PART_CHILD_USE_ROUGH_CURVE;
+                       part->randphasefac *= 0.5f;
                }
        }
 }