Commit: b405a2e4c0ad7e1a852b533fef20f30bc29d5e57
Author: Bastien Montagne
Date:   Mon Nov 28 12:20:12 2016 +0100
Branches: soc-2016-pbvh-painting
https://developer.blender.org/rBb405a2e4c0ad7e1a852b533fef20f30bc29d5e57

Cleanup: get rid of unused functions and vars, and indentation fixes.

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

M       source/blender/editors/sculpt_paint/paint_vertex.c

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

diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c 
b/source/blender/editors/sculpt_paint/paint_vertex.c
index 3b32788..650783b 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex.c
@@ -178,11 +178,6 @@ static VPaint *new_vpaint(int wpaint)
        return vp;
 }
 
-static int *get_indexarray(Mesh *me)
-{
-       return MEM_mallocN(sizeof(int) * (me->totpoly + 1), "vertexpaint");
-}
-
 unsigned int vpaint_get_current_col(Scene *scene, VPaint *vp)
 {
        Brush *brush = BKE_paint_brush(&vp->paint);
@@ -296,15 +291,6 @@ static int wpaint_mirror_vgroup_ensure(Object *ob, const 
int vgroup_active)
        return -1;
 }
 
-static void free_vpaint_prev(VPaint *vp)
-{
-       if (vp->vpaint_prev) {
-               MEM_freeN(vp->vpaint_prev);
-               vp->vpaint_prev = NULL;
-               vp->tot = 0;
-       }
-}
-
 static void free_wpaint_prev(VPaint *vp)
 {
        if (vp->wpaint_prev) {
@@ -314,19 +300,6 @@ static void free_wpaint_prev(VPaint *vp)
        }
 }
 
