[Bf-blender-cvs] [a167cb7] fluid-mantaflow: wavelet fixes and refactored smoke.h
Sebastián Barschkis
noreply at git.blender.org
Thu Jan 28 12:37:26 CET 2016
Commit: a167cb75ceccb8c87d835b258153886fad9cceab
Author: Sebastián Barschkis
Date: Sat Jan 9 21:37:23 2016 +0100
Branches: fluid-mantaflow
https://developer.blender.org/rBa167cb75ceccb8c87d835b258153886fad9cceab
wavelet fixes and refactored smoke.h
===================================================================
M intern/smoke/intern/FLUID_3D.cpp
M intern/smoke/intern/MANTA.cpp
M intern/smoke/intern/WTURBULENCE.cpp
M intern/smoke/intern/scenarios/smoke.h
===================================================================
diff --git a/intern/smoke/intern/FLUID_3D.cpp b/intern/smoke/intern/FLUID_3D.cpp
index 86f4f2c..e25b34d 100644
--- a/intern/smoke/intern/FLUID_3D.cpp
+++ b/intern/smoke/intern/FLUID_3D.cpp
@@ -606,6 +606,7 @@ _xRes(res[0]), _yRes(res[1]), _zRes(res[2]), _res(0.0f)
std::string setup_script =
manta_import +
solver_setup_low +
+ uv_setup +
alloc_base_grids_low +
noise_low +
prep_domain_low +
diff --git a/intern/smoke/intern/MANTA.cpp b/intern/smoke/intern/MANTA.cpp
index 09d80e1..ae130b6 100644
--- a/intern/smoke/intern/MANTA.cpp
+++ b/intern/smoke/intern/MANTA.cpp
@@ -424,7 +424,7 @@ std::string Manta_API::get_real_value( const std::string& varName, SmokeModifier
if (varName == "UVS_CNT")
ss << smd->domain->manta_uvs_num ;
else if (varName == "UPRES")
- ss << smd->domain->amplify+1;
+ ss << smd->domain->amplify; //ss << smd->domain->amplify+1;
else if (varName == "WLT_STR")
ss << smd->domain->strength ;
else if (varName == "RES")
@@ -718,17 +718,17 @@ void Manta_API::update_pointers(FLUID_3D *fluid)
fluid->_fuel_inflow = (float* )pointer_from_string(get_grid_pointer("fuel_inflow", "s"));
if (fluid-> manta_resoution == 2) {return;}
if (fluid->using_colors) {
- fluid->_color_r = (float* )pointer_from_string(get_grid_pointer("color_r_low", "s"));
- fluid->_color_g = (float* )pointer_from_string(get_grid_pointer("color_g_low", "s"));
- fluid->_color_b = (float* )pointer_from_string(get_grid_pointer("color_b_low", "s"));
+ fluid->_color_r = (float* )pointer_from_string(get_grid_pointer("color_r", "s"));
+ fluid->_color_g = (float* )pointer_from_string(get_grid_pointer("color_g", "s"));
+ fluid->_color_b = (float* )pointer_from_string(get_grid_pointer("color_b", "s"));
}
if (fluid->using_heat) {
- fluid->_heat = (float* )pointer_from_string(get_grid_pointer("heat_low", "s"));
+ fluid->_heat = (float* )pointer_from_string(get_grid_pointer("heat", "s"));
}
if (fluid->using_fire) {
- fluid->_flame = (float* )pointer_from_string(get_grid_pointer("flame_low", "s"));
- fluid->_fuel = (float* )pointer_from_string(get_grid_pointer("fuel_low", "s"));
- fluid->_react = (float* )pointer_from_string(get_grid_pointer("react_low", "s"));
+ fluid->_flame = (float* )pointer_from_string(get_grid_pointer("flame", "s"));
+ fluid->_fuel = (float* )pointer_from_string(get_grid_pointer("fuel", "s"));
+ fluid->_react = (float* )pointer_from_string(get_grid_pointer("react", "s"));
}
fluid->_xVelocity = (float* )pointer_from_string(get_grid_pointer("x_vel", "s"));
fluid->_yVelocity = (float* )pointer_from_string(get_grid_pointer("y_vel", "s"));
@@ -740,14 +740,14 @@ void Manta_API::update_high_res_pointers(WTURBULENCE *wt)
cout << "Updating pointers high res" << endl;
wt->_densityBig = (float* )pointer_from_string(get_grid_pointer("xl_density", "xl"));;
if (wt->using_colors) {
- wt->_color_rBig = (float* )pointer_from_string(get_grid_pointer("color_r_high", "xl"));
- wt->_color_gBig = (float* )pointer_from_string(get_grid_pointer("color_g_high", "xl"));
- wt->_color_bBig = (float* )pointer_from_string(get_grid_pointer("color_b_high", "xl"));
+ wt->_color_rBig = (float* )pointer_from_string(get_grid_pointer("xl_color_r", "xl"));
+ wt->_color_gBig = (float* )pointer_from_string(get_grid_pointer("xl_color_g", "xl"));
+ wt->_color_bBig = (float* )pointer_from_string(get_grid_pointer("xl_color_b", "xl"));
}
if (wt->using_fire) {
- wt->_flameBig = (float* )pointer_from_string(get_grid_pointer("flame_high", "xl"));
- wt->_fuelBig = (float* )pointer_from_string(get_grid_pointer("fuel_high", "xl"));
- wt->_reactBig = (float* )pointer_from_string(get_grid_pointer("react_high", "xl"));
+ wt->_flameBig = (float* )pointer_from_string(get_grid_pointer("xl_flame", "xl"));
+ wt->_fuelBig = (float* )pointer_from_string(get_grid_pointer("xl_fuel", "xl"));
+ wt->_reactBig = (float* )pointer_from_string(get_grid_pointer("xl_react", "xl"));
}
}
diff --git a/intern/smoke/intern/WTURBULENCE.cpp b/intern/smoke/intern/WTURBULENCE.cpp
index 758b65b..ff7553a 100644
--- a/intern/smoke/intern/WTURBULENCE.cpp
+++ b/intern/smoke/intern/WTURBULENCE.cpp
@@ -1266,6 +1266,7 @@ WTURBULENCE::WTURBULENCE(int xResSm, int yResSm, int zResSm, int amplify, int no
alloc_base_grids_high +
noise_high +
prep_domain_high +
+ flags +
wavelet_turbulence_noise +
smoke_step_high;
std::string final_script = Manta_API::parse_script(setup_script, sds->smd);
@@ -1283,30 +1284,30 @@ WTURBULENCE::WTURBULENCE(int xResSm, int yResSm, int zResSm, int amplify, int no
initColors(0.0f, 0.0f, 0.0f);
}
-// // allocate & init texture coordinates
-// _tcU = new float[_totalCellsSm];
-// _tcV = new float[_totalCellsSm];
-// _tcW = new float[_totalCellsSm];
-// _tcTemp = new float[_totalCellsSm];
-//
-// // map all
-// const float dx = 1.0f/(float)(_resSm[0]);
-// const float dy = 1.0f/(float)(_resSm[1]);
-// const float dz = 1.0f/(float)(_resSm[2]);
-// int index = 0;
-// for (int z = 0; z < _zResSm; z++)
-// for (int y = 0; y < _yResSm; y++)
-// for (int x = 0; x < _xResSm; x++, index++)
-// {
-// _tcU[index] = x*dx;
-// _tcV[index] = y*dy;
-// _tcW[index] = z*dz;
-// _tcTemp[index] = 0.;
-// }
-//
-// // noise tiles
-// _noiseTile = new float[noiseTileSize * noiseTileSize * noiseTileSize];
-// setNoise(noisetype, noisefile_path);
+ // allocate & init texture coordinates
+ _tcU = new float[_totalCellsSm];
+ _tcV = new float[_totalCellsSm];
+ _tcW = new float[_totalCellsSm];
+ _tcTemp = new float[_totalCellsSm];
+
+ // map all
+ const float dx = 1.0f/(float)(_resSm[0]);
+ const float dy = 1.0f/(float)(_resSm[1]);
+ const float dz = 1.0f/(float)(_resSm[2]);
+ int index = 0;
+ for (int z = 0; z < _zResSm; z++)
+ for (int y = 0; y < _yResSm; y++)
+ for (int x = 0; x < _xResSm; x++, index++)
+ {
+ _tcU[index] = x*dx;
+ _tcV[index] = y*dy;
+ _tcW[index] = z*dz;
+ _tcTemp[index] = 0.;
+ }
+
+ // noise tiles
+ _noiseTile = new float[noiseTileSize * noiseTileSize * noiseTileSize];
+ setNoise(noisetype, noisefile_path);
Manta_API::update_high_res_pointers(this);
}
@@ -1325,19 +1326,19 @@ WTURBULENCE::~WTURBULENCE()
PyGILState_Release(gilstate);
delete[] _densityBig;
- delete[] _densityBigOld;
+// delete[] _densityBigOld;
if (_flameBig) delete[] _flameBig;
if (_fuelBig) delete[] _fuelBig;
- if (_fuelBigOld) delete[] _fuelBigOld;
+// if (_fuelBigOld) delete[] _fuelBigOld;
if (_reactBig) delete[] _reactBig;
- if (_reactBigOld) delete[] _reactBigOld;
+// if (_reactBigOld) delete[] _reactBigOld;
if (_color_rBig) delete[] _color_rBig;
- if (_color_rBigOld) delete[] _color_rBigOld;
+// if (_color_rBigOld) delete[] _color_rBigOld;
if (_color_gBig) delete[] _color_gBig;
- if (_color_gBigOld) delete[] _color_gBigOld;
+// if (_color_gBigOld) delete[] _color_gBigOld;
if (_color_bBig) delete[] _color_bBig;
- if (_color_bBigOld) delete[] _color_bBigOld;
+// if (_color_bBigOld) delete[] _color_bBigOld;
delete[] _tcU;
delete[] _tcV;
@@ -1380,7 +1381,9 @@ void WTURBULENCE::setNoise(int type, const char *noisefile_path)
{}
void WTURBULENCE::initBlenderRNA(float *strength)
-{}
+{
+ _strength = strength;
+}
void WTURBULENCE::stepTurbulenceReadable(float dt, float* xvel, float* yvel, float* zvel, unsigned char *obstacles)
{
diff --git a/intern/smoke/intern/scenarios/smoke.h b/intern/smoke/intern/scenarios/smoke.h
index dceeccf..4c133b3 100644
--- a/intern/smoke/intern/scenarios/smoke.h
+++ b/intern/smoke/intern/scenarios/smoke.h
@@ -16,6 +16,14 @@ using_fire = $USING_FIRE$\n\
low_flags_updated = False\n\
using_wavelets = $USE_WAVELETS$\n";
+const string uv_setup = "\n\
+# create the array of uv grids\n\
+uv = []\n\
+for i in range(uvs):\n\
+ uvGrid = s.create(VecGrid)\n\
+ uv.append(uvGrid)\n\
+ resetUvGrid(uv[i])\n";
+
//////////////////////////////////////////////////////////////////////
// LOW RESOLUTION SETUP
//////////////////////////////////////////////////////////////////////
@@ -32,7 +40,8 @@ if dim == 2:\n\
s = FluidSolver(name='main', gridSize=gs, dim=dim)\n\
s.timestep = $TIMESTEP$\n\
timings = Timings()\n\
-vorticity = $VORTICITY$\n";
+vorticity = $VORTICITY$\n\
+uvs = $UVS_CNT$\n";
const string alloc_base_grids_low = "\n\
# prepare grids low\n\
@@ -43,6 +52,7 @@ y_vel = s.create(RealGrid)\n\
z_vel = s.create(RealGrid)\n\
density = s.create(LevelsetGrid)\n\
pressure = s.create(RealGrid)\n\
+energy = s.create(RealGrid)\n\
forces = s.create(MACGrid)\n\
inflow_grid = s.create(LevelsetGrid)\n\
fuel_inflow = s.create(LevelsetGrid)\n";
@@ -76,7 +86,6 @@ if dim == 2:\n\
xl_gs.z = 1\n\
xl = Solver(name = 'larger', gridSize = xl_gs)\n\
xl.timestep = $XL_TIMESTEP$\n\
-uvs = $UVS_CNT$\n\
wltStrength = $WLT_STR$\n\
octaves = 0\n\
if(upres>0):\n\
@@ -109,11 +118,12 @@ xl_flags.initDomain()\n\
xl_flags.fillGrid()\n";
const string wavelet_turbulence_noise = "\n\
-# wavelet turbulence noise\n\
-xl_wltnoise = xl.create(NoiseField, loadFromFile=True)\n\
-xl_wltnoise.posScale = vec3( int(1.0*xl_gs.x) ) * 0.5\n\
-xl_wltnoise.posScale = xl_wltnoise.posScale * 0.5\n\
-xl_wltnoise.timeAnim = 0.1 \n";
+# wavelet turbulence noise field\n\
+xl_wltnoise = s.create(NoiseField, loadFromFile=True)\n\
+xl_wltnoise.posScale = vec3( int(1.0*gs.x) ) * 0.5\n\
+xl_wltnoise.timeAnim = 0.1\n\
+if(upres>0):\n\
+ xl_wltnoise.posScale = xl_wltnoise.posScale * (1./upres)\n";
//////////////////////////////////////////////////////////////////////
// ADDITIONAL GRIDS
@@ -121,49 +131,49 @@ xl_wltnoise.timeAnim = 0.1 \n";
const string alloc_colors_low = "\n\
print('Allocating colors low')\n\
-color_r_low = s.create(RealGrid)\n\
-color_g_low = s.create(RealGrid)\n\
-color_b_low = s.create(RealGrid)\n";
+color_r = s.create(RealGrid)\n\
+color_g = s.create(RealGrid)\n\
+color_b = s.create(RealGrid)\n";
const string alloc_colors_high = "\n\
print('Allocating colors high')\n\
-color_r_high = xl.create(RealGrid)\n\
-color_g_high = xl.create(RealGrid)\n\
-color_b_high = xl.create(RealGrid)\n";
+xl_color_r = xl.create(RealGrid)\n\
+xl_color_g = xl.create(RealGrid)\n\
+xl_color_b = xl.create(RealGrid)\n";
const string init_colors_low = "\n\
print('Initializi
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list