forked from bartvdbraak/blender
Fix T79941: mantaflow cache doesn't work with ' character in path
The fix is to escape the `'` character as well. Reviewers: sebbas Differential Revision: https://developer.blender.org/D8773
This commit is contained in:
parent
a708cdabe6
commit
fec522be6a
@ -1086,15 +1086,19 @@ string MANTA::parseScript(const string &setup_string, FluidModifierData *fmd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Dirty hack: Needed to format paths from python code that is run via PyRun_SimpleString */
|
/* Dirty hack: Needed to format paths from python code that is run via PyRun_SimpleString */
|
||||||
static string escapeSlashes(string const &s)
|
static string escapePath(string const &s)
|
||||||
{
|
{
|
||||||
string result = "";
|
string result = "";
|
||||||
for (string::const_iterator i = s.begin(), end = s.end(); i != end; ++i) {
|
for (char c : s) {
|
||||||
unsigned char c = *i;
|
if (c == '\\') {
|
||||||
if (c == '\\')
|
|
||||||
result += "\\\\";
|
result += "\\\\";
|
||||||
else
|
}
|
||||||
|
else if (c == '\'') {
|
||||||
|
result += "\\\'";
|
||||||
|
}
|
||||||
|
else {
|
||||||
result += c;
|
result += c;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -1155,13 +1159,13 @@ bool MANTA::writeData(FluidModifierData *fmd, int framenr)
|
|||||||
|
|
||||||
if (mUsingSmoke) {
|
if (mUsingSmoke) {
|
||||||
ss.str("");
|
ss.str("");
|
||||||
ss << "smoke_save_data_" << mCurrentID << "('" << escapeSlashes(directory) << "', " << framenr
|
ss << "smoke_save_data_" << mCurrentID << "('" << escapePath(directory) << "', " << framenr
|
||||||
<< ", '" << volume_format << "', " << resumable_cache << ")";
|
<< ", '" << volume_format << "', " << resumable_cache << ")";
|
||||||
pythonCommands.push_back(ss.str());
|
pythonCommands.push_back(ss.str());
|
||||||
}
|
}
|
||||||
if (mUsingLiquid) {
|
if (mUsingLiquid) {
|
||||||
ss.str("");
|
ss.str("");
|
||||||
ss << "liquid_save_data_" << mCurrentID << "('" << escapeSlashes(directory) << "', " << framenr
|
ss << "liquid_save_data_" << mCurrentID << "('" << escapePath(directory) << "', " << framenr
|
||||||
<< ", '" << volume_format << "', " << resumable_cache << ")";
|
<< ", '" << volume_format << "', " << resumable_cache << ")";
|
||||||
pythonCommands.push_back(ss.str());
|
pythonCommands.push_back(ss.str());
|
||||||
}
|
}
|
||||||
@ -1183,7 +1187,7 @@ bool MANTA::writeNoise(FluidModifierData *fmd, int framenr)
|
|||||||
|
|
||||||
if (mUsingSmoke && mUsingNoise) {
|
if (mUsingSmoke && mUsingNoise) {
|
||||||
ss.str("");
|
ss.str("");
|
||||||
ss << "smoke_save_noise_" << mCurrentID << "('" << escapeSlashes(directory) << "', " << framenr
|
ss << "smoke_save_noise_" << mCurrentID << "('" << escapePath(directory) << "', " << framenr
|
||||||
<< ", '" << volume_format << "', " << resumable_cache << ")";
|
<< ", '" << volume_format << "', " << resumable_cache << ")";
|
||||||
pythonCommands.push_back(ss.str());
|
pythonCommands.push_back(ss.str());
|
||||||
}
|
}
|
||||||
@ -1256,7 +1260,7 @@ bool MANTA::readData(FluidModifierData *fmd, int framenr, bool resumable)
|
|||||||
|
|
||||||
if (mUsingSmoke) {
|
if (mUsingSmoke) {
|
||||||
ss.str("");
|
ss.str("");
|
||||||
ss << "smoke_load_data_" << mCurrentID << "('" << escapeSlashes(directory) << "', " << framenr
|
ss << "smoke_load_data_" << mCurrentID << "('" << escapePath(directory) << "', " << framenr
|
||||||
<< ", '" << volume_format << "', " << resumable_cache << ")";
|
<< ", '" << volume_format << "', " << resumable_cache << ")";
|
||||||
pythonCommands.push_back(ss.str());
|
pythonCommands.push_back(ss.str());
|
||||||
result &= runPythonString(pythonCommands);
|
result &= runPythonString(pythonCommands);
|
||||||
@ -1264,7 +1268,7 @@ bool MANTA::readData(FluidModifierData *fmd, int framenr, bool resumable)
|
|||||||
}
|
}
|
||||||
if (mUsingLiquid) {
|
if (mUsingLiquid) {
|
||||||
ss.str("");
|
ss.str("");
|
||||||
ss << "liquid_load_data_" << mCurrentID << "('" << escapeSlashes(directory) << "', " << framenr
|
ss << "liquid_load_data_" << mCurrentID << "('" << escapePath(directory) << "', " << framenr
|
||||||
<< ", '" << volume_format << "', " << resumable_cache << ")";
|
<< ", '" << volume_format << "', " << resumable_cache << ")";
|
||||||
pythonCommands.push_back(ss.str());
|
pythonCommands.push_back(ss.str());
|
||||||
result &= runPythonString(pythonCommands);
|
result &= runPythonString(pythonCommands);
|
||||||
@ -1298,7 +1302,7 @@ bool MANTA::readNoise(FluidModifierData *fmd, int framenr, bool resumable)
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
ss.str("");
|
ss.str("");
|
||||||
ss << "smoke_load_noise_" << mCurrentID << "('" << escapeSlashes(directory) << "', " << framenr
|
ss << "smoke_load_noise_" << mCurrentID << "('" << escapePath(directory) << "', " << framenr
|
||||||
<< ", '" << volume_format << "', " << resumable_cache << ")";
|
<< ", '" << volume_format << "', " << resumable_cache << ")";
|
||||||
pythonCommands.push_back(ss.str());
|
pythonCommands.push_back(ss.str());
|
||||||
|
|
||||||
@ -1326,14 +1330,14 @@ bool MANTA::readMesh(FluidModifierData *fmd, int framenr)
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
ss.str("");
|
ss.str("");
|
||||||
ss << "liquid_load_mesh_" << mCurrentID << "('" << escapeSlashes(directory) << "', " << framenr
|
ss << "liquid_load_mesh_" << mCurrentID << "('" << escapePath(directory) << "', " << framenr
|
||||||
<< ", '" << mesh_format << "')";
|
<< ", '" << mesh_format << "')";
|
||||||
pythonCommands.push_back(ss.str());
|
pythonCommands.push_back(ss.str());
|
||||||
|
|
||||||
if (mUsingMVel) {
|
if (mUsingMVel) {
|
||||||
ss.str("");
|
ss.str("");
|
||||||
ss << "liquid_load_meshvel_" << mCurrentID << "('" << escapeSlashes(directory) << "', "
|
ss << "liquid_load_meshvel_" << mCurrentID << "('" << escapePath(directory) << "', " << framenr
|
||||||
<< framenr << ", '" << volume_format << "')";
|
<< ", '" << volume_format << "')";
|
||||||
pythonCommands.push_back(ss.str());
|
pythonCommands.push_back(ss.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1367,8 +1371,8 @@ bool MANTA::readParticles(FluidModifierData *fmd, int framenr, bool resumable)
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
ss.str("");
|
ss.str("");
|
||||||
ss << "liquid_load_particles_" << mCurrentID << "('" << escapeSlashes(directory) << "', "
|
ss << "liquid_load_particles_" << mCurrentID << "('" << escapePath(directory) << "', " << framenr
|
||||||
<< framenr << ", '" << volume_format << "', " << resumable_cache << ")";
|
<< ", '" << volume_format << "', " << resumable_cache << ")";
|
||||||
pythonCommands.push_back(ss.str());
|
pythonCommands.push_back(ss.str());
|
||||||
|
|
||||||
return (mParticlesFromFile = runPythonString(pythonCommands));
|
return (mParticlesFromFile = runPythonString(pythonCommands));
|
||||||
@ -1399,13 +1403,13 @@ bool MANTA::readGuiding(FluidModifierData *fmd, int framenr, bool sourceDomain)
|
|||||||
|
|
||||||
if (sourceDomain) {
|
if (sourceDomain) {
|
||||||
ss.str("");
|
ss.str("");
|
||||||
ss << "fluid_load_vel_" << mCurrentID << "('" << escapeSlashes(directory) << "', " << framenr
|
ss << "fluid_load_vel_" << mCurrentID << "('" << escapePath(directory) << "', " << framenr
|
||||||
<< ", '" << volume_format << "')";
|
<< ", '" << volume_format << "')";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ss.str("");
|
ss.str("");
|
||||||
ss << "fluid_load_guiding_" << mCurrentID << "('" << escapeSlashes(directory) << "', "
|
ss << "fluid_load_guiding_" << mCurrentID << "('" << escapePath(directory) << "', " << framenr
|
||||||
<< framenr << ", '" << volume_format << "')";
|
<< ", '" << volume_format << "')";
|
||||||
}
|
}
|
||||||
pythonCommands.push_back(ss.str());
|
pythonCommands.push_back(ss.str());
|
||||||
|
|
||||||
@ -1439,7 +1443,7 @@ bool MANTA::bakeData(FluidModifierData *fmd, int framenr)
|
|||||||
BLI_path_make_safe(cacheDirGuiding);
|
BLI_path_make_safe(cacheDirGuiding);
|
||||||
|
|
||||||
ss.str("");
|
ss.str("");
|
||||||
ss << "bake_fluid_data_" << mCurrentID << "('" << escapeSlashes(cacheDirData) << "', " << framenr
|
ss << "bake_fluid_data_" << mCurrentID << "('" << escapePath(cacheDirData) << "', " << framenr
|
||||||
<< ", '" << volume_format << "')";
|
<< ", '" << volume_format << "')";
|
||||||
pythonCommands.push_back(ss.str());
|
pythonCommands.push_back(ss.str());
|
||||||
|
|
||||||
@ -1465,7 +1469,7 @@ bool MANTA::bakeNoise(FluidModifierData *fmd, int framenr)
|
|||||||
BLI_path_make_safe(cacheDirNoise);
|
BLI_path_make_safe(cacheDirNoise);
|
||||||
|
|
||||||
ss.str("");
|
ss.str("");
|
||||||
ss << "bake_noise_" << mCurrentID << "('" << escapeSlashes(cacheDirNoise) << "', " << framenr
|
ss << "bake_noise_" << mCurrentID << "('" << escapePath(cacheDirNoise) << "', " << framenr
|
||||||
<< ", '" << volume_format << "')";
|
<< ", '" << volume_format << "')";
|
||||||
pythonCommands.push_back(ss.str());
|
pythonCommands.push_back(ss.str());
|
||||||
|
|
||||||
@ -1492,8 +1496,8 @@ bool MANTA::bakeMesh(FluidModifierData *fmd, int framenr)
|
|||||||
BLI_path_make_safe(cacheDirMesh);
|
BLI_path_make_safe(cacheDirMesh);
|
||||||
|
|
||||||
ss.str("");
|
ss.str("");
|
||||||
ss << "bake_mesh_" << mCurrentID << "('" << escapeSlashes(cacheDirMesh) << "', " << framenr
|
ss << "bake_mesh_" << mCurrentID << "('" << escapePath(cacheDirMesh) << "', " << framenr << ", '"
|
||||||
<< ", '" << volume_format << "', '" << mesh_format << "')";
|
<< volume_format << "', '" << mesh_format << "')";
|
||||||
pythonCommands.push_back(ss.str());
|
pythonCommands.push_back(ss.str());
|
||||||
|
|
||||||
return runPythonString(pythonCommands);
|
return runPythonString(pythonCommands);
|
||||||
@ -1522,7 +1526,7 @@ bool MANTA::bakeParticles(FluidModifierData *fmd, int framenr)
|
|||||||
BLI_path_make_safe(cacheDirParticles);
|
BLI_path_make_safe(cacheDirParticles);
|
||||||
|
|
||||||
ss.str("");
|
ss.str("");
|
||||||
ss << "bake_particles_" << mCurrentID << "('" << escapeSlashes(cacheDirParticles) << "', "
|
ss << "bake_particles_" << mCurrentID << "('" << escapePath(cacheDirParticles) << "', "
|
||||||
<< framenr << ", '" << volume_format << "', " << resumable_cache << ")";
|
<< framenr << ", '" << volume_format << "', " << resumable_cache << ")";
|
||||||
pythonCommands.push_back(ss.str());
|
pythonCommands.push_back(ss.str());
|
||||||
|
|
||||||
@ -1552,7 +1556,7 @@ bool MANTA::bakeGuiding(FluidModifierData *fmd, int framenr)
|
|||||||
BLI_path_make_safe(cacheDirGuiding);
|
BLI_path_make_safe(cacheDirGuiding);
|
||||||
|
|
||||||
ss.str("");
|
ss.str("");
|
||||||
ss << "bake_guiding_" << mCurrentID << "('" << escapeSlashes(cacheDirGuiding) << "', " << framenr
|
ss << "bake_guiding_" << mCurrentID << "('" << escapePath(cacheDirGuiding) << "', " << framenr
|
||||||
<< ", '" << volume_format << "', " << resumable_cache << ")";
|
<< ", '" << volume_format << "', " << resumable_cache << ")";
|
||||||
pythonCommands.push_back(ss.str());
|
pythonCommands.push_back(ss.str());
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user