diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-02-03 05:30:21 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-02-03 05:30:21 +0400 |
commit | 075fee4d58a65b4313bb7e984ae195690f4c7bfd (patch) | |
tree | e801da2591eda34a4c4c7fd5436ff476353b1c55 /source/blender/modifiers/intern/MOD_fluidsim_util.c | |
parent | 68cc7e168207c4c519f54f7e0f7f638768386cd0 (diff) | |
parent | 050963b6a9529e0abdd597d163ddc4343c0b15c2 (diff) |
svn merge ^/trunk/blender -r43830:43864
Diffstat (limited to 'source/blender/modifiers/intern/MOD_fluidsim_util.c')
-rw-r--r-- | source/blender/modifiers/intern/MOD_fluidsim_util.c | 44 |
1 files changed, 19 insertions, 25 deletions
diff --git a/source/blender/modifiers/intern/MOD_fluidsim_util.c b/source/blender/modifiers/intern/MOD_fluidsim_util.c index b25cf1916c6..9dc560afb0f 100644 --- a/source/blender/modifiers/intern/MOD_fluidsim_util.c +++ b/source/blender/modifiers/intern/MOD_fluidsim_util.c @@ -152,9 +152,7 @@ void fluidsim_init(FluidsimModifierData *fluidmd) void fluidsim_free(FluidsimModifierData *fluidmd) { -#ifdef WITH_MOD_FLUID - if(fluidmd) - { + if(fluidmd) { if(fluidmd->fss->meshVelocities) { MEM_freeN(fluidmd->fss->meshVelocities); @@ -162,16 +160,13 @@ void fluidsim_free(FluidsimModifierData *fluidmd) } MEM_freeN(fluidmd->fss); } -#else - (void)fluidmd; /* unused */ -#endif return; } #ifdef WITH_MOD_FLUID /* read .bobj.gz file into a fluidsimDerivedMesh struct */ -static DerivedMesh *fluidsim_read_obj(const char *filename) +static DerivedMesh *fluidsim_read_obj(const char *filename, const MPoly *mp_example) { int wri = 0,i; int gotBytes; @@ -184,6 +179,9 @@ static DerivedMesh *fluidsim_read_obj(const char *filename) short *normals, *no_s; float no[3]; + const short mp_mat_nr = mp_example->mat_nr; + const char mp_flag = mp_example->flag; + // ------------------------------------------------ // get numverts + numfaces first // ------------------------------------------------ @@ -289,6 +287,10 @@ static DerivedMesh *fluidsim_read_obj(const char *filename) gotBytes = gzread(gzf, face, sizeof(int) * 3); + /* initialize from existing face */ + mp->mat_nr = mp_mat_nr; + mp->flag = mp_flag; + mp->loopstart = i * 3; mp->totloop = 3; @@ -444,8 +446,7 @@ static DerivedMesh *fluidsim_read_cache(Object *ob, DerivedMesh *orgdm, Fluidsim FluidsimSettings *fss = fluidmd->fss; DerivedMesh *dm = NULL; MPoly *mpoly; - int numpolys; - int mat_nr, flag, i; + MPoly mp_example = {0}; if(!useRenderParams) { displaymode = fss->guiDisplayMode; @@ -473,7 +474,15 @@ static DerivedMesh *fluidsim_read_cache(Object *ob, DerivedMesh *orgdm, Fluidsim BLI_path_abs(targetFile, modifier_path_relbase(ob)); BLI_path_frame(targetFile, curFrame, 0); // fixed #frame-no - dm = fluidsim_read_obj(targetFile); + // assign material + flags to new dm + // if there's no faces in original dm, keep materials and flags unchanged + mpoly = orgdm->getPolyArray(orgdm); + if (mpoly) { + mp_example = *mpoly; + } + /* else leave NULL'd */ + + dm = fluidsim_read_obj(targetFile, &mp_example); if(!dm) { @@ -494,21 +503,6 @@ static DerivedMesh *fluidsim_read_cache(Object *ob, DerivedMesh *orgdm, Fluidsim return NULL; } - // assign material + flags to new dm - mpoly = orgdm->getPolyArray(orgdm); - if(mpoly) { - mat_nr = mpoly[0].mat_nr; - flag = mpoly[0].flag; - - mpoly = dm->getPolyArray(dm); - numpolys = dm->getNumPolys(dm); - for(i=0; i<numpolys; i++) - { - mpoly[i].mat_nr = mat_nr; - mpoly[i].flag = flag; - } - } - // load vertex velocities, if they exist... // TODO? use generate flag as loading flag as well? // warning, needs original .bobj.gz mesh loading filename |