[Bf-blender-cvs] [54aefbf789b] greasepencil-object: Cleanup: Various small issues noticed earlier

Joshua Leung noreply at git.blender.org
Wed Dec 13 10:10:29 CET 2017


Commit: 54aefbf789b9199896b55ef535663d80384735a1
Author: Joshua Leung
Date:   Wed Dec 13 21:56:47 2017 +1300
Branches: greasepencil-object
https://developer.blender.org/rB54aefbf789b9199896b55ef535663d80384735a1

Cleanup: Various small issues noticed earlier

* Rename BKE_get_falloff_factor() to BKE_gpencil_multiframe_falloff_calc()
  and make it return value instead of passing in a pointer to fill.

* Rename "gso->falloff" to "gso->mf_falloff" to be less ambiguous

* Fix indentation issues in gpencil_brush.c

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

M	source/blender/blenkernel/BKE_gpencil.h
M	source/blender/blenkernel/intern/gpencil.c
M	source/blender/editors/gpencil/gpencil_brush.c

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

diff --git a/source/blender/blenkernel/BKE_gpencil.h b/source/blender/blenkernel/BKE_gpencil.h
index b139230f31e..af2bf4ad8b1 100644
--- a/source/blender/blenkernel/BKE_gpencil.h
+++ b/source/blender/blenkernel/BKE_gpencil.h
@@ -218,6 +218,6 @@ bool BKE_gp_smooth_stroke_strength(struct bGPDstroke *gps, int i, float inf);
 bool BKE_gp_smooth_stroke_thickness(struct bGPDstroke *gps, int i, float inf);
 
 void BKE_gp_get_range_selected(struct bGPDlayer *gpl, int *r_initframe, int *r_endframe);
-void BKE_get_falloff_factor(struct bGPDframe *gpf, int actnum, int f_init, int f_end, struct CurveMapping *cur_falloff, float *r_value);
+float BKE_gpencil_multiframe_falloff_calc(struct bGPDframe *gpf, int actnum, int f_init, int f_end, struct CurveMapping *cur_falloff);
 
 #endif /*  __BKE_GPENCIL_H__ */
diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index 6dcc7b684cb..77f43f7b3f0 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -2575,22 +2575,26 @@ void BKE_gp_get_range_selected(bGPDlayer *gpl, int *r_initframe, int *r_endframe
 * \param f_end        Number of last selected frame
 * \param cur_falloff  Curve with falloff factors
 */
-void BKE_get_falloff_factor(bGPDframe *gpf, int actnum, int f_init, int f_end, CurveMapping *cur_falloff, float *r_value)
+float BKE_gpencil_multiframe_falloff_calc(bGPDframe *gpf, int actnum, int f_init, int f_end, CurveMapping *cur_falloff)
 {
 	float fnum = 0.5f; /* default mid curve */
+	float value;
+	
 	/* frames to the right of the active frame */
 	if (gpf->framenum < actnum) {
 		fnum = (float)(gpf->framenum - f_init) / (actnum - f_init);
 		fnum *= 0.5f;
-		*r_value = curvemapping_evaluateF(cur_falloff, 0, fnum);
+		value = curvemapping_evaluateF(cur_falloff, 0, fnum);
 	}
 	/* frames to the left of the active frame */
 	else if (gpf->framenum > actnum) {
 		fnum = (float)(gpf->framenum - actnum) / (f_end - actnum);
 		fnum *= 0.5f;
-		*r_value = curvemapping_evaluateF(cur_falloff, 0, fnum + 0.5f);
+		value = curvemapping_evaluateF(cur_falloff, 0, fnum + 0.5f);
 	}
 	else {
-		*r_value = 1.0f;
+		value = 1.0f;
 	}
+	
+	return value;
 }
diff --git a/source/blender/editors/gpencil/gpencil_brush.c b/source/blender/editors/gpencil/gpencil_brush.c
index da0fccc3dbf..2af9aca9939 100644
--- a/source/blender/editors/gpencil/gpencil_brush.c
+++ b/source/blender/editors/gpencil/gpencil_brush.c
@@ -129,6 +129,13 @@ typedef struct tGP_BrushEditData {
 	/* - effect vector (e.g. 2D/3D translation for grab brush) */
 	float dvec[3];
 	
+	/* - multiframe falloff factor */
+	float mf_falloff;
+	
+	/* active vertex group */
+	int vrgroup;
+	
+	
 	/* brush geometry (bounding box) */
 	rcti brush_rect;
 	
@@ -142,8 +149,6 @@ typedef struct tGP_BrushEditData {
 	/* Timer for in-place accumulation of brush effect */
 	wmTimer *timer;
 	bool timerTick; /* is this event from a timer */
-	int vrgroup;    /* active vertex group */
-	float falloff;  /* multiframe falloff factor */
 } tGP_BrushEditData;
 
 
@@ -246,9 +251,10 @@ static float gp_brush_influence_calc(tGP_BrushEditData *gso, const int radius, c
 		
 		influence *= fac;
 	}
+	
 	/* apply multiframe falloff */
-	influence *= gso->falloff;
-
+	influence *= gso->mf_falloff;
+	
 	/* return influence */
 	return influence;
 }
@@ -1461,7 +1467,7 @@ static bool gpsculpt_brush_apply_standard(bContext *C, tGP_BrushEditData *gso)
 		/* init multiframe falloff options */
 		int f_init = 0;
 		int f_end = 0;
-		gso->falloff = 1.0f;
+		gso->mf_falloff = 1.0f;
 
 		bGPDframe *init_gpf = gpl->actframe;
 		if ((is_multiedit) && (gpl->actframe)){
@@ -1478,10 +1484,10 @@ static bool gpsculpt_brush_apply_standard(bContext *C, tGP_BrushEditData *gso)
 				
 				/* compute multiframe falloff factor*/
 				if ((is_multiedit) && (ts->gp_sculpt.flag & GP_BRUSHEDIT_FLAG_FRAME_FALLOFF)) {
-					BKE_get_falloff_factor(gpf, gpl->actframe->framenum, 
-											f_init, f_end, 
-											ts->gp_sculpt.cur_falloff, 
-											&gso->falloff);
+					gso->mf_falloff = BKE_gpencil_multiframe_falloff_calc(
+					                    gpf, gpl->actframe->framenum,
+					                    f_init, f_end,
+					                    ts->gp_sculpt.cur_falloff);
 				}
 
 				/* calculate difference matrix */
@@ -1519,9 +1525,9 @@ static bool gpsculpt_brush_apply_standard(bContext *C, tGP_BrushEditData *gso)
 						{
 							if (gso->first) {
 								/* First time this brush stroke is being applied:
-							 * 1) Prepare data buffers (init/clear) for this stroke
-							 * 2) Use the points now under the cursor
-							 */
+								 * 1) Prepare data buffers (init/clear) for this stroke
+								 * 2) Use the points now under the cursor
+								 */
 								gp_brush_grab_stroke_init(gso, gps);
 								changed |= gpsculpt_brush_do_stroke(gso, gps, diff_mat, gp_brush_grab_store_points);
 							}



More information about the Bf-blender-cvs mailing list