Commit: bb0e1375b131b86f0f31b2a537a21ec765ee07f0
Author: Lukas Tönne
Date:   Thu Dec 31 12:04:51 2015 +0100
Branches: object_nodes
https://developer.blender.org/rBbb0e1375b131b86f0f31b2a537a21ec765ee07f0

Merge branch 'master' into object_nodes

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



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

diff --cc source/blender/blenkernel/intern/smoke.c
index a347eba,29ae04b..4ea5fbb
--- a/source/blender/blenkernel/intern/smoke.c
+++ b/source/blender/blenkernel/intern/smoke.c
@@@ -2405,75 -2499,100 +2499,100 @@@ static void update_flowsfluids(Scene *s
                MEM_freeN(emaps);
  }
  
+ typedef struct UpdateEffectorsData {
+       Scene *scene;
+       SmokeDomainSettings *sds;
+       ListBase *effectors;
+ 
+       float *density;
+       float *fuel;
+       float *force_x;
+       float *force_y;
+       float *force_z;
+       float *velocity_x;
+       float *velocity_y;
+       float *velocity_z;
+       unsigned char *obstacle;
+ } UpdateEffectorsData;
+ 
+ static void update_effectors_task_cb(void *userdata, void 
*UNUSED(userdata_chunk), int x)
+ {
+       UpdateEffectorsData *data = userdata;
+       SmokeDomainSettings *sds = data->sds;
+ 
+       for (int y = 0; y < sds->res[1]; y++) {
+               for (int z = 0; z < sds->res[2]; z++)
+               {
+                       EffectedPoint epoint;
+                       float mag;
+                       float voxelCenter[3] = {0, 0, 0}, vel[3] = {0, 0, 0}, 
retvel[3] = {0, 0, 0};
+                       const unsigned int index = smoke_get_index(x, 
sds->res[0], y, sds->res[1], z);
+ 
+                       if (((data->fuel ? MAX2(data->density[index], 
data->fuel[index]) : data->density[index]) < FLT_EPSILON) ||
+                           data->obstacle[index])
+                       {
+                               continue;
+                       }
+ 
+                       vel[0] = data->velocity_x[index];
+                       vel[1] = data->velocity_y[index];
+                       vel[2] = data->velocity_z[index];
+ 
+                       /* convert vel to global space */
+                       mag = len_v3(vel);
+                       mul_mat3_m4_v3(sds->obmat, vel);
+                       normalize_v3(vel);
+                       mul_v3_fl(vel, mag);
+ 
+                       voxelCenter[0] = sds->p0[0] + sds->cell_size[0] * 
((float)(x + sds->res_min[0]) + 0.5f);
+                       voxelCenter[1] = sds->p0[1] + sds->cell_size[1] * 
((float)(y + sds->res_min[1]) + 0.5f);
+                       voxelCenter[2] = sds->p0[2] + sds->cell_size[2] * 
((float)(z + sds->res_min[2]) + 0.5f);
+                       mul_m4_v3(sds->obmat, voxelCenter);
+ 
+                       pd_point_from_loc(data->scene, voxelCenter, vel, index, 
&epoint);
+                       pdDoEffectors(data->effectors, NULL, 
sds->effector_weights, &epoint, retvel, NULL);
+ 
+                       /* convert retvel to local space */
+                       mag = len_v3(retvel);
+                       mul_mat3_m4_v3(sds->imat, retvel);
+                       normalize_v3(retvel);
+                       mul_v3_fl(retvel, mag);
+ 
+                       // TODO dg - do in force!
+                       data->force_x[index] = min_ff(max_ff(-1.0f, retvel[0] * 
0.2f), 1.0f);
+                       data->force_y[index] = min_ff(max_ff(-1.0f, retvel[1] * 
0.2f), 1.0f);
+                       data->force_z[index] = min_ff(max_ff(-1.0f, retvel[2] * 
0.2f), 1.0f);
+               }
+       }
+ }
+ 
  static void update_effectors(Scene *scene, Object *ob, SmokeDomainSettings 
*sds, float UNUSED(dt))
  {
 -      ListBase *effectors;
 +      EffectorContext *effectors;
        /* make sure smoke flow influence is 0.0f */
        sds->effector_weights->weight[PFIELD_SMOKEFLOW] = 0.0f;
        effectors = pdInitEffectors(scene, ob, NULL, sds->effector_weights, 
true);
  
-       if (effectors)
-       {
-               float *density = smoke_get_density(sds->fluid);
-               float *fuel = smoke_get_fuel(sds->fluid);
-               float *force_x = smoke_get_force_x(sds->fluid);
-               float *force_y = smoke_get_force_y(sds->fluid);
-               float *force_z = smoke_get_force_z(sds->fluid);
-               float *velocity_x = smoke_get_velocity_x(sds->fluid);
-               float *velocity_y = smoke_get_velocity_y(sds->fluid);
-               float *velocity_z = smoke_get_velocity_z(sds->fluid);
-               unsigned char *obstacle = smoke_get_obstacle(sds->fluid);
-               int x;
- 
+       if (effectors) {
                // precalculate wind forces
- #pragma omp parallel for schedule(static)
-               for (x = 0; x < sds->res[0]; x++)
-               {
-                       int y, z;
-                       for (y = 0; y < sds->res[1]; y++)
-                               for (z = 0; z < sds->res[2]; z++)
-                               {
-                                       EffectedPoint epoint;
-                                       float mag;
-                                       float voxelCenter[3] = {0, 0, 0}, 
vel[3] = {0, 0, 0}, retvel[3] = {0, 0, 0};
-                                       unsigned int index = smoke_get_index(x, 
sds->res[0], y, sds->res[1], z);
- 
-                                       if (((fuel ? MAX2(density[index], 
fuel[index]) : density[index]) < FLT_EPSILON) || obstacle[index])
-                                               continue;
- 
-                                       vel[0] = velocity_x[index];
-                                       vel[1] = velocity_y[index];
-                                       vel[2] = velocity_z[index];
- 
-                                       /* convert vel to global space */
-                                       mag = len_v3(vel);
-                                       mul_mat3_m4_v3(sds->obmat, vel);
-                                       normalize_v3(vel);
-                                       mul_v3_fl(vel, mag);
- 
-                                       voxelCenter[0] = sds->p0[0] + 
sds->cell_size[0] * ((float)(x + sds->res_min[0]) + 0.5f);
-                                       voxelCenter[1] = sds->p0[1] + 
sds->cell_size[1] * ((float)(y + sds->res_min[1]) + 0.5f);
-                                       voxelCenter[2] = sds->p0[2] + 
sds->cell_size[2] * ((float)(z + sds->res_min[2]) + 0.5f);
-                                       mul_m4_v3(sds->obmat, voxelCenter);
- 
-                                       pd_point_from_loc(scene, voxelCenter, 
vel, index, &epoint);
-                                       pdDoEffectors(effectors, NULL, 
sds->effector_weights, &epoint, retvel, NULL);
- 
-                                       /* convert retvel to local space */
-                                       mag = len_v3(retvel);
-                                       mul_mat3_m4_v3(sds->imat, retvel);
-                                       normalize_v3(retvel);
-                                       mul_v3_fl(retvel, mag);
- 
-                                       // TODO dg - do in force!
-                                       force_x[index] = min_ff(max_ff(-1.0f, 
retvel[0] * 0.2f), 1.0f);
-                                       force_y[index] = min_ff(max_ff(-1.0f, 
retvel[1] * 0.2f), 1.0f);
-                                       force_z[index] = min_ff(max_ff(-1.0f, 
retvel[2] * 0.2f), 1.0f);
-                               }
-               }
+               UpdateEffectorsData data;
+               data.scene = scene;
+               data.sds = sds;
+               data.effectors = effectors;
+               data.density = smoke_get_density(sds->fluid);
+               data.fuel = smoke_get_fuel(sds->fluid);
+               data.force_x = smoke_get_force_x(sds->fluid);
+               data.force_y = smoke_get_force_y(sds->fluid);
+               data.force_z = smoke_get_force_z(sds->fluid);
+               data.velocity_x = smoke_get_velocity_x(sds->fluid);
+               data.velocity_y = smoke_get_velocity_y(sds->fluid);
+               data.velocity_z = smoke_get_velocity_z(sds->fluid);
+               data.obstacle = smoke_get_obstacle(sds->fluid);
+ 
+               BLI_task_parallel_range_ex(0, sds->res[0], &data, NULL, 0, 
update_effectors_task_cb, true, false);
        }
  
 -      pdEndEffectors(&effectors);
 +      pdEndEffectors(effectors);
  }
  
  static void step(Scene *scene, Object *ob, SmokeModifierData *smd, 
DerivedMesh *domain_dm, float fps, bool for_render)

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to