svn merge -r 15649:15800 https://svn.blender.org/svnroot/bf-blender/trunk/blender...
[blender-staging.git] / source / blender / blenloader / intern / readfile.c
index ad004dd5c8216509e59c967dec8cadf947351978..65c5aad43a71410be9e3ef8a9c486ce3a3fb788c 100644 (file)
@@ -3041,10 +3041,6 @@ 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);
-                       }
                        
                        /* texture field */
                        if(ob->pd)
@@ -3118,6 +3114,12 @@ 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);
+                       fluidmd->fss->ipo = newlibadr_us(fd, lb, fluidmd->fss->ipo);
+               }
                else if (md->type==eModifierType_Collision) {
                        
                        CollisionModifierData *collmd = (CollisionModifierData*) md;
@@ -3304,13 +3306,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);
@@ -7560,8 +7555,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);
 
@@ -7730,6 +7729,26 @@ 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);
+                       }
+               }
+       }
+       
 
        /* WATCH IT!!!: pointers from libdata have not been converted yet here! */
        /* WATCH IT 2!: Userdef struct init has to be in src/usiblender.c! */