Commit: 130d52206405266d44477d81c22608a872f3e0ed
Author: Antonio Vazquez
Date:   Tue Aug 29 16:10:08 2017 +0200
Branches: greasepencil-object
https://developer.blender.org/rB130d52206405266d44477d81c22608a872f3e0ed

MultiEdit in Sculpt Mode

Allow to use Multi Edit in Sculpt mode. Now the brushes can be applied to 
several frames.

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

M       release/scripts/startup/bl_ui/space_view3d.py
M       source/blender/editors/gpencil/gpencil_brush.c
M       source/blender/editors/include/ED_gpencil.h

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

diff --git a/release/scripts/startup/bl_ui/space_view3d.py 
b/release/scripts/startup/bl_ui/space_view3d.py
index 28895e53530..40958f3e626 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -164,7 +164,6 @@ class VIEW3D_HT_header(Header):
                 row.prop(context.tool_settings.gpencil_sculpt, 
"use_select_mask")
                 row.prop(context.tool_settings.gpencil_sculpt, 
"selection_alpha", slider=True)
 
-            if context.gpencil_data.use_stroke_edit_mode:
                 gpd = context.gpencil_data
                 row = layout.row()
                 row.prop(gpd, "multiedit", text="Multi Edit", 
icon="FORCE_HARMONIC")
diff --git a/source/blender/editors/gpencil/gpencil_brush.c 
b/source/blender/editors/gpencil/gpencil_brush.c
index b8efb3c3acf..e6f10d9326a 100644
--- a/source/blender/editors/gpencil/gpencil_brush.c
+++ b/source/blender/editors/gpencil/gpencil_brush.c
@@ -1442,101 +1442,104 @@ static bool gpsculpt_brush_apply_standard(bContext 
*C, tGP_BrushEditData *gso)
        float diff_mat[4][4];
        Object *obact = CTX_data_active_object(C);     
        bGPdata *gpd = gso->gpd;
