[Bf-blender-cvs] [809fc4807a5] greasepencil-object: Make falloff function external to reuse
Antonio Vazquez
noreply at git.blender.org
Fri Dec 1 17:27:58 CET 2017
Commit: 809fc4807a582bf6614592a3f774ac096235d146
Author: Antonio Vazquez
Date: Fri Dec 1 17:27:51 2017 +0100
Branches: greasepencil-object
https://developer.blender.org/rB809fc4807a582bf6614592a3f774ac096235d146
Make falloff function external to reuse
Move the calculation of falloff factor to a separated function to be reused in transformations.
===================================================================
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 5ea2c92b5b5..65783df1345 100644
--- a/source/blender/blenkernel/BKE_gpencil.h
+++ b/source/blender/blenkernel/BKE_gpencil.h
@@ -31,6 +31,7 @@
* \author Joshua Leung
*/
+struct CurveMapping;
struct bContext;
struct EvaluationContext;
struct ToolSettings;
@@ -216,5 +217,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);
#endif /* __BKE_GPENCIL_H__ */
diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index 977fcf61147..f08adbb7b96 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -2486,4 +2486,31 @@ void BKE_gp_get_range_selected(bGPDlayer *gpl, int *r_initframe, int *r_endframe
}
}
}
+}
+/**
+* Get Falloff factor base on frame range
+* \param gpf Frame
+* \param actnum Number of active frame in layer
+* \param f_init Number of first selected frame
+* \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 fnum = 0.5f; /* default mid curve */
+ /* 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);
+ }
+ /* 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);
+ }
+ else {
+ *r_value = 1.0f;
+ }
}
\ No newline at end of file
diff --git a/source/blender/editors/gpencil/gpencil_brush.c b/source/blender/editors/gpencil/gpencil_brush.c
index cc81d99fac7..da0fccc3dbf 100644
--- a/source/blender/editors/gpencil/gpencil_brush.c
+++ b/source/blender/editors/gpencil/gpencil_brush.c
@@ -1478,22 +1478,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)) {
- float fnum = 0.5f; /* default mid curve */
- /* frames to the right of the active frame */
- if (gpf->framenum < gpl->actframe->framenum) {
- fnum = (float)(gpf->framenum - f_init) / (gpl->actframe->framenum - f_init);
- fnum *= 0.5f;
- gso->falloff = curvemapping_evaluateF(ts->gp_sculpt.cur_falloff, 0, fnum);
- }
- /* frames to the left of the active frame */
- else if (gpf->framenum > gpl->actframe->framenum) {
- fnum = (float)(gpf->framenum - gpl->actframe->framenum) / (f_end - gpl->actframe->framenum);
- fnum *= 0.5f;
- gso->falloff = curvemapping_evaluateF(ts->gp_sculpt.cur_falloff, 0, fnum + 0.5f);
- }
- else {
- gso->falloff = 1.0f;
- }
+ BKE_get_falloff_factor(gpf, gpl->actframe->framenum,
+ f_init, f_end,
+ ts->gp_sculpt.cur_falloff,
+ &gso->falloff);
}
/* calculate difference matrix */
More information about the Bf-blender-cvs
mailing list