[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [55518] trunk/blender/source/blender/ blenkernel/intern/smoke.c: Fix [#34721]: Smoke adaptive domain threshold ignores high resolution data.

Miika Hamalainen miika.hamalainen at kolumbus.fi
Fri Mar 22 18:11:32 CET 2013


Revision: 55518
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=55518
Author:   miikah
Date:     2013-03-22 17:11:32 +0000 (Fri, 22 Mar 2013)
Log Message:
-----------
Fix [#34721]: Smoke adaptive domain threshold ignores high resolution data.

In some cases high resolution domain could have higher density than the low resolution counterpart, causing adaptive domain to clip off areas where density is still above domain threshold. Now also high resolution data is used to determine domain bounds.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/smoke.c

Modified: trunk/blender/source/blender/blenkernel/intern/smoke.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/smoke.c	2013-03-22 17:08:55 UTC (rev 55517)
+++ trunk/blender/source/blender/blenkernel/intern/smoke.c	2013-03-22 17:11:32 UTC (rev 55518)
@@ -1303,10 +1303,18 @@
 	int x, y, z, i;
 	float *density = smoke_get_density(sds->fluid);
 	float *fuel = smoke_get_fuel(sds->fluid);
+	float *bigdensity = smoke_turbulence_get_density(sds->wt);
+	float *bigfuel = smoke_turbulence_get_fuel(sds->wt);
 	float *vx = smoke_get_velocity_x(sds->fluid);
 	float *vy = smoke_get_velocity_y(sds->fluid);
 	float *vz = smoke_get_velocity_z(sds->fluid);
+	int block_size = sds->amplify + 1;
+	int wt_res[3];
 
+	if (sds->flags & MOD_SMOKE_HIGHRES && sds->wt) {
+		smoke_turbulence_get_res(sds->wt, wt_res);
+	}
+
 	INIT_MINMAX(min_vel, max_vel);
 
 	/* Calculate bounds for current domain content */
@@ -1317,9 +1325,36 @@
 				int xn = x - new_shift[0];
 				int yn = y - new_shift[1];
 				int zn = z - new_shift[2];
-				int index = smoke_get_index(x - sds->res_min[0], sds->res[0], y - sds->res_min[1], sds->res[1], z - sds->res_min[2]);
-				float max_den = (fuel) ? MAX2(density[index], fuel[index]) : density[index];
+				int index;
+				float max_den;
+				
+				/* skip if cell already belongs to new area */
+				if (xn >= min[0] && xn <= max[0] && yn >= min[1] && yn <= max[1] && zn >= min[2] && zn <= max[2])
+					continue;
 
+				index = smoke_get_index(x - sds->res_min[0], sds->res[0], y - sds->res_min[1], sds->res[1], z - sds->res_min[2]);
+				max_den = (fuel) ? MAX2(density[index], fuel[index]) : density[index];
+
+				/* check high resolution bounds if max density isnt already high enough */
+				if (max_den < sds->adapt_threshold && sds->flags & MOD_SMOKE_HIGHRES && sds->wt) {
+					int i, j, k;
+					/* high res grid index */
+					int xx = (x - sds->res_min[0]) * block_size;
+					int yy = (y - sds->res_min[1]) * block_size;
+					int zz = (z - sds->res_min[2]) * block_size;
+
+					for (i = 0; i < block_size; i++)
+						for (j = 0; j < block_size; j++)
+							for (k = 0; k < block_size; k++)
+							{
+								int big_index = smoke_get_index(xx + i, wt_res[0], yy + j, wt_res[1], zz + k);
+								float den = (bigfuel) ? MAX2(bigdensity[big_index], bigfuel[big_index]) : bigdensity[big_index];
+								if (den > max_den) {
+									max_den = den;
+								}
+							}
+				}
+
 				/* content bounds (use shifted coordinates) */
 				if (max_den >= sds->adapt_threshold) {
 					if (min[0] > xn) min[0] = xn;
@@ -1329,6 +1364,7 @@
 					if (max[1] < yn) max[1] = yn;
 					if (max[2] < zn) max[2] = zn;
 				}
+
 				/* velocity bounds */
 				if (min_vel[0] > vx[index]) min_vel[0] = vx[index];
 				if (min_vel[1] > vy[index]) min_vel[1] = vy[index];




More information about the Bf-blender-cvs mailing list