Commit: 05c03b6526287334c11f1a2947b2e46492f038ab
Author: Sebastián Barschkis
Date:   Mon Jun 6 18:13:31 2016 +0200
Branches: fluid-mantaflow
https://developer.blender.org/rB05c03b6526287334c11f1a2947b2e46492f038ab

cleaned up scripts and init functions which use them

===================================================================

M       intern/mantaflow/intern/LIQUID.cpp
M       intern/mantaflow/intern/SMOKE.cpp
M       intern/mantaflow/intern/SMOKE.h
M       intern/mantaflow/intern/strings/shared_script.h
M       intern/mantaflow/intern/strings/smoke_script.h

===================================================================

diff --git a/intern/mantaflow/intern/LIQUID.cpp 
b/intern/mantaflow/intern/LIQUID.cpp
index 4a66af1..c4ffcd2 100644
--- a/intern/mantaflow/intern/LIQUID.cpp
+++ b/intern/mantaflow/intern/LIQUID.cpp
@@ -53,7 +53,7 @@ void LIQUID::initSetup()
 {
        std::string tmpString = manta_import
                + solver_low
-               + adaptive_time_stepping
+               + adaptive_time_stepping_low
                + alloc_liquid
                + liquid_variables
                + prep_domain
diff --git a/intern/mantaflow/intern/SMOKE.cpp 
b/intern/mantaflow/intern/SMOKE.cpp
index e23707c..185d47f 100644
--- a/intern/mantaflow/intern/SMOKE.cpp
+++ b/intern/mantaflow/intern/SMOKE.cpp
@@ -116,6 +116,9 @@ SMOKE::SMOKE(int *res, SmokeModifierData *smd)
        // Only start Mantaflow once. No need to start whenever new SMOKE 
objected is allocated
        if (!mantaInitialized)
                startMantaflow();
+
+       initDomain(smd);
+       if (mUsingHighRes) initDomainHigh(smd);
        
        // Initialize Mantaflow variables in Python
        // Liquid
@@ -127,7 +130,7 @@ SMOKE::SMOKE(int *res, SmokeModifierData *smd)
        
        // Smoke
        if (mUsingSmoke) {
-               initSetup(smd);
+               initSmoke(smd);
                if (mUsingHeat)   initHeat(smd);
                if (mUsingFire)   initFire(smd);
                if (mUsingColors) initColors(smd);
@@ -146,7 +149,7 @@ SMOKE::SMOKE(int *res, SmokeModifierData *smd)
                        mTotalCellsHigh = mResXHigh * mResYHigh * mResZHigh;
                        
                        // Initialize Mantaflow variables in Python
-                       initSetupHigh(smd);
+                       initSmokeHigh(smd);
                        if (mUsingFire)   initFireHigh(smd);
                        if (mUsingColors) initColorsHigh(smd);
 
@@ -155,13 +158,33 @@ SMOKE::SMOKE(int *res, SmokeModifierData *smd)
        }
 }
 
-void SMOKE::initSetup(SmokeModifierData *smd)
+void SMOKE::initDomain(SmokeModifierData *smd)
 {
        std::string tmpString = manta_import
                + solver_low
-               + adaptive_time_stepping
-               + alloc_base_grids_low
-               + smoke_variables
+               + adaptive_time_stepping_low;
+       std::string finalString = parseScript(tmpString, smd);
+       mCommands.clear();
+       mCommands.push_back(finalString);
+       
+       runPythonString(mCommands);
+}
+
+void SMOKE::initDomainHigh(SmokeModifierData *smd)
+{
+       std::string tmpString = solver_high
+               + adaptive_time_stepping_high;
+       std::string finalString = parseScript(tmpString, smd);
+       mCommands.clear();
+       mCommands.push_back(finalString);
+       
+       runPythonString(mCommands);
+}
+
+void SMOKE::initSmoke(SmokeModifierData *smd)
+{
+       std::string tmpString = alloc_base_grids_low
+               + smoke_variables_low
                + prep_domain_low
                + manta_step
                + smoke_step_low;
@@ -172,9 +195,9 @@ void SMOKE::initSetup(SmokeModifierData *smd)
        runPythonString(mCommands);
 }
 
