[Bf-blender-cvs] [f2f8c5b2bd9] master: Cleanup: Move Multiplane Scrape brush to its own file

Pablo Dobarro noreply at git.blender.org
Fri Mar 6 16:01:33 CET 2020


Commit: f2f8c5b2bd984f1034f4ba9999bdc5d3fe72d45a
Author: Pablo Dobarro
Date:   Fri Mar 6 16:00:33 2020 +0100
Branches: master
https://developer.blender.org/rBf2f8c5b2bd984f1034f4ba9999bdc5d3fe72d45a

Cleanup: Move Multiplane Scrape brush to its own file

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

M	source/blender/editors/sculpt_paint/CMakeLists.txt
M	source/blender/editors/sculpt_paint/paint_cursor.c
M	source/blender/editors/sculpt_paint/sculpt.c
M	source/blender/editors/sculpt_paint/sculpt_intern.h
A	source/blender/editors/sculpt_paint/sculpt_multiplane_scrape.c

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

diff --git a/source/blender/editors/sculpt_paint/CMakeLists.txt b/source/blender/editors/sculpt_paint/CMakeLists.txt
index 1f568250f3f..f497b80e0f4 100644
--- a/source/blender/editors/sculpt_paint/CMakeLists.txt
+++ b/source/blender/editors/sculpt_paint/CMakeLists.txt
@@ -59,6 +59,7 @@ set(SRC
   paint_vertex_weight_ops.c
   paint_vertex_weight_utils.c
   sculpt.c
+  sculpt_multiplane_scrape.c
   sculpt_cloth.c
   sculpt_pose.c
   sculpt_undo.c
diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c
index 963fc556827..07dfa970404 100644
--- a/source/blender/editors/sculpt_paint/paint_cursor.c
+++ b/source/blender/editors/sculpt_paint/paint_cursor.c
@@ -1223,70 +1223,6 @@ static void sculpt_geometry_preview_lines_draw(const uint gpuattr, SculptSession
   }
 }
 
