[Bf-blender-cvs] [abd33a3c0c1] master: Fluid: Cleanup naming for emmission bounding box

Sebastián Barschkis noreply at git.blender.org
Fri Mar 6 11:04:35 CET 2020


Commit: abd33a3c0c1cf7097d7ee25a68b6083e19a89f75
Author: Sebastián Barschkis
Date:   Fri Mar 6 11:03:21 2020 +0100
Branches: master
https://developer.blender.org/rBabd33a3c0c1cf7097d7ee25a68b6083e19a89f75

Fluid: Cleanup naming for emmission bounding box

Since the bounding boxes are now also being used for effector objects, there needs to be a better name for them. Instead of calling them EmissionMap, which caters only to emission objects, they will now be called FluidObjectBB.

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

M	source/blender/blenkernel/intern/fluid.c

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

diff --git a/source/blender/blenkernel/intern/fluid.c b/source/blender/blenkernel/intern/fluid.c
index 977b449f6d3..f638211dded 100644
--- a/source/blender/blenkernel/intern/fluid.c
+++ b/source/blender/blenkernel/intern/fluid.c
@@ -650,7 +650,7 @@ static bool is_static_object(Object *ob)
 /** \name Bounding Box
  * \{ */
 
-typedef struct EmissionMap {
+typedef struct FluidObjectBB {
   float *influence;
   float *velocity;
   float *distances;
@@ -658,95 +658,98 @@ typedef struct EmissionMap {
   int min[3], max[3], res[3];
   int hmin[3], hmax[3], hres[3];
   int total_cells, valid;
-} EmissionMap;
+} FluidObjectBB;
 
-static void em_boundInsert(EmissionMap *em, float point[3])
+static void bb_boundInsert(FluidObjectBB *bb, float point[3])
 {
   int i = 0;
-  if (!em->valid) {
+  if (!bb->valid) {
     for (; i < 3; i++) {
-      em->min[i] = (int)floor(point[i]);
-      em->max[i] = (int)ceil(point[i]);
+      bb->min[i] = (int)floor(point[i]);
+      bb->max[i] = (int)ceil(point[i]);
     }
-    em->valid = 1;
+    bb->valid = 1;
   }
   else {
     for (; i < 3; i++) {
-      if (point[i] < em->min[i]) {
-        em->min[i] = (int)floor(point[i]);
+      if (point[i] < bb->min[i]) {
+        bb->min[i] = (int)floor(point[i]);
       }
-      if (point[i] > em->max[i]) {
-        em->max[i] = (int)ceil(point[i]);
+      if (point[i] > bb->max[i]) {
+        bb->max[i] = (int)ceil(point[i]);
       }
     }
   }
 }
 
-static void em_allocateData(EmissionMap *em, bool use_velocity, bool use_influence)
+static void bb_allocateData(FluidObjectBB *bb, bool use_velocity, bool use_influence)
 {
   int i, res[3];
 
   for (i = 0; i < 3; i++) {
-    res[i] = em->max[i] - em->min[i];
+    res[i] = bb->max[i] - bb->min[i];
     if (res[i] <= 0) {
       return;
     }
   }
-  em->total_cells = res[0] * res[1] * res[2];
-  copy_v3_v3_int(em->res, res);
+  bb->total_cells = res[0] * res[1] * res[2];
+  copy_v3_v3_int(bb->res, res);
 
-  em->numobjs = MEM_calloc_arrayN(em->total_cells, sizeof(float), "fluid_bb_numobjs");
+  bb->numobjs = MEM_calloc_arrayN(bb->total_cells, sizeof(float), "fluid_bb_numobjs");
   if (use_influence) {
-    em->influence = MEM_calloc_arrayN(em->total_cells, sizeof(float), "fluid_bb_influence");
+    bb->influence = MEM_calloc_arrayN(bb->total_cells, sizeof(float), "fluid_bb_influence");
   }
   if (use_velocity) {
-    em->velocity = MEM_calloc_arrayN(em->total_cells * 3, sizeof(float), "fluid_bb_velocity");
+    bb->velocity = MEM_calloc_arrayN(bb->total_cells * 3, sizeof(float), "fluid_bb_velocity");
   }
 
-  em->distances = MEM_malloc_arrayN(em->total_cells, sizeof(float), "fluid_bb_distances");
+  bb->distances = MEM_malloc_arrayN(bb->total_cells, sizeof(float), "fluid_bb_distances");
   /* Initialize to infinity. */
-  memset(em->distances, 0x7f7f7f7f, sizeof(float) * em->total_cells);
+  memset(bb->distances, 0x7f7f7f7f, sizeof(float) * bb->total_cells);
 
-  em->valid = true;
+  bb->valid = true;
 }
 
-static void em_freeData(EmissionMap *em)
+static void bb_freeData(FluidObjectBB *bb)
 {
-  if (em->numobjs) {
-    MEM_freeN(em->numobjs);
+  if (bb->numobjs) {
+    MEM_freeN(bb->numobjs);
   }
-  if (em->influence) {
-    MEM_freeN(em->influence);
+  if (bb->influence) {
+    MEM_freeN(bb->influence);
   }
-  if (em->velocity) {
-    MEM_freeN(em->velocity);
+  if (bb->velocity) {
+    MEM_freeN(bb->velocity);
   }
-  if (em->distances) {
-    MEM_freeN(em->distances);
+  if (bb->distances) {
+    MEM_freeN(bb->distances);
   }
 }
 
-static void em_combineMaps(EmissionMap *output, EmissionMap *em2, int additive, float sample_size)
+static void bb_combineMaps(FluidObjectBB *output,
+                           FluidObjectBB *bb2,
+                           int additive,
+                           float sample_size)
 {
   int i, x, y, z;
 
   /* Copyfill input 1 struct and clear output for new allocation. */
-  EmissionMap em1;
-  memcpy(&em1, output, sizeof(EmissionMap));
-  memset(output, 0, sizeof(EmissionMap));
+  FluidObjectBB bb1;
+  memcpy(&bb1, output, sizeof(FluidObjectBB));
+  memset(output, 0, sizeof(FluidObjectBB));
 
   for (i = 0; i < 3; i++) {
-    if (em1.valid) {
-      output->min[i] = MIN2(em1.min[i], em2->min[i]);
-      output->max[i] = MAX2(em1.max[i], em2->max[i]);
+    if (bb1.valid) {
+      output->min[i] = MIN2(bb1.min[i], bb2->min[i]);
+      output->max[i] = MAX2(bb1.max[i], bb2->max[i]);
     }
     else {
-      output->min[i] = em2->min[i];
-      output->max[i] = em2->max[i];
+      output->min[i] = bb2->min[i];
+      output->max[i] = bb2->max[i];
     }
   }
   /* Allocate output map. */
-  em_allocateData(output, (em1.velocity || em2->velocity), (em1.influence || em2->influence));
+  bb_allocateData(output, (bb1.velocity || bb2->velocity), (bb1.influence || bb2->influence));
 
   /* Low through bounding box */
   for (x = output->min[0]; x < output->max[0]; x++) {
@@ -759,45 +762,45 @@ static void em_combineMaps(EmissionMap *output, EmissionMap *em2, int additive,
                                         z - output->min[2]);
 
         /* Initialize with first input if in range. */
-        if (x >= em1.min[0] && x < em1.max[0] && y >= em1.min[1] && y < em1.max[1] &&
-            z >= em1.min[2] && z < em1.max[2]) {
+        if (x >= bb1.min[0] && x < bb1.max[0] && y >= bb1.min[1] && y < bb1.max[1] &&
+            z >= bb1.min[2] && z < bb1.max[2]) {
           int index_in = manta_get_index(
-              x - em1.min[0], em1.res[0], y - em1.min[1], em1.res[1], z - em1.min[2]);
+              x - bb1.min[0], bb1.res[0], y - bb1.min[1], bb1.res[1], z - bb1.min[2]);
 
           /* Values. */
-          output->numobjs[index_out] = em1.numobjs[index_in];
-          output->influence[index_out] = em1.influence[index_in];
-          output->distances[index_out] = em1.distances[index_in];
-          if (output->velocity && em1.velocity) {
-            copy_v3_v3(&output->velocity[index_out * 3], &em1.velocity[index_in * 3]);
+          output->numobjs[index_out] = bb1.numobjs[index_in];
+          output->influence[index_out] = bb1.influence[index_in];
+          output->distances[index_out] = bb1.distances[index_in];
+          if (output->velocity && bb1.velocity) {
+            copy_v3_v3(&output->velocity[index_out * 3], &bb1.velocity[index_in * 3]);
           }
         }
 
         /* Apply second input if in range. */
-        if (x >= em2->min[0] && x < em2->max[0] && y >= em2->min[1] && y < em2->max[1] &&
-            z >= em2->min[2] && z < em2->max[2]) {
+        if (x >= bb2->min[0] && x < bb2->max[0] && y >= bb2->min[1] && y < bb2->max[1] &&
+            z >= bb2->min[2] && z < bb2->max[2]) {
           int index_in = manta_get_index(
-              x - em2->min[0], em2->res[0], y - em2->min[1], em2->res[1], z - em2->min[2]);
+              x - bb2->min[0], bb2->res[0], y - bb2->min[1], bb2->res[1], z - bb2->min[2]);
 
           /* Values. */
-          output->numobjs[index_out] = MAX2(em2->numobjs[index_in], output->numobjs[index_out]);
+          output->numobjs[index_out] = MAX2(bb2->numobjs[index_in], output->numobjs[index_out]);
           if (additive) {
-            output->influence[index_out] += em2->influence[index_in] * sample_size;
+            output->influence[index_out] += bb2->influence[index_in] * sample_size;
           }
           else {
-            output->influence[index_out] = MAX2(em2->influence[index_in],
+            output->influence[index_out] = MAX2(bb2->influence[index_in],
                                                 output->influence[index_out]);
           }
-          output->distances[index_out] = MIN2(em2->distances[index_in],
+          output->distances[index_out] = MIN2(bb2->distances[index_in],
                                               output->distances[index_out]);
-          if (output->velocity && em2->velocity) {
+          if (output->velocity && bb2->velocity) {
             /* Last sample replaces the velocity. */
             output->velocity[index_out * 3] = ADD_IF_LOWER(output->velocity[index_out * 3],
-                                                           em2->velocity[index_in * 3]);
+                                                           bb2->velocity[index_in * 3]);
             output->velocity[index_out * 3 + 1] = ADD_IF_LOWER(output->velocity[index_out * 3 + 1],
-                                                               em2->velocity[index_in * 3 + 1]);
+                                                               bb2->velocity[index_in * 3 + 1]);
             output->velocity[index_out * 3 + 2] = ADD_IF_LOWER(output->velocity[index_out * 3 + 2],
-                                                               em2->velocity[index_in * 3 + 2]);
+                                                               bb2->velocity[index_in * 3 + 2]);
           }
         }
       } /* Low res loop. */
@@ -805,7 +808,7 @@ static void em_combineMaps(EmissionMap *output, EmissionMap *em2, int additive,
   }
 
   /* Free original data. */
-  em_freeData(&em1);
+  bb_freeData(&bb1);
 }
 
 /** \} */
@@ -940,7 +943,7 @@ typedef struct ObstaclesFromDMData {
   const MLoopTri *mlooptri;
 
   BVHTreeFromMesh *tree;
-  EmissionMap *om;
+  FluidObjectBB *bb;
 
   bool has_velocity;
   float *vert_vel;
@@ -952,29 +955,29 @@ static void obstacles_from_mesh_task_cb(void *__restrict userdata,
                                         const TaskParallelTLS *__restrict UNUSED(tls))
 {
   ObstaclesFromDMData *data = userdata;
-  EmissionMap *om = data->om;
+  FluidObjectBB *bb = data->bb;
 
   for (int x = data->min[0]; x < data->max[0]; x++) {
     for (int y = data->min[1]; y < data->max[1]; y++) {
       const int index = manta_get_index(
-          x - om->min[0], om->res[0], y - om->min[1], om->res[1], z - om->min[2]);
+          x - bb->min[0], bb->res[0], y - bb->min[1], bb->res[1], z - bb->min[2]);
       float ray_start[3] = {(float)x + 0.5f, (float)y + 0.5f, (float)z + 0.5f};
 
-      /* Calculate object velocities. Result in om->velocity. */
+      /* Calculate object velocities. Result in bb->velocity. */
       sample_effector(data->mes,
                       data->mvert,
                       data->mloop

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list