GPencil: Rename Fill closure methods

The new names are:

* Radius
* Extend

The mode Radius + Extend has been removed.

Also, some code cleanup and format.
This commit is contained in:
Antonio Vazquez 2022-09-16 11:06:44 +02:00
parent 468f2ccc0e
commit 172b0ebe6a
4 changed files with 24 additions and 51 deletions

View File

@ -199,10 +199,8 @@ static void gpencil_delete_temp_stroke_extension(tGPDfill *tgpf, const bool all_
for (bGPDframe *gpf = init_gpf; gpf; gpf = gpf->next) {
LISTBASE_FOREACH_MUTABLE (bGPDstroke *, gps, &gpf->strokes) {
/* free stroke */
if (
(gps->flag & GP_STROKE_NOFILL) &&
(gps->flag & GP_STROKE_TAG || gps->flag & GP_STROKE_HELP))
{
if ((gps->flag & GP_STROKE_NOFILL) &&
(gps->flag & GP_STROKE_TAG || gps->flag & GP_STROKE_HELP)) {
BLI_remlink(&gpf->strokes, gps);
BKE_gpencil_free_stroke(gps);
}
@ -214,11 +212,8 @@ static void gpencil_delete_temp_stroke_extension(tGPDfill *tgpf, const bool all_
}
}
static bool extended_bbox_overlap(float min1[3],
float max1[3],
float min2[3],
float max2[3],
float extend)
static bool extended_bbox_overlap(
float min1[3], float max1[3], float min2[3], float max2[3], float extend)
{
for (int axis = 0; axis < 3; axis++) {
float intersection_min = max_ff(min1[axis], min2[axis]) - extend;
@ -230,10 +225,7 @@ static bool extended_bbox_overlap(float min1[3],
return true;
}
static void add_stroke_extension(bGPDframe *gpf,
bGPDstroke *gps,
float p1[3],
float p2[3])
static void add_stroke_extension(bGPDframe *gpf, bGPDstroke *gps, float p1[3], float p2[3])
{
bGPDstroke *gps_new = BKE_gpencil_stroke_new(gps->mat_nr, 2, gps->thickness);
gps_new->flag |= GP_STROKE_NOFILL | GP_STROKE_TAG;
@ -355,7 +347,7 @@ static void gpencil_create_extensions(tGPDfill *tgpf)
d2 = normalize_v3(tan2);
total_length += d2;
if (i > 1) {
if (tgpf->fill_extend_mode == GP_FILL_EMODE_CIRCLES) {
if (tgpf->fill_extend_mode == GP_FILL_EMODE_RADIUS) {
continue;
}
float curvature[3];
@ -390,7 +382,7 @@ static void gpencil_create_extensions(tGPDfill *tgpf)
}
}
if (tgpf->fill_extend_mode != GP_FILL_EMODE_CIRCLES) {
if (tgpf->fill_extend_mode != GP_FILL_EMODE_RADIUS) {
/* Extend start. */
bGPDspoint *pt0 = &gps->points[1];
bGPDspoint *pt1 = &gps->points[0];
@ -427,7 +419,7 @@ static void gpencil_create_extensions(tGPDfill *tgpf)
}
/* Connect endpoints within a radius */
if (tgpf->fill_extend_mode == GP_FILL_EMODE_LINES) {
if (tgpf->fill_extend_mode == GP_FILL_EMODE_EXTEND) {
continue;
}
float *stroke1_start = &gps->points[0].x;
@ -436,16 +428,13 @@ static void gpencil_create_extensions(tGPDfill *tgpf)
* isn't already so short that it's within that distance
*/
if (len_v3v3(stroke1_start, stroke1_end) < connection_dist &&
total_length > connection_dist)
{
total_length > connection_dist) {
add_stroke_extension(gpf, gps, stroke1_start, stroke1_end);
BLI_gset_add(connected_endpoints, stroke1_start);
BLI_gset_add(connected_endpoints, stroke1_end);
}
for (bGPDstroke *gps2 = (bGPDstroke *)(((Link *)gps)->next);
gps2 != NULL;
gps2 = (bGPDstroke *)(((Link *)gps2)->next))
{
for (bGPDstroke *gps2 = (bGPDstroke *)(((Link *)gps)->next); gps2 != NULL;
gps2 = (bGPDstroke *)(((Link *)gps2)->next)) {
/* Don't check distance to temporary extensions. */
if ((gps2->flag & GP_STROKE_NOFILL) && (gps2->flag & GP_STROKE_TAG)) {
continue;
@ -551,8 +540,8 @@ static void gpencil_draw_basic_stroke(tGPDfill *tgpf,
float col[4];
const float extend_col[4] = {0.0f, 1.0f, 1.0f, 1.0f};
const float help_col[4] = {1.0f, 0.0f, 0.5f, 1.0f};
const bool is_extend =
(gps->flag & GP_STROKE_NOFILL) && (gps->flag & GP_STROKE_TAG) && !(gps->flag & GP_STROKE_HELP);
const bool is_extend = (gps->flag & GP_STROKE_NOFILL) && (gps->flag & GP_STROKE_TAG) &&
!(gps->flag & GP_STROKE_HELP);
const bool is_help = gps->flag & GP_STROKE_HELP;
if (!gpencil_stroke_is_drawable(tgpf, gps)) {
@ -562,12 +551,14 @@ static void gpencil_draw_basic_stroke(tGPDfill *tgpf,
if (is_help && tgpf->is_render) {
/* Help strokes are for display only and shouldn't render */
return;
} else if (is_help) {
}
else if (is_help) {
/* Color help strokes that won't affect fill or render separately from
* extended strokes, as they will affect them */
copy_v4_v4(col, help_col);
col[3] = (gps->flag & GP_STROKE_TAG) ? 0.5f : 0.1f;
} else if ((is_extend) && (!tgpf->is_render)) {
}
else if ((is_extend) && (!tgpf->is_render)) {
copy_v4_v4(col, extend_col);
}
else {
@ -786,8 +777,7 @@ static void gpencil_draw_datablock(tGPDfill *tgpf, const float ink[4])
/* Normal strokes. */
if (ELEM(tgpf->fill_draw_mode, GP_FILL_DMODE_STROKE, GP_FILL_DMODE_BOTH)) {
if (gpencil_stroke_is_drawable(tgpf, gps) &&
((gps->flag & GP_STROKE_TAG) == 0) &&
if (gpencil_stroke_is_drawable(tgpf, gps) && ((gps->flag & GP_STROKE_TAG) == 0) &&
((gps->flag & GP_STROKE_HELP) == 0)) {
ED_gpencil_draw_fill(&tgpw);
}

View File

@ -127,9 +127,8 @@ typedef enum eGP_FillDrawModes {
/* BrushGpencilSettings->fill_extend_mode */
typedef enum eGP_FillExtendModes {
GP_FILL_EMODE_LINES_AND_CIRCLES = 0,
GP_FILL_EMODE_LINES = 1,
GP_FILL_EMODE_CIRCLES = 2,
GP_FILL_EMODE_RADIUS = 0,
GP_FILL_EMODE_EXTEND = 1,
} eGP_FillExtendModes;
/* BrushGpencilSettings->fill_layer_mode */

View File

@ -70,7 +70,7 @@ typedef struct BrushGpencilSettings {
int fill_simplylvl;
/** Type of control lines drawing mode. */
int fill_draw_mode;
/** Type of gap filling to use */
/** Type of gap filling extension to use. */
int fill_extend_mode;
/** Icon identifier. */
int icon_id;

View File

@ -287,22 +287,8 @@ static EnumPropertyItem rna_enum_gpencil_fill_draw_modes_items[] = {
{0, NULL, 0, NULL, NULL}};
static EnumPropertyItem rna_enum_gpencil_fill_extend_modes_items[] = {
{GP_FILL_EMODE_LINES,
"LINES",
0,
"Line",
"Extend strokes in straight lines"},
{
GP_FILL_EMODE_CIRCLES,
"CIRCLES",
0,
"Circle",
"Connect endpoints that are close together"},
{GP_FILL_EMODE_LINES_AND_CIRCLES,
"LINES_AND_CIRCLES",
0,
"Line & Circle",
"Extend strokes and connect close endpoints"},
{GP_FILL_EMODE_RADIUS, "RADIUS", 0, "Radius", "Connect endpoints that are close together"},
{GP_FILL_EMODE_EXTEND, "EXTEND", 0, "Extend", "Extend strokes in straight lines"},
{0, NULL, 0, NULL, NULL}};
static EnumPropertyItem rna_enum_gpencil_fill_layers_modes_items[] = {
@ -1671,9 +1657,7 @@ static void rna_def_gpencil_options(BlenderRNA *brna)
RNA_def_property_enum_sdna(prop, NULL, "fill_extend_mode");
RNA_def_property_enum_items(prop, rna_enum_gpencil_fill_extend_modes_items);
RNA_def_property_ui_text(
prop,
"Gap Closure",
"Types of stroke extensions used for closing gaps");
prop, "Gap Closure", "Types of stroke extensions used for closing gaps");
RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
/* Number of pixels to dilate fill area. Negative values contract the filled area. */