From a2c5c2b4068d12e26a8c9d640a389b410c7507f3 Mon Sep 17 00:00:00 2001 From: YimingWu Date: Wed, 15 Sep 2021 14:24:28 +0800 Subject: GPencil: Dot dash modifier. Create dot-dash effect for grease pencil strokes. User can manually edit the length, gap and styles for each segment of dashed lines. The values in each segment can all be key-framed to make animations. Reviewed By: Hans Goudey (HooglyBoogly), Antonio Vazquez (antoniov) Differential Revision: http://developer.blender.org/D11876 --- .../makesdna/DNA_gpencil_modifier_defaults.h | 18 ++++++++++++ .../blender/makesdna/DNA_gpencil_modifier_types.h | 34 ++++++++++++++++++++++ source/blender/makesdna/intern/dna_defaults.c | 4 +++ 3 files changed, 56 insertions(+) (limited to 'source/blender/makesdna') diff --git a/source/blender/makesdna/DNA_gpencil_modifier_defaults.h b/source/blender/makesdna/DNA_gpencil_modifier_defaults.h index 8ab15b97537..450527c7443 100644 --- a/source/blender/makesdna/DNA_gpencil_modifier_defaults.h +++ b/source/blender/makesdna/DNA_gpencil_modifier_defaults.h @@ -319,5 +319,23 @@ .material = NULL,\ } +#define _DNA_DEFAULT_DashGpencilModifierData \ + { \ + .dash_offset = 0, \ + .segments = NULL, \ + .segments_len = 1, \ + .segment_active_index = 0, \ + } + +#define _DNA_DEFAULT_DashGpencilModifierSegment \ + { \ + .name = "", \ + .dash = 2, \ + .gap = 1, \ + .radius = 1.0f, \ + .opacity = 1.0f, \ + .mat_nr = -1, \ + } + /* clang-format off */ diff --git a/source/blender/makesdna/DNA_gpencil_modifier_types.h b/source/blender/makesdna/DNA_gpencil_modifier_types.h index c91afa58cb1..d3429329ef6 100644 --- a/source/blender/makesdna/DNA_gpencil_modifier_types.h +++ b/source/blender/makesdna/DNA_gpencil_modifier_types.h @@ -56,6 +56,7 @@ typedef enum GpencilModifierType { eGpencilModifierType_Lineart = 19, eGpencilModifierType_Length = 20, eGpencilModifierType_Weight = 21, + eGpencilModifierType_Dash = 22, /* Keep last. */ NUM_GREASEPENCIL_MODIFIER_TYPES, } GpencilModifierType; @@ -507,6 +508,39 @@ typedef enum eLengthGpencil_Type { GP_LENGTH_ABSOLUTE = 1, } eLengthGpencil_Type; +typedef struct DashGpencilModifierSegment { + char name[64]; + /* For path reference. */ + struct DashGpencilModifierData *dmd; + int dash; + int gap; + float radius; + float opacity; + int mat_nr; + int _pad; +} DashGpencilModifierSegment; + +typedef struct DashGpencilModifierData { + GpencilModifierData modifier; + /** Material for filtering. */ + struct Material *material; + /** Layer name. */ + char layername[64]; + /** Custom index for passes. */ + int pass_index; + /** Flags. */ + int flag; + /** Custom index for passes. */ + int layer_pass; + + int dash_offset; + + DashGpencilModifierSegment *segments; + int segments_len; + int segment_active_index; + +} DashGpencilModifierData; + typedef struct MirrorGpencilModifierData { GpencilModifierData modifier; struct Object *object; diff --git a/source/blender/makesdna/intern/dna_defaults.c b/source/blender/makesdna/intern/dna_defaults.c index 3570f5a6a6f..4cb8610f6ac 100644 --- a/source/blender/makesdna/intern/dna_defaults.c +++ b/source/blender/makesdna/intern/dna_defaults.c @@ -321,6 +321,8 @@ SDNA_DEFAULT_DECL_STRUCT(TintGpencilModifierData); SDNA_DEFAULT_DECL_STRUCT(WeightGpencilModifierData); SDNA_DEFAULT_DECL_STRUCT(LineartGpencilModifierData); SDNA_DEFAULT_DECL_STRUCT(LengthGpencilModifierData); +SDNA_DEFAULT_DECL_STRUCT(DashGpencilModifierData); +SDNA_DEFAULT_DECL_STRUCT(DashGpencilModifierSegment); #undef SDNA_DEFAULT_DECL_STRUCT @@ -549,6 +551,8 @@ const void *DNA_default_table[SDNA_TYPE_MAX] = { SDNA_DEFAULT_DECL(WeightGpencilModifierData), SDNA_DEFAULT_DECL(LineartGpencilModifierData), SDNA_DEFAULT_DECL(LengthGpencilModifierData), + SDNA_DEFAULT_DECL(DashGpencilModifierData), + SDNA_DEFAULT_DECL(DashGpencilModifierSegment), }; #undef SDNA_DEFAULT_DECL #undef SDNA_DEFAULT_DECL_EX -- cgit v1.2.3