[Bf-blender-cvs] [2b3b73f] soc-2014-fluid: low-res: passing obstacles in-memory

Roman Pogribnyi noreply at git.blender.org
Tue Oct 21 23:09:46 CEST 2014


Commit: 2b3b73fbb0f3b95a256d04a94238eef547da355d
Author: Roman Pogribnyi
Date:   Sat Oct 18 15:52:46 2014 +0200
Branches: soc-2014-fluid
https://developer.blender.org/rB2b3b73fbb0f3b95a256d04a94238eef547da355d

low-res: passing obstacles in-memory

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

M	intern/smoke/extern/smoke_API.h
M	intern/smoke/intern/MANTA.cpp
M	intern/smoke/intern/smoke_API.cpp
M	source/blender/blenkernel/intern/smoke.c

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

diff --git a/intern/smoke/extern/smoke_API.h b/intern/smoke/extern/smoke_API.h
index 9133b5a..fb42d3a 100644
--- a/intern/smoke/extern/smoke_API.h
+++ b/intern/smoke/extern/smoke_API.h
@@ -120,8 +120,8 @@ void smoke_mantaflow_sim_step(struct Scene *scene, struct SmokeModifierData *smd
 void smoke_mantaflow_stop_sim();
 void manta_write_effectors(struct Scene *s, struct SmokeModifierData *smd);
 void manta_update_effectors(struct Scene *scene, struct Object *ob,struct SmokeDomainSettings *sds, float dt);
-void manta_write_emitters(struct SmokeFlowSettings *sfs, int min_x, int min_y, int min_z, int max_x, int max_y, int max_z, int d_x, int d_y, int d_z,float *influence, float *vel);
-
+void manta_write_emitters(struct SmokeFlowSettings *sfs, int min_x, int min_y, int min_z, int max_x, int max_y, int max_z, int d_x, int d_y, int d_z,float *influence, float *vel);	
+void manta_export_obstacles(float * influence, int x, int y, int z);
 #ifdef __cplusplus
 }
 #endif
diff --git a/intern/smoke/intern/MANTA.cpp b/intern/smoke/intern/MANTA.cpp
index e8fbc33..089c8f4 100644
--- a/intern/smoke/intern/MANTA.cpp
+++ b/intern/smoke/intern/MANTA.cpp
@@ -410,7 +410,7 @@ void Manta_API::export_obstacles(float *data, int x, int y, int z)
 	stringStream << grid_name << " = s.create(RealGrid)";
 	const std::string command_1 = stringStream.str();
 	stringStream.str("");
-	stringStream << grid_name << ".readGridFromMemory(\'"<< data << "\',\'" << grid_name << "\', " << x << "," << y << "," << z << ")";
+	stringStream << grid_name << ".readGridFromMemory(\'"<< data << "\', " << x << "," << y << "," << z << ")";
 	const std::string command_2 = stringStream.str();
 	const std::string command_3 = grid_name + ".applyToGrid(grid = flags, value = FlagObstacle)";
 	PyGILState_STATE gilstate = PyGILState_Ensure();
diff --git a/intern/smoke/intern/smoke_API.cpp b/intern/smoke/intern/smoke_API.cpp
index a5ba264..8e6918c 100644
--- a/intern/smoke/intern/smoke_API.cpp
+++ b/intern/smoke/intern/smoke_API.cpp
@@ -551,6 +551,11 @@ extern "C" void manta_write_emitters(struct SmokeFlowSettings *sfs, int min_x, i
 //	export_em_fields(Manta_API::instance()->_emission_map,sfs->density, min_x,  min_y,  min_z,  max_x,  max_y,  max_z,  d_x,  d_y,  d_z,  influence,  vel);
 }
 
+extern "C" void manta_export_obstacles(float * influence, int x, int y, int z)
+{
+	Manta_API::export_obstacles(influence, x, y, z);
+}
+
 extern "C" void smoke_mantaflow_stop_sim()
 {
 	Manta_API::instance()->stop_manta_sim();
diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c
index 64513a4..456052e 100644
--- a/source/blender/blenkernel/intern/smoke.c
+++ b/source/blender/blenkernel/intern/smoke.c
@@ -914,27 +914,31 @@ static void update_obstacles(Scene *scene, Object *ob, SmokeDomainSettings *sds,
 
 	if (collobjs)
 		MEM_freeN(collobjs);
-
+	
+	float *manta_obs_sdf = (float*)malloc(sizeof(float) * sds->res[0] * sds->res[1] * sds->res[2]);
 	/* obstacle cells should not contain any velocity from the smoke simulation */
 	for (z = 0; z < sds->res[0] * sds->res[1] * sds->res[2]; z++)
 	{
+		manta_obs_sdf[z] = 0.;
 		if (obstacles[z])
 		{
-			velxOrig[z] = 0;
-			velyOrig[z] = 0;
-			velzOrig[z] = 0;
-			density[z] = 0;
-			if (fuel) {
-				fuel[z] = 0;
-				flame[z] = 0;
-			}
-			if (r) {
-				r[z] = 0;
-				g[z] = 0;
-				b[z] = 0;
-			}
-		}
-	}
+			manta_obs_sdf[z] = 1.;
+//			velxOrig[z] = 0;
+//			velyOrig[z] = 0;
+//			velzOrig[z] = 0;
+//			density[z] = 0;
+//			if (fuel) {
+//				fuel[z] = 0;
+//				flame[z] = 0;
+//			}
+//			if (r) {
+//				r[z] = 0;
+//				g[z] = 0;
+//				b[z] = 0;
+//			}
+		}
+	}
+	manta_export_obstacles(manta_obs_sdf, sds->res[0], sds->res[1], sds->res[2]);
 }




More information about the Bf-blender-cvs mailing list