merge with trunk at r27259 and commit of a patch by anthony jones to fix msvc (though...
[blender-staging.git] / source / blender / blenkernel / intern / smoke.c
index e53707bd6eb993822ab261d21a167ca42a072e2e..dd25bfe4ec4c7f985f742fe7e054c31b84149fe2 100644 (file)
@@ -17,7 +17,7 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  *
  * The Original Code is Copyright (C) Blender Foundation.
  * All rights reserved.
@@ -872,11 +872,13 @@ static void smoke_calc_domain(Scene *scene, Object *ob, SmokeModifierData *smd)
                                                                heat[index] = sfs->temp;
                                                                density[index] = sfs->density;
 
-                                                               /*
+
+                                                               // Uses particle velocity as initial velocity for smoke
+                                                               if(smd->domain->flags & MOD_SMOKE_INITVELOCITY) {
                                                                velocity_x[index] = pa->state.vel[0];
                                                                velocity_y[index] = pa->state.vel[1];
                                                                velocity_z[index] = pa->state.vel[2];                                                                           
-                                                               */                                                                              
+                                                               }                                                                               
                                                                
                                                                // obstacle[index] |= 2;
                                                                // we need different handling for the high-res feature
@@ -1396,8 +1398,9 @@ static void get_cell(float *p0, int res[3], float dx, float *pos, int *cell, int
 
 static void smoke_calc_transparency(float *result, float *input, float *p0, float *p1, int res[3], float dx, float *light, bresenham_callback cb, float correct)
 {
-       int x, y, z;
+       int z;
        float bv[6];
+       int slabsize=res[0]*res[1];
 
        memset(result, -1, sizeof(float)*res[0]*res[1]*res[2]); // x
        bv[0] = p0[0];
@@ -1409,19 +1412,20 @@ static void smoke_calc_transparency(float *result, float *input, float *p0, floa
        bv[4] = p0[2];
        bv[5] = p1[2];
 
-#pragma omp parallel for schedule(static) private(y, z)
-       for(x = 0; x < res[0]; x++)
+#pragma omp parallel for schedule(static,1)
+       for(z = 0; z < res[2]; z++)
+       {
+               size_t index = z*slabsize;
+               int x,y;
+
                for(y = 0; y < res[1]; y++)
-                       for(z = 0; z < res[2]; z++)
+                       for(x = 0; x < res[0]; x++, index++)
                        {
                                float voxelCenter[3];
-                               size_t index;
                                float pos[3];
                                int cell[3];
                                float tRay = 1.0;
 
-                               index = smoke_get_index(x, res[0], y, res[1], z);
-
                                if(result[index] >= 0.0f)                                       
                                        continue;                                                               
                                voxelCenter[0] = p0[0] + dx *  x + dx * 0.5;
@@ -1446,5 +1450,6 @@ static void smoke_calc_transparency(float *result, float *input, float *p0, floa
 // #pragma omp critical
                                result[index] = tRay;                   
                        }
+       }
 }