[Bf-blender-cvs] [75482e3169d] fluid-mantaflow: added options for fluid guiding
Sebastián Barschkis
noreply at git.blender.org
Fri Aug 18 01:23:16 CEST 2017
Commit: 75482e3169de027159f3b4c4cb946974280a21a2
Author: Sebastián Barschkis
Date: Thu Aug 17 19:57:15 2017 +0200
Branches: fluid-mantaflow
https://developer.blender.org/rB75482e3169de027159f3b4c4cb946974280a21a2
added options for fluid guiding
Collision settings are now effector settings. In there an object can be of type collision or guiding.
===================================================================
M intern/mantaflow/extern/manta_fluid_API.h
M intern/mantaflow/intern/FLUID.cpp
M intern/mantaflow/intern/FLUID.h
M intern/mantaflow/intern/manta_fluid_API.cpp
M intern/mantaflow/intern/strings/liquid_script.h
M intern/mantaflow/intern/strings/smoke_script.h
M release/scripts/startup/bl_ui/properties_physics_smoke.py
M source/blender/blenkernel/intern/smoke.c
M source/blender/blenloader/intern/readfile.c
M source/blender/blenloader/intern/writefile.c
M source/blender/makesdna/DNA_modifier_types.h
M source/blender/makesdna/DNA_smoke_types.h
M source/blender/makesrna/intern/rna_modifier.c
M source/blender/makesrna/intern/rna_smoke.c
M source/blender/modifiers/intern/MOD_smoke.c
===================================================================
diff --git a/intern/mantaflow/extern/manta_fluid_API.h b/intern/mantaflow/extern/manta_fluid_API.h
index 6da6429f853..628acc72345 100644
--- a/intern/mantaflow/extern/manta_fluid_API.h
+++ b/intern/mantaflow/extern/manta_fluid_API.h
@@ -90,6 +90,11 @@ int smoke_turbulence_has_colors(struct FLUID *smoke);
void smoke_ensure_heat(struct FLUID *smoke, struct SmokeModifierData *smd);
void smoke_ensure_fire(struct FLUID *smoke, struct SmokeModifierData *smd);
void smoke_ensure_colors(struct FLUID *smoke, struct SmokeModifierData *smd);
+float *smoke_get_guide_velocity_x(struct FLUID *smoke);
+float *smoke_get_guide_velocity_y(struct FLUID *smoke);
+float *smoke_get_guide_velocity_z(struct FLUID *smoke);
+float *smoke_get_phiguidein(struct FLUID *smoke);
+int *smoke_get_num_guide(struct FLUID *fluid);
// Liquid grids
float *liquid_get_phiin(struct FLUID *liquid);
diff --git a/intern/mantaflow/intern/FLUID.cpp b/intern/mantaflow/intern/FLUID.cpp
index dbdb312945a..44563e0eb9d 100644
--- a/intern/mantaflow/intern/FLUID.cpp
+++ b/intern/mantaflow/intern/FLUID.cpp
@@ -87,6 +87,9 @@ FLUID::FLUID(int *res, SmokeModifierData *smd) : mCurrentID(++solverID)
mObVelocityX = NULL;
mObVelocityY = NULL;
mObVelocityZ = NULL;
+ mGuideVelocityX = NULL;
+ mGuideVelocityY = NULL;
+ mGuideVelocityZ = NULL;
mInVelocityX = NULL;
mInVelocityY = NULL;
mInVelocityZ = NULL;
@@ -119,6 +122,7 @@ FLUID::FLUID(int *res, SmokeModifierData *smd) : mCurrentID(++solverID)
// Liquid low res grids
mPhiIn = NULL;
mPhiObsIn = NULL;
+ mPhiGuideIn = NULL;
mPhiOutIn = NULL;
mPhi = NULL;
@@ -233,6 +237,7 @@ void FLUID::initSmoke(SmokeModifierData *smd)
std::string tmpString = smoke_alloc_low
+ smoke_variables_low
+ smoke_bounds_low
+ + smoke_guiding
+ smoke_adaptive_step
+ smoke_export_low
+ smoke_pre_step_low
@@ -449,6 +454,9 @@ FLUID::~FLUID()
mObVelocityX = NULL;
mObVelocityY = NULL;
mObVelocityZ = NULL;
+ mGuideVelocityX = NULL;
+ mGuideVelocityY = NULL;
+ mGuideVelocityZ = NULL;
mInVelocityX = NULL;
mInVelocityY = NULL;
mInVelocityZ = NULL;
@@ -480,6 +488,7 @@ FLUID::~FLUID()
// Liquid
mPhiIn = NULL;
mPhiObsIn = NULL;
+ mPhiGuideIn = NULL;
mPhiOutIn = NULL;
mPhi = NULL;
@@ -1134,6 +1143,13 @@ void FLUID::updatePointers()
mInVelocityY = (float*) getDataPointer("y_invel" + solver_ext, solver);
mInVelocityZ = (float*) getDataPointer("z_invel" + solver_ext, solver);
+ mPhiGuideIn = (float*) getDataPointer("phiGuideIn" + solver_ext, solver);
+ mNumGuide = (int*) getDataPointer("numGuides" + solver_ext, solver);
+
+ mGuideVelocityX = (float*) getDataPointer("x_guidevel" + solver_ext, solver);
+ mGuideVelocityY = (float*) getDataPointer("y_guidevel" + solver_ext, solver);
+ mGuideVelocityZ = (float*) getDataPointer("z_guidevel" + solver_ext, solver);
+
if (mUsingHeat) {
mHeat = (float*) getDataPointer("heat" + solver_ext, solver);
}
diff --git a/intern/mantaflow/intern/FLUID.h b/intern/mantaflow/intern/FLUID.h
index ea5e8f99030..f2c3dfa6034 100644
--- a/intern/mantaflow/intern/FLUID.h
+++ b/intern/mantaflow/intern/FLUID.h
@@ -101,6 +101,9 @@ public:
inline float* getObVelocityX() { return mObVelocityX; }
inline float* getObVelocityY() { return mObVelocityY; }
inline float* getObVelocityZ() { return mObVelocityZ; }
+ inline float* getGuideVelocityX() { return mGuideVelocityX; }
+ inline float* getGuideVelocityY() { return mGuideVelocityY; }
+ inline float* getGuideVelocityZ() { return mGuideVelocityZ; }
inline float* getInVelocityX() { return mInVelocityX; }
inline float* getInVelocityY() { return mInVelocityY; }
inline float* getInVelocityZ() { return mInVelocityZ; }
@@ -109,8 +112,9 @@ public:
inline float* getForceZ() { return mForceZ; }
inline int* getObstacle() { return mObstacle; }
inline int* getNumObstacle() { return mNumObstacle; }
+ inline int* getNumGuide() { return mNumGuide; }
inline float* getFlame() { return mFlame; }
- inline float* getFuel() { return mFuel; }
+ inline float* getFuel() { return mFuel; }
inline float* getReact() { return mReact; }
inline float* getColorR() { return mColorR; }
inline float* getColorG() { return mColorG; }
@@ -133,6 +137,7 @@ public:
inline float* getPhiIn() { return mPhiIn; }
inline float* getPhiObsIn() { return mPhiObsIn; }
+ inline float* getPhiGuideIn() { return mPhiGuideIn; }
inline float* getPhiOutIn() { return mPhiOutIn; }
inline float* getPhi() { return mPhi; }
@@ -235,14 +240,18 @@ private:
float* mObVelocityX;
float* mObVelocityY;
float* mObVelocityZ;
+ float* mGuideVelocityX;
+ float* mGuideVelocityY;
+ float* mGuideVelocityZ;
float* mInVelocityX;
float* mInVelocityY;
float* mInVelocityZ;
float* mForceX;
float* mForceY;
float* mForceZ;
- int* mObstacle; /* only used (useful) for static obstacles like domain boundaries */
+ int* mObstacle;
int* mNumObstacle;
+ int* mNumGuide;
float *mFlame;
float *mFuel;
float *mReact;
@@ -267,6 +276,7 @@ private:
// Liquids
float* mPhiIn;
float* mPhiObsIn;
+ float* mPhiGuideIn;
float* mPhiOutIn;
float* mPhi;
diff --git a/intern/mantaflow/intern/manta_fluid_API.cpp b/intern/mantaflow/intern/manta_fluid_API.cpp
index 31ef047e609..959b92eb851 100644
--- a/intern/mantaflow/intern/manta_fluid_API.cpp
+++ b/intern/mantaflow/intern/manta_fluid_API.cpp
@@ -254,6 +254,21 @@ extern "C" float *smoke_get_ob_velocity_z(FLUID *fluid)
return fluid->getObVelocityZ();
}
+extern "C" float *smoke_get_guide_velocity_x(FLUID *smoke)
+{
+ return smoke->getGuideVelocityX();
+}
+
+extern "C" float *smoke_get_guide_velocity_y(FLUID *smoke)
+{
+ return smoke->getGuideVelocityY();
+}
+
+extern "C" float *smoke_get_guide_velocity_z(FLUID *smoke)
+{
+ return smoke->getGuideVelocityZ();
+}
+
extern "C" float *smoke_get_in_velocity_x(FLUID *fluid)
{
return fluid->getInVelocityX();
@@ -444,6 +459,11 @@ extern "C" int *fluid_get_num_obstacle(FLUID *fluid)
return fluid->getNumObstacle();
}
+extern "C" int *smoke_get_num_guide(FLUID *fluid)
+{
+ return fluid->getNumGuide();
+}
+
extern "C" int smoke_has_heat(FLUID *smoke)
{
return (smoke->getHeat()) ? 1 : 0;
@@ -502,6 +522,11 @@ extern "C" void smoke_ensure_colors(FLUID *smoke, struct SmokeModifierData *smd)
}
}
+extern "C" float *smoke_get_phiguidein(FLUID *smoke)
+{
+ return smoke->getPhiGuideIn();
+}
+
extern "C" void liquid_ensure_init(FLUID *smoke, struct SmokeModifierData *smd)
{
if (smoke) {
diff --git a/intern/mantaflow/intern/strings/liquid_script.h b/intern/mantaflow/intern/strings/liquid_script.h
index a7a962fe344..240125e3c0a 100644
--- a/intern/mantaflow/intern/strings/liquid_script.h
+++ b/intern/mantaflow/intern/strings/liquid_script.h
@@ -154,6 +154,7 @@ def liquid_post_step_low_$ID$():\n\
# TODO (sebbas): liquid inflow\n\
#invel_s$ID$.clear()\n\
\n\
+ phiIn_s$ID$.setConst(9999)\n\
phiObs_s$ID$.setConst(9999)\n\
phiOut_s$ID$.setConst(9999)\n\
phiOutIn_s$ID$.setConst(9999)\n\
diff --git a/intern/mantaflow/intern/strings/smoke_script.h b/intern/mantaflow/intern/strings/smoke_script.h
index e4857af04d4..885415fff4b 100644
--- a/intern/mantaflow/intern/strings/smoke_script.h
+++ b/intern/mantaflow/intern/strings/smoke_script.h
@@ -39,12 +39,7 @@ mantaMsg('Smoke domain low')\n\
flags_s$ID$.initDomain(boundaryWidth=boundaryWidth_s$ID$)\n\
flags_s$ID$.fillGrid()\n\
if doOpen_s$ID$:\n\
- setOpenBound(flags=flags_s$ID$, bWidth=boundaryWidth_s$ID$, openBound=boundConditions_s$ID$, type=FlagOutflow|FlagEmpty)\n\
-\n\
-# TODO (sebbas): just put this code here out of convenience - removing this later anyways\n\
-getSpiralVelocity(flags=flags_s$ID$, vel=velT_s$ID$, strength=$GUIDING_STRENGTH$, with3D=True)\n\
-setGradientYWeight(W=weightG_s$ID$, minY=0, maxY=res_s$ID$/2, valAtMin=valAtMin_s$ID$, valAtMax=valAtMin_s$ID$)\n\
-setGradientYWeight(W=weightG_s$ID$, minY=res_s$ID$/2, maxY=res_s$ID$, valAtMin=valAtMax_s$ID$, valAtMax=valAtMax_s$ID$)\n";
+ setOpenBound(flags=flags_s$ID$, bWidth=boundaryWidth_s$ID$, openBound=boundConditions_s$ID$, type=FlagOutflow|FlagEmpty)\n";
const std::string smoke_bounds_high = "\n\
# prepare domain high\n\
@@ -67,7 +62,7 @@ using_guiding_s$ID$ = $USING_GUIDING$\n\
vorticity_s$ID$ = $VORTICITY$\n\
\n\
# fluid guiding params\n\
-scale_s$ID$ = 2\n\
+factorGuiding_s$ID$ = $GUIDING_STRENGTH$\n\
valAtMin_s$ID$ = 1\n\
valAtMax_s$ID$ = 5\n\
beta_s$ID$ = 2\n\
@@ -96,6 +91,17 @@ const std::string smoke_with_fire = "\n\
using_fire_s$ID$ = True\n";
//////////////////////////////////////////////////////////////////////
+// GUIDING
+//////////////////////////////////////////////////////////////////////
+
+const std::string smoke_guiding = "\n\
+ weightGuide_s$ID$.multConst(0)\n\
+ weightGuide_s$ID$.addConst(2)\n\
+#getSpiralVelocity(flags=flags_s$ID$, vel=guidevel_s$ID$, strength=$GUIDING_STRENGTH$, with3D=True)\n\
+#setGradientYWeight(W=weightGuide_s$ID$, minY=0, maxY=res_s$ID$/2, valAtMin=valAtMin_s$ID$, valAtMax=valAtMin_s$ID$)\n\
+#setGradientYWeight(W=weightGuide_s$ID$, minY=res_s$ID$/2, maxY=res_s$ID$, valAtMin=valAtMax_s$ID$, valAtMax=valAtMax_s$ID$)\n";
+
+//////////////////////////////////////////////////////////////////////
// GRIDS
//////////////////////////////////////////////////////////////////////
@@ -104,6 +110,7 @@ const std::string smoke_alloc_low = "\n\
mantaMsg('Smoke alloc low')\n\
flags_s$ID$ = s$ID$.create(FlagGrid)\n\
numObs_s$ID$ = s$ID$.create(IntGrid)\n\
+numGuides_s$ID$ = s$ID$.create(IntGrid)\n\
vel_s$ID$ = s$ID$.create(MACGrid)\n\
x_vel_s$ID$ = s$ID$.create(RealGrid)\n\
y_vel_s$ID$ = s$ID$.create(RealGrid)\n\
@@ -117,11 +124,16 @@ invel_s$ID$ = s$ID$.create(VecGrid)\n\
x_invel_s$ID$ = s$ID$.create(RealGrid)\n\
y_invel_s$ID$ = s$ID$.create(RealGrid)\n\
z_invel_s$ID$ = s$ID$.create(RealGrid)\n\
-velT_s$ID$ = s$ID$.create(MACGrid)\n\
-weightG_s$ID$ = s$ID$.create(RealGrid)\n\
+guidevel_s$ID$ = s$ID$.create(MACGrid)\n\
+guidevelC_s$ID$ = s$ID$.create(Vec3Grid)\n\
+x_guidevel_s$ID$
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list