[Bf-blender-cvs] [b6a4a8d5cda] temp-lineart-embree: GPencil: Cyclic flag for dot dash modifier

YimingWu noreply at git.blender.org
Sat Mar 26 17:10:56 CET 2022


Commit: b6a4a8d5cda19add89c9830edb6b8c673a2cc191
Author: YimingWu
Date:   Fri Mar 25 20:13:04 2022 +0800
Branches: temp-lineart-embree
https://developer.blender.org/rBb6a4a8d5cda19add89c9830edb6b8c673a2cc191

GPencil: Cyclic flag for dot dash modifier

Cyclic option per segment, allows interesting "loop" visual effects.

Reviewed by: Antonio Vazquez (antoniov)

Differential Revision: https://developer.blender.org/D14439

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

M	source/blender/gpencil_modifiers/intern/MOD_gpencildash.c
M	source/blender/makesdna/DNA_gpencil_modifier_types.h
M	source/blender/makesrna/intern/rna_gpencil_modifier.c

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

diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencildash.c b/source/blender/gpencil_modifiers/intern/MOD_gpencildash.c
index 25c7fdca9f6..e57b9df03f5 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencildash.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencildash.c
@@ -148,6 +148,9 @@ static bool stroke_dash(const bGPDstroke *gps,
 
     bGPDstroke *stroke = BKE_gpencil_stroke_new(
         ds->mat_nr < 0 ? gps->mat_nr : ds->mat_nr, size, gps->thickness);
+    if (ds->flag & GP_DASH_USE_CYCLIC) {
+      stroke->flag |= GP_STROKE_CYCLIC;
+    }
 
     for (int is = 0; is < size; is++) {
       bGPDspoint *p = &gps->points[new_stroke_offset + is];
@@ -337,6 +340,7 @@ static void panel_draw(const bContext *C, Panel *panel)
     uiItemR(sub, &ds_ptr, "radius", 0, NULL, ICON_NONE);
     uiItemR(sub, &ds_ptr, "opacity", 0, NULL, ICON_NONE);
     uiItemR(sub, &ds_ptr, "material_index", 0, NULL, ICON_NONE);
+    uiItemR(sub, &ds_ptr, "use_cyclic", 0, NULL, ICON_NONE);
   }
 
   gpencil_modifier_panel_end(layout, ptr);
diff --git a/source/blender/makesdna/DNA_gpencil_modifier_types.h b/source/blender/makesdna/DNA_gpencil_modifier_types.h
index 4f655e87a09..7568dc5ff9a 100644
--- a/source/blender/makesdna/DNA_gpencil_modifier_types.h
+++ b/source/blender/makesdna/DNA_gpencil_modifier_types.h
@@ -522,7 +522,7 @@ typedef struct DashGpencilModifierSegment {
   float radius;
   float opacity;
   int mat_nr;
-  int _pad;
+  int flag;
 } DashGpencilModifierSegment;
 
 typedef struct DashGpencilModifierData {
@@ -546,6 +546,14 @@ typedef struct DashGpencilModifierData {
 
 } DashGpencilModifierData;
 
+typedef enum eDashGpencil_Flag {
+  GP_DASH_INVERT_LAYER = (1 << 0),
+  GP_DASH_INVERT_PASS = (1 << 1),
+  GP_DASH_INVERT_LAYERPASS = (1 << 2),
+  GP_DASH_INVERT_MATERIAL = (1 << 3),
+  GP_DASH_USE_CYCLIC = (1 << 7),
+} eDashGpencil_Flag;
+
 typedef struct MirrorGpencilModifierData {
   GpencilModifierData modifier;
   struct Object *object;
diff --git a/source/blender/makesrna/intern/rna_gpencil_modifier.c b/source/blender/makesrna/intern/rna_gpencil_modifier.c
index bf3f506251c..9e25ddaf790 100644
--- a/source/blender/makesrna/intern/rna_gpencil_modifier.c
+++ b/source/blender/makesrna/intern/rna_gpencil_modifier.c
@@ -3743,6 +3743,11 @@ static void rna_def_modifier_gpencildash(BlenderRNA *brna)
       "Use this index on generated segment. -1 means using the existing material");
   RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
 
+  prop = RNA_def_property(srna, "use_cyclic", PROP_BOOLEAN, PROP_NONE);
+  RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_DASH_USE_CYCLIC);
+  RNA_def_property_ui_text(prop, "Use Cyclic", "Enable cyclic on individual stroke dashes");
+  RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
+
   srna = RNA_def_struct(brna, "DashGpencilModifierData", "GpencilModifier");
   RNA_def_struct_ui_text(srna, "Dash Modifier", "Create dot-dash effect for strokes");
   RNA_def_struct_sdna(srna, "DashGpencilModifierData");
@@ -3794,17 +3799,17 @@ static void rna_def_modifier_gpencildash(BlenderRNA *brna)
   RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
 
   prop = RNA_def_property(srna, "invert_layers", PROP_BOOLEAN, PROP_NONE);
-  RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LENGTH_INVERT_LAYER);
+  RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_DASH_INVERT_LAYER);
   RNA_def_property_ui_text(prop, "Inverse Layers", "Inverse filter");
   RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
 
   prop = RNA_def_property(srna, "invert_materials", PROP_BOOLEAN, PROP_NONE);
-  RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LENGTH_INVERT_MATERIAL);
+  RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_DASH_INVERT_MATERIAL);
   RNA_def_property_ui_text(prop, "Inverse Materials", "Inverse filter");
   RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
 
   prop = RNA_def_property(srna, "invert_material_pass", PROP_BOOLEAN, PROP_NONE);
-  RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LENGTH_INVERT_PASS);
+  RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_DASH_INVERT_PASS);
   RNA_def_property_ui_text(prop, "Inverse Pass", "Inverse filter");
   RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
 
@@ -3815,7 +3820,7 @@ static void rna_def_modifier_gpencildash(BlenderRNA *brna)
   RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
 
   prop = RNA_def_property(srna, "invert_layer_pass", PROP_BOOLEAN, PROP_NONE);
-  RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LENGTH_INVERT_LAYERPASS);
+  RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_DASH_INVERT_LAYERPASS);
   RNA_def_property_ui_text(prop, "Inverse Pass", "Inverse filter");
   RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");



More information about the Bf-blender-cvs mailing list