GPencil: lower bounds for gap in dot dash modifier
This patch maximizes the possible bounds for the dash and gap parameters in the dot dash modifier. This makes e.g. chopping up lines without gaps possible. Differential Revision: http://developer.blender.org/D14428
This commit is contained in:
parent
bc290b47cd
commit
8d4244691a
|
@ -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];
|
||||
|
@ -204,9 +205,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 +234,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)
|
||||
{
|
||||
|
@ -362,7 +376,7 @@ GpencilModifierTypeInfo modifierType_Gpencil_Dash = {
|
|||
|
||||
/* initData */ initData,
|
||||
/* freeData */ freeData,
|
||||
/* isDisabled */ NULL,
|
||||
/* isDisabled */ isDisabled,
|
||||
/* updateDepsgraph */ NULL,
|
||||
/* dependsOnTime */ NULL,
|
||||
/* foreachIDLink */ foreachIDLink,
|
||||
|
|
|
@ -3676,7 +3676,7 @@ static void rna_def_modifier_gpencildash(BlenderRNA *brna)
|
|||
RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
|
||||
|
||||
prop = RNA_def_property(srna, "gap", PROP_INT, PROP_NONE);
|
||||
RNA_def_property_range(prop, 1, INT16_MAX);
|
||||
RNA_def_property_range(prop, 0, INT16_MAX);
|
||||
RNA_def_property_ui_text(prop, "Gap", "The number of points skipped after this segment");
|
||||
RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
|
||||
|
||||
|
|
Loading…
Reference in New Issue