Commit: 0fac021c2165ef4b7bf975bfbe7f41f9583276e0
Author: Nathan Vollmer
Date:   Tue Sep 13 17:47:09 2016 -0600
Branches: soc-2016-pbvh-painting
https://developer.blender.org/rB0fac021c2165ef4b7bf975bfbe7f41f9583276e0

Refactoring

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

M       release/scripts/startup/bl_ui/space_view3d_toolbar.py
M       source/blender/blenkernel/BKE_paint.h
M       source/blender/blenkernel/intern/paint.c
M       source/blender/blenlib/BLI_math_base.h
M       source/blender/blenlib/intern/math_base_inline.c
M       source/blender/blenloader/intern/versioning_defaults.c
M       source/blender/editors/sculpt_paint/paint_vertex.c

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

diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py 
b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index ee9b7e5..7df4d59 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -1702,7 +1702,6 @@ class VIEW3D_PT_tools_brush_appearance(Panel, 
View3DPaintPanel):
 class VIEW3D_PT_tools_weightpaint(View3DPanel, Panel):
     bl_category = "Tools"
     bl_context = "weightpaint"
-    bl_options = {'DEFAULT_CLOSED'}
     bl_label = "Weight Tools"
 
     def draw(self, context):
diff --git a/source/blender/blenkernel/BKE_paint.h 
b/source/blender/blenkernel/BKE_paint.h
index eb47cd8..9be9f64 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -204,16 +204,16 @@ typedef struct SculptSession {
        struct SculptStroke *stroke;
        struct StrokeCache *cache;
 
-       int *map_mem;
-       MeshElemMap* vert_to_loop;
+       int *vert_map_mem;
+       MeshElemMap *vert_to_loop;
        int *poly_map_mem;
-       MeshElemMap* vert_to_poly;
+       MeshElemMap *vert_to_poly;
 
-       unsigned long* totalColor;
-       double* totalWeight;
-       unsigned int *totloopsHit;
-       float *maxWeight;
-       unsigned int *previousColor;
+       unsigned int *total_color;
+       double *total_weight;
+       unsigned int *tot_loops_hit;
+       float *max_weight;
+       unsigned int *previous_color;
 } SculptSession;
 
 void BKE_sculptsession_free(struct Object *ob);
diff --git a/source/blender/blenkernel/intern/paint.c 
b/source/blender/blenkernel/intern/paint.c
index 734d2bf..08a4308 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -750,26 +750,24 @@ void BKE_sculptsession_free(Object *ob)
                /* Free maps */
                if (ss->vert_to_loop)
                        MEM_freeN(ss->vert_to_loop);
-               if (ss->map_mem)
-                       MEM_freeN(ss->map_mem);
+               if (ss->vert_map_mem)
+                       MEM_freeN(ss->vert_map_mem);
                if (ss->vert_to_poly)
                        MEM_freeN(ss->vert_to_poly);
                if (ss->poly_map_mem)
                        MEM_freeN(ss->poly_map_mem);
 
-               /* Free average brush arrays */
-               if (ob->sculpt->totloopsHit)
-                       MEM_freeN(ob->sculpt->totloopsHit);
-
-               if (ob->sculpt->totalColor)
-                       MEM_freeN(ob->sculpt->totalColor);
-
-               MEM_freeN(ob->sculpt->totalWeight);
-
-               if (ob->sculpt->maxWeight)
-                       MEM_freeN(ob->sculpt->maxWeight);
-               if (ob->sculpt->previousColor)
-                       MEM_freeN(ob->sculpt->previousColor);
+               /* Free average, blur, and spray brush arrays */
+               if (ob->sculpt->tot_loops_hit)
+                       MEM_freeN(ob->sculpt->tot_loops_hit);
+               if (ob->sculpt->total_color)
+                       MEM_freeN(ob->sculpt->total_color);
+               if (ob->sculpt->total_weight)
+                 MEM_freeN(ob->sculpt->total_weight);
+               if (ob->sculpt->max_weight)
+                       MEM_freeN(ob->sculpt->max_weight);
+               if (ob->sculpt->previous_color)
+                       MEM_freeN(ob->sculpt->previous_color);
 
                MEM_freeN(ss);
 
