Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorPablo Dobarro <pablodp606>2020-03-01 21:12:30 +0300
committerPablo Dobarro <pablo@pop-os.localdomain>2020-03-01 21:29:10 +0300
commitc04c5ac4f6ea59173c86d0b99be84d28571a4a00 (patch)
tree8a9f314bf182d95b6a2864f399815ddfbb6f9f6f /source
parentf2557d137ae8a0f36764bac3ab61f7cc047eca72 (diff)
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
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/sculpt_paint/paint_cursor.c2
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c28
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_intern.h2
3 files changed, 17 insertions, 15 deletions
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 */