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.
This commit is contained in:
@@ -52,7 +52,7 @@ void BKE_stamp_buf(struct Scene *scene, struct Object *camera, unsigned char *re
|
||||
int BKE_alphatest_ibuf(struct ImBuf *ibuf);
|
||||
int BKE_write_ibuf_stamp(struct Scene *scene, struct Object *camera, struct ImBuf *ibuf, const char *name, int imtype, int subimtype, int quality);
|
||||
int BKE_write_ibuf(struct ImBuf *ibuf, const char *name, int imtype, int subimtype, int quality);
|
||||
void BKE_makepicstring(char *string, const char *base, int frame, int imtype, const short use_ext, const short use_frames);
|
||||
void BKE_makepicstring(char *string, const char *base, const char *relbase, int frame, int imtype, const short use_ext, const short use_frames);
|
||||
int BKE_add_image_extension(char *string, int imtype);
|
||||
int BKE_ftype_to_imtype(int ftype);
|
||||
int BKE_imtype_to_ftype(int imtype);
|
||||
|
@@ -364,5 +364,8 @@ void test_object_modifiers(struct Object *ob);
|
||||
/* here for do_versions */
|
||||
void modifier_mdef_compact_influences(struct ModifierData *md);
|
||||
|
||||
void modifier_path_init(char *path, int path_maxlen, const char *name);
|
||||
const char *modifier_path_relbase(struct Object *ob);
|
||||
|
||||
#endif
|
||||
|
||||
|
@@ -48,7 +48,8 @@ typedef struct OceanCache {
|
||||
struct ImBuf **ibufs_foam;
|
||||
struct ImBuf **ibufs_norm;
|
||||
|
||||
char *bakepath;
|
||||
const char *bakepath;
|
||||
const char *relbase;
|
||||
|
||||
/* precalculated for time range */
|
||||
float *time;
|
||||
@@ -92,8 +93,9 @@ void BKE_ocean_eval_ij(struct Ocean * oc, struct OceanResult *ocr, int i, int j)
|
||||
|
||||
|
||||
/* ocean cache handling */
|
||||
struct OceanCache *BKE_init_ocean_cache(char *bakepath, int start, int end, float wave_scale,
|
||||
float chop_amount, float foam_coverage, float foam_fade, int resolution);
|
||||
struct OceanCache *BKE_init_ocean_cache(const char *bakepath, const char *relbase,
|
||||
int start, int end, float wave_scale,
|
||||
float chop_amount, float foam_coverage, float foam_fade, int resolution);
|
||||
void BKE_simulate_ocean_cache(struct OceanCache *och, int frame);
|
||||
|
||||
void BKE_bake_ocean(struct Ocean *o, struct OceanCache *och, void (*update_cb)(void *, float progress, int *cancel), void *update_cb_data);
|
||||
|
@@ -976,8 +976,8 @@ struct DynamicPaintSurface *dynamicPaint_createNewSurface(DynamicPaintCanvasSett
|
||||
surface->wave_timescale = 1.0f;
|
||||
surface->wave_spring = 0.20f;
|
||||
|
||||
BLI_snprintf(surface->image_output_path, sizeof(surface->image_output_path), "%sdynamicpaint", U.textudir);
|
||||
BLI_cleanup_dir(NULL, surface->image_output_path);
|
||||
modifier_path_init(surface->image_output_path, sizeof(surface->image_output_path), "dynamicpaint");
|
||||
|
||||
dynamicPaintSurface_setUniqueName(surface, "Surface");
|
||||
|
||||
surface->effector_weights = BKE_add_effector_weights(NULL);
|
||||
|
@@ -1484,11 +1484,11 @@ int BKE_write_ibuf_stamp(Scene *scene, struct Object *camera, ImBuf *ibuf, const
|
||||
}
|
||||
|
||||
|
||||
void BKE_makepicstring(char *string, const char *base, int frame, int imtype, const short use_ext, const short use_frames)
|
||||
void BKE_makepicstring(char *string, const char *base, const char *relbase, int frame, int imtype, const short use_ext, const short use_frames)
|
||||
{
|
||||
if (string==NULL) return;
|
||||
BLI_strncpy(string, base, FILE_MAX - 10); /* weak assumption */
|
||||
BLI_path_abs(string, G.main->name);
|
||||
BLI_path_abs(string, relbase);
|
||||
|
||||
if(use_frames)
|
||||
BLI_path_frame(string, frame, 4);
|
||||
|
@@ -60,6 +60,11 @@
|
||||
#include "BKE_key.h"
|
||||
#include "BKE_multires.h"
|
||||
|
||||
/* may move these, only for modifier_path_relbase */
|
||||
#include "BKE_global.h" /* ugh, G.main->name only */
|
||||
#include "BKE_main.h"
|
||||
/* end */
|
||||
|
||||
#include "MOD_modifiertypes.h"
|
||||
|
||||
ModifierTypeInfo *modifierType_getInfo(ModifierType type)
|
||||
@@ -573,3 +578,36 @@ void test_object_modifiers(Object *ob)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* where should this go?, it doesnt fit well anywhere :S - campbell */
|
||||
|
||||
/* elubie: changed this to default to the same dir as the render output
|
||||
* to prevent saving to C:\ on Windows */
|
||||
|
||||
/* campbell: logic behind this...
|
||||
*
|
||||
* - if the ID is from a library, return library path
|
||||
* - else if the file has been saved return the blend file path.
|
||||
* - else if the file isn't saved and the ID isnt from a library, return the temp dir.
|
||||
*/
|
||||
const char *modifier_path_relbase(Object *ob)
|
||||
{
|
||||
if (G.relbase_valid || ob->id.lib) {
|
||||
return ID_BLEND_PATH(G.main, &ob->id);
|
||||
}
|
||||
else {
|
||||
/* last resort, better then using "" which resolves to the current
|
||||
* working directory */
|
||||
return BLI_temporary_dir();
|
||||
}
|
||||
}
|
||||
|
||||
/* initializes the path with either */
|
||||
void modifier_path_init(char *path, int path_maxlen, const char *name)
|
||||
{
|
||||
/* elubie: changed this to default to the same dir as the render output
|
||||
* to prevent saving to C:\ on Windows */
|
||||
BLI_join_dirfile(path, path_maxlen,
|
||||
G.relbase_valid ? "//" : BLI_temporary_dir(),
|
||||
name);
|
||||
}
|
||||
|
@@ -998,7 +998,7 @@ void BKE_free_ocean(struct Ocean *oc)
|
||||
#define CACHE_TYPE_FOAM 2
|
||||
#define CACHE_TYPE_NORMAL 3
|
||||
|
||||
static void cache_filename(char *string, const char *path, int frame, int type)
|
||||
static void cache_filename(char *string, const char *path, const char *relbase, int frame, int type)
|
||||
{
|
||||
char cachepath[FILE_MAX];
|
||||
const char *fname;
|
||||
@@ -1018,7 +1018,7 @@ static void cache_filename(char *string, const char *path, int frame, int type)
|
||||
|
||||
BLI_join_dirfile(cachepath, sizeof(cachepath), path, fname);
|
||||
|
||||
BKE_makepicstring(string, cachepath, frame, R_OPENEXR, 1, TRUE);
|
||||
BKE_makepicstring(string, cachepath, relbase, frame, R_OPENEXR, 1, TRUE);
|
||||
}
|
||||
|
||||
void BKE_free_ocean_cache(struct OceanCache *och)
|
||||
@@ -1119,12 +1119,15 @@ void BKE_ocean_cache_eval_ij(struct OceanCache *och, struct OceanResult *ocr, in
|
||||
}
|
||||
}
|
||||
|
||||
struct OceanCache *BKE_init_ocean_cache(char *bakepath, int start, int end, float wave_scale,
|
||||
float chop_amount, float foam_coverage, float foam_fade, int resolution)
|
||||
struct OceanCache *BKE_init_ocean_cache(const char *bakepath, const char *relbase,
|
||||
int start, int end, float wave_scale,
|
||||
float chop_amount, float foam_coverage, float foam_fade, int resolution)
|
||||
{
|
||||
OceanCache *och = MEM_callocN(sizeof(OceanCache), "ocean cache data");
|
||||
|
||||
och->bakepath = bakepath;
|
||||
och->relbase = relbase;
|
||||
|
||||
och->start = start;
|
||||
och->end = end;
|
||||
och->duration = (end - start) + 1;
|
||||
@@ -1158,17 +1161,17 @@ void BKE_simulate_ocean_cache(struct OceanCache *och, int frame)
|
||||
if (och->ibufs_disp[f] != NULL ) return;
|
||||
|
||||
|
||||
cache_filename(string, och->bakepath, frame, CACHE_TYPE_DISPLACE);
|
||||
cache_filename(string, och->bakepath, och->relbase, frame, CACHE_TYPE_DISPLACE);
|
||||
och->ibufs_disp[f] = IMB_loadiffname(string, 0);
|
||||
//if (och->ibufs_disp[f] == NULL) printf("error loading %s \n", string);
|
||||
//else printf("loaded cache %s \n", string);
|
||||
|
||||
cache_filename(string, och->bakepath, frame, CACHE_TYPE_FOAM);
|
||||
cache_filename(string, och->bakepath, och->relbase, frame, CACHE_TYPE_FOAM);
|
||||
och->ibufs_foam[f] = IMB_loadiffname(string, 0);
|
||||
//if (och->ibufs_foam[f] == NULL) printf("error loading %s \n", string);
|
||||
//else printf("loaded cache %s \n", string);
|
||||
|
||||
cache_filename(string, och->bakepath, frame, CACHE_TYPE_NORMAL);
|
||||
cache_filename(string, och->bakepath, och->relbase, frame, CACHE_TYPE_NORMAL);
|
||||
och->ibufs_norm[f] = IMB_loadiffname(string, 0);
|
||||
//if (och->ibufs_norm[f] == NULL) printf("error loading %s \n", string);
|
||||
//else printf("loaded cache %s \n", string);
|
||||
@@ -1288,18 +1291,18 @@ void BKE_bake_ocean(struct Ocean *o, struct OceanCache *och, void (*update_cb)(v
|
||||
}
|
||||
|
||||
/* write the images */
|
||||
cache_filename(string, och->bakepath, f, CACHE_TYPE_DISPLACE);
|
||||
cache_filename(string, och->bakepath, och->relbase, f, CACHE_TYPE_DISPLACE);
|
||||
if(0 == BKE_write_ibuf(ibuf_disp, string, R_OPENEXR, R_OPENEXR_HALF, 2)) // 2 == ZIP exr codec
|
||||
printf("Cannot save Displacement File Output to %s\n", string);
|
||||
|
||||
if (o->_do_jacobian) {
|
||||
cache_filename(string, och->bakepath, f, CACHE_TYPE_FOAM);
|
||||
cache_filename(string, och->bakepath, och->relbase, f, CACHE_TYPE_FOAM);
|
||||
if(0 == BKE_write_ibuf(ibuf_foam, string, R_OPENEXR, R_OPENEXR_HALF, 2)) // 2 == ZIP exr codec
|
||||
printf("Cannot save Foam File Output to %s\n", string);
|
||||
}
|
||||
|
||||
if (o->_do_normals) {
|
||||
cache_filename(string, och->bakepath, f, CACHE_TYPE_NORMAL);
|
||||
cache_filename(string, och->bakepath, och->relbase, f, CACHE_TYPE_NORMAL);
|
||||
if(0 == BKE_write_ibuf(ibuf_normal, string, R_OPENEXR, R_OPENEXR_HALF, 2)) // 2 == ZIP exr codec
|
||||
printf("Cannot save Normal File Output to %s\n", string);
|
||||
}
|
||||
@@ -1409,7 +1412,7 @@ struct OceanCache *BKE_init_ocean_cache(char *UNUSED(bakepath), int UNUSED(start
|
||||
return och;
|
||||
}
|
||||
|
||||
void BKE_simulate_ocean_cache(struct OceanCache *UNUSED(och), int UNUSED(frame))
|
||||
void BKE_simulate_ocean_cache(struct OceanCache *UNUSED(och), const char *UNUSED(relbase), int UNUSED(frame))
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -3935,9 +3935,10 @@ static void particles_fluid_step(ParticleSimulationData *sim, int UNUSED(cfra))
|
||||
// return;
|
||||
|
||||
// ok, start loading
|
||||
BLI_snprintf(filename, sizeof(filename), "%sfluidsurface_particles_####.gz", fss->surfdataPath);
|
||||
|
||||
BLI_path_abs(filename, G.main->name);
|
||||
BLI_join_dirfile(filename, sizeof(filename), fss->surfdataPath, OB_FLUIDSIM_SURF_PARTICLES_FNAME);
|
||||
|
||||
BLI_path_abs(filename, modifier_path_relbase(sim->ob));
|
||||
|
||||
BLI_path_frame(filename, curFrame, 0); // fixed #frame-no
|
||||
|
||||
gzf = gzopen(filename, "rb");
|
||||
|
@@ -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");
|
||||
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -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
|
||||
|
||||
// .tmp: dont overwrite/delete original file
|
||||
BLI_snprintf(targetFile, FILE_MAXDIR+FILE_MAXFILE, "%s%s.tmp", targetDir, suffixConfig);
|
||||
// prepare names...
|
||||
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
|
||||
|
||||
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;
|
||||
|
@@ -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) {
|
||||
|
@@ -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);
|
||||
|
@@ -178,6 +178,11 @@ typedef struct FluidsimSettings {
|
||||
#define OB_FLUIDSIM_ACTIVE (1 << 1)
|
||||
#define OB_FLUIDSIM_OVERRIDE_TIME (1 << 2)
|
||||
|
||||
#define OB_FLUIDSIM_SURF_PREVIEW_OBJ_FNAME "fluidsurface_preview_####.bobj.gz"
|
||||
#define OB_FLUIDSIM_SURF_FINAL_OBJ_FNAME "fluidsurface_final_####.bobj.gz"
|
||||
#define OB_FLUIDSIM_SURF_FINAL_VEL_FNAME "fluidsurface_final_####.bvel.gz"
|
||||
#define OB_FLUIDSIM_SURF_PARTICLES_FNAME "fluidsurface_particles_####.gz"
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@@ -83,18 +83,19 @@ static void rna_fluid_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerR
|
||||
WM_main_add_notifier(NC_OBJECT|ND_MODIFIER, ob);
|
||||
}
|
||||
|
||||
static int fluidsim_find_lastframe(FluidsimSettings *fss)
|
||||
static int fluidsim_find_lastframe(Object *ob, FluidsimSettings *fss)
|
||||
{
|
||||
char targetDir[FILE_MAXFILE+FILE_MAXDIR], targetFile[FILE_MAXFILE+FILE_MAXDIR];
|
||||
char targetFileTest[FILE_MAX];
|
||||
char targetFile[FILE_MAX];
|
||||
int curFrame = 1;
|
||||
|
||||
BLI_snprintf(targetDir, sizeof(targetDir), "%sfluidsurface_final_####.bobj.gz", fss->surfdataPath);
|
||||
BLI_path_abs(targetDir, G.main->name);
|
||||
BLI_join_dirfile(targetFile, sizeof(targetFile), fss->surfdataPath, OB_FLUIDSIM_SURF_FINAL_OBJ_FNAME);
|
||||
BLI_path_abs(targetFile, modifier_path_relbase(ob));
|
||||
|
||||
do {
|
||||
BLI_strncpy(targetFile, targetDir, sizeof(targetFile));
|
||||
BLI_path_frame(targetFile, curFrame++, 0);
|
||||
} while(BLI_exists(targetFile));
|
||||
BLI_strncpy(targetFileTest, targetFile, sizeof(targetFileTest));
|
||||
BLI_path_frame(targetFileTest, curFrame++, 0);
|
||||
} while(BLI_exists(targetFileTest));
|
||||
|
||||
return curFrame - 1;
|
||||
}
|
||||
@@ -105,7 +106,7 @@ static void rna_fluid_find_enframe(Main *bmain, Scene *scene, PointerRNA *ptr)
|
||||
FluidsimModifierData *fluidmd= (FluidsimModifierData*)modifiers_findByType(ob, eModifierType_Fluidsim);
|
||||
|
||||
if(fluidmd->fss->flag & OB_FLUIDSIM_REVERSE) {
|
||||
fluidmd->fss->lastgoodframe = fluidsim_find_lastframe(fluidmd->fss);
|
||||
fluidmd->fss->lastgoodframe = fluidsim_find_lastframe(ob, fluidmd->fss);
|
||||
}
|
||||
else {
|
||||
fluidmd->fss->lastgoodframe = -1;
|
||||
|
@@ -77,7 +77,7 @@ static void rna_SceneRender_get_frame_path(RenderData *rd, int frame, char *name
|
||||
if(BKE_imtype_is_movie(rd->imtype))
|
||||
BKE_makeanimstring(name, rd);
|
||||
else
|
||||
BKE_makepicstring(name, rd->pic, (frame==INT_MIN) ? rd->cfra : frame, rd->imtype, rd->scemode & R_EXTENSION, TRUE);
|
||||
BKE_makepicstring(name, rd->pic, G.main->name, (frame==INT_MIN) ? rd->cfra : frame, rd->imtype, rd->scemode & R_EXTENSION, TRUE);
|
||||
}
|
||||
|
||||
#ifdef WITH_COLLADA
|
||||
|
@@ -69,8 +69,7 @@ void fluidsim_init(FluidsimModifierData *fluidmd)
|
||||
if(fluidmd)
|
||||
{
|
||||
FluidsimSettings *fss = MEM_callocN(sizeof(FluidsimSettings), "fluidsimsettings");
|
||||
int surfdataPathMax = FILE_MAX;
|
||||
|
||||
|
||||
fluidmd->fss = fss;
|
||||
|
||||
if(!fss)
|
||||
@@ -103,24 +102,7 @@ void fluidsim_init(FluidsimModifierData *fluidmd)
|
||||
// fluid/inflow settings
|
||||
// fss->iniVel --> automatically set to 0
|
||||
|
||||
/* elubie: changed this to default to the same dir as the render output
|
||||
to prevent saving to C:\ on Windows */
|
||||
if (G.relbase_valid) { /* is the .blend saved? */
|
||||
/* subfolder next to saved file */
|
||||
BLI_strncpy(fss->surfdataPath, "//fluid_cache", surfdataPathMax);
|
||||
BLI_add_slash(fss->surfdataPath);
|
||||
}
|
||||
else {
|
||||
/* subfolder in temp. directory */
|
||||
BLI_strncpy(fss->surfdataPath, BLI_temporary_dir(), surfdataPathMax);
|
||||
surfdataPathMax -= strlen(fss->surfdataPath);
|
||||
if (surfdataPathMax > 1) {
|
||||
BLI_strncpy(fss->surfdataPath+strlen(fss->surfdataPath), "fluid_cache", surfdataPathMax);
|
||||
surfdataPathMax -= strlen("fluid_cache");
|
||||
if (surfdataPathMax > 1)
|
||||
BLI_add_slash(fss->surfdataPath);
|
||||
}
|
||||
}
|
||||
modifier_path_init(fss->surfdataPath, sizeof(fss->surfdataPath), "fluid_cache");
|
||||
|
||||
// first init of bounding box
|
||||
// no bounding box needed
|
||||
@@ -461,11 +443,11 @@ static void fluidsim_read_vel_cache(FluidsimModifierData *fluidmd, DerivedMesh *
|
||||
gzclose(gzf);
|
||||
}
|
||||
|
||||
static DerivedMesh *fluidsim_read_cache(DerivedMesh *orgdm, FluidsimModifierData *fluidmd, int framenr, int useRenderParams)
|
||||
static DerivedMesh *fluidsim_read_cache(Object *ob, DerivedMesh *orgdm, FluidsimModifierData *fluidmd, int framenr, int useRenderParams)
|
||||
{
|
||||
int displaymode = 0;
|
||||
int curFrame = framenr - 1 /*scene->r.sfra*/; /* start with 0 at start frame */
|
||||
char targetDir[FILE_MAXFILE+FILE_MAXDIR], targetFile[FILE_MAXFILE+FILE_MAXDIR];
|
||||
char targetFile[FILE_MAXFILE+FILE_MAXDIR];
|
||||
FluidsimSettings *fss = fluidmd->fss;
|
||||
DerivedMesh *dm = NULL;
|
||||
MFace *mface;
|
||||
@@ -478,27 +460,22 @@ static DerivedMesh *fluidsim_read_cache(DerivedMesh *orgdm, FluidsimModifierData
|
||||
displaymode = fss->renderDisplayMode;
|
||||
}
|
||||
|
||||
BLI_strncpy(targetDir, fss->surfdataPath, sizeof(targetDir));
|
||||
|
||||
// use preview or final mesh?
|
||||
if(displaymode==1)
|
||||
{
|
||||
// just display original object
|
||||
switch (displaymode) {
|
||||
case 1:
|
||||
/* just display original object */
|
||||
return NULL;
|
||||
}
|
||||
else if(displaymode==2)
|
||||
{
|
||||
strcat(targetDir,"fluidsurface_preview_####");
|
||||
}
|
||||
else
|
||||
{ // 3
|
||||
strcat(targetDir,"fluidsurface_final_####");
|
||||
case 2:
|
||||
/* use preview mesh */
|
||||
BLI_join_dirfile(targetFile, sizeof(targetFile), fss->surfdataPath, OB_FLUIDSIM_SURF_PREVIEW_OBJ_FNAME);
|
||||
break;
|
||||
default: /* 3 */
|
||||
/* 3. use final mesh */
|
||||
BLI_join_dirfile(targetFile, sizeof(targetFile), fss->surfdataPath, OB_FLUIDSIM_SURF_FINAL_OBJ_FNAME);
|
||||
break;
|
||||
}
|
||||
|
||||
BLI_path_abs(targetDir, G.main->name);
|
||||
BLI_path_frame(targetDir, curFrame, 0); // fixed #frame-no
|
||||
|
||||
BLI_snprintf(targetFile, sizeof(targetFile), "%s.bobj.gz", targetDir);
|
||||
BLI_path_abs(targetFile, modifier_path_relbase(ob));
|
||||
BLI_path_frame(targetFile, curFrame, 0); // fixed #frame-no
|
||||
|
||||
dm = fluidsim_read_obj(targetFile);
|
||||
|
||||
@@ -554,7 +531,7 @@ static DerivedMesh *fluidsim_read_cache(DerivedMesh *orgdm, FluidsimModifierData
|
||||
#endif // WITH_MOD_FLUID
|
||||
|
||||
DerivedMesh *fluidsimModifier_do(FluidsimModifierData *fluidmd, Scene *scene,
|
||||
Object *UNUSED(ob),
|
||||
Object *ob,
|
||||
DerivedMesh *dm,
|
||||
int useRenderParams, int UNUSED(isFinalCalc))
|
||||
{
|
||||
@@ -587,7 +564,7 @@ DerivedMesh *fluidsimModifier_do(FluidsimModifierData *fluidmd, Scene *scene,
|
||||
|
||||
/* try to read from cache */
|
||||
/* if the frame is there, fine, otherwise don't do anything */
|
||||
if((result = fluidsim_read_cache(dm, fluidmd, framenr, useRenderParams)))
|
||||
if((result = fluidsim_read_cache(ob, dm, fluidmd, framenr, useRenderParams)))
|
||||
return result;
|
||||
|
||||
return dm;
|
||||
|
@@ -48,10 +48,13 @@
|
||||
#include "MOD_util.h"
|
||||
|
||||
#ifdef WITH_OCEANSIM
|
||||
static void init_cache_data(struct OceanModifierData *omd)
|
||||
static void init_cache_data(Object *ob, struct OceanModifierData *omd)
|
||||
{
|
||||
omd->oceancache = BKE_init_ocean_cache(omd->cachepath, omd->bakestart, omd->bakeend, omd->wave_scale,
|
||||
omd->chop_amount, omd->foam_coverage, omd->foam_fade, omd->resolution);
|
||||
const char *relbase= modifier_path_relbase(ob);
|
||||
|
||||
omd->oceancache = BKE_init_ocean_cache(omd->cachepath, relbase,
|
||||
omd->bakestart, omd->bakeend, omd->wave_scale,
|
||||
omd->chop_amount, omd->foam_coverage, omd->foam_fade, omd->resolution);
|
||||
}
|
||||
|
||||
static void clear_cache_data(struct OceanModifierData *omd)
|
||||
@@ -97,7 +100,6 @@ static void initData(ModifierData *md)
|
||||
{
|
||||
#ifdef WITH_OCEANSIM
|
||||
OceanModifierData *omd = (OceanModifierData*) md;
|
||||
int cachepathmax = sizeof(omd->cachepath);
|
||||
|
||||
omd->resolution = 7;
|
||||
omd->spatial_size = 50;
|
||||
@@ -125,22 +127,7 @@ static void initData(ModifierData *md)
|
||||
omd->repeat_x = 1;
|
||||
omd->repeat_y = 1;
|
||||
|
||||
if (G.relbase_valid) { /* is the .blend saved? */
|
||||
/* subfolder next to saved file */
|
||||
BLI_strncpy(omd->cachepath, "//ocean_cache", cachepathmax);
|
||||
BLI_add_slash(omd->cachepath);
|
||||
}
|
||||
else {
|
||||
/* subfolder in temp. directory */
|
||||
BLI_strncpy(omd->cachepath, BLI_temporary_dir(), cachepathmax);
|
||||
cachepathmax -= strlen(omd->cachepath);
|
||||
if (cachepathmax > 1) {
|
||||
BLI_strncpy(omd->cachepath+strlen(omd->cachepath), "ocean_cache", cachepathmax);
|
||||
cachepathmax -= strlen("ocean_cache");
|
||||
if (cachepathmax > 1)
|
||||
BLI_add_slash(omd->cachepath);
|
||||
}
|
||||
}
|
||||
modifier_path_init(omd->cachepath, sizeof(omd->cachepath), "ocean_cache");
|
||||
|
||||
omd->cached = 0;
|
||||
omd->bakestart = 1;
|
||||
@@ -377,9 +364,9 @@ static DerivedMesh *generate_ocean_geometry(OceanModifierData *omd)
|
||||
return result;
|
||||
}
|
||||
|
||||
static DerivedMesh *doOcean(ModifierData *md, Object *UNUSED(ob),
|
||||
DerivedMesh *derivedData,
|
||||
int UNUSED(useRenderParams))
|
||||
static DerivedMesh *doOcean(ModifierData *md, Object *ob,
|
||||
DerivedMesh *derivedData,
|
||||
int UNUSED(useRenderParams))
|
||||
{
|
||||
OceanModifierData *omd = (OceanModifierData*) md;
|
||||
|
||||
@@ -410,7 +397,7 @@ static DerivedMesh *doOcean(ModifierData *md, Object *UNUSED(ob),
|
||||
|
||||
/* do ocean simulation */
|
||||
if (omd->cached == TRUE) {
|
||||
if (!omd->oceancache) init_cache_data(omd);
|
||||
if (!omd->oceancache) init_cache_data(ob, omd);
|
||||
BKE_simulate_ocean_cache(omd->oceancache, md->scene->r.cfra);
|
||||
} else {
|
||||
simulate_ocean_modifier(omd);
|
||||
|
@@ -56,6 +56,7 @@ static void node_composit_exec_output_file(void *data, bNode *node, bNodeStack *
|
||||
* scrubbing through the timeline when the compositor updates */
|
||||
return;
|
||||
} else {
|
||||
Main *bmain= G.main; /* TODO, have this passed along */
|
||||
CompBuf *cbuf= typecheck_compbuf(in[0]->data, CB_RGBA);
|
||||
ImBuf *ibuf= IMB_allocImBuf(cbuf->x, cbuf->y, 32, 0);
|
||||
char string[256];
|
||||
@@ -74,7 +75,7 @@ static void node_composit_exec_output_file(void *data, bNode *node, bNodeStack *
|
||||
}
|
||||
}
|
||||
|
||||
BKE_makepicstring(string, nif->name, rd->cfra, nif->imtype, (rd->scemode & R_EXTENSION), TRUE);
|
||||
BKE_makepicstring(string, nif->name, bmain->name, rd->cfra, nif->imtype, (rd->scemode & R_EXTENSION), TRUE);
|
||||
|
||||
if(0 == BKE_write_ibuf(ibuf, string, nif->imtype, nif->subimtype, nif->imtype==R_OPENEXR?nif->codec:nif->quality))
|
||||
printf("Cannot save Node File Output to %s\n", string);
|
||||
|
@@ -130,7 +130,7 @@ Render R;
|
||||
|
||||
/* ********* alloc and free ******** */
|
||||
|
||||
static int do_write_image_or_movie(Render *re, Scene *scene, bMovieHandle *mh, const char *name_override);
|
||||
static int do_write_image_or_movie(Render *re, Main *bmain, Scene *scene, bMovieHandle *mh, const char *name_override);
|
||||
|
||||
static volatile int g_break= 0;
|
||||
static int thread_break(void *UNUSED(arg))
|
||||
@@ -2964,10 +2964,10 @@ void RE_BlenderFrame(Render *re, Main *bmain, Scene *scene, SceneRenderLayer *sr
|
||||
}
|
||||
else {
|
||||
char name[FILE_MAX];
|
||||
BKE_makepicstring(name, scene->r.pic, scene->r.cfra, scene->r.imtype, scene->r.scemode & R_EXTENSION, FALSE);
|
||||
|
||||
BKE_makepicstring(name, scene->r.pic, bmain->name, scene->r.cfra, scene->r.imtype, scene->r.scemode & R_EXTENSION, FALSE);
|
||||
|
||||
/* reports only used for Movie */
|
||||
do_write_image_or_movie(re, scene, NULL, name);
|
||||
do_write_image_or_movie(re, bmain, scene, NULL, name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2978,7 +2978,7 @@ void RE_BlenderFrame(Render *re, Main *bmain, Scene *scene, SceneRenderLayer *sr
|
||||
G.rendering= 0;
|
||||
}
|
||||
|
||||
static int do_write_image_or_movie(Render *re, Scene *scene, bMovieHandle *mh, const char *name_override)
|
||||
static int do_write_image_or_movie(Render *re, Main *bmain, Scene *scene, bMovieHandle *mh, const char *name_override)
|
||||
{
|
||||
char name[FILE_MAX];
|
||||
RenderResult rres;
|
||||
@@ -3006,7 +3006,7 @@ static int do_write_image_or_movie(Render *re, Scene *scene, bMovieHandle *mh, c
|
||||
if(name_override)
|
||||
BLI_strncpy(name, name_override, sizeof(name));
|
||||
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, bmain->name, scene->r.cfra, scene->r.imtype, scene->r.scemode & R_EXTENSION, TRUE);
|
||||
|
||||
if(re->r.imtype==R_MULTILAYER) {
|
||||
if(re->result) {
|
||||
@@ -3109,7 +3109,7 @@ void RE_BlenderAnim(Render *re, Main *bmain, Scene *scene, Object *camera_overri
|
||||
do_render_all_options(re);
|
||||
|
||||
if(re->test_break(re->tbh) == 0) {
|
||||
if(!do_write_image_or_movie(re, scene, mh, NULL))
|
||||
if(!do_write_image_or_movie(re, bmain, scene, mh, NULL))
|
||||
G.afbreek= 1;
|
||||
}
|
||||
|
||||
@@ -3151,7 +3151,7 @@ void RE_BlenderAnim(Render *re, Main *bmain, Scene *scene, Object *camera_overri
|
||||
/* Touch/NoOverwrite options are only valid for image's */
|
||||
if(BKE_imtype_is_movie(scene->r.imtype) == 0) {
|
||||
if(scene->r.mode & (R_NO_OVERWRITE | R_TOUCH))
|
||||
BKE_makepicstring(name, scene->r.pic, scene->r.cfra, scene->r.imtype, scene->r.scemode & R_EXTENSION, TRUE);
|
||||
BKE_makepicstring(name, scene->r.pic, bmain->name, scene->r.cfra, scene->r.imtype, scene->r.scemode & R_EXTENSION, TRUE);
|
||||
|
||||
if(scene->r.mode & R_NO_OVERWRITE && BLI_exists(name)) {
|
||||
printf("skipping existing frame \"%s\"\n", name);
|
||||
@@ -3173,7 +3173,7 @@ void RE_BlenderAnim(Render *re, Main *bmain, Scene *scene, Object *camera_overri
|
||||
|
||||
if(re->test_break(re->tbh) == 0) {
|
||||
if(!G.afbreek)
|
||||
if(!do_write_image_or_movie(re, scene, mh, NULL))
|
||||
if(!do_write_image_or_movie(re, bmain, scene, mh, NULL))
|
||||
G.afbreek= 1;
|
||||
}
|
||||
else
|
||||
|
Reference in New Issue
Block a user