diff --git a/source/blender/blenlib/BLI_math_base.h 
b/source/blender/blenlib/BLI_math_base.h
index 5751aee..e97a250 100644
--- a/source/blender/blenlib/BLI_math_base.h
+++ b/source/blender/blenlib/BLI_math_base.h
@@ -205,7 +205,6 @@ MINLINE unsigned int power_of_2_min_u(unsigned int x);
 
 MINLINE int iroundf(float a);
 MINLINE int divide_round_i(int a, int b);
-MINLINE unsigned long divide_round_ul(unsigned long a, unsigned long b);
 MINLINE int mod_i(int i, int n);
 
 int pow_i(int base, int exp);
diff --git a/source/blender/blenlib/intern/math_base_inline.c 
b/source/blender/blenlib/intern/math_base_inline.c
index e7362ed..8d2d80c 100644
--- a/source/blender/blenlib/intern/math_base_inline.c
+++ b/source/blender/blenlib/intern/math_base_inline.c
@@ -193,11 +193,6 @@ MINLINE int divide_round_i(int a, int b)
        return (2 * a + b) / (2 * b);
 }
 
-MINLINE unsigned long divide_round_ul(unsigned long a, unsigned long b)
-{
-  return (2 * a + b) / (2 * b);
-}
-
 /**
  * modulo that handles negative numbers, works the same as Python's.
  */
diff --git a/source/blender/blenloader/intern/versioning_defaults.c 
b/source/blender/blenloader/intern/versioning_defaults.c
index 8ca5dbe..46e5038 100644
--- a/source/blender/blenloader/intern/versioning_defaults.c
+++ b/source/blender/blenloader/intern/versioning_defaults.c
@@ -94,14 +94,12 @@ void BLO_update_defaults_startup_blend(Main *bmain)
                                sculpt->detail_size = 12;
                        }
                        