-static void copy_vpaint_prev(VPaint *vp, unsigned int *lcol, int tot)
-{
-       free_vpaint_prev(vp);
-
-       vp->tot = tot;
-       
-       if (lcol == NULL || tot == 0) return;
-       
-       vp->vpaint_prev = MEM_mallocN(sizeof(int) * tot, "vpaint_prev");
-       memcpy(vp->vpaint_prev, lcol, sizeof(int) * tot);
-       
-}
-
 static void copy_wpaint_prev(VPaint *wp, MDeformVert *dverts, int dcount)
 {
        free_wpaint_prev(wp);
@@ -828,46 +801,6 @@ static unsigned int vpaint_blend(VPaint *vp, unsigned int 
col, unsigned int colo
 }
 
 
-static int UNUSED_FUNCTION(sample_backbuf_area)(ViewContext *vc, int *indexar, 
int totpoly, int x, int y, float size)
-{
-       struct ImBuf *ibuf;
-       int a, tot = 0, index;
-       
-       /* brecht: disabled this because it obviously fails for
-        * brushes with size > 64, why is this here? */
-       /*if (size > 64.0) size = 64.0;*/
-       
-       ibuf = ED_view3d_backbuf_read(vc, x - size, y - size, x + size, y + 
size);
-       if (ibuf) {
-               unsigned int *rt = ibuf->rect;
-
-               memset(indexar, 0, sizeof(int) * (totpoly + 1));
-               
-               size = ibuf->x * ibuf->y;
-               while (size--) {
-                               
-                       if (*rt) {
-                               index = *rt;
-                               if (index > 0 && index <= totpoly) {
-                                       indexar[index] = 1;
-                               }
-                       }
-               
-                       rt++;
-               }
-               
-               for (a = 1; a <= totpoly; a++) {
-                       if (indexar[a]) {
-                               indexar[tot++] = a;
-                       }
-               }
-
-               IMB_freeImBuf(ibuf);
-       }
-       
-       return tot;
-}
-
 /* whats _dl mean? */
 static float calc_vp_strength_col_dl(VPaint *vp, ViewContext *vc, const float 
co[3],
                                  const float mval[2], const float 
brush_size_pressure, float rgba[4])
@@ -2197,39 +2130,6 @@ static bool wpaint_stroke_test_start(bContext *C, 
wmOperator *op, const float mo
        return true;
 }
 
-static float UNUSED_FUNCTION(wpaint_blur_weight_single)(const MDeformVert *dv, 
const WeightPaintInfo *wpi)
-{
-       return defvert_find_weight(dv, wpi->active.index);
-}
-
-static float UNUSED_FUNCTION(wpaint_blur_weight_multi)(const MDeformVert *dv, 
const WeightPaintInfo *wpi)
-{
-       float weight = BKE_defvert_multipaint_collective_weight(
-               dv, wpi->defbase_tot, wpi->defbase_sel, wpi->defbase_tot_sel, 
wpi->do_auto_normalize);
-       CLAMP(weight, 0.0f, 1.0f);
-       return weight;
-}
-
-static float UNUSED_FUNCTION(wpaint_blur_weight_calc_from_connected)(
-        const MDeformVert *dvert, WeightPaintInfo *wpi, struct WPaintData 
*wpd, const unsigned int vidx,
-        float (*blur_weight_func)(const MDeformVert *, const WeightPaintInfo 
*))
-{
-       const MeshElemMap *map = &wpd->blur_data.vmap[vidx];
-       float paintweight;
-       if (map->count != 0) {
-               paintweight = 0.0f;
-               for (int j = 0; j < map->count; j++) {
-                       paintweight += 
blur_weight_func(&dvert[map->indices[j]], wpi);
-               }
-               paintweight /= map->count;
-       }
-       else {
-               paintweight = blur_weight_func(&dvert[vidx], wpi);
-       }
-
-       return paintweight;
-}
-
 static void calc_area_normal_and_center_task_cb(void *userdata, const int n)
 {
        SculptThreadedTaskData *data = userdata;
@@ -2370,229 +2270,228 @@ static void calc_brushdata_symm(VPaint *vd, 
StrokeCache *cache, const char symm,
 }
 
 static void do_wpaint_brush_blur_task_cb_ex(
-  void *userdata, void *UNUSED(userdata_chunk), const int n, const int 
UNUSED(thread_id))
+        void *userdata, void *UNUSED(userdata_chunk), const int n, const int 
UNUSED(thread_id))
 {
-  SculptThreadedTaskData *data = userdata;
-  SculptSession *ss = data->ob->sculpt;
+       SculptThreadedTaskData *data = userdata;
+       SculptSession *ss = data->ob->sculpt;
 
-  Brush *brush = data->brush;
-  StrokeCache *cache = ss->cache;
-  const float bstrength = cache->bstrength;
+       Brush *brush = data->brush;
+       StrokeCache *cache = ss->cache;
+       const float bstrength = cache->bstrength;
 
-  int total_hit_loops;
-  double finalColor;
+       int total_hit_loops;
+       double finalColor;
 
-  //for each vertex
-  PBVHVertexIter vd;
+       //for each vertex
+       PBVHVertexIter vd;
 
-  BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE)
-  {
-    SculptBrushTest test;
-    sculpt_brush_test_init(ss, &test);
-
-    //Test to see if the vertex coordinates are within the spherical brush 
region.
-    if (sculpt_brush_test(&test, vd.co)) {
-      const int vertexIndex = vd.vert_indices[vd.i];
-
-      //Get the average poly color
-      total_hit_loops = 0;
-      finalColor = 0;
-
-      for (int j = 0; j < ss->vert_to_poly[vertexIndex].count; j++) {
-        int polyIndex = ss->vert_to_poly[vertexIndex].indices[j];
-        MPoly poly = data->me->mpoly[polyIndex];
-
-        total_hit_loops += poly.totloop;
-        for (int k = 0; k < poly.totloop; ++k) {
-          int loopIndex = poly.loopstart + k;
-          MLoop loop = data->me->mloop[loopIndex];
-          MDeformVert *dv = &data->me->dvert[loop.v];
-          MDeformWeight *dw = defvert_verify_index(dv, 
data->wpi->active.index);
-          finalColor += dw->weight;
-        }
-      }
-      if (total_hit_loops != 0) {
-        const float fade = BKE_brush_curve_strength(brush, test.dist, 
cache->radius);
-        const float dot = dot_vf3vs3(cache->sculpt_normal_symm, vd.no);
-
-        finalColor /= total_hit_loops;
-        if (dot > 0.0) {
-          do_weight_paint_vertex(data->vp, data->ob, data->wpi, vertexIndex, 
dot * fade * bstrength, (float)finalColor);
-        }
-      }
-    }
-    BKE_pbvh_vertex_iter_end;
-  }
+       BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, 
PBVH_ITER_UNIQUE)
+       {
+               SculptBrushTest test;
+               sculpt_brush_test_init(ss, &test);
+
+               //Test to see if the vertex coordinates are within the 
spherical brush region.
+               if (sculpt_brush_test(&test, vd.co)) {
+                       const int vertexIndex = vd.vert_indices[vd.i];
+
+                       //Get the average poly color
+                       total_hit_loops = 0;
+                       finalColor = 0;
+
+                       for (int j = 0; j < 
ss->vert_to_poly[vertexIndex].count; j++) {
+                               int polyIndex = 
ss->vert_to_poly[vertexIndex].indices[j];
+                               MPoly poly = data->me->mpoly[polyIndex];
+
+                               total_hit_loops += poly.totloop;
+                               for (int k = 0; k < poly.totloop; ++k) {
+                                       int loopIndex = poly.loopstart + k;
+                                       MLoop loop = data->me->mloop[loopIndex];
+                                       MDeformVert *dv = 
&data->me->dvert[loop.v];
+                                       MDeformWeight *dw = 
defvert_verify_index(dv, data->wpi->active.index);
+                                       finalColor += dw->weight;
+                               }
+                       }
+                       if (total_hit_loops != 0) {
+                               const float fade = 
BKE_brush_curve_strength(brush, test.dist, cache->radius);
+                               const float dot = 
dot_vf3vs3(cache->sculpt_normal_symm, vd.no);
+
+                               finalColor /= total_hit_loops;
+                               if (dot > 0.0) {
+                                       do_weight_paint_vertex(data->vp, 
data->ob, data->wpi, vertexIndex, dot * fade * bstrength, (float)finalColor);
+                               }
+                       }
+               }
+               BKE_pbvh_vertex_iter_end;
+       }
 }
 
 static void do_wpaint_brush_smudge_task_cb_ex(
-  void *userdata, void *UNUSED(userdata_chunk), const int n, const int 
UNUSED(thread_id))
+        void *userdata, void *UNUSED(userdata_chunk), const int n, const int 
UNUSED(thread_id))
 {
-  SculptThreadedTaskData *data = userdata;
-  SculptSession *ss = data->ob->sculpt;
-  Brush *brush = data->brush;
-  StrokeCache *cache = ss->cache;
-  const float bstrength = cache->bstrength;
-  bool shouldColor = false;
-  float finalWeight;
-  float brushDirection[3];
-  sub_v3_v3v3(brushDirection, cache->location, cache->last_location);
-  normalize_v3(brushDirection);
-
-  //If the position from the last update is initialized...
-  if (cache->is_last_valid) {
-    //for each vertex
-    PBVHVertexIter vd;
-    BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE)
-    {
-      SculptBrushTest test;
-      sculpt_brush_test_init(ss, &test);
-
-      //Test to see if the vertex coordinates are within the spherical brush 
region.
-      if (sculpt_brush_test(&test, vd.co)) {
-        const float dot = dot_vf3vs3(cache->sculpt_normal_symm, vd.no);
-        const int vertexIndex = vd.vert_indices[vd.i];
-        MVert *currentVert = &data->me->mvert[vertexIndex];
-
-        //Minimum dot product between brush direction and current to neighbor 
direction is 0.0, meaning orthogonal.
-        float maxDotProduct = 0.0f;
-
-        //Get the color of the loop in the opposite direction of the brush 
movement (this callback is specifically for smudge.)
-        finalWeight = 0;
-        for (int j = 0; j < ss->vert_to_poly[vertexIndex].count; j++) {
-          int polyIndex = ss->vert_to_poly[vertexIndex].indices[j];
-          MPoly *poly = &data->me->mpoly[polyIndex];
-          for (int k = 0; k < poly->totloop; k++) {
-            unsigned int loopIndex = poly->loopstart + k;
-            MLoop *loop = &data->me->mloop[loopIndex];
-            unsigned int neighborIndex = loop->v;
-            MVert *neighbor = &data->me->mvert[neighborIndex];
-
-            //Get the direction from the selected vert to the neighbor.
-            float toNeighbor[3];
-            sub_v3_v3v3(toNeighbor, currentVert->co, neighbor->co);
-            normalize_v3(toNeighbor);
-
-            float dotProduct = dot_v3v3(toNeighbor, brushDirection);
-
-            if (dotProduct > maxDotProduct) {
-              maxDotProduct = dotProduct;
-              MDeformVert *dv = &data->me->dvert[neighborIndex];
-              MDeformWeight *dw = defvert_verify_index(dv, 
data->wpi->active.index);
-              finalWeight = dw->weight;
-              shouldColor = tru

@@ Diff output truncated at 10240 characters. @@

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

Reply via email to