Fix T74525: Fluid caches overwrite each other by default
Reviewers: sebbas Differential Revision: https://developer.blender.org/D7093
This commit is contained in:
parent
a6d7280b8e
commit
0f1f751785
Notes:
blender-bot
2023-02-14 05:16:25 +01:00
Referenced by issue #74525, Mantaflow: By default, having more than one fluid domain overwrites cache of first one
|
@ -62,6 +62,7 @@ void BKE_fluid_reallocate_copy_fluid(struct FluidDomainSettings *mds,
|
|||
int o_shift[3],
|
||||
int n_shift[3]);
|
||||
void BKE_fluid_cache_free(struct FluidDomainSettings *mds, struct Object *ob, int cache_map);
|
||||
void BKE_fluid_cache_new_name_for_current_session(int maxlen, char *r_name);
|
||||
|
||||
float BKE_fluid_get_velocity_at(struct Object *ob, float position[3], float velocity[3]);
|
||||
int BKE_fluid_get_data_flags(struct FluidDomainSettings *mds);
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "BLI_listbase.h"
|
||||
|
||||
#include "BLI_fileops.h"
|
||||
#include "BLI_hash.h"
|
||||
#include "BLI_math.h"
|
||||
#include "BLI_path_util.h"
|
||||
#include "BLI_string.h"
|
||||
|
@ -4810,9 +4811,10 @@ void BKE_fluid_modifier_create_type_data(struct FluidModifierData *mmd)
|
|||
mmd->domain->cache_particle_format = FLUID_DOMAIN_FILE_UNI;
|
||||
mmd->domain->cache_noise_format = FLUID_DOMAIN_FILE_UNI;
|
||||
#endif
|
||||
modifier_path_init(mmd->domain->cache_directory,
|
||||
sizeof(mmd->domain->cache_directory),
|
||||
FLUID_DOMAIN_DIR_DEFAULT);
|
||||
char cache_name[64];
|
||||
BKE_fluid_cache_new_name_for_current_session(sizeof(cache_name), cache_name);
|
||||
modifier_path_init(
|
||||
mmd->domain->cache_directory, sizeof(mmd->domain->cache_directory), cache_name);
|
||||
|
||||
/* time options */
|
||||
mmd->domain->time_scale = 1.0;
|
||||
|
@ -5148,4 +5150,11 @@ void BKE_fluid_modifier_copy(const struct FluidModifierData *mmd,
|
|||
}
|
||||
}
|
||||
|
||||
void BKE_fluid_cache_new_name_for_current_session(int maxlen, char *r_name)
|
||||
{
|
||||
static int counter = 1;
|
||||
BLI_snprintf(r_name, maxlen, FLUID_DOMAIN_DIR_DEFAULT "_%x", BLI_hash_int(counter));
|
||||
counter++;
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
|
|
@ -189,8 +189,9 @@ static bool fluid_validatepaths(FluidJob *job, ReportList *reports)
|
|||
|
||||
/* We do not accept empty paths, they can end in random places silently, see T51176. */
|
||||
if (mds->cache_directory[0] == '\0') {
|
||||
modifier_path_init(
|
||||
mds->cache_directory, sizeof(mds->cache_directory), FLUID_DOMAIN_DIR_DEFAULT);
|
||||
char cache_name[64];
|
||||
BKE_fluid_cache_new_name_for_current_session(sizeof(cache_name), cache_name);
|
||||
modifier_path_init(mds->cache_directory, sizeof(mds->cache_directory), cache_name);
|
||||
BKE_reportf(reports,
|
||||
RPT_WARNING,
|
||||
"Fluid: Empty cache path, reset to default '%s'",
|
||||
|
@ -206,8 +207,9 @@ static bool fluid_validatepaths(FluidJob *job, ReportList *reports)
|
|||
/* We change path to some presumably valid default value, but do not allow bake process to
|
||||
* continue, this gives user chance to set manually another path. */
|
||||
if (!dir_exists) {
|
||||
modifier_path_init(
|
||||
mds->cache_directory, sizeof(mds->cache_directory), FLUID_DOMAIN_DIR_DEFAULT);
|
||||
char cache_name[64];
|
||||
BKE_fluid_cache_new_name_for_current_session(sizeof(cache_name), cache_name);
|
||||
modifier_path_init(mds->cache_directory, sizeof(mds->cache_directory), cache_name);
|
||||
|
||||
BKE_reportf(reports,
|
||||
RPT_ERROR,
|
||||
|
|
Loading…
Reference in New Issue