-                       if (ts->vpaint)
-                       {
+                       if (ts->vpaint) {
                                VPaint *vp = ts->vpaint;
                                vp->radial_symm[0] = vp->radial_symm[1] = 
vp->radial_symm[2] = 1;
                        }
 
-                       if (ts->wpaint)
-                       {
+                       if (ts->wpaint) {
                                VPaint *wp = ts->wpaint;
                                wp->radial_symm[0] = wp->radial_symm[1] = 
wp->radial_symm[2] = 1;
                        }
diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c 
b/source/blender/editors/sculpt_paint/paint_vertex.c
index c2ce7be..0945b59 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex.c
@@ -1728,11 +1728,11 @@ static void vertex_paint_init_session(Scene *scene, 
Object *ob)
 static void vertex_paint_init_session_maps(Object *ob) {
        /* Create maps */
        Mesh *me = ob->data;
-       ob->sculpt->map_mem = NULL;
+       ob->sculpt->vert_map_mem = NULL;
        ob->sculpt->vert_to_loop = NULL;
        ob->sculpt->poly_map_mem = NULL;
        ob->sculpt->vert_to_poly = NULL;
-       BKE_mesh_vert_loop_map_create(&ob->sculpt->vert_to_loop, 
&ob->sculpt->map_mem, me->mpoly, me->mloop, me->totvert, me->totpoly, 
me->totloop);
+       BKE_mesh_vert_loop_map_create(&ob->sculpt->vert_to_loop, 
&ob->sculpt->vert_map_mem, me->mpoly, me->mloop, me->totvert, me->totpoly, 
me->totloop);
        BKE_mesh_vert_poly_map_create(&ob->sculpt->vert_to_poly, 
&ob->sculpt->poly_map_mem, me->mpoly, me->mloop, me->totvert, me->totpoly, 
me->totloop);
 }
 
@@ -1744,11 +1744,11 @@ static void 
vertex_paint_init_session_average_arrays(Object *ob){
        Mesh *me = BKE_mesh_from_object(ob);
 
        //Need unsigned long to prevent overflow when averaging multiple 
whites, which take up an entire unsigned int each.
-       ob->sculpt->totalColor = MEM_callocN(totNode * 3 * sizeof(unsigned 
long), "totalColor");
-       ob->sculpt->totalWeight = MEM_callocN(totNode * sizeof(double), 
"totalWeight");
-       ob->sculpt->totloopsHit = MEM_callocN(totNode * sizeof(unsigned int), 
"totloopsHit");
-  ob->sculpt->maxWeight = MEM_callocN(me->totvert * sizeof(float), 
"maxWeight");
-  ob->sculpt->previousColor = MEM_callocN(me->totloop * sizeof(unsigned int), 
"previousColor");
+       ob->sculpt->total_color = MEM_callocN(totNode * 3 * sizeof(unsigned 
int), "total_color");
+       ob->sculpt->total_weight = MEM_callocN(totNode * sizeof(double), 
"total_weight");
+       ob->sculpt->tot_loops_hit = MEM_callocN(totNode * sizeof(unsigned int), 
"tot_loops_hit");
+       ob->sculpt->max_weight = MEM_callocN(me->totvert * sizeof(float), 
"max_weight");
+       ob->sculpt->previous_color = MEM_callocN(me->totloop * sizeof(unsigned 
int), "previous_color");
 }
 
 /* *************** set wpaint operator ****************** */
@@ -2184,13 +2184,13 @@ static bool wpaint_stroke_test_start(bContext *C, 
wmOperator *op, const float mo
        if (!ob->sculpt->vert_to_loop)
                vertex_paint_init_session_maps(ob);
 
-       if (!ob->sculpt->totloopsHit)
+       if (!ob->sculpt->tot_loops_hit)
                vertex_paint_init_session_average_arrays(ob);
 
        vwpaint_update_cache_invariants(C, vd, ss, op, mouse);
 
-  for (int i = 0; i < me->totvert; ++i)
-    ss->maxWeight[i] = -1.0;
+       for (int i = 0; i < me->totvert; ++i)
+               ss->max_weight[i] = -1.0;
 
        return true;
 }
@@ -2329,7 +2329,7 @@ static void calc_area_normal(
 static float dot_vf3vs3(const float brushNormal[3], const short 
vertexNormal[3]){
        float normal[3];
        normal_short_to_float_v3(normal, vertexNormal);
-       return dot_v3v3(brushNormal, normal);;
+       return dot_v3v3(brushNormal, normal);
 }
 
 /* Flip all the editdata across the axis/axes specified by symm. Used to
@@ -2377,7 +2377,7 @@ static void do_wpaint_brush_blur_task_cb_ex(
   StrokeCache *cache = ss->cache;
   const float bstrength = cache->bstrength;
 
-  int totalHitLoops;
+  int total_hit_loops;
   double finalColor;
 
   //for each vertex
@@ -2393,14 +2393,14 @@ static void do_wpaint_brush_blur_task_cb_ex(
       const int vertexIndex = vd.vert_indices[vd.i];
 
       //Get the average poly color
-      totalHitLoops = 0;
+      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];
 
-        totalHitLoops += poly.totloop;
+        total_hit_loops += poly.totloop;
         for (int k = 0; k < poly.totloop; ++k) {
           int loopIndex = poly.loopstart + k;
           MLoop loop = data->me->mloop[loopIndex];
@@ -2409,11 +2409,11 @@ static void do_wpaint_brush_blur_task_cb_ex(
           finalColor += dw->weight;
         }
       }
-      if (totalHitLoops != 0) {
+      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 /= totalHitLoops;
+        finalColor /= total_hit_loops;
         if (dot > 0.0) {
           do_weight_paint_vertex(data->vp, data->ob, data->wpi, vertexIndex, 
dot * fade * bstrength, (float)finalColor);
         }
@@ -2514,27 +2514,30 @@ static void do_wpaint_brush_draw_task_cb_ex(
       const int vertexIndex = vd.vert_indices[vd.i];
       const float dot = dot_vf3vs3(cache->sculpt_normal_symm, vd.no);
       const float fade = BKE_brush_curve_strength(brush, test.dist, 
cache->radius);
-      float actualStrength = bstrength * fade * dot;
+      const float brush_alpha_value = BKE_brush_alpha_get(scene, brush);
+      const float brush_alpha_pressure =
+             brush_alpha_value * (BKE_brush_use_alpha_pressure(scene, brush) ? 
ss->cache->pressure : 1.0f);
+      float actualStrength = bstrength * fade * dot * brush_alpha_pressure;
       float currentWeight;
 
       //Spray logic
       if (!(data->vp->flag & VP_SPRAY)) {
-        MDeformVert *dv = &data->me->dvert[vertexIndex];
-        MDeformWeight *dw;
-        dw = (data->vp->flag & VP_ONLYVGROUP) ? defvert_find_index(dv, 
data->wpi->active.index) :
-                                                defvert_verify_index(dv, 
data->wpi->active.index);
-        currentWeight = dw-

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to