svn merge -r 16592:16667 https://svn.blender.org/svnroot/bf-blender/trunk/blender
[blender-staging.git] / source / blender / blenloader / intern / readfile.c
index a1d50b618d12816d64f1dd9bc0f1c1775c6d3bfd..63f3f88da500dec5be94295fdccf89c85fdbe59b 100644 (file)
@@ -37,6 +37,9 @@
 #ifdef WIN32
 #include "winsock2.h"
 #include "BLI_winstuff.h"
+#ifndef INT_MAX
+#include "limits.h"
+#endif
 #endif
 
 #include <stdio.h> // for printf fopen fwrite fclose sprintf FILE
 #include "BKE_object.h"
 #include "BKE_particle.h"
 #include "BKE_pointcache.h"
-#include "BKE_property.h" // for get_property
+#include "BKE_property.h" // for get_ob_property
 #include "BKE_sca.h" // for init_actuator
 #include "BKE_scene.h"
 #include "BKE_softbody.h"      // sbNew()
@@ -3063,9 +3066,12 @@ static void lib_link_object(FileData *fd, Main *main)
                                }
                                act= act->next;
                        }
-
-                       if(ob->fluidsimSettings) {
-                               ob->fluidsimSettings->ipo = newlibadr_us(fd, ob->id.lib, ob->fluidsimSettings->ipo);
+                       
+                       {
+                               FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(ob, eModifierType_Fluidsim);
+                               
+                               if(fluidmd && fluidmd->fss) 
+                                       fluidmd->fss->ipo = newlibadr_us(fd, ob->id.lib, fluidmd->fss->ipo);
                        }
                        
                        /* texture field */
@@ -3140,6 +3146,11 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb)
                        }
                        
                }
+               else if (md->type==eModifierType_Fluidsim) {
+                       FluidsimModifierData *fluidmd = (FluidsimModifierData*) md;
+                       
+                       fluidmd->fss= newdataadr(fd, fluidmd->fss);
+               }
                else if (md->type==eModifierType_Collision) {
                        
                        CollisionModifierData *collmd = (CollisionModifierData*) md;
@@ -3326,13 +3337,6 @@ static void direct_link_object(FileData *fd, Object *ob)
                        direct_link_pointcache(fd, sb->pointcache);
        }
        ob->fluidsimSettings= newdataadr(fd, ob->fluidsimSettings); /* NT */
-       if(ob->fluidsimSettings) {
-               // reinit mesh pointers
-               ob->fluidsimSettings->orgMesh = NULL; //ob->data;
-               ob->fluidsimSettings->meshSurface = NULL;
-               ob->fluidsimSettings->meshBB = NULL;
-               ob->fluidsimSettings->meshSurfNormals = NULL;
-       }
 
        link_list(fd, &ob->particlesystem);
        direct_link_particlesystems(fd,&ob->particlesystem);
@@ -5325,7 +5329,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                        while (act) {
                                if(act->type==ACT_IPO) {
                                        ia= act->data;
-                                       prop= get_property(ob, ia->name);
+                                       prop= get_ob_property(ob, ia->name);
                                        if(prop) {
                                                ia->type= ACT_IPO_FROM_PROP;
                                        }
@@ -7629,8 +7633,12 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                                        }
                                }
 
-                               if(ob->fluidsimSettings && ob->fluidsimSettings->type == OB_FLUIDSIM_PARTICLE)
-                                       part->type = PART_FLUID;
+                               
+                               {
+                                       FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(ob, eModifierType_Fluidsim);
+                                       if(fluidmd && fluidmd->fss && fluidmd->fss->type == OB_FLUIDSIM_PARTICLE)
+                                               part->type = PART_FLUID;
+                               }
 
                                free_effects(&ob->effect);
 
@@ -7785,6 +7793,29 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                        la->sun_intensity = 1.0;
                }
        }
+       
+       // convert fluids to modifier
+       if(main->versionfile <= 246 && main->subversionfile < 1)
+       {
+               Object *ob;
+               
+               for(ob = main->object.first; ob; ob= ob->id.next) {
+                       if(ob->fluidsimSettings)
+                       {
+                               FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifier_new(eModifierType_Fluidsim);
+                               BLI_addhead(&ob->modifiers, (ModifierData *)fluidmd);
+                               
+                               MEM_freeN(fluidmd->fss);
+                               fluidmd->fss = MEM_dupallocN(ob->fluidsimSettings);
+                               fluidmd->fss->ipo = newlibadr_us(fd, ob->id.lib, ob->fluidsimSettings->ipo);
+                               MEM_freeN(ob->fluidsimSettings);
+                               
+                               fluidmd->fss->lastgoodframe = INT_MAX;
+                               fluidmd->fss->flag = 0;
+                       }
+               }
+       }
+       
 
        if(main->versionfile < 246 || (main->versionfile == 246 && main->subversionfile < 1)) {
                Mesh *me;
@@ -7809,6 +7840,32 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                }
        }
 
+       if (main->versionfile < 247 || (main->versionfile == 247 && main->subversionfile < 3)){
+               Object *ob;
+               for(ob = main->object.first; ob; ob= ob->id.next) {
+                       // Starting from subversion 3, ACTOR is a separate feature.
+                       // Before it was conditioning all the other dynamic flags
+                       if (!(ob->gameflag & OB_ACTOR))
+                               ob->gameflag &= ~(OB_GHOST|OB_DYNAMIC|OB_RIGID_BODY|OB_SOFT_BODY|OB_COLLISION_RESPONSE);
+               }
+       }
+
+       if (main->versionfile < 247 || (main->versionfile == 247 && main->subversionfile < 4)){
+               Scene *sce= main->scene.first;
+               while(sce) {
+                       if(sce->frame_step==0)
+                               sce->frame_step= 1;
+                       sce= sce->id.next;
+               }
+       }
+
+       if (main->versionfile < 247 || (main->versionfile == 247 && main->subversionfile < 5)) {
+               Lamp *la= main->lamp.first;
+               for(; la; la= la->id.next) {
+                       la->skyblendtype= MA_RAMP_ADD;
+                       la->skyblendfac= 1.0f;
+               }
+       }
        /* WATCH IT!!!: pointers from libdata have not been converted yet here! */
        /* WATCH IT 2!: Userdef struct init has to be in src/usiblender.c! */