+       bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd);
 
        CTX_DATA_BEGIN(C, bGPDlayer *, gpl, editable_gpencil_layers)
        {
-               bGPDframe *gpf = gpl->actframe;
-               if (gpf == NULL)
-                       continue;
-               
-               /* calculate difference matrix */
-               ED_gpencil_parent_location(obact, gpd, gpl, diff_mat);
-               
-               for (bGPDstroke *gps = gpf->strokes.first; gps; gps = 
gps->next) {
-                       /* skip strokes that are invalid for current view */
-                       if (ED_gpencil_stroke_can_use(C, gps) == false)
-                               continue;
-                       /* check if the color is editable */
-                       if (ED_gpencil_stroke_color_use(gpl, gps) == false) {
-                               continue;
-                       }
+               for (bGPDframe *gpf = gpl->frames.first; gpf; gpf = gpf->next) {
+                       if ((gpf == gpl->actframe) || ((gpf->flag & 
GP_FRAME_SELECT) && (is_multiedit))) {
+
+                               /* calculate difference matrix */
+                               ED_gpencil_parent_location(obact, gpd, gpl, 
diff_mat);
+
+                               for (bGPDstroke *gps = gpf->strokes.first; gps; 
gps = gps->next) {
+                                       /* skip strokes that are invalid for 
current view */
+                                       if (ED_gpencil_stroke_can_use(C, gps) 
== false)
+                                               continue;
+                                       /* check if the color is editable */
+                                       if (ED_gpencil_stroke_color_use(gpl, 
gps) == false) {
+                                               continue;
+                                       }
 
-                       switch (gso->brush_type) {
-                               case GP_EDITBRUSH_TYPE_SMOOTH: /* Smooth 
strokes */
-                               {
-                                       changed |= 
gpsculpt_brush_do_stroke(gso, gps, diff_mat, gp_brush_smooth_apply);
-                                       break;
-                               }
+                                       switch (gso->brush_type) {
+                                       case GP_EDITBRUSH_TYPE_SMOOTH: /* 
Smooth strokes */
+                                       {
+                                               changed |= 
gpsculpt_brush_do_stroke(gso, gps, diff_mat, gp_brush_smooth_apply);
+                                               break;
+                                       }
 
-                               case GP_EDITBRUSH_TYPE_THICKNESS: /* Adjust 
stroke thickness */
-                               {
-                                       changed |= 
gpsculpt_brush_do_stroke(gso, gps, diff_mat, gp_brush_thickness_apply);
-                                       break;
-                               }
+                                       case GP_EDITBRUSH_TYPE_THICKNESS: /* 
Adjust stroke thickness */
+                                       {
+                                               changed |= 
gpsculpt_brush_do_stroke(gso, gps, diff_mat, gp_brush_thickness_apply);
+                                               break;
+                                       }
 
-                               case GP_EDITBRUSH_TYPE_STRENGTH: /* Adjust 
stroke color strength */
-                               {
-                                       changed |= 
gpsculpt_brush_do_stroke(gso, gps, diff_mat, gp_brush_strength_apply);
-                                       break;
-                               }
+                                       case GP_EDITBRUSH_TYPE_STRENGTH: /* 
Adjust stroke color strength */
+                                       {
+                                               changed |= 
gpsculpt_brush_do_stroke(gso, gps, diff_mat, gp_brush_strength_apply);
+                                               break;
+                                       }
 
-                               case GP_EDITBRUSH_TYPE_GRAB: /* Grab points */
-                               {
-                                       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
-                                                */
-                                               gp_brush_grab_stroke_init(gso, 
gps);
-                                               changed |= 
gpsculpt_brush_do_stroke(gso, gps, diff_mat, gp_brush_grab_store_points);
+                                       case GP_EDITBRUSH_TYPE_GRAB: /* Grab 
points */
+                                       {
+                                               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
+                                                        */
+                                                       
gp_brush_grab_stroke_init(gso, gps);
+                                                       changed |= 
gpsculpt_brush_do_stroke(gso, gps, diff_mat, gp_brush_grab_store_points);
+                                               }
+                                               else {
+                                                       /* Apply effect to the 
stored points */
+                                                       
gp_brush_grab_apply_cached(gso, gps, diff_mat);
+                                                       changed |= true;
+                                               }
+                                               break;
                                        }
-                                       else {
-                                               /* Apply effect to the stored 
points */
-                                               gp_brush_grab_apply_cached(gso, 
gps, diff_mat);
-                                               changed |= true;
+
+                                       case GP_EDITBRUSH_TYPE_PUSH: /* Push 
points */
+                                       {
+                                               changed |= 
gpsculpt_brush_do_stroke(gso, gps, diff_mat, gp_brush_push_apply);
+                                               break;
                                        }
-                                       break;
-                               }
 
-                               case GP_EDITBRUSH_TYPE_PUSH: /* Push points */
-                               {
-                                       changed |= 
gpsculpt_brush_do_stroke(gso, gps, diff_mat, gp_brush_push_apply);
-                                       break;
-                               }
+                                       case GP_EDITBRUSH_TYPE_PINCH: /* Pinch 
points */
+                                       {
+                                               changed |= 
gpsculpt_brush_do_stroke(gso, gps, diff_mat, gp_brush_pinch_apply);
+                                               break;
+                                       }
 
-                               case GP_EDITBRUSH_TYPE_PINCH: /* Pinch points */
-                               {
-                                       changed |= 
gpsculpt_brush_do_stroke(gso, gps, diff_mat, gp_brush_pinch_apply);
-                                       break;
-                               }
+                                       case GP_EDITBRUSH_TYPE_TWIST: /* Twist 
points around midpoint */
+                                       {
+                                               changed |= 
gpsculpt_brush_do_stroke(gso, gps, diff_mat, gp_brush_twist_apply);
+                                               break;
+                                       }
 
-                               case GP_EDITBRUSH_TYPE_TWIST: /* Twist points 
around midpoint */
-                               {
-                                       changed |= 
gpsculpt_brush_do_stroke(gso, gps, diff_mat, gp_brush_twist_apply);
-                                       break;
-                               }
+                                       case GP_EDITBRUSH_TYPE_RANDOMIZE: /* 
Apply jitter */
+                                       {
+                                               changed |= 
gpsculpt_brush_do_stroke(gso, gps, diff_mat, gp_brush_randomize_apply);
+                                               break;
+                                       }
 
-                               case GP_EDITBRUSH_TYPE_RANDOMIZE: /* Apply 
jitter */
-                               {
-                                       changed |= 
gpsculpt_brush_do_stroke(gso, gps, diff_mat, gp_brush_randomize_apply);
-                                       break;
-                               }
+                                       case GP_EDITBRUSH_TYPE_WEIGHT: /* 
Adjust vertex group weight */
+                                       {
+                                               changed |= 
gpsculpt_brush_do_stroke(gso, gps, diff_mat, gp_brush_weight_apply);
+                                               break;
+                                       }
 
-                               case GP_EDITBRUSH_TYPE_WEIGHT: /* Adjust vertex 
group weight */
-                               {
-                                       changed |= 
gpsculpt_brush_do_stroke(gso, gps, diff_mat, gp_brush_weight_apply);
-                                       break;
-                               }
 
+                                       default:
+                                               printf("ERROR: Unknown type of 
GPencil Sculpt brush - %u\n", gso->brush_type);
+                                               break;
+                                       }
+                                       /* Triangulation must be calculated if 
changed */
+                                       if (changed) {
+                                               gps->flag |= 
GP_STROKE_RECALC_CACHES;
+                                               gps->tot_triangles = 0;
+                                       }
+                               }
 
-                               default:
-                                       printf("ERROR: Unknown type of GPencil 
Sculpt brush - %u\n", gso->brush_type);
-                                       break;
-                       }
-                       /* Triangulation must be calculated if changed */
-                       if (changed) {
-                               gps->flag |= GP_STROKE_RECALC_CACHES;
-                               gps->tot_triangles = 0;
                        }
                }
        }
diff --git a/source/blender/editors/include/ED_gpencil.h 
b/source/blender/editors/include/ED_gpencil.h
index de626ff76bf..9bd2ee23194 100644
--- a/source/blender/editors/include/ED_gpencil.h
+++ b/source/blender/editors/include/ED_gpencil.h
@@ -113,7 +113,7 @@ typedef struct tGPencilSort {
 #define GPENCIL_SKETCH_SESSIONS_ON(scene) 
((scene)->toolsettings->gpencil_flags & GP_TOOL_FLAG_PAINTSESSIONS_ON)
 
 /* Check if 'multiedit sessions' is enabled */
-#define GPENCIL_MULTIEDIT_SESSIONS_ON(gpd) ((gpd) && (gpd->flag & 
GP_DATA_STROKE_EDITMODE) && (gpd->flag & GP_DATA_STROKE_MULTIEDIT)) 
+#define GPENCIL_MULTIEDIT_SESSIONS_ON(gpd) ((gpd) && (gpd->flag & 
(GP_DATA_STROKE_EDITMODE | GP_DATA_STROKE_SCULPTMODE)) && (gpd->flag & 
GP_DATA_STROKE_MULTIEDIT)) 
 
 /* ----------- Grease Pencil Tools/Context ------------- */

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to