Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2011-11-20 18:38:11 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-11-20 18:38:11 +0400
commitf1eb66aa68105ac27f371f4f708d8abf3b7da38b (patch)
tree77ce3c813f25702880e330740e06ae60a0aadca8 /source/blender/editors
parentbe701c7336a3f967a3a2807f8a7a0c511cb76815 (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')
-rw-r--r--source/blender/editors/object/object_modifier.c7
-rw-r--r--source/blender/editors/physics/dynamicpaint_ops.c8
-rw-r--r--source/blender/editors/physics/physics_fluid.c39
-rw-r--r--source/blender/editors/render/render_opengl.c6
-rw-r--r--source/blender/editors/screen/screendump.c4
5 files changed, 37 insertions, 27 deletions
diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c
index af9e6592eb5..7b747769e49 100644
--- a/source/blender/editors/object/object_modifier.c
+++ b/source/blender/editors/object/object_modifier.c
@@ -1526,9 +1526,10 @@ static int ocean_bake_exec(bContext *C, wmOperator *op)
WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
return OPERATOR_FINISHED;
}
-
- och = BKE_init_ocean_cache(omd->cachepath, omd->bakestart, omd->bakeend, omd->wave_scale,
- omd->chop_amount, omd->foam_coverage, omd->foam_fade, omd->resolution);
+
+ och = BKE_init_ocean_cache(omd->cachepath, modifier_path_relbase(ob),
+ omd->bakestart, omd->bakeend, omd->wave_scale,
+ omd->chop_amount, omd->foam_coverage, omd->foam_fade, omd->resolution);
och->time = MEM_mallocN(och->duration*sizeof(float), "foam bake time");
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;
diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c
index 843918e9173..188a61181ce 100644
--- a/source/blender/editors/render/render_opengl.c
+++ b/source/blender/editors/render/render_opengl.c
@@ -73,6 +73,7 @@
#include "render_intern.h"
typedef struct OGLRender {
+ Main *bmain;
Render *re;
Scene *scene;
@@ -223,7 +224,7 @@ static void screen_opengl_render_apply(OGLRender *oglrender)
IMB_color_to_bw(ibuf);
}
- BKE_makepicstring(name, scene->r.pic, scene->r.cfra, scene->r.imtype, scene->r.scemode & R_EXTENSION, FALSE);
+ BKE_makepicstring(name, scene->r.pic, oglrender->bmain->name, scene->r.cfra, scene->r.imtype, scene->r.scemode & R_EXTENSION, FALSE);
ok= BKE_write_ibuf(ibuf, name, scene->r.imtype, scene->r.subimtype, scene->r.quality); /* no need to stamp here */
if(ok) printf("OpenGL Render written to '%s'\n", name);
else printf("OpenGL Render failed to write '%s'\n", name);
@@ -292,6 +293,7 @@ static int screen_opengl_render_init(bContext *C, wmOperator *op)
oglrender->ofs= ofs;
oglrender->sizex= sizex;
oglrender->sizey= sizey;
+ oglrender->bmain= CTX_data_main(C);
oglrender->scene= scene;
oglrender->write_still= is_write_still && !is_animation;
@@ -462,7 +464,7 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op)
}
}
else {
- BKE_makepicstring(name, scene->r.pic, scene->r.cfra, scene->r.imtype, scene->r.scemode & R_EXTENSION, TRUE);
+ BKE_makepicstring(name, scene->r.pic, oglrender->bmain->name, scene->r.cfra, scene->r.imtype, scene->r.scemode & R_EXTENSION, TRUE);
ok= BKE_write_ibuf_stamp(scene, camera, ibuf, name, scene->r.imtype, scene->r.subimtype, scene->r.quality);
if(ok==0) {
diff --git a/source/blender/editors/screen/screendump.c b/source/blender/editors/screen/screendump.c
index 017325c535e..8a90aadbee2 100644
--- a/source/blender/editors/screen/screendump.c
+++ b/source/blender/editors/screen/screendump.c
@@ -219,6 +219,7 @@ void SCREEN_OT_screenshot(wmOperatorType *ot)
/* *************** screenshot movie job ************************* */
typedef struct ScreenshotJob {
+ Main *bmain;
Scene *scene;
unsigned int *dumprect;
int x, y, dumpsx, dumpsy;
@@ -297,7 +298,7 @@ static void screenshot_startjob(void *sjv, short *stop, short *do_update, float
char name[FILE_MAXDIR+FILE_MAXFILE];
int ok;
- BKE_makepicstring(name, rd.pic, cfra, rd.imtype, rd.scemode & R_EXTENSION, TRUE);
+ BKE_makepicstring(name, rd.pic, sj->bmain->name, cfra, rd.imtype, rd.scemode & R_EXTENSION, TRUE);
ibuf->rect= sj->dumprect;
ok= BKE_write_ibuf(ibuf, name, rd.imtype, rd.subimtype, rd.quality);
@@ -355,6 +356,7 @@ static int screencast_exec(bContext *C, wmOperator *op)
sj->dumpsx= curarea->totrct.xmax - sj->x;
sj->dumpsy= curarea->totrct.ymax - sj->y;
}
+ sj->bmain= CTX_data_main(C);
sj->scene= CTX_data_scene(C);
BKE_reports_init(&sj->reports, RPT_PRINT);