-void SMOKE::initSetupHigh(SmokeModifierData *smd)
+void SMOKE::initSmokeHigh(SmokeModifierData *smd)
 {
-       std::string tmpString = solver_setup_high
+       std::string tmpString = solver_high
                + alloc_base_grids_high
                + uv_setup
                + prep_domain_high
@@ -257,10 +280,7 @@ void SMOKE::initColorsHigh(SmokeModifierData *smd)
 void SMOKE::initLiquid(SmokeModifierData *smd)
 {
        if (!mPhi) {
-               std::string tmpString = manta_import
-                       + solver_low
-                       + adaptive_time_stepping
-                       + alloc_liquid
+               std::string tmpString = alloc_liquid
                        + liquid_variables
                        + prep_domain
                        + adaptive_step_liquid
@@ -560,12 +580,12 @@ void SMOKE::exportScript(SmokeModifierData *smd)
        }
        
        // Rest of low res setup
-       manta_script += prep_domain_low + smoke_variables;
+       manta_script += prep_domain_low + smoke_variables_low;
        
        // Setup high
        if (smd->domain->flags & MOD_SMOKE_HIGHRES) {
                manta_script +=
-                       solver_setup_high +
+                       solver_high +
                        uv_setup +
                        alloc_base_grids_high;
        }
diff --git a/intern/mantaflow/intern/SMOKE.h b/intern/mantaflow/intern/SMOKE.h
index 68268eb..8a52ff6 100644
--- a/intern/mantaflow/intern/SMOKE.h
+++ b/intern/mantaflow/intern/SMOKE.h
@@ -178,8 +178,10 @@ private:
        // Liquids
        float* mPhi;
        
-       void initSetup(struct SmokeModifierData *smd);
-       void initSetupHigh(struct SmokeModifierData *smd);
+       void initDomain(struct SmokeModifierData *smd);
+       void initDomainHigh(struct SmokeModifierData *smd);
+       void initSmoke(struct SmokeModifierData *smd);
+       void initSmokeHigh(struct SmokeModifierData *smd);
        void startMantaflow();
        void runPythonString(std::vector<std::string> commands);
        std::string getRealValue(const std::string& varName, SmokeModifierData 
*smd);
diff --git a/intern/mantaflow/intern/strings/shared_script.h 
b/intern/mantaflow/intern/strings/shared_script.h
index a72802c..c07d57d 100644
--- a/intern/mantaflow/intern/strings/shared_script.h
+++ b/intern/mantaflow/intern/strings/shared_script.h
@@ -41,7 +41,14 @@ gs     = vec3($RESX$,$RESY$,$RESZ$)\n\
 if dim == 2: gs.z = 1\n\
 s      = Solver(name='main', gridSize=gs, dim=dim)\n";
 
-const std::string adaptive_time_stepping = "\n\
+const std::string solver_high = "\n\
+# solver high params\n\
+upres  = $UPRES$\n\
+xl_gs  = vec3($HRESX$, $HRESY$, $HRESZ$)\n\
+if dim == 2: xl_gs.z = 1\n\
+xl = Solver(name = 'larger', gridSize = xl_gs)\n";
+
+const std::string adaptive_time_stepping_low = "\n\
 # adaptive time stepping\n\
 dt_default    = 0.1\n\
 dt_factor     = $DT_FACTOR$\n\
@@ -53,4 +60,10 @@ s.timestepMax = dt0\n\
 s.cfl         = 4.0\n\
 s.timestep    = dt0\n";
 
+const std::string adaptive_time_stepping_high = "\n\
+xl.frameLength = s.frameLength\n\
+xl.timestepMin = s.timestepMin / 10\n\
+xl.timestepMax = s.timestepMax\n\
+xl.cfl         = s.cfl\n";
+
 
diff --git a/intern/mantaflow/intern/strings/smoke_script.h 
b/intern/mantaflow/intern/strings/smoke_script.h
index ec24c54..f900c9c 100644
--- a/intern/mantaflow/intern/strings/smoke_script.h
+++ b/intern/mantaflow/intern/strings/smoke_script.h
@@ -33,16 +33,6 @@
 // GENERAL SETUP
 //////////////////////////////////////////////////////////////////////
 
-const std::string smoke_variables = "\n\
-using_colors    = $USING_COLORS$\n\
-using_heat      = $USING_HEAT$\n\
-using_fire      = $USING_FIRE$\n\
-using_wavelets  = $USE_WAVELETS$\n\
-vorticity       = $VORTICITY$\n\
-doOpen          = $DO_OPEN$\n\
-boundConditions = '$BOUNDCONDITIONS$'\n\
-boundaryWidth   = 1\n";
-
 const std::string uv_setup = "\n\
 # create the array of uv grids\n\
 uv = []\n\
@@ -60,6 +50,16 @@ copyVec3ToReal(source=uv[1], targetX=texture_u2, 
targetY=texture_v2, targetZ=tex
 // LOW RESOLUTION SETUP
 //////////////////////////////////////////////////////////////////////
 
+const std::string smoke_variables_low = "\n\
+using_colors    = $USING_COLORS$\n\
+using_heat      = $USING_HEAT$\n\
+using_fire      = $USING_FIRE$\n\
+using_wavelets  = $USE_WAVELETS$\n\
+vorticity       = $VORTICITY$\n\
+doOpen          = $DO_OPEN$\n\
+boundConditions = '$BOUNDCONDITIONS$'\n\
+boundaryWidth   = 1\n";
+
 const std::string alloc_base_grids_low = "\n\
 # prepare grids low\n\
 flags       = s.create(FlagGrid)\n\
@@ -91,16 +91,7 @@ if doOpen:\n\
 // HIGH RESOLUTION SETUP
 //////////////////////////////////////////////////////////////////////
 
-const std::string solver_setup_high = "\n\
-# solver high params\n\
-upres = $UPRES$\n\
-xl_gs = vec3($HRESX$, $HRESY$, $HRESZ$)\n\
-if dim == 2: xl_gs.z = 1\n\
-xl = Solver(name = 'larger', gridSize = xl_gs)\n\
-xl.frameLength = s.frameLength\n\
-xl.timestepMin = s.timestepMin / 10\n\
-xl.timestepMax = s.timestepMax\n\
-xl.cfl         = s.cfl\n\
+const std::string smoke_variables_high = "\n\
 wltStrength    = $WLT_STR$\n\
 octaves = 0\n\
 uvs = 2\n\

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to