[Bf-blender-cvs] [7ce68ff9108] greasepencil-object: WIP: Save falloff factor for transformations

Antonio Vazquez noreply at git.blender.org
Fri Jan 5 17:27:44 CET 2018


Commit: 7ce68ff91088b1d283bf4fc0b53e4645a79167cf
Author: Antonio Vazquez
Date:   Fri Jan 5 10:48:28 2018 +0100
Branches: greasepencil-object
https://developer.blender.org/rB7ce68ff91088b1d283bf4fc0b53e4645a79167cf

WIP: Save falloff factor for transformations

This data must be used by transformation to determine the effect of the change.

Also enabled the falloff option for edit mode.

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

M	release/scripts/startup/bl_ui/properties_grease_pencil_common.py
M	release/scripts/startup/bl_ui/space_view3d.py
M	source/blender/editors/transform/transform_conversions.c
M	source/blender/makesdna/DNA_gpencil_types.h

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

diff --git a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
index 67a85e6535f..3989d12c2ff 100644
--- a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
+++ b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
@@ -578,7 +578,7 @@ class GreasePencilMultiFramePanel:
         if context.editable_gpencil_strokes:
             is_3d_view = context.space_data.type == 'VIEW_3D'
             if is_3d_view:
-                return bool(gpd.is_stroke_sculpt_mode or gpd.is_stroke_weight_mode)
+                return bool(gpd.use_stroke_edit_mode or gpd.is_stroke_sculpt_mode or gpd.is_stroke_weight_mode)
 
         return False
 
diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index 37968767fd0..f593808ba28 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -174,7 +174,7 @@ class VIEW3D_HT_header(Header):
                 row.prop(gpd, "show_edit_lines", text="", icon="PARTICLE_POINT")
                 row.prop(gpd, "use_multiedit", text="Multi Frame", icon="FORCE_HARMONIC")
                 col = row.column()
-                col.enabled = gpd.use_multiedit and gpd.is_stroke_sculpt_mode
+                col.enabled = gpd.use_multiedit and (gpd.is_stroke_sculpt_mode or gpd.use_stroke_edit_mode)
                 col.prop(settings, "use_multiframe_falloff", text="", icon="SMOOTHCURVE")
                 col = row.column()
                 col.enabled = gpd.use_multiedit
diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c
index fd945e58f32..04b3d8a85f4 100644
--- a/source/blender/editors/transform/transform_conversions.c
+++ b/source/blender/editors/transform/transform_conversions.c
@@ -91,6 +91,7 @@
 #include "BKE_editmesh.h"
 #include "BKE_tracking.h"
 #include "BKE_mask.h"
+#include "BKE_colortools.h"
 
 #include "BIK_api.h"
 
@@ -7828,7 +7829,11 @@ void flushTransPaintCurve(TransInfo *t)
 static void createTransGPencil(bContext *C, TransInfo *t)
 {
 	bGPdata *gpd = ED_gpencil_data_get_active(C);
+	ToolSettings *ts = CTX_data_tool_settings(C);
+
 	bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd);
+	bool use_multiframe_falloff = (ts->gp_sculpt.flag & GP_BRUSHEDIT_FLAG_FRAME_FALLOFF) != 0;
+
 	Object *obact = CTX_data_active_object(C);
 	bGPDlayer *gpl;
 	TransData *td = NULL;
@@ -7854,6 +7859,11 @@ static void createTransGPencil(bContext *C, TransInfo *t)
 	if (gpd == NULL)
 		return;
 	
+	/* initialize falloff curve */
+	if (is_multiedit) {
+		curvemapping_initialize(ts->gp_sculpt.cur_falloff);
+	}
+
 	/* First Pass: Count the number of datapoints required for the strokes, 
 	 * (and additional info about the configuration - e.g. 2D/3D?)
 	 */
@@ -7941,6 +7951,13 @@ static void createTransGPencil(bContext *C, TransInfo *t)
 			if (is_multiedit) {
 				init_gpf = gpl->frames.first;
 			}
+			/* init multiframe falloff options */
+			int f_init = 0;
+			int f_end = 0;
+
+			if (use_multiframe_falloff) {
+				BKE_gp_get_range_selected(gpl, &f_init, &f_end);
+			}
 
 			/* calculate difference matrix */
 			ED_gpencil_parent_location(obact, gpd, gpl, diff_mat);
@@ -7966,6 +7983,15 @@ static void createTransGPencil(bContext *C, TransInfo *t)
 			/* Loop over strokes, adding TransData for points as needed... */
 			for (gpf = init_gpf; gpf; gpf = gpf->next) {
 				if ((gpf == gpl->actframe) || ((gpf->flag & GP_FRAME_SELECT) && (is_multiedit))) {
+
+					/* if multiframe and falloff, recalculate and save value */
+					float falloff = 1.0f; /* by default no falloff */
+					if ((is_multiedit) && (use_multiframe_falloff)) {
+						/* Faloff depends on distance to active frame (relative to the overall frame range) */
+						falloff = BKE_gpencil_multiframe_falloff_calc(gpf, gpl->actframe->framenum,
+							f_init, f_end, ts->gp_sculpt.cur_falloff);
+					}
+
 					for (gps = gpf->strokes.first; gps; gps = gps->next) {
 						TransData *head = td;
 						TransData *tail = td;
@@ -8009,6 +8035,8 @@ static void createTransGPencil(bContext *C, TransInfo *t)
 								madd_v3_v3v3fl(center, center, &pt->x, ninv);
 							}
 #endif
+							/* save falloff factor */
+							gps->falloff = falloff;
 
 							/* add all necessary points... */
 							for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
@@ -8089,7 +8117,6 @@ static void createTransGPencil(bContext *C, TransInfo *t)
 	}
 }
 
-
 void createTransData(bContext *C, TransInfo *t)
 {
 	Scene *scene = t->scene;
diff --git a/source/blender/makesdna/DNA_gpencil_types.h b/source/blender/makesdna/DNA_gpencil_types.h
index 0d76bb12ef1..dc9cc6f3c26 100644
--- a/source/blender/makesdna/DNA_gpencil_types.h
+++ b/source/blender/makesdna/DNA_gpencil_types.h
@@ -252,6 +252,9 @@ typedef struct bGPDstroke {
 	
 	/* temporary layer name only used during copy/paste to put the stroke in the original layer */
 	char tmp_layerinfo[128];
+
+	float falloff;          /* runtime falloff factor (only for transform) */
+	char pad1[4];
 } bGPDstroke;
 
 /* bGPDstroke->flag */



More information about the Bf-blender-cvs mailing list