-static void sculpt_multiplane_scrape_preview_draw(const uint gpuattr,
-                                                  SculptSession *ss,
-                                                  const float outline_col[3],
-                                                  const float outline_alpha)
-{
-  float local_mat_inv[4][4];
-  invert_m4_m4(local_mat_inv, ss->cache->stroke_local_mat);
-  GPU_matrix_mul(local_mat_inv);
-  float angle = ss->cache->multiplane_scrape_angle;
-  if (ss->cache->pen_flip || ss->cache->invert) {
-    angle = -angle;
-  }
-
-  float offset = ss->cache->radius * 0.25f;
-
-  float p[3] = {0.0f, 0.0f, ss->cache->radius};
-  float y_axis[3] = {0.0f, 1.0f, 0.0f};
-  float p_l[3];
-  float p_r[3];
-  float area_center[3] = {0.0f, 0.0f, 0.0f};
-  rotate_v3_v3v3fl(p_r, p, y_axis, DEG2RADF((angle + 180) * 0.5f));
-  rotate_v3_v3v3fl(p_l, p, y_axis, DEG2RADF(-(angle + 180) * 0.5f));
-
-  immBegin(GPU_PRIM_LINES, 14);
-  immVertex3f(gpuattr, area_center[0], area_center[1] + offset, area_center[2]);
-  immVertex3f(gpuattr, p_r[0], p_r[1] + offset, p_r[2]);
-  immVertex3f(gpuattr, area_center[0], area_center[1] + offset, area_center[2]);
-  immVertex3f(gpuattr, p_l[0], p_l[1] + offset, p_l[2]);
-
-  immVertex3f(gpuattr, area_center[0], area_center[1] - offset, area_center[2]);
-  immVertex3f(gpuattr, p_r[0], p_r[1] - offset, p_r[2]);
-  immVertex3f(gpuattr, area_center[0], area_center[1] - offset, area_center[2]);
-  immVertex3f(gpuattr, p_l[0], p_l[1] - offset, p_l[2]);
-
-  immVertex3f(gpuattr, area_center[0], area_center[1] - offset, area_center[2]);
-  immVertex3f(gpuattr, area_center[0], area_center[1] + offset, area_center[2]);
-
-  immVertex3f(gpuattr, p_r[0], p_r[1] - offset, p_r[2]);
-  immVertex3f(gpuattr, p_r[0], p_r[1] + offset, p_r[2]);
-
-  immVertex3f(gpuattr, p_l[0], p_l[1] - offset, p_l[2]);
-  immVertex3f(gpuattr, p_l[0], p_l[1] + offset, p_l[2]);
-
-  immEnd();
-
-  immUniformColor3fvAlpha(outline_col, outline_alpha * 0.1f);
-  immBegin(GPU_PRIM_TRIS, 12);
-  immVertex3f(gpuattr, area_center[0], area_center[1] + offset, area_center[2]);
-  immVertex3f(gpuattr, p_r[0], p_r[1] + offset, p_r[2]);
-  immVertex3f(gpuattr, p_r[0], p_r[1] - offset, p_r[2]);
-  immVertex3f(gpuattr, area_center[0], area_center[1] + offset, area_center[2]);
-  immVertex3f(gpuattr, area_center[0], area_center[1] - offset, area_center[2]);
-  immVertex3f(gpuattr, p_r[0], p_r[1] - offset, p_r[2]);
-
-  immVertex3f(gpuattr, area_center[0], area_center[1] + offset, area_center[2]);
-  immVertex3f(gpuattr, p_l[0], p_l[1] + offset, p_l[2]);
-  immVertex3f(gpuattr, p_l[0], p_l[1] - offset, p_l[2]);
-  immVertex3f(gpuattr, area_center[0], area_center[1] + offset, area_center[2]);
-  immVertex3f(gpuattr, area_center[0], area_center[1] - offset, area_center[2]);
-  immVertex3f(gpuattr, p_l[0], p_l[1] - offset, p_l[2]);
-
-  immEnd();
-}
-
 static bool paint_use_2d_cursor(ePaintMode mode)
 {
   if (mode >= PAINT_MODE_TEXTURE_3D) {
@@ -1629,7 +1565,7 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
                                       NULL);
             GPU_matrix_push();
             GPU_matrix_mul(vc.obact->obmat);
-            sculpt_multiplane_scrape_preview_draw(pos, ss, outline_col, outline_alpha);
+            SCULPT_multiplane_scrape_preview_draw(pos, ss, outline_col, outline_alpha);
             GPU_matrix_pop();
             GPU_matrix_pop_projection();
           }
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index dcbcdc98ddf..3f60d96b7ce 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -1897,7 +1897,7 @@ static void calc_area_center(
   }
 }
 
