diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-03-24 10:38:07 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-03-24 10:38:07 +0400 |
commit | ab4a2aaf4a4b2b4e416aa1f113b30362cbe0dec3 (patch) | |
tree | 81af4c18519181490074508dbe9a8d515eab634f /source/blender/editors/physics/physics_fluid.c | |
parent | 5a90ea77bc1333efe4e1e54984a080550ed3f707 (diff) |
style cleanup: follow style guide for formatting of if/for/while loops, and else if's
Diffstat (limited to 'source/blender/editors/physics/physics_fluid.c')
-rw-r--r-- | source/blender/editors/physics/physics_fluid.c | 93 |
1 files changed, 50 insertions, 43 deletions
diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c index af229fc4cb1..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; @@ -685,13 +689,13 @@ 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 = BLI_fopen(targetFile, "w"); - if(fileCfg) { + 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; } @@ -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"); @@ -997,7 +1004,7 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor BLI_join_dirfile(targetFile, sizeof(targetFile), targetDir, suffixConfigTmp); // make sure these directories exist as well - if(outStringsChanged) { + if (outStringsChanged) { BLI_make_existing_file(targetFile); } @@ -1051,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 @@ -1060,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]; } } } @@ -1076,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 */ @@ -1139,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; @@ -1150,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; |