diff options
author | Joseph Eagar <joeedh@gmail.com> | 2022-03-29 08:54:24 +0300 |
---|---|---|
committer | Joseph Eagar <joeedh@gmail.com> | 2022-03-29 08:54:24 +0300 |
commit | 176b331c43c5378b0a346b7c96b0934c9c5bf19f (patch) | |
tree | 546efd965d57bfa16945c2ef1ab664b2a3667471 /source/blender/gpencil_modifiers/intern/MOD_gpencildash.c | |
parent | 2f3ace40240797100161a659a12d995e1480b91b (diff) | |
parent | 540bfbbb27966b4b8affeaa273a70beac9373b23 (diff) |
Merge branch 'master' into temp-sculpt-colors
Diffstat (limited to 'source/blender/gpencil_modifiers/intern/MOD_gpencildash.c')
-rw-r--r-- | source/blender/gpencil_modifiers/intern/MOD_gpencildash.c | 36 |
1 files changed, 27 insertions, 9 deletions
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencildash.c b/source/blender/gpencil_modifiers/intern/MOD_gpencildash.c index 439073752da..e57b9df03f5 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencildash.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencildash.c @@ -97,12 +97,13 @@ static bool stroke_dash(const bGPDstroke *gps, int new_stroke_offset = 0; int trim_start = 0; + int sequence_length = 0; for (int i = 0; i < dmd->segments_len; i++) { - if (dmd->segments[i].dash + real_gap(&dmd->segments[i]) < 1) { - BLI_assert_unreachable(); - /* This means there's a part that doesn't have any length, can't do dot-dash. */ - return false; - } + sequence_length += dmd->segments[i].dash + real_gap(&dmd->segments[i]); + } + if (sequence_length < 1) { + /* This means the whole segment has no length, can't do dot-dash. */ + return false; } const DashGpencilModifierSegment *const first_segment = &dmd->segments[0]; @@ -147,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]; @@ -204,9 +208,10 @@ static void apply_dash_for_frame( dmd->flag & GP_LENGTH_INVERT_PASS, dmd->flag & GP_LENGTH_INVERT_LAYERPASS, dmd->flag & GP_LENGTH_INVERT_MATERIAL)) { - stroke_dash(gps, dmd, &result); - BLI_remlink(&gpf->strokes, gps); - BKE_gpencil_free_stroke(gps); + if (stroke_dash(gps, dmd, &result)) { + BLI_remlink(&gpf->strokes, gps); + BKE_gpencil_free_stroke(gps); + } } } bGPDstroke *gps_dash; @@ -232,6 +237,18 @@ static void bakeModifier(Main *UNUSED(bmain), /* -------------------------------- */ +static bool isDisabled(GpencilModifierData *md, int UNUSED(userRenderParams)) +{ + DashGpencilModifierData *dmd = (DashGpencilModifierData *)md; + + int sequence_length = 0; + for (int i = 0; i < dmd->segments_len; i++) { + sequence_length += dmd->segments[i].dash + real_gap(&dmd->segments[i]); + } + /* This means the whole segment has no length, can't do dot-dash. */ + return sequence_length < 1; +} + /* Generic "generateStrokes" callback */ static void generateStrokes(GpencilModifierData *md, Depsgraph *depsgraph, Object *ob) { @@ -323,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); @@ -362,7 +380,7 @@ GpencilModifierTypeInfo modifierType_Gpencil_Dash = { /* initData */ initData, /* freeData */ freeData, - /* isDisabled */ NULL, + /* isDisabled */ isDisabled, /* updateDepsgraph */ NULL, /* dependsOnTime */ NULL, /* foreachIDLink */ foreachIDLink, |