[Bf-blender-cvs] [3e5a354333a] master: Fix sculpt pen tilt support changing the brush strength
Pablo Dobarro
noreply at git.blender.org
Tue Oct 20 21:41:56 CEST 2020
Commit: 3e5a354333adcaaf095b24777fd0d52f4d4bb75d
Author: Pablo Dobarro
Date: Tue Oct 20 13:44:30 2020 +0200
Branches: master
https://developer.blender.org/rB3e5a354333adcaaf095b24777fd0d52f4d4bb75d
Fix sculpt pen tilt support changing the brush strength
SCULPT_tilt_apply_to_normal expects a normal, and offset was already
scaled by radius. The funcion returns a normalized vector, so the
strength of the brush was changed.
Reviewed By: sergey
Differential Revision: https://developer.blender.org/D9275
===================================================================
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/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 3ded57d938f..adc62b23559 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -2810,6 +2810,12 @@ void SCULPT_tilt_apply_to_normal(float r_normal[3], StrokeCache *cache, const fl
normalize_v3(r_normal);
}
+void SCULPT_tilt_effective_normal_get(const SculptSession *ss, const Brush *brush, float r_no[3])
+{
+ copy_v3_v3(r_no, ss->cache->sculpt_normal_symm);
+ SCULPT_tilt_apply_to_normal(r_no, ss->cache, brush->tilt_strength_factor);
+}
+
static void update_brush_local_mat(Sculpt *sd, Object *ob)
{
StrokeCache *cache = ob->sculpt->cache;
@@ -3119,8 +3125,9 @@ static void do_draw_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
const float bstrength = ss->cache->bstrength;
/* Offset with as much as possible factored in already. */
- mul_v3_v3fl(offset, ss->cache->sculpt_normal_symm, ss->cache->radius);
- SCULPT_tilt_apply_to_normal(offset, ss->cache, brush->tilt_strength_factor);
+ float effective_normal[3];
+ SCULPT_tilt_effective_normal_get(ss, brush, effective_normal);
+ mul_v3_v3fl(offset, effective_normal, ss->cache->radius);
mul_v3_v3(offset, ss->cache->scale);
mul_v3_fl(offset, bstrength);
@@ -3197,8 +3204,9 @@ static void do_draw_sharp_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int to
const float bstrength = ss->cache->bstrength;
/* Offset with as much as possible factored in already. */
- mul_v3_v3fl(offset, ss->cache->sculpt_normal_symm, ss->cache->radius);
- SCULPT_tilt_apply_to_normal(offset, ss->cache, brush->tilt_strength_factor);
+ float effective_normal[3];
+ SCULPT_tilt_effective_normal_get(ss, brush, effective_normal);
+ mul_v3_v3fl(offset, effective_normal, ss->cache->radius);
mul_v3_v3(offset, ss->cache->scale);
mul_v3_fl(offset, bstrength);
diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h
index 4216f23bea4..6313c934774 100644
--- a/source/blender/editors/sculpt_paint/sculpt_intern.h
+++ b/source/blender/editors/sculpt_paint/sculpt_intern.h
@@ -814,6 +814,9 @@ void SCULPT_tilt_apply_to_normal(float r_normal[3],
struct StrokeCache *cache,
const float tilt_strength);
+/* Get effective surface normal with pen tilt and tilt strength applied to it. */
+void SCULPT_tilt_effective_normal_get(const SculptSession *ss, const Brush *brush, float r_no[3]);
+
/* just for vertex paint. */
bool SCULPT_pbvh_calc_area_normal(const struct Brush *brush,
Object *ob,
More information about the Bf-blender-cvs
mailing list