diff options
author | Daniel Genrich <daniel.genrich@gmx.net> | 2008-09-21 22:20:02 +0400 |
---|---|---|
committer | Daniel Genrich <daniel.genrich@gmx.net> | 2008-09-21 22:20:02 +0400 |
commit | 8471184dc5a726903329bc37040e051e9ec0f5d4 (patch) | |
tree | 03312b48c93c5f2acb25e5280ce5a586244dd54e /source/blender/blenloader | |
parent | afe851b6d194ad93f85a66ea5866a3709708089d (diff) | |
parent | 518b8fe01834b6379614f65f7c611645e5ad4bd5 (diff) |
Merging fluidcontrol to trunk from rev16649 fluidcontrol branch. Code provided by Nils Thuerey.
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 55 | ||||
-rw-r--r-- | source/blender/blenloader/intern/writefile.c | 6 |
2 files changed, 48 insertions, 13 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index a538cfe5fa4..8d998016667 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -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 @@ -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); @@ -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); @@ -7775,6 +7783,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; diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 44634a7468c..e53c725867a 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -852,6 +852,11 @@ static void write_modifiers(WriteData *wd, ListBase *modbase) writestruct(wd, DATA, "ClothCollSettings", 1, clmd->coll_parms); writestruct(wd, DATA, "PointCache", 1, clmd->point_cache); } + else if(md->type==eModifierType_Fluidsim) { + FluidsimModifierData *fluidmd = (FluidsimModifierData*) md; + + writestruct(wd, DATA, "FluidsimSettings", 1, fluidmd->fss); + } else if (md->type==eModifierType_Collision) { /* @@ -917,7 +922,6 @@ static void write_objects(WriteData *wd, ListBase *idbase) writestruct(wd, DATA, "PartDeflect", 1, ob->pd); writestruct(wd, DATA, "SoftBody", 1, ob->soft); if(ob->soft) writestruct(wd, DATA, "PointCache", 1, ob->soft->pointcache); - writestruct(wd, DATA, "FluidsimSettings", 1, ob->fluidsimSettings); // NT write_particlesystems(wd, &ob->particlesystem); write_modifiers(wd, &ob->modifiers); |