diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-11-20 18:38:11 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-11-20 18:38:11 +0400 |
commit | f1eb66aa68105ac27f371f4f708d8abf3b7da38b (patch) | |
tree | 77ce3c813f25702880e330740e06ae60a0aadca8 /source/blender/editors/physics | |
parent | be701c7336a3f967a3a2807f8a7a0c511cb76815 (diff) |
share code for fluidsim, ocean & dynamic paint file paths.
- use BLI_join_dirfile for joining all paths (no need to ensure slash is appended).
- paths from linked library files now supported.
Diffstat (limited to 'source/blender/editors/physics')
-rw-r--r-- | source/blender/editors/physics/dynamicpaint_ops.c | 8 | ||||
-rw-r--r-- | source/blender/editors/physics/physics_fluid.c | 39 |
2 files changed, 26 insertions, 21 deletions
diff --git a/source/blender/editors/physics/dynamicpaint_ops.c b/source/blender/editors/physics/dynamicpaint_ops.c index a12a9c8720b..6e25307b786 100644 --- a/source/blender/editors/physics/dynamicpaint_ops.c +++ b/source/blender/editors/physics/dynamicpaint_ops.c @@ -312,22 +312,22 @@ static int dynamicPaint_bakeImageSequence(bContext *C, DynamicPaintSurface *surf */ { char filename[FILE_MAX]; - /* make sure output path has ending slash */ - BLI_add_slash(surface->image_output_path); /* primary output layer */ if (surface->flags & MOD_DPAINT_OUT1) { /* set filepath */ - BLI_snprintf(filename, sizeof(filename), "%s%s", surface->image_output_path, surface->output_name); + BLI_join_dirfile(filename, sizeof(filename), surface->image_output_path, surface->output_name); BLI_path_frame(filename, frame, 4); + /* save image */ dynamicPaint_outputSurfaceImage(surface, filename, 0); } /* secondary output */ if (surface->flags & MOD_DPAINT_OUT2 && surface->type == MOD_DPAINT_SURFACE_T_PAINT) { /* set filepath */ - BLI_snprintf(filename, sizeof(filename), "%s%s", surface->image_output_path, surface->output_name2); + BLI_join_dirfile(filename, sizeof(filename), surface->image_output_path, surface->output_name2); BLI_path_frame(filename, frame, 4); + /* save image */ dynamicPaint_outputSurfaceImage(surface, filename, 1); } diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c index 6e88d477d9c..9dd4503414a 100644 --- a/source/blender/editors/physics/physics_fluid.c +++ b/source/blender/editors/physics/physics_fluid.c @@ -640,14 +640,17 @@ static int fluid_init_filepaths(Object *fsDomain, char *targetDir, char *targetF char newSurfdataPath[FILE_MAXDIR+FILE_MAXFILE]; // modified output settings const char *suffixConfig = FLUID_SUFFIX_CONFIG; int outStringsChanged = 0; - + // prepare names... - strncpy(targetDir, domainSettings->surfdataPath, FILE_MAXDIR); - strncpy(newSurfdataPath, domainSettings->surfdataPath, FILE_MAXDIR); - BLI_path_abs(targetDir, G.main->name); // fixed #frame-no + const char *relbase= modifier_path_relbase(fsDomain); + + BLI_strncpy(targetDir, domainSettings->surfdataPath, FILE_MAXDIR); + 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 - // .tmp: dont overwrite/delete original file - BLI_snprintf(targetFile, FILE_MAXDIR+FILE_MAXFILE, "%s%s.tmp", targetDir, suffixConfig); + BLI_join_dirfile(targetFile, FILE_MAX, targetDir, suffixConfig); + /* .tmp: dont overwrite/delete original file */ + strncat(targetFile, ".tmp", FILE_MAX); // make sure all directories exist // as the bobjs use the same dir, this only needs to be checked @@ -663,7 +666,7 @@ static int fluid_init_filepaths(Object *fsDomain, char *targetDir, char *targetF BLI_delete(targetFile, 0,0); } - if((strlen(targetDir)<1) || (!dirExist)) { + if(targetDir[0] == '\0' || (!dirExist)) { char blendDir[FILE_MAXDIR+FILE_MAXFILE]; char blendFile[FILE_MAXDIR+FILE_MAXFILE]; @@ -805,20 +808,20 @@ static void fluidbake_free_data(FluidAnimChannels *channels, ListBase *fobjects, } /* copied from rna_fluidsim.c: fluidsim_find_lastframe() */ -static void fluidsim_delete_until_lastframe(FluidsimSettings *fss) +static void fluidsim_delete_until_lastframe(FluidsimSettings *fss, const char *relbase) { char targetDir[FILE_MAXFILE+FILE_MAXDIR], targetFile[FILE_MAXFILE+FILE_MAXDIR]; char targetDirVel[FILE_MAXFILE+FILE_MAXDIR], targetFileVel[FILE_MAXFILE+FILE_MAXDIR]; char previewDir[FILE_MAXFILE+FILE_MAXDIR], previewFile[FILE_MAXFILE+FILE_MAXDIR]; int curFrame = 1, exists = 0; - BLI_snprintf(targetDir, sizeof(targetDir), "%sfluidsurface_final_####.bobj.gz", fss->surfdataPath); - BLI_snprintf(targetDirVel, sizeof(targetDir), "%sfluidsurface_final_####.bvel.gz", fss->surfdataPath); - BLI_snprintf(previewDir, sizeof(targetDir), "%sfluidsurface_preview_####.bobj.gz", fss->surfdataPath); + BLI_join_dirfile(targetDir, sizeof(targetDir), fss->surfdataPath, OB_FLUIDSIM_SURF_FINAL_OBJ_FNAME); + BLI_join_dirfile(targetDirVel, sizeof(targetDirVel), fss->surfdataPath, OB_FLUIDSIM_SURF_FINAL_VEL_FNAME); + BLI_join_dirfile(previewDir, sizeof(previewDir), fss->surfdataPath, OB_FLUIDSIM_SURF_PREVIEW_OBJ_FNAME); - BLI_path_abs(targetDir, G.main->name); - BLI_path_abs(targetDirVel, G.main->name); - BLI_path_abs(previewDir, G.main->name); + BLI_path_abs(targetDir, relbase); + BLI_path_abs(targetDirVel, relbase); + BLI_path_abs(previewDir, relbase); do { BLI_strncpy(targetFile, targetDir, sizeof(targetFile)); @@ -851,6 +854,7 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor char debugStrBuffer[256]; 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 *suffixSurface = FLUID_SUFFIX_SURFACE; @@ -911,7 +915,7 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor domainSettings->lastgoodframe = -1; /* delete old baked files */ - fluidsim_delete_until_lastframe(domainSettings); + fluidsim_delete_until_lastframe(domainSettings, relbase); /* rough check of settings... */ if(domainSettings->previewresxyz > domainSettings->resolutionxyz) { @@ -997,7 +1001,8 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor /* ******** start writing / exporting ******** */ // use .tmp, dont overwrite/delete original file - BLI_snprintf(targetFile, 240, "%s%s.tmp", targetDir, suffixConfig); + BLI_join_dirfile(targetFile, sizeof(targetFile), targetDir, suffixConfig); + strncat(targetFile, ".tmp", sizeof(targetFile)); // make sure these directories exist as well if(outStringsChanged) { @@ -1025,7 +1030,7 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor fsset->aniFrameTime = channels->aniFrameTime; fsset->noOfFrames = noFrames; // is otherwise subtracted in parser - BLI_snprintf(targetFile, 240, "%s%s", targetDir, suffixSurface); + BLI_join_dirfile(targetFile, sizeof(targetFile), targetDir, suffixSurface); // defaults for compressibility and adaptive grids fsset->gstar = domainSettings->gstar; |