[Bf-blender-cvs] [36e732c] master: Sculpt brush can now grab inwards w/ normal weight

Campbell Barton noreply at git.blender.org
Mon Feb 22 19:13:15 CET 2016


Commit: 36e732c89f93660f016f52ab9abcefa50dcd182d
Author: Campbell Barton
Date:   Tue Feb 23 05:04:32 2016 +1100
Branches: master
https://developer.blender.org/rB36e732c89f93660f016f52ab9abcefa50dcd182d

Sculpt brush can now grab inwards w/ normal weight

Previously the grab brush could only move ourwards when normal aligned.

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

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 245724f..1625971 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -2203,16 +2203,25 @@ static void do_grab_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
 	SculptSession *ss = ob->sculpt;
 	Brush *brush = BKE_paint_brush(&sd->paint);
 	float grab_delta[3];
-	float len;
 
 	copy_v3_v3(grab_delta, ss->cache->grab_delta_symmetry);
 
-	len = len_v3(grab_delta);
-
 	if (brush->normal_weight > 0) {
-		mul_v3_fl(ss->cache->sculpt_normal_symm, len * brush->normal_weight);
+		/* signed to support grabbing in (to make a hole) as well as out. */
+		const float len_signed = dot_v3v3(ss->cache->sculpt_normal_symm, ss->cache->grab_delta_symmetry);
+
+		/* this scale effectively projects the offset so dragging follows the cursor,
+		 * as the normal points towards the view, the scale increases. */
+		float len_view_scale;
+		{
+			float view_aligned_normal[3];
+			project_plane_v3_v3v3(view_aligned_normal, ss->cache->sculpt_normal_symm, ss->cache->view_normal);
+			len_view_scale = fabsf(dot_v3v3(view_aligned_normal, ss->cache->sculpt_normal_symm));
+			len_view_scale = (len_view_scale > FLT_EPSILON) ? 1.0f / len_view_scale : 1.0f;
+		}
+
 		mul_v3_fl(grab_delta, 1.0f - brush->normal_weight);
-		add_v3_v3(grab_delta, ss->cache->sculpt_normal_symm);
+		madd_v3_v3fl(grab_delta, ss->cache->sculpt_normal_symm, (len_signed * brush->normal_weight) * len_view_scale);
 	}
 
 	SculptThreadedTaskData data = {




More information about the Bf-blender-cvs mailing list