[Bf-blender-cvs] [49e304c] GPencil_Editing_Stage3: GPencil Sculpt: "Push" Brush

Joshua Leung noreply at git.blender.org
Fri Jul 10 15:42:29 CEST 2015


Commit: 49e304c15500578f72e111a8f0a499f4f37a3fb8
Author: Joshua Leung
Date:   Sat Jul 11 01:39:43 2015 +1200
Branches: GPencil_Editing_Stage3
https://developer.blender.org/rB49e304c15500578f72e111a8f0a499f4f37a3fb8

GPencil Sculpt: "Push" Brush

This is similar to the grab brush in that it translates points according to
the strength of the brush. The difference however is that it is applied instead
to whatever points are under the brush as it travels, instead of only those
that were within the brush region initially.

Notes:
* The effect of this brush is more like a "smear" effect
* I got a crash initially, but haven't been able to reproduce. So, unless this
  crops up again, I'll consider that a one-off for now.

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

M	source/blender/editors/gpencil/gpencil_brush.c

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

diff --git a/source/blender/editors/gpencil/gpencil_brush.c b/source/blender/editors/gpencil/gpencil_brush.c
index dceec41..9b985a6 100644
--- a/source/blender/editors/gpencil/gpencil_brush.c
+++ b/source/blender/editors/gpencil/gpencil_brush.c
@@ -450,6 +450,28 @@ static void gp_brush_grab_stroke_free(void *ptr)
 	MEM_freeN(data);
 }
 
+/* ----------------------------------------------- */
+/* Push Brush */
+/* NOTE: Depends on gp_brush_grab_calc_dvec() */
+
+static bool gp_brush_push_apply(tGP_BrushEditData *gso, bGPDstroke *gps, int i,
+                                const int radius, const int co[2])
+{
+	bGPDspoint *pt = gps->points + i;
+	float inf = gp_brush_influence_calc(gso, radius, co);
+	float delta[3] = {0.0f};
+		
+	/* adjust the amount of displacement to apply */
+	mul_v3_v3fl(delta, gso->dvec, inf);
+	
+	/* apply */
+	add_v3_v3(&pt->x, delta);
+
+	/* done */
+	return true;
+}
+
+
 /* ************************************************ */
 /* Cursor drawing */
 
@@ -707,6 +729,7 @@ static void gpsculpt_brush_apply(bContext *C, wmOperator *op, PointerRNA *itempt
 	/* Calculate brush-specific data which applies equally to all points */
 	switch (gso->brush_type) {
 		case GP_EDITBRUSH_TYPE_GRAB: /* Grab points */
+		case GP_EDITBRUSH_TYPE_PUSH: /* Push points */
 		{
 			/* calculate amount of displacement to apply */
 			gp_brush_grab_calc_dvec(gso);
@@ -752,6 +775,12 @@ static void gpsculpt_brush_apply(bContext *C, wmOperator *op, PointerRNA *itempt
 			}
 			break;
 			
+			case GP_EDITBRUSH_TYPE_PUSH: /* Push points */
+			{
+				changed |= gpsculpt_brush_do_stroke(gso, gps, gp_brush_push_apply);
+			}
+			break;
+			
 			case GP_EDITBRUSH_TYPE_RANDOMISE: /* Apply jitter */
 			{
 				//changed |= gpsculpt_brush_do_stroke(gso, gps, apply);




More information about the Bf-blender-cvs mailing list