diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2012-03-25 12:20:19 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2012-03-25 12:20:19 +0400 |
commit | 3b711a6ed009b35bb69cd0ca878eeb8d55fa0e77 (patch) | |
tree | b3fdb366cb49bdea5b57dfa6ba4a82635c68d0ee /source/blender/editors/physics/physics_fluid.c | |
parent | a2ebfc82dbe954acc432ae017ac62a30a11b6a16 (diff) | |
parent | e99a23fc6b33b5097eab44aac19c2a089ddebce6 (diff) |
Merged changes in the trunk up to revision 45133.
Conflicts resolved:
source/blender/blenloader/intern/readfile.c
source/blender/blenloader/intern/writefile.c
source/blender/bmesh/intern/bmesh_construct.c
source/blender/bmesh/intern/bmesh_mesh_conv.c
source/blender/bmesh/intern/bmesh_mesh_conv.h
source/blender/editors/interface/interface_templates.c
source/blender/editors/interface/resources.c
source/blender/editors/mesh/bmesh_select.c
source/blender/editors/mesh/bmesh_tools.c
source/blender/editors/space_view3d/drawobject.c
source/blender/render/intern/source/shadeoutput.c
Diffstat (limited to 'source/blender/editors/physics/physics_fluid.c')
-rw-r--r-- | source/blender/editors/physics/physics_fluid.c | 122 |
1 files changed, 64 insertions, 58 deletions
diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c index 96a59ee4542..23765b03d35 100644 --- a/source/blender/editors/physics/physics_fluid.c +++ b/source/blender/editors/physics/physics_fluid.c @@ -129,7 +129,8 @@ static void get_fluid_gravity(float *gravity, Scene *scene, FluidsimSettings *fs { if (scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY) { copy_v3_v3(gravity, scene->physics_settings.gravity); - } else { + } + else { copy_v3_v3(gravity, fss->grav); } } @@ -138,7 +139,8 @@ static float get_fluid_size_m(Scene *scene, Object *domainob, FluidsimSettings * { if (!scene->unit.system) { return fss->realsize; - } else { + } + else { float dim[3]; float longest_axis; @@ -212,20 +214,22 @@ static void fluidsimPrintChannel(FILE *file, float *channel, int paramsize, char int i,j; int channelSize = paramsize; - if(entries==3) { + if (entries==3) { elbeemSimplifyChannelVec3( channel, &channelSize); - } else if(entries==1) { + } + else if (entries==1) { elbeemSimplifyChannelFloat( channel, &channelSize); - } else { + } + else { // invalid, cant happen? } fprintf(file, " CHANNEL %s = \n", str); - for(i=0; i<channelSize;i++) { + for (i=0; i<channelSize;i++) { fprintf(file," "); - for(j=0;j<=entries;j++) { // also print time value + for (j=0;j<=entries;j++) { // also print time value fprintf(file," %f ", channel[i*(entries+1)+j] ); - if(j==entries-1){ fprintf(file," "); } + if (j==entries-1) { fprintf(file," "); } } fprintf(file," \n"); } @@ -298,7 +302,7 @@ static void set_vertex_channel(float *channel, float time, struct Scene *scene, } /* fill frame of channel with vertex locations */ - for(j=0; j < (3*numVerts); j++) { + for (j=0; j < (3*numVerts); j++) { channel[i*framesize + j] = verts[j]; } channel[i*framesize + framesize-1] = time; @@ -468,7 +472,7 @@ static void fluid_init_all_channels(bContext *C, Object *UNUSED(fsDomain), Fluid /* init euler rotation values and convert to elbeem format */ /* get the rotation from ob->obmat rather than ob->rot to account for parent animations */ - if(i) { + if (i) { copy_v3_v3(old_rot, fobj->Rotation + 4*(i-1)); mul_v3_fl(old_rot, -M_PI/180.f); } @@ -538,16 +542,16 @@ static void export_fluid_objects(ListBase *fobjects, Scene *scene, int length) fsmesh.channelScale = fobj->Scale; fsmesh.channelActive = fobj->Active; - if( ELEM(fsmesh.type, OB_FLUIDSIM_FLUID, OB_FLUIDSIM_INFLOW)) { + if ( ELEM(fsmesh.type, OB_FLUIDSIM_FLUID, OB_FLUIDSIM_INFLOW)) { fsmesh.channelInitialVel = fobj->InitialVelocity; fsmesh.localInivelCoords = ((fluidmd->fss->typeFlags & OB_FSINFLOW_LOCALCOORD)?1:0); } - if(fluidmd->fss->typeFlags & OB_FSBND_NOSLIP) + if (fluidmd->fss->typeFlags & OB_FSBND_NOSLIP) fsmesh.obstacleType = FLUIDSIM_OBSTACLE_NOSLIP; - else if(fluidmd->fss->typeFlags & OB_FSBND_PARTSLIP) + else if (fluidmd->fss->typeFlags & OB_FSBND_PARTSLIP) fsmesh.obstacleType = FLUIDSIM_OBSTACLE_PARTSLIP; - else if(fluidmd->fss->typeFlags & OB_FSBND_FREESLIP) + else if (fluidmd->fss->typeFlags & OB_FSBND_FREESLIP) fsmesh.obstacleType = FLUIDSIM_OBSTACLE_FREESLIP; fsmesh.obstaclePartslip = fluidmd->fss->partSlipValue; @@ -578,7 +582,7 @@ static void export_fluid_objects(ListBase *fobjects, Scene *scene, int length) } /* animated meshes */ - if(deform) { + if (deform) { fsmesh.channelSizeVertices = length; fsmesh.channelVertices = fobj->VertexCache; @@ -590,8 +594,8 @@ static void export_fluid_objects(ListBase *fobjects, Scene *scene, int length) elbeemAddMesh(&fsmesh); - if(verts) MEM_freeN(verts); - if(tris) MEM_freeN(tris); + if (verts) MEM_freeN(verts); + if (tris) MEM_freeN(tris); } } @@ -602,7 +606,7 @@ static int fluid_validate_scene(ReportList *reports, Scene *scene, Object *fsDom int channelObjCount = 0; int fluidInputCount = 0; - for(base=scene->base.first; base; base= base->next) + for (base=scene->base.first; base; base= base->next) { Object *ob = base->object; FluidsimModifierData *fluidmdtmp = (FluidsimModifierData *)modifiers_findByType(ob, eModifierType_Fluidsim); @@ -610,7 +614,7 @@ static int fluid_validate_scene(ReportList *reports, Scene *scene, Object *fsDom /* only find objects with fluid modifiers */ if (!fluidmdtmp || ob->type != OB_MESH) continue; - if(fluidmdtmp->fss->type == OB_FLUIDSIM_DOMAIN) { + if (fluidmdtmp->fss->type == OB_FLUIDSIM_DOMAIN) { /* if no initial domain object given, find another potential domain */ if (!fsDomain) { newdomain = ob; @@ -654,6 +658,7 @@ static int fluid_validate_scene(ReportList *reports, Scene *scene, Object *fsDom #define FLUID_SUFFIX_CONFIG "fluidsim.cfg" +#define FLUID_SUFFIX_CONFIG_TMP (FLUID_SUFFIX_CONFIG ".tmp") #define FLUID_SUFFIX_SURFACE "fluidsurface" static int fluid_init_filepaths(Object *fsDomain, char *targetDir, char *targetFile, char *debugStrBuffer) @@ -663,7 +668,7 @@ static int fluid_init_filepaths(Object *fsDomain, char *targetDir, char *targetF FILE *fileCfg; int dirExist = 0; char newSurfdataPath[FILE_MAX]; // modified output settings - const char *suffixConfig = FLUID_SUFFIX_CONFIG; + const char *suffixConfigTmp = FLUID_SUFFIX_CONFIG_TMP; int outStringsChanged = 0; // prepare names... @@ -673,9 +678,8 @@ static int fluid_init_filepaths(Object *fsDomain, char *targetDir, char *targetF BLI_strncpy(newSurfdataPath, domainSettings->surfdataPath, FILE_MAXDIR); /* if 0'd out below, this value is never used! */ BLI_path_abs(targetDir, relbase); // fixed #frame-no - BLI_join_dirfile(targetFile, FILE_MAX, targetDir, suffixConfig); - /* .tmp: dont overwrite/delete original file */ - strncat(targetFile, ".tmp", FILE_MAX); + /* .tmp: don't overwrite/delete original file */ + BLI_join_dirfile(targetFile, FILE_MAX, targetDir, suffixConfigTmp); // make sure all directories exist // as the bobjs use the same dir, this only needs to be checked @@ -684,14 +688,14 @@ static int fluid_init_filepaths(Object *fsDomain, char *targetDir, char *targetF // check selected directory // simply try to open cfg file for writing to test validity of settings - fileCfg = fopen(targetFile, "w"); - if(fileCfg) { + fileCfg = BLI_fopen(targetFile, "w"); + if (fileCfg) { dirExist = 1; fclose(fileCfg); // remove cfg dummy from directory test BLI_delete(targetFile, 0,0); } - if(targetDir[0] == '\0' || (!dirExist)) { + if (targetDir[0] == '\0' || (!dirExist)) { char blendDir[FILE_MAX]; char blendFile[FILE_MAX]; @@ -709,7 +713,7 @@ static int fluid_init_filepaths(Object *fsDomain, char *targetDir, char *targetF // check if modified output dir is ok #if 0 - if(outStringsChanged) { + if (outStringsChanged) { char dispmsg[FILE_MAX+256]; int selection=0; BLI_strncpy(dispmsg,"Output settings set to: '", sizeof(dispmsg)); @@ -718,7 +722,7 @@ static int fluid_init_filepaths(Object *fsDomain, char *targetDir, char *targetF // ask user if thats what he/she wants... selection = pupmenu(dispmsg); - if(selection<1) return 0; // 0 from menu, or -1 aborted + if (selection<1) return 0; // 0 from menu, or -1 aborted BLI_strncpy(targetDir, newSurfdataPath, sizeof(targetDir)); strncpy(domainSettings->surfdataPath, newSurfdataPath, FILE_MAXDIR); BLI_path_abs(targetDir, G.main->name); // fixed #frame-no @@ -751,7 +755,7 @@ static int fluidbake_breakjob(void *customdata) { FluidBakeJob *fb= (FluidBakeJob *)customdata; - if(fb->stop && *(fb->stop)) + if (fb->stop && *(fb->stop)) return 1; /* this is not nice yet, need to make the jobs list template better @@ -865,7 +869,7 @@ static void fluidsim_delete_until_lastframe(FluidsimSettings *fss, const char *r BLI_delete(targetFileVel, 0, 0); BLI_delete(previewFile, 0, 0); } - } while(exists); + } while (exists); return; } @@ -881,7 +885,7 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor int gridlevels = 0; const char *relbase= modifier_path_relbase(fsDomain); const char *strEnvName = "BLENDER_ELBEEMDEBUG"; // from blendercall.cpp - const char *suffixConfig = FLUID_SUFFIX_CONFIG; + const char *suffixConfigTmp = FLUID_SUFFIX_CONFIG_TMP; const char *suffixSurface = FLUID_SUFFIX_SURFACE; char targetDir[FILE_MAX]; // store & modify output settings @@ -904,7 +908,7 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor fb= MEM_callocN(sizeof(FluidBakeJob), "fluid bake job"); - if(getenv(strEnvName)) { + if (getenv(strEnvName)) { int dlevel = atoi(getenv(strEnvName)); elbeemSetDebugLevel(dlevel); BLI_snprintf(debugStrBuffer, sizeof(debugStrBuffer),"fluidsimBake::msg: Debug messages activated due to envvar '%s'\n",strEnvName); @@ -913,7 +917,7 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor /* make sure it corresponds to startFrame setting (old: noFrames = scene->r.efra - scene->r.sfra +1) */; noFrames = scene->r.efra - 0; - if(noFrames<=0) { + if (noFrames<=0) { BKE_report(reports, RPT_ERROR, "No frames to export - check your animation range settings"); fluidbake_free_data(channels, fobjects, fsset, fb); return 0; @@ -943,7 +947,7 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor fluidsim_delete_until_lastframe(domainSettings, relbase); /* rough check of settings... */ - if(domainSettings->previewresxyz > domainSettings->resolutionxyz) { + if (domainSettings->previewresxyz > domainSettings->resolutionxyz) { BLI_snprintf(debugStrBuffer,sizeof(debugStrBuffer),"fluidsimBake::warning - Preview (%d) >= Resolution (%d)... setting equal.\n", domainSettings->previewresxyz , domainSettings->resolutionxyz); elbeemDebugOut(debugStrBuffer); domainSettings->previewresxyz = domainSettings->resolutionxyz; @@ -952,16 +956,19 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor // this should do as an approximation, with in/outflow // doing this more accurate would be overkill // perhaps add manual setting? - if(domainSettings->maxRefine <0) { - if(domainSettings->resolutionxyz>128) { + if (domainSettings->maxRefine <0) { + if (domainSettings->resolutionxyz>128) { gridlevels = 2; - } else - if(domainSettings->resolutionxyz>64) { + } + else + if (domainSettings->resolutionxyz>64) { gridlevels = 1; - } else { + } + else { gridlevels = 0; } - } else { + } + else { gridlevels = domainSettings->maxRefine; } BLI_snprintf(debugStrBuffer,sizeof(debugStrBuffer),"fluidsimBake::msg: Baking %s, refine: %d\n", fsDomain->id.name , gridlevels ); @@ -983,7 +990,7 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor /* ******** init domain object's matrix ******** */ copy_m4_m4(domainMat, fsDomain->obmat); - if(!invert_m4_m4(invDomMat, domainMat)) { + if (!invert_m4_m4(invDomMat, domainMat)) { BLI_snprintf(debugStrBuffer,sizeof(debugStrBuffer),"fluidsimBake::error - Invalid obj matrix?\n"); elbeemDebugOut(debugStrBuffer); BKE_report(reports, RPT_ERROR, "Invalid object matrix"); @@ -993,12 +1000,11 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor } /* ******** start writing / exporting ******** */ - // use .tmp, dont overwrite/delete original file - BLI_join_dirfile(targetFile, sizeof(targetFile), targetDir, suffixConfig); - strncat(targetFile, ".tmp", sizeof(targetFile)); + // use .tmp, don't overwrite/delete original file + BLI_join_dirfile(targetFile, sizeof(targetFile), targetDir, suffixConfigTmp); // make sure these directories exist as well - if(outStringsChanged) { + if (outStringsChanged) { BLI_make_existing_file(targetFile); } @@ -1052,7 +1058,7 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor fsset->domainobsPartslip = domainSettings->partSlipValue; /* use domainobsType also for surface generation flag (bit: >=64) */ - if(domainSettings->typeFlags & OB_FSSG_NOOBS) + if (domainSettings->typeFlags & OB_FSSG_NOOBS) fsset->mFsSurfGenSetting = FLUIDSIM_FSSG_NOOBS; else fsset->mFsSurfGenSetting = 0; // "normal" mode @@ -1061,8 +1067,8 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor // init blender domain transform matrix { int j; - for(i=0; i<4; i++) { - for(j=0; j<4; j++) { + for (i=0; i<4; i++) { + for (j=0; j<4; j++) { fsset->surfaceTrafo[i*4+j] = invDomMat[j][i]; } } } @@ -1077,7 +1083,7 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor /* custom data for fluid bake job */ fb->settings = fsset; - if(do_job) { + if (do_job) { wmJob *steve= WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene, "Fluid Simulation", WM_JOB_PROGRESS); /* setup job */ @@ -1140,10 +1146,10 @@ static int fluidsimBake(bContext *UNUSED(C), ReportList *UNUSED(reports), Object static int fluid_bake_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { /* only one bake job at a time */ - if(WM_jobs_test(CTX_wm_manager(C), CTX_data_scene(C))) + if (WM_jobs_test(CTX_wm_manager(C), CTX_data_scene(C))) return OPERATOR_CANCELLED; - if(!fluidsimBake(C, op->reports, CTX_data_active_object(C), TRUE)) + if (!fluidsimBake(C, op->reports, CTX_data_active_object(C), TRUE)) return OPERATOR_CANCELLED; return OPERATOR_FINISHED; @@ -1151,7 +1157,7 @@ static int fluid_bake_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event) static int fluid_bake_exec(bContext *C, wmOperator *op) { - if(!fluidsimBake(C, op->reports, CTX_data_active_object(C), FALSE)) + if (!fluidsimBake(C, op->reports, CTX_data_active_object(C), FALSE)) return OPERATOR_CANCELLED; return OPERATOR_FINISHED; @@ -1160,13 +1166,13 @@ static int fluid_bake_exec(bContext *C, wmOperator *op) void FLUID_OT_bake(wmOperatorType *ot) { /* identifiers */ - ot->name= "Fluid Simulation Bake"; - ot->description= "Bake fluid simulation"; - ot->idname= "FLUID_OT_bake"; + ot->name = "Fluid Simulation Bake"; + ot->description = "Bake fluid simulation"; + ot->idname = "FLUID_OT_bake"; /* api callbacks */ - ot->invoke= fluid_bake_invoke; - ot->exec= fluid_bake_exec; - ot->poll= ED_operator_object_active_editable; + ot->invoke = fluid_bake_invoke; + ot->exec = fluid_bake_exec; + ot->poll = ED_operator_object_active_editable; } |