-static void calc_area_normal(
+void SCULPT_calc_area_normal(
     Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode, float r_area_no[3])
 {
   const Brush *brush = BKE_paint_brush(&sd->paint);
@@ -2413,7 +2413,7 @@ static void calc_sculpt_normal(
       break;
 
     case SCULPT_DISP_DIR_AREA:
-      calc_area_normal(sd, ob, nodes, totnode, r_area_no);
+      SCULPT_calc_area_normal(sd, ob, nodes, totnode, r_area_no);
       break;
 
     default:
@@ -4690,7 +4690,7 @@ static void do_inflate_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totno
   BKE_pbvh_parallel_range(0, totnode, &data, do_inflate_brush_task_cb_ex, &settings);
 }
 
-static int plane_trim(const StrokeCache *cache, const Brush *brush, const float val[3])
+int SCULPT_plane_trim(const StrokeCache *cache, const Brush *brush, const float val[3])
 {
   return (!(brush->flag & BRUSH_PLANE_TRIM) ||
           ((dot_v3v3(val, val) <= cache->radius_squared * cache->plane_trim_squared)));
@@ -4705,13 +4705,13 @@ static bool plane_point_side_flip(const float co[3], const float plane[4], const
   return d <= 0.0f;
 }
 
-static int plane_point_side(const float co[3], const float plane[4])
+int SCULPT_plane_point_side(const float co[3], const float plane[4])
 {
   float d = plane_point_side_v3(plane, co);
   return d <= 0.0f;
 }
 
-static float get_offset(Sculpt *sd, SculptSession *ss)
+float SCULPT_brush_plane_offset_get(Sculpt *sd, SculptSession *ss)
 {
   Brush *brush = BKE_paint_brush(&sd->paint);
 
@@ -4756,7 +4756,7 @@ static void do_flatten_brush_task_cb_ex(void *__restrict userdata,
 
       sub_v3_v3v3(val, intr, vd.co);
 
-      if (plane_trim(ss->cache, brush, val)) {
+      if (SCULPT_plane_trim(ss->cache, brush, val)) {
         const float fade = bstrength * SCULPT_brush_strength_factor(ss,
                                                                     brush,
                                                                     vd.co,
@@ -4788,7 +4788,7 @@ static void do_flatten_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totno
   float area_no[3];
   float area_co[3];
 
-  float offset = get_offset(sd, ss);
+  float offset = SCULPT_brush_plane_offset_get(sd, ss);
   float displace;
   float temp[3];
 
@@ -4944,7 +4944,7 @@ static void do_clay_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
   const float initial_radius = fabsf(ss->cache->initial_radius);
   bool flip = ss->cache->bstrength < 0.0f;
 
-  float offset = get_offset(sd, ss);
+  float offset = SCULPT_brush_plane_offset_get(sd, ss);
   float displace;
 
   float area_no[3];
@@ -5001,349 +5001,6 @@ static void do_clay_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
   BKE_pbvh_parallel_range(0, totnode, &data, do_clay_brush_task_cb_ex, &settings);
 }
 
-/* -------------------------------------------------------------------- */
-
-/** \name Sculpt Multiplane Scrape Brush
- * \{ */
-
-typedef struct MultiplaneScrapeSampleData {
-  float area_cos[2][3];
-  float area_nos[2][3];
-  int area_count[2];
-} MultiplaneScrapeSampleData;
-
-static void calc_multiplane_scrape_surface_task_cb(void *__restrict userdata,
-                                                   const int n,
-                                                   const TaskParallelTLS *__restrict tls)
-{
-  SculptThreadedTaskData *data = userdata;
-  SculptSession *ss = data->ob->sculpt;
-  const Brush *brush = data->brush;
-  MultiplaneScrapeSampleData *mssd = tls->userdata_chunk;
-  float(*mat)[4] = data->mat;
-
-  PBVHVertexIter vd;
-
-  SculptBrushTest test;
-  SculptBrushTestFn sculpt_brush_test_sq_fn = SCULPT_brush_test_init_with_falloff_shape(
-      ss, &test, brush->falloff_shape);
-
-  /* Apply the brush normal radius to the test before sampling. */
-  float test_radius = sqrtf(test.radius_squared);
-  test_radius *= brush->normal_radius_factor;
-  test.radius_squared = test_radius * test_radius;
-
-  BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE)
-  {
-
-    if (sculpt_brush_test_sq_fn(&test, vd.co)) {
-      float local_co[3];
-      float normal[3];
-      if (vd.no) {
-        normal_short_to_float_v3(normal, vd.no);
-      }
-      else {
-        copy_v3_v3(normal, vd.fno);
-      }
-      mul_v3_m4v3(local_co, mat, vd.co);
-      /* Use the brush falloff to weight the sampled normals. */
-      const float fade = SCULPT_brush_strength_factor(ss,
-                                                      brush,
-                                                      vd.co,
-                                                      sqrtf(test.dist),
-                                                      vd.no,
-                                                      vd.fno,
-                                                      vd.mask ? *vd.mask : 0.0f,
-                                                      vd.index,
-                                                      tls->thread_id);
-
-      /* Sample the normal and area of the +X and -X axis individually. */
-      if (local_co[0] > 0.0f) {
-        madd_v3_v3fl(mssd->area_nos[0], normal, fade);
-        add_v3_v3(mssd->area_cos[0], vd.co);
-        mssd->area_count[0]++;
-      }
-      else {
-        madd_v3_v3fl(mssd->area_nos[1], normal, fade);
-        add_v3_v3(mssd->area_cos[1], vd.co);
-        mssd->area_count[1]++;
-      }
-    }
-    BKE_pbvh_vertex_iter_end;
-  }
-}
-
-static void calc_multiplane_scrape_surface_reduce(const void *__restrict UNUSED(userdata),
-                                                  void *__restrict chunk_join,
-                                                  void 

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list