[Bf-blender-cvs] [356cede] master: Sculpt: change behavior of crease brush

Campbell Barton noreply at git.blender.org
Wed Apr 15 07:29:01 CEST 2015


Commit: 356ceded279b190bfca801afe25323efadd40571
Author: Campbell Barton
Date:   Wed Apr 15 15:22:37 2015 +1000
Branches: master
https://developer.blender.org/rB356ceded279b190bfca801afe25323efadd40571

Sculpt: change behavior of crease brush

Pinch would give a flat result on either side of the stroke,
because points were dragged towards a single point.

Now pinch is projected on the sculpt plane, which gives a tighter crease.
The reverse is true too - blob brush which shares the code is also more curved.

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

M	source/blender/editors/sculpt_paint/sculpt.c

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

diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 6ca368e..411ccef 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -1699,6 +1699,16 @@ static void do_crease_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod
 	float brush_alpha;
 	int n;
 
+	/* vars for handling projection when calculating the pinch vector.
+	 * Use surface normal for 'v_proj',s o the vertices are pinched towards a line instead of a single point.
+	 * Without this we get a 'flat' surface surrounding the pinch */
+	const float  *pinch_proj = ss->cache->sculpt_normal_symm;
+	const float   pinch_proj_len_sq = len_squared_v3(pinch_proj);
+	const bool do_pinch_proj = (pinch_proj_len_sq > FLT_EPSILON);
+	/* simplifies projection calc below */
+	const float pinch_proj_len_sq_inv_neg = do_pinch_proj ? -1.0f / pinch_proj_len_sq : 0.0f;
+
+
 	/* offset with as much as possible factored in already */
 	mul_v3_v3fl(offset, ss->cache->sculpt_normal_symm, ss->cache->radius);
 	mul_v3_v3(offset, ss->cache->scale);
@@ -1739,6 +1749,15 @@ static void do_crease_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod
 				sub_v3_v3v3(val1, test.location, vd.co);
 				mul_v3_fl(val1, fade * flippedbstrength);
 
+				if (do_pinch_proj) {
+#if 0
+					project_plane_v3_v3v3(val1, val1, v_proj);
+#else
+					/* inline the projection, cache `-1.0 / dot_v3_v3(v_proj, v_proj)` */
+					madd_v3_v3fl(val1, pinch_proj, dot_v3v3(val1, pinch_proj) * pinch_proj_len_sq_inv_neg);
+#endif
+				}
+
 				/* then we draw */
 				mul_v3_v3fl(val2, offset, fade);




More information about the Bf-blender-cvs mailing list