Fluid: Cleanup and improved readability
A collection of multiple changes that had been living in my stash: - Use nullptr instead of NULL in C++ files - Removed unused/deprecated functions from headers - Cleared animatable flag in cache UI - Comment cleanups
This commit is contained in:
@@ -27,10 +27,6 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <zlib.h>
|
#include <zlib.h>
|
||||||
|
|
||||||
#if OPENVDB == 1
|
|
||||||
# include "openvdb/openvdb.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "MANTA_main.h"
|
#include "MANTA_main.h"
|
||||||
#include "Python.h"
|
#include "Python.h"
|
||||||
#include "fluid_script.h"
|
#include "fluid_script.h"
|
||||||
@@ -60,13 +56,6 @@ using std::to_string;
|
|||||||
atomic<int> MANTA::solverID(0);
|
atomic<int> MANTA::solverID(0);
|
||||||
int MANTA::with_debug(0);
|
int MANTA::with_debug(0);
|
||||||
|
|
||||||
/* Number of particles that the cache reads at once (with zlib). */
|
|
||||||
#define PARTICLE_CHUNK 20000
|
|
||||||
/* Number of mesh nodes that the cache reads at once (with zlib). */
|
|
||||||
#define NODE_CHUNK 20000
|
|
||||||
/* Number of mesh triangles that the cache reads at once (with zlib). */
|
|
||||||
#define TRIANGLE_CHUNK 20000
|
|
||||||
|
|
||||||
MANTA::MANTA(int *res, FluidModifierData *fmd) : mCurrentID(++solverID)
|
MANTA::MANTA(int *res, FluidModifierData *fmd) : mCurrentID(++solverID)
|
||||||
{
|
{
|
||||||
if (with_debug)
|
if (with_debug)
|
||||||
@@ -96,8 +85,7 @@ MANTA::MANTA(int *res, FluidModifierData *fmd) : mCurrentID(++solverID)
|
|||||||
mUsingInvel = (fds->active_fields & FLUID_DOMAIN_ACTIVE_INVEL);
|
mUsingInvel = (fds->active_fields & FLUID_DOMAIN_ACTIVE_INVEL);
|
||||||
mUsingOutflow = (fds->active_fields & FLUID_DOMAIN_ACTIVE_OUTFLOW);
|
mUsingOutflow = (fds->active_fields & FLUID_DOMAIN_ACTIVE_OUTFLOW);
|
||||||
|
|
||||||
// Simulation constants
|
/* Simulation constants. */
|
||||||
mTempAmb = 0; // TODO: Maybe use this later for buoyancy calculation
|
|
||||||
mResX = res[0];
|
mResX = res[0];
|
||||||
mResY = res[1];
|
mResY = res[1];
|
||||||
mResZ = res[2];
|
mResZ = res[2];
|
||||||
@@ -105,7 +93,7 @@ MANTA::MANTA(int *res, FluidModifierData *fmd) : mCurrentID(++solverID)
|
|||||||
mTotalCells = mResX * mResY * mResZ;
|
mTotalCells = mResX * mResY * mResZ;
|
||||||
mResGuiding = fds->res;
|
mResGuiding = fds->res;
|
||||||
|
|
||||||
// Smoke low res grids
|
/* Smoke low res grids. */
|
||||||
mDensity = nullptr;
|
mDensity = nullptr;
|
||||||
mShadow = nullptr;
|
mShadow = nullptr;
|
||||||
mHeat = nullptr;
|
mHeat = nullptr;
|
||||||
@@ -131,7 +119,7 @@ MANTA::MANTA(int *res, FluidModifierData *fmd) : mCurrentID(++solverID)
|
|||||||
mReactIn = nullptr;
|
mReactIn = nullptr;
|
||||||
mEmissionIn = nullptr;
|
mEmissionIn = nullptr;
|
||||||
|
|
||||||
// Smoke high res grids
|
/* Smoke high res grids. */
|
||||||
mDensityHigh = nullptr;
|
mDensityHigh = nullptr;
|
||||||
mFlameHigh = nullptr;
|
mFlameHigh = nullptr;
|
||||||
mFuelHigh = nullptr;
|
mFuelHigh = nullptr;
|
||||||
@@ -146,19 +134,19 @@ MANTA::MANTA(int *res, FluidModifierData *fmd) : mCurrentID(++solverID)
|
|||||||
mTextureV2 = nullptr;
|
mTextureV2 = nullptr;
|
||||||
mTextureW2 = nullptr;
|
mTextureW2 = nullptr;
|
||||||
|
|
||||||
// Fluid low res grids
|
/* Fluid low res grids. */
|
||||||
mPhiIn = nullptr;
|
mPhiIn = nullptr;
|
||||||
mPhiStaticIn = nullptr;
|
mPhiStaticIn = nullptr;
|
||||||
mPhiOutIn = nullptr;
|
mPhiOutIn = nullptr;
|
||||||
mPhiOutStaticIn = nullptr;
|
mPhiOutStaticIn = nullptr;
|
||||||
mPhi = nullptr;
|
mPhi = nullptr;
|
||||||
|
|
||||||
// Mesh
|
/* Mesh. */
|
||||||
mMeshNodes = nullptr;
|
mMeshNodes = nullptr;
|
||||||
mMeshTriangles = nullptr;
|
mMeshTriangles = nullptr;
|
||||||
mMeshVelocities = nullptr;
|
mMeshVelocities = nullptr;
|
||||||
|
|
||||||
// Fluid obstacle
|
/* Fluid obstacle. */
|
||||||
mPhiObsIn = nullptr;
|
mPhiObsIn = nullptr;
|
||||||
mPhiObsStaticIn = nullptr;
|
mPhiObsStaticIn = nullptr;
|
||||||
mNumObstacle = nullptr;
|
mNumObstacle = nullptr;
|
||||||
@@ -166,39 +154,39 @@ MANTA::MANTA(int *res, FluidModifierData *fmd) : mCurrentID(++solverID)
|
|||||||
mObVelocityY = nullptr;
|
mObVelocityY = nullptr;
|
||||||
mObVelocityZ = nullptr;
|
mObVelocityZ = nullptr;
|
||||||
|
|
||||||
// Fluid guiding
|
/* Fluid guiding. */
|
||||||
mPhiGuideIn = nullptr;
|
mPhiGuideIn = nullptr;
|
||||||
mNumGuide = nullptr;
|
mNumGuide = nullptr;
|
||||||
mGuideVelocityX = nullptr;
|
mGuideVelocityX = nullptr;
|
||||||
mGuideVelocityY = nullptr;
|
mGuideVelocityY = nullptr;
|
||||||
mGuideVelocityZ = nullptr;
|
mGuideVelocityZ = nullptr;
|
||||||
|
|
||||||
// Fluid initial velocity
|
/* Fluid initial velocity. */
|
||||||
mInVelocityX = nullptr;
|
mInVelocityX = nullptr;
|
||||||
mInVelocityY = nullptr;
|
mInVelocityY = nullptr;
|
||||||
mInVelocityZ = nullptr;
|
mInVelocityZ = nullptr;
|
||||||
|
|
||||||
// Secondary particles
|
/* Secondary particles. */
|
||||||
mFlipParticleData = nullptr;
|
mFlipParticleData = nullptr;
|
||||||
mFlipParticleVelocity = nullptr;
|
mFlipParticleVelocity = nullptr;
|
||||||
mSndParticleData = nullptr;
|
mParticleData = nullptr;
|
||||||
mSndParticleVelocity = nullptr;
|
mParticleVelocity = nullptr;
|
||||||
mSndParticleLife = nullptr;
|
mParticleLife = nullptr;
|
||||||
|
|
||||||
// Cache read success indicators
|
/* Cache read success indicators. */
|
||||||
mFlipFromFile = false;
|
mFlipFromFile = false;
|
||||||
mMeshFromFile = false;
|
mMeshFromFile = false;
|
||||||
mParticlesFromFile = false;
|
mParticlesFromFile = false;
|
||||||
|
|
||||||
// Setup Mantaflow in Python
|
/* Setup Mantaflow in Python. */
|
||||||
initializeMantaflow();
|
initializeMantaflow();
|
||||||
|
|
||||||
// Initializa RNA map with values that Python will need
|
/* Initializa RNA map with values that Python will need. */
|
||||||
initializeRNAMap(fmd);
|
initializeRNAMap(fmd);
|
||||||
|
|
||||||
bool initSuccess = true;
|
bool initSuccess = true;
|
||||||
// Initialize Mantaflow variables in Python
|
/* Initialize Mantaflow variables in Python. */
|
||||||
// Liquid
|
/* Liquid. */
|
||||||
if (mUsingLiquid) {
|
if (mUsingLiquid) {
|
||||||
initSuccess &= initDomain();
|
initSuccess &= initDomain();
|
||||||
initSuccess &= initLiquid();
|
initSuccess &= initLiquid();
|
||||||
@@ -227,7 +215,7 @@ MANTA::MANTA(int *res, FluidModifierData *fmd) : mCurrentID(++solverID)
|
|||||||
mResZMesh = mUpresMesh * mResZ;
|
mResZMesh = mUpresMesh * mResZ;
|
||||||
mTotalCellsMesh = mResXMesh * mResYMesh * mResZMesh;
|
mTotalCellsMesh = mResXMesh * mResYMesh * mResZMesh;
|
||||||
|
|
||||||
// Initialize Mantaflow variables in Python
|
/* Initialize Mantaflow variables in Python. */
|
||||||
initSuccess &= initMesh();
|
initSuccess &= initMesh();
|
||||||
initSuccess &= initLiquidMesh();
|
initSuccess &= initLiquidMesh();
|
||||||
}
|
}
|
||||||
@@ -245,7 +233,7 @@ MANTA::MANTA(int *res, FluidModifierData *fmd) : mCurrentID(++solverID)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Smoke
|
/* Smoke. */
|
||||||
if (mUsingSmoke) {
|
if (mUsingSmoke) {
|
||||||
initSuccess &= initDomain();
|
initSuccess &= initDomain();
|
||||||
initSuccess &= initSmoke();
|
initSuccess &= initSmoke();
|
||||||
@@ -274,7 +262,7 @@ MANTA::MANTA(int *res, FluidModifierData *fmd) : mCurrentID(++solverID)
|
|||||||
mResZNoise = amplify * mResZ;
|
mResZNoise = amplify * mResZ;
|
||||||
mTotalCellsHigh = mResXNoise * mResYNoise * mResZNoise;
|
mTotalCellsHigh = mResXNoise * mResYNoise * mResZNoise;
|
||||||
|
|
||||||
// Initialize Mantaflow variables in Python
|
/* Initialize Mantaflow variables in Python. */
|
||||||
initSuccess &= initNoise();
|
initSuccess &= initNoise();
|
||||||
initSuccess &= initSmokeNoise();
|
initSuccess &= initSmokeNoise();
|
||||||
if (mUsingFire)
|
if (mUsingFire)
|
||||||
@@ -290,17 +278,17 @@ MANTA::MANTA(int *res, FluidModifierData *fmd) : mCurrentID(++solverID)
|
|||||||
|
|
||||||
bool MANTA::initDomain(FluidModifierData *fmd)
|
bool MANTA::initDomain(FluidModifierData *fmd)
|
||||||
{
|
{
|
||||||
// Vector will hold all python commands that are to be executed
|
/* Vector will hold all python commands that are to be executed. */
|
||||||
vector<string> pythonCommands;
|
vector<string> pythonCommands;
|
||||||
|
|
||||||
// Set manta debug level first
|
/* Set manta debug level first. */
|
||||||
pythonCommands.push_back(manta_import + manta_debuglevel);
|
pythonCommands.push_back(manta_import + manta_debuglevel);
|
||||||
|
|
||||||
ostringstream ss;
|
ostringstream ss;
|
||||||
ss << "set_manta_debuglevel(" << with_debug << ")";
|
ss << "set_manta_debuglevel(" << with_debug << ")";
|
||||||
pythonCommands.push_back(ss.str());
|
pythonCommands.push_back(ss.str());
|
||||||
|
|
||||||
// Now init basic fluid domain
|
/* Now init basic fluid domain. */
|
||||||
string tmpString = fluid_variables + fluid_solver + fluid_alloc + fluid_cache_helper +
|
string tmpString = fluid_variables + fluid_solver + fluid_alloc + fluid_cache_helper +
|
||||||
fluid_bake_multiprocessing + fluid_bake_data + fluid_bake_noise +
|
fluid_bake_multiprocessing + fluid_bake_data + fluid_bake_noise +
|
||||||
fluid_bake_mesh + fluid_bake_particles + fluid_bake_guiding +
|
fluid_bake_mesh + fluid_bake_particles + fluid_bake_guiding +
|
||||||
@@ -541,7 +529,7 @@ bool MANTA::initSndParts(FluidModifierData *fmd)
|
|||||||
|
|
||||||
bool MANTA::initLiquidSndParts(FluidModifierData *fmd)
|
bool MANTA::initLiquidSndParts(FluidModifierData *fmd)
|
||||||
{
|
{
|
||||||
if (!mSndParticleData) {
|
if (!mParticleData) {
|
||||||
vector<string> pythonCommands;
|
vector<string> pythonCommands;
|
||||||
string tmpString = liquid_alloc_particles + liquid_variables_particles +
|
string tmpString = liquid_alloc_particles + liquid_variables_particles +
|
||||||
liquid_step_particles + fluid_with_sndparts + liquid_load_particles +
|
liquid_step_particles + fluid_with_sndparts + liquid_load_particles +
|
||||||
@@ -560,7 +548,7 @@ MANTA::~MANTA()
|
|||||||
cout << "~FLUID: " << mCurrentID << " with res(" << mResX << ", " << mResY << ", " << mResZ
|
cout << "~FLUID: " << mCurrentID << " with res(" << mResX << ", " << mResY << ", " << mResZ
|
||||||
<< ")" << endl;
|
<< ")" << endl;
|
||||||
|
|
||||||
// Destruction string for Python
|
/* Destruction string for Python. */
|
||||||
string tmpString = "";
|
string tmpString = "";
|
||||||
vector<string> pythonCommands;
|
vector<string> pythonCommands;
|
||||||
bool result = false;
|
bool result = false;
|
||||||
@@ -568,10 +556,10 @@ MANTA::~MANTA()
|
|||||||
tmpString += manta_import;
|
tmpString += manta_import;
|
||||||
tmpString += fluid_delete_all;
|
tmpString += fluid_delete_all;
|
||||||
|
|
||||||
// Initializa RNA map with values that Python will need
|
/* Initializa RNA map with values that Python will need. */
|
||||||
initializeRNAMap();
|
initializeRNAMap();
|
||||||
|
|
||||||
// Leave out fmd argument in parseScript since only looking up IDs
|
/* Leave out fmd argument in parseScript since only looking up IDs. */
|
||||||
string finalString = parseScript(tmpString);
|
string finalString = parseScript(tmpString);
|
||||||
pythonCommands.push_back(finalString);
|
pythonCommands.push_back(finalString);
|
||||||
result = runPythonString(pythonCommands);
|
result = runPythonString(pythonCommands);
|
||||||
@@ -633,10 +621,10 @@ void MANTA::initializeMantaflow()
|
|||||||
string filename = "manta_scene_" + to_string(mCurrentID) + ".py";
|
string filename = "manta_scene_" + to_string(mCurrentID) + ".py";
|
||||||
vector<string> fill = vector<string>();
|
vector<string> fill = vector<string>();
|
||||||
|
|
||||||
// Initialize extension classes and wrappers
|
/* Initialize extension classes and wrappers. */
|
||||||
srand(0);
|
srand(0);
|
||||||
PyGILState_STATE gilstate = PyGILState_Ensure();
|
PyGILState_STATE gilstate = PyGILState_Ensure();
|
||||||
Pb::setup(filename, fill); // Namespace from Mantaflow (registry)
|
Pb::setup(filename, fill); /* Namespace from Mantaflow (registry). */
|
||||||
PyGILState_Release(gilstate);
|
PyGILState_Release(gilstate);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -646,7 +634,7 @@ void MANTA::terminateMantaflow()
|
|||||||
cout << "Fluid: Releasing Mantaflow framework" << endl;
|
cout << "Fluid: Releasing Mantaflow framework" << endl;
|
||||||
|
|
||||||
PyGILState_STATE gilstate = PyGILState_Ensure();
|
PyGILState_STATE gilstate = PyGILState_Ensure();
|
||||||
Pb::finalize(); // Namespace from Mantaflow (registry)
|
Pb::finalize(); /* Namespace from Mantaflow (registry). */
|
||||||
PyGILState_Release(gilstate);
|
PyGILState_Release(gilstate);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1087,7 +1075,7 @@ string MANTA::parseScript(const string &setup_string, FluidModifierData *fmd)
|
|||||||
ostringstream res;
|
ostringstream res;
|
||||||
string line = "";
|
string line = "";
|
||||||
|
|
||||||
// Update RNA map if modifier data is handed over
|
/* Update RNA map if modifier data is handed over. */
|
||||||
if (fmd) {
|
if (fmd) {
|
||||||
initializeRNAMap(fmd);
|
initializeRNAMap(fmd);
|
||||||
}
|
}
|
||||||
@@ -1125,7 +1113,8 @@ bool MANTA::writeConfiguration(FluidModifierData *fmd, int framenr)
|
|||||||
/* Create 'config' subdir if it does not exist already. */
|
/* Create 'config' subdir if it does not exist already. */
|
||||||
BLI_dir_create_recursive(directory.c_str());
|
BLI_dir_create_recursive(directory.c_str());
|
||||||
|
|
||||||
gzFile gzf = (gzFile)BLI_gzopen(file.c_str(), "wb1"); // do some compression
|
/* Open new file with some compression. */
|
||||||
|
gzFile gzf = (gzFile)BLI_gzopen(file.c_str(), "wb1");
|
||||||
if (!gzf) {
|
if (!gzf) {
|
||||||
cerr << "Fluid Error -- Cannot open file " << file << endl;
|
cerr << "Fluid Error -- Cannot open file " << file << endl;
|
||||||
return false;
|
return false;
|
||||||
@@ -1629,10 +1618,10 @@ void MANTA::exportSmokeScript(FluidModifierData *fmd)
|
|||||||
|
|
||||||
string manta_script;
|
string manta_script;
|
||||||
|
|
||||||
// Libraries
|
/* Libraries. */
|
||||||
manta_script += header_libraries + manta_import;
|
manta_script += header_libraries + manta_import;
|
||||||
|
|
||||||
// Variables
|
/* Variables. */
|
||||||
manta_script += header_variables + fluid_variables + smoke_variables;
|
manta_script += header_variables + fluid_variables + smoke_variables;
|
||||||
if (noise) {
|
if (noise) {
|
||||||
manta_script += fluid_variables_noise + smoke_variables_noise;
|
manta_script += fluid_variables_noise + smoke_variables_noise;
|
||||||
@@ -1640,14 +1629,14 @@ void MANTA::exportSmokeScript(FluidModifierData *fmd)
|
|||||||
if (guiding)
|
if (guiding)
|
||||||
manta_script += fluid_variables_guiding;
|
manta_script += fluid_variables_guiding;
|
||||||
|
|
||||||
// Solvers
|
/* Solvers. */
|
||||||
manta_script += header_solvers + fluid_solver;
|
manta_script += header_solvers + fluid_solver;
|
||||||
if (noise)
|
if (noise)
|
||||||
manta_script += fluid_solver_noise;
|
manta_script += fluid_solver_noise;
|
||||||
if (guiding)
|
if (guiding)
|
||||||
manta_script += fluid_solver_guiding;
|
manta_script += fluid_solver_guiding;
|
||||||
|
|
||||||
// Grids
|
/* Grids. */
|
||||||
manta_script += header_grids + fluid_alloc + smoke_alloc;
|
manta_script += header_grids + fluid_alloc + smoke_alloc;
|
||||||
if (noise) {
|
if (noise) {
|
||||||
manta_script += smoke_alloc_noise;
|
manta_script += smoke_alloc_noise;
|
||||||
@@ -1671,36 +1660,36 @@ void MANTA::exportSmokeScript(FluidModifierData *fmd)
|
|||||||
if (outflow)
|
if (outflow)
|
||||||
manta_script += fluid_alloc_outflow;
|
manta_script += fluid_alloc_outflow;
|
||||||
|
|
||||||
// Noise field
|
/* Noise field. */
|
||||||
if (noise)
|
if (noise)
|
||||||
manta_script += smoke_wavelet_noise;
|
manta_script += smoke_wavelet_noise;
|
||||||
|
|
||||||
// Time
|
/* Time. */
|
||||||
manta_script += header_time + fluid_time_stepping + fluid_adapt_time_step;
|
manta_script += header_time + fluid_time_stepping + fluid_adapt_time_step;
|
||||||
|
|
||||||
// Import
|
/* Import. */
|
||||||
manta_script += header_import + fluid_file_import + fluid_cache_helper + smoke_load_data;
|
manta_script += header_import + fluid_file_import + fluid_cache_helper + smoke_load_data;
|
||||||
if (noise)
|
if (noise)
|
||||||
manta_script += smoke_load_noise;
|
manta_script += smoke_load_noise;
|
||||||
if (guiding)
|
if (guiding)
|
||||||
manta_script += fluid_load_guiding;
|
manta_script += fluid_load_guiding;
|
||||||
|
|
||||||
// Pre/Post Steps
|
/* Pre/Post Steps. */
|
||||||
manta_script += header_prepost + fluid_pre_step + fluid_post_step;
|
manta_script += header_prepost + fluid_pre_step + fluid_post_step;
|
||||||
|
|
||||||
// Steps
|
/* Steps. */
|
||||||
manta_script += header_steps + smoke_adaptive_step + smoke_step;
|
manta_script += header_steps + smoke_adaptive_step + smoke_step;
|
||||||
if (noise) {
|
if (noise) {
|
||||||
manta_script += smoke_step_noise;
|
manta_script += smoke_step_noise;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Main
|
/* Main. */
|
||||||
manta_script += header_main + smoke_standalone + fluid_standalone;
|
manta_script += header_main + smoke_standalone + fluid_standalone;
|
||||||
|
|
||||||
// Fill in missing variables in script
|
/* Fill in missing variables in script. */
|
||||||
string final_script = MANTA::parseScript(manta_script, fmd);
|
string final_script = MANTA::parseScript(manta_script, fmd);
|
||||||
|
|
||||||
// Write script
|
/* Write script. */
|
||||||
ofstream myfile;
|
ofstream myfile;
|
||||||
myfile.open(cacheDirScript);
|
myfile.open(cacheDirScript);
|
||||||
myfile << final_script;
|
myfile << final_script;
|
||||||
@@ -1739,10 +1728,10 @@ void MANTA::exportLiquidScript(FluidModifierData *fmd)
|
|||||||
|
|
||||||
string manta_script;
|
string manta_script;
|
||||||
|
|
||||||
// Libraries
|
/* Libraries. */
|
||||||
manta_script += header_libraries + manta_import;
|
manta_script += header_libraries + manta_import;
|
||||||
|
|
||||||
// Variables
|
/* Variables. */
|
||||||
manta_script += header_variables + fluid_variables + liquid_variables;
|
manta_script += header_variables + fluid_variables + liquid_variables;
|
||||||
if (mesh)
|
if (mesh)
|
||||||
manta_script += fluid_variables_mesh;
|
manta_script += fluid_variables_mesh;
|
||||||
@@ -1751,7 +1740,7 @@ void MANTA::exportLiquidScript(FluidModifierData *fmd)
|
|||||||
if (guiding)
|
if (guiding)
|
||||||
manta_script += fluid_variables_guiding;
|
manta_script += fluid_variables_guiding;
|
||||||
|
|
||||||
// Solvers
|
/* Solvers. */
|
||||||
manta_script += header_solvers + fluid_solver;
|
manta_script += header_solvers + fluid_solver;
|
||||||
if (mesh)
|
if (mesh)
|
||||||
manta_script += fluid_solver_mesh;
|
manta_script += fluid_solver_mesh;
|
||||||
@@ -1760,7 +1749,7 @@ void MANTA::exportLiquidScript(FluidModifierData *fmd)
|
|||||||
if (guiding)
|
if (guiding)
|
||||||
manta_script += fluid_solver_guiding;
|
manta_script += fluid_solver_guiding;
|
||||||
|
|
||||||
// Grids
|
/* Grids. */
|
||||||
manta_script += header_grids + fluid_alloc + liquid_alloc;
|
manta_script += header_grids + fluid_alloc + liquid_alloc;
|
||||||
if (mesh)
|
if (mesh)
|
||||||
manta_script += liquid_alloc_mesh;
|
manta_script += liquid_alloc_mesh;
|
||||||
@@ -1777,13 +1766,13 @@ void MANTA::exportLiquidScript(FluidModifierData *fmd)
|
|||||||
if (outflow)
|
if (outflow)
|
||||||
manta_script += fluid_alloc_outflow;
|
manta_script += fluid_alloc_outflow;
|
||||||
|
|
||||||
// Domain init
|
/* Domain init. */
|
||||||
manta_script += header_gridinit + liquid_init_phi;
|
manta_script += header_gridinit + liquid_init_phi;
|
||||||
|
|
||||||
// Time
|
/* Time. */
|
||||||
manta_script += header_time + fluid_time_stepping + fluid_adapt_time_step;
|
manta_script += header_time + fluid_time_stepping + fluid_adapt_time_step;
|
||||||
|
|
||||||
// Import
|
/* Import. */
|
||||||
manta_script += header_import + fluid_file_import + fluid_cache_helper + liquid_load_data;
|
manta_script += header_import + fluid_file_import + fluid_cache_helper + liquid_load_data;
|
||||||
if (mesh)
|
if (mesh)
|
||||||
manta_script += liquid_load_mesh;
|
manta_script += liquid_load_mesh;
|
||||||
@@ -1792,23 +1781,23 @@ void MANTA::exportLiquidScript(FluidModifierData *fmd)
|
|||||||
if (guiding)
|
if (guiding)
|
||||||
manta_script += fluid_load_guiding;
|
manta_script += fluid_load_guiding;
|
||||||
|
|
||||||
// Pre/Post Steps
|
/* Pre/Post Steps. */
|
||||||
manta_script += header_prepost + fluid_pre_step + fluid_post_step;
|
manta_script += header_prepost + fluid_pre_step + fluid_post_step;
|
||||||
|
|
||||||
// Steps
|
/* Steps. */
|
||||||
manta_script += header_steps + liquid_adaptive_step + liquid_step;
|
manta_script += header_steps + liquid_adaptive_step + liquid_step;
|
||||||
if (mesh)
|
if (mesh)
|
||||||
manta_script += liquid_step_mesh;
|
manta_script += liquid_step_mesh;
|
||||||
if (drops || bubble || floater || tracer)
|
if (drops || bubble || floater || tracer)
|
||||||
manta_script += liquid_step_particles;
|
manta_script += liquid_step_particles;
|
||||||
|
|
||||||
// Main
|
/* Main. */
|
||||||
manta_script += header_main + liquid_standalone + fluid_standalone;
|
manta_script += header_main + liquid_standalone + fluid_standalone;
|
||||||
|
|
||||||
// Fill in missing variables in script
|
/* Fill in missing variables in script. */
|
||||||
string final_script = MANTA::parseScript(manta_script, fmd);
|
string final_script = MANTA::parseScript(manta_script, fmd);
|
||||||
|
|
||||||
// Write script
|
/* Write script. */
|
||||||
ofstream myfile;
|
ofstream myfile;
|
||||||
myfile.open(cacheDirScript);
|
myfile.open(cacheDirScript);
|
||||||
myfile << final_script;
|
myfile << final_script;
|
||||||
@@ -2108,9 +2097,9 @@ void MANTA::updatePointers(FluidModifierData *fmd)
|
|||||||
mMeshVelocities = (meshvel) ? getPointer<vector<pVel>>("mVel" + mesh_ext, func) : nullptr;
|
mMeshVelocities = (meshvel) ? getPointer<vector<pVel>>("mVel" + mesh_ext, func) : nullptr;
|
||||||
|
|
||||||
/* Secondary particles. */
|
/* Secondary particles. */
|
||||||
mSndParticleData = (parts) ? getPointer<vector<pData>>("ppSnd" + snd_ext, func) : nullptr;
|
mParticleData = (parts) ? getPointer<vector<pData>>("ppSnd" + snd_ext, func) : nullptr;
|
||||||
mSndParticleVelocity = (parts) ? getPointer<vector<pVel>>("pVelSnd" + pp_ext, func) : nullptr;
|
mParticleVelocity = (parts) ? getPointer<vector<pVel>>("pVelSnd" + pp_ext, func) : nullptr;
|
||||||
mSndParticleLife = (parts) ? getPointer<vector<float>>("pLifeSnd" + pp_ext, func) : nullptr;
|
mParticleLife = (parts) ? getPointer<vector<float>>("pLifeSnd" + pp_ext, func) : nullptr;
|
||||||
|
|
||||||
mFlipFromFile = false;
|
mFlipFromFile = false;
|
||||||
mMeshFromFile = false;
|
mMeshFromFile = false;
|
||||||
|
@@ -41,7 +41,7 @@ struct MANTA {
|
|||||||
MANTA(){};
|
MANTA(){};
|
||||||
virtual ~MANTA();
|
virtual ~MANTA();
|
||||||
|
|
||||||
// Mirroring Mantaflow structures for particle data (pVel also used for mesh vert vels)
|
/* Mirroring Mantaflow structures for particle data (pVel also used for mesh vert vels). */
|
||||||
typedef struct PData {
|
typedef struct PData {
|
||||||
float pos[3];
|
float pos[3];
|
||||||
int flag;
|
int flag;
|
||||||
@@ -50,7 +50,7 @@ struct MANTA {
|
|||||||
float pos[3];
|
float pos[3];
|
||||||
} pVel;
|
} pVel;
|
||||||
|
|
||||||
// Mirroring Mantaflow structures for meshes
|
/* Mirroring Mantaflow structures for meshes. */
|
||||||
typedef struct Node {
|
typedef struct Node {
|
||||||
int flags;
|
int flags;
|
||||||
float pos[3], normal[3];
|
float pos[3], normal[3];
|
||||||
@@ -60,36 +60,33 @@ struct MANTA {
|
|||||||
int flags;
|
int flags;
|
||||||
} Triangle;
|
} Triangle;
|
||||||
|
|
||||||
// Manta step, handling everything
|
/* Grid initialization functions. */
|
||||||
void step(struct FluidModifierData *fmd, int startFrame);
|
bool initHeat(struct FluidModifierData *fmd = nullptr);
|
||||||
|
bool initFire(struct FluidModifierData *fmd = nullptr);
|
||||||
|
bool initColors(struct FluidModifierData *fmd = nullptr);
|
||||||
|
bool initFireHigh(struct FluidModifierData *fmd = nullptr);
|
||||||
|
bool initColorsHigh(struct FluidModifierData *fmd = nullptr);
|
||||||
|
bool initLiquid(FluidModifierData *fmd = nullptr);
|
||||||
|
bool initLiquidMesh(FluidModifierData *fmd = nullptr);
|
||||||
|
bool initObstacle(FluidModifierData *fmd = nullptr);
|
||||||
|
bool initCurvature(FluidModifierData *fmd = nullptr);
|
||||||
|
bool initGuiding(FluidModifierData *fmd = nullptr);
|
||||||
|
bool initFractions(FluidModifierData *fmd = nullptr);
|
||||||
|
bool initInVelocity(FluidModifierData *fmd = nullptr);
|
||||||
|
bool initOutflow(FluidModifierData *fmd = nullptr);
|
||||||
|
bool initSndParts(FluidModifierData *fmd = nullptr);
|
||||||
|
bool initLiquidSndParts(FluidModifierData *fmd = nullptr);
|
||||||
|
|
||||||
// Grid initialization functions
|
/* Pointer transfer: Mantaflow -> Blender. */
|
||||||
bool initHeat(struct FluidModifierData *fmd = NULL);
|
|
||||||
bool initFire(struct FluidModifierData *fmd = NULL);
|
|
||||||
bool initColors(struct FluidModifierData *fmd = NULL);
|
|
||||||
bool initFireHigh(struct FluidModifierData *fmd = NULL);
|
|
||||||
bool initColorsHigh(struct FluidModifierData *fmd = NULL);
|
|
||||||
bool initLiquid(FluidModifierData *fmd = NULL);
|
|
||||||
bool initLiquidMesh(FluidModifierData *fmd = NULL);
|
|
||||||
bool initObstacle(FluidModifierData *fmd = NULL);
|
|
||||||
bool initCurvature(FluidModifierData *fmd = NULL);
|
|
||||||
bool initGuiding(FluidModifierData *fmd = NULL);
|
|
||||||
bool initFractions(FluidModifierData *fmd = NULL);
|
|
||||||
bool initInVelocity(FluidModifierData *fmd = NULL);
|
|
||||||
bool initOutflow(FluidModifierData *fmd = NULL);
|
|
||||||
bool initSndParts(FluidModifierData *fmd = NULL);
|
|
||||||
bool initLiquidSndParts(FluidModifierData *fmd = NULL);
|
|
||||||
|
|
||||||
// Pointer transfer: Mantaflow -> Blender
|
|
||||||
void updatePointers(FluidModifierData *fmd);
|
void updatePointers(FluidModifierData *fmd);
|
||||||
|
|
||||||
// Write cache
|
/* Write cache. */
|
||||||
bool writeConfiguration(FluidModifierData *fmd, int framenr);
|
bool writeConfiguration(FluidModifierData *fmd, int framenr);
|
||||||
bool writeData(FluidModifierData *fmd, int framenr);
|
bool writeData(FluidModifierData *fmd, int framenr);
|
||||||
bool writeNoise(FluidModifierData *fmd, int framenr);
|
bool writeNoise(FluidModifierData *fmd, int framenr);
|
||||||
// write calls for mesh and particles were left in bake calls for now
|
// write calls for mesh and particles were left in bake calls for now
|
||||||
|
|
||||||
// Read cache (via Manta save/load)
|
/* Read cache (via Python). */
|
||||||
bool readConfiguration(FluidModifierData *fmd, int framenr);
|
bool readConfiguration(FluidModifierData *fmd, int framenr);
|
||||||
bool readData(FluidModifierData *fmd, int framenr, bool resumable);
|
bool readData(FluidModifierData *fmd, int framenr, bool resumable);
|
||||||
bool readNoise(FluidModifierData *fmd, int framenr, bool resumable);
|
bool readNoise(FluidModifierData *fmd, int framenr, bool resumable);
|
||||||
@@ -97,26 +94,21 @@ struct MANTA {
|
|||||||
bool readParticles(FluidModifierData *fmd, int framenr, bool resumable);
|
bool readParticles(FluidModifierData *fmd, int framenr, bool resumable);
|
||||||
bool readGuiding(FluidModifierData *fmd, int framenr, bool sourceDomain);
|
bool readGuiding(FluidModifierData *fmd, int framenr, bool sourceDomain);
|
||||||
|
|
||||||
// Read cache (via file read functions in MANTA - e.g. read .bobj.gz meshes, .uni particles)
|
/* Propagate variable changes from RNA to Python. */
|
||||||
bool updateMeshStructures(FluidModifierData *fmd, int framenr);
|
|
||||||
bool updateFlipStructures(FluidModifierData *fmd, int framenr);
|
|
||||||
bool updateParticleStructures(FluidModifierData *fmd, int framenr);
|
|
||||||
bool updateSmokeStructures(FluidModifierData *fmd, int framenr);
|
|
||||||
bool updateNoiseStructures(FluidModifierData *fmd, int framenr);
|
|
||||||
bool updateVariables(FluidModifierData *fmd);
|
bool updateVariables(FluidModifierData *fmd);
|
||||||
|
|
||||||
// Bake cache
|
/* Bake cache. */
|
||||||
bool bakeData(FluidModifierData *fmd, int framenr);
|
bool bakeData(FluidModifierData *fmd, int framenr);
|
||||||
bool bakeNoise(FluidModifierData *fmd, int framenr);
|
bool bakeNoise(FluidModifierData *fmd, int framenr);
|
||||||
bool bakeMesh(FluidModifierData *fmd, int framenr);
|
bool bakeMesh(FluidModifierData *fmd, int framenr);
|
||||||
bool bakeParticles(FluidModifierData *fmd, int framenr);
|
bool bakeParticles(FluidModifierData *fmd, int framenr);
|
||||||
bool bakeGuiding(FluidModifierData *fmd, int framenr);
|
bool bakeGuiding(FluidModifierData *fmd, int framenr);
|
||||||
|
|
||||||
// IO for Mantaflow scene script
|
/* IO for Mantaflow scene script. */
|
||||||
void exportSmokeScript(struct FluidModifierData *fmd);
|
void exportSmokeScript(struct FluidModifierData *fmd);
|
||||||
void exportLiquidScript(struct FluidModifierData *fmd);
|
void exportLiquidScript(struct FluidModifierData *fmd);
|
||||||
|
|
||||||
// Check cache status by frame
|
/* Check cache status by frame. */
|
||||||
bool hasConfig(FluidModifierData *fmd, int framenr);
|
bool hasConfig(FluidModifierData *fmd, int framenr);
|
||||||
bool hasData(FluidModifierData *fmd, int framenr);
|
bool hasData(FluidModifierData *fmd, int framenr);
|
||||||
bool hasNoise(FluidModifierData *fmd, int framenr);
|
bool hasNoise(FluidModifierData *fmd, int framenr);
|
||||||
@@ -193,7 +185,7 @@ struct MANTA {
|
|||||||
return mUpresParticle;
|
return mUpresParticle;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Smoke getters
|
/* Smoke getters. */
|
||||||
inline float *getDensity()
|
inline float *getDensity()
|
||||||
{
|
{
|
||||||
return mDensity;
|
return mDensity;
|
||||||
@@ -422,9 +414,9 @@ struct MANTA {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static atomic<int> solverID;
|
static atomic<int> solverID;
|
||||||
static int with_debug; // on or off (1 or 0), also sets manta debug level
|
static int with_debug; /* On or off (1 or 0), also sets manta debug level. */
|
||||||
|
|
||||||
// Mesh getters
|
/* Mesh getters. */
|
||||||
inline int getNumVertices()
|
inline int getNumVertices()
|
||||||
{
|
{
|
||||||
return (mMeshNodes && !mMeshNodes->empty()) ? mMeshNodes->size() : 0;
|
return (mMeshNodes && !mMeshNodes->empty()) ? mMeshNodes->size() : 0;
|
||||||
@@ -563,9 +555,9 @@ struct MANTA {
|
|||||||
inline int getSndParticleFlagAt(int i)
|
inline int getSndParticleFlagAt(int i)
|
||||||
{
|
{
|
||||||
assert(i >= 0);
|
assert(i >= 0);
|
||||||
if (mSndParticleData && !mSndParticleData->empty()) {
|
if (mParticleData && !mParticleData->empty()) {
|
||||||
assert(i < mSndParticleData->size());
|
assert(i < mParticleData->size());
|
||||||
return (*mSndParticleData)[i].flag;
|
return (*mParticleData)[i].flag;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -601,27 +593,27 @@ struct MANTA {
|
|||||||
inline float getSndParticlePositionXAt(int i)
|
inline float getSndParticlePositionXAt(int i)
|
||||||
{
|
{
|
||||||
assert(i >= 0);
|
assert(i >= 0);
|
||||||
if (mSndParticleData && !mSndParticleData->empty()) {
|
if (mParticleData && !mParticleData->empty()) {
|
||||||
assert(i < mSndParticleData->size());
|
assert(i < mParticleData->size());
|
||||||
return (*mSndParticleData)[i].pos[0];
|
return (*mParticleData)[i].pos[0];
|
||||||
}
|
}
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
}
|
}
|
||||||
inline float getSndParticlePositionYAt(int i)
|
inline float getSndParticlePositionYAt(int i)
|
||||||
{
|
{
|
||||||
assert(i >= 0);
|
assert(i >= 0);
|
||||||
if (mSndParticleData && !mSndParticleData->empty()) {
|
if (mParticleData && !mParticleData->empty()) {
|
||||||
assert(i < mSndParticleData->size());
|
assert(i < mParticleData->size());
|
||||||
return (*mSndParticleData)[i].pos[1];
|
return (*mParticleData)[i].pos[1];
|
||||||
}
|
}
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
}
|
}
|
||||||
inline float getSndParticlePositionZAt(int i)
|
inline float getSndParticlePositionZAt(int i)
|
||||||
{
|
{
|
||||||
assert(i >= 0);
|
assert(i >= 0);
|
||||||
if (mSndParticleData && !mSndParticleData->empty()) {
|
if (mParticleData && !mParticleData->empty()) {
|
||||||
assert(i < mSndParticleData->size());
|
assert(i < mParticleData->size());
|
||||||
return (*mSndParticleData)[i].pos[2];
|
return (*mParticleData)[i].pos[2];
|
||||||
}
|
}
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
}
|
}
|
||||||
@@ -657,27 +649,27 @@ struct MANTA {
|
|||||||
inline float getSndParticleVelocityXAt(int i)
|
inline float getSndParticleVelocityXAt(int i)
|
||||||
{
|
{
|
||||||
assert(i >= 0);
|
assert(i >= 0);
|
||||||
if (mSndParticleVelocity && !mSndParticleVelocity->empty()) {
|
if (mParticleVelocity && !mParticleVelocity->empty()) {
|
||||||
assert(i < mSndParticleVelocity->size());
|
assert(i < mParticleVelocity->size());
|
||||||
return (*mSndParticleVelocity)[i].pos[0];
|
return (*mParticleVelocity)[i].pos[0];
|
||||||
}
|
}
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
}
|
}
|
||||||
inline float getSndParticleVelocityYAt(int i)
|
inline float getSndParticleVelocityYAt(int i)
|
||||||
{
|
{
|
||||||
assert(i >= 0);
|
assert(i >= 0);
|
||||||
if (mSndParticleVelocity && !mSndParticleVelocity->empty()) {
|
if (mParticleVelocity && !mParticleVelocity->empty()) {
|
||||||
assert(i < mSndParticleVelocity->size());
|
assert(i < mParticleVelocity->size());
|
||||||
return (*mSndParticleVelocity)[i].pos[1];
|
return (*mParticleVelocity)[i].pos[1];
|
||||||
}
|
}
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
}
|
}
|
||||||
inline float getSndParticleVelocityZAt(int i)
|
inline float getSndParticleVelocityZAt(int i)
|
||||||
{
|
{
|
||||||
assert(i >= 0);
|
assert(i >= 0);
|
||||||
if (mSndParticleVelocity && !mSndParticleVelocity->empty()) {
|
if (mParticleVelocity && !mParticleVelocity->empty()) {
|
||||||
assert(i < mSndParticleVelocity->size());
|
assert(i < mParticleVelocity->size());
|
||||||
return (*mSndParticleVelocity)[i].pos[2];
|
return (*mParticleVelocity)[i].pos[2];
|
||||||
}
|
}
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
}
|
}
|
||||||
@@ -686,30 +678,28 @@ struct MANTA {
|
|||||||
{
|
{
|
||||||
return (mFlipParticleData && !mFlipParticleData->empty()) ?
|
return (mFlipParticleData && !mFlipParticleData->empty()) ?
|
||||||
(float *)&mFlipParticleData->front() :
|
(float *)&mFlipParticleData->front() :
|
||||||
NULL;
|
nullptr;
|
||||||
}
|
}
|
||||||
inline float *getSndParticleData()
|
inline float *getSndParticleData()
|
||||||
{
|
{
|
||||||
return (mSndParticleData && !mSndParticleData->empty()) ? (float *)&mSndParticleData->front() :
|
return (mParticleData && !mParticleData->empty()) ? (float *)&mParticleData->front() : nullptr;
|
||||||
NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline float *getFlipParticleVelocity()
|
inline float *getFlipParticleVelocity()
|
||||||
{
|
{
|
||||||
return (mFlipParticleVelocity && !mFlipParticleVelocity->empty()) ?
|
return (mFlipParticleVelocity && !mFlipParticleVelocity->empty()) ?
|
||||||
(float *)&mFlipParticleVelocity->front() :
|
(float *)&mFlipParticleVelocity->front() :
|
||||||
NULL;
|
nullptr;
|
||||||
}
|
}
|
||||||
inline float *getSndParticleVelocity()
|
inline float *getSndParticleVelocity()
|
||||||
{
|
{
|
||||||
return (mSndParticleVelocity && !mSndParticleVelocity->empty()) ?
|
return (mParticleVelocity && !mParticleVelocity->empty()) ?
|
||||||
(float *)&mSndParticleVelocity->front() :
|
(float *)&mParticleVelocity->front() :
|
||||||
NULL;
|
nullptr;
|
||||||
}
|
}
|
||||||
inline float *getSndParticleLife()
|
inline float *getSndParticleLife()
|
||||||
{
|
{
|
||||||
return (mSndParticleLife && !mSndParticleLife->empty()) ? (float *)&mSndParticleLife->front() :
|
return (mParticleLife && !mParticleLife->empty()) ? (float *)&mParticleLife->front() : nullptr;
|
||||||
NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int getNumFlipParticles()
|
inline int getNumFlipParticles()
|
||||||
@@ -718,7 +708,7 @@ struct MANTA {
|
|||||||
}
|
}
|
||||||
inline int getNumSndParticles()
|
inline int getNumSndParticles()
|
||||||
{
|
{
|
||||||
return (mSndParticleData && !mSndParticleData->empty()) ? mSndParticleData->size() : 0;
|
return (mParticleData && !mParticleData->empty()) ? mParticleData->size() : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool usingFlipFromFile()
|
inline bool usingFlipFromFile()
|
||||||
@@ -734,7 +724,7 @@ struct MANTA {
|
|||||||
return mParticlesFromFile;
|
return mParticlesFromFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Direct access to solver time attributes
|
/* Direct access to solver time attributes. */
|
||||||
int getFrame();
|
int getFrame();
|
||||||
float getTimestep();
|
float getTimestep();
|
||||||
void adaptTimestep();
|
void adaptTimestep();
|
||||||
@@ -742,7 +732,7 @@ struct MANTA {
|
|||||||
bool needsRealloc(FluidModifierData *fmd);
|
bool needsRealloc(FluidModifierData *fmd);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// simulation constants
|
/* Simulation constants. */
|
||||||
size_t mTotalCells;
|
size_t mTotalCells;
|
||||||
size_t mTotalCellsHigh;
|
size_t mTotalCellsHigh;
|
||||||
size_t mTotalCellsMesh;
|
size_t mTotalCellsMesh;
|
||||||
@@ -750,6 +740,7 @@ struct MANTA {
|
|||||||
|
|
||||||
unordered_map<string, string> mRNAMap;
|
unordered_map<string, string> mRNAMap;
|
||||||
|
|
||||||
|
/* The ID of the solver objects will be incremented for every new object. */
|
||||||
int mCurrentID;
|
int mCurrentID;
|
||||||
|
|
||||||
bool mUsingHeat;
|
bool mUsingHeat;
|
||||||
@@ -796,10 +787,7 @@ struct MANTA {
|
|||||||
int mUpresMesh;
|
int mUpresMesh;
|
||||||
int mUpresParticle;
|
int mUpresParticle;
|
||||||
|
|
||||||
float mTempAmb; /* ambient temperature */
|
/* Fluid grids. */
|
||||||
float mConstantScaling;
|
|
||||||
|
|
||||||
// Fluid grids
|
|
||||||
float *mVelocityX;
|
float *mVelocityX;
|
||||||
float *mVelocityY;
|
float *mVelocityY;
|
||||||
float *mVelocityZ;
|
float *mVelocityZ;
|
||||||
@@ -819,7 +807,7 @@ struct MANTA {
|
|||||||
float *mNumObstacle;
|
float *mNumObstacle;
|
||||||
float *mNumGuide;
|
float *mNumGuide;
|
||||||
|
|
||||||
// Smoke grids
|
/* Smoke grids. */
|
||||||
float *mDensity;
|
float *mDensity;
|
||||||
float *mHeat;
|
float *mHeat;
|
||||||
float *mFlame;
|
float *mFlame;
|
||||||
@@ -851,7 +839,7 @@ struct MANTA {
|
|||||||
float *mTextureV2;
|
float *mTextureV2;
|
||||||
float *mTextureW2;
|
float *mTextureW2;
|
||||||
|
|
||||||
// Liquid grids
|
/* Liquid grids. */
|
||||||
float *mPhiIn;
|
float *mPhiIn;
|
||||||
float *mPhiStaticIn;
|
float *mPhiStaticIn;
|
||||||
float *mPhiObsIn;
|
float *mPhiObsIn;
|
||||||
@@ -861,31 +849,31 @@ struct MANTA {
|
|||||||
float *mPhiOutStaticIn;
|
float *mPhiOutStaticIn;
|
||||||
float *mPhi;
|
float *mPhi;
|
||||||
|
|
||||||
// Mesh fields
|
/* Mesh fields. */
|
||||||
vector<Node> *mMeshNodes;
|
vector<Node> *mMeshNodes;
|
||||||
vector<Triangle> *mMeshTriangles;
|
vector<Triangle> *mMeshTriangles;
|
||||||
vector<pVel> *mMeshVelocities;
|
vector<pVel> *mMeshVelocities;
|
||||||
|
|
||||||
// Particle fields
|
/* Particle fields. */
|
||||||
vector<pData> *mFlipParticleData;
|
vector<pData> *mFlipParticleData;
|
||||||
vector<pVel> *mFlipParticleVelocity;
|
vector<pVel> *mFlipParticleVelocity;
|
||||||
|
|
||||||
vector<pData> *mSndParticleData;
|
vector<pData> *mParticleData;
|
||||||
vector<pVel> *mSndParticleVelocity;
|
vector<pVel> *mParticleVelocity;
|
||||||
vector<float> *mSndParticleLife;
|
vector<float> *mParticleLife;
|
||||||
|
|
||||||
void initializeRNAMap(struct FluidModifierData *doRnaRefresh = NULL);
|
void initializeRNAMap(struct FluidModifierData *doRnaRefresh = nullptr);
|
||||||
bool initDomain(struct FluidModifierData *doRnaRefresh = NULL);
|
bool initDomain(struct FluidModifierData *doRnaRefresh = nullptr);
|
||||||
bool initNoise(struct FluidModifierData *doRnaRefresh = NULL);
|
bool initNoise(struct FluidModifierData *doRnaRefresh = nullptr);
|
||||||
bool initMesh(struct FluidModifierData *doRnaRefresh = NULL);
|
bool initMesh(struct FluidModifierData *doRnaRefresh = nullptr);
|
||||||
bool initSmoke(struct FluidModifierData *doRnaRefresh = NULL);
|
bool initSmoke(struct FluidModifierData *doRnaRefresh = nullptr);
|
||||||
bool initSmokeNoise(struct FluidModifierData *doRnaRefresh = NULL);
|
bool initSmokeNoise(struct FluidModifierData *doRnaRefresh = nullptr);
|
||||||
void initializeMantaflow();
|
void initializeMantaflow();
|
||||||
void terminateMantaflow();
|
void terminateMantaflow();
|
||||||
bool runPythonString(vector<string> commands);
|
bool runPythonString(vector<string> commands);
|
||||||
string getRealValue(const string &varName);
|
string getRealValue(const string &varName);
|
||||||
string parseLine(const string &line);
|
string parseLine(const string &line);
|
||||||
string parseScript(const string &setup_string, FluidModifierData *fmd = NULL);
|
string parseScript(const string &setup_string, FluidModifierData *fmd = nullptr);
|
||||||
string getDirectory(struct FluidModifierData *fmd, string subdirectory);
|
string getDirectory(struct FluidModifierData *fmd, string subdirectory);
|
||||||
string getFile(struct FluidModifierData *fmd,
|
string getFile(struct FluidModifierData *fmd,
|
||||||
string subdirectory,
|
string subdirectory,
|
||||||
|
@@ -2596,7 +2596,7 @@ static void ensure_flowsfields(FluidDomainSettings *fds)
|
|||||||
manta_smoke_ensure_fire(fds->fluid, fds->fmd);
|
manta_smoke_ensure_fire(fds->fluid, fds->fmd);
|
||||||
}
|
}
|
||||||
if (fds->active_fields & FLUID_DOMAIN_ACTIVE_COLORS) {
|
if (fds->active_fields & FLUID_DOMAIN_ACTIVE_COLORS) {
|
||||||
/* initialize all smoke with "active_color" */
|
/* Initialize all smoke with "active_color". */
|
||||||
manta_smoke_ensure_colors(fds->fluid, fds->fmd);
|
manta_smoke_ensure_colors(fds->fluid, fds->fmd);
|
||||||
}
|
}
|
||||||
if (fds->type == FLUID_DOMAIN_TYPE_LIQUID &&
|
if (fds->type == FLUID_DOMAIN_TYPE_LIQUID &&
|
||||||
@@ -2617,7 +2617,7 @@ static void update_flowsflags(FluidDomainSettings *fds, Object **flowobjs, int n
|
|||||||
FLUID_DOMAIN_ACTIVE_HEAT | FLUID_DOMAIN_ACTIVE_FIRE);
|
FLUID_DOMAIN_ACTIVE_HEAT | FLUID_DOMAIN_ACTIVE_FIRE);
|
||||||
active_fields &= ~prev_flags;
|
active_fields &= ~prev_flags;
|
||||||
|
|
||||||
/* Monitor active fields based on flow settings */
|
/* Monitor active fields based on flow settings. */
|
||||||
for (flow_index = 0; flow_index < numflowobj; flow_index++) {
|
for (flow_index = 0; flow_index < numflowobj; flow_index++) {
|
||||||
Object *flow_ob = flowobjs[flow_index];
|
Object *flow_ob = flowobjs[flow_index];
|
||||||
FluidModifierData *fmd2 = (FluidModifierData *)BKE_modifiers_findby_type(flow_ob,
|
FluidModifierData *fmd2 = (FluidModifierData *)BKE_modifiers_findby_type(flow_ob,
|
||||||
@@ -2628,6 +2628,7 @@ static void update_flowsflags(FluidDomainSettings *fds, Object **flowobjs, int n
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Activate specific grids if at least one flow object requires this grid. */
|
||||||
if ((fmd2->type & MOD_FLUID_TYPE_FLOW) && fmd2->flow) {
|
if ((fmd2->type & MOD_FLUID_TYPE_FLOW) && fmd2->flow) {
|
||||||
FluidFlowSettings *ffs = fmd2->flow;
|
FluidFlowSettings *ffs = fmd2->flow;
|
||||||
if (!ffs) {
|
if (!ffs) {
|
||||||
@@ -2648,17 +2649,17 @@ static void update_flowsflags(FluidDomainSettings *fds, Object **flowobjs, int n
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* activate heat field if flow produces any heat */
|
/* Activate heat field if a flow object produces any heat. */
|
||||||
if (ffs->temperature) {
|
if (ffs->temperature != 0.0) {
|
||||||
active_fields |= FLUID_DOMAIN_ACTIVE_HEAT;
|
active_fields |= FLUID_DOMAIN_ACTIVE_HEAT;
|
||||||
}
|
}
|
||||||
/* activate fuel field if flow adds any fuel */
|
/* Activate fuel field if a flow object is of fire type. */
|
||||||
if (ffs->fuel_amount &&
|
if (ffs->fuel_amount != 0.0 || ffs->type == FLUID_FLOW_TYPE_FIRE ||
|
||||||
(ffs->type == FLUID_FLOW_TYPE_FIRE || ffs->type == FLUID_FLOW_TYPE_SMOKEFIRE)) {
|
ffs->type == FLUID_FLOW_TYPE_SMOKEFIRE) {
|
||||||
active_fields |= FLUID_DOMAIN_ACTIVE_FIRE;
|
active_fields |= FLUID_DOMAIN_ACTIVE_FIRE;
|
||||||
}
|
}
|
||||||
/* activate color field if flows add smoke with varying colors */
|
/* Activate color field if flows add smoke with varying colors. */
|
||||||
if (ffs->density &&
|
if (ffs->density != 0.0 &&
|
||||||
(ffs->type == FLUID_FLOW_TYPE_SMOKE || ffs->type == FLUID_FLOW_TYPE_SMOKEFIRE)) {
|
(ffs->type == FLUID_FLOW_TYPE_SMOKE || ffs->type == FLUID_FLOW_TYPE_SMOKEFIRE)) {
|
||||||
if (!(active_fields & FLUID_DOMAIN_ACTIVE_COLOR_SET)) {
|
if (!(active_fields & FLUID_DOMAIN_ACTIVE_COLOR_SET)) {
|
||||||
copy_v3_v3(fds->active_color, ffs->color);
|
copy_v3_v3(fds->active_color, ffs->color);
|
||||||
@@ -2671,11 +2672,11 @@ static void update_flowsflags(FluidDomainSettings *fds, Object **flowobjs, int n
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Monitor active fields based on domain settings */
|
/* Monitor active fields based on domain settings. */
|
||||||
if (fds->type == FLUID_DOMAIN_TYPE_GAS && active_fields & FLUID_DOMAIN_ACTIVE_FIRE) {
|
if (fds->type == FLUID_DOMAIN_TYPE_GAS && active_fields & FLUID_DOMAIN_ACTIVE_FIRE) {
|
||||||
/* heat is always needed for fire */
|
/* Heat is always needed for fire. */
|
||||||
active_fields |= FLUID_DOMAIN_ACTIVE_HEAT;
|
active_fields |= FLUID_DOMAIN_ACTIVE_HEAT;
|
||||||
/* also activate colors if domain smoke color differs from active color */
|
/* Also activate colors if domain smoke color differs from active color. */
|
||||||
if (!(active_fields & FLUID_DOMAIN_ACTIVE_COLOR_SET)) {
|
if (!(active_fields & FLUID_DOMAIN_ACTIVE_COLOR_SET)) {
|
||||||
copy_v3_v3(fds->active_color, fds->flame_smoke_color);
|
copy_v3_v3(fds->active_color, fds->flame_smoke_color);
|
||||||
active_fields |= FLUID_DOMAIN_ACTIVE_COLOR_SET;
|
active_fields |= FLUID_DOMAIN_ACTIVE_COLOR_SET;
|
||||||
|
@@ -2048,6 +2048,7 @@ static void rna_def_fluid_domain_settings(BlenderRNA *brna)
|
|||||||
prop,
|
prop,
|
||||||
"Start",
|
"Start",
|
||||||
"Frame on which the simulation starts. This is the first frame that will be baked");
|
"Frame on which the simulation starts. This is the first frame that will be baked");
|
||||||
|
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||||
|
|
||||||
prop = RNA_def_property(srna, "cache_frame_end", PROP_INT, PROP_TIME);
|
prop = RNA_def_property(srna, "cache_frame_end", PROP_INT, PROP_TIME);
|
||||||
RNA_def_property_int_sdna(prop, NULL, "cache_frame_end");
|
RNA_def_property_int_sdna(prop, NULL, "cache_frame_end");
|
||||||
@@ -2057,6 +2058,7 @@ static void rna_def_fluid_domain_settings(BlenderRNA *brna)
|
|||||||
prop,
|
prop,
|
||||||
"End",
|
"End",
|
||||||
"Frame on which the simulation stops. This is the last frame that will be baked");
|
"Frame on which the simulation stops. This is the last frame that will be baked");
|
||||||
|
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||||
|
|
||||||
prop = RNA_def_property(srna, "cache_frame_offset", PROP_INT, PROP_TIME);
|
prop = RNA_def_property(srna, "cache_frame_offset", PROP_INT, PROP_TIME);
|
||||||
RNA_def_property_int_sdna(prop, NULL, "cache_frame_offset");
|
RNA_def_property_int_sdna(prop, NULL, "cache_frame_offset");
|
||||||
@@ -2066,6 +2068,7 @@ static void rna_def_fluid_domain_settings(BlenderRNA *brna)
|
|||||||
"Offset",
|
"Offset",
|
||||||
"Frame offset that is used when loading the simulation from the cache. It is not considered "
|
"Frame offset that is used when loading the simulation from the cache. It is not considered "
|
||||||
"when baking the simulation, only when loading it");
|
"when baking the simulation, only when loading it");
|
||||||
|
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||||
|
|
||||||
prop = RNA_def_property(srna, "cache_frame_pause_data", PROP_INT, PROP_TIME);
|
prop = RNA_def_property(srna, "cache_frame_pause_data", PROP_INT, PROP_TIME);
|
||||||
RNA_def_property_int_sdna(prop, NULL, "cache_frame_pause_data");
|
RNA_def_property_int_sdna(prop, NULL, "cache_frame_pause_data");
|
||||||
@@ -2089,6 +2092,7 @@ static void rna_def_fluid_domain_settings(BlenderRNA *brna)
|
|||||||
prop, NULL, "rna_Fluid_cachetype_mesh_set", "rna_Fluid_cachetype_mesh_itemf");
|
prop, NULL, "rna_Fluid_cachetype_mesh_set", "rna_Fluid_cachetype_mesh_itemf");
|
||||||
RNA_def_property_ui_text(
|
RNA_def_property_ui_text(
|
||||||
prop, "File Format", "Select the file format to be used for caching surface data");
|
prop, "File Format", "Select the file format to be used for caching surface data");
|
||||||
|
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||||
RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_meshcache_reset");
|
RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_meshcache_reset");
|
||||||
|
|
||||||
prop = RNA_def_property(srna, "cache_data_format", PROP_ENUM, PROP_NONE);
|
prop = RNA_def_property(srna, "cache_data_format", PROP_ENUM, PROP_NONE);
|
||||||
@@ -2098,6 +2102,7 @@ static void rna_def_fluid_domain_settings(BlenderRNA *brna)
|
|||||||
prop, NULL, "rna_Fluid_cachetype_data_set", "rna_Fluid_cachetype_volume_itemf");
|
prop, NULL, "rna_Fluid_cachetype_data_set", "rna_Fluid_cachetype_volume_itemf");
|
||||||
RNA_def_property_ui_text(
|
RNA_def_property_ui_text(
|
||||||
prop, "File Format", "Select the file format to be used for caching volumetric data");
|
prop, "File Format", "Select the file format to be used for caching volumetric data");
|
||||||
|
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||||
RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_datacache_reset");
|
RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_datacache_reset");
|
||||||
|
|
||||||
prop = RNA_def_property(srna, "cache_particle_format", PROP_ENUM, PROP_NONE);
|
prop = RNA_def_property(srna, "cache_particle_format", PROP_ENUM, PROP_NONE);
|
||||||
@@ -2107,6 +2112,7 @@ static void rna_def_fluid_domain_settings(BlenderRNA *brna)
|
|||||||
prop, NULL, "rna_Fluid_cachetype_particle_set", "rna_Fluid_cachetype_particle_itemf");
|
prop, NULL, "rna_Fluid_cachetype_particle_set", "rna_Fluid_cachetype_particle_itemf");
|
||||||
RNA_def_property_ui_text(
|
RNA_def_property_ui_text(
|
||||||
prop, "File Format", "Select the file format to be used for caching particle data");
|
prop, "File Format", "Select the file format to be used for caching particle data");
|
||||||
|
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||||
RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_particlescache_reset");
|
RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_particlescache_reset");
|
||||||
|
|
||||||
prop = RNA_def_property(srna, "cache_noise_format", PROP_ENUM, PROP_NONE);
|
prop = RNA_def_property(srna, "cache_noise_format", PROP_ENUM, PROP_NONE);
|
||||||
@@ -2116,6 +2122,7 @@ static void rna_def_fluid_domain_settings(BlenderRNA *brna)
|
|||||||
prop, NULL, "rna_Fluid_cachetype_noise_set", "rna_Fluid_cachetype_volume_itemf");
|
prop, NULL, "rna_Fluid_cachetype_noise_set", "rna_Fluid_cachetype_volume_itemf");
|
||||||
RNA_def_property_ui_text(
|
RNA_def_property_ui_text(
|
||||||
prop, "File Format", "Select the file format to be used for caching noise data");
|
prop, "File Format", "Select the file format to be used for caching noise data");
|
||||||
|
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||||
RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_noisecache_reset");
|
RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_noisecache_reset");
|
||||||
|
|
||||||
prop = RNA_def_property(srna, "cache_type", PROP_ENUM, PROP_NONE);
|
prop = RNA_def_property(srna, "cache_type", PROP_ENUM, PROP_NONE);
|
||||||
@@ -2123,6 +2130,7 @@ static void rna_def_fluid_domain_settings(BlenderRNA *brna)
|
|||||||
RNA_def_property_enum_items(prop, cache_types);
|
RNA_def_property_enum_items(prop, cache_types);
|
||||||
RNA_def_property_enum_funcs(prop, NULL, "rna_Fluid_cachetype_set", NULL);
|
RNA_def_property_enum_funcs(prop, NULL, "rna_Fluid_cachetype_set", NULL);
|
||||||
RNA_def_property_ui_text(prop, "Type", "Change the cache type of the simulation");
|
RNA_def_property_ui_text(prop, "Type", "Change the cache type of the simulation");
|
||||||
|
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||||
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Fluid_domain_data_reset");
|
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Fluid_domain_data_reset");
|
||||||
|
|
||||||
prop = RNA_def_property(srna, "cache_resumable", PROP_BOOLEAN, PROP_NONE);
|
prop = RNA_def_property(srna, "cache_resumable", PROP_BOOLEAN, PROP_NONE);
|
||||||
@@ -2133,6 +2141,7 @@ static void rna_def_fluid_domain_settings(BlenderRNA *brna)
|
|||||||
"Additional data will be saved so that the bake jobs can be resumed after pausing. Because "
|
"Additional data will be saved so that the bake jobs can be resumed after pausing. Because "
|
||||||
"more data will be written to disk it is recommended to avoid enabling this option when "
|
"more data will be written to disk it is recommended to avoid enabling this option when "
|
||||||
"baking at high resolutions");
|
"baking at high resolutions");
|
||||||
|
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||||
RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_datacache_reset");
|
RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_datacache_reset");
|
||||||
|
|
||||||
prop = RNA_def_property(srna, "cache_directory", PROP_STRING, PROP_DIRPATH);
|
prop = RNA_def_property(srna, "cache_directory", PROP_STRING, PROP_DIRPATH);
|
||||||
|
Reference in New Issue
Block a user