[Bf-blender-cvs] [2a1a6bc] soc-2014-fluid: 2D lowres smoke

Roman Pogribnyi noreply at git.blender.org
Mon Mar 9 23:09:49 CET 2015


Commit: 2a1a6bc5720a4310e42a67754998e0480bf7c59b
Author: Roman Pogribnyi
Date:   Mon Mar 9 22:55:34 2015 +0100
Branches: soc-2014-fluid
https://developer.blender.org/rB2a1a6bc5720a4310e42a67754998e0480bf7c59b

2D lowres smoke

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

M	intern/smoke/intern/MANTA.cpp
M	source/blender/blenkernel/intern/smoke.c

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

diff --git a/intern/smoke/intern/MANTA.cpp b/intern/smoke/intern/MANTA.cpp
index 1ebabc7..6772fb4 100644
--- a/intern/smoke/intern/MANTA.cpp
+++ b/intern/smoke/intern/MANTA.cpp
@@ -603,6 +603,7 @@ void * Manta_API::pointerFromString(const std::string& s){
 
 void Manta_API::updatePointers(FLUID_3D *fluid, bool updateColor)
 {
+	//blender_to_manta: whether we copy data from blender density/velocity field to mantaflow or the other way around
 	/*in 2D case, we want to copy in the Z-axis field that is in the middle of X and Y axes */
 	//x + y * max_x + z * max_x*max_y
 //	int position_to_copy_from(0 + (fluid->xRes()/2) * fluid->xRes() + (fluid->zRes()/2) * fluid->xRes()*fluid->yRes());
@@ -618,17 +619,16 @@ void Manta_API::updatePointers(FLUID_3D *fluid, bool updateColor)
 			}
 		}
 		int step = 0;
-		for (int cnt(0); cnt < fluid->xRes() * fluid->zRes()-1; ++cnt){
-			assert(fluid->_yLocation != -1);
-			step = int(fluid->_yRes * 0.5) * fluid->_xRes + 
-					(cnt % (fluid->_xRes)) + 
-					int(cnt/(fluid->_xRes)) * fluid->_xRes * fluid->_yRes;
-			if ((step < 0) || (step > fluid->_totalCells)){
-				cout << "UpdatePointers: step is larger tahn cell dim" << step << endl;
-			}
-			fluid->_density[step] = manta_fluid_density[cnt];
-			fluid->_manta_flags[step] = manta_fluid_flags[cnt];
-		}		
+		for (int cnty(0);cnty<fluid->yRes(); ++cnty)
+			for(int cntz(0);cntz<fluid->zRes(); ++cntz)
+			{
+				step = fluid->xRes() + cnty * fluid->xRes() + cntz * fluid->xRes()*fluid->yRes(); 
+				if ((step < 0) || (step > fluid->_totalCells)){
+					cout << "UpdatePointers: step is larger tahn cell dim" << step << endl;
+				}
+				fluid->_density[step] = manta_fluid_density[cnty + cntz*fluid->xRes()];
+				fluid->_manta_flags[step] = manta_fluid_flags[cnty + cntz*fluid->xRes()];
+			}		
 	}
 	else{
 		fluid->_density = (float* )pointerFromString(getGridPointer("density", "s"));	
diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c
index 0884ca2..306c5b0 100644
--- a/source/blender/blenkernel/intern/smoke.c
+++ b/source/blender/blenkernel/intern/smoke.c
@@ -2301,14 +2301,7 @@ static void update_flowsfluids(Scene *scene, Object *ob, SmokeDomainSettings *sd
 								if(sds->manta_solver_res == 3){
 									apply_inflow_fields(sfs, emission_map[e_index], d_index, inflow_grid, heat, fuel, react, color_r, color_g, color_b);
 								}
-								else{ /*2D solver*/
-									int cell_cnt;
-									for (cell_cnt=0; cell_cnt< sds->res_max[0] * sds->res_max[2]-1; ++cell_cnt ){
-										int step = cell_index_3D(cell_cnt, sds->res_max[0], sds->res_max[1], sds->res_max[2]);
-										inflow_grid[cell_cnt] = density[step];
-									}
-								}
-								/* initial velocity */
+																/* initial velocity */
 								if (sfs->flags & MOD_SMOKE_FLOW_INITVELOCITY) {
 									velocity_x[d_index] = ADD_IF_LOWER(velocity_x[d_index], velocity_map[e_index * 3]);
 									velocity_y[d_index] = ADD_IF_LOWER(velocity_y[d_index], velocity_map[e_index * 3 + 1]);
@@ -2402,6 +2395,19 @@ static void update_flowsfluids(Scene *scene, Object *ob, SmokeDomainSettings *sd
 										} // hires loop
 							}  // bigdensity
 						} // low res loop
+
+				{ /*2D solver*/
+					int cnty;
+					int cntz;
+					int step;
+					for ( cnty=0;cnty<sds->res_max[1]; ++cnty)
+						for( cntz=0;cntz<sds->res_max[2]; ++cntz)
+						{
+							step = sds->res_max[0]/2 + cnty * sds->res_max[0] + cntz * sds->res_max[0]*sds->res_max[1]; 
+							inflow_grid[cnty + cntz*sds->res_max[0]] = density[step];
+						}
+				}
+
 				if((sds->flags & MOD_SMOKE_USE_MANTA) && (bigdensity)){
 //					manta_write_emitters(sfs,true,0,0,0,bigres[0], bigres[1], bigres[2], bigres[0], bigres[1], bigres[2],manta_big_inflow_sdf, NULL);
 					MEM_freeN(manta_big_inflow_sdf);




More information about the Bf-blender-cvs mailing list