Fluid: Fix for relative cache paths
Relative paths in the cache are no longer converted into absolute paths automatically.
This commit is contained in:
parent
597d6be61c
commit
e2c8aa4971
|
@ -330,22 +330,22 @@ void BKE_fluid_cache_free(FluidDomainSettings *mds, Object *ob, int cache_map)
|
|||
{
|
||||
char temp_dir[FILE_MAX];
|
||||
int flags = mds->cache_flag;
|
||||
|
||||
/* Ensure cache directory is not relative */
|
||||
const char *relbase = modifier_path_relbase_from_global(ob);
|
||||
BLI_path_abs(mds->cache_directory, relbase);
|
||||
|
||||
if (cache_map & FLUID_DOMAIN_OUTDATED_DATA) {
|
||||
flags &= ~(FLUID_DOMAIN_BAKING_DATA | FLUID_DOMAIN_BAKED_DATA | FLUID_DOMAIN_OUTDATED_DATA);
|
||||
BLI_path_join(temp_dir, sizeof(temp_dir), mds->cache_directory, FLUID_DOMAIN_DIR_CONFIG, NULL);
|
||||
BLI_path_abs(temp_dir, relbase);
|
||||
if (BLI_exists(temp_dir)) {
|
||||
BLI_delete(temp_dir, true, true);
|
||||
}
|
||||
BLI_path_join(temp_dir, sizeof(temp_dir), mds->cache_directory, FLUID_DOMAIN_DIR_DATA, NULL);
|
||||
BLI_path_abs(temp_dir, relbase);
|
||||
if (BLI_exists(temp_dir)) {
|
||||
BLI_delete(temp_dir, true, true);
|
||||
}
|
||||
BLI_path_join(temp_dir, sizeof(temp_dir), mds->cache_directory, FLUID_DOMAIN_DIR_SCRIPT, NULL);
|
||||
BLI_path_abs(temp_dir, relbase);
|
||||
if (BLI_exists(temp_dir)) {
|
||||
BLI_delete(temp_dir, true, true);
|
||||
}
|
||||
|
@ -354,6 +354,7 @@ void BKE_fluid_cache_free(FluidDomainSettings *mds, Object *ob, int cache_map)
|
|||
if (cache_map & FLUID_DOMAIN_OUTDATED_NOISE) {
|
||||
flags &= ~(FLUID_DOMAIN_BAKING_NOISE | FLUID_DOMAIN_BAKED_NOISE | FLUID_DOMAIN_OUTDATED_NOISE);
|
||||
BLI_path_join(temp_dir, sizeof(temp_dir), mds->cache_directory, FLUID_DOMAIN_DIR_NOISE, NULL);
|
||||
BLI_path_abs(temp_dir, relbase);
|
||||
if (BLI_exists(temp_dir)) {
|
||||
BLI_delete(temp_dir, true, true);
|
||||
}
|
||||
|
@ -362,6 +363,7 @@ void BKE_fluid_cache_free(FluidDomainSettings *mds, Object *ob, int cache_map)
|
|||
if (cache_map & FLUID_DOMAIN_OUTDATED_MESH) {
|
||||
flags &= ~(FLUID_DOMAIN_BAKING_MESH | FLUID_DOMAIN_BAKED_MESH | FLUID_DOMAIN_OUTDATED_MESH);
|
||||
BLI_path_join(temp_dir, sizeof(temp_dir), mds->cache_directory, FLUID_DOMAIN_DIR_MESH, NULL);
|
||||
BLI_path_abs(temp_dir, relbase);
|
||||
if (BLI_exists(temp_dir)) {
|
||||
BLI_delete(temp_dir, true, true);
|
||||
}
|
||||
|
@ -372,6 +374,7 @@ void BKE_fluid_cache_free(FluidDomainSettings *mds, Object *ob, int cache_map)
|
|||
FLUID_DOMAIN_OUTDATED_PARTICLES);
|
||||
BLI_path_join(
|
||||
temp_dir, sizeof(temp_dir), mds->cache_directory, FLUID_DOMAIN_DIR_PARTICLES, NULL);
|
||||
BLI_path_abs(temp_dir, relbase);
|
||||
if (BLI_exists(temp_dir)) {
|
||||
BLI_delete(temp_dir, true, true);
|
||||
}
|
||||
|
@ -381,6 +384,7 @@ void BKE_fluid_cache_free(FluidDomainSettings *mds, Object *ob, int cache_map)
|
|||
if (cache_map & FLUID_DOMAIN_OUTDATED_GUIDE) {
|
||||
flags &= ~(FLUID_DOMAIN_BAKING_GUIDE | FLUID_DOMAIN_BAKED_GUIDE | FLUID_DOMAIN_OUTDATED_GUIDE);
|
||||
BLI_path_join(temp_dir, sizeof(temp_dir), mds->cache_directory, FLUID_DOMAIN_DIR_GUIDE, NULL);
|
||||
BLI_path_abs(temp_dir, relbase);
|
||||
if (BLI_exists(temp_dir)) {
|
||||
BLI_delete(temp_dir, true, true);
|
||||
}
|
||||
|
|
|
@ -178,11 +178,12 @@ static bool fluid_initjob(
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool fluid_initpaths(FluidJob *job, ReportList *reports)
|
||||
static bool fluid_validatepaths(FluidJob *job, ReportList *reports)
|
||||
{
|
||||
FluidDomainSettings *mds = job->mmd->domain;
|
||||
char temp_dir[FILE_MAX];
|
||||
temp_dir[0] = '\0';
|
||||
bool is_relative = false;
|
||||
|
||||
const char *relbase = modifier_path_relbase(job->bmain, job->ob);
|
||||
|
||||
|
@ -197,7 +198,7 @@ static bool fluid_initpaths(FluidJob *job, ReportList *reports)
|
|||
}
|
||||
|
||||
BLI_strncpy(temp_dir, mds->cache_directory, FILE_MAXDIR);
|
||||
BLI_path_abs(temp_dir, relbase);
|
||||
is_relative = BLI_path_abs(temp_dir, relbase);
|
||||
|
||||
/* Ensure whole path exists */
|
||||
const bool dir_exists = BLI_dir_create_recursive(temp_dir);
|
||||
|
@ -215,7 +216,6 @@ static bool fluid_initpaths(FluidJob *job, ReportList *reports)
|
|||
mds->cache_directory);
|
||||
|
||||
BLI_strncpy(temp_dir, mds->cache_directory, FILE_MAXDIR);
|
||||
BLI_path_abs(temp_dir, relbase);
|
||||
|
||||
/* Ensure whole path exists and is writable. */
|
||||
if (!BLI_dir_create_recursive(temp_dir)) {
|
||||
|
@ -224,6 +224,7 @@ static bool fluid_initpaths(FluidJob *job, ReportList *reports)
|
|||
"Fluid: Could not use default cache directory '%s', "
|
||||
"please define a valid cache path manually",
|
||||
temp_dir);
|
||||
return false;
|
||||
}
|
||||
/* Copy final dir back into domain settings */
|
||||
BLI_strncpy(mds->cache_directory, temp_dir, FILE_MAXDIR);
|
||||
|
@ -231,6 +232,11 @@ static bool fluid_initpaths(FluidJob *job, ReportList *reports)
|
|||
return false;
|
||||
}
|
||||
|
||||
/* Change path back to is original state (ie relative or absolute). */
|
||||
if (is_relative) {
|
||||
BLI_path_rel(temp_dir, relbase);
|
||||
}
|
||||
|
||||
/* Copy final dir back into domain settings */
|
||||
BLI_strncpy(mds->cache_directory, temp_dir, FILE_MAXDIR);
|
||||
return true;
|
||||
|
@ -521,7 +527,7 @@ static int fluid_bake_exec(struct bContext *C, struct wmOperator *op)
|
|||
fluid_bake_free(job);
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
if (!fluid_initpaths(job, op->reports)) {
|
||||
if (!fluid_validatepaths(job, op->reports)) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
fluid_bake_startjob(job, NULL, NULL, NULL);
|
||||
|
@ -547,7 +553,7 @@ static int fluid_bake_invoke(struct bContext *C,
|
|||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
if (!fluid_initpaths(job, op->reports)) {
|
||||
if (!fluid_validatepaths(job, op->reports)) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
|
@ -621,7 +627,7 @@ static int fluid_free_exec(struct bContext *C, struct wmOperator *op)
|
|||
job->type = op->type->idname;
|
||||
job->name = op->type->name;
|
||||
|
||||
if (!fluid_initpaths(job, op->reports)) {
|
||||
if (!fluid_validatepaths(job, op->reports)) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue