[Bf-blender-cvs] [c04c5ac4f6e] master: Fix T73947: Support radial symmetry in Multiplane Scrape

Pablo Dobarro noreply at git.blender.org
Sun Mar 1 19:30:19 CET 2020


Commit: c04c5ac4f6ea59173c86d0b99be84d28571a4a00
Author: Pablo Dobarro
Date:   Sun Mar 1 19:12:30 2020 +0100
Branches: master
https://developer.blender.org/rBc04c5ac4f6ea59173c86d0b99be84d28571a4a00

Fix T73947: Support radial symmetry in Multiplane Scrape

This includes the following changes:
- Use always the angle stored in the StrokeCache when deforming
- Interpolate between the previous and the new sampled angles
- Calculate the cursor matrix only on the 0 radial symmetry iteration

Reviewed By: brecht

Maniphest Tasks: T73947

Differential Revision: https://developer.blender.org/D6901

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

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

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

diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c
index cabf17e8534..ff26b347035 100644
--- a/source/blender/editors/sculpt_paint/paint_cursor.c
+++ b/source/blender/editors/sculpt_paint/paint_cursor.c
@@ -1231,7 +1231,7 @@ static void sculpt_multiplane_scrape_preview_draw(const uint gpuattr,
   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_sampled_angle;
+  float angle = ss->cache->multiplane_scrape_angle;
   if (ss->cache->pen_flip || ss->cache->invert) {
     angle = -angle;
   }
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 9a01be9d7b3..06aa3f22de0 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -5510,6 +5510,7 @@ static void do_multiplane_scrape_brush(Sculpt *sd, Object *ob, PBVHNode **nodes,
 
   /* Delay the first daub because grab delta is not setup. */
   if (ss->cache->first_time) {
+    ss->cache->multiplane_scrape_angle = 0.0f;
     return;
   }
 
@@ -5533,10 +5534,8 @@ static void do_multiplane_scrape_brush(Sculpt *sd, Object *ob, PBVHNode **nodes,
   normalize_m4(mat);
   invert_m4(mat);
 
-  float angle = brush->multiplane_scrape_angle;
-
   /* Update matrix for the cursor preview. */
-  if (ss->cache->mirror_symmetry_pass == 0) {
+  if (ss->cache->mirror_symmetry_pass == 0 && ss->cache->radial_symmetry_pass == 0) {
     copy_m4_m4(ss->cache->stroke_local_mat, mat);
   }
 
@@ -5593,8 +5592,8 @@ static void do_multiplane_scrape_brush(Sculpt *sd, Object *ob, PBVHNode **nodes,
       sampled_angle = -sampled_angle;
     }
 
-    /* In dynamic mode, set the angle to 0 when inverting the brush, so you can trim plane surfaces
-     * without changing the brush. */
+    /* In dynamic mode, set the angle to 0 when inverting the brush, so you can trim plane
+     * surfaces without changing the brush. */
     if (flip) {
       sampled_angle = 0.0f;
     }
@@ -5602,27 +5601,28 @@ static void do_multiplane_scrape_brush(Sculpt *sd, Object *ob, PBVHNode **nodes,
       copy_v3_v3(area_co, ss->cache->location);
     }
 
-    angle = RAD2DEGF(sampled_angle);
+    /* Interpolate between the previous and new sampled angles to avoid artifacts when if angle
+     * difference between two samples is too big. */
+    ss->cache->multiplane_scrape_angle = interpf(
+        RAD2DEGF(sampled_angle), ss->cache->multiplane_scrape_angle, 0.2f);
   }
   else {
 
     /* Standard mode: Scrape with the brush property fixed angle. */
     copy_v3_v3(area_co, ss->cache->location);
+    ss->cache->multiplane_scrape_angle = brush->multiplane_scrape_angle;
     if (flip) {
-      angle = -angle;
+      ss->cache->multiplane_scrape_angle *= -1.0f;
     }
   }
 
-  /* Set the angle for the cursor preview. */
-  ss->cache->multiplane_scrape_sampled_angle = angle;
-
   SculptThreadedTaskData data = {
       .sd = sd,
       .ob = ob,
       .brush = brush,
       .nodes = nodes,
       .mat = mat,
-      .multiplane_scrape_angle = angle,
+      .multiplane_scrape_angle = ss->cache->multiplane_scrape_angle,
   };
 
   /* Calculate the final left and right scrape planes. */
@@ -5633,13 +5633,15 @@ static void do_multiplane_scrape_brush(Sculpt *sd, Object *ob, PBVHNode **nodes,
   invert_m4_m4(mat_inv, mat);
 
   mul_v3_mat3_m4v3(plane_no, mat, area_no);
-  rotate_v3_v3v3fl(plane_no_rot, plane_no, y_axis, DEG2RADF(-angle * 0.5f));
+  rotate_v3_v3v3fl(
+      plane_no_rot, plane_no, y_axis, DEG2RADF(-ss->cache->multiplane_scrape_angle * 0.5f));
   mul_v3_mat3_m4v3(plane_no, mat_inv, plane_no_rot);
   normalize_v3(plane_no);
   plane_from_point_normal_v3(data.multiplane_scrape_planes[1], area_co, plane_no);
 
   mul_v3_mat3_m4v3(plane_no, mat, area_no);
-  rotate_v3_v3v3fl(plane_no_rot, plane_no, y_axis, DEG2RADF(angle * 0.5f));
+  rotate_v3_v3v3fl(
+      plane_no_rot, plane_no, y_axis, DEG2RADF(ss->cache->multiplane_scrape_angle * 0.5f));
   mul_v3_mat3_m4v3(plane_no, mat_inv, plane_no_rot);
   normalize_v3(plane_no);
   plane_from_point_normal_v3(data.multiplane_scrape_planes[0], area_co, plane_no);
diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h
index c67096c2dff..d9905f74be8 100644
--- a/source/blender/editors/sculpt_paint/sculpt_intern.h
+++ b/source/blender/editors/sculpt_paint/sculpt_intern.h
@@ -521,7 +521,7 @@ typedef struct StrokeCache {
   float *automask;
 
   float stroke_local_mat[4][4];
-  float multiplane_scrape_sampled_angle;
+  float multiplane_scrape_angle;
 
   rcti previous_r; /* previous redraw rectangle */
   rcti current_r;  /* current redraw rectangle */



More information about the Bf-blender-cvs mailing list