Hopefully a working merge with trunk (could be one error left in raytrace.c - will...
[blender.git] / source / blender / blenloader / intern / readfile.c
index c88e06a9993d2a37770dd2497a4e74203390abd7..59c11297478f75991b238741a00550ee7a9562af 100644 (file)
@@ -2505,6 +2505,7 @@ static void lib_link_texture(FileData *fd, Main *main)
                        tex->ima= newlibadr_us(fd, tex->id.lib, tex->ima);
                        tex->ipo= newlibadr_us(fd, tex->id.lib, tex->ipo);
                        if(tex->env) tex->env->object= newlibadr(fd, tex->id.lib, tex->env->object);
+                       if(tex->pd) tex->pd->object= newlibadr(fd, tex->id.lib, tex->pd->object);
 
                        if(tex->nodetree)
                                lib_link_ntree(fd, &tex->id, tex->nodetree);
@@ -2534,6 +2535,17 @@ static void direct_link_texture(FileData *fd, Tex *tex)
                memset(tex->env->cube, 0, 6*sizeof(void *));
                tex->env->ok= 0;
        }
+
+       tex->pd= newdataadr(fd, tex->pd);
+       if(tex->pd) {
+               tex->pd->point_tree = NULL;
+               tex->pd->coba= newdataadr(fd, tex->pd->coba);
+       }
+       
+       tex->vd= newdataadr(fd, tex->vd);
+       if(tex->vd) {
+               tex->vd->dataset = NULL;
+       }
        
        tex->nodetree= newdataadr(fd, tex->nodetree);
        if(tex->nodetree)
@@ -7740,6 +7752,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
        if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 11)) {
                Object *ob;
                bActionStrip *strip;
+
                
                /* nla-strips - scale */                
                for (ob= main->object.first; ob; ob= ob->id.next) {
@@ -7763,6 +7776,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                                ob->soft->shearstiff = 1.0f; 
                        }
                }
+               
        }
 
        if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 14)) {
@@ -7908,6 +7922,57 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                        la->skyblendtype= MA_RAMP_ADD;
                        la->skyblendfac= 1.0f;
                }
+               
+       }
+       
+       if (main->versionfile <= 247) {
+               Material *ma;
+               Tex *tex;
+               
+               for(ma=main->mat.first; ma; ma= ma->id.next) {
+                       /* trigger for non-volumetric file */
+                       if (ma->vol_shade_stepsize < 0.0001f) {
+                               ma->vol_shade_stepsize = 0.2f;
+                               ma->vol_stepsize = 0.2f;
+                               ma->vol_absorption = 1.0f;
+                               ma->vol_scattering = 1.0f;
+                               ma->vol_absorption_col[0] = ma->vol_absorption_col[1] = ma->vol_absorption_col[2] = 0.0f;       
+                       }
+                       if (ma->vol_density_scale < 0.0001f)
+                               ma->vol_density_scale = 1.0f;
+                       if (ma->vol_precache_resolution == 0)
+                               ma->vol_precache_resolution = 50;
+                       if (ma->vol_depth_cutoff < 0.0001)
+                               ma->vol_depth_cutoff = 0.05;
+               }
+               
+               for(tex=main->tex.first; tex; tex= tex->id.next) {
+                       if (tex->pd == NULL) 
+                               tex->pd = BKE_add_pointdensity();
+                       else if (tex->pd->noise_size < 0.0001f) {
+                               tex->pd->noise_size = 0.5f;
+                               tex->pd->noise_depth = 1;
+                               tex->pd->noise_fac = 1.0f;
+                               tex->pd->noise_influence = TEX_PD_NOISE_STATIC;
+                       }
+                       if (tex->pd->falloff_softness < 1.0f)
+                               tex->pd->falloff_softness = 2.0f;
+                       if (tex->pd->coba == NULL) {
+                               tex->pd->coba = add_colorband(1);
+                               tex->pd->speed_scale = 1.0f;
+                       }
+                       
+                       if (tex->vd == NULL) {
+                               tex->vd = BKE_add_voxeldata();
+                       } else if (tex->vd->resolX == 0) {
+                               tex->vd->dataset = NULL;
+                               tex->vd->resolX = 1;
+                               tex->vd->resolY = 1;
+                               tex->vd->resolZ = 1;
+                               tex->vd->interp_type= TEX_VD_NEARESTNEIGHBOR;
+                               tex->vd->int_multiplier = 1.0;
+                       }
+               }
        }
        
        /* set the curve radius interpolation to 2.47 default - easy */
@@ -7932,6 +7997,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                        }
                }
        }
+
        /* direction constraint actuators were always local in previous version */
        if (main->versionfile < 247 || (main->versionfile == 247 && main->subversionfile < 7)) {
                bActuator *act;
@@ -8004,7 +8070,27 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                        }
                }
        }
-       
+
+       if (main->versionfile < 248 || (main->versionfile == 248 && main->subversionfile < 3)) {
+               Tex *tex;
+               Material *ma;
+               
+               /* blend texture extrapolation */
+               for(tex=main->tex.first; tex; tex= tex->id.next) {
+                       if (tex->type == TEX_BLEND)
+                               tex->extend = TEX_EXTEND;
+               }
+               
+               for(ma=main->mat.first; ma; ma= ma->id.next) {
+                       if (ma->vol_shadeflag & 2) { // old MA_VOL_ATTENUATED
+                               ma->vol_shade_type = MA_VOL_SHADE_SINGLE;
+                               ma->vol_ms_diff = 0.5f;
+                               ma->vol_ms_steps = 5;
+                               ma->vol_ms_intensity = 1.0;
+                       }
+               }
+       }
+
        if (main->versionfile < 248 || (main->versionfile == 248 && main->subversionfile < 2)) {
                Scene *sce;