Fix hair random rotation limited to 180 degrees
[blender.git] / source / blender / blenloader / intern / versioning_270.c
index 572566df6a2e76a1b428cccd321939038a92bb3a..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"
@@ -456,10 +465,10 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
                        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)) {
@@ -562,6 +571,16 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
                        }
                        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 (!MAIN_VERSION_ATLEAST(main, 273, 7)) {
@@ -591,4 +610,201 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
                        }
                }
        }
+
+       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 (!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, 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) {
+                       part->randphasefac *= 0.5f;
+               }
+       }
 }