diff --git a/intern/elbeem/extern/LBM_fluidsim.h b/intern/elbeem/extern/LBM_fluidsim.h index a6ba16a9599..0f7e0e1ef5d 100644 --- a/intern/elbeem/extern/LBM_fluidsim.h +++ b/intern/elbeem/extern/LBM_fluidsim.h @@ -48,6 +48,9 @@ struct FluidsimSettings* fluidsimSettingsNew(struct Object *srcob); /* frees internal data itself */ void fluidsimSettingsFree(struct FluidsimSettings* sb); +/* duplicate internal data */ +struct FluidsimSettings* fluidsimSettingsCopy(struct FluidsimSettings* sb); + /* export blender geometry to fluid solver */ void fluidsimBake(struct Object* ob); diff --git a/source/blender/blenkernel/bad_level_call_stubs/stubs.c b/source/blender/blenkernel/bad_level_call_stubs/stubs.c index b927cbe98ef..1bad2de5bbc 100644 --- a/source/blender/blenkernel/bad_level_call_stubs/stubs.c +++ b/source/blender/blenkernel/bad_level_call_stubs/stubs.c @@ -60,6 +60,7 @@ void insert_vert_ipo(struct IpoCurve *icu, float x, float y); struct IpoCurve *verify_ipocurve(struct ID *id, short a, char *b, char *d, int e); void elbeemDebugOut(char *msg); void fluidsimSettingsFree(struct FluidsimSettings* sb); +void fluidsimSettingsCopy(struct FluidsimSettings* sb); /* readfile.c */ @@ -224,6 +225,7 @@ struct DispListMesh *NewBooleanMeshDLM(struct Object *ob, struct Object *ob_sele // bobj read/write debug messages void elbeemDebugOut(char *msg) {} void fluidsimSettingsFree(struct FluidsimSettings* sb) {} +void fluidsimSettingsCopy(struct FluidsimSettings* sb) {} /*new render funcs */ void externtex(struct MTex *mtex, float *vec, float *tin, float *tr, float *tg, float *tb, float *ta) {} diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index f76137c586f..d4aa87ec87a 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -902,8 +902,9 @@ Object *copy_object(Object *ob) obn->soft= copy_softbody(ob->soft); /* NT copy fluid sim setting memory */ - if(obn->fluidsimSettings) obn->fluidsimSettings = MEM_dupallocN(ob->fluidsimSettings); - else obn->fluidsimSettings = NULL; + //if(obn->fluidsimSettings) obn->fluidsimSettings = MEM_dupallocN(ob->fluidsimSettings); + //else obn->fluidsimSettings = NULL; + obn->fluidsimSettings = fluidsimSettingsCopy(ob->fluidsimSettings); obn->derivedDeform = NULL; obn->derivedFinal = NULL; diff --git a/source/blender/src/fluidsim.c b/source/blender/src/fluidsim.c index 858c01834b9..8f028d9670f 100644 --- a/source/blender/src/fluidsim.c +++ b/source/blender/src/fluidsim.c @@ -208,6 +208,37 @@ FluidsimSettings *fluidsimSettingsNew(struct Object *srcob) return fss; } +/* duplicate struct, analogous to free */ +FluidsimSettings* fluidsimSettingsCopy(FluidsimSettings *fss) +{ + FluidsimSettings *dupfss; + Mesh *dupFsMesh = NULL; + + if(!fss) return NULL; + dupfss = MEM_dupallocN(fss); + + dupFsMesh = fss->meshSurface; + if(dupFsMesh) { + dupfss->meshSurface = MEM_dupallocN(dupFsMesh); + if(dupFsMesh->mvert) dupfss->meshSurface->mvert = MEM_dupallocN(dupFsMesh->mvert); + if(dupFsMesh->medge) dupfss->meshSurface->medge = MEM_dupallocN(dupFsMesh->medge); + if(dupFsMesh->mface) dupfss->meshSurface->mface = MEM_dupallocN(dupFsMesh->mface); + } + + dupFsMesh = fss->meshBB; + if(dupFsMesh) { + dupfss->meshBB = MEM_dupallocN(dupFsMesh); + if(dupFsMesh->mvert) dupfss->meshBB->mvert = MEM_dupallocN(dupFsMesh->mvert); + if(dupFsMesh->medge) dupfss->meshBB->medge = MEM_dupallocN(dupFsMesh->medge); + if(dupFsMesh->mface) dupfss->meshBB->mface = MEM_dupallocN(dupFsMesh->mface); + } + + if(fss->meshSurfNormals) dupfss->meshSurfNormals = MEM_dupallocN(fss->meshSurfNormals); + + return dupfss; +} + + /* free struct */ void fluidsimSettingsFree(FluidsimSettings *fss) {