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:
authorSebastián Barschkis <sebbas@sebbas.org>2020-11-06 16:35:22 +0300
committerSebastián Barschkis <sebbas@sebbas.org>2020-11-06 16:35:40 +0300
commit6bca9d8c113e80aa9550229719b7c59c34e46bb5 (patch)
tree7350bf400a7fafd449ebeb9838d1301e1bb484d2 /intern/mantaflow/intern/MANTA_main.cpp
parentaf35ada2f3fa8da4d46b3a71de724d353d716820 (diff)
Cleanup: Fluid engine API return types
Use bool return type where possible instead of int (the return values from fluid object are already boolean instead of int). Also removed several if guards in API functions. If one of the arguments is in fact invalid / nullptr (should not happen though), it better to catch them directly where they failed and not silently escape them.
Diffstat (limited to 'intern/mantaflow/intern/MANTA_main.cpp')
-rw-r--r--intern/mantaflow/intern/MANTA_main.cpp33
1 files changed, 19 insertions, 14 deletions
diff --git a/intern/mantaflow/intern/MANTA_main.cpp b/intern/mantaflow/intern/MANTA_main.cpp
index 0dbbd1ee9d0..fef6399ab23 100644
--- a/intern/mantaflow/intern/MANTA_main.cpp
+++ b/intern/mantaflow/intern/MANTA_main.cpp
@@ -458,8 +458,7 @@ bool MANTA::initObstacle(FluidModifierData *fmd)
string finalString = parseScript(tmpString, fmd);
pythonCommands.push_back(finalString);
- mUsingObstacle = true;
- return runPythonString(pythonCommands);
+ return (mUsingObstacle = runPythonString(pythonCommands));
}
return false;
}
@@ -473,8 +472,7 @@ bool MANTA::initGuiding(FluidModifierData *fmd)
string finalString = parseScript(tmpString, fmd);
pythonCommands.push_back(finalString);
- mUsingGuiding = true;
- return runPythonString(pythonCommands);
+ return (mUsingGuiding = runPythonString(pythonCommands));
}
return false;
}
@@ -486,8 +484,7 @@ bool MANTA::initFractions(FluidModifierData *fmd)
string finalString = parseScript(tmpString, fmd);
pythonCommands.push_back(finalString);
- mUsingFractions = true;
- return runPythonString(pythonCommands);
+ return (mUsingFractions = runPythonString(pythonCommands));
}
bool MANTA::initInVelocity(FluidModifierData *fmd)
@@ -498,8 +495,7 @@ bool MANTA::initInVelocity(FluidModifierData *fmd)
string finalString = parseScript(tmpString, fmd);
pythonCommands.push_back(finalString);
- mUsingInvel = true;
- return runPythonString(pythonCommands);
+ return (mUsingInvel = runPythonString(pythonCommands));
}
return false;
}
@@ -512,8 +508,7 @@ bool MANTA::initOutflow(FluidModifierData *fmd)
string finalString = parseScript(tmpString, fmd);
pythonCommands.push_back(finalString);
- mUsingOutflow = true;
- return runPythonString(pythonCommands);
+ return (mUsingOutflow = runPythonString(pythonCommands));
}
return false;
}
@@ -565,7 +560,7 @@ MANTA::~MANTA()
pythonCommands.push_back(finalString);
result = runPythonString(pythonCommands);
- assert(result);
+ BLI_assert(result);
UNUSED_VARS(result);
}
@@ -610,7 +605,7 @@ bool MANTA::runPythonString(vector<string> commands)
}
PyGILState_Release(gilstate);
- assert(success);
+ BLI_assert(success);
return success;
}
@@ -1590,7 +1585,7 @@ bool MANTA::updateVariables(FluidModifierData *fmd)
return runPythonString(pythonCommands);
}
-void MANTA::exportSmokeScript(FluidModifierData *fmd)
+bool MANTA::exportSmokeScript(FluidModifierData *fmd)
{
if (with_debug)
cout << "MANTA::exportSmokeScript()" << endl;
@@ -1696,9 +1691,14 @@ void MANTA::exportSmokeScript(FluidModifierData *fmd)
myfile.open(cacheDirScript);
myfile << final_script;
myfile.close();
+ if (!myfile) {
+ cerr << "Fluid Error -- Could not export standalone Mantaflow smoke domain script";
+ return false;
+ }
+ return true;
}
-void MANTA::exportLiquidScript(FluidModifierData *fmd)
+bool MANTA::exportLiquidScript(FluidModifierData *fmd)
{
if (with_debug)
cout << "MANTA::exportLiquidScript()" << endl;
@@ -1804,6 +1804,11 @@ void MANTA::exportLiquidScript(FluidModifierData *fmd)
myfile.open(cacheDirScript);
myfile << final_script;
myfile.close();
+ if (!myfile) {
+ cerr << "Fluid Error -- Could not export standalone Mantaflow liquid domain script";
+ return false;
+ }
+ return true;
}
/* Call Mantaflow Python functions through this function. Use isAttribute for object attributes,