Fluid: Refactored the Mantaflow <-> Blender pointer exchange function and switched to from NULL to nullptr in cpp files

This commit is contained in:
Sebastián Barschkis
2020-01-21 18:30:55 +01:00
parent 5168408ae5
commit 6c50e82efb
3 changed files with 270 additions and 273 deletions

View File

@@ -84,81 +84,81 @@ MANTA::MANTA(int *res, FluidModifierData *mmd) : mCurrentID(++solverID)
mResGuiding = mmd->domain->res;
// Smoke low res grids
mDensity = NULL;
mShadow = NULL;
mHeat = NULL;
mVelocityX = NULL;
mVelocityY = NULL;
mVelocityZ = NULL;
mForceX = NULL;
mForceY = NULL;
mForceZ = NULL;
mFlame = NULL;
mFuel = NULL;
mReact = NULL;
mColorR = NULL;
mColorG = NULL;
mColorB = NULL;
mObstacle = NULL;
mDensityIn = NULL;
mHeatIn = NULL;
mColorRIn = NULL;
mColorGIn = NULL;
mColorBIn = NULL;
mFuelIn = NULL;
mReactIn = NULL;
mEmissionIn = NULL;
mDensity = nullptr;
mShadow = nullptr;
mHeat = nullptr;
mVelocityX = nullptr;
mVelocityY = nullptr;
mVelocityZ = nullptr;
mForceX = nullptr;
mForceY = nullptr;
mForceZ = nullptr;
mFlame = nullptr;
mFuel = nullptr;
mReact = nullptr;
mColorR = nullptr;
mColorG = nullptr;
mColorB = nullptr;
mObstacle = nullptr;
mDensityIn = nullptr;
mHeatIn = nullptr;
mColorRIn = nullptr;
mColorGIn = nullptr;
mColorBIn = nullptr;
mFuelIn = nullptr;
mReactIn = nullptr;
mEmissionIn = nullptr;
// Smoke high res grids
mDensityHigh = NULL;
mFlameHigh = NULL;
mFuelHigh = NULL;
mReactHigh = NULL;
mColorRHigh = NULL;
mColorGHigh = NULL;
mColorBHigh = NULL;
mTextureU = NULL;
mTextureV = NULL;
mTextureW = NULL;
mTextureU2 = NULL;
mTextureV2 = NULL;
mTextureW2 = NULL;
mDensityHigh = nullptr;
mFlameHigh = nullptr;
mFuelHigh = nullptr;
mReactHigh = nullptr;
mColorRHigh = nullptr;
mColorGHigh = nullptr;
mColorBHigh = nullptr;
mTextureU = nullptr;
mTextureV = nullptr;
mTextureW = nullptr;
mTextureU2 = nullptr;
mTextureV2 = nullptr;
mTextureW2 = nullptr;
// Fluid low res grids
mPhiIn = NULL;
mPhiOutIn = NULL;
mPhi = NULL;
mPhiIn = nullptr;
mPhiOutIn = nullptr;
mPhi = nullptr;
// Mesh
mMeshNodes = NULL;
mMeshTriangles = NULL;
mMeshVelocities = NULL;
mMeshNodes = nullptr;
mMeshTriangles = nullptr;
mMeshVelocities = nullptr;
// Fluid obstacle
mPhiObsIn = NULL;
mNumObstacle = NULL;
mObVelocityX = NULL;
mObVelocityY = NULL;
mObVelocityZ = NULL;
mPhiObsIn = nullptr;
mNumObstacle = nullptr;
mObVelocityX = nullptr;
mObVelocityY = nullptr;
mObVelocityZ = nullptr;
// Fluid guiding
mPhiGuideIn = NULL;
mNumGuide = NULL;
mGuideVelocityX = NULL;
mGuideVelocityY = NULL;
mGuideVelocityZ = NULL;
mPhiGuideIn = nullptr;
mNumGuide = nullptr;
mGuideVelocityX = nullptr;
mGuideVelocityY = nullptr;
mGuideVelocityZ = nullptr;
// Fluid initial velocity
mInVelocityX = NULL;
mInVelocityY = NULL;
mInVelocityZ = NULL;
mInVelocityX = nullptr;
mInVelocityY = nullptr;
mInVelocityZ = nullptr;
// Secondary particles
mFlipParticleData = NULL;
mFlipParticleVelocity = NULL;
mSndParticleData = NULL;
mSndParticleVelocity = NULL;
mSndParticleLife = NULL;
mFlipParticleData = nullptr;
mFlipParticleVelocity = nullptr;
mSndParticleData = nullptr;
mSndParticleVelocity = nullptr;
mSndParticleLife = nullptr;
// Cache read success indicators
mFlipFromFile = false;
@@ -1029,7 +1029,7 @@ int MANTA::updateFlipStructures(FluidModifierData *mmd, int framenr)
std::string pformat = getCacheFileEnding(mmd->domain->cache_particle_format);
BLI_path_join(
cacheDir, sizeof(cacheDir), mmd->domain->cache_directory, FLUID_DOMAIN_DIR_DATA, NULL);
cacheDir, sizeof(cacheDir), mmd->domain->cache_directory, FLUID_DOMAIN_DIR_DATA, nullptr);
// TODO (sebbas): Use pp_xl and pVel_xl when using upres simulation?
@@ -1081,7 +1081,7 @@ int MANTA::updateMeshStructures(FluidModifierData *mmd, int framenr)
std::string mformat = getCacheFileEnding(mmd->domain->cache_mesh_format);
std::string dformat = getCacheFileEnding(mmd->domain->cache_data_format);
BLI_path_join(
cacheDir, sizeof(cacheDir), mmd->domain->cache_directory, FLUID_DOMAIN_DIR_MESH, NULL);
cacheDir, sizeof(cacheDir), mmd->domain->cache_directory, FLUID_DOMAIN_DIR_MESH, nullptr);
ss << "lMesh_####" << mformat;
BLI_join_dirfile(targetFile, sizeof(targetFile), cacheDir, ss.str().c_str());
@@ -1131,8 +1131,11 @@ int MANTA::updateParticleStructures(FluidModifierData *mmd, int framenr)
targetFile[0] = '\0';
std::string pformat = getCacheFileEnding(mmd->domain->cache_particle_format);
BLI_path_join(
cacheDir, sizeof(cacheDir), mmd->domain->cache_directory, FLUID_DOMAIN_DIR_PARTICLES, NULL);
BLI_path_join(cacheDir,
sizeof(cacheDir),
mmd->domain->cache_directory,
FLUID_DOMAIN_DIR_PARTICLES,
nullptr);
ss << "ppSnd_####" << pformat;
BLI_join_dirfile(targetFile, sizeof(targetFile), cacheDir, ss.str().c_str());
@@ -1192,7 +1195,7 @@ int MANTA::writeConfiguration(FluidModifierData *mmd, int framenr)
std::string dformat = getCacheFileEnding(mmd->domain->cache_data_format);
BLI_path_join(
cacheDir, sizeof(cacheDir), mmd->domain->cache_directory, FLUID_DOMAIN_DIR_CONFIG, NULL);
cacheDir, sizeof(cacheDir), mmd->domain->cache_directory, FLUID_DOMAIN_DIR_CONFIG, nullptr);
BLI_path_make_safe(cacheDir);
BLI_dir_create_recursive(cacheDir); /* Create 'config' subdir if it does not exist already */
@@ -1246,7 +1249,7 @@ int MANTA::writeData(FluidModifierData *mmd, int framenr)
sizeof(cacheDirData),
mmd->domain->cache_directory,
FLUID_DOMAIN_DIR_DATA,
NULL);
nullptr);
BLI_path_make_safe(cacheDirData);
ss.str("");
@@ -1285,7 +1288,7 @@ int MANTA::readConfiguration(FluidModifierData *mmd, int framenr)
std::string dformat = getCacheFileEnding(mmd->domain->cache_data_format);
BLI_path_join(
cacheDir, sizeof(cacheDir), mmd->domain->cache_directory, FLUID_DOMAIN_DIR_CONFIG, NULL);
cacheDir, sizeof(cacheDir), mmd->domain->cache_directory, FLUID_DOMAIN_DIR_CONFIG, nullptr);
BLI_path_make_safe(cacheDir);
ss.str("");
@@ -1345,16 +1348,25 @@ int MANTA::readData(FluidModifierData *mmd, int framenr)
sizeof(cacheDirData),
mmd->domain->cache_directory,
FLUID_DOMAIN_DIR_DATA,
NULL);
nullptr);
BLI_path_make_safe(cacheDirData);
/* Exit early if there is nothing present in the cache for this frame */
ss.str("");
ss << "vel_####" << dformat;
BLI_join_dirfile(targetFile, sizeof(targetFile), cacheDirData, ss.str().c_str());
BLI_path_frame(targetFile, framenr, 0);
if (!BLI_exists(targetFile))
return 0;
if (mUsingSmoke) {
ss << "density_####" << dformat;
BLI_join_dirfile(targetFile, sizeof(targetFile), cacheDirData, ss.str().c_str());
BLI_path_frame(targetFile, framenr, 0);
if (!BLI_exists(targetFile))
return 0;
}
if (mUsingLiquid) {
ss << "phi_####" << dformat;
BLI_join_dirfile(targetFile, sizeof(targetFile), cacheDirData, ss.str().c_str());
BLI_path_frame(targetFile, framenr, 0);
if (!BLI_exists(targetFile))
return 0;
}
ss.str("");
ss << "fluid_load_data_" << mCurrentID << "('" << escapeSlashes(cacheDirData) << "', " << framenr
@@ -1402,7 +1414,7 @@ int MANTA::readNoise(FluidModifierData *mmd, int framenr)
sizeof(cacheDirNoise),
mmd->domain->cache_directory,
FLUID_DOMAIN_DIR_NOISE,
NULL);
nullptr);
BLI_path_make_safe(cacheDirNoise);
/* Exit early if there is nothing present in the cache for this frame */
@@ -1447,7 +1459,7 @@ int MANTA::readMesh(FluidModifierData *mmd, int framenr)
sizeof(cacheDirMesh),
mmd->domain->cache_directory,
FLUID_DOMAIN_DIR_MESH,
NULL);
nullptr);
BLI_path_make_safe(cacheDirMesh);
/* Exit early if there is nothing present in the cache for this frame */
@@ -1503,7 +1515,7 @@ int MANTA::readParticles(FluidModifierData *mmd, int framenr)
sizeof(cacheDirParticles),
mmd->domain->cache_directory,
FLUID_DOMAIN_DIR_PARTICLES,
NULL);
nullptr);
BLI_path_make_safe(cacheDirParticles);
/* Exit early if there is nothing present in the cache for this frame */
@@ -1544,7 +1556,7 @@ int MANTA::readGuiding(FluidModifierData *mmd, int framenr, bool sourceDomain)
const char *subdir = (sourceDomain) ? FLUID_DOMAIN_DIR_DATA : FLUID_DOMAIN_DIR_GUIDE;
BLI_path_join(
cacheDirGuiding, sizeof(cacheDirGuiding), mmd->domain->cache_directory, subdir, NULL);
cacheDirGuiding, sizeof(cacheDirGuiding), mmd->domain->cache_directory, subdir, nullptr);
BLI_path_make_safe(cacheDirGuiding);
/* Exit early if there is nothing present in the cache for this frame */
@@ -1592,12 +1604,12 @@ int MANTA::bakeData(FluidModifierData *mmd, int framenr)
sizeof(cacheDirData),
mmd->domain->cache_directory,
FLUID_DOMAIN_DIR_DATA,
NULL);
nullptr);
BLI_path_join(cacheDirGuiding,
sizeof(cacheDirGuiding),
mmd->domain->cache_directory,
FLUID_DOMAIN_DIR_GUIDE,
NULL);
nullptr);
BLI_path_make_safe(cacheDirData);
BLI_path_make_safe(cacheDirGuiding);
@@ -1633,12 +1645,12 @@ int MANTA::bakeNoise(FluidModifierData *mmd, int framenr)
sizeof(cacheDirData),
mmd->domain->cache_directory,
FLUID_DOMAIN_DIR_DATA,
NULL);
nullptr);
BLI_path_join(cacheDirNoise,
sizeof(cacheDirNoise),
mmd->domain->cache_directory,
FLUID_DOMAIN_DIR_NOISE,
NULL);
nullptr);
BLI_path_make_safe(cacheDirData);
BLI_path_make_safe(cacheDirNoise);
@@ -1672,12 +1684,12 @@ int MANTA::bakeMesh(FluidModifierData *mmd, int framenr)
sizeof(cacheDirData),
mmd->domain->cache_directory,
FLUID_DOMAIN_DIR_DATA,
NULL);
nullptr);
BLI_path_join(cacheDirMesh,
sizeof(cacheDirMesh),
mmd->domain->cache_directory,
FLUID_DOMAIN_DIR_MESH,
NULL);
nullptr);
BLI_path_make_safe(cacheDirData);
BLI_path_make_safe(cacheDirMesh);
@@ -1713,12 +1725,12 @@ int MANTA::bakeParticles(FluidModifierData *mmd, int framenr)
sizeof(cacheDirData),
mmd->domain->cache_directory,
FLUID_DOMAIN_DIR_DATA,
NULL);
nullptr);
BLI_path_join(cacheDirParticles,
sizeof(cacheDirParticles),
mmd->domain->cache_directory,
FLUID_DOMAIN_DIR_PARTICLES,
NULL);
nullptr);
BLI_path_make_safe(cacheDirData);
BLI_path_make_safe(cacheDirParticles);
@@ -1749,7 +1761,7 @@ int MANTA::bakeGuiding(FluidModifierData *mmd, int framenr)
sizeof(cacheDirGuiding),
mmd->domain->cache_directory,
FLUID_DOMAIN_DIR_GUIDE,
NULL);
nullptr);
BLI_path_make_safe(cacheDirGuiding);
ss.str("");
@@ -1800,11 +1812,12 @@ void MANTA::exportSmokeScript(FluidModifierData *mmd)
char cacheDirScript[FILE_MAX] = "\0";
BLI_path_join(
cacheDir, sizeof(cacheDir), mmd->domain->cache_directory, FLUID_DOMAIN_DIR_SCRIPT, NULL);
cacheDir, sizeof(cacheDir), mmd->domain->cache_directory, FLUID_DOMAIN_DIR_SCRIPT, nullptr);
BLI_path_make_safe(cacheDir);
/* Create 'script' subdir if it does not exist already */
BLI_dir_create_recursive(cacheDir);
BLI_path_join(cacheDirScript, sizeof(cacheDirScript), cacheDir, FLUID_DOMAIN_SMOKE_SCRIPT, NULL);
BLI_path_join(
cacheDirScript, sizeof(cacheDirScript), cacheDir, FLUID_DOMAIN_SMOKE_SCRIPT, nullptr);
BLI_path_make_safe(cacheDir);
bool noise = mmd->domain->flags & FLUID_DOMAIN_USE_NOISE;
@@ -1903,12 +1916,12 @@ void MANTA::exportLiquidScript(FluidModifierData *mmd)
char cacheDirScript[FILE_MAX] = "\0";
BLI_path_join(
cacheDir, sizeof(cacheDir), mmd->domain->cache_directory, FLUID_DOMAIN_DIR_SCRIPT, NULL);
cacheDir, sizeof(cacheDir), mmd->domain->cache_directory, FLUID_DOMAIN_DIR_SCRIPT, nullptr);
BLI_path_make_safe(cacheDir);
/* Create 'script' subdir if it does not exist already */
BLI_dir_create_recursive(cacheDir);
BLI_path_join(
cacheDirScript, sizeof(cacheDirScript), cacheDir, FLUID_DOMAIN_LIQUID_SCRIPT, NULL);
cacheDirScript, sizeof(cacheDirScript), cacheDir, FLUID_DOMAIN_LIQUID_SCRIPT, nullptr);
BLI_path_make_safe(cacheDirScript);
bool mesh = mmd->domain->flags & FLUID_DOMAIN_USE_MESH;
@@ -2005,11 +2018,11 @@ static PyObject *callPythonFunction(std::string varName,
if (MANTA::with_debug)
std::cout << "Missing Python variable name and/or function name -- name is: " << varName
<< ", function name is: " << functionName << std::endl;
return NULL;
return nullptr;
}
PyGILState_STATE gilstate = PyGILState_Ensure();
PyObject *main = NULL, *var = NULL, *func = NULL, *returnedValue = NULL;
PyObject *main = nullptr, *var = nullptr, *func = nullptr, *returnedValue = nullptr;
/* Be sure to initialise Python before importing main. */
Py_Initialize();
@@ -2017,20 +2030,20 @@ static PyObject *callPythonFunction(std::string varName,
// Get pyobject that holds result value
main = PyImport_ImportModule("__main__");
if (!main)
return NULL;
return nullptr;
var = PyObject_GetAttrString(main, varName.c_str());
if (!var)
return NULL;
return nullptr;
func = PyObject_GetAttrString(var, functionName.c_str());
Py_DECREF(var);
if (!func)
return NULL;
return nullptr;
if (!isAttribute) {
returnedValue = PyObject_CallObject(func, NULL);
returnedValue = PyObject_CallObject(func, nullptr);
Py_DECREF(func);
}
@@ -2067,7 +2080,7 @@ static void *stringToPointer(char *inputString)
{
std::string str(inputString);
std::istringstream in(str);
void *dataPointer = NULL;
void *dataPointer = nullptr;
in >> dataPointer;
return dataPointer;
}
@@ -2405,9 +2418,9 @@ void MANTA::updateParticlesFromUni(const char *filename, bool isSecondarySys, bo
}
// Pointer to FLIP system or to secondary particle system
std::vector<pData> *dataPointer = NULL;
std::vector<pVel> *velocityPointer = NULL;
std::vector<float> *lifePointer = NULL;
std::vector<pData> *dataPointer = nullptr;
std::vector<pVel> *velocityPointer = nullptr;
std::vector<float> *lifePointer = nullptr;
if (isSecondarySys) {
dataPointer = mSndParticleData;
@@ -2488,27 +2501,6 @@ void MANTA::updateParticlesFromUni(const char *filename, bool isSecondarySys, bo
gzclose(gzf);
}
template<typename T>
void MANTA::setPointers(std::vector<std::tuple<T **, std::string, std::string, bool>> objects)
{
PyObject *mantaObject = NULL;
for (typename std::vector<std::tuple<T **, std::string, std::string, bool>>::iterator it =
objects.begin();
it != objects.end();
++it) {
if (!std::get<3>(*it))
continue;
mantaObject = callPythonFunction(std::get<1>(*it), std::get<2>(*it));
if (mantaObject) {
(*std::get<0>(*it)) = (T *)stringToPointer(pyObjectToString(mantaObject));
}
else {
(*std::get<0>(*it)) = NULL;
}
}
}
void MANTA::updatePointers()
{
if (with_debug)
@@ -2532,153 +2524,159 @@ void MANTA::updatePointers()
std::string mesh_ext2 = "_" + mesh2;
std::string noise_ext = "_" + noise;
std::vector<std::tuple<int **, std::string, std::string, bool>> mantaIntObjects;
mantaIntObjects.push_back(std::make_tuple(&mObstacle, "flags" + solver_ext, func, true));
mObstacle = (int *)stringToPointer(
pyObjectToString(callPythonFunction("flags" + solver_ext, func)));
mPhiIn = (float *)stringToPointer(
pyObjectToString(callPythonFunction("phiIn" + solver_ext, func)));
mVelocityX = (float *)stringToPointer(
pyObjectToString(callPythonFunction("x_vel" + solver_ext, func)));
mVelocityY = (float *)stringToPointer(
pyObjectToString(callPythonFunction("y_vel" + solver_ext, func)));
mVelocityZ = (float *)stringToPointer(
pyObjectToString(callPythonFunction("z_vel" + solver_ext, func)));
mForceX = (float *)stringToPointer(
pyObjectToString(callPythonFunction("x_force" + solver_ext, func)));
mForceY = (float *)stringToPointer(
pyObjectToString(callPythonFunction("y_force" + solver_ext, func)));
mForceZ = (float *)stringToPointer(
pyObjectToString(callPythonFunction("z_force" + solver_ext, func)));
std::vector<std::tuple<float **, std::string, std::string, bool>> mantaFloatObjects;
mantaFloatObjects.push_back(std::make_tuple(&mPhiIn, "phiIn" + solver_ext, func, true));
mantaFloatObjects.push_back(std::make_tuple(&mVelocityX, "x_vel" + solver_ext, func, true));
mantaFloatObjects.push_back(std::make_tuple(&mVelocityY, "y_vel" + solver_ext, func, true));
mantaFloatObjects.push_back(std::make_tuple(&mVelocityZ, "z_vel" + solver_ext, func, true));
mantaFloatObjects.push_back(std::make_tuple(&mForceX, "x_force" + solver_ext, func, true));
mantaFloatObjects.push_back(std::make_tuple(&mForceY, "y_force" + solver_ext, func, true));
mantaFloatObjects.push_back(std::make_tuple(&mForceZ, "z_force" + solver_ext, func, true));
mantaFloatObjects.push_back(
std::make_tuple(&mPhiOutIn, "phiOutIn" + solver_ext, func, mUsingOutflow));
mantaFloatObjects.push_back(
std::make_tuple(&mPhiObsIn, "phiObsIn" + solver_ext, func, mUsingObstacle));
mantaFloatObjects.push_back(
std::make_tuple(&mObVelocityX, "x_obvel" + solver_ext, func, mUsingObstacle));
mantaFloatObjects.push_back(
std::make_tuple(&mObVelocityY, "y_obvel" + solver_ext, func, mUsingObstacle));
mantaFloatObjects.push_back(
std::make_tuple(&mObVelocityZ, "z_obvel" + solver_ext, func, mUsingObstacle));
mantaFloatObjects.push_back(
std::make_tuple(&mPhiGuideIn, "phiGuideIn" + solver_ext, func, mUsingGuiding));
mantaFloatObjects.push_back(
std::make_tuple(&mGuideVelocityX, "x_guidevel" + solver_ext, func, mUsingGuiding));
mantaFloatObjects.push_back(
std::make_tuple(&mGuideVelocityY, "y_guidevel" + solver_ext, func, mUsingGuiding));
mantaFloatObjects.push_back(
std::make_tuple(&mGuideVelocityZ, "z_guidevel" + solver_ext, func, mUsingGuiding));
mantaFloatObjects.push_back(
std::make_tuple(&mInVelocityX, "x_invel" + solver_ext, func, mUsingInvel));
mantaFloatObjects.push_back(
std::make_tuple(&mInVelocityY, "y_invel" + solver_ext, func, mUsingInvel));
mantaFloatObjects.push_back(
std::make_tuple(&mInVelocityZ, "z_invel" + solver_ext, func, mUsingInvel));
mantaFloatObjects.push_back(
std::make_tuple(&mNumObstacle, "numObs" + solver_ext, func, mUsingObstacle));
mantaFloatObjects.push_back(
std::make_tuple(&mNumGuide, "numGuides" + solver_ext, func, mUsingGuiding));
mantaFloatObjects.push_back(std::make_tuple(&mPhi, "phi" + solver_ext, func, mUsingLiquid));
mantaFloatObjects.push_back(
std::make_tuple(&mDensity, "density" + solver_ext, func, mUsingSmoke));
mantaFloatObjects.push_back(
std::make_tuple(&mDensityIn, "densityIn" + solver_ext, func, mUsingSmoke));
mantaFloatObjects.push_back(std::make_tuple(&mShadow, "shadow" + solver_ext, func, mUsingSmoke));
mantaFloatObjects.push_back(
std::make_tuple(&mEmissionIn, "emissionIn" + solver_ext, func, mUsingSmoke));
mantaFloatObjects.push_back(
std::make_tuple(&mHeat, "heat" + solver_ext, func, mUsingSmoke & mUsingHeat));
mantaFloatObjects.push_back(
std::make_tuple(&mHeatIn, "heatIn" + solver_ext, func, mUsingSmoke & mUsingHeat));
mantaFloatObjects.push_back(
std::make_tuple(&mFlame, "flame" + solver_ext, func, mUsingSmoke & mUsingFire));
mantaFloatObjects.push_back(
std::make_tuple(&mFuel, "fuel" + solver_ext, func, mUsingSmoke & mUsingFire));
mantaFloatObjects.push_back(
std::make_tuple(&mReact, "react" + solver_ext, func, mUsingSmoke & mUsingFire));
mantaFloatObjects.push_back(
std::make_tuple(&mFuelIn, "fuelIn" + solver_ext, func, mUsingSmoke & mUsingFire));
mantaFloatObjects.push_back(
std::make_tuple(&mReactIn, "reactIn" + solver_ext, func, mUsingSmoke & mUsingFire));
mantaFloatObjects.push_back(
std::make_tuple(&mColorR, "color_r" + solver_ext, func, mUsingSmoke & mUsingColors));
mantaFloatObjects.push_back(
std::make_tuple(&mColorG, "color_g" + solver_ext, func, mUsingSmoke & mUsingColors));
mantaFloatObjects.push_back(
std::make_tuple(&mColorB, "color_b" + solver_ext, func, mUsingSmoke & mUsingColors));
mantaFloatObjects.push_back(
std::make_tuple(&mColorRIn, "color_r_in" + solver_ext, func, mUsingSmoke & mUsingColors));
mantaFloatObjects.push_back(
std::make_tuple(&mColorGIn, "color_g_in" + solver_ext, func, mUsingSmoke & mUsingColors));
mantaFloatObjects.push_back(
std::make_tuple(&mColorBIn, "color_b_in" + solver_ext, func, mUsingSmoke & mUsingColors));
mantaFloatObjects.push_back(
std::make_tuple(&mDensityHigh, "density" + noise_ext, func, mUsingSmoke & mUsingNoise));
mantaFloatObjects.push_back(
std::make_tuple(&mTextureU, "texture_u" + solver_ext, func, mUsingSmoke & mUsingNoise));
mantaFloatObjects.push_back(
std::make_tuple(&mTextureV, "texture_v" + solver_ext, func, mUsingSmoke & mUsingNoise));
mantaFloatObjects.push_back(
std::make_tuple(&mTextureW, "texture_w" + solver_ext, func, mUsingSmoke & mUsingNoise));
mantaFloatObjects.push_back(
std::make_tuple(&mTextureU2, "texture_u2" + solver_ext, func, mUsingSmoke & mUsingNoise));
mantaFloatObjects.push_back(
std::make_tuple(&mTextureV2, "texture_v2" + solver_ext, func, mUsingSmoke & mUsingNoise));
mantaFloatObjects.push_back(
std::make_tuple(&mTextureW2, "texture_w2" + solver_ext, func, mUsingSmoke & mUsingNoise));
mantaFloatObjects.push_back(std::make_tuple(
&mFlameHigh, "flame" + noise_ext, func, mUsingSmoke & mUsingNoise & mUsingFire));
mantaFloatObjects.push_back(std::make_tuple(
&mFuelHigh, "fuel" + noise_ext, func, mUsingSmoke & mUsingNoise & mUsingFire));
mantaFloatObjects.push_back(std::make_tuple(
&mReactHigh, "react" + noise_ext, func, mUsingSmoke & mUsingNoise & mUsingFire));
mantaFloatObjects.push_back(std::make_tuple(
&mColorRHigh, "color_r" + noise_ext, func, mUsingSmoke & mUsingNoise & mUsingColors));
mantaFloatObjects.push_back(std::make_tuple(
&mColorGHigh, "color_g" + noise_ext, func, mUsingSmoke & mUsingNoise & mUsingColors));
mantaFloatObjects.push_back(std::make_tuple(
&mColorBHigh, "color_b" + noise_ext, func, mUsingSmoke & mUsingNoise & mUsingColors));
std::vector<std::tuple<std::vector<pData> **, std::string, std::string, bool>> mantaPDataObjects;
mantaPDataObjects.push_back(
std::make_tuple(&mFlipParticleData, "pp" + solver_ext, func, mUsingLiquid));
mantaPDataObjects.push_back(std::make_tuple(
&mSndParticleData,
"ppSnd" + snd_ext,
func,
mUsingLiquid & (mUsingDrops | mUsingBubbles | mUsingFloats | mUsingTracers)));
std::vector<std::tuple<std::vector<pVel> **, std::string, std::string, bool>> mantaPVelObjects;
mantaPVelObjects.push_back(
std::make_tuple(&mFlipParticleVelocity, "pVel" + parts_ext, func, mUsingLiquid));
mantaPVelObjects.push_back(std::make_tuple(
&mMeshVelocities, "mVel" + mesh_ext2, func, mUsingLiquid & mUsingMesh & mUsingMVel));
mantaPVelObjects.push_back(std::make_tuple(
&mSndParticleVelocity,
"pVelSnd" + parts_ext,
func,
mUsingLiquid & (mUsingDrops | mUsingBubbles | mUsingFloats | mUsingTracers)));
std::vector<std::tuple<std::vector<Node> **, std::string, std::string, bool>> mantaNodeObjects;
mantaNodeObjects.push_back(
std::make_tuple(&mMeshNodes, "mesh" + mesh_ext, funcNodes, mUsingLiquid & mUsingMesh));
std::vector<std::tuple<std::vector<Triangle> **, std::string, std::string, bool>>
mantaTriangleObjects;
mantaTriangleObjects.push_back(
std::make_tuple(&mMeshTriangles, "mesh" + mesh_ext, funcTris, mUsingLiquid & mUsingMesh));
std::vector<std::tuple<std::vector<float> **, std::string, std::string, bool>>
mantaFloatVecObjects;
mantaFloatVecObjects.push_back(std::make_tuple(
&mSndParticleLife,
"pLifeSnd" + parts_ext,
func,
mUsingLiquid & (mUsingDrops | mUsingBubbles | mUsingFloats | mUsingTracers)));
setPointers(mantaIntObjects);
setPointers(mantaFloatObjects);
setPointers(mantaPDataObjects);
setPointers(mantaPVelObjects);
setPointers(mantaNodeObjects);
setPointers(mantaTriangleObjects);
setPointers(mantaFloatVecObjects);
if (mUsingOutflow) {
mPhiOutIn = (float *)stringToPointer(
pyObjectToString(callPythonFunction("phiOutIn" + solver_ext, func)));
}
if (mUsingObstacle) {
mPhiObsIn = (float *)stringToPointer(
pyObjectToString(callPythonFunction("phiObsIn" + solver_ext, func)));
mObVelocityX = (float *)stringToPointer(
pyObjectToString(callPythonFunction("x_obvel" + solver_ext, func)));
mObVelocityY = (float *)stringToPointer(
pyObjectToString(callPythonFunction("y_obvel" + solver_ext, func)));
mObVelocityZ = (float *)stringToPointer(
pyObjectToString(callPythonFunction("z_obvel" + solver_ext, func)));
mNumObstacle = (float *)stringToPointer(
pyObjectToString(callPythonFunction("numObs" + solver_ext, func)));
}
if (mUsingGuiding) {
mPhiGuideIn = (float *)stringToPointer(
pyObjectToString(callPythonFunction("phiGuideIn" + solver_ext, func)));
mGuideVelocityX = (float *)stringToPointer(
pyObjectToString(callPythonFunction("x_guidevel" + solver_ext, func)));
mGuideVelocityY = (float *)stringToPointer(
pyObjectToString(callPythonFunction("y_guidevel" + solver_ext, func)));
mGuideVelocityZ = (float *)stringToPointer(
pyObjectToString(callPythonFunction("z_guidevel" + solver_ext, func)));
}
if (mUsingInvel) {
mInVelocityX = (float *)stringToPointer(
pyObjectToString(callPythonFunction("x_invel" + solver_ext, func)));
mInVelocityY = (float *)stringToPointer(
pyObjectToString(callPythonFunction("y_invel" + solver_ext, func)));
mInVelocityZ = (float *)stringToPointer(
pyObjectToString(callPythonFunction("z_invel" + solver_ext, func)));
mNumGuide = (float *)stringToPointer(
pyObjectToString(callPythonFunction("numGuides" + solver_ext, func)));
}
if (mUsingSmoke) {
mDensity = (float *)stringToPointer(
pyObjectToString(callPythonFunction("density" + solver_ext, func)));
mDensityIn = (float *)stringToPointer(
pyObjectToString(callPythonFunction("densityIn" + solver_ext, func)));
mShadow = (float *)stringToPointer(
pyObjectToString(callPythonFunction("shadow" + solver_ext, func)));
mEmissionIn = (float *)stringToPointer(
pyObjectToString(callPythonFunction("emissionIn" + solver_ext, func)));
}
if (mUsingSmoke && mUsingHeat) {
mHeat = (float *)stringToPointer(
pyObjectToString(callPythonFunction("heat" + solver_ext, func)));
mHeatIn = (float *)stringToPointer(
pyObjectToString(callPythonFunction("heatIn" + solver_ext, func)));
}
if (mUsingSmoke && mUsingFire) {
mFlame = (float *)stringToPointer(
pyObjectToString(callPythonFunction("flame" + solver_ext, func)));
mFuel = (float *)stringToPointer(
pyObjectToString(callPythonFunction("fuel" + solver_ext, func)));
mReact = (float *)stringToPointer(
pyObjectToString(callPythonFunction("react" + solver_ext, func)));
mFuelIn = (float *)stringToPointer(
pyObjectToString(callPythonFunction("fuelIn" + solver_ext, func)));
mReactIn = (float *)stringToPointer(
pyObjectToString(callPythonFunction("reactIn" + solver_ext, func)));
}
if (mUsingSmoke && mUsingColors) {
mColorR = (float *)stringToPointer(
pyObjectToString(callPythonFunction("color_r" + solver_ext, func)));
mColorG = (float *)stringToPointer(
pyObjectToString(callPythonFunction("color_g" + solver_ext, func)));
mColorB = (float *)stringToPointer(
pyObjectToString(callPythonFunction("color_b" + solver_ext, func)));
mColorRIn = (float *)stringToPointer(
pyObjectToString(callPythonFunction("color_r_in" + solver_ext, func)));
mColorGIn = (float *)stringToPointer(
pyObjectToString(callPythonFunction("color_g_in" + solver_ext, func)));
mColorBIn = (float *)stringToPointer(
pyObjectToString(callPythonFunction("color_b_in" + solver_ext, func)));
}
if (mUsingSmoke && mUsingNoise) {
mDensityHigh = (float *)stringToPointer(
pyObjectToString(callPythonFunction("density" + noise_ext, func)));
mTextureU = (float *)stringToPointer(
pyObjectToString(callPythonFunction("texture_u" + solver_ext, func)));
mTextureV = (float *)stringToPointer(
pyObjectToString(callPythonFunction("texture_v" + solver_ext, func)));
mTextureW = (float *)stringToPointer(
pyObjectToString(callPythonFunction("texture_w" + solver_ext, func)));
mTextureU2 = (float *)stringToPointer(
pyObjectToString(callPythonFunction("texture_u2" + solver_ext, func)));
mTextureV2 = (float *)stringToPointer(
pyObjectToString(callPythonFunction("texture_v2" + solver_ext, func)));
mTextureW2 = (float *)stringToPointer(
pyObjectToString(callPythonFunction("texture_w2" + solver_ext, func)));
}
if (mUsingSmoke && mUsingNoise && mUsingFire) {
mFlameHigh = (float *)stringToPointer(
pyObjectToString(callPythonFunction("flame" + noise_ext, func)));
mFuelHigh = (float *)stringToPointer(
pyObjectToString(callPythonFunction("fuel" + noise_ext, func)));
mReactHigh = (float *)stringToPointer(
pyObjectToString(callPythonFunction("react" + noise_ext, func)));
}
if (mUsingSmoke && mUsingNoise && mUsingColors) {
mColorRHigh = (float *)stringToPointer(
pyObjectToString(callPythonFunction("color_r" + noise_ext, func)));
mColorGHigh = (float *)stringToPointer(
pyObjectToString(callPythonFunction("color_g" + noise_ext, func)));
mColorBHigh = (float *)stringToPointer(
pyObjectToString(callPythonFunction("color_b" + noise_ext, func)));
}
if (mUsingLiquid) {
mPhi = (float *)stringToPointer(
pyObjectToString(callPythonFunction("phi" + solver_ext, func)));
mFlipParticleData = (std::vector<pData> *)stringToPointer(
pyObjectToString(callPythonFunction("pp" + solver_ext, func)));
mFlipParticleVelocity = (std::vector<pVel> *)stringToPointer(
pyObjectToString(callPythonFunction("pVel" + parts_ext, func)));
}
if (mUsingLiquid && mUsingMesh) {
mMeshNodes = (std::vector<Node> *)stringToPointer(
pyObjectToString(callPythonFunction("mesh" + mesh_ext, funcNodes)));
mMeshTriangles = (std::vector<Triangle> *)stringToPointer(
pyObjectToString(callPythonFunction("mesh" + mesh_ext, funcTris)));
}
if (mUsingLiquid && mUsingMVel) {
mMeshVelocities = (std::vector<pVel> *)stringToPointer(
pyObjectToString(callPythonFunction("mVel" + mesh_ext2, func)));
}
if (mUsingLiquid && (mUsingDrops | mUsingBubbles | mUsingFloats | mUsingTracers)) {
mSndParticleData = (std::vector<pData> *)stringToPointer(
pyObjectToString(callPythonFunction("ppSnd" + snd_ext, func)));
mSndParticleVelocity = (std::vector<pVel> *)stringToPointer(
pyObjectToString(callPythonFunction("pVelSnd" + parts_ext, func)));
mSndParticleLife = (std::vector<float> *)stringToPointer(
pyObjectToString(callPythonFunction("pLifeSnd" + parts_ext, func)));
}
mFlipFromFile = true;
mMeshFromFile = false;

View File

@@ -854,8 +854,6 @@ struct MANTA {
void updateParticlesFromUni(const char *filename, bool isSecondarySys, bool isVelData);
void updateMeshFromFile(const char *filename);
void updateParticlesFromFile(const char *filename, bool isSecondarySys, bool isVelData);
template<class T>
void setPointers(std::vector<std::tuple<T **, std::string, std::string, bool>>);
};
#endif

View File

@@ -372,7 +372,8 @@ void manta_smoke_export(MANTA *smoke,
if (b)
*b = smoke->getColorB();
*obstacle = smoke->getObstacle();
*shadow = smoke->getShadow();
if (shadow)
*shadow = smoke->getShadow();
*dt = 1; // dummy value, not needed for smoke
*dx = 1; // dummy value, not needed for smoke
}
@@ -557,9 +558,9 @@ float *manta_smoke_get_flame(MANTA *smoke)
{
return smoke->getFlame();
}
float *manta_smoke_get_shadow(MANTA *fluid)
float *manta_smoke_get_shadow(MANTA *smoke)
{
return fluid->getShadow();
return smoke->getShadow();
}
float *manta_smoke_get_color_r(MANTA *smoke)